@object-ui/plugin-chatbot 11.5.0 → 13.2.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 +53 -0
- package/dist/ChatbotEnhanced.d.ts +19 -1
- package/dist/ChatbotEnhanced.d.ts.map +1 -1
- package/dist/elements/prompt-input.d.ts +15 -9
- package/dist/elements/prompt-input.d.ts.map +1 -1
- package/dist/index.js +178 -156
- package/dist/index.umd.cjs +1 -1
- package/dist/mapMessages.d.ts +20 -0
- package/dist/mapMessages.d.ts.map +1 -1
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -996,10 +996,12 @@ var er = ({ className: e, from: t, ...n }) => /* @__PURE__ */ Q("div", {
|
|
|
996
996
|
currentBranch: i,
|
|
997
997
|
totalBranches: o.length,
|
|
998
998
|
goToPrevious: () => {
|
|
999
|
-
|
|
999
|
+
let e = i > 0 ? i - 1 : o.length - 1;
|
|
1000
|
+
c(e);
|
|
1000
1001
|
},
|
|
1001
1002
|
goToNext: () => {
|
|
1002
|
-
|
|
1003
|
+
let e = i < o.length - 1 ? i + 1 : 0;
|
|
1004
|
+
c(e);
|
|
1003
1005
|
},
|
|
1004
1006
|
branches: o,
|
|
1005
1007
|
setBranches: s
|
|
@@ -1202,7 +1204,8 @@ function Or({ initialInput: e = "", children: t }) {
|
|
|
1202
1204
|
type: "file",
|
|
1203
1205
|
url: URL.createObjectURL(e),
|
|
1204
1206
|
mediaType: e.type,
|
|
1205
|
-
filename: e.name
|
|
1207
|
+
filename: e.name,
|
|
1208
|
+
file: e
|
|
1206
1209
|
}))));
|
|
1207
1210
|
}, []), h = o((e) => {
|
|
1208
1211
|
s((t) => {
|
|
@@ -1391,7 +1394,8 @@ var Nr = ({ label: e = "Add photos or files", ...t }) => {
|
|
|
1391
1394
|
type: "file",
|
|
1392
1395
|
url: URL.createObjectURL(e),
|
|
1393
1396
|
mediaType: e.type,
|
|
1394
|
-
filename: e.name
|
|
1397
|
+
filename: e.name,
|
|
1398
|
+
file: e
|
|
1395
1399
|
});
|
|
1396
1400
|
return e.concat(i);
|
|
1397
1401
|
});
|
|
@@ -2018,10 +2022,14 @@ function Vi(e) {
|
|
|
2018
2022
|
}
|
|
2019
2023
|
}
|
|
2020
2024
|
function Hi(e) {
|
|
2021
|
-
let t =
|
|
2022
|
-
return t === "
|
|
2025
|
+
let t = Vt(e)?.status;
|
|
2026
|
+
return t === "changes_proposed" || t === "blueprint_proposed" || t === "awaiting_confirmation";
|
|
2023
2027
|
}
|
|
2024
2028
|
function Ui(e) {
|
|
2029
|
+
let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available");
|
|
2030
|
+
return t === "output-error" || t === "output-denied" ? "failed" : t === "approval-requested" || t === "approval-responded" ? "awaiting" : t === "output-available" ? Hi(e.result) ? "awaiting" : "completed" : "running";
|
|
2031
|
+
}
|
|
2032
|
+
function Wi(e) {
|
|
2025
2033
|
return [
|
|
2026
2034
|
{
|
|
2027
2035
|
create_object: "新建对象",
|
|
@@ -2037,13 +2045,13 @@ function Ui(e) {
|
|
|
2037
2045
|
e.details
|
|
2038
2046
|
].filter(Boolean).join(" ");
|
|
2039
2047
|
}
|
|
2040
|
-
function
|
|
2048
|
+
function Gi(e) {
|
|
2041
2049
|
return e.toolName === "propose_blueprint";
|
|
2042
2050
|
}
|
|
2043
|
-
function
|
|
2044
|
-
return
|
|
2051
|
+
function Ki(e) {
|
|
2052
|
+
return Gi(e) && Ui(e) === "completed" && !e.proposedPlan && !e.proposedChanges && !e.draftReview?.items.length;
|
|
2045
2053
|
}
|
|
2046
|
-
var
|
|
2054
|
+
var qi = [
|
|
2047
2055
|
"待补",
|
|
2048
2056
|
"后续",
|
|
2049
2057
|
"将在",
|
|
@@ -2069,25 +2077,25 @@ var Ki = [
|
|
|
2069
2077
|
"coming soon",
|
|
2070
2078
|
"tbd"
|
|
2071
2079
|
];
|
|
2072
|
-
function
|
|
2080
|
+
function Ji(e) {
|
|
2073
2081
|
let t = [], n = [];
|
|
2074
2082
|
for (let r of e) {
|
|
2075
2083
|
if (typeof r != "string") continue;
|
|
2076
2084
|
let e = r.trim();
|
|
2077
2085
|
if (!e) continue;
|
|
2078
2086
|
let i = e.toLowerCase();
|
|
2079
|
-
|
|
2087
|
+
qi.some((e) => i.includes(e)) ? n.push(e) : t.push(e);
|
|
2080
2088
|
}
|
|
2081
2089
|
return {
|
|
2082
2090
|
designNotes: t,
|
|
2083
2091
|
deferred: n
|
|
2084
2092
|
};
|
|
2085
2093
|
}
|
|
2086
|
-
function Ji(e) {
|
|
2087
|
-
let t = Hi(e);
|
|
2088
|
-
return t === "awaiting" || t === "failed" || !!e.pendingActionId || !!e.draftReview?.items.length || !!e.proposedPlan || !!e.proposedChanges || Gi(e);
|
|
2089
|
-
}
|
|
2090
2094
|
function Yi(e) {
|
|
2095
|
+
let t = Ui(e);
|
|
2096
|
+
return t === "awaiting" || t === "failed" || !!e.pendingActionId || !!e.draftReview?.items.length || !!e.proposedPlan || !!e.proposedChanges || Ki(e);
|
|
2097
|
+
}
|
|
2098
|
+
function Xi(e) {
|
|
2091
2099
|
switch (e) {
|
|
2092
2100
|
case "failed": return 4;
|
|
2093
2101
|
case "awaiting": return 3;
|
|
@@ -2095,10 +2103,13 @@ function Yi(e) {
|
|
|
2095
2103
|
case "completed": return 1;
|
|
2096
2104
|
}
|
|
2097
2105
|
}
|
|
2098
|
-
function
|
|
2106
|
+
function Zi(e) {
|
|
2107
|
+
return /^\((?:called [^)]*|tool call|no content)\)$/.test(e.trim());
|
|
2108
|
+
}
|
|
2109
|
+
function Qi(e) {
|
|
2099
2110
|
let t = /* @__PURE__ */ new Map();
|
|
2100
2111
|
for (let n of e) {
|
|
2101
|
-
let e =
|
|
2112
|
+
let e = Ui(n), r = `${n.toolName}:${e}`, i = t.get(r);
|
|
2102
2113
|
if (i) {
|
|
2103
2114
|
i.count += 1, i.errorText = i.errorText ?? n.errorText;
|
|
2104
2115
|
continue;
|
|
@@ -2113,11 +2124,11 @@ function Xi(e) {
|
|
|
2113
2124
|
});
|
|
2114
2125
|
}
|
|
2115
2126
|
return Array.from(t.values()).sort((e, t) => {
|
|
2116
|
-
let n =
|
|
2127
|
+
let n = Xi(t.state) - Xi(e.state);
|
|
2117
2128
|
return n === 0 ? e.title.localeCompare(t.title) : n;
|
|
2118
2129
|
});
|
|
2119
2130
|
}
|
|
2120
|
-
function
|
|
2131
|
+
function $i({ health: e }) {
|
|
2121
2132
|
if (!e) return null;
|
|
2122
2133
|
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 = [];
|
|
2123
2134
|
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) {
|
|
@@ -2147,7 +2158,7 @@ function Zi({ health: e }) {
|
|
|
2147
2158
|
]
|
|
2148
2159
|
});
|
|
2149
2160
|
}
|
|
2150
|
-
var
|
|
2161
|
+
var ea = 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 = 10 * 1024 * 1024, suggestions: T, labels: E, models: D, selectedModelId: O, onModelChange: k, headerSlot: A, promptOverlaySlot: j, onInputChange: M, onToolApprove: N, toolApproveLabel: P = "Approve", toolDenyLabel: F = "Deny", toolDenyReason: I = "User denied the operation", toolDecisions: L, onReviewDraft: ee, toolReviewLabel: te = (e) => `Review ${e} change${e === 1 ? "" : "s"}`, onPublishDrafts: R, onOpenBuiltApp: ne, openBuiltAppLabel: re = "Open app", onPreviewDraftApp: z, previewDraftLabel: ie = "Preview", onDraftArtifacts: B, onBuildMaterialized: ae, publishDraftsLabel: V = "Publish", publishedLabel: oe = "Published", verifiedLabel: se = "Verified", nextStepsLabel: ce = "What's next", planTitleLabel: le = "Proposed plan", planExtendLabel: ue = "Adding to existing app", planQuestionsLabel: de = "Confirm before building", planAssumptionsLabel: fe = "Assumptions", planDeferredLabel: pe = "Not yet built", planApproveHintLabel: me = "Reply to approve or adjust this plan.", planApproveLabel: he = "Build it", planAdjustLabel: ge = "Adjust", planBuiltLabel: _e = "Built", planReadyLabel: ve = "The plan is ready. Build it now, or tell me what to adjust.", planApproveMessage: ye = "Looks good — build it as proposed.", planApproveDefaultsMessage: be = "Build it with your best assumptions; use sensible defaults for the open questions.", planAnswerMessage: xe = (e, t) => `For "${e}", go with: ${t}.`, fetchPendingDraftCount: H, autoPublishDrafts: U = !1, processVisibility: W = "summary", surface: Se = "card", ...Ce }, we) => {
|
|
2151
2162
|
let G = d ? "streaming" : "ready", K = Se === "plain", [Te, Ee] = e.useState(null), De = e.useRef(""), Oe = e.useRef(null), J = e.useMemo(() => ({
|
|
2152
2163
|
emptyTitle: E?.emptyTitle ?? "Start a conversation",
|
|
2153
2164
|
emptyDescription: E?.emptyDescription ?? "Ask anything — the assistant has access to your current app context.",
|
|
@@ -2174,7 +2185,7 @@ var Qi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2174
2185
|
connectionStalledLabel: E?.connectionStalledLabel ?? "Still working…",
|
|
2175
2186
|
connectionOfflineLabel: E?.connectionOfflineLabel ?? "Connection lost — reconnecting…",
|
|
2176
2187
|
designingPlanLabel: E?.designingPlanLabel ?? "Designing your app…",
|
|
2177
|
-
designingPlanHints: E?.designingPlanHints ??
|
|
2188
|
+
designingPlanHints: E?.designingPlanHints ?? la
|
|
2178
2189
|
}), [E]), [Ae, je] = e.useState(() => /* @__PURE__ */ new Set()), [Ne, Fe] = e.useState(() => /* @__PURE__ */ new Map()), [Ie, Le] = e.useState(() => /* @__PURE__ */ new Map()), Re = e.useRef(/* @__PURE__ */ new Set()), ze = e.useCallback(async (e) => {
|
|
2179
2190
|
if (H) try {
|
|
2180
2191
|
let t = await H(e);
|
|
@@ -2304,7 +2315,7 @@ var Qi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2304
2315
|
navigator.clipboard?.writeText(e.content), Ee(e.id), window.setTimeout(() => Ee((t) => t === e.id ? null : t), 1500);
|
|
2305
2316
|
}, []), it = e.useMemo(() => {
|
|
2306
2317
|
let e = /* @__PURE__ */ new Set(), t = [], r = -1, i = 0;
|
|
2307
|
-
for (let e of n) for (let n of e.toolInvocations ?? []) (n.proposedPlan ||
|
|
2318
|
+
for (let e of n) for (let n of e.toolInvocations ?? []) (n.proposedPlan || Ki(n)) && n.toolCallId && t.push({
|
|
2308
2319
|
id: n.toolCallId,
|
|
2309
2320
|
order: i
|
|
2310
2321
|
}), n.toolName === "apply_blueprint" && (r = i), i += 1;
|
|
@@ -2323,7 +2334,7 @@ var Qi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2323
2334
|
}
|
|
2324
2335
|
return e;
|
|
2325
2336
|
}, [n]), ot = (e) => {
|
|
2326
|
-
let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available"), n = `tool-${e.toolName}`, r = L?.[e.toolCallId], a = t === "approval-requested" && !!N && !r, o = t === "approval-requested" && !!e.pendingActionId, s = zn(e.toolName), c = Bn(e.result), l = W === "debug" && s && s.toLowerCase() !== e.toolName.toLowerCase(), u = W === "debug" || a, d = e.draftReview?.packageId, f = d === void 0 ? void 0 : Ie.get(d), p = f === void 0 ? Ae.has(e.toolCallId) : f === 0, m = t === "input-streaming" || t === "input-available", h = /* @__PURE__ */ $("span", {
|
|
2337
|
+
let t = e.state ?? (e.errorText ? "output-error" : e.result === void 0 ? "input-available" : "output-available"), n = `tool-${e.toolName}`, r = L?.[e.toolCallId], a = t === "approval-requested" && !!N && !r, o = t === "approval-requested" && !!e.pendingActionId, s = zn(e.toolName), c = Bn(e.result), l = W === "debug" && s && s.toLowerCase() !== e.toolName.toLowerCase(), u = W === "debug" || a, d = e.draftReview?.packageId, f = d === void 0 ? void 0 : Ie.get(d), p = f === void 0 ? Ae.has(e.toolCallId) : f === 0, m = t === "input-streaming" || t === "input-available", h = t === "output-available" && Hi(e.result) ? "approval-requested" : t, g = /* @__PURE__ */ $("span", {
|
|
2327
2338
|
className: "inline-flex min-w-0 items-center gap-2",
|
|
2328
2339
|
children: [
|
|
2329
2340
|
/* @__PURE__ */ Q("span", { children: s || e.toolName }),
|
|
@@ -2331,22 +2342,22 @@ var Qi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2331
2342
|
className: "rounded bg-muted px-1 py-px text-[10px] font-mono text-muted-foreground",
|
|
2332
2343
|
children: e.toolName
|
|
2333
2344
|
}) : null,
|
|
2334
|
-
m ?
|
|
2345
|
+
m ? Gi(e) ? /* @__PURE__ */ Q(fa, {
|
|
2335
2346
|
label: J.designingPlanLabel,
|
|
2336
2347
|
hints: J.designingPlanHints,
|
|
2337
2348
|
offlineLabel: J.connectionOfflineLabel
|
|
2338
|
-
}) : /* @__PURE__ */ Q(
|
|
2349
|
+
}) : /* @__PURE__ */ Q(pa, { offlineLabel: J.connectionOfflineLabel }) : null
|
|
2339
2350
|
]
|
|
2340
2351
|
});
|
|
2341
2352
|
return /* @__PURE__ */ $(bi, {
|
|
2342
|
-
defaultOpen: t === "output-error" || t === "approval-requested" || !!(e.draftReview && e.draftReview.items.length > 0) || !!e.proposedPlan || !!e.proposedChanges ||
|
|
2353
|
+
defaultOpen: t === "output-error" || t === "approval-requested" || !!(e.draftReview && e.draftReview.items.length > 0) || !!e.proposedPlan || !!e.proposedChanges || Ki(e),
|
|
2343
2354
|
children: [/* @__PURE__ */ Q(Si, {
|
|
2344
2355
|
type: n,
|
|
2345
|
-
state:
|
|
2346
|
-
title:
|
|
2356
|
+
state: h,
|
|
2357
|
+
title: g
|
|
2347
2358
|
}), /* @__PURE__ */ $(Ci, { children: [
|
|
2348
2359
|
u && e.args !== void 0 ? /* @__PURE__ */ Q(wi, { input: e.args }) : null,
|
|
2349
|
-
o ? null : u || t === "output-error" ? /* @__PURE__ */ Q(
|
|
2360
|
+
o ? null : u || t === "output-error" ? /* @__PURE__ */ Q(Ca, {
|
|
2350
2361
|
output: c,
|
|
2351
2362
|
errorText: e.errorText
|
|
2352
2363
|
}) : null,
|
|
@@ -2438,7 +2449,7 @@ var Qi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2438
2449
|
children: [/* @__PURE__ */ Q(ke, { className: "mt-0.5 size-3.5 shrink-0" }), /* @__PURE__ */ Q("span", { children: e.message })]
|
|
2439
2450
|
}, `w${t}`))]
|
|
2440
2451
|
}) : null,
|
|
2441
|
-
Ae.has(e.toolCallId) ? /* @__PURE__ */ Q(
|
|
2452
|
+
Ae.has(e.toolCallId) ? /* @__PURE__ */ Q($i, { health: Ne.get(e.toolCallId) }) : null,
|
|
2442
2453
|
e.draftReview.nextSteps && e.draftReview.nextSteps.length > 0 ? /* @__PURE__ */ $("div", {
|
|
2443
2454
|
className: "flex flex-col gap-1 border-t bg-muted/20 px-3 py-2",
|
|
2444
2455
|
"data-testid": "draft-next-steps",
|
|
@@ -2500,7 +2511,7 @@ var Qi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2500
2511
|
}) : null;
|
|
2501
2512
|
})(),
|
|
2502
2513
|
(() => {
|
|
2503
|
-
let { designNotes: t, deferred: n } =
|
|
2514
|
+
let { designNotes: t, deferred: n } = Ji(e.proposedPlan.assumptions);
|
|
2504
2515
|
return /* @__PURE__ */ $(Z, { children: [t.length > 0 ? /* @__PURE__ */ $("div", {
|
|
2505
2516
|
className: "flex flex-col gap-0.5",
|
|
2506
2517
|
"data-testid": "proposed-plan-assumptions",
|
|
@@ -2588,7 +2599,7 @@ var Qi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2588
2599
|
})
|
|
2589
2600
|
]
|
|
2590
2601
|
}) : null,
|
|
2591
|
-
|
|
2602
|
+
Ki(e) ? /* @__PURE__ */ $("div", {
|
|
2592
2603
|
className: "flex flex-col gap-2 border-t bg-muted/20 px-3 py-2.5",
|
|
2593
2604
|
"data-testid": "proposed-plan-fallback",
|
|
2594
2605
|
children: [
|
|
@@ -2646,7 +2657,7 @@ var Qi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2646
2657
|
className: "flex flex-col gap-1",
|
|
2647
2658
|
children: e.proposedChanges.changes.map((e, t) => /* @__PURE__ */ $("div", {
|
|
2648
2659
|
className: "flex items-start gap-1.5 rounded-md border bg-background px-2 py-1 text-[11px] text-foreground/80",
|
|
2649
|
-
children: [/* @__PURE__ */ Q(mt, { className: "mt-px size-3 shrink-0 text-foreground/40" }), /* @__PURE__ */ Q("span", { children:
|
|
2660
|
+
children: [/* @__PURE__ */ Q(mt, { className: "mt-px size-3 shrink-0 text-foreground/40" }), /* @__PURE__ */ Q("span", { children: Wi(e) })]
|
|
2650
2661
|
}, t))
|
|
2651
2662
|
}),
|
|
2652
2663
|
i ? at.has(e.toolCallId) ? /* @__PURE__ */ Q("div", {
|
|
@@ -2717,38 +2728,38 @@ var Qi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2717
2728
|
}) : /* @__PURE__ */ Q(Me, { className: "size-4" })
|
|
2718
2729
|
}),
|
|
2719
2730
|
/* @__PURE__ */ $("div", {
|
|
2720
|
-
className: "space-y-1",
|
|
2731
|
+
className: "w-full max-w-full space-y-1",
|
|
2721
2732
|
children: [/* @__PURE__ */ Q("h3", {
|
|
2722
|
-
className: "text-sm font-medium text-foreground/90",
|
|
2733
|
+
className: "text-sm font-medium text-foreground/90 break-words",
|
|
2723
2734
|
children: J.emptyTitle
|
|
2724
2735
|
}), /* @__PURE__ */ Q("p", {
|
|
2725
|
-
className: "text-sm text-muted-foreground",
|
|
2736
|
+
className: "text-sm text-muted-foreground break-words",
|
|
2726
2737
|
children: J.emptyDescription
|
|
2727
2738
|
})]
|
|
2728
2739
|
}),
|
|
2729
|
-
T && T.length > 0 ? /* @__PURE__ */ Q(
|
|
2730
|
-
className: "justify-center gap-2",
|
|
2740
|
+
T && T.length > 0 ? /* @__PURE__ */ Q("div", {
|
|
2741
|
+
className: "flex w-full max-w-full flex-wrap justify-center gap-2",
|
|
2731
2742
|
children: T.map((e) => /* @__PURE__ */ Q(mi, {
|
|
2732
|
-
className: "h-8 border-border/60 bg-background/80 px-3 text-xs font-medium text-foreground/90 shadow-none hover:bg-muted/60",
|
|
2743
|
+
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",
|
|
2733
2744
|
suggestion: e,
|
|
2734
2745
|
onClick: $e
|
|
2735
2746
|
}, e))
|
|
2736
2747
|
}) : null
|
|
2737
2748
|
]
|
|
2738
2749
|
}) : n.map((e) => {
|
|
2739
|
-
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 && !!e.streaming && !e.content && n.length === 0 && !r && !a && !o, l = !t && W === "summary" ? n.filter((e) => !
|
|
2750
|
+
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 && !!e.streaming && !e.content && n.length === 0 && !r && !a && !o, l = !t && W === "summary" ? n.filter((e) => !Yi(e) && !(o && e.toolName === "propose_blueprint")) : [], u = !t && W === "debug" ? n : !t && W !== "debug" ? n.filter(Yi) : [];
|
|
2740
2751
|
return /* @__PURE__ */ Q(er, {
|
|
2741
2752
|
from: Bi(e.role),
|
|
2742
2753
|
children: /* @__PURE__ */ $("div", {
|
|
2743
2754
|
className: q("flex w-full gap-2.5", m ? t ? "flex-row-reverse items-start" : "flex-row items-start" : "flex-col"),
|
|
2744
|
-
children: [m ? /* @__PURE__ */ Q(
|
|
2755
|
+
children: [m ? /* @__PURE__ */ Q(ta, {
|
|
2745
2756
|
isUser: t,
|
|
2746
2757
|
url: t ? h : _,
|
|
2747
2758
|
fallback: t ? g : v
|
|
2748
2759
|
}) : null, /* @__PURE__ */ $("div", {
|
|
2749
2760
|
className: q("flex min-w-0 flex-col gap-2", m && !t && "flex-1"),
|
|
2750
2761
|
children: [/* @__PURE__ */ $(tr, { children: [
|
|
2751
|
-
o ? /* @__PURE__ */ Q(
|
|
2762
|
+
o ? /* @__PURE__ */ Q(ga, {
|
|
2752
2763
|
progress: o,
|
|
2753
2764
|
designingLabel: J.designingPlanLabel,
|
|
2754
2765
|
extendLabel: ue,
|
|
@@ -2756,7 +2767,7 @@ var Qi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2756
2767
|
stalledLabel: J.connectionStalledLabel,
|
|
2757
2768
|
offlineLabel: J.connectionOfflineLabel
|
|
2758
2769
|
}) : null,
|
|
2759
|
-
a ? /* @__PURE__ */ Q(
|
|
2770
|
+
a ? /* @__PURE__ */ Q(_a, {
|
|
2760
2771
|
progress: a,
|
|
2761
2772
|
onOpenBuiltApp: ne,
|
|
2762
2773
|
openBuiltAppLabel: re,
|
|
@@ -2771,15 +2782,19 @@ var Qi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2771
2782
|
className: "mb-2",
|
|
2772
2783
|
children: [/* @__PURE__ */ Q(Ni, {}), /* @__PURE__ */ Q(Pi, { children: r })]
|
|
2773
2784
|
}) : null,
|
|
2774
|
-
!t && W === "summary" && l.length > 0 ? /* @__PURE__ */ Q(
|
|
2775
|
-
groups:
|
|
2785
|
+
!t && W === "summary" && l.length > 0 ? /* @__PURE__ */ Q(va, {
|
|
2786
|
+
groups: Qi(l),
|
|
2776
2787
|
labels: J
|
|
2777
2788
|
}) : null,
|
|
2778
2789
|
!t && u.length > 0 ? u.map(ot) : null,
|
|
2779
2790
|
t ? e.content ? /* @__PURE__ */ Q("div", {
|
|
2780
2791
|
className: "whitespace-pre-wrap break-words",
|
|
2781
2792
|
children: e.content
|
|
2782
|
-
}) : null : c ? /* @__PURE__ */ Q(
|
|
2793
|
+
}) : null : c ? /* @__PURE__ */ Q(ra, {}) : e.content ? Zi(e.content) ? /* @__PURE__ */ Q("span", {
|
|
2794
|
+
className: "text-xs italic text-muted-foreground/70",
|
|
2795
|
+
title: e.content,
|
|
2796
|
+
children: J.agentActivity
|
|
2797
|
+
}) : /* @__PURE__ */ Q(fr, { children: e.content }) : null,
|
|
2783
2798
|
e.streaming && !c ? /* @__PURE__ */ Q("span", {
|
|
2784
2799
|
"aria-hidden": !0,
|
|
2785
2800
|
className: "ml-0.5 inline-block w-[2px] h-4 align-middle bg-current animate-pulse"
|
|
@@ -2838,7 +2853,7 @@ var Qi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2838
2853
|
})]
|
|
2839
2854
|
})
|
|
2840
2855
|
}, e.id);
|
|
2841
|
-
}), d && !n.some((e) => e.streaming) ? /* @__PURE__ */ Q(
|
|
2856
|
+
}), d && !n.some((e) => e.streaming) ? /* @__PURE__ */ Q(na, {
|
|
2842
2857
|
showAvatar: m,
|
|
2843
2858
|
assistantAvatarUrl: _,
|
|
2844
2859
|
assistantAvatarFallback: v,
|
|
@@ -2848,11 +2863,11 @@ var Qi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2848
2863
|
}) : null]
|
|
2849
2864
|
}), /* @__PURE__ */ Q(Xn, {})]
|
|
2850
2865
|
}),
|
|
2851
|
-
f ? Wn(f) && !Un(f) ? /* @__PURE__ */ Q(
|
|
2866
|
+
f ? Wn(f) && !Un(f) ? /* @__PURE__ */ Q(xa, {
|
|
2852
2867
|
error: f,
|
|
2853
2868
|
rateLimitedLabel: J.sendFailedRateLimited,
|
|
2854
2869
|
genericLabel: J.sendFailedGeneric
|
|
2855
|
-
}) : /* @__PURE__ */ Q(
|
|
2870
|
+
}) : /* @__PURE__ */ Q(Sa, {
|
|
2856
2871
|
error: f,
|
|
2857
2872
|
onReload: s,
|
|
2858
2873
|
onUpgrade: c
|
|
@@ -2918,8 +2933,8 @@ var Qi = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
2918
2933
|
]
|
|
2919
2934
|
});
|
|
2920
2935
|
});
|
|
2921
|
-
|
|
2922
|
-
function
|
|
2936
|
+
ea.displayName = "ChatbotEnhanced";
|
|
2937
|
+
function ta({ isUser: e, url: t, fallback: n }) {
|
|
2923
2938
|
return /* @__PURE__ */ Q("div", {
|
|
2924
2939
|
className: q("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"),
|
|
2925
2940
|
"aria-hidden": "true",
|
|
@@ -2930,13 +2945,13 @@ function $i({ isUser: e, url: t, fallback: n }) {
|
|
|
2930
2945
|
}) : e ? n?.trim()?.charAt(0)?.toUpperCase() || "U" : /* @__PURE__ */ Q(Me, { className: "size-4" })
|
|
2931
2946
|
});
|
|
2932
2947
|
}
|
|
2933
|
-
function
|
|
2948
|
+
function na({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n, waitingLabel: r, stalledLabel: i, offlineLabel: a }) {
|
|
2934
2949
|
return /* @__PURE__ */ Q(er, {
|
|
2935
2950
|
from: "assistant",
|
|
2936
2951
|
"aria-live": "polite",
|
|
2937
2952
|
children: /* @__PURE__ */ $("div", {
|
|
2938
2953
|
className: q("flex w-full gap-2.5", e ? "flex-row items-start" : "flex-col"),
|
|
2939
|
-
children: [e ? /* @__PURE__ */ Q(
|
|
2954
|
+
children: [e ? /* @__PURE__ */ Q(ta, {
|
|
2940
2955
|
isUser: !1,
|
|
2941
2956
|
url: t,
|
|
2942
2957
|
fallback: n
|
|
@@ -2944,7 +2959,7 @@ function ea({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n,
|
|
|
2944
2959
|
className: "rounded-lg border bg-muted/30 px-3 py-2 text-muted-foreground",
|
|
2945
2960
|
children: /* @__PURE__ */ $("span", {
|
|
2946
2961
|
className: "inline-flex items-center gap-2",
|
|
2947
|
-
children: [/* @__PURE__ */ Q(
|
|
2962
|
+
children: [/* @__PURE__ */ Q(ra, {}), /* @__PURE__ */ Q(ca, {
|
|
2948
2963
|
active: !0,
|
|
2949
2964
|
pending: !0,
|
|
2950
2965
|
activityKey: 0,
|
|
@@ -2957,7 +2972,7 @@ function ea({ showAvatar: e, assistantAvatarUrl: t, assistantAvatarFallback: n,
|
|
|
2957
2972
|
})
|
|
2958
2973
|
});
|
|
2959
2974
|
}
|
|
2960
|
-
function
|
|
2975
|
+
function ra() {
|
|
2961
2976
|
return /* @__PURE__ */ $(Z, { children: [/* @__PURE__ */ Q("span", {
|
|
2962
2977
|
className: "sr-only",
|
|
2963
2978
|
children: "Assistant is responding"
|
|
@@ -2971,12 +2986,12 @@ function ta() {
|
|
|
2971
2986
|
]
|
|
2972
2987
|
})] });
|
|
2973
2988
|
}
|
|
2974
|
-
function
|
|
2989
|
+
function ia(e) {
|
|
2975
2990
|
let t = Math.floor(e / 60), n = e % 60;
|
|
2976
2991
|
return `${t}:${String(n).padStart(2, "0")}`;
|
|
2977
2992
|
}
|
|
2978
|
-
var
|
|
2979
|
-
function
|
|
2993
|
+
var aa = 6;
|
|
2994
|
+
function oa(t, n) {
|
|
2980
2995
|
let r = e.useRef(0), i = e.useRef(0), [a, o] = e.useState({
|
|
2981
2996
|
elapsed: 0,
|
|
2982
2997
|
quiet: 0
|
|
@@ -3005,10 +3020,10 @@ function ia(t, n) {
|
|
|
3005
3020
|
}, [t]), {
|
|
3006
3021
|
elapsedSeconds: a.elapsed,
|
|
3007
3022
|
quietSeconds: a.quiet,
|
|
3008
|
-
live: a.quiet <
|
|
3023
|
+
live: a.quiet < aa
|
|
3009
3024
|
};
|
|
3010
3025
|
}
|
|
3011
|
-
function
|
|
3026
|
+
function sa() {
|
|
3012
3027
|
let [t, n] = e.useState(() => typeof navigator < "u" && navigator.onLine === !1);
|
|
3013
3028
|
return e.useEffect(() => {
|
|
3014
3029
|
if (typeof window > "u") return;
|
|
@@ -3018,8 +3033,8 @@ function aa() {
|
|
|
3018
3033
|
};
|
|
3019
3034
|
}, []), t;
|
|
3020
3035
|
}
|
|
3021
|
-
function
|
|
3022
|
-
let { elapsedSeconds: o, quietSeconds: s, live: c } =
|
|
3036
|
+
function ca({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stalledLabel: i = "Still working…", offlineLabel: a = "Connection lost — reconnecting…" }) {
|
|
3037
|
+
let { elapsedSeconds: o, quietSeconds: s, live: c } = oa(e, t), l = sa() ? "offline" : c ? n ? "waiting" : "receiving" : "stalled", u = ia(o);
|
|
3023
3038
|
return /* @__PURE__ */ $("span", {
|
|
3024
3039
|
className: q("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"),
|
|
3025
3040
|
"aria-live": "polite",
|
|
@@ -3042,7 +3057,7 @@ function oa({ active: e, activityKey: t, pending: n = !1, waitingLabel: r, stall
|
|
|
3042
3057
|
]
|
|
3043
3058
|
});
|
|
3044
3059
|
}
|
|
3045
|
-
var
|
|
3060
|
+
var la = [
|
|
3046
3061
|
"Mapping out the data you’ll track…",
|
|
3047
3062
|
"Shaping objects and their fields…",
|
|
3048
3063
|
"Connecting related records…",
|
|
@@ -3053,21 +3068,21 @@ var sa = [
|
|
|
3053
3068
|
"Sketching a dashboard to track it…",
|
|
3054
3069
|
"Double-checking the structure hangs together…",
|
|
3055
3070
|
"Pulling the plan together…"
|
|
3056
|
-
],
|
|
3057
|
-
function
|
|
3071
|
+
], ua = 3500;
|
|
3072
|
+
function da(e, t, n = ua) {
|
|
3058
3073
|
if (t <= 0) return -1;
|
|
3059
3074
|
if (t === 1) return 0;
|
|
3060
|
-
let r = Math.floor((Number.isFinite(e) && e > 0 ? e : 0) / (n > 0 ? n :
|
|
3075
|
+
let r = Math.floor((Number.isFinite(e) && e > 0 ? e : 0) / (n > 0 ? n : ua));
|
|
3061
3076
|
return Math.min(r, t - 1);
|
|
3062
3077
|
}
|
|
3063
|
-
function
|
|
3078
|
+
function fa({ label: t, hints: n, offlineLabel: r }) {
|
|
3064
3079
|
let [i, a] = e.useState(0);
|
|
3065
3080
|
e.useEffect(() => {
|
|
3066
3081
|
if (n.length <= 1) return;
|
|
3067
|
-
let e = Date.now(), t = setInterval(() => a(Date.now() - e),
|
|
3082
|
+
let e = Date.now(), t = setInterval(() => a(Date.now() - e), ua);
|
|
3068
3083
|
return () => clearInterval(t);
|
|
3069
3084
|
}, [n.length]);
|
|
3070
|
-
let o =
|
|
3085
|
+
let o = da(i, n.length), s = o >= 0 ? n[o] : void 0, c = n.length > 1 && n.length <= 12;
|
|
3071
3086
|
return /* @__PURE__ */ $("span", {
|
|
3072
3087
|
className: "inline-flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground",
|
|
3073
3088
|
"data-testid": "build-proposal-progress",
|
|
@@ -3091,12 +3106,12 @@ function ua({ label: t, hints: n, offlineLabel: r }) {
|
|
|
3091
3106
|
"aria-hidden": !0,
|
|
3092
3107
|
children: n.map((e, t) => /* @__PURE__ */ Q("span", { className: q("size-1 rounded-full transition-colors", t <= o ? "bg-primary/70" : "bg-muted-foreground/25") }, t))
|
|
3093
3108
|
}) : null,
|
|
3094
|
-
/* @__PURE__ */ Q(
|
|
3109
|
+
/* @__PURE__ */ Q(pa, { offlineLabel: r })
|
|
3095
3110
|
]
|
|
3096
3111
|
});
|
|
3097
3112
|
}
|
|
3098
|
-
function
|
|
3099
|
-
let [n, r] = e.useState(0), i =
|
|
3113
|
+
function pa({ offlineLabel: t }) {
|
|
3114
|
+
let [n, r] = e.useState(0), i = sa();
|
|
3100
3115
|
return e.useEffect(() => {
|
|
3101
3116
|
let e = Date.now(), t = setInterval(() => r(Math.floor((Date.now() - e) / 1e3)), 1e3);
|
|
3102
3117
|
return () => clearInterval(t);
|
|
@@ -3109,25 +3124,25 @@ function da({ offlineLabel: t }) {
|
|
|
3109
3124
|
className: "size-3 shrink-0",
|
|
3110
3125
|
"aria-hidden": !0
|
|
3111
3126
|
}),
|
|
3112
|
-
/* @__PURE__ */ Q("span", { children:
|
|
3127
|
+
/* @__PURE__ */ Q("span", { children: ia(n) }),
|
|
3113
3128
|
i ? /* @__PURE__ */ $("span", { children: ["· ", t] }) : null
|
|
3114
3129
|
]
|
|
3115
3130
|
});
|
|
3116
3131
|
}
|
|
3117
|
-
var
|
|
3132
|
+
var ma = [
|
|
3118
3133
|
"object",
|
|
3119
3134
|
"view",
|
|
3120
3135
|
"dashboard",
|
|
3121
3136
|
"app",
|
|
3122
3137
|
"seed"
|
|
3123
|
-
],
|
|
3138
|
+
], ha = {
|
|
3124
3139
|
object: "Objects",
|
|
3125
3140
|
view: "Views",
|
|
3126
3141
|
dashboard: "Dashboards",
|
|
3127
3142
|
app: "App",
|
|
3128
3143
|
seed: "Sample data"
|
|
3129
3144
|
};
|
|
3130
|
-
function
|
|
3145
|
+
function ga({ 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…" }) {
|
|
3131
3146
|
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 = [];
|
|
3132
3147
|
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__ */ $("div", {
|
|
3133
3148
|
className: "rounded-lg border bg-muted/30 p-3 text-sm",
|
|
@@ -3154,7 +3169,7 @@ function ma({ progress: e, designingLabel: t = "Designing your app…", extendLa
|
|
|
3154
3169
|
}) : null,
|
|
3155
3170
|
p ? null : /* @__PURE__ */ Q("span", {
|
|
3156
3171
|
className: "ml-auto shrink-0",
|
|
3157
|
-
children: /* @__PURE__ */ Q(
|
|
3172
|
+
children: /* @__PURE__ */ Q(ca, {
|
|
3158
3173
|
active: !0,
|
|
3159
3174
|
activityKey: m,
|
|
3160
3175
|
waitingLabel: r,
|
|
@@ -3191,13 +3206,13 @@ function ma({ progress: e, designingLabel: t = "Designing your app…", extendLa
|
|
|
3191
3206
|
]
|
|
3192
3207
|
});
|
|
3193
3208
|
}
|
|
3194
|
-
function
|
|
3209
|
+
function _a({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app", onPreviewDraftApp: r, previewDraftLabel: i = "Preview", waitingLabel: a = "Waiting for server…", stalledLabel: o = "Still working…", offlineLabel: s = "Connection lost — reconnecting…" }) {
|
|
3195
3210
|
let { phase: c, appLabel: l, items: u, done: d, total: f, seq: p } = e, m = c === "done", h = p ?? `${c}:${d}:${u.length}`, g = u.find((e) => e.type === "app"), _ = f > 0 ? Math.min(100, Math.round(d / f * 100)) : m ? 100 : 6, v = /* @__PURE__ */ new Map();
|
|
3196
3211
|
for (let e of u) {
|
|
3197
3212
|
let t = v.get(e.type) ?? [];
|
|
3198
3213
|
t.push(e.name.replace(/_sample$/, "")), v.set(e.type, t);
|
|
3199
3214
|
}
|
|
3200
|
-
let y = [...
|
|
3215
|
+
let y = [...ma.filter((e) => v.has(e)), ...[...v.keys()].filter((e) => !ma.includes(e))];
|
|
3201
3216
|
return /* @__PURE__ */ $("div", {
|
|
3202
3217
|
className: "rounded-lg border bg-muted/30 p-3 text-sm",
|
|
3203
3218
|
"data-testid": "build-progress",
|
|
@@ -3213,7 +3228,7 @@ function ha({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
|
|
|
3213
3228
|
}) : null,
|
|
3214
3229
|
m ? null : /* @__PURE__ */ Q("span", {
|
|
3215
3230
|
className: "ml-auto",
|
|
3216
|
-
children: /* @__PURE__ */ Q(
|
|
3231
|
+
children: /* @__PURE__ */ Q(ca, {
|
|
3217
3232
|
active: !0,
|
|
3218
3233
|
activityKey: h,
|
|
3219
3234
|
waitingLabel: a,
|
|
@@ -3241,7 +3256,7 @@ function ha({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
|
|
|
3241
3256
|
children: [
|
|
3242
3257
|
/* @__PURE__ */ Q("span", {
|
|
3243
3258
|
className: "font-medium text-foreground",
|
|
3244
|
-
children:
|
|
3259
|
+
children: ha[e] ?? e
|
|
3245
3260
|
}),
|
|
3246
3261
|
" ",
|
|
3247
3262
|
t.slice(0, 6).join(", "),
|
|
@@ -3270,7 +3285,7 @@ function ha({ progress: e, onOpenBuiltApp: t, openBuiltAppLabel: n = "Open app",
|
|
|
3270
3285
|
]
|
|
3271
3286
|
});
|
|
3272
3287
|
}
|
|
3273
|
-
function
|
|
3288
|
+
function va({ groups: e, labels: t }) {
|
|
3274
3289
|
return e.length === 0 ? null : /* @__PURE__ */ Q("div", {
|
|
3275
3290
|
className: "not-prose mb-2 border-l border-border/70 pl-3",
|
|
3276
3291
|
children: /* @__PURE__ */ Q("div", {
|
|
@@ -3280,7 +3295,7 @@ function ga({ groups: e, labels: t }) {
|
|
|
3280
3295
|
children: [/* @__PURE__ */ $("div", {
|
|
3281
3296
|
className: "flex min-w-0 items-center gap-2",
|
|
3282
3297
|
children: [
|
|
3283
|
-
/* @__PURE__ */ Q(
|
|
3298
|
+
/* @__PURE__ */ Q(ya, { state: e.state }),
|
|
3284
3299
|
/* @__PURE__ */ Q("span", {
|
|
3285
3300
|
className: "truncate font-medium text-foreground",
|
|
3286
3301
|
children: e.title
|
|
@@ -3290,22 +3305,22 @@ function ga({ groups: e, labels: t }) {
|
|
|
3290
3305
|
children: ["x", e.count]
|
|
3291
3306
|
}) : null
|
|
3292
3307
|
]
|
|
3293
|
-
}), e.state === "running" ? e.rawName === "propose_blueprint" ? /* @__PURE__ */ Q(
|
|
3308
|
+
}), e.state === "running" ? e.rawName === "propose_blueprint" ? /* @__PURE__ */ Q(fa, {
|
|
3294
3309
|
label: t.designingPlanLabel,
|
|
3295
3310
|
hints: t.designingPlanHints,
|
|
3296
3311
|
offlineLabel: t.connectionOfflineLabel
|
|
3297
|
-
}) : /* @__PURE__ */ Q(
|
|
3312
|
+
}) : /* @__PURE__ */ Q(pa, { offlineLabel: t.connectionOfflineLabel }) : /* @__PURE__ */ Q("span", {
|
|
3298
3313
|
className: q("shrink-0 text-[10px] font-medium", e.state === "failed" ? "text-destructive" : e.state === "completed" ? "text-emerald-700 dark:text-emerald-400" : "text-muted-foreground"),
|
|
3299
|
-
children:
|
|
3314
|
+
children: ba(e.state, t)
|
|
3300
3315
|
})]
|
|
3301
3316
|
}, e.key))
|
|
3302
3317
|
})
|
|
3303
3318
|
});
|
|
3304
3319
|
}
|
|
3305
|
-
function
|
|
3320
|
+
function ya({ state: e }) {
|
|
3306
3321
|
return e === "failed" ? /* @__PURE__ */ Q(X, { className: "size-3.5 shrink-0 text-destructive" }) : e === "completed" ? /* @__PURE__ */ Q(Y, { className: "size-3.5 shrink-0 text-emerald-600" }) : /* @__PURE__ */ Q(Ue, { className: "size-3.5 shrink-0 text-muted-foreground" });
|
|
3307
3322
|
}
|
|
3308
|
-
function
|
|
3323
|
+
function ba(e, t) {
|
|
3309
3324
|
switch (e) {
|
|
3310
3325
|
case "failed": return t.toolFailed;
|
|
3311
3326
|
case "awaiting": return t.toolAwaitingApproval;
|
|
@@ -3313,7 +3328,7 @@ function va(e, t) {
|
|
|
3313
3328
|
case "completed": return t.toolCompleted;
|
|
3314
3329
|
}
|
|
3315
3330
|
}
|
|
3316
|
-
function
|
|
3331
|
+
function xa({ error: t, rateLimitedLabel: n, genericLabel: r }) {
|
|
3317
3332
|
let i = e.useMemo(() => Kn(t) ? n : r, [
|
|
3318
3333
|
t,
|
|
3319
3334
|
n,
|
|
@@ -3335,7 +3350,7 @@ function ya({ error: t, rateLimitedLabel: n, genericLabel: r }) {
|
|
|
3335
3350
|
})
|
|
3336
3351
|
});
|
|
3337
3352
|
}
|
|
3338
|
-
function
|
|
3353
|
+
function Sa({ error: t, onReload: n, onUpgrade: r }) {
|
|
3339
3354
|
let i = e.useMemo(() => Un(t), [t]), { summary: a, details: o } = e.useMemo(() => Vn(t), [t]), [s, c] = e.useState(!1);
|
|
3340
3355
|
if (i) {
|
|
3341
3356
|
let e = typeof navigator < "u" && !!navigator.language?.toLowerCase().startsWith("zh"), t = (e ? i.message : i.messageEn ?? i.message) || (e ? "AI 额度已用完。" : "You have reached your AI quota."), n = i.topUp ? e ? "购买额度包" : "Buy a credit pack" : e ? "升级方案" : "Upgrade plan";
|
|
@@ -3407,7 +3422,7 @@ function ba({ error: t, onReload: n, onUpgrade: r }) {
|
|
|
3407
3422
|
})
|
|
3408
3423
|
});
|
|
3409
3424
|
}
|
|
3410
|
-
function
|
|
3425
|
+
function Ca({ output: e, errorText: t }) {
|
|
3411
3426
|
return t ? /* @__PURE__ */ Q(Ti, {
|
|
3412
3427
|
output: void 0,
|
|
3413
3428
|
errorText: t
|
|
@@ -3427,7 +3442,7 @@ function xa({ output: e, errorText: t }) {
|
|
|
3427
3442
|
}
|
|
3428
3443
|
//#endregion
|
|
3429
3444
|
//#region src/FloatingChatbot.tsx
|
|
3430
|
-
function
|
|
3445
|
+
function wa({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
|
|
3431
3446
|
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);
|
|
3432
3447
|
e.useEffect(() => {
|
|
3433
3448
|
let e = document.getElementById("floating-chatbot-portal");
|
|
@@ -3447,7 +3462,7 @@ function Sa({ floatingConfig: t, headerExtra: n, headerActions: r, ...i }) {
|
|
|
3447
3462
|
height: c,
|
|
3448
3463
|
headerExtra: n,
|
|
3449
3464
|
headerActions: r,
|
|
3450
|
-
children: /* @__PURE__ */ Q(
|
|
3465
|
+
children: /* @__PURE__ */ Q(ea, {
|
|
3451
3466
|
...i,
|
|
3452
3467
|
maxHeight: "100%",
|
|
3453
3468
|
className: "h-full border-0 rounded-none"
|
|
@@ -3474,7 +3489,7 @@ Ft.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3474
3489
|
autoResponseDelay: e.autoResponseDelay,
|
|
3475
3490
|
onSend: e.onSend
|
|
3476
3491
|
});
|
|
3477
|
-
return /* @__PURE__ */ Q(
|
|
3492
|
+
return /* @__PURE__ */ Q(Ga, {
|
|
3478
3493
|
messages: r,
|
|
3479
3494
|
placeholder: e.placeholder,
|
|
3480
3495
|
onSendMessage: (e) => {
|
|
@@ -3640,7 +3655,7 @@ Ft.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3640
3655
|
autoResponseDelay: e.autoResponseDelay,
|
|
3641
3656
|
onSend: e.onSend
|
|
3642
3657
|
});
|
|
3643
|
-
return /* @__PURE__ */ Q(
|
|
3658
|
+
return /* @__PURE__ */ Q(ea, {
|
|
3644
3659
|
messages: r,
|
|
3645
3660
|
placeholder: e.placeholder,
|
|
3646
3661
|
onSendMessage: (e, t) => {
|
|
@@ -3827,7 +3842,7 @@ Ft.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3827
3842
|
autoResponseDelay: e.autoResponseDelay,
|
|
3828
3843
|
onSend: e.onSend
|
|
3829
3844
|
});
|
|
3830
|
-
return /* @__PURE__ */ Q(
|
|
3845
|
+
return /* @__PURE__ */ Q(wa, {
|
|
3831
3846
|
floatingConfig: e.floatingConfig,
|
|
3832
3847
|
messages: r,
|
|
3833
3848
|
placeholder: e.placeholder,
|
|
@@ -3999,7 +4014,7 @@ Ft.register("chatbot", ({ schema: e, className: t, ...n }) => {
|
|
|
3999
4014
|
});
|
|
4000
4015
|
//#endregion
|
|
4001
4016
|
//#region src/elements/loader.tsx
|
|
4002
|
-
var
|
|
4017
|
+
var Ta = ({ size: e = 16 }) => /* @__PURE__ */ $("svg", {
|
|
4003
4018
|
height: e,
|
|
4004
4019
|
strokeLinejoin: "round",
|
|
4005
4020
|
style: { color: "currentcolor" },
|
|
@@ -4080,18 +4095,18 @@ var Ca = ({ size: e = 16 }) => /* @__PURE__ */ $("svg", {
|
|
|
4080
4095
|
})
|
|
4081
4096
|
}) })
|
|
4082
4097
|
]
|
|
4083
|
-
}),
|
|
4098
|
+
}), Ea = ({ className: e, size: t = 16, ...n }) => /* @__PURE__ */ Q("div", {
|
|
4084
4099
|
className: q("inline-flex animate-spin items-center justify-center", e),
|
|
4085
4100
|
...n,
|
|
4086
|
-
children: /* @__PURE__ */ Q(
|
|
4087
|
-
}),
|
|
4101
|
+
children: /* @__PURE__ */ Q(Ta, { size: t })
|
|
4102
|
+
}), Da = /* @__PURE__ */ Lt({
|
|
4088
4103
|
CodeBlock: () => vi,
|
|
4089
4104
|
CodeBlockCopyButton: () => yi,
|
|
4090
4105
|
Conversation: () => qn,
|
|
4091
4106
|
ConversationContent: () => Jn,
|
|
4092
4107
|
ConversationEmptyState: () => Yn,
|
|
4093
4108
|
ConversationScrollButton: () => Xn,
|
|
4094
|
-
Loader: () =>
|
|
4109
|
+
Loader: () => Ea,
|
|
4095
4110
|
Message: () => er,
|
|
4096
4111
|
MessageAction: () => rr,
|
|
4097
4112
|
MessageActions: () => nr,
|
|
@@ -4163,14 +4178,14 @@ var Ca = ({ size: e = 16 }) => /* @__PURE__ */ $("svg", {
|
|
|
4163
4178
|
usePromptInputController: () => wr,
|
|
4164
4179
|
useProviderAttachments: () => Er,
|
|
4165
4180
|
useReasoning: () => Oi
|
|
4166
|
-
}),
|
|
4167
|
-
function
|
|
4181
|
+
}), Oa = "/api/v1/ai";
|
|
4182
|
+
function ka(e, t, n) {
|
|
4168
4183
|
let r = e.replace(/\/$/, ""), i = new URLSearchParams();
|
|
4169
4184
|
if (n) for (let [e, t] of Object.entries(n)) t == null || t === "" || i.set(e, String(t));
|
|
4170
4185
|
let a = i.toString();
|
|
4171
4186
|
return `${r}${t}${a ? `?${a}` : ""}`;
|
|
4172
4187
|
}
|
|
4173
|
-
async function
|
|
4188
|
+
async function Aa(e, t, n) {
|
|
4174
4189
|
let r = await fetch(e, {
|
|
4175
4190
|
credentials: "include",
|
|
4176
4191
|
...t,
|
|
@@ -4190,8 +4205,8 @@ async function Oa(e, t, n) {
|
|
|
4190
4205
|
}
|
|
4191
4206
|
return i;
|
|
4192
4207
|
}
|
|
4193
|
-
function
|
|
4194
|
-
let { apiBase: n =
|
|
4208
|
+
function ja(t = {}) {
|
|
4209
|
+
let { apiBase: n = Oa, 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({
|
|
4195
4210
|
apiBase: n,
|
|
4196
4211
|
status: r,
|
|
4197
4212
|
conversationId: i,
|
|
@@ -4209,7 +4224,7 @@ function ka(t = {}) {
|
|
|
4209
4224
|
let { apiBase: e, status: t, conversationId: n, limit: r, headers: i } = _.current;
|
|
4210
4225
|
m(!0), g(void 0);
|
|
4211
4226
|
try {
|
|
4212
|
-
let a = await
|
|
4227
|
+
let a = await Aa(ka(e, "/pending-actions", {
|
|
4213
4228
|
status: t && t !== "all" ? t : void 0,
|
|
4214
4229
|
conversationId: n,
|
|
4215
4230
|
limit: r
|
|
@@ -4221,9 +4236,9 @@ function ka(t = {}) {
|
|
|
4221
4236
|
m(!1);
|
|
4222
4237
|
}
|
|
4223
4238
|
}, []), y = e.useCallback(async (e) => {
|
|
4224
|
-
let { apiBase: t, headers: n } = _.current, r =
|
|
4239
|
+
let { apiBase: t, headers: n } = _.current, r = ka(t, `/pending-actions/${encodeURIComponent(e)}/approve`);
|
|
4225
4240
|
try {
|
|
4226
|
-
return await
|
|
4241
|
+
return await Aa(r, {
|
|
4227
4242
|
method: "POST",
|
|
4228
4243
|
body: "{}"
|
|
4229
4244
|
}, n);
|
|
@@ -4231,9 +4246,9 @@ function ka(t = {}) {
|
|
|
4231
4246
|
v();
|
|
4232
4247
|
}
|
|
4233
4248
|
}, [v]), b = e.useCallback(async (e, t) => {
|
|
4234
|
-
let { apiBase: n, headers: r } = _.current, i =
|
|
4249
|
+
let { apiBase: n, headers: r } = _.current, i = ka(n, `/pending-actions/${encodeURIComponent(e)}/reject`);
|
|
4235
4250
|
try {
|
|
4236
|
-
return await
|
|
4251
|
+
return await Aa(i, {
|
|
4237
4252
|
method: "POST",
|
|
4238
4253
|
body: JSON.stringify(t ? { reason: t } : {})
|
|
4239
4254
|
}, r);
|
|
@@ -4267,7 +4282,7 @@ function ka(t = {}) {
|
|
|
4267
4282
|
}
|
|
4268
4283
|
//#endregion
|
|
4269
4284
|
//#region src/AiPendingActionsInbox.tsx
|
|
4270
|
-
var
|
|
4285
|
+
var Ma = {
|
|
4271
4286
|
pending: {
|
|
4272
4287
|
variant: "secondary",
|
|
4273
4288
|
label: "Pending"
|
|
@@ -4289,8 +4304,8 @@ var Aa = {
|
|
|
4289
4304
|
label: "Rejected"
|
|
4290
4305
|
}
|
|
4291
4306
|
};
|
|
4292
|
-
function
|
|
4293
|
-
let t =
|
|
4307
|
+
function Na({ status: e }) {
|
|
4308
|
+
let t = Ma[e] ?? {
|
|
4294
4309
|
variant: "outline",
|
|
4295
4310
|
label: e
|
|
4296
4311
|
};
|
|
@@ -4299,7 +4314,7 @@ function ja({ status: e }) {
|
|
|
4299
4314
|
children: t.label
|
|
4300
4315
|
});
|
|
4301
4316
|
}
|
|
4302
|
-
function
|
|
4317
|
+
function Pa(e) {
|
|
4303
4318
|
if (!e) return "—";
|
|
4304
4319
|
let t = Date.parse(e);
|
|
4305
4320
|
if (Number.isNaN(t)) return e;
|
|
@@ -4317,7 +4332,7 @@ function Ma(e) {
|
|
|
4317
4332
|
return e;
|
|
4318
4333
|
}
|
|
4319
4334
|
}
|
|
4320
|
-
function
|
|
4335
|
+
function Fa(e) {
|
|
4321
4336
|
if (!e) return null;
|
|
4322
4337
|
try {
|
|
4323
4338
|
return JSON.parse(e);
|
|
@@ -4325,7 +4340,7 @@ function Na(e) {
|
|
|
4325
4340
|
return e;
|
|
4326
4341
|
}
|
|
4327
4342
|
}
|
|
4328
|
-
function
|
|
4343
|
+
function Ia({ value: e, max: t = 320 }) {
|
|
4329
4344
|
let n = typeof e == "string" ? e : JSON.stringify(e, null, 2);
|
|
4330
4345
|
return n == null || n === "" ? /* @__PURE__ */ Q("span", {
|
|
4331
4346
|
className: "text-muted-foreground text-xs",
|
|
@@ -4336,20 +4351,20 @@ function Pa({ value: e, max: t = 320 }) {
|
|
|
4336
4351
|
children: n
|
|
4337
4352
|
});
|
|
4338
4353
|
}
|
|
4339
|
-
function
|
|
4354
|
+
function La(e) {
|
|
4340
4355
|
switch (e) {
|
|
4341
4356
|
case "pending": return "pending";
|
|
4342
4357
|
case "all": return "all";
|
|
4343
4358
|
case "decided": return "all";
|
|
4344
4359
|
}
|
|
4345
4360
|
}
|
|
4346
|
-
function
|
|
4347
|
-
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: P, approve: F, reject: I } =
|
|
4361
|
+
function Ra({ 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 }) {
|
|
4362
|
+
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: P, approve: F, reject: I } = ja({
|
|
4348
4363
|
apiBase: t,
|
|
4349
4364
|
headers: n,
|
|
4350
4365
|
pollInterval: r,
|
|
4351
4366
|
conversationId: i,
|
|
4352
|
-
status:
|
|
4367
|
+
status: La(l)
|
|
4353
4368
|
}), L = e.useMemo(() => l === "decided" ? j.filter((e) => e.status !== "pending") : j, [j, l]), z = e.useMemo(() => d ? j.find((e) => e.id === d) ?? null : null, [d, j]), ie = e.useCallback(async (e) => {
|
|
4354
4369
|
E(e), O(null);
|
|
4355
4370
|
try {
|
|
@@ -4498,7 +4513,7 @@ function Ia({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4498
4513
|
className: "text-sm",
|
|
4499
4514
|
children: e.object_name
|
|
4500
4515
|
}),
|
|
4501
|
-
/* @__PURE__ */ Q(H, { children: /* @__PURE__ */ Q(
|
|
4516
|
+
/* @__PURE__ */ Q(H, { children: /* @__PURE__ */ Q(Na, { status: e.status }) }),
|
|
4502
4517
|
/* @__PURE__ */ Q(H, {
|
|
4503
4518
|
className: "text-xs text-muted-foreground",
|
|
4504
4519
|
children: /* @__PURE__ */ $("span", {
|
|
@@ -4506,7 +4521,7 @@ function Ia({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4506
4521
|
children: [
|
|
4507
4522
|
/* @__PURE__ */ Q(He, { className: "h-3 w-3" }),
|
|
4508
4523
|
" ",
|
|
4509
|
-
|
|
4524
|
+
Pa(e.proposed_at)
|
|
4510
4525
|
]
|
|
4511
4526
|
})
|
|
4512
4527
|
}),
|
|
@@ -4595,14 +4610,14 @@ function Ia({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4595
4610
|
children: "Status"
|
|
4596
4611
|
}), /* @__PURE__ */ Q("div", {
|
|
4597
4612
|
className: "mt-1",
|
|
4598
|
-
children: /* @__PURE__ */ Q(
|
|
4613
|
+
children: /* @__PURE__ */ Q(Na, { status: z.status })
|
|
4599
4614
|
})] }),
|
|
4600
4615
|
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(V, {
|
|
4601
4616
|
className: "text-xs text-muted-foreground",
|
|
4602
4617
|
children: "Proposed"
|
|
4603
4618
|
}), /* @__PURE__ */ Q("div", {
|
|
4604
4619
|
className: "mt-1 text-xs",
|
|
4605
|
-
children:
|
|
4620
|
+
children: Pa(z.proposed_at)
|
|
4606
4621
|
})] }),
|
|
4607
4622
|
/* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(V, {
|
|
4608
4623
|
className: "text-xs text-muted-foreground",
|
|
@@ -4636,21 +4651,21 @@ function Ia({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4636
4651
|
children: "Tool input"
|
|
4637
4652
|
}), /* @__PURE__ */ Q("div", {
|
|
4638
4653
|
className: "mt-1.5",
|
|
4639
|
-
children: /* @__PURE__ */ Q(
|
|
4654
|
+
children: /* @__PURE__ */ Q(Ia, { value: Fa(z.tool_input) })
|
|
4640
4655
|
})] }),
|
|
4641
4656
|
z.result ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(V, {
|
|
4642
4657
|
className: "text-xs",
|
|
4643
4658
|
children: "Result"
|
|
4644
4659
|
}), /* @__PURE__ */ Q("div", {
|
|
4645
4660
|
className: "mt-1.5",
|
|
4646
|
-
children: /* @__PURE__ */ Q(
|
|
4661
|
+
children: /* @__PURE__ */ Q(Ia, { value: Fa(z.result) })
|
|
4647
4662
|
})] }) : null,
|
|
4648
4663
|
z.error ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(V, {
|
|
4649
4664
|
className: "text-xs text-destructive",
|
|
4650
4665
|
children: "Error"
|
|
4651
4666
|
}), /* @__PURE__ */ Q("div", {
|
|
4652
4667
|
className: "mt-1.5",
|
|
4653
|
-
children: /* @__PURE__ */ Q(
|
|
4668
|
+
children: /* @__PURE__ */ Q(Ia, { value: z.error })
|
|
4654
4669
|
})] }) : null,
|
|
4655
4670
|
z.rejection_reason ? /* @__PURE__ */ $("div", { children: [/* @__PURE__ */ Q(V, {
|
|
4656
4671
|
className: "text-xs",
|
|
@@ -4721,14 +4736,14 @@ function Ia({ apiBase: t, headers: n, pollInterval: r = 5e3, conversationId: i,
|
|
|
4721
4736
|
}
|
|
4722
4737
|
//#endregion
|
|
4723
4738
|
//#region src/useHitlInChat.ts
|
|
4724
|
-
function
|
|
4739
|
+
function za(e) {
|
|
4725
4740
|
return !e || e.length === 0 ? "/api/v1/ai" : e.endsWith("/") ? e.slice(0, -1) : e;
|
|
4726
4741
|
}
|
|
4727
|
-
function
|
|
4742
|
+
function Ba(e, t) {
|
|
4728
4743
|
let n = { ...e ?? {} };
|
|
4729
4744
|
return t && (n["Content-Type"] = "application/json"), n;
|
|
4730
4745
|
}
|
|
4731
|
-
async function
|
|
4746
|
+
async function Va(e) {
|
|
4732
4747
|
let t = await e.text();
|
|
4733
4748
|
if (!t) return null;
|
|
4734
4749
|
try {
|
|
@@ -4737,8 +4752,8 @@ async function za(e) {
|
|
|
4737
4752
|
return { raw: t };
|
|
4738
4753
|
}
|
|
4739
4754
|
}
|
|
4740
|
-
function
|
|
4741
|
-
let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s =
|
|
4755
|
+
function Ha(t) {
|
|
4756
|
+
let { messages: n, apiBase: r, headers: i, onDecided: a, continueConversation: o } = t, s = za(r), c = e.useMemo(() => {
|
|
4742
4757
|
let e = /* @__PURE__ */ new Map();
|
|
4743
4758
|
for (let t of n) {
|
|
4744
4759
|
let n = t.toolInvocations ?? [];
|
|
@@ -4781,9 +4796,9 @@ function Ba(t) {
|
|
|
4781
4796
|
let r = `${s}/pending-actions/${encodeURIComponent(l)}/${t ? "approve" : "reject"}`, c = t ? "{}" : JSON.stringify({ reason: n ?? "" }), d = await fetch(r, {
|
|
4782
4797
|
method: "POST",
|
|
4783
4798
|
credentials: "include",
|
|
4784
|
-
headers:
|
|
4799
|
+
headers: Ba(i, !0),
|
|
4785
4800
|
body: c
|
|
4786
|
-
}), f = await
|
|
4801
|
+
}), f = await Va(d) ?? {};
|
|
4787
4802
|
if (!d.ok) {
|
|
4788
4803
|
let t = typeof f.error == "string" ? f.error : `Approval failed: HTTP ${d.status}`;
|
|
4789
4804
|
m(e, {
|
|
@@ -4797,20 +4812,26 @@ function Ba(t) {
|
|
|
4797
4812
|
return;
|
|
4798
4813
|
}
|
|
4799
4814
|
let p = f.status ?? (t ? "executed" : "rejected"), h = !1;
|
|
4800
|
-
if (p === "executed"
|
|
4815
|
+
if (p === "executed") m(e, {
|
|
4801
4816
|
state: "success",
|
|
4802
4817
|
message: "Approved — action executed."
|
|
4803
|
-
}), h = !0
|
|
4818
|
+
}), h = !0;
|
|
4819
|
+
else if (p === "rejected") m(e, {
|
|
4804
4820
|
state: "success",
|
|
4805
4821
|
message: n ? `Rejected: ${n}` : "Rejected."
|
|
4806
|
-
}), h = !0
|
|
4807
|
-
|
|
4808
|
-
|
|
4809
|
-
|
|
4822
|
+
}), h = !0;
|
|
4823
|
+
else if (p === "failed") {
|
|
4824
|
+
let t = f.error ?? "Action approved but execution failed.";
|
|
4825
|
+
m(e, {
|
|
4826
|
+
state: "error",
|
|
4827
|
+
message: t
|
|
4828
|
+
});
|
|
4829
|
+
} else m(e, {
|
|
4810
4830
|
state: "success",
|
|
4811
4831
|
message: `Status: ${p}`
|
|
4812
|
-
}), h = !0
|
|
4813
|
-
|
|
4832
|
+
}), h = !0;
|
|
4833
|
+
if (a?.(e, f), h && o) {
|
|
4834
|
+
let r = Ua({
|
|
4814
4835
|
approved: t,
|
|
4815
4836
|
status: p,
|
|
4816
4837
|
toolName: u,
|
|
@@ -4827,9 +4848,10 @@ function Ba(t) {
|
|
|
4827
4848
|
});
|
|
4828
4849
|
}
|
|
4829
4850
|
} catch (t) {
|
|
4851
|
+
let n = t instanceof Error ? t.message : String(t);
|
|
4830
4852
|
m(e, {
|
|
4831
4853
|
state: "error",
|
|
4832
|
-
message:
|
|
4854
|
+
message: n
|
|
4833
4855
|
});
|
|
4834
4856
|
} finally {
|
|
4835
4857
|
--d.current, d.current <= 0 && (d.current = 0, p(!1));
|
|
@@ -4845,24 +4867,24 @@ function Ba(t) {
|
|
|
4845
4867
|
isDeciding: f
|
|
4846
4868
|
};
|
|
4847
4869
|
}
|
|
4848
|
-
function
|
|
4870
|
+
function Ua(e) {
|
|
4849
4871
|
let { approved: t, status: n, toolName: r, pendingActionId: i, outcome: a, reason: o } = e, s = `[HITL ${i}]`;
|
|
4850
4872
|
if (t && n === "executed") {
|
|
4851
4873
|
let e = a.result;
|
|
4852
|
-
return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e :
|
|
4874
|
+
return `${s} The operator approved the \`${r}\` call. It executed successfully with result: ${e == null ? "(no payload)" : typeof e == "string" ? e : Wa(JSON.stringify(e), 800)}. Acknowledge the outcome concisely and continue the user's task.`;
|
|
4853
4875
|
}
|
|
4854
4876
|
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.`;
|
|
4855
4877
|
if (n === "failed") {
|
|
4856
4878
|
let e = a.error;
|
|
4857
|
-
return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e :
|
|
4879
|
+
return `${s} The \`${r}\` call was approved but execution failed: ${typeof e == "string" ? e : Wa(JSON.stringify(e ?? {}), 400)}. Apologize concisely and offer alternatives.`;
|
|
4858
4880
|
}
|
|
4859
4881
|
}
|
|
4860
|
-
function
|
|
4882
|
+
function Wa(e, t) {
|
|
4861
4883
|
return e.length <= t ? e : `${e.slice(0, t - 1)}…`;
|
|
4862
4884
|
}
|
|
4863
4885
|
//#endregion
|
|
4864
4886
|
//#region src/index.tsx
|
|
4865
|
-
var
|
|
4887
|
+
var Ga = 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) => {
|
|
4866
4888
|
let [m, h] = e.useState(""), g = e.useRef(null), _ = e.useRef(null);
|
|
4867
4889
|
e.useEffect(() => {
|
|
4868
4890
|
if (g.current) {
|
|
@@ -4888,7 +4910,7 @@ var Ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
4888
4910
|
children: n.length === 0 ? /* @__PURE__ */ Q("div", {
|
|
4889
4911
|
className: "flex items-center justify-center h-32 text-muted-foreground text-sm",
|
|
4890
4912
|
children: "No messages yet. Start a conversation!"
|
|
4891
|
-
}) : n.map((e) => /* @__PURE__ */ Q(
|
|
4913
|
+
}) : n.map((e) => /* @__PURE__ */ Q(Ka, {
|
|
4892
4914
|
message: e,
|
|
4893
4915
|
showTimestamp: o,
|
|
4894
4916
|
userAvatarUrl: s,
|
|
@@ -4919,8 +4941,8 @@ var Ua = e.forwardRef(({ className: t, messages: n = [], placeholder: r = "Type
|
|
|
4919
4941
|
})]
|
|
4920
4942
|
});
|
|
4921
4943
|
});
|
|
4922
|
-
|
|
4923
|
-
var
|
|
4944
|
+
Ga.displayName = "Chatbot";
|
|
4945
|
+
var Ka = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback: r, assistantAvatarUrl: i, assistantAvatarFallback: a }) => {
|
|
4924
4946
|
let o = e.role === "user";
|
|
4925
4947
|
if (e.role === "system") return /* @__PURE__ */ Q("div", {
|
|
4926
4948
|
className: "flex justify-center",
|
|
@@ -4952,7 +4974,7 @@ var Wa = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
|
|
|
4952
4974
|
})]
|
|
4953
4975
|
})]
|
|
4954
4976
|
});
|
|
4955
|
-
},
|
|
4977
|
+
}, qa = e.forwardRef(({ className: e, avatarSrc: t, avatarFallback: n = "AI", ...r }, i) => /* @__PURE__ */ $("div", {
|
|
4956
4978
|
ref: i,
|
|
4957
4979
|
className: q("flex gap-3", e),
|
|
4958
4980
|
...r,
|
|
@@ -4974,6 +4996,6 @@ var Wa = ({ message: e, showTimestamp: t, userAvatarUrl: n, userAvatarFallback:
|
|
|
4974
4996
|
})
|
|
4975
4997
|
})]
|
|
4976
4998
|
}));
|
|
4977
|
-
|
|
4999
|
+
qa.displayName = "TypingIndicator";
|
|
4978
5000
|
//#endregion
|
|
4979
|
-
export { sn as AGENT_ALIAS_GROUPS,
|
|
5001
|
+
export { sn as AGENT_ALIAS_GROUPS, Da as AIElements, Ra as AiPendingActionsInbox, Ga as Chatbot, ea as ChatbotEnhanced, wa as FloatingChatbot, Ln as FloatingChatbotPanel, Tn as FloatingChatbotProvider, jn as FloatingChatbotTrigger, mn as PLATFORM_DEFAULT_AGENT, qa as TypingIndicator, cn as agentAliasGroup, ln as agentRouteName, Jt as buildProgressFromDraftReview, Kt as detectDraftResult, Wt as detectProposedPlan, zn as humanizeToolName, pn as isAskAgent, fn as isBuildAgent, dn as isBuiltinAgentName, zi as publishHealthFromResponse, un as resolveAgentParam, hn as resolveDefaultAgentName, Vn as summarizeChatError, en as uiMessageToChatMessage, tn as uiMessagesToChatMessages, Bn as unwrapToolResult, xn as useAgents, Cn as useAiModels, En as useFloatingChatbot, Ha as useHitlInChat, on as useObjectChat, ja as usePendingActions };
|