@personai/agent-ui-chat-react 0.0.0-stage → 1.0.0-preview.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +177 -0
- package/README.md +113 -2
- package/dist/index.js +3523 -0
- package/dist/src/ChatA2UI.d.ts +7 -0
- package/dist/src/ChatGoalIndicator.d.ts +20 -0
- package/dist/src/ChatHistoryRail.d.ts +9 -0
- package/dist/src/ChatPanel.d.ts +100 -0
- package/dist/src/ChatRuntimeWindow.d.ts +71 -0
- package/dist/src/ChatUserInputCard.d.ts +7 -0
- package/dist/src/ChatUserInputGroup.d.ts +11 -0
- package/dist/src/ChatWindow.d.ts +13 -0
- package/dist/src/InteractionReceipt.d.ts +7 -0
- package/dist/src/MermaidBlock.d.ts +6 -0
- package/dist/src/ToolResultView.d.ts +5 -0
- package/dist/src/chatAttachments.d.ts +4 -0
- package/dist/src/chatHistory.d.ts +11 -0
- package/dist/src/index.d.ts +8 -0
- package/dist/styles.css +2 -0
- package/package.json +50 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,3523 @@
|
|
|
1
|
+
import { createContext as e, useCallback as t, useContext as n, useEffect as r, useId as i, useImperativeHandle as a, useLayoutEffect as o, useMemo as s, useRef as c, useState as l } from "react";
|
|
2
|
+
import { ArrowDown as u, Bot as d, BrainCircuit as f, Check as p, CheckCircle2 as m, ChevronDown as h, ChevronRight as g, CircleAlert as _, CircleDot as v, CircleHelp as y, CircleX as b, Copy as x, FileText as S, LoaderCircle as C, Maximize2 as ee, MessageSquareText as te, Minus as ne, Pause as w, Pencil as T, Play as E, Plus as re, RotateCcw as ie, Square as D, Terminal as O, Trash2 as k, UserRound as A, X as ae } from "lucide-react";
|
|
3
|
+
import { AGENT_CATALOG_ID as oe, AssistantMessageStream as se, AssistantReplyQueue as ce, ChatA2uiSession as le, ChatAdapterError as ue, MermaidDiagram as de, activeNativeUserInputRequests as fe, aguiEventMillis as pe, aguiEventRunId as me, aguiReasoningEffort as he, aguiWorkElapsedMilliseconds as ge, applyMessageProvenance as _e, batchApprovalDecisions as ve, belongsToNewChatTurn as ye, buildAguiRunNotices as be, buildAguiUserWorkCards as xe, buildTranscriptPresentation as Se, buildTranscriptWorkTimeline as Ce, chatAnnotationForHref as we, chatAnnotationTooltip as Te, chatAnnotationsByMessage as Ee, chatErrorPresentation as De, clampFloatingStateToViewport as Oe, contextCompactionInProgress as ke, createInteractionClient as Ae, createMockChatAdapter as je, createSteerWorkSegmentEvents as Me, currentAguiTerminalEvent as Ne, defaultChatAnnotationLabels as Pe, defaultFloatingState as Fe, defaultHistoryLabels as Ie, defaultToolActionSummaryLabel as Le, describeDebugEvent as j, detectToolPresentationLocale as Re, enqueueChatSubmission as ze, floatingStatesEqual as M, formatTime as Be, hasPendingBatchItems as Ve, historyBlockUrl as N, historyCompactionEvents as He, historyEventRunId as Ue, historyMessages as We, historyToolResult as Ge, historyUserInputRequests as Ke, historyWorkCompleted as qe, historyWorkGroups as Je, interactionMessages as Ye, interactionToolSummary as Xe, isAguiCancellationEvent as Ze, isAguiExecutionTerminalEvent as Qe, isAguiPresentationFailureEvent as $e, isAguiRequestProgressEvent as et, isSteerQueueFallbackCode as tt, mergeChatMessagesChronologically as nt, mergeTranscriptAguiEvents as rt, mermaidFenceClosed as it, messageActorName as at, messageSenderAvatar as P, messageSenderIsHuman as F, mountChatAnnotationPreviews as ot, mountChatAnnotationSelection as st, nativeUserInputBatchAnswer as ct, nativeUserInputRequests as lt, normalizeChatSession as ut, openChatAnnotationEditor as dt, pendingApprovalRequests as ft, readFloatingState as pt, reduceFloatingState as mt, removeQueuedChatSubmission as ht, reorderQueuedChatSubmission as gt, requestedSkillsFromDraft as _t, resolveComposerLabels as vt, resolveFloatingViewportBounds as I, resolveRuntimeMessage as yt, summarizeReasoning as L, summarizeToolActions as bt, takeNextQueuedChatSubmission as xt, toolCommandCountLabel as St, toolCompactLabel as Ct, toolDisplayName as wt, toolOperationDetails as Tt, truncateLabel as Et, waitingInputComposerLabel as Dt, workTimelineElapsedMilliseconds as Ot, writeFloatingState as kt } from "@personai/agent-ui-chat-core";
|
|
4
|
+
import { Fragment as At, jsx as R, jsxs as z } from "react/jsx-runtime";
|
|
5
|
+
import { A2UISurface as jt } from "@personai/agent-ui-a2ui-react";
|
|
6
|
+
import { Composer as Mt, useComposerDisabled as Nt } from "@personai/agent-ui-composer-react";
|
|
7
|
+
import { A2UIClient as Pt } from "@personai/agent-ui-a2ui-core";
|
|
8
|
+
import Ft from "react-markdown";
|
|
9
|
+
import It from "remark-gfm";
|
|
10
|
+
import { AgentMotion as Lt, MotionProvider as Rt, useMotion as B } from "@personai/agent-ui-motion-react";
|
|
11
|
+
//#region src/InteractionReceipt.tsx
|
|
12
|
+
function V({ message: e, actorName: t, hideMessageIdentity: n = !1 }) {
|
|
13
|
+
let a = e.interactionResponse, o = i(), s = c(null), u = c(null), d = c(void 0), f = c(!1), [m, h] = l(!1), g = a.summaryLabel ?? a.rows[0]?.value ?? "", _ = a.approval ? a.approval.approved ? p : ae : a.kind === "form" ? S : y;
|
|
14
|
+
function v() {
|
|
15
|
+
clearTimeout(d.current);
|
|
16
|
+
}
|
|
17
|
+
function b() {
|
|
18
|
+
v(), u.current?.hidePopover(), f.current = !1;
|
|
19
|
+
}
|
|
20
|
+
function x() {
|
|
21
|
+
if (v(), !s.current || !u.current) return;
|
|
22
|
+
let e = s.current.getBoundingClientRect(), t = e.top > window.innerHeight - e.bottom;
|
|
23
|
+
Object.assign(u.current.style, {
|
|
24
|
+
width: `${Math.min(420, window.innerWidth - 24)}px`,
|
|
25
|
+
left: `${Math.max(12, Math.min(e.left, window.innerWidth - Math.min(420, window.innerWidth - 24) - 12))}px`,
|
|
26
|
+
top: t ? "auto" : `${e.bottom + 8}px`,
|
|
27
|
+
bottom: t ? `${window.innerHeight - e.top + 8}px` : "auto",
|
|
28
|
+
maxHeight: `${Math.max(80, (t ? e.top : window.innerHeight - e.bottom) - 24)}px`
|
|
29
|
+
}), u.current.showPopover();
|
|
30
|
+
}
|
|
31
|
+
function C() {
|
|
32
|
+
v(), f.current || (d.current = setTimeout(b, 180));
|
|
33
|
+
}
|
|
34
|
+
return r(() => {
|
|
35
|
+
let e = (e) => {
|
|
36
|
+
e.target instanceof Node && u.current?.contains(e.target) || (u.current?.hidePopover(), f.current = !1);
|
|
37
|
+
};
|
|
38
|
+
return window.addEventListener("scroll", e, !0), window.addEventListener("resize", e), () => {
|
|
39
|
+
clearTimeout(d.current), window.removeEventListener("scroll", e, !0), window.removeEventListener("resize", e);
|
|
40
|
+
};
|
|
41
|
+
}, []), /* @__PURE__ */ z("div", {
|
|
42
|
+
className: "ef-chat__interaction-receipt",
|
|
43
|
+
"data-message-id": e.messageId,
|
|
44
|
+
"data-history-interaction-id": a.requestId,
|
|
45
|
+
onMouseEnter: x,
|
|
46
|
+
onMouseLeave: C,
|
|
47
|
+
onBlur: (e) => {
|
|
48
|
+
e.currentTarget.contains(e.relatedTarget) || b();
|
|
49
|
+
},
|
|
50
|
+
children: [/* @__PURE__ */ z("button", {
|
|
51
|
+
ref: s,
|
|
52
|
+
type: "button",
|
|
53
|
+
className: "ef-chat__interaction-chip",
|
|
54
|
+
"aria-expanded": m,
|
|
55
|
+
"aria-controls": o,
|
|
56
|
+
"aria-haspopup": "dialog",
|
|
57
|
+
onFocus: x,
|
|
58
|
+
onClick: () => {
|
|
59
|
+
f.current ? b() : (f.current = !0, x());
|
|
60
|
+
},
|
|
61
|
+
children: [/* @__PURE__ */ R(_, {
|
|
62
|
+
size: 14,
|
|
63
|
+
"aria-hidden": "true"
|
|
64
|
+
}), /* @__PURE__ */ R("span", { children: g })]
|
|
65
|
+
}), /* @__PURE__ */ z("div", {
|
|
66
|
+
ref: u,
|
|
67
|
+
id: o,
|
|
68
|
+
popover: "auto",
|
|
69
|
+
role: "dialog",
|
|
70
|
+
"aria-label": g,
|
|
71
|
+
tabIndex: 0,
|
|
72
|
+
className: "ef-chat__interaction-popover",
|
|
73
|
+
onMouseEnter: v,
|
|
74
|
+
onMouseLeave: C,
|
|
75
|
+
onToggle: (e) => {
|
|
76
|
+
let t = e.newState === "open";
|
|
77
|
+
h(t), t || (f.current = !1);
|
|
78
|
+
},
|
|
79
|
+
children: [/* @__PURE__ */ z("div", {
|
|
80
|
+
className: "ef-chat__interaction-meta",
|
|
81
|
+
children: [!n && /* @__PURE__ */ R("span", { children: t }), a.answeredAt != null && /* @__PURE__ */ R("time", { children: Be(e.createdAt) })]
|
|
82
|
+
}), /* @__PURE__ */ R("dl", {
|
|
83
|
+
className: "ef-chat__interaction-summary",
|
|
84
|
+
children: a.rows.map((e, t) => /* @__PURE__ */ z("div", { children: [/* @__PURE__ */ R("dt", { children: e.label }), /* @__PURE__ */ R("dd", { children: e.value })] }, t))
|
|
85
|
+
})]
|
|
86
|
+
})]
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/ChatUserInputCard.tsx
|
|
91
|
+
function H({ disabled: e = !1, labels: t, onSubmit: n, request: i }) {
|
|
92
|
+
let a = JSON.stringify([
|
|
93
|
+
i.a2uiInteraction ?? null,
|
|
94
|
+
i.intro,
|
|
95
|
+
i.nativeInteraction?.details,
|
|
96
|
+
i.nativeInteraction?.responseSchema,
|
|
97
|
+
i.answers,
|
|
98
|
+
t ?? null
|
|
99
|
+
]), o = s(() => Ae(i, t), [i.requestId, a]), c = i.a2uiInteraction?.surfaceId ?? `interaction:${i.requestId}`;
|
|
100
|
+
return r(() => {
|
|
101
|
+
i.a2uiInteraction || o.apply({
|
|
102
|
+
version: "v0.9.1",
|
|
103
|
+
updateDataModel: {
|
|
104
|
+
surfaceId: c,
|
|
105
|
+
path: "/status",
|
|
106
|
+
value: e ? "Submitting" : i.status
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}, [
|
|
110
|
+
o,
|
|
111
|
+
e,
|
|
112
|
+
i.status,
|
|
113
|
+
c
|
|
114
|
+
]), /* @__PURE__ */ R("fieldset", {
|
|
115
|
+
className: "ef-chat__a2ui",
|
|
116
|
+
disabled: e || i.status !== "Pending" || !!(i.expiresAtMs && i.expiresAtMs <= Date.now()),
|
|
117
|
+
style: {
|
|
118
|
+
border: 0,
|
|
119
|
+
margin: 0,
|
|
120
|
+
padding: 0,
|
|
121
|
+
minWidth: 0
|
|
122
|
+
},
|
|
123
|
+
children: /* @__PURE__ */ R(jt, {
|
|
124
|
+
client: o,
|
|
125
|
+
surfaceId: c,
|
|
126
|
+
onAction: (e) => {
|
|
127
|
+
if (i.a2uiInteraction) {
|
|
128
|
+
n([{
|
|
129
|
+
questionId: i.requestId,
|
|
130
|
+
answerKind: "Other",
|
|
131
|
+
optionId: null,
|
|
132
|
+
otherText: JSON.stringify(e.action.context.response)
|
|
133
|
+
}]);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
let t = e.action.context.answer;
|
|
137
|
+
if (typeof t == "boolean") {
|
|
138
|
+
let e = Object.entries(i.nativeInteraction?.optionPayloads ?? {}).find(([, e]) => e === t);
|
|
139
|
+
e && n([{
|
|
140
|
+
questionId: i.requestId,
|
|
141
|
+
answerKind: "Option",
|
|
142
|
+
optionId: e[0],
|
|
143
|
+
otherText: null
|
|
144
|
+
}]);
|
|
145
|
+
} else n(Object.values(t ?? {}));
|
|
146
|
+
}
|
|
147
|
+
})
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region src/ChatUserInputGroup.tsx
|
|
152
|
+
function U(e) {
|
|
153
|
+
let t = ft(e.request, e.requests);
|
|
154
|
+
return t.length === 1 ? /* @__PURE__ */ R(H, { ...e }) : /* @__PURE__ */ R(zt, {
|
|
155
|
+
...e,
|
|
156
|
+
requests: t
|
|
157
|
+
}, JSON.stringify(t.map((e) => [
|
|
158
|
+
e.sessionId,
|
|
159
|
+
e.runId,
|
|
160
|
+
e.requestId
|
|
161
|
+
])));
|
|
162
|
+
}
|
|
163
|
+
function zt({ requests: e, labels: t, disabled: n, submitFailed: r, onSubmit: i }) {
|
|
164
|
+
let [a, o] = l({}), s = e.filter((e) => a[e.requestId]).length, c = (t) => {
|
|
165
|
+
if (n) return;
|
|
166
|
+
let r = ve(e, t);
|
|
167
|
+
r && (o(r), i(e.flatMap((e) => r[e.requestId])));
|
|
168
|
+
}, u = (t, r) => {
|
|
169
|
+
if (n) return;
|
|
170
|
+
let s = {
|
|
171
|
+
...a,
|
|
172
|
+
[t.requestId]: r
|
|
173
|
+
};
|
|
174
|
+
o(s), e.every((e) => s[e.requestId]) && i(e.flatMap((e) => s[e.requestId]));
|
|
175
|
+
};
|
|
176
|
+
return /* @__PURE__ */ z("section", {
|
|
177
|
+
className: "ef-chat__approval-batch",
|
|
178
|
+
"aria-label": t?.approvalBatch ?? "Tool approvals",
|
|
179
|
+
children: [
|
|
180
|
+
/* @__PURE__ */ z("header", {
|
|
181
|
+
className: "ef-chat__approval-batch-header",
|
|
182
|
+
children: [
|
|
183
|
+
/* @__PURE__ */ R("strong", { children: t?.approvalBatch ?? "Tool approvals" }),
|
|
184
|
+
/* @__PURE__ */ z("span", {
|
|
185
|
+
"aria-live": "polite",
|
|
186
|
+
children: [
|
|
187
|
+
s,
|
|
188
|
+
" / ",
|
|
189
|
+
e.length
|
|
190
|
+
]
|
|
191
|
+
}),
|
|
192
|
+
/* @__PURE__ */ R("p", { children: t?.approvalBatchHint ?? "Decide on every call. Execution resumes only after all decisions are submitted." })
|
|
193
|
+
]
|
|
194
|
+
}),
|
|
195
|
+
e.map((e) => /* @__PURE__ */ z("div", {
|
|
196
|
+
className: "ef-chat__approval-batch-item",
|
|
197
|
+
children: [/* @__PURE__ */ R(H, {
|
|
198
|
+
disabled: n,
|
|
199
|
+
labels: t,
|
|
200
|
+
request: a[e.requestId] ? {
|
|
201
|
+
...e,
|
|
202
|
+
answers: a[e.requestId],
|
|
203
|
+
status: "Answered"
|
|
204
|
+
} : e,
|
|
205
|
+
onSubmit: (t) => u(e, t)
|
|
206
|
+
}), a[e.requestId] && !n ? /* @__PURE__ */ z("button", {
|
|
207
|
+
type: "button",
|
|
208
|
+
className: "ef-chat__approval-batch-change",
|
|
209
|
+
onClick: () => o((t) => {
|
|
210
|
+
let n = { ...t };
|
|
211
|
+
return delete n[e.requestId], n;
|
|
212
|
+
}),
|
|
213
|
+
children: [
|
|
214
|
+
t?.approvalWaiting ?? "Waiting for batch",
|
|
215
|
+
" · ",
|
|
216
|
+
t?.approvalChange ?? "Change"
|
|
217
|
+
]
|
|
218
|
+
}) : null]
|
|
219
|
+
}, e.requestId)),
|
|
220
|
+
e.length - s > 1 ? /* @__PURE__ */ z("footer", {
|
|
221
|
+
className: "ef-chat__approval-batch-actions",
|
|
222
|
+
children: [/* @__PURE__ */ R("button", {
|
|
223
|
+
type: "button",
|
|
224
|
+
disabled: n || !ve(e, !1),
|
|
225
|
+
onClick: () => c(!1),
|
|
226
|
+
children: t?.rejectAll ?? "Reject all"
|
|
227
|
+
}), /* @__PURE__ */ R("button", {
|
|
228
|
+
type: "button",
|
|
229
|
+
className: "ef-chat__approval-batch-approve",
|
|
230
|
+
disabled: n || !ve(e, !0),
|
|
231
|
+
onClick: () => c(!0),
|
|
232
|
+
children: t?.approveAll ?? "Approve all"
|
|
233
|
+
})]
|
|
234
|
+
}) : null,
|
|
235
|
+
r && s === e.length && !n ? /* @__PURE__ */ R("button", {
|
|
236
|
+
type: "button",
|
|
237
|
+
className: "ef-chat__approval-batch-retry",
|
|
238
|
+
onClick: () => i(e.flatMap((e) => a[e.requestId])),
|
|
239
|
+
children: t?.approvalRetry ?? "Retry submission"
|
|
240
|
+
}) : null
|
|
241
|
+
]
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
//#endregion
|
|
245
|
+
//#region src/ChatGoalIndicator.tsx
|
|
246
|
+
function Bt({ objective: e, status: t, label: n, progress: r, busy: i, resumeDisabled: a, onPause: o, onResume: s, onRestart: c, onDelete: l, labels: u }) {
|
|
247
|
+
return /* @__PURE__ */ z("section", {
|
|
248
|
+
className: "ef-chat-goal",
|
|
249
|
+
"aria-label": n,
|
|
250
|
+
"aria-busy": i || void 0,
|
|
251
|
+
children: [
|
|
252
|
+
/* @__PURE__ */ R(v, {
|
|
253
|
+
className: "ef-chat-goal__icon",
|
|
254
|
+
size: 16,
|
|
255
|
+
"aria-hidden": "true"
|
|
256
|
+
}),
|
|
257
|
+
/* @__PURE__ */ z("div", {
|
|
258
|
+
className: "ef-chat-goal__content",
|
|
259
|
+
children: [/* @__PURE__ */ z("div", {
|
|
260
|
+
className: "ef-chat-goal__heading",
|
|
261
|
+
children: [
|
|
262
|
+
/* @__PURE__ */ R("span", { children: n }),
|
|
263
|
+
/* @__PURE__ */ R("span", {
|
|
264
|
+
className: "ef-chat-goal__status",
|
|
265
|
+
children: t
|
|
266
|
+
}),
|
|
267
|
+
r && /* @__PURE__ */ R("span", {
|
|
268
|
+
className: "ef-chat-goal__progress",
|
|
269
|
+
children: r
|
|
270
|
+
})
|
|
271
|
+
]
|
|
272
|
+
}), /* @__PURE__ */ R("div", {
|
|
273
|
+
className: "ef-chat-goal__objective",
|
|
274
|
+
title: e,
|
|
275
|
+
children: e
|
|
276
|
+
})]
|
|
277
|
+
}),
|
|
278
|
+
/* @__PURE__ */ z("div", {
|
|
279
|
+
className: "ef-chat-goal__actions",
|
|
280
|
+
children: [
|
|
281
|
+
o && /* @__PURE__ */ R("button", {
|
|
282
|
+
type: "button",
|
|
283
|
+
disabled: i,
|
|
284
|
+
onClick: o,
|
|
285
|
+
"aria-label": u.pause,
|
|
286
|
+
title: u.pause,
|
|
287
|
+
children: /* @__PURE__ */ R(w, {
|
|
288
|
+
size: 15,
|
|
289
|
+
"aria-hidden": "true"
|
|
290
|
+
})
|
|
291
|
+
}),
|
|
292
|
+
s && /* @__PURE__ */ R("button", {
|
|
293
|
+
type: "button",
|
|
294
|
+
disabled: i || a,
|
|
295
|
+
onClick: s,
|
|
296
|
+
"aria-label": u.resume,
|
|
297
|
+
title: u.resume,
|
|
298
|
+
children: /* @__PURE__ */ R(E, {
|
|
299
|
+
size: 15,
|
|
300
|
+
"aria-hidden": "true"
|
|
301
|
+
})
|
|
302
|
+
}),
|
|
303
|
+
c && /* @__PURE__ */ R("button", {
|
|
304
|
+
type: "button",
|
|
305
|
+
disabled: i,
|
|
306
|
+
onClick: c,
|
|
307
|
+
"aria-label": u.restart,
|
|
308
|
+
title: u.restart,
|
|
309
|
+
children: /* @__PURE__ */ R(ie, {
|
|
310
|
+
size: 15,
|
|
311
|
+
"aria-hidden": "true"
|
|
312
|
+
})
|
|
313
|
+
}),
|
|
314
|
+
l && /* @__PURE__ */ R("button", {
|
|
315
|
+
type: "button",
|
|
316
|
+
disabled: i,
|
|
317
|
+
onClick: l,
|
|
318
|
+
"aria-label": u.delete,
|
|
319
|
+
title: u.delete,
|
|
320
|
+
children: /* @__PURE__ */ R(k, {
|
|
321
|
+
size: 15,
|
|
322
|
+
"aria-hidden": "true"
|
|
323
|
+
})
|
|
324
|
+
})
|
|
325
|
+
]
|
|
326
|
+
})
|
|
327
|
+
]
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
//#endregion
|
|
331
|
+
//#region src/ChatA2UI.tsx
|
|
332
|
+
function Vt({ message: e, onAction: t, runtime: n, disabled: r }) {
|
|
333
|
+
let i = s(() => {
|
|
334
|
+
let t = (e.a2ui?.messages.length === 0 ? n?.client : void 0) ?? new Pt();
|
|
335
|
+
try {
|
|
336
|
+
for (let n of e.a2ui?.messages ?? []) t.apply(n);
|
|
337
|
+
return {
|
|
338
|
+
client: t,
|
|
339
|
+
error: !1
|
|
340
|
+
};
|
|
341
|
+
} catch {
|
|
342
|
+
return {
|
|
343
|
+
client: t,
|
|
344
|
+
error: !0
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
}, [e.a2ui, n]);
|
|
348
|
+
return i.error ? /* @__PURE__ */ R("div", {
|
|
349
|
+
role: "alert",
|
|
350
|
+
children: "Invalid A2UI message"
|
|
351
|
+
}) : /* @__PURE__ */ R("div", {
|
|
352
|
+
className: "ef-chat__a2ui",
|
|
353
|
+
children: (e.a2ui?.surfaceIds ?? Object.keys(i.client.getSnapshot().surfaces)).map((a) => /* @__PURE__ */ R("fieldset", {
|
|
354
|
+
disabled: r || e.channel === "history" || n?.getSurface(a)?.mode === "Display",
|
|
355
|
+
style: {
|
|
356
|
+
border: 0,
|
|
357
|
+
padding: 0,
|
|
358
|
+
margin: 0,
|
|
359
|
+
minWidth: 0
|
|
360
|
+
},
|
|
361
|
+
children: /* @__PURE__ */ R(jt, {
|
|
362
|
+
client: i.client,
|
|
363
|
+
surfaceId: a,
|
|
364
|
+
onAction: (r, i) => {
|
|
365
|
+
let o = n?.getSurface(a);
|
|
366
|
+
t?.(r, o ? n.metadata(o.ownerAgentId) : i, o ? {
|
|
367
|
+
sessionId: e.sessionId,
|
|
368
|
+
messageId: e.messageId,
|
|
369
|
+
surface: o
|
|
370
|
+
} : void 0);
|
|
371
|
+
}
|
|
372
|
+
})
|
|
373
|
+
}, a))
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
//#endregion
|
|
377
|
+
//#region src/chatHistory.ts
|
|
378
|
+
function Ht(e, t = 96) {
|
|
379
|
+
return Et(e.replace(/\s+/g, " ").trim(), t);
|
|
380
|
+
}
|
|
381
|
+
function Ut(e, t = 240) {
|
|
382
|
+
let n = e.replace(/\r\n?/g, "\n").trim();
|
|
383
|
+
return n.length <= t ? n : `${n.slice(0, Math.max(0, t - 3)).trimEnd()}...`;
|
|
384
|
+
}
|
|
385
|
+
function Wt(e, t) {
|
|
386
|
+
let n = [], r = null;
|
|
387
|
+
function i() {
|
|
388
|
+
r &&= (n.push(r), null);
|
|
389
|
+
}
|
|
390
|
+
e.forEach((e) => {
|
|
391
|
+
if (e.role === "USER" && !e.interactionResponse) {
|
|
392
|
+
i(), r = {
|
|
393
|
+
assistantPreview: "",
|
|
394
|
+
hasAssistantReply: !1,
|
|
395
|
+
hasWorkActivity: !1,
|
|
396
|
+
id: `turn-${e.messageId}`,
|
|
397
|
+
messageCodes: [e.messageId],
|
|
398
|
+
userMessageCode: e.messageId,
|
|
399
|
+
userPreview: Ht(e.content || (e.annotations ?? []).map((e) => e.comment).join("; "), 72) || e.provenance?.sender.displayName || e.actor || "User"
|
|
400
|
+
};
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
!r && (e.content.trim() || e.a2ui || e.history) && (r = {
|
|
404
|
+
assistantPreview: "",
|
|
405
|
+
hasAssistantReply: !1,
|
|
406
|
+
hasWorkActivity: !1,
|
|
407
|
+
id: `turn-${e.messageId}`,
|
|
408
|
+
messageCodes: [],
|
|
409
|
+
userMessageCode: e.messageId,
|
|
410
|
+
userPreview: e.provenance?.sender.displayName || e.actor || "Assistant"
|
|
411
|
+
}), r && (r.messageCodes.push(e.messageId), e.role === "ASSISTANT" && (e.content.trim() || e.a2ui) && (r.hasAssistantReply = !0, r.assistantPreview = Ut(e.content)));
|
|
412
|
+
}), i();
|
|
413
|
+
let a = /* @__PURE__ */ new Set();
|
|
414
|
+
return t.waitingForModelAnchorMessageCode && a.add(t.waitingForModelAnchorMessageCode), t.workRailsByMessageCode.forEach((e, t) => {
|
|
415
|
+
e.length && a.add(t);
|
|
416
|
+
}), n.forEach((e) => {
|
|
417
|
+
e.hasWorkActivity = e.messageCodes.some((e) => a.has(e));
|
|
418
|
+
}), n.filter((e) => e.userPreview);
|
|
419
|
+
}
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region src/ChatHistoryRail.tsx
|
|
422
|
+
function Gt(...e) {
|
|
423
|
+
return e.filter(Boolean).join(" ");
|
|
424
|
+
}
|
|
425
|
+
function W(e, t) {
|
|
426
|
+
let n = e.scrollHeight - e.clientHeight;
|
|
427
|
+
if (n > 0 && e.scrollTop >= n - 1) return t.at(-1) ?? "";
|
|
428
|
+
let r = e.getBoundingClientRect().top, i = t[0] ?? "", a = Infinity;
|
|
429
|
+
return t.forEach((t) => {
|
|
430
|
+
let n = e.querySelector(`[data-chat-turn-id="${t}"]`);
|
|
431
|
+
if (!n) return;
|
|
432
|
+
let o = n.getBoundingClientRect(), s = Math.abs(o.top - r - 24);
|
|
433
|
+
s < a && (a = s, i = t);
|
|
434
|
+
}), i;
|
|
435
|
+
}
|
|
436
|
+
function Kt(e) {
|
|
437
|
+
let t = Math.max(0, 1 - e / 60);
|
|
438
|
+
return t * t;
|
|
439
|
+
}
|
|
440
|
+
function qt(e, t) {
|
|
441
|
+
let n = 0, r = Infinity;
|
|
442
|
+
return e.forEach((e, i) => {
|
|
443
|
+
let a = Math.abs(e - t);
|
|
444
|
+
a < r && (r = a, n = i);
|
|
445
|
+
}), n;
|
|
446
|
+
}
|
|
447
|
+
function Jt({ messages: e, transcriptRef: t, presentation: n }) {
|
|
448
|
+
let i = s(() => Wt(e, n), [e, n]), [a, u] = l(""), [d, f] = l(""), [p, m] = l(null), [h, g] = l([]), _ = c(null), v = c([]);
|
|
449
|
+
r(() => {
|
|
450
|
+
let e = t.current;
|
|
451
|
+
if (!e || !i.length) {
|
|
452
|
+
u("");
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
let n = i.map((e) => e.id);
|
|
456
|
+
function r() {
|
|
457
|
+
let e = t.current;
|
|
458
|
+
e && u(W(e, n));
|
|
459
|
+
}
|
|
460
|
+
return r(), e.addEventListener("scroll", r, { passive: !0 }), window.addEventListener("resize", r), () => {
|
|
461
|
+
e.removeEventListener("scroll", r), window.removeEventListener("resize", r);
|
|
462
|
+
};
|
|
463
|
+
}, [t, i]), r(() => {
|
|
464
|
+
i.some((e) => e.id === d) || f("");
|
|
465
|
+
}, [d, i]), o(() => {
|
|
466
|
+
let e = _.current;
|
|
467
|
+
if (!e) {
|
|
468
|
+
g([]);
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
function t() {
|
|
472
|
+
let t = e.getBoundingClientRect();
|
|
473
|
+
g(v.current.map((e) => {
|
|
474
|
+
if (!e) return 0;
|
|
475
|
+
let n = e.getBoundingClientRect();
|
|
476
|
+
return n.top - t.top + n.height / 2;
|
|
477
|
+
}));
|
|
478
|
+
}
|
|
479
|
+
return t(), window.addEventListener("resize", t), () => window.removeEventListener("resize", t);
|
|
480
|
+
}, [i]), r(() => {
|
|
481
|
+
if (p === null) {
|
|
482
|
+
f("");
|
|
483
|
+
return;
|
|
484
|
+
}
|
|
485
|
+
let e = i[p];
|
|
486
|
+
f(e?.id ?? "");
|
|
487
|
+
}, [p, i]);
|
|
488
|
+
let y = () => {
|
|
489
|
+
if (p === null) return;
|
|
490
|
+
let e = i[p];
|
|
491
|
+
e && (t.current?.querySelector(`[data-chat-turn-id="${e.id}"]`))?.scrollIntoView({
|
|
492
|
+
behavior: "smooth",
|
|
493
|
+
block: "start"
|
|
494
|
+
});
|
|
495
|
+
}, b = i.find((e) => e.id === d) ?? null, x = p === null ? null : h[p];
|
|
496
|
+
return i.length ? /* @__PURE__ */ z("div", {
|
|
497
|
+
className: "ef-chat-history-rail",
|
|
498
|
+
ref: _,
|
|
499
|
+
onMouseLeave: () => m(null),
|
|
500
|
+
onMouseMove: (e) => {
|
|
501
|
+
let t = _.current;
|
|
502
|
+
if (!t || h.length === 0) return;
|
|
503
|
+
let n = t.getBoundingClientRect(), r = e.clientY - n.top;
|
|
504
|
+
m(qt(h, r));
|
|
505
|
+
},
|
|
506
|
+
onClick: y,
|
|
507
|
+
children: [/* @__PURE__ */ R("div", {
|
|
508
|
+
className: "ef-chat-history-rail__markers",
|
|
509
|
+
"aria-label": "Chat history",
|
|
510
|
+
children: i.map((e, n) => {
|
|
511
|
+
let r = p === null && e.id === a, i = p === n, o = p === null ? null : h[p] ?? null, s = Kt(o === null ? Infinity : Math.abs((h[n] ?? 0) - o)), c = i ? 24 : 6 + s * 14 + (r ? 8 : 0);
|
|
512
|
+
return /* @__PURE__ */ R("button", {
|
|
513
|
+
className: Gt("ef-chat-history-rail__marker", r && "ef-chat-history-rail__marker--active"),
|
|
514
|
+
type: "button",
|
|
515
|
+
"aria-label": e.userPreview,
|
|
516
|
+
"data-active": r ? "true" : "false",
|
|
517
|
+
"data-hovered": i ? "true" : "false",
|
|
518
|
+
ref: (e) => {
|
|
519
|
+
v.current[n] = e;
|
|
520
|
+
},
|
|
521
|
+
style: { width: p === null ? `${r ? 14 : 6}px` : `${c}px` },
|
|
522
|
+
onClick: () => {
|
|
523
|
+
(t.current?.querySelector(`[data-chat-turn-id="${e.id}"]`))?.scrollIntoView({
|
|
524
|
+
behavior: "smooth",
|
|
525
|
+
block: "start"
|
|
526
|
+
});
|
|
527
|
+
},
|
|
528
|
+
onMouseEnter: () => m(n),
|
|
529
|
+
onFocus: () => {
|
|
530
|
+
m(n);
|
|
531
|
+
},
|
|
532
|
+
onBlur: () => m((e) => e === n ? null : e),
|
|
533
|
+
children: /* @__PURE__ */ R("span", {
|
|
534
|
+
className: "ef-chat-history-rail__sr-only",
|
|
535
|
+
children: e.userPreview
|
|
536
|
+
})
|
|
537
|
+
}, e.id);
|
|
538
|
+
})
|
|
539
|
+
}), b && x !== null ? /* @__PURE__ */ z("span", {
|
|
540
|
+
className: Gt("ef-chat-history-rail__preview", !b.hasAssistantReply && b.hasWorkActivity && "ef-chat-history-rail__preview--compact"),
|
|
541
|
+
role: "tooltip",
|
|
542
|
+
style: { top: `${x}px` },
|
|
543
|
+
children: [/* @__PURE__ */ R("span", {
|
|
544
|
+
className: "ef-chat-history-rail__preview-user",
|
|
545
|
+
children: b.userPreview
|
|
546
|
+
}), b.hasAssistantReply ? /* @__PURE__ */ R("span", {
|
|
547
|
+
className: "ef-chat-history-rail__preview-assistant markdown-body",
|
|
548
|
+
children: /* @__PURE__ */ R(Ft, {
|
|
549
|
+
remarkPlugins: [It],
|
|
550
|
+
children: b.assistantPreview
|
|
551
|
+
})
|
|
552
|
+
}) : null]
|
|
553
|
+
}) : null]
|
|
554
|
+
}) : null;
|
|
555
|
+
}
|
|
556
|
+
//#endregion
|
|
557
|
+
//#region src/chatAttachments.ts
|
|
558
|
+
function Yt(e) {
|
|
559
|
+
return e === "image/png" || e === "image/jpeg" || e === "image/webp" || e === "image/gif";
|
|
560
|
+
}
|
|
561
|
+
function Xt(e) {
|
|
562
|
+
let t = e.contentType?.toLowerCase();
|
|
563
|
+
return e.kind === "image" || !!e.imageUrl || Yt(t);
|
|
564
|
+
}
|
|
565
|
+
function Zt(e, t) {
|
|
566
|
+
let [n, i] = l(null);
|
|
567
|
+
return r(() => {
|
|
568
|
+
if (e.imageUrl || !t || !Xt(e)) {
|
|
569
|
+
i(null);
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
let n = !0, r = null;
|
|
573
|
+
return t(e).then((e) => {
|
|
574
|
+
let t = URL.createObjectURL(e);
|
|
575
|
+
if (!n) {
|
|
576
|
+
URL.revokeObjectURL(t);
|
|
577
|
+
return;
|
|
578
|
+
}
|
|
579
|
+
r = t, i(t);
|
|
580
|
+
}).catch(() => {
|
|
581
|
+
n && i(null);
|
|
582
|
+
}), () => {
|
|
583
|
+
n = !1, r && URL.revokeObjectURL(r);
|
|
584
|
+
};
|
|
585
|
+
}, [e, t]), e.imageUrl ?? n;
|
|
586
|
+
}
|
|
587
|
+
//#endregion
|
|
588
|
+
//#region src/MermaidBlock.tsx
|
|
589
|
+
var Qt = e({
|
|
590
|
+
content: "",
|
|
591
|
+
streaming: !1
|
|
592
|
+
});
|
|
593
|
+
function $t({ source: e, ready: t }) {
|
|
594
|
+
let n = c(null), i = c(null);
|
|
595
|
+
return r(() => {
|
|
596
|
+
if (!n.current) return;
|
|
597
|
+
let e = new de(n.current);
|
|
598
|
+
return i.current = e, () => {
|
|
599
|
+
e.dispose(), i.current = null;
|
|
600
|
+
};
|
|
601
|
+
}, []), r(() => {
|
|
602
|
+
i.current?.update(e, t);
|
|
603
|
+
}, [e, t]), /* @__PURE__ */ R("div", {
|
|
604
|
+
className: "ef-chat__mermaid",
|
|
605
|
+
"data-theme-part": "chat-mermaid",
|
|
606
|
+
ref: n
|
|
607
|
+
});
|
|
608
|
+
}
|
|
609
|
+
var en = ({ node: e, children: t, ...r }) => {
|
|
610
|
+
let i = n(Qt), a = e?.children[0];
|
|
611
|
+
if (a?.type === "element" && a.tagName === "code") {
|
|
612
|
+
let t = a.properties.className;
|
|
613
|
+
if (Array.isArray(t) && t.some((e) => String(e).toLowerCase() === "language-mermaid")) {
|
|
614
|
+
let t = a.children.map((e) => e.type === "text" ? e.value : "").join(""), n = i.content.slice(e?.position?.start.offset ?? 0, e?.position?.end.offset);
|
|
615
|
+
return /* @__PURE__ */ R($t, {
|
|
616
|
+
source: t,
|
|
617
|
+
ready: !i.streaming || it(n)
|
|
618
|
+
});
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
return /* @__PURE__ */ R("pre", {
|
|
622
|
+
...r,
|
|
623
|
+
children: t
|
|
624
|
+
});
|
|
625
|
+
};
|
|
626
|
+
//#endregion
|
|
627
|
+
//#region src/ChatPanel.tsx
|
|
628
|
+
function G(...e) {
|
|
629
|
+
return e.filter(Boolean).join(" ");
|
|
630
|
+
}
|
|
631
|
+
async function tn(e) {
|
|
632
|
+
if (navigator.clipboard?.writeText) {
|
|
633
|
+
await navigator.clipboard.writeText(e);
|
|
634
|
+
return;
|
|
635
|
+
}
|
|
636
|
+
let t = document.createElement("textarea");
|
|
637
|
+
t.value = e, t.setAttribute("readonly", "true"), t.style.position = "fixed", t.style.left = "-9999px", document.body.appendChild(t), t.select(), document.execCommand("copy"), document.body.removeChild(t);
|
|
638
|
+
}
|
|
639
|
+
var nn = e(Pe), rn = e([]);
|
|
640
|
+
function an({ href: e, children: t }) {
|
|
641
|
+
let r = n(rn), i = n(sn), a = n(nn), o = we(e, r);
|
|
642
|
+
return o ? /* @__PURE__ */ R("span", {
|
|
643
|
+
className: "ef-chat__annotation-reference",
|
|
644
|
+
tabIndex: 0,
|
|
645
|
+
role: "button",
|
|
646
|
+
"data-annotation-source-id": o.messageId,
|
|
647
|
+
"data-annotation-tooltip": Te(o, a),
|
|
648
|
+
children: t
|
|
649
|
+
}) : i ? i({
|
|
650
|
+
href: e,
|
|
651
|
+
children: t
|
|
652
|
+
}) : /* @__PURE__ */ R("a", {
|
|
653
|
+
href: e,
|
|
654
|
+
children: t
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
function on({ annotations: e, formatCount: t }) {
|
|
658
|
+
let r = n(nn);
|
|
659
|
+
return e.length ? /* @__PURE__ */ R("div", {
|
|
660
|
+
className: "ef-chat__text-annotations",
|
|
661
|
+
children: /* @__PURE__ */ z("span", {
|
|
662
|
+
className: "ef-chat__annotation-reference ef-chat__inspection-count",
|
|
663
|
+
tabIndex: 0,
|
|
664
|
+
role: "note",
|
|
665
|
+
"data-annotation-tooltip": e.map((e) => Te(e, r)).join("\n\n"),
|
|
666
|
+
children: [
|
|
667
|
+
/* @__PURE__ */ R(te, { size: 16 }),
|
|
668
|
+
" ",
|
|
669
|
+
t(e.length)
|
|
670
|
+
]
|
|
671
|
+
})
|
|
672
|
+
}) : null;
|
|
673
|
+
}
|
|
674
|
+
var sn = e(void 0);
|
|
675
|
+
function cn({ content: e, emptyMessage: t, streaming: n = !1 }) {
|
|
676
|
+
return /* @__PURE__ */ R("div", {
|
|
677
|
+
className: "markdown-body",
|
|
678
|
+
"data-chat-annotation-source": "true",
|
|
679
|
+
children: /* @__PURE__ */ R(Qt.Provider, {
|
|
680
|
+
value: {
|
|
681
|
+
content: e || t,
|
|
682
|
+
streaming: n
|
|
683
|
+
},
|
|
684
|
+
children: /* @__PURE__ */ R(Ft, {
|
|
685
|
+
remarkPlugins: [It],
|
|
686
|
+
components: {
|
|
687
|
+
pre: en,
|
|
688
|
+
a: an
|
|
689
|
+
},
|
|
690
|
+
children: e || t
|
|
691
|
+
})
|
|
692
|
+
})
|
|
693
|
+
});
|
|
694
|
+
}
|
|
695
|
+
function ln(e) {
|
|
696
|
+
return `${e} annotation${e === 1 ? "" : "s"}`;
|
|
697
|
+
}
|
|
698
|
+
var un = {
|
|
699
|
+
attachments: "Attachments",
|
|
700
|
+
annotationPreview: "Annotation preview"
|
|
701
|
+
};
|
|
702
|
+
function dn({ attachment: e, downloadAttachment: t, onPreview: n }) {
|
|
703
|
+
let r = Zt(e, t);
|
|
704
|
+
return r ? /* @__PURE__ */ R("figure", {
|
|
705
|
+
className: "ef-chat__inspection-preview",
|
|
706
|
+
children: /* @__PURE__ */ R("button", {
|
|
707
|
+
"aria-label": `Preview ${e.summary}`,
|
|
708
|
+
className: "ef-chat__inspection-preview-button",
|
|
709
|
+
type: "button",
|
|
710
|
+
onClick: () => n(r, e.summary),
|
|
711
|
+
children: /* @__PURE__ */ R("img", {
|
|
712
|
+
alt: e.summary,
|
|
713
|
+
src: r
|
|
714
|
+
})
|
|
715
|
+
})
|
|
716
|
+
}) : null;
|
|
717
|
+
}
|
|
718
|
+
function fn({ attachment: e, downloadAttachment: t }) {
|
|
719
|
+
let n = e.fileName || e.title || e.summary || e.id;
|
|
720
|
+
async function r() {
|
|
721
|
+
if (t) try {
|
|
722
|
+
let n = await t(e), r = URL.createObjectURL(n), i = document.createElement("a");
|
|
723
|
+
i.href = r, i.download = e.fileName || e.title || e.id, i.click(), window.setTimeout(() => URL.revokeObjectURL(r), 0);
|
|
724
|
+
} catch {}
|
|
725
|
+
}
|
|
726
|
+
return /* @__PURE__ */ z("button", {
|
|
727
|
+
className: "ef-chat__attachment-file",
|
|
728
|
+
disabled: !t,
|
|
729
|
+
title: t ? `Download ${n}` : n,
|
|
730
|
+
type: "button",
|
|
731
|
+
onClick: () => {
|
|
732
|
+
r();
|
|
733
|
+
},
|
|
734
|
+
children: [
|
|
735
|
+
/* @__PURE__ */ R(S, {
|
|
736
|
+
"aria-hidden": "true",
|
|
737
|
+
size: 15
|
|
738
|
+
}),
|
|
739
|
+
/* @__PURE__ */ R("span", { children: n }),
|
|
740
|
+
e.byteSize ? /* @__PURE__ */ R("small", { children: mn(e.byteSize) }) : null
|
|
741
|
+
]
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
function pn({ attachment: e, downloadAttachment: t, onPreview: n }) {
|
|
745
|
+
let r = Zt(e, t), i = e.summary || e.fileName || e.id;
|
|
746
|
+
return /* @__PURE__ */ z("div", {
|
|
747
|
+
className: "ef-chat__annotation-preview-item",
|
|
748
|
+
children: [r ? /* @__PURE__ */ R("button", {
|
|
749
|
+
"aria-label": `Preview ${i}`,
|
|
750
|
+
className: "ef-chat__annotation-preview-image-button",
|
|
751
|
+
type: "button",
|
|
752
|
+
onClick: () => n(r, i),
|
|
753
|
+
children: /* @__PURE__ */ R("img", {
|
|
754
|
+
alt: i,
|
|
755
|
+
src: r
|
|
756
|
+
})
|
|
757
|
+
}) : /* @__PURE__ */ R("div", {
|
|
758
|
+
className: "ef-chat__annotation-preview-placeholder",
|
|
759
|
+
children: /* @__PURE__ */ R(S, {
|
|
760
|
+
"aria-hidden": "true",
|
|
761
|
+
size: 16
|
|
762
|
+
})
|
|
763
|
+
}), /* @__PURE__ */ R("span", {
|
|
764
|
+
title: i,
|
|
765
|
+
children: i
|
|
766
|
+
})]
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
function mn(e) {
|
|
770
|
+
return e < 1024 ? `${e} B` : e < 1048576 ? `${Math.ceil(e / 1024)} KB` : `${(e / 1048576).toFixed(1)} MB`;
|
|
771
|
+
}
|
|
772
|
+
function hn({ attachments: e, attachmentLabels: t, downloadAttachment: n, formatAnnotationCount: r, onPreviewImage: a }) {
|
|
773
|
+
let o = e ?? [], s = o.filter((e) => e.kind === "inspection"), c = o.filter(Xt), u = o.filter((e) => !Xt(e)), [d, f] = l(!1), p = i();
|
|
774
|
+
if (!o.length) return null;
|
|
775
|
+
let m = s.length ? r(s.length) : t.attachments;
|
|
776
|
+
return /* @__PURE__ */ z("section", {
|
|
777
|
+
"aria-label": m || t.attachments,
|
|
778
|
+
className: "ef-chat__inspection-attachments",
|
|
779
|
+
children: [
|
|
780
|
+
/* @__PURE__ */ R("div", {
|
|
781
|
+
className: "ef-chat__inspection-previews",
|
|
782
|
+
children: c.map((e) => /* @__PURE__ */ R(dn, {
|
|
783
|
+
attachment: e,
|
|
784
|
+
downloadAttachment: n,
|
|
785
|
+
onPreview: a
|
|
786
|
+
}, e.id))
|
|
787
|
+
}),
|
|
788
|
+
u.length ? /* @__PURE__ */ R("div", {
|
|
789
|
+
className: "ef-chat__attachment-files",
|
|
790
|
+
children: u.map((e) => /* @__PURE__ */ R(fn, {
|
|
791
|
+
attachment: e,
|
|
792
|
+
downloadAttachment: n
|
|
793
|
+
}, e.id))
|
|
794
|
+
}) : null,
|
|
795
|
+
s.length ? /* @__PURE__ */ z("div", {
|
|
796
|
+
className: "ef-chat__inspection-count-wrap",
|
|
797
|
+
onBlur: (e) => {
|
|
798
|
+
e.currentTarget.contains(e.relatedTarget) || f(!1);
|
|
799
|
+
},
|
|
800
|
+
onFocus: () => f(!0),
|
|
801
|
+
onMouseEnter: () => f(!0),
|
|
802
|
+
onMouseLeave: () => f(!1),
|
|
803
|
+
children: [/* @__PURE__ */ z("button", {
|
|
804
|
+
"aria-controls": p,
|
|
805
|
+
"aria-expanded": d,
|
|
806
|
+
"aria-label": `${t.annotationPreview}: ${m}`,
|
|
807
|
+
className: "ef-chat__inspection-count",
|
|
808
|
+
type: "button",
|
|
809
|
+
children: [/* @__PURE__ */ R(te, {
|
|
810
|
+
"aria-hidden": "true",
|
|
811
|
+
size: 16
|
|
812
|
+
}), /* @__PURE__ */ R("span", { children: m })]
|
|
813
|
+
}), d ? /* @__PURE__ */ z("div", {
|
|
814
|
+
"aria-label": t.annotationPreview,
|
|
815
|
+
className: "ef-chat__annotation-preview",
|
|
816
|
+
id: p,
|
|
817
|
+
role: "tooltip",
|
|
818
|
+
children: [/* @__PURE__ */ R("strong", { children: t.annotationPreview }), /* @__PURE__ */ R("div", {
|
|
819
|
+
className: "ef-chat__annotation-preview-list",
|
|
820
|
+
children: s.map((e) => /* @__PURE__ */ R(pn, {
|
|
821
|
+
attachment: e,
|
|
822
|
+
downloadAttachment: n,
|
|
823
|
+
onPreview: a
|
|
824
|
+
}, e.id))
|
|
825
|
+
})]
|
|
826
|
+
}) : null]
|
|
827
|
+
}) : null
|
|
828
|
+
]
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
function gn({ image: e, onClose: t }) {
|
|
832
|
+
return r(() => {
|
|
833
|
+
if (!e) return;
|
|
834
|
+
function n(e) {
|
|
835
|
+
e.key === "Escape" && t();
|
|
836
|
+
}
|
|
837
|
+
return document.addEventListener("keydown", n), () => document.removeEventListener("keydown", n);
|
|
838
|
+
}, [e, t]), e ? /* @__PURE__ */ R("div", {
|
|
839
|
+
"aria-label": "Image preview",
|
|
840
|
+
"aria-modal": "true",
|
|
841
|
+
className: "ef-chat__image-preview-dialog",
|
|
842
|
+
role: "dialog",
|
|
843
|
+
"data-theme-anchor": "dialog",
|
|
844
|
+
onMouseDown: (e) => {
|
|
845
|
+
e.target === e.currentTarget && t();
|
|
846
|
+
},
|
|
847
|
+
children: /* @__PURE__ */ z("div", {
|
|
848
|
+
className: "ef-chat__image-preview-content",
|
|
849
|
+
children: [/* @__PURE__ */ R("button", {
|
|
850
|
+
"aria-label": "Close image preview",
|
|
851
|
+
className: "ef-chat__image-preview-close",
|
|
852
|
+
title: "Close image preview",
|
|
853
|
+
type: "button",
|
|
854
|
+
onClick: t,
|
|
855
|
+
children: /* @__PURE__ */ R(ae, { size: 18 })
|
|
856
|
+
}), /* @__PURE__ */ R("img", {
|
|
857
|
+
alt: e.alt,
|
|
858
|
+
src: e.source
|
|
859
|
+
})]
|
|
860
|
+
})
|
|
861
|
+
}) : null;
|
|
862
|
+
}
|
|
863
|
+
function _n({ ariaLabel: e, title: t, value: n }) {
|
|
864
|
+
let [i, a] = l(!1), o = c(null);
|
|
865
|
+
r(() => () => {
|
|
866
|
+
o.current !== null && window.clearTimeout(o.current);
|
|
867
|
+
}, []);
|
|
868
|
+
async function s() {
|
|
869
|
+
n.trim() && (await tn(n), a(!0), o.current !== null && window.clearTimeout(o.current), o.current = window.setTimeout(() => a(!1), 1400));
|
|
870
|
+
}
|
|
871
|
+
return /* @__PURE__ */ R("button", {
|
|
872
|
+
className: "ef-chat__icon-button",
|
|
873
|
+
type: "button",
|
|
874
|
+
"aria-label": e,
|
|
875
|
+
disabled: !n.trim(),
|
|
876
|
+
title: t,
|
|
877
|
+
onClick: () => void s(),
|
|
878
|
+
children: R(i ? m : x, { size: 14 })
|
|
879
|
+
});
|
|
880
|
+
}
|
|
881
|
+
function vn({ currentUserDisplayName: e, hideMessageIdentity: t = !1, emptyAssistantMessage: r = "No assistant response was produced.", isStreaming: i = !1, message: a, processMessage: o = !1, a2uiSession: s, a2uiDisabled: c, onA2UIAction: l, onEditMessage: u, onDeleteTurn: f, deleteTurnLabel: p = "Delete turn" }) {
|
|
882
|
+
let m = a.provenance?.sender.kind.toUpperCase() === "SYSTEM", h = a.role === "USER" && !m, g = n(rn), _ = n(nn), v = h ? [] : g.filter((e) => !a.content.includes(`#chat-annotation-${e.id}`)), y = at(a, e), b = P(a);
|
|
883
|
+
return h && a.interactionResponse ? /* @__PURE__ */ R("div", {
|
|
884
|
+
className: "ef-chat__message-entry ef-chat__message-entry--user",
|
|
885
|
+
children: /* @__PURE__ */ R(V, {
|
|
886
|
+
message: a,
|
|
887
|
+
actorName: y,
|
|
888
|
+
hideMessageIdentity: t
|
|
889
|
+
})
|
|
890
|
+
}) : /* @__PURE__ */ z("div", {
|
|
891
|
+
className: G("ef-chat__message-entry", h && "ef-chat__message-entry--user", o && "ef-chat__message-entry--process"),
|
|
892
|
+
children: [/* @__PURE__ */ z("article", {
|
|
893
|
+
className: G("ef-chat__message", h && "ef-chat__message--user", m && "ef-chat__message--system", o && "ef-chat__message--process"),
|
|
894
|
+
"data-message-id": a.messageId,
|
|
895
|
+
"data-theme-anchor": "chat-message",
|
|
896
|
+
"data-theme-part": m ? "chat-message-system" : h ? "chat-message-user" : "chat-message-assistant",
|
|
897
|
+
"data-streaming": i ? "true" : void 0,
|
|
898
|
+
children: [
|
|
899
|
+
!o && !t ? /* @__PURE__ */ R("div", {
|
|
900
|
+
className: "ef-chat__message-header",
|
|
901
|
+
children: /* @__PURE__ */ z("div", {
|
|
902
|
+
className: "ef-chat__message-actor",
|
|
903
|
+
children: [b ? /* @__PURE__ */ R("img", {
|
|
904
|
+
src: b,
|
|
905
|
+
alt: "",
|
|
906
|
+
width: 16,
|
|
907
|
+
height: 16
|
|
908
|
+
}) : F(a) ? /* @__PURE__ */ R(A, { size: 16 }) : /* @__PURE__ */ R(d, { size: 16 }), /* @__PURE__ */ R("span", {
|
|
909
|
+
"data-interaction-response-sender": a.interactionResponse ? a.provenance?.sender.kind : void 0,
|
|
910
|
+
children: y
|
|
911
|
+
})]
|
|
912
|
+
})
|
|
913
|
+
}) : null,
|
|
914
|
+
h ? /* @__PURE__ */ R("div", {
|
|
915
|
+
className: "ef-chat__message-body",
|
|
916
|
+
"data-chat-annotation-source": a.interactionResponse ? void 0 : "true",
|
|
917
|
+
"data-history-interaction-id": a.interactionResponse?.requestId,
|
|
918
|
+
children: a.interactionResponse ? /* @__PURE__ */ R("dl", {
|
|
919
|
+
className: "ef-chat__interaction-summary",
|
|
920
|
+
children: a.interactionResponse.rows.map((e, t) => /* @__PURE__ */ z("div", { children: [/* @__PURE__ */ R("dt", { children: e.label }), /* @__PURE__ */ R("dd", { children: e.value })] }, t))
|
|
921
|
+
}) : a.content
|
|
922
|
+
}) : /* @__PURE__ */ R(cn, {
|
|
923
|
+
content: a.content,
|
|
924
|
+
streaming: i,
|
|
925
|
+
emptyMessage: a.a2ui ? "" : r
|
|
926
|
+
}),
|
|
927
|
+
v.length ? /* @__PURE__ */ R("div", {
|
|
928
|
+
className: "ef-chat__reply-annotations",
|
|
929
|
+
children: v.map((e) => /* @__PURE__ */ R("span", {
|
|
930
|
+
role: "button",
|
|
931
|
+
"data-annotation-source-id": e.messageId,
|
|
932
|
+
tabIndex: 0,
|
|
933
|
+
className: "ef-chat__annotation-reference",
|
|
934
|
+
"data-annotation-tooltip": Te(e, _),
|
|
935
|
+
children: _.annotation(g.indexOf(e) + 1)
|
|
936
|
+
}, e.id))
|
|
937
|
+
}) : null,
|
|
938
|
+
a.a2ui ? /* @__PURE__ */ R(Vt, {
|
|
939
|
+
message: a,
|
|
940
|
+
runtime: s,
|
|
941
|
+
disabled: c,
|
|
942
|
+
onAction: l
|
|
943
|
+
}) : null
|
|
944
|
+
]
|
|
945
|
+
}), /* @__PURE__ */ z("div", {
|
|
946
|
+
className: "ef-chat__message-actions ef-chat__message-actions--outside",
|
|
947
|
+
children: [
|
|
948
|
+
/* @__PURE__ */ R(_n, {
|
|
949
|
+
ariaLabel: "Copy raw markdown",
|
|
950
|
+
title: "Copy raw markdown",
|
|
951
|
+
value: a.content
|
|
952
|
+
}),
|
|
953
|
+
h && !a.interactionResponse && u ? /* @__PURE__ */ R("button", {
|
|
954
|
+
className: "ef-chat__icon-button",
|
|
955
|
+
type: "button",
|
|
956
|
+
"aria-label": "Edit message",
|
|
957
|
+
onClick: () => u(a.content, a),
|
|
958
|
+
children: /* @__PURE__ */ R(T, { size: 14 })
|
|
959
|
+
}) : null,
|
|
960
|
+
h && !a.interactionResponse && a.history?.run && f ? /* @__PURE__ */ R("button", {
|
|
961
|
+
className: "ef-chat__icon-button",
|
|
962
|
+
type: "button",
|
|
963
|
+
"aria-label": p,
|
|
964
|
+
title: p,
|
|
965
|
+
onClick: () => f(a),
|
|
966
|
+
children: /* @__PURE__ */ R(k, {
|
|
967
|
+
"aria-hidden": "true",
|
|
968
|
+
size: 14
|
|
969
|
+
})
|
|
970
|
+
}) : null,
|
|
971
|
+
!a.interactionResponse || a.interactionResponse.answeredAt != null ? /* @__PURE__ */ R("span", {
|
|
972
|
+
className: "ef-chat__message-time",
|
|
973
|
+
children: Be(a.createdAt)
|
|
974
|
+
}) : null
|
|
975
|
+
]
|
|
976
|
+
})]
|
|
977
|
+
});
|
|
978
|
+
}
|
|
979
|
+
function yn(e) {
|
|
980
|
+
if (e < 1e3) return "<1s";
|
|
981
|
+
let t = Math.max(1, Math.round(e / 1e3));
|
|
982
|
+
if (t < 60) return `${t}s`;
|
|
983
|
+
let n = Math.floor(t / 60), r = t % 60;
|
|
984
|
+
if (n < 60) return r ? `${n}m ${r}s` : `${n}m`;
|
|
985
|
+
let i = Math.floor(n / 60), a = n % 60;
|
|
986
|
+
return a ? `${i}h ${a}m` : `${i}h`;
|
|
987
|
+
}
|
|
988
|
+
var K = {
|
|
989
|
+
ariaLabel: "Agent work",
|
|
990
|
+
preparing: "Preparing request…",
|
|
991
|
+
responding: "Drafting response…",
|
|
992
|
+
thinking: "Thinking…",
|
|
993
|
+
workedFor: (e) => `Work completed ${e}`,
|
|
994
|
+
workingFor: (e) => `Working for ${e}`,
|
|
995
|
+
failed: "Run failed",
|
|
996
|
+
notices: {
|
|
997
|
+
mcpUnavailable: "MCP integration unavailable",
|
|
998
|
+
presentationIncomplete: "Presentation replay is incomplete",
|
|
999
|
+
presentationIncompleteDetail: "Some output could not be displayed or saved. The execution result is reported separately.",
|
|
1000
|
+
compactionRequested: "Preparing to compact context…",
|
|
1001
|
+
compactionStarted: "Compacting context…",
|
|
1002
|
+
compactionCompleted: "Context compacted",
|
|
1003
|
+
compactionFailed: "Context compaction failed",
|
|
1004
|
+
compactionInterrupted: "Run ended before compaction completion was reported",
|
|
1005
|
+
toolSchemaOverBudget: "Tool definitions exceed the context budget",
|
|
1006
|
+
toolSchemaBudget: (e, t, n) => `Tool definitions use about ${e.toLocaleString()} tokens, exceeding the ${t.toLocaleString()} limit (${n.toLocaleString()} tools).`,
|
|
1007
|
+
toolSchemaBudgetHint: "Reduce exposed tools or increase the Tool Schema budget."
|
|
1008
|
+
}
|
|
1009
|
+
}, bn = {
|
|
1010
|
+
ariaLabel: "Tool run steps",
|
|
1011
|
+
completed: (e) => e,
|
|
1012
|
+
running: (e) => e,
|
|
1013
|
+
group: (e) => `${e} ${e === 1 ? "tool call" : "tool calls"}`,
|
|
1014
|
+
groupSummary: Le,
|
|
1015
|
+
statusDone: "done",
|
|
1016
|
+
statusRunning: "running",
|
|
1017
|
+
parameters: "Parameters",
|
|
1018
|
+
result: "Result",
|
|
1019
|
+
log: "Log",
|
|
1020
|
+
noResult: "No result payload.",
|
|
1021
|
+
waitingActivity: "Waiting for tool activity...",
|
|
1022
|
+
copyParameters: "Copy parameters",
|
|
1023
|
+
copyResult: "Copy result",
|
|
1024
|
+
reasoningCaptured: "Reasoning captured.",
|
|
1025
|
+
reasoningThinking: "Thinking...",
|
|
1026
|
+
reasoningAria: "Thinking",
|
|
1027
|
+
emptyReasoning: "No reasoning content was produced.",
|
|
1028
|
+
subagentDispatched: (e) => e ? `Dispatched ${e} subagent` : "Subagent dispatched",
|
|
1029
|
+
resolveName: (e, t) => wt(e, t)
|
|
1030
|
+
};
|
|
1031
|
+
function q(e, t) {
|
|
1032
|
+
return Re(t, [
|
|
1033
|
+
e?.ariaLabel,
|
|
1034
|
+
e?.thinking,
|
|
1035
|
+
e?.preparing,
|
|
1036
|
+
e?.responding
|
|
1037
|
+
]);
|
|
1038
|
+
}
|
|
1039
|
+
function xn(e) {
|
|
1040
|
+
if (!e) return !1;
|
|
1041
|
+
try {
|
|
1042
|
+
let t = JSON.parse(e);
|
|
1043
|
+
return !!(t && typeof t == "object" && "isError" in t && t.isError === !0);
|
|
1044
|
+
} catch {
|
|
1045
|
+
return !1;
|
|
1046
|
+
}
|
|
1047
|
+
}
|
|
1048
|
+
function Sn(e, t) {
|
|
1049
|
+
return t.tool?.subagentDispatched ? t.tool.subagentDispatched(e) : /[\u3400-\u9fff]/.test([
|
|
1050
|
+
t.ariaLabel,
|
|
1051
|
+
t.thinking,
|
|
1052
|
+
t.preparing,
|
|
1053
|
+
t.responding
|
|
1054
|
+
].join(" ")) ? e ? `已派发 ${e} 子代理` : "已派发子代理" : bn.subagentDispatched(e);
|
|
1055
|
+
}
|
|
1056
|
+
function J({ card: e, labels: t = K, nested: n = !1, statusLabel: i, statusFailed: a = !1, compact: o = !1, locale: c }) {
|
|
1057
|
+
let u = Ve(e.result), d = e.ended || !u && !!e.result, f = !u && (a || xn(e.result)), p = e.started && !d, _ = Xe(e.toolName, e.args), v = {
|
|
1058
|
+
...bn,
|
|
1059
|
+
...t.tool
|
|
1060
|
+
}, y = q(t, c), x = s(() => Tt(e.toolName, e.args, y), [
|
|
1061
|
+
e.toolName,
|
|
1062
|
+
e.args,
|
|
1063
|
+
y
|
|
1064
|
+
]), S = _ === null && x.some((e) => e.fields.length > 0), ee = S ? "button" : "div", te = St(e.toolName, e.args, y), ne = t.tool?.resolveName?.(e.toolName, e.args), w = ne ? Ct(e.toolName, e.args, ne, y) : wt(e.toolName, e.args, void 0, y), T = e.toolName.toLowerCase() === "agent_spawn", E = e.subagentName !== void 0 || T && e.toolCallId.startsWith("subagent:") ? Sn(e.subagentName || "", t) : i ? w : d ? v.completed(w) : v.running(w), re = e.subagentName === void 0 ? Ct(e.toolName, e.args, w, y) : E, [ie, D] = l(!1);
|
|
1065
|
+
return r(() => {
|
|
1066
|
+
d && D(!1);
|
|
1067
|
+
}, [d, p]), /* @__PURE__ */ z("div", {
|
|
1068
|
+
className: G("ef-chat__tool-row", !n && "ef-chat__tool-row--standalone"),
|
|
1069
|
+
children: [/* @__PURE__ */ z(ee, {
|
|
1070
|
+
className: G("ef-chat__tool-toggle", !S && "ef-chat__tool-toggle--static", n && "ef-chat__tool-toggle--nested"),
|
|
1071
|
+
type: S ? "button" : void 0,
|
|
1072
|
+
"aria-expanded": S ? ie : void 0,
|
|
1073
|
+
onClick: S ? () => D((e) => !e) : void 0,
|
|
1074
|
+
children: [/* @__PURE__ */ z("span", {
|
|
1075
|
+
className: "ef-chat__tool-toggle-main",
|
|
1076
|
+
children: [/* @__PURE__ */ R("span", {
|
|
1077
|
+
className: G("ef-chat__tool-badge", G(n ? "ef-chat__tool-badge--nested" : "ef-chat__tool-badge--standalone", f && "ef-chat__tool-badge--failed", d && !f && "ef-chat__tool-badge--done")),
|
|
1078
|
+
children: n && !d ? /* @__PURE__ */ R("span", {
|
|
1079
|
+
className: "ef-chat__tool-timeline-dot",
|
|
1080
|
+
"aria-hidden": "true"
|
|
1081
|
+
}) : f ? /* @__PURE__ */ R(b, { size: 14 }) : d ? /* @__PURE__ */ R(m, { size: 14 }) : p ? /* @__PURE__ */ R(C, {
|
|
1082
|
+
size: 14,
|
|
1083
|
+
className: "animate-spin"
|
|
1084
|
+
}) : /* @__PURE__ */ R(O, { size: 14 })
|
|
1085
|
+
}), /* @__PURE__ */ R("span", {
|
|
1086
|
+
className: "ef-chat__tool-toggle-text",
|
|
1087
|
+
children: /* @__PURE__ */ R("span", {
|
|
1088
|
+
className: "ef-chat__tool-title-row",
|
|
1089
|
+
children: /* @__PURE__ */ R("span", {
|
|
1090
|
+
className: G("ef-chat__tool-title", n && "ef-chat__tool-title--nested"),
|
|
1091
|
+
children: te ?? (n || o && re !== w ? re : E)
|
|
1092
|
+
})
|
|
1093
|
+
})
|
|
1094
|
+
})]
|
|
1095
|
+
}), S ? /* @__PURE__ */ R("span", {
|
|
1096
|
+
className: "ef-chat__tool-chevron",
|
|
1097
|
+
children: R(ie ? h : g, { size: 14 })
|
|
1098
|
+
}) : null]
|
|
1099
|
+
}), S && ie ? /* @__PURE__ */ R("div", {
|
|
1100
|
+
className: G("ef-chat__tool-body", n ? "ef-chat__tool-body--nested" : "ef-chat__tool-body--standalone"),
|
|
1101
|
+
children: /* @__PURE__ */ R("div", {
|
|
1102
|
+
className: "ef-chat__tool-sections",
|
|
1103
|
+
children: /* @__PURE__ */ R("div", {
|
|
1104
|
+
className: "ef-chat__tool-operations",
|
|
1105
|
+
children: x.map((e, t) => e.fields.length ? /* @__PURE__ */ z("section", {
|
|
1106
|
+
className: "ef-chat__tool-operation",
|
|
1107
|
+
"data-tool-operation-index": t,
|
|
1108
|
+
children: [x.length > 1 ? /* @__PURE__ */ z("p", {
|
|
1109
|
+
className: "ef-chat__tool-operation-title",
|
|
1110
|
+
children: [
|
|
1111
|
+
t + 1,
|
|
1112
|
+
". ",
|
|
1113
|
+
w
|
|
1114
|
+
]
|
|
1115
|
+
}) : null, e.fields.length ? /* @__PURE__ */ R("dl", {
|
|
1116
|
+
className: "ef-chat__tool-operation-fields",
|
|
1117
|
+
children: e.fields.map((e, t) => /* @__PURE__ */ z("div", { children: [/* @__PURE__ */ R("dt", { children: e.label }), /* @__PURE__ */ R("dd", { children: e.code ? /* @__PURE__ */ z("div", {
|
|
1118
|
+
className: "ef-chat__tool-operation-code",
|
|
1119
|
+
children: [/* @__PURE__ */ R("pre", { children: e.value }), /* @__PURE__ */ R(_n, {
|
|
1120
|
+
ariaLabel: e.copyLabel,
|
|
1121
|
+
title: e.copyLabel,
|
|
1122
|
+
value: e.value
|
|
1123
|
+
})]
|
|
1124
|
+
}) : /* @__PURE__ */ R("p", { children: e.value }) })] }, t))
|
|
1125
|
+
}) : null]
|
|
1126
|
+
}, t) : null)
|
|
1127
|
+
})
|
|
1128
|
+
})
|
|
1129
|
+
}) : null]
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
function Cn({ card: e, labels: t = K, statusLabels: n, failedStatuses: i, locale: a, autoExpanded: o = !1 }) {
|
|
1133
|
+
let s = {
|
|
1134
|
+
...bn,
|
|
1135
|
+
...t.tool
|
|
1136
|
+
}, c = e.toolCards.filter((e) => e.started), [u, d] = l(o);
|
|
1137
|
+
if (r(() => {
|
|
1138
|
+
d(o);
|
|
1139
|
+
}, [o]), !c.length) return null;
|
|
1140
|
+
if (c.length === 1) {
|
|
1141
|
+
let e = c[0];
|
|
1142
|
+
return /* @__PURE__ */ R(J, {
|
|
1143
|
+
card: e,
|
|
1144
|
+
labels: t,
|
|
1145
|
+
locale: a,
|
|
1146
|
+
statusLabel: n?.[e.id],
|
|
1147
|
+
statusFailed: i?.[e.id]
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
let f = c.some((e) => e.started && !e.ended && !e.result), p = s.groupSummary?.(bt(c)) ?? Le(bt(c));
|
|
1151
|
+
return /* @__PURE__ */ z("section", {
|
|
1152
|
+
className: "ef-chat__rail-entry",
|
|
1153
|
+
"aria-label": s.ariaLabel,
|
|
1154
|
+
children: [/* @__PURE__ */ z("button", {
|
|
1155
|
+
className: "ef-chat__rail-entry-toggle",
|
|
1156
|
+
type: "button",
|
|
1157
|
+
"aria-expanded": u,
|
|
1158
|
+
onClick: () => d((e) => !e),
|
|
1159
|
+
children: [/* @__PURE__ */ z("span", {
|
|
1160
|
+
className: "ef-chat__rail-entry-main",
|
|
1161
|
+
children: [/* @__PURE__ */ R("span", {
|
|
1162
|
+
className: "ef-chat__rail-entry-icon",
|
|
1163
|
+
children: /* @__PURE__ */ R(O, {
|
|
1164
|
+
size: 15,
|
|
1165
|
+
className: f ? "animate-pulse" : void 0
|
|
1166
|
+
})
|
|
1167
|
+
}), /* @__PURE__ */ R("span", {
|
|
1168
|
+
className: "ef-chat__rail-entry-summary ef-chat__rail-entry-summary--strong",
|
|
1169
|
+
children: p
|
|
1170
|
+
})]
|
|
1171
|
+
}), /* @__PURE__ */ R("span", {
|
|
1172
|
+
className: "ef-chat__rail-entry-chevron",
|
|
1173
|
+
children: R(u ? h : g, { size: 14 })
|
|
1174
|
+
})]
|
|
1175
|
+
}), u ? /* @__PURE__ */ R("ol", {
|
|
1176
|
+
className: "ef-chat__rail-entry-list",
|
|
1177
|
+
children: c.map((e) => /* @__PURE__ */ R("li", { children: /* @__PURE__ */ R(J, {
|
|
1178
|
+
card: e,
|
|
1179
|
+
labels: t,
|
|
1180
|
+
nested: !0,
|
|
1181
|
+
locale: a,
|
|
1182
|
+
statusLabel: n?.[e.id],
|
|
1183
|
+
statusFailed: i?.[e.id]
|
|
1184
|
+
}) }, e.id))
|
|
1185
|
+
}) : null]
|
|
1186
|
+
});
|
|
1187
|
+
}
|
|
1188
|
+
function Y({ card: e, labels: t = K, unfolded: n = !1 }) {
|
|
1189
|
+
let r = {
|
|
1190
|
+
...bn,
|
|
1191
|
+
...t.tool
|
|
1192
|
+
};
|
|
1193
|
+
e.toolCards.some((e) => e.started && !e.ended && !e.result);
|
|
1194
|
+
let i = L(e) || (e.ended ? r.reasoningCaptured : r.reasoningThinking), a = e.summary, [o, s] = l(!1);
|
|
1195
|
+
return n ? /* @__PURE__ */ R("section", {
|
|
1196
|
+
className: "ef-chat__rail-entry",
|
|
1197
|
+
"aria-label": r.reasoningAria,
|
|
1198
|
+
children: /* @__PURE__ */ z("div", {
|
|
1199
|
+
className: "ef-chat__rail-entry-main ef-chat__reasoning-inline",
|
|
1200
|
+
children: [/* @__PURE__ */ R(f, {
|
|
1201
|
+
size: 15,
|
|
1202
|
+
className: e.ended ? void 0 : "animate-pulse"
|
|
1203
|
+
}), /* @__PURE__ */ R("div", {
|
|
1204
|
+
className: "ef-chat__rail-detail",
|
|
1205
|
+
children: /* @__PURE__ */ R(cn, {
|
|
1206
|
+
content: a || i,
|
|
1207
|
+
emptyMessage: r.emptyReasoning,
|
|
1208
|
+
streaming: !e.ended
|
|
1209
|
+
})
|
|
1210
|
+
})]
|
|
1211
|
+
})
|
|
1212
|
+
}) : /* @__PURE__ */ z("section", {
|
|
1213
|
+
className: "ef-chat__rail-entry",
|
|
1214
|
+
"aria-label": r.reasoningAria,
|
|
1215
|
+
children: [/* @__PURE__ */ z("button", {
|
|
1216
|
+
className: "ef-chat__rail-entry-toggle",
|
|
1217
|
+
type: "button",
|
|
1218
|
+
"aria-expanded": o,
|
|
1219
|
+
onClick: () => s((e) => !e),
|
|
1220
|
+
children: [/* @__PURE__ */ z("span", {
|
|
1221
|
+
className: "ef-chat__rail-entry-main",
|
|
1222
|
+
children: [/* @__PURE__ */ R("span", {
|
|
1223
|
+
className: "ef-chat__rail-entry-icon",
|
|
1224
|
+
children: /* @__PURE__ */ R(f, {
|
|
1225
|
+
size: 15,
|
|
1226
|
+
className: e.ended ? void 0 : "animate-pulse"
|
|
1227
|
+
})
|
|
1228
|
+
}), /* @__PURE__ */ R("span", {
|
|
1229
|
+
className: G("ef-chat__rail-entry-summary", !e.ended && "ef-chat__rail-entry-summary--pending"),
|
|
1230
|
+
children: i
|
|
1231
|
+
})]
|
|
1232
|
+
}), /* @__PURE__ */ R("span", {
|
|
1233
|
+
className: "ef-chat__rail-entry-chevron",
|
|
1234
|
+
children: R(o ? h : g, { size: 14 })
|
|
1235
|
+
})]
|
|
1236
|
+
}), o ? /* @__PURE__ */ R("div", {
|
|
1237
|
+
className: "ef-chat__rail-entry-body",
|
|
1238
|
+
children: a ? /* @__PURE__ */ R("div", {
|
|
1239
|
+
className: "ef-chat__rail-detail",
|
|
1240
|
+
children: /* @__PURE__ */ R(cn, {
|
|
1241
|
+
content: a,
|
|
1242
|
+
emptyMessage: r.emptyReasoning
|
|
1243
|
+
})
|
|
1244
|
+
}) : null
|
|
1245
|
+
}) : null]
|
|
1246
|
+
});
|
|
1247
|
+
}
|
|
1248
|
+
function wn({ raw: e, fallback: t, code: n }) {
|
|
1249
|
+
let r = De(e, t, n);
|
|
1250
|
+
return /* @__PURE__ */ z(At, { children: [/* @__PURE__ */ R("div", {
|
|
1251
|
+
className: "ef-chat__run-notice-detail",
|
|
1252
|
+
children: r.summary
|
|
1253
|
+
}), r.details ? /* @__PURE__ */ z("details", {
|
|
1254
|
+
className: "ef-chat__error-details",
|
|
1255
|
+
children: [/* @__PURE__ */ R("summary", { children: /[\u3400-\u9fff]/.test(t) ? "错误详情" : "Error details" }), /* @__PURE__ */ R("pre", { children: r.details })]
|
|
1256
|
+
}) : null] });
|
|
1257
|
+
}
|
|
1258
|
+
function Tn({ notices: e, labels: t }) {
|
|
1259
|
+
let n = {
|
|
1260
|
+
...K.notices,
|
|
1261
|
+
...t.notices
|
|
1262
|
+
};
|
|
1263
|
+
return e.map((e) => {
|
|
1264
|
+
let r = !1, i = !1, a, o = "", s = "", c = _;
|
|
1265
|
+
if (e.kind === "compaction") r = e.status === "requested" || e.status === "started", i = e.status === "failed", a = {
|
|
1266
|
+
requested: n.compactionRequested,
|
|
1267
|
+
started: n.compactionStarted,
|
|
1268
|
+
completed: n.compactionCompleted,
|
|
1269
|
+
failed: n.compactionFailed,
|
|
1270
|
+
interrupted: n.compactionInterrupted
|
|
1271
|
+
}[e.status], o = e.code, r && (c = C), e.status === "completed" && (c = m);
|
|
1272
|
+
else if (e.kind === "integrationWarning") a = n.mcpUnavailable, o = e.message || e.code;
|
|
1273
|
+
else if (e.kind === "runStopped") a = t.stopped ?? "Run stopped", o = e.message, c = D;
|
|
1274
|
+
else if (i = !0, a = t.failed ?? K.failed, o = e.message || e.code, e.code === "AGENT_AGUI_REPLAY_INCOMPLETE") a = n.presentationIncomplete, o = n.presentationIncompleteDetail;
|
|
1275
|
+
else if (e.code.toLowerCase() === "tool_schema_over_budget") {
|
|
1276
|
+
a = n.toolSchemaOverBudget;
|
|
1277
|
+
let t = e.toolSchemaBudget;
|
|
1278
|
+
o = t ? n.toolSchemaBudget(t.estimatedTokens, t.limitTokens, t.toolCount) : "", s = n.toolSchemaBudgetHint;
|
|
1279
|
+
}
|
|
1280
|
+
return /* @__PURE__ */ z("div", {
|
|
1281
|
+
className: G("ef-chat__run-notice", i && "ef-chat__run-notice--error"),
|
|
1282
|
+
role: i ? "alert" : "status",
|
|
1283
|
+
"aria-atomic": "true",
|
|
1284
|
+
children: [/* @__PURE__ */ R(c, {
|
|
1285
|
+
size: 16,
|
|
1286
|
+
"aria-hidden": "true",
|
|
1287
|
+
className: r ? "animate-spin" : void 0
|
|
1288
|
+
}), /* @__PURE__ */ z("div", {
|
|
1289
|
+
className: "ef-chat__run-notice-content",
|
|
1290
|
+
children: [
|
|
1291
|
+
/* @__PURE__ */ R("div", {
|
|
1292
|
+
className: "ef-chat__run-notice-title",
|
|
1293
|
+
children: a
|
|
1294
|
+
}),
|
|
1295
|
+
o ? /* @__PURE__ */ R(wn, {
|
|
1296
|
+
raw: o,
|
|
1297
|
+
fallback: t.failed ?? "Run failed",
|
|
1298
|
+
code: e.kind === "runError" || e.kind === "runStopped" ? e.code : void 0
|
|
1299
|
+
}) : null,
|
|
1300
|
+
s ? /* @__PURE__ */ R("div", {
|
|
1301
|
+
className: "ef-chat__run-notice-detail",
|
|
1302
|
+
children: s
|
|
1303
|
+
}) : null
|
|
1304
|
+
]
|
|
1305
|
+
})]
|
|
1306
|
+
}, e.kind === "integrationWarning" ? e.id : e.kind === "runError" || e.kind === "runStopped" ? e.kind + ":" + e.code : e.kind);
|
|
1307
|
+
});
|
|
1308
|
+
}
|
|
1309
|
+
function En({ message: e, workOnly: t = !1, showReasoningCards: n = !0, labels: r, hasRunError: i = !1, historyLabels: a = Ie, locale: o }) {
|
|
1310
|
+
let s = e.history;
|
|
1311
|
+
if (!s) return null;
|
|
1312
|
+
let c = s.message.content.filter((e) => e.type === "Reasoning").map((e) => "text" in e ? e.text : "").join(""), l = s.message.content.filter((e) => e.type === "Json" || e.type === "Media" || e.type === "Resource"), u = !t && e.role === "ASSISTANT" && !!s.run?.error && !i;
|
|
1313
|
+
return (t ? (!n || !c.trim()) && !s.tools.length : !l.length && s.message.structured == null && !u) ? null : /* @__PURE__ */ z("section", {
|
|
1314
|
+
className: "ef-chat__history-details",
|
|
1315
|
+
"data-history-message-id": e.messageId,
|
|
1316
|
+
children: [
|
|
1317
|
+
t && n && c ? /* @__PURE__ */ R(Y, {
|
|
1318
|
+
labels: r,
|
|
1319
|
+
card: {
|
|
1320
|
+
id: `${e.messageId}:reasoning`,
|
|
1321
|
+
runId: e.runId ?? "",
|
|
1322
|
+
content: c,
|
|
1323
|
+
summary: c,
|
|
1324
|
+
ended: s.message.status !== "Running",
|
|
1325
|
+
firstMillis: s.message.createdAtMs,
|
|
1326
|
+
endMillis: s.step?.finishedAtMs ?? null,
|
|
1327
|
+
toolCards: []
|
|
1328
|
+
}
|
|
1329
|
+
}) : null,
|
|
1330
|
+
!t && l.map((e, t) => /* @__PURE__ */ R("div", { children: e.type === "Json" ? /* @__PURE__ */ R("pre", { children: JSON.stringify(e.value, null, 2) }) : e.type === "Media" && e.mimeType.startsWith("image/") && N(e) ? /* @__PURE__ */ R("img", {
|
|
1331
|
+
src: N(e),
|
|
1332
|
+
alt: e.name ?? e.mimeType,
|
|
1333
|
+
loading: "lazy"
|
|
1334
|
+
}) : e.type === "Media" || e.type === "Resource" ? N(e) ? /* @__PURE__ */ R("a", {
|
|
1335
|
+
href: N(e),
|
|
1336
|
+
target: "_blank",
|
|
1337
|
+
rel: "noreferrer",
|
|
1338
|
+
children: e.name ?? (e.type === "Resource" ? e.uri : e.mimeType)
|
|
1339
|
+
}) : /* @__PURE__ */ R("code", { children: e.name ?? (e.type === "Resource" ? e.uri : e.mimeType) }) : null }, t)),
|
|
1340
|
+
!t && s.message.structured != null ? /* @__PURE__ */ R("pre", { children: JSON.stringify(s.message.structured, null, 2) }) : null,
|
|
1341
|
+
t && s.tools.map((e) => /* @__PURE__ */ R("div", {
|
|
1342
|
+
"data-tool-invocation-id": e.id,
|
|
1343
|
+
children: /* @__PURE__ */ R(J, {
|
|
1344
|
+
labels: r,
|
|
1345
|
+
locale: o,
|
|
1346
|
+
statusLabel: a.statuses[e.status],
|
|
1347
|
+
card: {
|
|
1348
|
+
id: e.id,
|
|
1349
|
+
runId: e.runId,
|
|
1350
|
+
toolCallId: e.id,
|
|
1351
|
+
toolName: e.toolName,
|
|
1352
|
+
args: e.arguments,
|
|
1353
|
+
result: Ge(e),
|
|
1354
|
+
logs: [],
|
|
1355
|
+
parentReasoningId: null,
|
|
1356
|
+
firstMillis: e.startedAtMs ?? s.message.createdAtMs,
|
|
1357
|
+
started: e.status === "Running",
|
|
1358
|
+
ended: ["Completed", "Failed"].includes(e.status)
|
|
1359
|
+
}
|
|
1360
|
+
})
|
|
1361
|
+
}, e.id)),
|
|
1362
|
+
u ? /* @__PURE__ */ R(wn, {
|
|
1363
|
+
raw: s.run.error,
|
|
1364
|
+
fallback: r?.failed ?? a.statuses.Failed
|
|
1365
|
+
}) : null
|
|
1366
|
+
]
|
|
1367
|
+
});
|
|
1368
|
+
}
|
|
1369
|
+
function Dn({ messages: e, labels: t = K, historyLabels: n, showReasoningCards: i = !0, locale: a }) {
|
|
1370
|
+
let o = qe(e), [s, c] = l(!1);
|
|
1371
|
+
r(() => {
|
|
1372
|
+
o && c(!1);
|
|
1373
|
+
}, [o]);
|
|
1374
|
+
let u = e.flatMap((e) => e.history?.run ? [e.history.run] : []), d = u.map((e) => e.startedAtMs), f = u.flatMap((e) => e.finishedAtMs == null ? [] : [e.finishedAtMs]), p = yn(d.length && f.length ? Math.max(...f) - Math.min(...d) : 0), m = u.some((e) => e.status === "Failed"), v = !m && u.some((e) => e.status === "Interrupted"), y = m ? n.statuses.Failed : v ? n.statuses.Interrupted : null, x = o ? t.workedFor(p) : t.workingFor(p);
|
|
1375
|
+
return /* @__PURE__ */ z("section", {
|
|
1376
|
+
className: "ef-chat__rail",
|
|
1377
|
+
"aria-label": t.ariaLabel,
|
|
1378
|
+
"data-history-work": !0,
|
|
1379
|
+
children: [
|
|
1380
|
+
/* @__PURE__ */ z("button", {
|
|
1381
|
+
className: "ef-chat__rail-summary",
|
|
1382
|
+
type: "button",
|
|
1383
|
+
"aria-expanded": s,
|
|
1384
|
+
onClick: () => c((e) => !e),
|
|
1385
|
+
children: [x, R(s ? h : g, { size: 14 })]
|
|
1386
|
+
}),
|
|
1387
|
+
y ? /* @__PURE__ */ z("div", {
|
|
1388
|
+
className: G("ef-chat__run-notice", m && "ef-chat__run-notice--error"),
|
|
1389
|
+
role: m ? "alert" : "status",
|
|
1390
|
+
children: [R(m ? _ : b, {
|
|
1391
|
+
"aria-hidden": "true",
|
|
1392
|
+
size: 16
|
|
1393
|
+
}), /* @__PURE__ */ R("div", {
|
|
1394
|
+
className: "ef-chat__run-notice-content",
|
|
1395
|
+
children: /* @__PURE__ */ R("div", {
|
|
1396
|
+
className: "ef-chat__run-notice-title",
|
|
1397
|
+
children: y
|
|
1398
|
+
})
|
|
1399
|
+
})]
|
|
1400
|
+
}) : null,
|
|
1401
|
+
s ? /* @__PURE__ */ R("div", {
|
|
1402
|
+
className: "ef-chat__rail-stack",
|
|
1403
|
+
children: e.map((e) => /* @__PURE__ */ R(En, {
|
|
1404
|
+
message: e,
|
|
1405
|
+
workOnly: !0,
|
|
1406
|
+
showReasoningCards: i,
|
|
1407
|
+
labels: t,
|
|
1408
|
+
historyLabels: n,
|
|
1409
|
+
locale: a
|
|
1410
|
+
}, e.messageId))
|
|
1411
|
+
}) : null
|
|
1412
|
+
]
|
|
1413
|
+
});
|
|
1414
|
+
}
|
|
1415
|
+
function X({ historyCovered: e = !1, debugEvents: t, events: n, labels: i = K, messageId: a, userInputRequests: o = [], timeline: c, renderMessage: u, historyLabels: f = Ie, showReasoningCards: p = !0, locale: m }) {
|
|
1416
|
+
let v = s(() => {
|
|
1417
|
+
let e = be(n), t = c?.messages.find((e) => e.history?.run?.error)?.history?.run?.error;
|
|
1418
|
+
return t && !e.some((e) => e.kind === "runError" && e.code !== "AGENT_AGUI_REPLAY_INCOMPLETE") && e.push({
|
|
1419
|
+
kind: "runError",
|
|
1420
|
+
code: "HISTORY_RUN_ERROR",
|
|
1421
|
+
message: t
|
|
1422
|
+
}), e;
|
|
1423
|
+
}, [n, c]), y = s(() => xe(n).filter((e) => p || e.kind !== "reasoning"), [n, p]), x = s(() => c?.items.filter((e) => p || e.kind !== "reasoning") ?? [], [c, p]), S = s(() => {
|
|
1424
|
+
let e = new Set(n.map((e) => me(e)));
|
|
1425
|
+
return o.filter((t) => e.has(t.runId) || !!(a && t.assistantMessageId === a));
|
|
1426
|
+
}, [
|
|
1427
|
+
n,
|
|
1428
|
+
a,
|
|
1429
|
+
o
|
|
1430
|
+
]), C = s(() => [...y.map((e) => ({
|
|
1431
|
+
firstMillis: e.value.firstMillis,
|
|
1432
|
+
kind: "agui",
|
|
1433
|
+
card: e
|
|
1434
|
+
}))].sort((e, t) => e.firstMillis - t.firstMillis), [y]), ee = S.find((e) => e.status === "Pending"), te = s(() => he(n), [n]), ne = s(() => Ne(n), [n]), w = s(() => {
|
|
1435
|
+
if (!ne) return null;
|
|
1436
|
+
let e = Ze(ne) && !v.some((e) => e.kind === "runError" && e.code !== "AGENT_AGUI_REPLAY_INCOMPLETE");
|
|
1437
|
+
return {
|
|
1438
|
+
duration: yn(ge(n)),
|
|
1439
|
+
failed: String(ne.type).toUpperCase() === "RUN_ERROR" && !e,
|
|
1440
|
+
stopped: e,
|
|
1441
|
+
runId: me(ne)
|
|
1442
|
+
};
|
|
1443
|
+
}, [
|
|
1444
|
+
n,
|
|
1445
|
+
v,
|
|
1446
|
+
ne
|
|
1447
|
+
]), T = c?.completed ?? (e || !!w && !ee), E = c?.waitingAtMs !== void 0 || !!ee, [re, ie] = l(!T), [D, O] = l(() => Date.now()), k = c ? yn(Ot(c, D)) : T ? w?.duration ?? "<1s" : yn(ge(n, D, ee?.requestedAt || void 0));
|
|
1448
|
+
if (r(() => {
|
|
1449
|
+
if (T || E) return;
|
|
1450
|
+
O(Date.now());
|
|
1451
|
+
let e = window.setInterval(() => O(Date.now()), 1e3);
|
|
1452
|
+
return () => window.clearInterval(e);
|
|
1453
|
+
}, [T, E]), r(() => {
|
|
1454
|
+
ie(!T);
|
|
1455
|
+
}, [T]), !c && e && !t.length) return v.length ? /* @__PURE__ */ R("section", {
|
|
1456
|
+
className: "ef-chat__rail",
|
|
1457
|
+
"aria-label": i.ariaLabel,
|
|
1458
|
+
children: /* @__PURE__ */ R(Tn, {
|
|
1459
|
+
notices: v,
|
|
1460
|
+
labels: i
|
|
1461
|
+
})
|
|
1462
|
+
}) : null;
|
|
1463
|
+
if (!c && !w && !n.length && !C.length && !t.length) return null;
|
|
1464
|
+
if (v.length > 0 && !w && n.every((e) => e.type === "CUSTOM" && e.name === "agent.presentation.incomplete")) return /* @__PURE__ */ R("section", {
|
|
1465
|
+
className: "ef-chat__rail",
|
|
1466
|
+
"aria-label": i.ariaLabel,
|
|
1467
|
+
children: /* @__PURE__ */ R(Tn, {
|
|
1468
|
+
notices: v,
|
|
1469
|
+
labels: i
|
|
1470
|
+
})
|
|
1471
|
+
});
|
|
1472
|
+
let A = (c ? x.length > 0 : C.length > 0) || t.length > 0, ae = !c?.events.length && c?.messages.some((e) => e.history?.run?.status === "Failed"), oe = !ae && !c?.events.length && c?.messages.some((e) => e.history?.run?.status === "Interrupted"), se = ae ? f.statuses.Failed : oe ? f.statuses.Interrupted : null, ce = !w && n.some($e), le = T ? i.workedFor(k) : E ? `${i.waitingForAnswer ?? "Waiting for your answer"} · ${k}` : i.workingFor(k), ue = /* @__PURE__ */ z("span", {
|
|
1473
|
+
className: "ef-chat__rail-summary-label",
|
|
1474
|
+
children: [/* @__PURE__ */ R("span", { children: le }), te ? /* @__PURE__ */ R("span", { children: ` · ${te}` }) : null]
|
|
1475
|
+
});
|
|
1476
|
+
return /* @__PURE__ */ z("section", {
|
|
1477
|
+
className: "ef-chat__rail",
|
|
1478
|
+
"aria-label": i.ariaLabel,
|
|
1479
|
+
children: [
|
|
1480
|
+
A ? /* @__PURE__ */ z("button", {
|
|
1481
|
+
className: "ef-chat__rail-summary",
|
|
1482
|
+
type: "button",
|
|
1483
|
+
"aria-expanded": re,
|
|
1484
|
+
onClick: () => ie((e) => !e),
|
|
1485
|
+
children: [ue, R(re ? h : g, { size: 14 })]
|
|
1486
|
+
}) : /* @__PURE__ */ R("div", {
|
|
1487
|
+
className: "ef-chat__rail-summary ef-chat__rail-summary--static",
|
|
1488
|
+
children: ue
|
|
1489
|
+
}),
|
|
1490
|
+
/* @__PURE__ */ R(Tn, {
|
|
1491
|
+
notices: v,
|
|
1492
|
+
labels: i
|
|
1493
|
+
}),
|
|
1494
|
+
se ? /* @__PURE__ */ z("div", {
|
|
1495
|
+
className: G("ef-chat__run-notice", ae && "ef-chat__run-notice--error"),
|
|
1496
|
+
role: ae ? "alert" : "status",
|
|
1497
|
+
children: [R(ae ? _ : b, {
|
|
1498
|
+
"aria-hidden": "true",
|
|
1499
|
+
size: 16
|
|
1500
|
+
}), /* @__PURE__ */ R("div", {
|
|
1501
|
+
className: "ef-chat__run-notice-content",
|
|
1502
|
+
children: /* @__PURE__ */ R("div", {
|
|
1503
|
+
className: "ef-chat__run-notice-title",
|
|
1504
|
+
children: se
|
|
1505
|
+
})
|
|
1506
|
+
})]
|
|
1507
|
+
}) : null,
|
|
1508
|
+
re && A ? /* @__PURE__ */ z("div", {
|
|
1509
|
+
className: "ef-chat__rail-stack",
|
|
1510
|
+
style: { marginTop: 8 },
|
|
1511
|
+
children: [c ? /* @__PURE__ */ R("section", {
|
|
1512
|
+
className: "ef-chat__rail",
|
|
1513
|
+
"aria-label": "Agent work rail",
|
|
1514
|
+
style: {
|
|
1515
|
+
maxWidth: "none",
|
|
1516
|
+
paddingLeft: 0
|
|
1517
|
+
},
|
|
1518
|
+
children: /* @__PURE__ */ R("div", {
|
|
1519
|
+
className: "ef-chat__rail-card-list",
|
|
1520
|
+
children: x.map((e) => /* @__PURE__ */ R("div", {
|
|
1521
|
+
"data-work-item": e.kind,
|
|
1522
|
+
"data-work-item-id": e.id,
|
|
1523
|
+
children: e.kind === "message" ? u?.(e.message) : e.kind === "reasoning" ? /* @__PURE__ */ R(Y, {
|
|
1524
|
+
card: e.value,
|
|
1525
|
+
labels: i
|
|
1526
|
+
}) : e.kind === "toolGroup" ? /* @__PURE__ */ R(Cn, {
|
|
1527
|
+
card: e.value,
|
|
1528
|
+
autoExpanded: !T && e.value.isCurrentPhase === !0,
|
|
1529
|
+
labels: i,
|
|
1530
|
+
locale: m,
|
|
1531
|
+
statusLabels: e.historyStatuses ? Object.fromEntries(Object.entries(e.historyStatuses).map(([e, t]) => [e, f.statuses[t]])) : void 0,
|
|
1532
|
+
failedStatuses: e.historyStatuses ? Object.fromEntries(Object.entries(e.historyStatuses).map(([e, t]) => [e, t === "Failed"])) : void 0
|
|
1533
|
+
}) : /* @__PURE__ */ R(J, {
|
|
1534
|
+
card: e.value,
|
|
1535
|
+
labels: i,
|
|
1536
|
+
locale: m,
|
|
1537
|
+
compact: !0,
|
|
1538
|
+
statusLabel: e.historyStatus ? f.statuses[e.historyStatus] : void 0,
|
|
1539
|
+
statusFailed: e.historyStatus === "Failed"
|
|
1540
|
+
})
|
|
1541
|
+
}, e.id))
|
|
1542
|
+
})
|
|
1543
|
+
}) : C.length ? /* @__PURE__ */ R("section", {
|
|
1544
|
+
className: "ef-chat__rail",
|
|
1545
|
+
"aria-label": "Agent work rail",
|
|
1546
|
+
style: {
|
|
1547
|
+
maxWidth: "none",
|
|
1548
|
+
paddingLeft: 0
|
|
1549
|
+
},
|
|
1550
|
+
children: /* @__PURE__ */ R("div", {
|
|
1551
|
+
className: "ef-chat__rail-card-list",
|
|
1552
|
+
children: C.map((e) => e.card.kind === "reasoning" ? /* @__PURE__ */ R(Y, {
|
|
1553
|
+
card: e.card.value,
|
|
1554
|
+
labels: i
|
|
1555
|
+
}, e.card.value.id) : e.card.kind === "toolGroup" ? /* @__PURE__ */ R(Cn, {
|
|
1556
|
+
card: e.card.value,
|
|
1557
|
+
autoExpanded: !T && e.card.value.isCurrentPhase === !0,
|
|
1558
|
+
labels: i,
|
|
1559
|
+
locale: m
|
|
1560
|
+
}, e.card.value.id) : /* @__PURE__ */ R(J, {
|
|
1561
|
+
card: e.card.value,
|
|
1562
|
+
labels: i,
|
|
1563
|
+
locale: m
|
|
1564
|
+
}, e.card.value.id))
|
|
1565
|
+
})
|
|
1566
|
+
}) : null, t.length ? /* @__PURE__ */ R("section", {
|
|
1567
|
+
className: "ef-chat__rail",
|
|
1568
|
+
"aria-label": "AG-UI debug event cards",
|
|
1569
|
+
style: {
|
|
1570
|
+
maxWidth: "none",
|
|
1571
|
+
paddingLeft: 0
|
|
1572
|
+
},
|
|
1573
|
+
children: /* @__PURE__ */ R("div", {
|
|
1574
|
+
className: "ef-chat__debug-list",
|
|
1575
|
+
children: t.map((e, t) => /* @__PURE__ */ R("div", {
|
|
1576
|
+
className: "ef-chat__debug-item",
|
|
1577
|
+
children: /* @__PURE__ */ R("div", {
|
|
1578
|
+
className: "ef-chat__debug-summary",
|
|
1579
|
+
children: e
|
|
1580
|
+
})
|
|
1581
|
+
}, `${e}-${t}`))
|
|
1582
|
+
})
|
|
1583
|
+
}) : null]
|
|
1584
|
+
}) : null,
|
|
1585
|
+
!T && !E && !ce ? /* @__PURE__ */ z("div", {
|
|
1586
|
+
className: "ef-chat__rail-current ef-chat__rail-current--working",
|
|
1587
|
+
role: "status",
|
|
1588
|
+
children: [/* @__PURE__ */ R(d, {
|
|
1589
|
+
className: "ef-chat__rail-current-icon",
|
|
1590
|
+
size: 15,
|
|
1591
|
+
"aria-hidden": "true"
|
|
1592
|
+
}), /* @__PURE__ */ R("span", {
|
|
1593
|
+
className: "ef-chat__rail-current-text",
|
|
1594
|
+
children: i.working ?? (/^[\u3400-\u9fff]/.test(i.thinking) ? "工作中" : "Working")
|
|
1595
|
+
})]
|
|
1596
|
+
}) : null
|
|
1597
|
+
]
|
|
1598
|
+
});
|
|
1599
|
+
}
|
|
1600
|
+
function Z({ labels: e = K }) {
|
|
1601
|
+
return /* @__PURE__ */ R("section", {
|
|
1602
|
+
className: "ef-chat__rail",
|
|
1603
|
+
"aria-label": e.ariaLabel,
|
|
1604
|
+
children: /* @__PURE__ */ z("div", {
|
|
1605
|
+
className: "ef-chat__waiting",
|
|
1606
|
+
children: [
|
|
1607
|
+
/* @__PURE__ */ R("span", { className: "ef-chat__waiting-line" }),
|
|
1608
|
+
/* @__PURE__ */ z("span", {
|
|
1609
|
+
className: "ef-chat__rail-toggle-label",
|
|
1610
|
+
children: [/* @__PURE__ */ R(C, {
|
|
1611
|
+
size: 14,
|
|
1612
|
+
className: "animate-spin"
|
|
1613
|
+
}), /* @__PURE__ */ R("span", { children: e.preparing })]
|
|
1614
|
+
}),
|
|
1615
|
+
/* @__PURE__ */ R("span", { className: "ef-chat__waiting-line" })
|
|
1616
|
+
]
|
|
1617
|
+
})
|
|
1618
|
+
});
|
|
1619
|
+
}
|
|
1620
|
+
function On({ renderAttachmentControl: e, pendingAttachments: t, showAttachmentControl: n, attachmentUploadPending: i, onAttachFile: a, onRemoveAttachment: o, attachLabel: f, uploadingLabel: p, removeAttachmentLabel: m, editQueuedLabel: h, removeQueuedLabel: g, reorderQueuedLabel: _, steerQueuedLabel: v, pendingAnnotations: y, onPendingAnnotationsChange: b, annotationLabels: x = Pe, allowDraftSession: S = !1, attachmentDownloader: ee, attachmentLabels: te = un, autoFocusComposer: ne = !1, createSessionLabel: w = "Create session", currentUserDisplayName: T, hideMessageIdentity: E = !1, composerRef: re, debugOptions: ie, disabledInput: D = !1, draft: O, composerHeader: k, composerTop: A, emptyDescription: ae = "Create a session to start chatting.", emptyTitle: oe = "No session selected", footerAddon: se, goal: ce, formatAnnotationCount: le = ln, headerContent: ue, inputPlaceholder: de = "Enter to send, Shift+Enter for newline", inputSuggestions: fe = [], skillSuggestionTriggers: pe, inputSuggestionLabels: me = {
|
|
1621
|
+
commands: "Commands",
|
|
1622
|
+
skills: "Skills",
|
|
1623
|
+
commandsAndSkills: "Commands and skills"
|
|
1624
|
+
}, queuedInputPlaceholder: he = "Enter to queue · Shift+Enter for newline", steeringInputPlaceholder: ge = "Enter to queue · ⌘/Ctrl+Enter to steer · Shift+Enter for newline", liveAguiAnchorMessageCodes: _e, liveAguiEvents: ve, liveAguiPendingAnchorMessageCode: ye, liveAguiPending: be, locale: xe, messages: we, historyLoading: De = !1, historyLoadingOlder: Oe = !1, historyLabels: ke = Ie, onLoadOlderHistory: Ae, onCreateSession: je, onNewSession: Me, onDraftChange: Ne, onPasteAttachment: Fe, a2uiSession: Le, a2uiDisabled: Re, onA2UIAction: ze, onEditMessage: M, onDeleteTurn: Be, deleteTurnLabel: Ve = "Delete turn", onEditQueuedMessage: N, onRemoveQueuedMessage: He, onSteerQueuedMessage: We, onReorderQueuedMessage: Ge, onSend: Ke, onStop: qe, protocolEvents: Xe, queueDisabled: Ze = !1, queuedLabel: Qe = "Queued", queuedMessages: et = [], runningSubmitModes: tt = [], runningEnterSubmitMode: nt = "queue", sendDisabled: rt, sendLabel: it = "Send", sending: at = !1, streamingAssistantMessageCode: P, session: F, showAgui: ct = !0, showReasoningCards: lt = !0, showHeader: ut = !0, showComposer: ft = !0, showHistoryRail: pt = !0, showStop: mt = !0, sidebarContent: ht, steerDisabled: gt = !1, queuedSteerDisabled: _t = !1, stopLabel: vt = "Stop", title: I, userInputLabels: yt, workRailLabels: L, userInputRequests: bt = [], userInputRequest: xt, userInputAnswerPending: St = !1, userInputAnswerFailed: Ct = !1, onAnswerUserInput: wt, renderMarkdownLink: Tt }) {
|
|
1625
|
+
let [Et, Ot] = l([]), kt = y ?? Et, jt = c(kt);
|
|
1626
|
+
jt.current = kt;
|
|
1627
|
+
let Nt = c((e) => {});
|
|
1628
|
+
Nt.current = (e) => {
|
|
1629
|
+
jt.current = e, y === void 0 && Ot(e), b?.(e);
|
|
1630
|
+
};
|
|
1631
|
+
let Pt = {
|
|
1632
|
+
content: O,
|
|
1633
|
+
annotations: kt
|
|
1634
|
+
}, Ft = c(null);
|
|
1635
|
+
r(() => (Ot([]), () => {
|
|
1636
|
+
Ft.current?.();
|
|
1637
|
+
}), [F?.sessionId]), r(() => () => {
|
|
1638
|
+
Ft.current?.();
|
|
1639
|
+
}, [F?.status, D]);
|
|
1640
|
+
function It(e, t) {
|
|
1641
|
+
Ft.current?.(), Ft.current = dt(t, e, (e) => {
|
|
1642
|
+
Nt.current(jt.current.map((t) => t.id === e.id ? e : t));
|
|
1643
|
+
}, x);
|
|
1644
|
+
}
|
|
1645
|
+
let Lt = s(() => Ee(we), [we]), Rt = c(null);
|
|
1646
|
+
r(() => Rt.current ? ot(Rt.current) : void 0, []);
|
|
1647
|
+
let B = c(null);
|
|
1648
|
+
r(() => {
|
|
1649
|
+
if (B.current && !D && F?.status !== "ARCHIVED") return st(B.current, (e) => {
|
|
1650
|
+
Nt.current([...jt.current, e]);
|
|
1651
|
+
}, x);
|
|
1652
|
+
}, [
|
|
1653
|
+
F?.sessionId,
|
|
1654
|
+
F?.status,
|
|
1655
|
+
D,
|
|
1656
|
+
x,
|
|
1657
|
+
S
|
|
1658
|
+
]);
|
|
1659
|
+
let [V, H] = l(!1), [zt, Vt] = l(null), Ht = c(!0), Ut = c(0), Gt = s(() => {
|
|
1660
|
+
if (P !== void 0) return P || void 0;
|
|
1661
|
+
if (!at) return;
|
|
1662
|
+
let e = we[we.length - 1];
|
|
1663
|
+
return e?.role === "ASSISTANT" ? e.messageId : void 0;
|
|
1664
|
+
}, [
|
|
1665
|
+
P,
|
|
1666
|
+
we,
|
|
1667
|
+
at
|
|
1668
|
+
]), W = s(() => Ye(we, bt, L, yt).filter((e) => e.messageId !== Gt || e.content.trim().length > 0 || !!e.a2ui), [
|
|
1669
|
+
we,
|
|
1670
|
+
bt,
|
|
1671
|
+
L,
|
|
1672
|
+
yt,
|
|
1673
|
+
Gt
|
|
1674
|
+
]), Kt = s(() => Je(W), [W]), qt = s(() => new Map(W.filter((e) => e.role === "ASSISTANT" && e.history?.run?.error).map((e) => [e.runId, e.messageId])), [W]), Yt = s(() => {
|
|
1675
|
+
let e = /* @__PURE__ */ new Set();
|
|
1676
|
+
if (ct) for (let t of [...Xe ?? [], ...ve ?? []]) t.type !== "RUN_ERROR" || $e(t) || (t.runId && e.add(t.runId), e.add(Ue(t)));
|
|
1677
|
+
return e;
|
|
1678
|
+
}, [
|
|
1679
|
+
ct,
|
|
1680
|
+
Xe,
|
|
1681
|
+
ve
|
|
1682
|
+
]), Xt = s(() => Se({
|
|
1683
|
+
debugOptions: ie,
|
|
1684
|
+
liveAguiAnchorMessageCodes: _e,
|
|
1685
|
+
liveAguiEvents: ve,
|
|
1686
|
+
liveAguiPendingAnchorMessageCode: ye,
|
|
1687
|
+
liveAguiPending: be,
|
|
1688
|
+
messages: W,
|
|
1689
|
+
protocolEvents: Xe,
|
|
1690
|
+
sessionId: F?.sessionId ?? ""
|
|
1691
|
+
}), [
|
|
1692
|
+
ie,
|
|
1693
|
+
_e,
|
|
1694
|
+
ve,
|
|
1695
|
+
ye,
|
|
1696
|
+
be,
|
|
1697
|
+
W,
|
|
1698
|
+
Xe,
|
|
1699
|
+
F?.sessionId
|
|
1700
|
+
]), Zt = s(() => Wt(W, Xt), [W, Xt]), Qt = s(() => Ce(W, Xt, bt, { showReasoningCards: lt }), [
|
|
1701
|
+
W,
|
|
1702
|
+
Xt,
|
|
1703
|
+
bt,
|
|
1704
|
+
lt
|
|
1705
|
+
]), $t = s(() => {
|
|
1706
|
+
let e = /* @__PURE__ */ new Map();
|
|
1707
|
+
return Zt.forEach((t) => {
|
|
1708
|
+
t.messageCodes.forEach((n) => {
|
|
1709
|
+
e.set(n, t.id);
|
|
1710
|
+
});
|
|
1711
|
+
}), e;
|
|
1712
|
+
}, [Zt]), en = s(() => {
|
|
1713
|
+
let e = /* @__PURE__ */ new Map();
|
|
1714
|
+
return Zt.forEach((t) => {
|
|
1715
|
+
e.set(t.id, []);
|
|
1716
|
+
}), W.forEach((t) => {
|
|
1717
|
+
let n = $t.get(t.messageId);
|
|
1718
|
+
if (!n) return;
|
|
1719
|
+
let r = e.get(n);
|
|
1720
|
+
r && r.push(t);
|
|
1721
|
+
}), e;
|
|
1722
|
+
}, [
|
|
1723
|
+
Zt,
|
|
1724
|
+
W,
|
|
1725
|
+
$t
|
|
1726
|
+
]);
|
|
1727
|
+
function tn(e) {
|
|
1728
|
+
return /* @__PURE__ */ z(At, { children: [/* @__PURE__ */ R(En, {
|
|
1729
|
+
message: e,
|
|
1730
|
+
labels: L,
|
|
1731
|
+
historyLabels: ke,
|
|
1732
|
+
locale: xe,
|
|
1733
|
+
hasRunError: Qt.managedMessageIds.has(e.messageId) || Yt.has(e.runId ?? "") || qt.get(e.runId) !== e.messageId
|
|
1734
|
+
}), e.content.trim() || e.a2ui || e.interactionResponse ? /* @__PURE__ */ R(vn, {
|
|
1735
|
+
currentUserDisplayName: T,
|
|
1736
|
+
hideMessageIdentity: E,
|
|
1737
|
+
processMessage: !0,
|
|
1738
|
+
isStreaming: e.messageId === Gt,
|
|
1739
|
+
message: e,
|
|
1740
|
+
a2uiSession: Le,
|
|
1741
|
+
a2uiDisabled: Re,
|
|
1742
|
+
onA2UIAction: ze,
|
|
1743
|
+
onEditMessage: M,
|
|
1744
|
+
onDeleteTurn: Be,
|
|
1745
|
+
deleteTurnLabel: Ve
|
|
1746
|
+
}) : null] });
|
|
1747
|
+
}
|
|
1748
|
+
function an(e) {
|
|
1749
|
+
return /* @__PURE__ */ R(X, {
|
|
1750
|
+
timeline: e,
|
|
1751
|
+
renderMessage: tn,
|
|
1752
|
+
historyLabels: ke,
|
|
1753
|
+
showReasoningCards: lt,
|
|
1754
|
+
locale: xe,
|
|
1755
|
+
events: e.events,
|
|
1756
|
+
labels: L,
|
|
1757
|
+
userInputRequests: bt,
|
|
1758
|
+
debugEvents: e.includeRunMetadata === !1 ? [] : (e.runIds ?? [e.runId]).flatMap((e) => Xt.debugEventsByRunCode.get(e) ?? []).map(j)
|
|
1759
|
+
}, e.id);
|
|
1760
|
+
}
|
|
1761
|
+
function cn(e = "auto") {
|
|
1762
|
+
let t = B.current;
|
|
1763
|
+
t && (t.scrollTo({
|
|
1764
|
+
behavior: e,
|
|
1765
|
+
top: t.scrollHeight
|
|
1766
|
+
}), Ut.current = t.scrollTop, Ht.current = !0, H(!1));
|
|
1767
|
+
}
|
|
1768
|
+
function dn() {
|
|
1769
|
+
let e = B.current;
|
|
1770
|
+
if (!e) return;
|
|
1771
|
+
let t = e.scrollHeight - e.scrollTop - e.clientHeight;
|
|
1772
|
+
t <= 2 ? Ht.current = !0 : e.scrollTop < Ut.current && (Ht.current = !1), Ut.current = e.scrollTop, H(t > 160);
|
|
1773
|
+
}
|
|
1774
|
+
return r(() => {
|
|
1775
|
+
Ht.current ? cn("auto") : dn();
|
|
1776
|
+
}, [
|
|
1777
|
+
we,
|
|
1778
|
+
Xt,
|
|
1779
|
+
xt
|
|
1780
|
+
]), r(() => {
|
|
1781
|
+
Ht.current = !0, H(!1);
|
|
1782
|
+
}, [F?.sessionId]), /* @__PURE__ */ R(nn.Provider, {
|
|
1783
|
+
value: x,
|
|
1784
|
+
children: /* @__PURE__ */ R(sn.Provider, {
|
|
1785
|
+
value: Tt,
|
|
1786
|
+
children: /* @__PURE__ */ z("div", {
|
|
1787
|
+
ref: Rt,
|
|
1788
|
+
className: "ef-chat",
|
|
1789
|
+
"data-theme-part": "chat",
|
|
1790
|
+
"data-theme-anchor": "chat",
|
|
1791
|
+
children: [
|
|
1792
|
+
/* @__PURE__ */ R("span", {
|
|
1793
|
+
"aria-hidden": "true",
|
|
1794
|
+
className: "ef-chat__theme-effect-layer",
|
|
1795
|
+
"data-theme-effect-layer": "chat"
|
|
1796
|
+
}),
|
|
1797
|
+
/* @__PURE__ */ R(gn, {
|
|
1798
|
+
image: zt,
|
|
1799
|
+
onClose: () => Vt(null)
|
|
1800
|
+
}),
|
|
1801
|
+
ut ? /* @__PURE__ */ R("header", {
|
|
1802
|
+
className: "ef-chat__header",
|
|
1803
|
+
children: /* @__PURE__ */ R("div", {
|
|
1804
|
+
className: "ef-chat__header-content",
|
|
1805
|
+
children: ue ?? /* @__PURE__ */ z(At, { children: [/* @__PURE__ */ R("span", {
|
|
1806
|
+
className: "ef-chat__title",
|
|
1807
|
+
children: I ?? F?.title ?? "Chat"
|
|
1808
|
+
}), F ? /* @__PURE__ */ z("span", {
|
|
1809
|
+
className: "ef-chat__subtitle",
|
|
1810
|
+
children: [
|
|
1811
|
+
F.sessionId,
|
|
1812
|
+
" ·",
|
|
1813
|
+
" ",
|
|
1814
|
+
F.displayName ?? "Assistant"
|
|
1815
|
+
]
|
|
1816
|
+
}) : null] })
|
|
1817
|
+
})
|
|
1818
|
+
}) : null,
|
|
1819
|
+
F || S ? /* @__PURE__ */ z(At, { children: [/* @__PURE__ */ z("div", {
|
|
1820
|
+
className: G("ef-chat__content", !!ht && "ef-chat__content--with-sidebar"),
|
|
1821
|
+
children: [
|
|
1822
|
+
pt ? /* @__PURE__ */ R(Jt, {
|
|
1823
|
+
messages: W,
|
|
1824
|
+
presentation: Xt,
|
|
1825
|
+
transcriptRef: B
|
|
1826
|
+
}) : null,
|
|
1827
|
+
/* @__PURE__ */ R("section", {
|
|
1828
|
+
className: "ef-chat__transcript",
|
|
1829
|
+
"aria-label": "Chat transcript",
|
|
1830
|
+
ref: B,
|
|
1831
|
+
onScroll: dn,
|
|
1832
|
+
onWheel: (e) => {
|
|
1833
|
+
e.deltaY < 0 && (Ht.current = !1);
|
|
1834
|
+
},
|
|
1835
|
+
children: /* @__PURE__ */ z("div", {
|
|
1836
|
+
className: "ef-chat__transcript-inner",
|
|
1837
|
+
children: [
|
|
1838
|
+
!De && Ae ? /* @__PURE__ */ R("button", {
|
|
1839
|
+
type: "button",
|
|
1840
|
+
disabled: Oe,
|
|
1841
|
+
onClick: Ae,
|
|
1842
|
+
children: Oe ? ke.loading : ke.loadOlder
|
|
1843
|
+
}) : null,
|
|
1844
|
+
!De && W.length ? Zt.map((e) => /* @__PURE__ */ R("section", {
|
|
1845
|
+
className: "ef-chat__turn",
|
|
1846
|
+
"data-chat-turn-id": e.id,
|
|
1847
|
+
children: (en.get(e.id) ?? []).map((e) => /* @__PURE__ */ z(rn.Provider, {
|
|
1848
|
+
value: Lt.get(e.messageId) ?? [],
|
|
1849
|
+
children: [
|
|
1850
|
+
ct ? Qt.before.get(e.messageId)?.map(an) : null,
|
|
1851
|
+
!ct || !Qt.processMessageIds.has(e.messageId) ? /* @__PURE__ */ z(At, { children: [
|
|
1852
|
+
!Qt.managedMessageIds.has(e.messageId) && Kt.has(e.messageId) ? /* @__PURE__ */ R(Dn, {
|
|
1853
|
+
messages: Kt.get(e.messageId),
|
|
1854
|
+
labels: L,
|
|
1855
|
+
historyLabels: ke,
|
|
1856
|
+
showReasoningCards: lt,
|
|
1857
|
+
locale: xe
|
|
1858
|
+
}) : null,
|
|
1859
|
+
/* @__PURE__ */ R(En, {
|
|
1860
|
+
message: e,
|
|
1861
|
+
labels: L,
|
|
1862
|
+
historyLabels: ke,
|
|
1863
|
+
locale: xe,
|
|
1864
|
+
hasRunError: Qt.managedMessageIds.has(e.messageId) || Yt.has(e.runId ?? "") || qt.get(e.runId) !== e.messageId
|
|
1865
|
+
}),
|
|
1866
|
+
e.role === "USER" && e.provenance?.sender.kind.toUpperCase() !== "SYSTEM" ? /* @__PURE__ */ z("div", {
|
|
1867
|
+
className: "ef-chat__user-message-group",
|
|
1868
|
+
children: [
|
|
1869
|
+
/* @__PURE__ */ R(on, {
|
|
1870
|
+
annotations: e.annotations ?? [],
|
|
1871
|
+
formatCount: le
|
|
1872
|
+
}),
|
|
1873
|
+
/* @__PURE__ */ R(hn, {
|
|
1874
|
+
attachments: e.attachments,
|
|
1875
|
+
attachmentLabels: te,
|
|
1876
|
+
downloadAttachment: ee,
|
|
1877
|
+
formatAnnotationCount: le,
|
|
1878
|
+
onPreviewImage: (e, t) => Vt({
|
|
1879
|
+
alt: t,
|
|
1880
|
+
source: e
|
|
1881
|
+
})
|
|
1882
|
+
}),
|
|
1883
|
+
/* @__PURE__ */ R(vn, {
|
|
1884
|
+
currentUserDisplayName: T,
|
|
1885
|
+
hideMessageIdentity: E,
|
|
1886
|
+
isStreaming: e.messageId === Gt,
|
|
1887
|
+
message: e,
|
|
1888
|
+
a2uiSession: Le,
|
|
1889
|
+
a2uiDisabled: Re,
|
|
1890
|
+
onA2UIAction: ze,
|
|
1891
|
+
onEditMessage: M,
|
|
1892
|
+
onDeleteTurn: Be,
|
|
1893
|
+
deleteTurnLabel: Ve
|
|
1894
|
+
})
|
|
1895
|
+
]
|
|
1896
|
+
}) : e.history && !e.a2ui && !e.content.trim() ? null : /* @__PURE__ */ R(vn, {
|
|
1897
|
+
currentUserDisplayName: T,
|
|
1898
|
+
hideMessageIdentity: E,
|
|
1899
|
+
isStreaming: e.messageId === Gt,
|
|
1900
|
+
message: e,
|
|
1901
|
+
a2uiSession: Le,
|
|
1902
|
+
a2uiDisabled: Re,
|
|
1903
|
+
onA2UIAction: ze,
|
|
1904
|
+
onEditMessage: M,
|
|
1905
|
+
onDeleteTurn: Be,
|
|
1906
|
+
deleteTurnLabel: Ve
|
|
1907
|
+
})
|
|
1908
|
+
] }) : null,
|
|
1909
|
+
ct && e.messageId === Xt.waitingForModelAnchorMessageCode ? /* @__PURE__ */ R(Z, { labels: L }) : null,
|
|
1910
|
+
ct ? Qt.after.get(e.messageId)?.map(an) : null
|
|
1911
|
+
]
|
|
1912
|
+
}, e.messageId))
|
|
1913
|
+
}, e.id)) : /* @__PURE__ */ z("div", {
|
|
1914
|
+
className: "ef-chat__transcript-empty",
|
|
1915
|
+
children: [/* @__PURE__ */ R(d, {
|
|
1916
|
+
strokeWidth: 1,
|
|
1917
|
+
size: "60",
|
|
1918
|
+
className: "ef-chat__transcript__bot"
|
|
1919
|
+
}), De ? /* @__PURE__ */ z("div", {
|
|
1920
|
+
role: "status",
|
|
1921
|
+
"aria-live": "polite",
|
|
1922
|
+
className: "ef-chat__history-loading",
|
|
1923
|
+
children: [/* @__PURE__ */ R(C, {
|
|
1924
|
+
className: "animate-spin",
|
|
1925
|
+
size: 18
|
|
1926
|
+
}), ke.loading]
|
|
1927
|
+
}) : null]
|
|
1928
|
+
}),
|
|
1929
|
+
xt?.status === "Pending" && wt ? /* @__PURE__ */ R(U, {
|
|
1930
|
+
requests: bt,
|
|
1931
|
+
disabled: St || F?.status === "ARCHIVED",
|
|
1932
|
+
submitFailed: Ct,
|
|
1933
|
+
labels: yt,
|
|
1934
|
+
onSubmit: wt,
|
|
1935
|
+
request: xt
|
|
1936
|
+
}) : null
|
|
1937
|
+
]
|
|
1938
|
+
})
|
|
1939
|
+
}),
|
|
1940
|
+
ht ? /* @__PURE__ */ R("aside", {
|
|
1941
|
+
className: "ef-chat__sidebar",
|
|
1942
|
+
children: ht
|
|
1943
|
+
}) : null
|
|
1944
|
+
]
|
|
1945
|
+
}), /* @__PURE__ */ z("footer", {
|
|
1946
|
+
className: "ef-chat__footer",
|
|
1947
|
+
children: [
|
|
1948
|
+
V ? /* @__PURE__ */ R("button", {
|
|
1949
|
+
className: "ef-chat__button ef-chat__jump",
|
|
1950
|
+
type: "button",
|
|
1951
|
+
"aria-label": "Jump to latest message",
|
|
1952
|
+
onClick: () => cn("smooth"),
|
|
1953
|
+
children: /* @__PURE__ */ R(u, { size: 16 })
|
|
1954
|
+
}) : null,
|
|
1955
|
+
Pt.annotations.length ? /* @__PURE__ */ R("div", {
|
|
1956
|
+
className: "ef-chat__pending-annotations",
|
|
1957
|
+
"aria-label": x.pendingAnnotations,
|
|
1958
|
+
children: Pt.annotations.map((e, t) => /* @__PURE__ */ z("div", { children: [/* @__PURE__ */ z("button", {
|
|
1959
|
+
type: "button",
|
|
1960
|
+
className: "ef-chat__pending-annotation-edit ef-chat__annotation-reference",
|
|
1961
|
+
disabled: D || F?.status === "ARCHIVED",
|
|
1962
|
+
onClick: (t) => It(e, t.currentTarget),
|
|
1963
|
+
"data-annotation-tooltip": Te(e, x),
|
|
1964
|
+
children: [
|
|
1965
|
+
x.annotation(t + 1),
|
|
1966
|
+
": ",
|
|
1967
|
+
e.comment
|
|
1968
|
+
]
|
|
1969
|
+
}), /* @__PURE__ */ R("button", {
|
|
1970
|
+
type: "button",
|
|
1971
|
+
"aria-label": x.removeAnnotation(t + 1),
|
|
1972
|
+
onClick: () => Nt.current(kt.filter((t) => t.id !== e.id)),
|
|
1973
|
+
children: "×"
|
|
1974
|
+
})] }, e.id))
|
|
1975
|
+
}) : null,
|
|
1976
|
+
ft && ce ? /* @__PURE__ */ R(Bt, { ...ce }) : null,
|
|
1977
|
+
ft ? A : null,
|
|
1978
|
+
ft ? /* @__PURE__ */ R(Mt, {
|
|
1979
|
+
composerKey: F?.sessionId,
|
|
1980
|
+
autoFocusComposer: ne,
|
|
1981
|
+
composerRef: re,
|
|
1982
|
+
composerHeader: k,
|
|
1983
|
+
disabledInput: D || xt?.status === "Pending",
|
|
1984
|
+
disabledInputReason: xt?.status === "Pending" ? yt?.composerWaiting ?? Dt(xe) : void 0,
|
|
1985
|
+
draft: Pt.content,
|
|
1986
|
+
footerAddon: se,
|
|
1987
|
+
inputPlaceholder: de,
|
|
1988
|
+
inputSuggestions: fe,
|
|
1989
|
+
skillSuggestionTriggers: pe,
|
|
1990
|
+
inputSuggestionLabels: me,
|
|
1991
|
+
queuedInputPlaceholder: he,
|
|
1992
|
+
steeringInputPlaceholder: ge,
|
|
1993
|
+
onDraftChange: Ne,
|
|
1994
|
+
onPasteAttachment: Fe,
|
|
1995
|
+
onEditQueuedMessage: N ? (e, t) => N(e, et.find((t) => t.id === e)?.input.content ?? t) : void 0,
|
|
1996
|
+
onRemoveQueuedMessage: He,
|
|
1997
|
+
onSteerQueuedMessage: We,
|
|
1998
|
+
onReorderQueuedMessage: Ge,
|
|
1999
|
+
onSend: Ke,
|
|
2000
|
+
onStop: qe,
|
|
2001
|
+
queueDisabled: Ze,
|
|
2002
|
+
queuedLabel: Qe,
|
|
2003
|
+
queuedMessages: et.map((e) => ({
|
|
2004
|
+
...e,
|
|
2005
|
+
input: {
|
|
2006
|
+
...e.input,
|
|
2007
|
+
content: e.input.content || (e.input.annotations ?? []).map((e) => e.comment).join("; ")
|
|
2008
|
+
}
|
|
2009
|
+
})),
|
|
2010
|
+
runningSubmitModes: tt,
|
|
2011
|
+
runningEnterSubmitMode: nt,
|
|
2012
|
+
sendDisabled: rt,
|
|
2013
|
+
sendLabel: it,
|
|
2014
|
+
sending: at,
|
|
2015
|
+
showStop: mt,
|
|
2016
|
+
steerDisabled: gt,
|
|
2017
|
+
queuedSteerDisabled: _t,
|
|
2018
|
+
stopLabel: vt,
|
|
2019
|
+
pendingAttachments: t,
|
|
2020
|
+
attachmentDownloader: ee,
|
|
2021
|
+
showAttachmentControl: n,
|
|
2022
|
+
attachmentUploadPending: i,
|
|
2023
|
+
onAttachFile: a,
|
|
2024
|
+
onRemoveAttachment: o,
|
|
2025
|
+
renderAttachmentControl: e,
|
|
2026
|
+
attachLabel: f,
|
|
2027
|
+
uploadingLabel: p,
|
|
2028
|
+
removeAttachmentLabel: m,
|
|
2029
|
+
reorderQueuedLabel: _ ?? (xe?.toLowerCase().startsWith("zh") ? "拖动排序,也可使用上下方向键调整" : "Drag to reorder; use Up/Down keys to move"),
|
|
2030
|
+
editQueuedLabel: h,
|
|
2031
|
+
removeQueuedLabel: g,
|
|
2032
|
+
steerQueuedLabel: v
|
|
2033
|
+
}) : null
|
|
2034
|
+
]
|
|
2035
|
+
})] }) : /* @__PURE__ */ z("div", {
|
|
2036
|
+
className: G("ef-chat__content", !!ht && "ef-chat__content--with-sidebar"),
|
|
2037
|
+
children: [/* @__PURE__ */ R("section", {
|
|
2038
|
+
className: "ef-chat__transcript",
|
|
2039
|
+
children: /* @__PURE__ */ R("div", {
|
|
2040
|
+
className: "ef-chat__empty",
|
|
2041
|
+
children: /* @__PURE__ */ z("div", {
|
|
2042
|
+
className: "ef-chat__empty-inner",
|
|
2043
|
+
children: [
|
|
2044
|
+
/* @__PURE__ */ R("div", {
|
|
2045
|
+
className: "ef-chat__empty-title",
|
|
2046
|
+
children: oe
|
|
2047
|
+
}),
|
|
2048
|
+
/* @__PURE__ */ R("div", {
|
|
2049
|
+
className: "ef-chat__empty-description",
|
|
2050
|
+
children: ae
|
|
2051
|
+
}),
|
|
2052
|
+
je ? /* @__PURE__ */ R("div", {
|
|
2053
|
+
style: { marginTop: 16 },
|
|
2054
|
+
children: /* @__PURE__ */ R("button", {
|
|
2055
|
+
className: "ef-chat__button",
|
|
2056
|
+
type: "button",
|
|
2057
|
+
onClick: je,
|
|
2058
|
+
children: w
|
|
2059
|
+
})
|
|
2060
|
+
}) : null
|
|
2061
|
+
]
|
|
2062
|
+
})
|
|
2063
|
+
})
|
|
2064
|
+
}), ht ? /* @__PURE__ */ R("aside", {
|
|
2065
|
+
className: "ef-chat__sidebar",
|
|
2066
|
+
children: ht
|
|
2067
|
+
}) : null]
|
|
2068
|
+
})
|
|
2069
|
+
]
|
|
2070
|
+
})
|
|
2071
|
+
})
|
|
2072
|
+
});
|
|
2073
|
+
}
|
|
2074
|
+
//#endregion
|
|
2075
|
+
//#region src/ChatWindow.tsx
|
|
2076
|
+
function kn({ onStateChange: e, showNewSession: n = !0, state: i, storageKey: a = "eliteforge.agent-ui.chat.window", title: o = "Chat", titleSubtitle: u = "AI assistant", resizeHint: f = "Drag to resize the window. Arrow keys fine-tune the size; hold Shift for larger steps.", ...p }) {
|
|
2077
|
+
let m = !!(i && e), [h, g] = l(() => pt(a, Fe)), [_, v] = l(null), [y, b] = l(0), [x, S] = l(!1), C = _ ?? (m ? i : h), te = c(null), w = c(null), T = c(null), E = c(null);
|
|
2078
|
+
function ie(e) {
|
|
2079
|
+
return e instanceof Element && !!e.closest("button, a, input, textarea, select, [role='button']");
|
|
2080
|
+
}
|
|
2081
|
+
r(() => {
|
|
2082
|
+
m || kt(a, h);
|
|
2083
|
+
}, [
|
|
2084
|
+
m,
|
|
2085
|
+
h,
|
|
2086
|
+
a
|
|
2087
|
+
]);
|
|
2088
|
+
let D = t((e) => typeof window > "u" ? e : Oe(e, {
|
|
2089
|
+
...I(window.innerWidth),
|
|
2090
|
+
viewportHeight: window.innerHeight,
|
|
2091
|
+
viewportWidth: window.innerWidth
|
|
2092
|
+
}), []), O = t((t, n = !0) => {
|
|
2093
|
+
let r = n ? D(t) : t;
|
|
2094
|
+
if (m) {
|
|
2095
|
+
e?.(r);
|
|
2096
|
+
return;
|
|
2097
|
+
}
|
|
2098
|
+
g(r);
|
|
2099
|
+
}, [
|
|
2100
|
+
D,
|
|
2101
|
+
m,
|
|
2102
|
+
e
|
|
2103
|
+
]), k = s(() => D(C), [
|
|
2104
|
+
C,
|
|
2105
|
+
D,
|
|
2106
|
+
y
|
|
2107
|
+
]);
|
|
2108
|
+
r(() => {
|
|
2109
|
+
if (typeof window > "u" || !k.open || _ !== null) {
|
|
2110
|
+
T.current = null;
|
|
2111
|
+
return;
|
|
2112
|
+
}
|
|
2113
|
+
let e = [
|
|
2114
|
+
window.innerWidth,
|
|
2115
|
+
window.innerHeight,
|
|
2116
|
+
C.collapsed,
|
|
2117
|
+
C.height,
|
|
2118
|
+
C.open,
|
|
2119
|
+
C.width,
|
|
2120
|
+
C.x,
|
|
2121
|
+
C.y,
|
|
2122
|
+
k.collapsed,
|
|
2123
|
+
k.height,
|
|
2124
|
+
k.open,
|
|
2125
|
+
k.width,
|
|
2126
|
+
k.x,
|
|
2127
|
+
k.y
|
|
2128
|
+
].join(":");
|
|
2129
|
+
if (M(C, k)) {
|
|
2130
|
+
T.current = null;
|
|
2131
|
+
return;
|
|
2132
|
+
}
|
|
2133
|
+
T.current !== e && (T.current = e, O(k, !1));
|
|
2134
|
+
}, [
|
|
2135
|
+
C,
|
|
2136
|
+
O,
|
|
2137
|
+
k,
|
|
2138
|
+
_
|
|
2139
|
+
]), r(() => {
|
|
2140
|
+
if (typeof window > "u" || !k.open) return;
|
|
2141
|
+
function e() {
|
|
2142
|
+
b((e) => e + 1);
|
|
2143
|
+
}
|
|
2144
|
+
return window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
2145
|
+
}, [k.open]);
|
|
2146
|
+
let A = s(() => ({
|
|
2147
|
+
height: k.collapsed ? 72 : k.height,
|
|
2148
|
+
transform: `translate(${-k.x}px, ${-k.y}px)`,
|
|
2149
|
+
width: k.width
|
|
2150
|
+
}), [k]);
|
|
2151
|
+
function oe(e) {
|
|
2152
|
+
k.collapsed || ie(e.target) || (w.current = {
|
|
2153
|
+
pointerId: e.pointerId,
|
|
2154
|
+
startX: e.clientX,
|
|
2155
|
+
startY: e.clientY,
|
|
2156
|
+
x: k.x,
|
|
2157
|
+
y: k.y
|
|
2158
|
+
}, e.currentTarget.setPointerCapture(e.pointerId), v(k));
|
|
2159
|
+
}
|
|
2160
|
+
function se(e) {
|
|
2161
|
+
if (!w.current || w.current.pointerId !== e.pointerId) return;
|
|
2162
|
+
let t = mt(k, {
|
|
2163
|
+
type: "move",
|
|
2164
|
+
x: w.current.x - (e.clientX - w.current.startX),
|
|
2165
|
+
y: w.current.y - (e.clientY - w.current.startY)
|
|
2166
|
+
});
|
|
2167
|
+
v(t);
|
|
2168
|
+
}
|
|
2169
|
+
function ce(e) {
|
|
2170
|
+
w.current && w.current.pointerId === e.pointerId && (w.current = null, e.currentTarget.releasePointerCapture(e.pointerId), _ && (O(_), v(null)));
|
|
2171
|
+
}
|
|
2172
|
+
function le(e) {
|
|
2173
|
+
e.button === 0 && (e.preventDefault(), e.stopPropagation(), E.current = {
|
|
2174
|
+
height: k.height,
|
|
2175
|
+
pointerId: e.pointerId,
|
|
2176
|
+
startX: e.clientX,
|
|
2177
|
+
startY: e.clientY,
|
|
2178
|
+
width: k.width
|
|
2179
|
+
}, e.currentTarget.setPointerCapture(e.pointerId), S(!0), v(k));
|
|
2180
|
+
}
|
|
2181
|
+
function ue(e) {
|
|
2182
|
+
if (!E.current || E.current.pointerId !== e.pointerId) return;
|
|
2183
|
+
let t = mt(k, {
|
|
2184
|
+
type: "resize",
|
|
2185
|
+
height: E.current.height - (e.clientY - E.current.startY),
|
|
2186
|
+
width: E.current.width - (e.clientX - E.current.startX)
|
|
2187
|
+
});
|
|
2188
|
+
v(t);
|
|
2189
|
+
}
|
|
2190
|
+
function de(e) {
|
|
2191
|
+
E.current && E.current.pointerId === e.pointerId && (E.current = null, S(!1), e.currentTarget.hasPointerCapture(e.pointerId) && e.currentTarget.releasePointerCapture(e.pointerId), _ && (O(_), v(null)));
|
|
2192
|
+
}
|
|
2193
|
+
function fe(e) {
|
|
2194
|
+
if (![
|
|
2195
|
+
"ArrowLeft",
|
|
2196
|
+
"ArrowRight",
|
|
2197
|
+
"ArrowUp",
|
|
2198
|
+
"ArrowDown"
|
|
2199
|
+
].includes(e.key)) return;
|
|
2200
|
+
e.preventDefault(), e.stopPropagation();
|
|
2201
|
+
let t = e.shiftKey ? 40 : 10;
|
|
2202
|
+
O(mt(k, {
|
|
2203
|
+
type: "resize",
|
|
2204
|
+
width: k.width + (e.key === "ArrowLeft" ? t : e.key === "ArrowRight" ? -t : 0),
|
|
2205
|
+
height: k.height + (e.key === "ArrowUp" ? t : e.key === "ArrowDown" ? -t : 0)
|
|
2206
|
+
}));
|
|
2207
|
+
}
|
|
2208
|
+
return /* @__PURE__ */ R("div", {
|
|
2209
|
+
className: "ef-chat-window",
|
|
2210
|
+
children: k.open ? /* @__PURE__ */ z("div", {
|
|
2211
|
+
className: k.collapsed ? "ef-chat-window__panel ef-chat-window__panel--collapsed" : "ef-chat-window__panel",
|
|
2212
|
+
ref: te,
|
|
2213
|
+
style: A,
|
|
2214
|
+
children: [
|
|
2215
|
+
/* @__PURE__ */ z("div", {
|
|
2216
|
+
className: "ef-chat-window__header",
|
|
2217
|
+
onPointerDown: oe,
|
|
2218
|
+
onPointerMove: se,
|
|
2219
|
+
onPointerUp: ce,
|
|
2220
|
+
onPointerCancel: ce,
|
|
2221
|
+
children: [/* @__PURE__ */ z("div", {
|
|
2222
|
+
className: "ef-chat-window__title",
|
|
2223
|
+
children: [/* @__PURE__ */ R(d, {
|
|
2224
|
+
size: 18,
|
|
2225
|
+
"aria-hidden": "true"
|
|
2226
|
+
}), /* @__PURE__ */ R("div", {
|
|
2227
|
+
className: "ef-chat-window__title-text",
|
|
2228
|
+
children: /* @__PURE__ */ R("span", {
|
|
2229
|
+
className: "ef-chat-window__title-main",
|
|
2230
|
+
children: o
|
|
2231
|
+
})
|
|
2232
|
+
})]
|
|
2233
|
+
}), /* @__PURE__ */ z("div", {
|
|
2234
|
+
className: "ef-chat-window__actions",
|
|
2235
|
+
children: [
|
|
2236
|
+
n ? /* @__PURE__ */ R("button", {
|
|
2237
|
+
className: "ef-chat-window__control",
|
|
2238
|
+
type: "button",
|
|
2239
|
+
title: "New chat",
|
|
2240
|
+
"aria-label": "New chat",
|
|
2241
|
+
onClick: () => p.onNewSession?.(),
|
|
2242
|
+
children: /* @__PURE__ */ R(re, { size: 16 })
|
|
2243
|
+
}) : null,
|
|
2244
|
+
/* @__PURE__ */ R("button", {
|
|
2245
|
+
className: "ef-chat-window__control",
|
|
2246
|
+
type: "button",
|
|
2247
|
+
title: k.collapsed ? "Expand chat" : "Collapse chat",
|
|
2248
|
+
"aria-label": k.collapsed ? "Expand chat" : "Collapse chat",
|
|
2249
|
+
onClick: () => O(mt(k, { type: "toggle-collapsed" })),
|
|
2250
|
+
children: k.collapsed ? /* @__PURE__ */ R(ee, { size: 16 }) : /* @__PURE__ */ R(ne, { size: 16 })
|
|
2251
|
+
}),
|
|
2252
|
+
/* @__PURE__ */ R("button", {
|
|
2253
|
+
className: "ef-chat-window__control",
|
|
2254
|
+
type: "button",
|
|
2255
|
+
"aria-label": "Close chat",
|
|
2256
|
+
onClick: () => O(mt(k, {
|
|
2257
|
+
type: "toggle-open",
|
|
2258
|
+
open: !1
|
|
2259
|
+
})),
|
|
2260
|
+
children: /* @__PURE__ */ R(ae, { size: 16 })
|
|
2261
|
+
})
|
|
2262
|
+
]
|
|
2263
|
+
})]
|
|
2264
|
+
}),
|
|
2265
|
+
k.collapsed ? null : /* @__PURE__ */ R("div", {
|
|
2266
|
+
className: "ef-chat-window__body",
|
|
2267
|
+
children: /* @__PURE__ */ R(On, {
|
|
2268
|
+
...p,
|
|
2269
|
+
showHeader: !1
|
|
2270
|
+
})
|
|
2271
|
+
}),
|
|
2272
|
+
k.collapsed ? null : /* @__PURE__ */ R("div", {
|
|
2273
|
+
className: "ef-chat-window__resize",
|
|
2274
|
+
role: "group",
|
|
2275
|
+
tabIndex: 0,
|
|
2276
|
+
title: f,
|
|
2277
|
+
"aria-label": f,
|
|
2278
|
+
"data-resizing": x || void 0,
|
|
2279
|
+
onPointerDown: le,
|
|
2280
|
+
onPointerMove: ue,
|
|
2281
|
+
onPointerUp: de,
|
|
2282
|
+
onPointerCancel: de,
|
|
2283
|
+
onLostPointerCapture: de,
|
|
2284
|
+
onKeyDown: fe
|
|
2285
|
+
})
|
|
2286
|
+
]
|
|
2287
|
+
}) : /* @__PURE__ */ z("button", {
|
|
2288
|
+
className: "ef-chat__button ef-chat-window__fab",
|
|
2289
|
+
type: "button",
|
|
2290
|
+
onClick: () => O(mt(k, {
|
|
2291
|
+
type: "toggle-open",
|
|
2292
|
+
open: !0
|
|
2293
|
+
})),
|
|
2294
|
+
children: [/* @__PURE__ */ R(d, { size: 16 }), /* @__PURE__ */ R("span", { children: o })]
|
|
2295
|
+
})
|
|
2296
|
+
});
|
|
2297
|
+
}
|
|
2298
|
+
//#endregion
|
|
2299
|
+
//#region src/ChatRuntimeWindow.tsx
|
|
2300
|
+
function An(e, t) {
|
|
2301
|
+
return `presentation-read-health:${e}:${t}`;
|
|
2302
|
+
}
|
|
2303
|
+
function jn(e, t, n) {
|
|
2304
|
+
let r = new Set(n.filter((e) => e.threadId === t && Qe(e)).map((e) => e.runId));
|
|
2305
|
+
return e.filter((e) => !(e.type === "CUSTOM" && e.name === "agent.presentation.incomplete" && e.threadId === t && typeof e.runId == "string" && r.has(e.runId) && e.id === An(t, e.runId)));
|
|
2306
|
+
}
|
|
2307
|
+
function Mn(e) {
|
|
2308
|
+
console.error(e);
|
|
2309
|
+
}
|
|
2310
|
+
function Nn(e) {
|
|
2311
|
+
return e?.trim() || void 0;
|
|
2312
|
+
}
|
|
2313
|
+
function Pn({ allowDraftSession: e = !1, agentReplyEffect: n = "off", agentReplySpeed: i = 120, adapter: o, attachmentDownloader: u, attachmentLabels: d, autoFocusComposer: f = !1, composerHeader: p, composerTop: m, config: h, composerRef: g, submitterRef: _, createSessionLabel: v, currentUserDisplayName: y, currentSender: b, draft: x, debugOptions: S, emptyDescription: C, emptyTitle: ee, errorDisplay: te = "inline", floatingSubtitle: ne = "AI assistant", floatingTitle: w = "Assistant", formatAnnotationCount: T, footerAddon: E, goal: re, headerContent: ie, initialSession: D = null, onCreateSession: O, onDraftChange: k, onError: A = Mn, confirmDeleteTurn: ae, onInfo: de, onPendingAttachmentsChange: me, onPasteAttachment: he, onRunStateChange: ge, onSessionChange: ve, pendingAnnotations: be, onPendingAnnotationsChange: xe, pendingAttachments: Ce, createSendInput: we, renderAttachmentControl: Te, showAttachmentControl: Ee = !0, showHeader: Oe, showHistoryRail: Ae, sidebarContent: Ne, windowState: Pe, onWindowStateChange: Fe, onA2UIAction: Ie, renderMarkdownLink: Le }) {
|
|
2314
|
+
let j = s(() => o ?? je(), [o]), Re = s(() => D ? ut(D) : null, [D]), [M, Be] = l(Re), [Ve, N] = l([]), Ge = c(null), qe = M?.sessionId ?? "";
|
|
2315
|
+
(!Ge.current || Ge.current.sessionId !== qe) && (Ge.current = new le(qe));
|
|
2316
|
+
let Je = Ge.current, [Ye, Xe] = l(0);
|
|
2317
|
+
r(() => Je.client.subscribe(() => Xe((e) => e + 1)), [Je]);
|
|
2318
|
+
let Ze = t(async (e = Je) => {
|
|
2319
|
+
if (!e.sessionId || !j.loadA2uiState) return;
|
|
2320
|
+
let t = await j.loadA2uiState(e.sessionId);
|
|
2321
|
+
e.hydrate(t);
|
|
2322
|
+
}, [Je, j]);
|
|
2323
|
+
r(() => {
|
|
2324
|
+
Ze().catch((e) => A(String(e), $("A2UI state failed")));
|
|
2325
|
+
}, [Ze]);
|
|
2326
|
+
let it = (e) => {
|
|
2327
|
+
let t = Ge.current;
|
|
2328
|
+
try {
|
|
2329
|
+
t.applyEvent(e) ? e.type === "CUSTOM" && e.name === "agent.a2ui" && (!e.threadId || e.threadId === t.sessionId) && Xe((e) => e + 1) : Ze(t).catch((e) => A(String(e), $("A2UI recovery failed")));
|
|
2330
|
+
} catch (e) {
|
|
2331
|
+
A(String(e), $("A2UI presentation failed")), Ze(t).catch(() => {});
|
|
2332
|
+
}
|
|
2333
|
+
}, at = s(() => nt(Ve, Je.messages()), [
|
|
2334
|
+
Ve,
|
|
2335
|
+
Je,
|
|
2336
|
+
Ye
|
|
2337
|
+
]), [P, ot] = l(null), [st, dt] = l(null), [pt, mt] = l(!1), [I, L] = l(null), [bt, St] = l([]), [Ct, wt] = l([]), Tt = s(() => [...new Map([...bt, ...Ct].filter((e) => e.sessionId === M?.sessionId).map((e) => [e.requestId, e])).values()], [
|
|
2338
|
+
bt,
|
|
2339
|
+
Ct,
|
|
2340
|
+
M?.sessionId
|
|
2341
|
+
]), Et = c(/* @__PURE__ */ new Set()), [Dt, Ot] = l(!1), [kt, jt] = l(null), [Mt, Nt] = l(!1), Pt = c(!1), [Ft, It] = l(null), [Lt, Rt] = l([]), [B, V] = l([]), [H, U] = l([]), [zt, Bt] = l({}), [Vt, Ht] = l(""), [Ut, Wt] = l(""), [Gt, W] = l([]), [Kt, qt] = l(!1), [Jt, Yt] = l(!1), [Xt, Zt] = l(null), [Qt, $t] = l(!1), [en, G] = l(!1), [tn, nn] = l(!1), rn = c(null), an = c(null), [on, sn] = l(!1), [cn, ln] = l(""), [un, dn] = l(null), [fn, pn] = l(null), [mn, hn] = l(!1), [gn, _n] = l(!1), [vn, yn] = l([]), K = c(""), bn = c(""), q = c(""), xn = c(null), Sn = c(/* @__PURE__ */ new Set()), J = c(0), Cn = c(!1), Y = c(null), wn = c(null), Tn = c(!1), En = c(0), Dn = c(/* @__PURE__ */ new WeakMap()), X = c(!1), Z = c([]), Pn = c(0), Fn = c(0), In = c(0), Ln = c(/* @__PURE__ */ new Set()), Rn = c(null), zn = c(/* @__PURE__ */ new Set()), Bn = c(/* @__PURE__ */ new Set()), Vn = c(x ?? ""), Hn = c([]), Un = c(Ce ?? []), Wn = x ?? Ut, Gn = Ce ?? Gt, [Kn, qn] = l([]), Jn = be ?? Kn, Yn = c(Jn);
|
|
2342
|
+
Yn.current = Jn;
|
|
2343
|
+
function Xn(e) {
|
|
2344
|
+
let t = typeof e == "function" ? e(Yn.current) : e;
|
|
2345
|
+
Yn.current = t, be === void 0 && qn(t), xe?.(t);
|
|
2346
|
+
}
|
|
2347
|
+
let Zn = c(n), Qn = c(i);
|
|
2348
|
+
Zn.current = n, Qn.current = i;
|
|
2349
|
+
let $n = t((e, t) => {
|
|
2350
|
+
N((n) => n.map((n) => n.messageId === e ? {
|
|
2351
|
+
...n,
|
|
2352
|
+
content: `${n.content}${t}`
|
|
2353
|
+
} : n));
|
|
2354
|
+
}, []), er = c(null);
|
|
2355
|
+
er.current ||= new ce($n, () => Qn.current);
|
|
2356
|
+
function tr(e, t, n) {
|
|
2357
|
+
let r = e.receive(t);
|
|
2358
|
+
if (!r) return;
|
|
2359
|
+
let { message: i, delta: a, ended: o } = r;
|
|
2360
|
+
o && er.current?.flush(i.messageId), N((e) => {
|
|
2361
|
+
let t = n ? e.filter((e) => e.messageId !== n) : e;
|
|
2362
|
+
return o && !i.content.trim() ? t.filter((e) => e.messageId !== i.messageId) : t.some((e) => e.messageId === i.messageId) ? t.map((e) => e.messageId === i.messageId ? {
|
|
2363
|
+
...e,
|
|
2364
|
+
phase: i.phase
|
|
2365
|
+
} : e) : [...t, {
|
|
2366
|
+
...i,
|
|
2367
|
+
content: ""
|
|
2368
|
+
}];
|
|
2369
|
+
}), Zt(e.activeMessageId), a && (sn(!1), er.current?.enqueue(i.messageId, a, Zn.current));
|
|
2370
|
+
}
|
|
2371
|
+
r(() => () => er.current?.dispose(), []), r(() => {
|
|
2372
|
+
n === "off" && er.current?.flush();
|
|
2373
|
+
}, [n]), r(() => {
|
|
2374
|
+
Vn.current = Wn;
|
|
2375
|
+
}, [Wn]), r(() => {
|
|
2376
|
+
Un.current = Gn;
|
|
2377
|
+
}, [Gn]);
|
|
2378
|
+
function nr(e) {
|
|
2379
|
+
let t = typeof e == "function" ? e(Vn.current) : e;
|
|
2380
|
+
Hn.current = _t(t, h.inputSuggestions ?? [], Hn.current), Vn.current = t, x === void 0 && Wt(t), k?.(t);
|
|
2381
|
+
}
|
|
2382
|
+
function rr(e) {
|
|
2383
|
+
let t = typeof e == "function" ? e(Un.current) : e;
|
|
2384
|
+
Un.current = t, Ce === void 0 && W(t), me?.(t);
|
|
2385
|
+
}
|
|
2386
|
+
let ir = h.showAgui !== !1 && j.capabilities.supportsAgui, ar = ir && !j.loadHistory && j.capabilities.supportsProtocolReplay && !!j.loadProtocolEvents, or = cn || fn?.runId || "", sr = Jt || !!fn, [cr, lr] = l(""), ur = sr ? fn?.operationKind ?? (cr === M?.sessionId || ke(B, or) ? "ContextCompaction" : void 0) : void 0, Q = ur === "ContextCompaction";
|
|
2387
|
+
r(() => {
|
|
2388
|
+
sr || lr("");
|
|
2389
|
+
}, [sr]);
|
|
2390
|
+
let dr = fn?.runId === or ? fn.state : "RUNNING", fr = fn?.runId === or ? fn.supportsSteer : un, pr = !!(!Q && j.capabilities.supportsSteer && j.steerMessage && or && dr === "RUNNING" && fr !== !1), mr = s(() => pr ? ["steer", "queue"] : ["queue"], [pr]), hr = !!(!Q && M && !gn && (or && dr === "RUNNING" && j.capabilities.supportsStop && j.stopRun || Jt && j.capabilities.supportsAbort && !(j.capabilities.supportsStop && j.stopRun)));
|
|
2391
|
+
r(() => {
|
|
2392
|
+
ge?.({
|
|
2393
|
+
loading: en || mn,
|
|
2394
|
+
active: sr,
|
|
2395
|
+
runId: or,
|
|
2396
|
+
sessionId: M?.sessionId ?? "",
|
|
2397
|
+
supportsSteer: pr,
|
|
2398
|
+
operationKind: ur
|
|
2399
|
+
});
|
|
2400
|
+
}, [
|
|
2401
|
+
ur,
|
|
2402
|
+
pr,
|
|
2403
|
+
or,
|
|
2404
|
+
ge,
|
|
2405
|
+
en,
|
|
2406
|
+
mn,
|
|
2407
|
+
sr,
|
|
2408
|
+
M?.sessionId
|
|
2409
|
+
]);
|
|
2410
|
+
let gr = s(() => vn.filter((e) => e.sessionId === M?.sessionId), [vn, M?.sessionId]), _r = s(() => _e(at.filter((e) => e.sessionId === M?.sessionId), [...B, ...H]), [
|
|
2411
|
+
at,
|
|
2412
|
+
M?.sessionId,
|
|
2413
|
+
B,
|
|
2414
|
+
H
|
|
2415
|
+
]);
|
|
2416
|
+
function vr(e) {
|
|
2417
|
+
X.current = e, Yt(e);
|
|
2418
|
+
}
|
|
2419
|
+
function yr(e) {
|
|
2420
|
+
Cn.current = e, hn(e);
|
|
2421
|
+
}
|
|
2422
|
+
function br(e) {
|
|
2423
|
+
return Dn.current.get(e) ?? "none";
|
|
2424
|
+
}
|
|
2425
|
+
function xr(e, t = !0) {
|
|
2426
|
+
let n = Y.current;
|
|
2427
|
+
return n ? (Dn.current.set(n, e), Y.current = null, t && (vr(!1), sn(!1), q.current = "", ln(""), dn(null)), n.abort(), !0) : !1;
|
|
2428
|
+
}
|
|
2429
|
+
function Sr(e = !0) {
|
|
2430
|
+
let t = wn.current;
|
|
2431
|
+
return t ? (wn.current = null, e && (Tn.current = !1, $t(!1)), t.abort(), !0) : !1;
|
|
2432
|
+
}
|
|
2433
|
+
function Cr(e) {
|
|
2434
|
+
e && Sn.current.has(`${K.current}:${e.runId}`) && (e = null), xn.current = e, pn(e);
|
|
2435
|
+
}
|
|
2436
|
+
function wr(e, t) {
|
|
2437
|
+
let n = q.current;
|
|
2438
|
+
for (let r of [n, t]) r && Sn.current.add(`${e}:${r}`);
|
|
2439
|
+
return Cr(xn.current), yr(!1), ++J.current;
|
|
2440
|
+
}
|
|
2441
|
+
let Tr = t(async (e, t) => {
|
|
2442
|
+
if (j.capabilities.supportsActiveRun && j.getActiveRun) return (await j.getActiveRun(e, t)).activeRun;
|
|
2443
|
+
if (j.loadHistory) {
|
|
2444
|
+
let n = (await j.loadHistory(e, {
|
|
2445
|
+
limit: 20,
|
|
2446
|
+
cursor: null
|
|
2447
|
+
}, t)).activeRuns.find((e) => e.status === "Running" && e.parentRunId === null);
|
|
2448
|
+
return n ? {
|
|
2449
|
+
runId: n.id,
|
|
2450
|
+
runtimeAdapterKey: "native",
|
|
2451
|
+
supportsSteer: j.capabilities.supportsSteer ?? !1,
|
|
2452
|
+
state: "RUNNING"
|
|
2453
|
+
} : null;
|
|
2454
|
+
}
|
|
2455
|
+
return !j.capabilities.supportsActiveRun || !j.getActiveRun ? null : (await j.getActiveRun(e, t)).activeRun;
|
|
2456
|
+
}, [j]);
|
|
2457
|
+
async function Er(e, t, n = () => !0) {
|
|
2458
|
+
if (j.loadHistory || !ir) return !0;
|
|
2459
|
+
let [r, i] = await Promise.allSettled([j.loadAguiEvents(e), ar && j.loadProtocolEvents ? j.loadProtocolEvents(e) : Promise.resolve([])]);
|
|
2460
|
+
if (K.current !== e || !n()) return !1;
|
|
2461
|
+
let a = [r, i].flatMap((e) => e.status === "rejected" ? [e.reason] : []);
|
|
2462
|
+
Lr(e, a);
|
|
2463
|
+
let o = a.length > 0 || r.status === "fulfilled" && r.value.some((e) => e.metadata?.replayIncomplete === "true"), s = {
|
|
2464
|
+
type: "CUSTOM",
|
|
2465
|
+
name: "agent.presentation.incomplete",
|
|
2466
|
+
id: An(e, t),
|
|
2467
|
+
runId: t,
|
|
2468
|
+
threadId: e,
|
|
2469
|
+
timestamp: Date.now(),
|
|
2470
|
+
value: { code: "AGENT_AGUI_REPLAY_INCOMPLETE" }
|
|
2471
|
+
};
|
|
2472
|
+
return r.status === "fulfilled" && Rt(r.value), i.status === "fulfilled" && ar ? (V(o ? [...i.value, s] : i.value), o || U((t) => jn(t, e, i.value)), i.value.some((e) => e.runId === t && ["RUN_FINISHED", "RUN_ERROR"].includes(e.type))) : (o && U((e) => [...e, s]), !1);
|
|
2473
|
+
}
|
|
2474
|
+
async function Dr(e, t, n) {
|
|
2475
|
+
let r = () => K.current === e && J.current === n && !X.current;
|
|
2476
|
+
if (j.loadHistory) {
|
|
2477
|
+
try {
|
|
2478
|
+
let t = await j.loadHistory(e, {
|
|
2479
|
+
limit: 20,
|
|
2480
|
+
cursor: null
|
|
2481
|
+
});
|
|
2482
|
+
if (!r()) return;
|
|
2483
|
+
N(We(t, h.userInputLabels)), ot(t), dt(t.nextCursor);
|
|
2484
|
+
let n = Ke(t, h.userInputLabels);
|
|
2485
|
+
St(n), L(n[0] ?? null), V(He(t)), Rt([]);
|
|
2486
|
+
let i = new Set(t.runs.filter((e) => [
|
|
2487
|
+
"Completed",
|
|
2488
|
+
"Failed",
|
|
2489
|
+
"Interrupted",
|
|
2490
|
+
"Waiting"
|
|
2491
|
+
].includes(e.status)).map((e) => e.id));
|
|
2492
|
+
U((e) => e.filter((e) => !i.has(Ue(e)))), Bt({});
|
|
2493
|
+
} catch (t) {
|
|
2494
|
+
Lr(e, [t]);
|
|
2495
|
+
}
|
|
2496
|
+
return;
|
|
2497
|
+
}
|
|
2498
|
+
let [i, a] = await Promise.allSettled([j.loadMessages(e), Er(e, t, r)]);
|
|
2499
|
+
r() && (i.status === "fulfilled" && N(i.value), a.status === "fulfilled" && a.value && (U([]), Bt({})));
|
|
2500
|
+
}
|
|
2501
|
+
async function Or(e) {
|
|
2502
|
+
try {
|
|
2503
|
+
let t = await Tr(e);
|
|
2504
|
+
if (K.current === e) {
|
|
2505
|
+
if (Cr(t), t) yr(!1);
|
|
2506
|
+
else if (Cn.current && !X.current) {
|
|
2507
|
+
yr(!1);
|
|
2508
|
+
let t = Mr(e);
|
|
2509
|
+
t && M?.sessionId === e && Gr(M, t.input, t);
|
|
2510
|
+
}
|
|
2511
|
+
}
|
|
2512
|
+
return t;
|
|
2513
|
+
} catch {
|
|
2514
|
+
return;
|
|
2515
|
+
}
|
|
2516
|
+
}
|
|
2517
|
+
function kr(e) {
|
|
2518
|
+
Z.current = e, yn(e);
|
|
2519
|
+
}
|
|
2520
|
+
function Ar(e, t, n = [], r = _t(t, h.inputSuggestions ?? [], Hn.current), i = Jn) {
|
|
2521
|
+
if (we) {
|
|
2522
|
+
let a = we(e, t, n);
|
|
2523
|
+
return a ? {
|
|
2524
|
+
...a,
|
|
2525
|
+
requestedSkills: r,
|
|
2526
|
+
annotations: i
|
|
2527
|
+
} : null;
|
|
2528
|
+
}
|
|
2529
|
+
let a = {
|
|
2530
|
+
clientCapabilities: { userInputRequests: !0 },
|
|
2531
|
+
content: t,
|
|
2532
|
+
annotations: i,
|
|
2533
|
+
requestedSkills: r
|
|
2534
|
+
};
|
|
2535
|
+
return n.length && (a.attachments = n), a;
|
|
2536
|
+
}
|
|
2537
|
+
function jr(e, t, n = "back") {
|
|
2538
|
+
Fn.current += 1;
|
|
2539
|
+
let r = {
|
|
2540
|
+
id: `QUEUED-${Date.now()}-${Fn.current}`,
|
|
2541
|
+
input: t,
|
|
2542
|
+
sessionId: e.sessionId
|
|
2543
|
+
};
|
|
2544
|
+
return kr(n === "front" ? [r, ...Z.current] : ze(Z.current, r)), r;
|
|
2545
|
+
}
|
|
2546
|
+
function Mr(e) {
|
|
2547
|
+
let t = xt(Z.current, e);
|
|
2548
|
+
return kr(t.remaining), t.submission;
|
|
2549
|
+
}
|
|
2550
|
+
r(() => {
|
|
2551
|
+
Be((e) => Re ? e && e.sessionId === Re.sessionId && e.updatedAt === Re.updatedAt && e.lastRunId === Re.lastRunId && e.lastRunStatus === Re.lastRunStatus && e.title === Re.title ? e : Re : e && null);
|
|
2552
|
+
}, [Re]), r(() => {
|
|
2553
|
+
let e = M?.sessionId ?? "", t = K.current;
|
|
2554
|
+
t && t !== e && (xr("detach"), Sr()), t !== e && (J.current += 1, Cr(null), yr(!1), Rn.current = null, q.current = "", ln(""), dn(null), vr(!1), $t(!1), Tn.current = !1, N([]), Rt([]), V([]), St([]), L(null), It(null), U([]), sn(!1), Bt({}), Ht(""), rr([]), Xn([])), K.current = e, ve?.(M);
|
|
2555
|
+
}, [ve, M]), r(() => () => {
|
|
2556
|
+
J.current += 1, xr("detach", !1), Sr(!1);
|
|
2557
|
+
}, []);
|
|
2558
|
+
let Nr = s(() => lt(rt(B, H), M?.sessionId ?? "", h.userInputLabels), [
|
|
2559
|
+
B,
|
|
2560
|
+
H,
|
|
2561
|
+
M?.sessionId,
|
|
2562
|
+
h.userInputLabels
|
|
2563
|
+
]), Pr = s(() => {
|
|
2564
|
+
let e = P ? Ke(P, h.userInputLabels).filter((e) => e.nativeInteraction) : [], t = new Map(e.map((e) => [e.requestId, e]));
|
|
2565
|
+
return Nr.forEach((e) => t.set(e.requestId, e)), fe([...t.values()], rt(B, H), M?.sessionId ?? "", P);
|
|
2566
|
+
}, [
|
|
2567
|
+
P,
|
|
2568
|
+
Nr,
|
|
2569
|
+
h.userInputLabels,
|
|
2570
|
+
B,
|
|
2571
|
+
H,
|
|
2572
|
+
M?.sessionId
|
|
2573
|
+
]);
|
|
2574
|
+
r(() => {
|
|
2575
|
+
Et.current.clear(), wt([]);
|
|
2576
|
+
}, [M?.sessionId]), r(() => {
|
|
2577
|
+
let e = Pr.filter((e) => !Et.current.has(e.requestId));
|
|
2578
|
+
St((t) => {
|
|
2579
|
+
let n = t.filter((e) => !e.nativeInteraction), r = new Set(n.filter((e) => e.status === "Pending").map((e) => e.requestId));
|
|
2580
|
+
return [...n, ...e.filter((e) => !r.has(e.requestId))];
|
|
2581
|
+
}), L((t) => t && !t.nativeInteraction ? t : e[0] ?? null);
|
|
2582
|
+
}, [Pr]);
|
|
2583
|
+
let Fr = t(async (e, t) => {
|
|
2584
|
+
if (j.loadHistory) {
|
|
2585
|
+
let n = await j.loadHistory(e, {
|
|
2586
|
+
limit: 20,
|
|
2587
|
+
cursor: null
|
|
2588
|
+
}, t), r = n.activeRuns.find((e) => e.status === "Running" && e.parentRunId === null), i = [], a;
|
|
2589
|
+
if (j.capabilities.supportsActiveRun && j.getActiveRun) try {
|
|
2590
|
+
a = await Tr(e, t);
|
|
2591
|
+
} catch (e) {
|
|
2592
|
+
i.push(e);
|
|
2593
|
+
}
|
|
2594
|
+
else a = r ? {
|
|
2595
|
+
runId: r.id,
|
|
2596
|
+
runtimeAdapterKey: "native",
|
|
2597
|
+
supportsSteer: j.capabilities.supportsSteer ?? !1,
|
|
2598
|
+
state: "RUNNING"
|
|
2599
|
+
} : null;
|
|
2600
|
+
let o = He(n);
|
|
2601
|
+
return {
|
|
2602
|
+
nextHistory: n,
|
|
2603
|
+
nextMessages: We(n, h.userInputLabels),
|
|
2604
|
+
nextAguiEvents: [],
|
|
2605
|
+
nextProtocolEvents: o,
|
|
2606
|
+
healthyProtocolEvents: o,
|
|
2607
|
+
healthNotice: void 0,
|
|
2608
|
+
nextActiveRun: a,
|
|
2609
|
+
nextUserInputRequests: Ke(n, h.userInputLabels),
|
|
2610
|
+
errors: i
|
|
2611
|
+
};
|
|
2612
|
+
}
|
|
2613
|
+
let n = await Promise.allSettled([
|
|
2614
|
+
j.loadMessages(e),
|
|
2615
|
+
ir ? j.loadAguiEvents(e) : Promise.resolve([]),
|
|
2616
|
+
ar && j.loadProtocolEvents ? j.loadProtocolEvents(e) : Promise.resolve([]),
|
|
2617
|
+
Tr(e, t).catch(() => void 0),
|
|
2618
|
+
j.capabilities.supportsUserInputRequests && j.loadUserInputRequests ? j.loadUserInputRequests(e, t) : Promise.resolve([])
|
|
2619
|
+
]), r = (e) => e.status === "fulfilled" ? e.value : void 0, i = r(n[1]), a = n[1].status === "rejected" || n[2].status === "rejected" || !!i?.some((e) => e.metadata?.replayIncomplete === "true"), o = i?.slice().reverse().find((e) => !!e.runId), s = r(n[0])?.slice().reverse().find((e) => !!e.runId), c = o?.runId || s?.runId || r(n[3])?.runId, l = a && c ? {
|
|
2620
|
+
type: "CUSTOM",
|
|
2621
|
+
name: "agent.presentation.incomplete",
|
|
2622
|
+
runId: c,
|
|
2623
|
+
threadId: e,
|
|
2624
|
+
id: An(e, c),
|
|
2625
|
+
timestamp: Date.parse(o?.occurredAt || s?.createdAt || "") || Date.now(),
|
|
2626
|
+
value: { code: "AGENT_AGUI_REPLAY_INCOMPLETE" }
|
|
2627
|
+
} : void 0, u = r(n[2]);
|
|
2628
|
+
return {
|
|
2629
|
+
nextHistory: void 0,
|
|
2630
|
+
nextMessages: r(n[0]),
|
|
2631
|
+
nextAguiEvents: n[2].status === "rejected" ? i?.map((e) => ({
|
|
2632
|
+
...e,
|
|
2633
|
+
metadata: {
|
|
2634
|
+
...e.metadata,
|
|
2635
|
+
replayIncomplete: "true"
|
|
2636
|
+
}
|
|
2637
|
+
})) : i,
|
|
2638
|
+
nextProtocolEvents: u && l ? [...u, l] : u,
|
|
2639
|
+
healthyProtocolEvents: a ? void 0 : u,
|
|
2640
|
+
healthNotice: l,
|
|
2641
|
+
nextActiveRun: r(n[3]),
|
|
2642
|
+
nextUserInputRequests: r(n[4]),
|
|
2643
|
+
errors: n.flatMap((e) => e.status === "rejected" ? [e.reason] : [])
|
|
2644
|
+
};
|
|
2645
|
+
}, [
|
|
2646
|
+
j,
|
|
2647
|
+
ir,
|
|
2648
|
+
ar,
|
|
2649
|
+
Tr,
|
|
2650
|
+
h.userInputLabels
|
|
2651
|
+
]);
|
|
2652
|
+
async function Ir() {
|
|
2653
|
+
let e = M?.sessionId, t = st, n = J.current;
|
|
2654
|
+
if (e && t && j.loadHistory && !pt && !Pt.current) {
|
|
2655
|
+
mt(!0);
|
|
2656
|
+
try {
|
|
2657
|
+
let r = await j.loadHistory(e, {
|
|
2658
|
+
limit: 20,
|
|
2659
|
+
cursor: t
|
|
2660
|
+
});
|
|
2661
|
+
if (K.current !== e || n !== J.current) return;
|
|
2662
|
+
N((e) => nt(We(r, h.userInputLabels), e)), V((e) => rt(He(r), e)), dt(r.nextCursor);
|
|
2663
|
+
} catch (t) {
|
|
2664
|
+
if (t?.status === 409 && K.current === e && n === J.current) try {
|
|
2665
|
+
let t = await j.loadHistory(e, {
|
|
2666
|
+
limit: 20,
|
|
2667
|
+
cursor: null
|
|
2668
|
+
});
|
|
2669
|
+
if (K.current === e && n === J.current) {
|
|
2670
|
+
N(We(t, h.userInputLabels)), ot(t), dt(t.nextCursor), V(He(t));
|
|
2671
|
+
let e = Ke(t, h.userInputLabels);
|
|
2672
|
+
St(e), L(e[0] ?? null);
|
|
2673
|
+
}
|
|
2674
|
+
} catch (t) {
|
|
2675
|
+
Lr(e, [t]);
|
|
2676
|
+
}
|
|
2677
|
+
else Lr(e, [t]);
|
|
2678
|
+
} finally {
|
|
2679
|
+
K.current === e && mt(!1);
|
|
2680
|
+
}
|
|
2681
|
+
}
|
|
2682
|
+
}
|
|
2683
|
+
let Lr = t((e, t) => {
|
|
2684
|
+
if (!t.length) {
|
|
2685
|
+
bn.current = "";
|
|
2686
|
+
return;
|
|
2687
|
+
}
|
|
2688
|
+
let n = t.map((e) => e instanceof Error ? e.message : $("Chat data could not be loaded")), r = JSON.stringify([e, n]);
|
|
2689
|
+
bn.current !== r && (bn.current = r, A(n.join("; "), $("Chat load failed")));
|
|
2690
|
+
}, [A]);
|
|
2691
|
+
r(() => {
|
|
2692
|
+
let e = !0, t = new AbortController();
|
|
2693
|
+
async function n() {
|
|
2694
|
+
let n = J.current;
|
|
2695
|
+
if (!M?.sessionId) {
|
|
2696
|
+
N([]), Rt([]), V([]), St([]), Cr(null);
|
|
2697
|
+
return;
|
|
2698
|
+
}
|
|
2699
|
+
G(!0), N([]), ot(null), dt(null);
|
|
2700
|
+
try {
|
|
2701
|
+
let { nextMessages: r, nextAguiEvents: i, nextProtocolEvents: a, nextActiveRun: o, nextUserInputRequests: s, nextHistory: c, errors: l, healthNotice: u, healthyProtocolEvents: d } = await Fr(M.sessionId, t.signal);
|
|
2702
|
+
if (!e || n !== J.current) return;
|
|
2703
|
+
if (Lr(M.sessionId, l), !X.current && r !== void 0 && (N(r), c && (ot(c), dt(c.nextCursor))), d !== void 0 && U((e) => jn(e, M.sessionId, d)), i !== void 0 && Rt(i), a === void 0 ? u && V((e) => [...e.filter((e) => e.type !== "CUSTOM" || e.name !== "agent.presentation.incomplete"), u]) : V(a), s !== void 0 && (St(s), L(s.find((e) => e.status === "Pending") ?? null)), o !== void 0) {
|
|
2704
|
+
if (Cr(o), o) yr(!1);
|
|
2705
|
+
else if (Cn.current && !X.current) {
|
|
2706
|
+
yr(!1);
|
|
2707
|
+
let e = Mr(M.sessionId);
|
|
2708
|
+
e && Gr(M, e.input, e);
|
|
2709
|
+
}
|
|
2710
|
+
}
|
|
2711
|
+
} catch (n) {
|
|
2712
|
+
if (!e || t.signal.aborted) return;
|
|
2713
|
+
A(n instanceof Error ? n.message : $("Chat data could not be loaded"), $("Chat load failed"));
|
|
2714
|
+
} finally {
|
|
2715
|
+
e && G(!1);
|
|
2716
|
+
}
|
|
2717
|
+
}
|
|
2718
|
+
return n(), () => {
|
|
2719
|
+
e = !1, t.abort();
|
|
2720
|
+
};
|
|
2721
|
+
}, [
|
|
2722
|
+
j,
|
|
2723
|
+
ir,
|
|
2724
|
+
A,
|
|
2725
|
+
ar,
|
|
2726
|
+
Fr,
|
|
2727
|
+
Lr,
|
|
2728
|
+
M?.sessionId
|
|
2729
|
+
]);
|
|
2730
|
+
let Rr = !!(M?.sessionId && (sr || mn || I || gr.length > 0));
|
|
2731
|
+
r(() => {
|
|
2732
|
+
if (!M?.sessionId || !Rr) return;
|
|
2733
|
+
let e = window.setInterval(async () => {
|
|
2734
|
+
if (!M?.sessionId || Pt.current) return;
|
|
2735
|
+
let e = J.current;
|
|
2736
|
+
try {
|
|
2737
|
+
let { nextMessages: t, nextAguiEvents: n, nextProtocolEvents: r, nextActiveRun: i, nextUserInputRequests: a, nextHistory: o, errors: s, healthNotice: c, healthyProtocolEvents: l } = await Fr(M.sessionId);
|
|
2738
|
+
if (K.current !== M.sessionId || e !== J.current) return;
|
|
2739
|
+
if (Lr(M.sessionId, s), !X.current && t !== void 0 && (N(t), o && (ot(o), dt(o.nextCursor))), l !== void 0 && U((e) => jn(e, M.sessionId, l)), n !== void 0 && Rt(n), r === void 0 ? c && V((e) => [...e.filter((e) => e.type !== "CUSTOM" || e.name !== "agent.presentation.incomplete"), c]) : V(r), a !== void 0 && (St(a), L(a.find((e) => e.status === "Pending") ?? null)), i !== void 0) {
|
|
2740
|
+
if (Cr(i), i) yr(!1);
|
|
2741
|
+
else if (Cn.current && !X.current) {
|
|
2742
|
+
yr(!1);
|
|
2743
|
+
let e = Mr(M.sessionId);
|
|
2744
|
+
e && Gr(M, e.input, e);
|
|
2745
|
+
}
|
|
2746
|
+
}
|
|
2747
|
+
} catch {}
|
|
2748
|
+
}, 1e3);
|
|
2749
|
+
return () => window.clearInterval(e);
|
|
2750
|
+
}, [
|
|
2751
|
+
j,
|
|
2752
|
+
ir,
|
|
2753
|
+
ar,
|
|
2754
|
+
Fr,
|
|
2755
|
+
Lr,
|
|
2756
|
+
M?.sessionId,
|
|
2757
|
+
Rr,
|
|
2758
|
+
I
|
|
2759
|
+
]), r(() => {
|
|
2760
|
+
let e = M?.sessionId;
|
|
2761
|
+
if (!e) {
|
|
2762
|
+
Rn.current = null;
|
|
2763
|
+
return;
|
|
2764
|
+
}
|
|
2765
|
+
if (fn) {
|
|
2766
|
+
Rn.current = {
|
|
2767
|
+
runId: fn.runId,
|
|
2768
|
+
sessionId: e
|
|
2769
|
+
};
|
|
2770
|
+
return;
|
|
2771
|
+
}
|
|
2772
|
+
let t = Rn.current;
|
|
2773
|
+
if (!t || t.sessionId !== e || ar && !B.some((e) => String(e.runId ?? e.runId ?? "") === t.runId && ["RUN_ERROR", "RUN_FINISHED"].includes(String(e.type).toUpperCase()))) return;
|
|
2774
|
+
Rn.current = null;
|
|
2775
|
+
let n = `${e}:${t.runId}`, r = Bn.current.delete(n);
|
|
2776
|
+
if (X.current || zn.current.has(n) || r) {
|
|
2777
|
+
zn.current.add(n);
|
|
2778
|
+
return;
|
|
2779
|
+
}
|
|
2780
|
+
zn.current.add(n);
|
|
2781
|
+
let i = Mr(e);
|
|
2782
|
+
i && M.sessionId === K.current && Gr(M, i.input, i);
|
|
2783
|
+
}, [
|
|
2784
|
+
B,
|
|
2785
|
+
ar,
|
|
2786
|
+
fn,
|
|
2787
|
+
M
|
|
2788
|
+
]);
|
|
2789
|
+
let zr = s(() => !!(Mt || Q || en || tn || h.disabledInput || I || Dt || !Wn.trim() && !Gn.length && !Jn.length), [
|
|
2790
|
+
Mt,
|
|
2791
|
+
Q,
|
|
2792
|
+
h.disabledInput,
|
|
2793
|
+
tn,
|
|
2794
|
+
Wn,
|
|
2795
|
+
en,
|
|
2796
|
+
Gn.length,
|
|
2797
|
+
Jn.length,
|
|
2798
|
+
M,
|
|
2799
|
+
Dt,
|
|
2800
|
+
I
|
|
2801
|
+
]), Br = s(() => Mt || Q || en || !!h.disabledInput || !!I || Dt || !Wn.trim() && !Gn.length && !Jn.length || !M, [
|
|
2802
|
+
Mt,
|
|
2803
|
+
Q,
|
|
2804
|
+
h.disabledInput,
|
|
2805
|
+
Wn,
|
|
2806
|
+
en,
|
|
2807
|
+
Gn.length,
|
|
2808
|
+
Jn.length,
|
|
2809
|
+
M,
|
|
2810
|
+
Dt,
|
|
2811
|
+
I
|
|
2812
|
+
]), Vr = Br || Qt || !pr;
|
|
2813
|
+
async function Hr() {
|
|
2814
|
+
return M || (rn.current ||= (nn(!0), j.createSession({ title: Nn(h.title) ?? w }).then((e) => (K.current = e.sessionId, Ge.current = new le(e.sessionId), Be(e), N([]), Rt([]), V([]), e)).finally(() => {
|
|
2815
|
+
rn.current = null, nn(!1);
|
|
2816
|
+
})), rn.current);
|
|
2817
|
+
}
|
|
2818
|
+
function Ur() {
|
|
2819
|
+
Hr().catch((e) => {
|
|
2820
|
+
A(e instanceof Error ? e.message : "Chat session creation failed", $("Chat send failed"));
|
|
2821
|
+
});
|
|
2822
|
+
}
|
|
2823
|
+
async function Wr(e) {
|
|
2824
|
+
if (e && j.uploadAttachment && !Kt) try {
|
|
2825
|
+
let t = await Hr();
|
|
2826
|
+
qt(!0);
|
|
2827
|
+
let n = await j.uploadAttachment(t, {
|
|
2828
|
+
file: e,
|
|
2829
|
+
kind: e.type.startsWith("image/") ? "image" : "file",
|
|
2830
|
+
summary: e.name
|
|
2831
|
+
});
|
|
2832
|
+
K.current === t.sessionId && rr((e) => [...e, n]);
|
|
2833
|
+
} catch (e) {
|
|
2834
|
+
A(e instanceof Error ? e.message : $("Chat attachment upload failed"), $("Attachment upload failed"));
|
|
2835
|
+
} finally {
|
|
2836
|
+
qt(!1);
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
async function Gr(e, t, n = null) {
|
|
2840
|
+
let r = Pn.current, i = () => {
|
|
2841
|
+
n && r === Pn.current && kr([n, ...ht(Z.current, n.id)]);
|
|
2842
|
+
};
|
|
2843
|
+
if (X.current || xn.current) return i(), !1;
|
|
2844
|
+
t = {
|
|
2845
|
+
...t,
|
|
2846
|
+
clientCapabilities: {
|
|
2847
|
+
...t.clientCapabilities,
|
|
2848
|
+
a2ui: {
|
|
2849
|
+
version: "v0.9.1",
|
|
2850
|
+
catalogIds: [oe]
|
|
2851
|
+
}
|
|
2852
|
+
},
|
|
2853
|
+
a2uiMetadata: Ge.current.metadata(t.metadata?.agentId ?? "main-agent")
|
|
2854
|
+
};
|
|
2855
|
+
let a = t.content.trim();
|
|
2856
|
+
if (!a && !t.attachments?.length && !t.annotations?.length) return i(), !1;
|
|
2857
|
+
let o = t.attachments ?? [], s = En.current, c = new AbortController(), l = ++J.current;
|
|
2858
|
+
Y.current = c, Dn.current.set(c, "none"), Ln.current.clear(), It(null), q.current = "", ln(""), dn(null), In.current += 1;
|
|
2859
|
+
let u = `${Date.now()}-${In.current}`, d = (/* @__PURE__ */ new Date()).toISOString(), f = `LOCAL-${u}-USER`, p = `LOCAL-${u}-ASSISTANT`, m = new se(e), g = () => {
|
|
2860
|
+
for (let e of [p, ...m.messageIds]) er.current?.flush(e);
|
|
2861
|
+
};
|
|
2862
|
+
Zt(p), lr(t.content.trim().toLowerCase() === "/compact" ? e.sessionId : ""), vr(!0), sn(ir), N((n) => [
|
|
2863
|
+
...n,
|
|
2864
|
+
{
|
|
2865
|
+
actor: b?.displayName ?? y ?? "User",
|
|
2866
|
+
provenance: { sender: b ?? {
|
|
2867
|
+
kind: "user",
|
|
2868
|
+
displayName: y || "User"
|
|
2869
|
+
} },
|
|
2870
|
+
channel: "conversation",
|
|
2871
|
+
content: a,
|
|
2872
|
+
annotations: t.annotations ?? [],
|
|
2873
|
+
attachments: o,
|
|
2874
|
+
requestedSkills: t.requestedSkills ?? [],
|
|
2875
|
+
createdAt: d,
|
|
2876
|
+
id: -Date.now() - In.current,
|
|
2877
|
+
messageId: f,
|
|
2878
|
+
role: "USER",
|
|
2879
|
+
runId: null,
|
|
2880
|
+
sessionId: e.sessionId
|
|
2881
|
+
},
|
|
2882
|
+
{
|
|
2883
|
+
actor: e.displayName ?? "Assistant",
|
|
2884
|
+
channel: "conversation",
|
|
2885
|
+
content: "",
|
|
2886
|
+
createdAt: d,
|
|
2887
|
+
id: -Date.now() - In.current - 1,
|
|
2888
|
+
messageId: p,
|
|
2889
|
+
role: "ASSISTANT",
|
|
2890
|
+
runId: null,
|
|
2891
|
+
sessionId: e.sessionId
|
|
2892
|
+
}
|
|
2893
|
+
]);
|
|
2894
|
+
let _ = !1, v = !1, x = !1, S = !1, C = null, ee = "";
|
|
2895
|
+
try {
|
|
2896
|
+
let n = await j.streamMessage(e, t, {
|
|
2897
|
+
onAguiEvent: (t) => {
|
|
2898
|
+
if (!ye(t, e.sessionId, d) || Y.current !== c) return;
|
|
2899
|
+
et(t) && (sn(!1), Ht("")), it(t);
|
|
2900
|
+
let n = String(t.runId ?? t.runId ?? "");
|
|
2901
|
+
if (typeof t.supportsSteer == "boolean" && dn(t.supportsSteer), n && !q.current && (q.current = n, ln(n)), tr(m, t, p), ir && (U((e) => [...e, t]), n)) {
|
|
2902
|
+
let e = String(t.type ?? "").toUpperCase();
|
|
2903
|
+
(e === "RUN_ERROR" || e === "AGENT.RUN.FAILED") && !$e(t) && Ln.current.add(n), Bt((e) => e[n] ? e : {
|
|
2904
|
+
...e,
|
|
2905
|
+
[n]: f
|
|
2906
|
+
});
|
|
2907
|
+
}
|
|
2908
|
+
},
|
|
2909
|
+
onDelta: (e) => {
|
|
2910
|
+
Y.current === c && (m.identified || (sn(!1), er.current?.enqueue(p, e, Zn.current)));
|
|
2911
|
+
}
|
|
2912
|
+
}, c.signal);
|
|
2913
|
+
if (br(c) !== "none") throw v = !0, S = !1, Error("Chat stream observer closed");
|
|
2914
|
+
if (K.current !== e.sessionId) return v = !0, S = !1, !1;
|
|
2915
|
+
g(), l = wr(n.session.sessionId, n.run.runId), n.run.status === "COMPLETED" && U((t) => t.some((e) => Qe(e) && Ue(e) === n.run.runId) ? t : [...t, {
|
|
2916
|
+
type: "RUN_FINISHED",
|
|
2917
|
+
threadId: e.sessionId,
|
|
2918
|
+
runId: n.run.runId,
|
|
2919
|
+
timestamp: Date.now(),
|
|
2920
|
+
outcome: { type: "success" }
|
|
2921
|
+
}]), v = !0, S = !1, Be(n.session), L(n.userInputRequest?.status === "Pending" ? n.userInputRequest : null);
|
|
2922
|
+
let r = n.userInputRequest;
|
|
2923
|
+
r?.status === "Pending" && St((e) => [...e.filter((e) => e.requestId !== r.requestId), r]), N((e) => m.settle(e, n.messages, [f, p], n.run)), C = n.session, ee = n.run.runId, _ = br(c) === "none" && En.current === s;
|
|
2924
|
+
} catch (r) {
|
|
2925
|
+
g();
|
|
2926
|
+
let s = br(c), l = r instanceof ue && r.code === "RUN_ALREADY_ACTIVE";
|
|
2927
|
+
x = l;
|
|
2928
|
+
let u = r instanceof ue && r.rejectedBeforeAdmission === !0, d = K.current === e.sessionId;
|
|
2929
|
+
if (u && d && (S = !!n, !n && !Vn.current && (Hn.current = t.requestedSkills ?? [], nr(a))), d && N((e) => e.filter((e) => l || u ? e.messageId !== f && e.messageId !== p : e.messageId !== p || !!e.content.trim())), l) n ? i() : jr(e, t, "front"), S = !1, yr(!0), await Or(e.sessionId), de?.("Another response is already running; your message was queued.", $("Message queued"));
|
|
2930
|
+
else if (s === "stop") v = !0, S = !1, de?.($("Current response has been stopped"), $("Chat stopped"));
|
|
2931
|
+
else if (s === "detach") S = !1;
|
|
2932
|
+
else {
|
|
2933
|
+
!n && t.annotations?.length && Xn((e) => [...t.annotations, ...e]), !n && o.length && rr((e) => [...o, ...e]);
|
|
2934
|
+
let i = De(r instanceof Error ? r.message : $("Chat send failed"), h.workRailLabels?.failed).summary, a = q.current, s = !!(a && Ln.current.has(a));
|
|
2935
|
+
ir && a && !s && (U((t) => [...t, {
|
|
2936
|
+
type: "CUSTOM",
|
|
2937
|
+
name: "agent.presentation.incomplete",
|
|
2938
|
+
runId: a,
|
|
2939
|
+
threadId: e.sessionId,
|
|
2940
|
+
timestamp: Date.now(),
|
|
2941
|
+
value: { code: "AGENT_AGUI_REPLAY_INCOMPLETE" }
|
|
2942
|
+
}]), Bt((e) => ({
|
|
2943
|
+
...e,
|
|
2944
|
+
[a]: f
|
|
2945
|
+
}))), (!ir || !s) && (It(i), A(i, $("Chat send failed")));
|
|
2946
|
+
}
|
|
2947
|
+
} finally {
|
|
2948
|
+
g(), N((e) => e.filter((e) => !m.messageIds.includes(e.messageId) || !!e.content.trim() || !!e.a2ui));
|
|
2949
|
+
let e = Y.current === c;
|
|
2950
|
+
Zt((e) => e === p || m.messageIds.includes(e ?? "") ? null : e), e && (vr(!1), sn(!1), Y.current = null, q.current = "", ln(""), dn(null));
|
|
2951
|
+
}
|
|
2952
|
+
if (v && C && Dr(C.sessionId, ee, l), !v && S && i(), x && Cn.current && K.current === e.sessionId && Or(e.sessionId), _ && C && K.current === e.sessionId) {
|
|
2953
|
+
let t = Mr(e.sessionId);
|
|
2954
|
+
t && Gr(C, t.input, t);
|
|
2955
|
+
}
|
|
2956
|
+
return _;
|
|
2957
|
+
}
|
|
2958
|
+
let Kr = (e, t, n) => {
|
|
2959
|
+
if (!n) {
|
|
2960
|
+
Ie?.(e, t);
|
|
2961
|
+
return;
|
|
2962
|
+
}
|
|
2963
|
+
if (!M || !j.sendA2uiActionStream || X.current || I || M.status === "ARCHIVED") return;
|
|
2964
|
+
let r = M, i = new AbortController();
|
|
2965
|
+
Y.current = i, vr(!0), It(null);
|
|
2966
|
+
let a = Je.prepareAction(e, t, n.surface), o = new se(r);
|
|
2967
|
+
j.sendA2uiActionStream(r, a, { onAguiEvent: (e) => {
|
|
2968
|
+
Y.current === i && K.current === r.sessionId && (it(e), tr(o, e), e.runId && (q.current = e.runId, ln(e.runId)), U((t) => [...t, e]));
|
|
2969
|
+
} }, i.signal).then((i) => {
|
|
2970
|
+
if (Je.completeAction(a.actionId), K.current !== r.sessionId) return;
|
|
2971
|
+
let s = wr(i.session.sessionId, i.run.runId);
|
|
2972
|
+
er.current?.flush(), N((e) => o.settle(e, i.messages, [], i.run)), Be(i.session), L(i.userInputRequest?.status === "Pending" ? i.userInputRequest : null), Ie?.(e, t, n), Dr(i.session.sessionId, i.run.runId, s), Ze().catch((e) => A(String(e), $("A2UI recovery failed")));
|
|
2973
|
+
}).catch((e) => {
|
|
2974
|
+
Y.current === i && K.current === r.sessionId && (It(String(e)), A(String(e), $("A2UI action failed")));
|
|
2975
|
+
}).finally(() => {
|
|
2976
|
+
Y.current === i && K.current === r.sessionId && (er.current?.flush(), Zt(null), Y.current = null, q.current = "", vr(!1), ln(""));
|
|
2977
|
+
});
|
|
2978
|
+
};
|
|
2979
|
+
async function qr(e) {
|
|
2980
|
+
if (Q || Dt || !M || !I || !j.answerUserInputRequestStream) return;
|
|
2981
|
+
let t = I;
|
|
2982
|
+
jt(null);
|
|
2983
|
+
let n = ft(t, bt), r = new Set(n.map((e) => e.requestId)), i = (t) => n.length === 1 ? e : e.filter((e) => e.questionId === t.requestId), a = M.sessionId, o = new se(M), s = !1, c = () => {
|
|
2984
|
+
if (s = !0, K.current === a) {
|
|
2985
|
+
for (let e of n) e.nativeInteraction && Et.current.add(e.requestId);
|
|
2986
|
+
wt((e) => [...e.filter((e) => !r.has(e.requestId)), ...n.map((e) => ({
|
|
2987
|
+
...e,
|
|
2988
|
+
answers: i(e),
|
|
2989
|
+
answeredAt: Date.now(),
|
|
2990
|
+
assistantMessageId: e.assistantMessageId ?? l,
|
|
2991
|
+
status: "Answered"
|
|
2992
|
+
}))]), Ot(!1), L((e) => e?.requestId === t.requestId ? null : e), St((e) => e.map((e) => r.has(e.requestId) ? {
|
|
2993
|
+
...e,
|
|
2994
|
+
answers: i(e),
|
|
2995
|
+
answeredAt: e.answeredAt ?? Date.now(),
|
|
2996
|
+
assistantMessageId: e.assistantMessageId ?? l,
|
|
2997
|
+
status: "Answered"
|
|
2998
|
+
} : e));
|
|
2999
|
+
}
|
|
3000
|
+
}, l = [...Ve].reverse().find((e) => e.role === "ASSISTANT")?.messageId ?? Ve.at(-1)?.messageId ?? "";
|
|
3001
|
+
Ot(!0);
|
|
3002
|
+
let u = ++J.current;
|
|
3003
|
+
vr(!0), sn(ir), Ht(l), V((e) => rt(e, H)), U([]), Bt({});
|
|
3004
|
+
try {
|
|
3005
|
+
let s = await j.answerUserInputRequestStream(M, I.requestId, {
|
|
3006
|
+
...ct(n, e),
|
|
3007
|
+
...j.loadA2uiState ? {
|
|
3008
|
+
clientCapabilities: {
|
|
3009
|
+
userInputRequests: !0,
|
|
3010
|
+
a2ui: {
|
|
3011
|
+
version: "v0.9.1",
|
|
3012
|
+
catalogIds: [oe]
|
|
3013
|
+
}
|
|
3014
|
+
},
|
|
3015
|
+
a2uiMetadata: Je.metadata(M.metadata?.agentId ?? "main-agent")
|
|
3016
|
+
} : {}
|
|
3017
|
+
}, { onAguiEvent: (e) => {
|
|
3018
|
+
if (K.current !== a || (et(e) && (sn(!1), Ht("")), e.type === "RUN_STARTED" && (c(), e.runId && (q.current = e.runId, ln(e.runId))), it(e), tr(o, e), !ir)) return;
|
|
3019
|
+
U((t) => [...t, e]);
|
|
3020
|
+
let n = String(e.runId ?? e.runId ?? "");
|
|
3021
|
+
n && l && Bt((e) => e[n] ? e : {
|
|
3022
|
+
...e,
|
|
3023
|
+
[n]: `interaction:${t.requestId}`
|
|
3024
|
+
});
|
|
3025
|
+
} });
|
|
3026
|
+
if (K.current !== a) return;
|
|
3027
|
+
c(), u = wr(s.session.sessionId, s.run.runId), er.current?.flush(), N((e) => o.settle(e, s.messages, [], s.run)), Be(s.session), L(s.userInputRequest?.status === "Pending" ? s.userInputRequest : null), St((e) => e.map((e) => r.has(e.requestId) ? {
|
|
3028
|
+
...e,
|
|
3029
|
+
answers: i(e),
|
|
3030
|
+
answeredAt: e.answeredAt ?? Date.now(),
|
|
3031
|
+
assistantMessageId: e.assistantMessageId ?? l,
|
|
3032
|
+
status: "Answered"
|
|
3033
|
+
} : e)), sn(!1), Ht(""), Bt({}), Dr(s.session.sessionId, s.run.runId, u);
|
|
3034
|
+
} catch (e) {
|
|
3035
|
+
if (K.current !== a) return;
|
|
3036
|
+
s || jt({
|
|
3037
|
+
sessionId: a,
|
|
3038
|
+
requestId: t.requestId
|
|
3039
|
+
}), A(e instanceof Error ? e.message : $("Chat answer failed"), $(s ? "Chat continuation failed" : "Chat answer failed"));
|
|
3040
|
+
} finally {
|
|
3041
|
+
if (K.current !== a) return;
|
|
3042
|
+
er.current?.flush(), Zt(null), q.current = "", ln(""), vr(!1), Ot(!1), sn(!1), Ht("");
|
|
3043
|
+
}
|
|
3044
|
+
}
|
|
3045
|
+
async function Jr(e) {
|
|
3046
|
+
if (Pt.current || Q || an.current || X.current || h.disabledInput || tn || !e && zr || I || Dt) return !1;
|
|
3047
|
+
let t = (e?.content ?? Wn).trim(), n = e ? e.attachments ?? [] : Gn, r = e ? [] : Jn, i = _t(t, h.inputSuggestions ?? [], Hn.current);
|
|
3048
|
+
if (!t && !n.length && !r.length) return !1;
|
|
3049
|
+
let a = Symbol("initial-submission");
|
|
3050
|
+
an.current = a;
|
|
3051
|
+
try {
|
|
3052
|
+
let o = await Hr(), s = Ar(o, t, n, i, r);
|
|
3053
|
+
return s ? (e || (nr(""), rr([]), Xn([])), xn.current ? (jr(o, s), !0) : (an.current === a && (an.current = null), await Gr(o, s), !0)) : !1;
|
|
3054
|
+
} catch (e) {
|
|
3055
|
+
return A(e instanceof Error ? e.message : $("Chat send failed"), $("Chat send failed")), !1;
|
|
3056
|
+
} finally {
|
|
3057
|
+
an.current === a && (an.current = null);
|
|
3058
|
+
}
|
|
3059
|
+
}
|
|
3060
|
+
a(_, () => ({ submit: Jr }));
|
|
3061
|
+
async function Yr() {
|
|
3062
|
+
if (Br || I || Dt) return;
|
|
3063
|
+
let e = await Hr();
|
|
3064
|
+
if (!e) return;
|
|
3065
|
+
let t = Wn.trim();
|
|
3066
|
+
if (!t && !Gn.length && !Jn.length) return;
|
|
3067
|
+
let n = Ar(e, t, Gn);
|
|
3068
|
+
if (n) {
|
|
3069
|
+
if (nr(""), rr([]), Xn([]), X.current || xn.current) {
|
|
3070
|
+
jr(e, n);
|
|
3071
|
+
return;
|
|
3072
|
+
}
|
|
3073
|
+
await Gr(e, n);
|
|
3074
|
+
}
|
|
3075
|
+
}
|
|
3076
|
+
async function Xr(e) {
|
|
3077
|
+
if (Tn.current || !e && Vr || !pr || I || Dt) return;
|
|
3078
|
+
let t = M;
|
|
3079
|
+
if (!t) return;
|
|
3080
|
+
let n = e ? Z.current.findIndex((n) => n.id === e && n.sessionId === t.sessionId) : -1;
|
|
3081
|
+
if (e && n < 0) return;
|
|
3082
|
+
let r = n >= 0 ? Z.current[n] : null, i = r?.input.content ?? Wn.trim();
|
|
3083
|
+
if (!r && !i && !Gn.length && !Jn.length) return;
|
|
3084
|
+
let a = r?.input ?? Ar(t, i, Gn);
|
|
3085
|
+
if (!a) return;
|
|
3086
|
+
let o = q.current || xn.current?.runId || "", s = Pn.current, c = En.current;
|
|
3087
|
+
if (r ? kr(ht(Z.current, r.id)) : (nr(""), rr([]), Xn([])), !o || !j.capabilities.supportsSteer || !j.steerMessage) {
|
|
3088
|
+
r ? kr([
|
|
3089
|
+
...Z.current.slice(0, n),
|
|
3090
|
+
r,
|
|
3091
|
+
...Z.current.slice(n)
|
|
3092
|
+
]) : jr(t, a);
|
|
3093
|
+
return;
|
|
3094
|
+
}
|
|
3095
|
+
let l = [...Ve].reverse().find((e) => e.role === "USER" && F(e));
|
|
3096
|
+
In.current += 1;
|
|
3097
|
+
let u = Math.max(Date.now(), ...H.map(pe).filter((e) => e !== null).map((e) => e + 1)), d = `LOCAL-${Date.now()}-${In.current}-STEER`, f = {
|
|
3098
|
+
actor: b?.displayName ?? y ?? "User",
|
|
3099
|
+
provenance: { sender: b ?? {
|
|
3100
|
+
kind: "user",
|
|
3101
|
+
displayName: y || "User"
|
|
3102
|
+
} },
|
|
3103
|
+
channel: "conversation",
|
|
3104
|
+
content: i,
|
|
3105
|
+
annotations: a.annotations ?? [],
|
|
3106
|
+
attachments: a.attachments ?? [],
|
|
3107
|
+
requestedSkills: a.requestedSkills ?? [],
|
|
3108
|
+
createdAt: new Date(u).toISOString(),
|
|
3109
|
+
id: -Date.now() - In.current,
|
|
3110
|
+
messageId: d,
|
|
3111
|
+
role: "USER",
|
|
3112
|
+
runId: o,
|
|
3113
|
+
sessionId: t.sessionId
|
|
3114
|
+
}, p = [...H].reverse().find((e) => e.runId === o || Ue(e) === o), m = p ? Ue(p) : o, h = ir && l ? Me({
|
|
3115
|
+
at: u,
|
|
3116
|
+
fromMessageId: l.messageId,
|
|
3117
|
+
nativeRunId: m,
|
|
3118
|
+
runId: o,
|
|
3119
|
+
threadId: t.sessionId,
|
|
3120
|
+
toMessageId: d
|
|
3121
|
+
}) : [];
|
|
3122
|
+
N((e) => nt(e, [f])), h.length && U((e) => [...e, ...h]);
|
|
3123
|
+
let g = () => {
|
|
3124
|
+
K.current === t.sessionId && (N((e) => e.filter((e) => e.messageId !== d)), h.length && U((e) => e.filter((e) => e.type !== "CLIENT_WORK_SEGMENT_START" && e.type !== "CLIENT_WORK_SEGMENT_END" || e.fromMessageId !== l?.messageId || e.toMessageId !== d)));
|
|
3125
|
+
}, _ = new AbortController();
|
|
3126
|
+
wn.current = _, Tn.current = !0, $t(!0);
|
|
3127
|
+
try {
|
|
3128
|
+
let e = await j.steerMessage(t, a, { expectedRunId: o }, _.signal);
|
|
3129
|
+
if (K.current === e.sessionId && (N((t) => nt(t.filter((e) => e.messageId !== d), [e.message])), h.length && l)) {
|
|
3130
|
+
let n = Me({
|
|
3131
|
+
at: u,
|
|
3132
|
+
fromMessageId: l.messageId,
|
|
3133
|
+
nativeRunId: m,
|
|
3134
|
+
runId: o,
|
|
3135
|
+
threadId: t.sessionId,
|
|
3136
|
+
toMessageId: e.message.messageId
|
|
3137
|
+
});
|
|
3138
|
+
U((e) => [...e.filter((e) => e.type !== "CLIENT_WORK_SEGMENT_START" && e.type !== "CLIENT_WORK_SEGMENT_END" || e.fromMessageId !== l.messageId || e.toMessageId !== d), ...n]);
|
|
3139
|
+
}
|
|
3140
|
+
if (wn.current !== _) return;
|
|
3141
|
+
} catch (e) {
|
|
3142
|
+
g();
|
|
3143
|
+
let o = wn.current !== _, l = e instanceof ue && tt(e.code);
|
|
3144
|
+
if (l && Pn.current === s) {
|
|
3145
|
+
if (r) {
|
|
3146
|
+
let e = [...Z.current];
|
|
3147
|
+
e.splice(Math.min(n, e.length), 0, r), kr(e);
|
|
3148
|
+
} else jr(t, a, "front");
|
|
3149
|
+
let e = await Or(t.sessionId);
|
|
3150
|
+
if (!X.current && e === null && En.current === c && K.current === t.sessionId) {
|
|
3151
|
+
let e = Mr(t.sessionId);
|
|
3152
|
+
e && Gr(t, e.input, e);
|
|
3153
|
+
}
|
|
3154
|
+
}
|
|
3155
|
+
let u = e instanceof Error && e.name === "AbortError";
|
|
3156
|
+
if (l) de?.($("The active run rejected steer; the message was queued"), $("Message queued"));
|
|
3157
|
+
else if (o || u) de?.($("Steer delivery was not confirmed and was not retried"), $("Steer not retried"));
|
|
3158
|
+
else {
|
|
3159
|
+
if (r && e instanceof ue && e.rejectedBeforeAdmission && Pn.current === s) {
|
|
3160
|
+
let e = [...Z.current];
|
|
3161
|
+
e.splice(Math.min(n, e.length), 0, r), kr(e);
|
|
3162
|
+
}
|
|
3163
|
+
!r && e instanceof ue && e.rejectedBeforeAdmission && K.current === t.sessionId && !Vn.current && (Hn.current = a.requestedSkills ?? [], nr(i), rr((e) => [...a.attachments ?? [], ...e]), Xn((e) => [...a.annotations ?? [], ...e])), A(e instanceof Error ? e.message : $("Chat steer failed"), $("Chat steer failed"));
|
|
3164
|
+
}
|
|
3165
|
+
} finally {
|
|
3166
|
+
wn.current === _ && (wn.current = null, Tn.current = !1, $t(!1));
|
|
3167
|
+
}
|
|
3168
|
+
}
|
|
3169
|
+
async function Zr(e = "send") {
|
|
3170
|
+
if (e === "queue") {
|
|
3171
|
+
await Yr();
|
|
3172
|
+
return;
|
|
3173
|
+
}
|
|
3174
|
+
if (e === "steer") {
|
|
3175
|
+
await Xr();
|
|
3176
|
+
return;
|
|
3177
|
+
}
|
|
3178
|
+
await Jr();
|
|
3179
|
+
}
|
|
3180
|
+
async function Qr(e) {
|
|
3181
|
+
let t = M?.sessionId, n = e.history?.run?.rootRunId, r = P?.version;
|
|
3182
|
+
if (t && n && r && j.deleteTurn && j.loadHistory && P?.canDeleteTurns && !Pt.current && !X.current && !xn.current && !Q && !P?.activeRuns.length) {
|
|
3183
|
+
Pt.current = !0, Nt(!0), ++J.current;
|
|
3184
|
+
try {
|
|
3185
|
+
if (!(ae ? await ae(e) : window.confirm(h.turnDeletionLabels?.confirm ?? $("Delete this user message and its agent replies? They will no longer appear in the conversation or be sent to the model. Rebuilding context may reduce cache hits and increase latency and cost."))) || K.current !== t || (await j.deleteTurn(t, {
|
|
3186
|
+
rootRunId: n,
|
|
3187
|
+
expectedVersion: r
|
|
3188
|
+
}), K.current !== t)) return;
|
|
3189
|
+
let i = new Set(Ve.filter((e) => e.history?.run?.rootRunId === n).map((e) => e.messageId));
|
|
3190
|
+
N((e) => e.filter((e) => e.history?.run?.rootRunId !== n)), U([]), Bt({}), V([]), Rt([]), wt([]), St([]), L(null), ot(null), dt(null), Xn(Jn.filter((e) => !i.has(e.messageId)));
|
|
3191
|
+
let a = await j.loadHistory(t, {
|
|
3192
|
+
limit: 20,
|
|
3193
|
+
cursor: null
|
|
3194
|
+
});
|
|
3195
|
+
if (K.current !== t) return;
|
|
3196
|
+
N(We(a, h.userInputLabels)), ot(a), dt(a.nextCursor), V(He(a)), await Ze();
|
|
3197
|
+
} catch (e) {
|
|
3198
|
+
if (K.current === t) {
|
|
3199
|
+
A(e instanceof Error ? e.message : String(e), $("Chat delete failed"));
|
|
3200
|
+
try {
|
|
3201
|
+
let e = await j.loadHistory(t, {
|
|
3202
|
+
limit: 20,
|
|
3203
|
+
cursor: null
|
|
3204
|
+
});
|
|
3205
|
+
K.current === t && (N(We(e, h.userInputLabels)), ot(e), dt(e.nextCursor));
|
|
3206
|
+
} catch {}
|
|
3207
|
+
}
|
|
3208
|
+
} finally {
|
|
3209
|
+
++J.current, Pt.current = !1, Nt(!1);
|
|
3210
|
+
}
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3213
|
+
function $r(e, t) {
|
|
3214
|
+
Hn.current = t?.requestedSkills ?? [], Xn(t?.annotations ?? []), nr(e);
|
|
3215
|
+
}
|
|
3216
|
+
function ei(e, t) {
|
|
3217
|
+
let n = Z.current.find((t) => t.id === e);
|
|
3218
|
+
kr(ht(Z.current, e)), Hn.current = n?.input.requestedSkills ?? [], nr(t), rr(n?.input.attachments ?? []), Xn(n?.input.annotations ?? []);
|
|
3219
|
+
}
|
|
3220
|
+
function ti(e) {
|
|
3221
|
+
kr(ht(Z.current, e));
|
|
3222
|
+
}
|
|
3223
|
+
function ni(e, t) {
|
|
3224
|
+
kr(gt(Z.current, e, t));
|
|
3225
|
+
}
|
|
3226
|
+
async function ri() {
|
|
3227
|
+
if (Q || !M || gn) return;
|
|
3228
|
+
let e = or;
|
|
3229
|
+
!e && j.capabilities.supportsStop && j.stopRun && (e = (await Or(M.sessionId))?.runId ?? "");
|
|
3230
|
+
let t = e ? `${M.sessionId}:${e}` : "";
|
|
3231
|
+
t && Bn.current.add(t), En.current += 1, Sr();
|
|
3232
|
+
let n = !!Y.current;
|
|
3233
|
+
if (j.capabilities.supportsStop && j.stopRun && e) {
|
|
3234
|
+
_n(!0), xn.current?.runId === e && Cr({
|
|
3235
|
+
...xn.current,
|
|
3236
|
+
state: "FINISHING"
|
|
3237
|
+
});
|
|
3238
|
+
try {
|
|
3239
|
+
await j.stopRun(M, { expectedRunId: e }), xr("stop"), n || de?.($("Current response has been stopped"), $("Chat stopped")), await Or(M.sessionId);
|
|
3240
|
+
} catch (e) {
|
|
3241
|
+
t && Bn.current.delete(t), A(e instanceof Error ? e.message : $("Chat stop failed"), $("Chat stop failed")), await Or(M.sessionId);
|
|
3242
|
+
} finally {
|
|
3243
|
+
_n(!1);
|
|
3244
|
+
}
|
|
3245
|
+
return;
|
|
3246
|
+
}
|
|
3247
|
+
xr("stop");
|
|
3248
|
+
}
|
|
3249
|
+
function ii() {
|
|
3250
|
+
h.showNewSession !== !1 && (Pn.current += 1, xr("detach"), Sr(), Be(null), N([]), L(null), Rt([]), V([]), U([]), Ht(""), Bt({}), rr([]), Xn([]), q.current = "", ln(""), dn(null), Cr(null), kr([]));
|
|
3251
|
+
}
|
|
3252
|
+
let ai = s(() => Se({
|
|
3253
|
+
debugOptions: S,
|
|
3254
|
+
liveAguiAnchorMessageCodes: zt,
|
|
3255
|
+
liveAguiEvents: H,
|
|
3256
|
+
liveAguiPendingAnchorMessageCode: Vt,
|
|
3257
|
+
liveAguiPending: on,
|
|
3258
|
+
messages: _r,
|
|
3259
|
+
protocolEvents: B,
|
|
3260
|
+
sessionId: M?.sessionId ?? ""
|
|
3261
|
+
}).debugEventsByRunCode, [
|
|
3262
|
+
S,
|
|
3263
|
+
zt,
|
|
3264
|
+
H,
|
|
3265
|
+
Vt,
|
|
3266
|
+
on,
|
|
3267
|
+
B,
|
|
3268
|
+
M?.sessionId,
|
|
3269
|
+
_r
|
|
3270
|
+
]), oi = s(() => ({
|
|
3271
|
+
...S,
|
|
3272
|
+
debugEventTypes: S?.debugEventTypes?.length ? Array.from(/* @__PURE__ */ new Set([...S.debugEventTypes, ...Array.from(ai.keys()).flatMap((e) => rt(B, H).filter((t) => (t.runId ?? t.runId ?? "") === e).map((e) => String(e.type).toUpperCase()))])) : S?.debugEventTypes
|
|
3273
|
+
}), [
|
|
3274
|
+
S,
|
|
3275
|
+
H,
|
|
3276
|
+
ai,
|
|
3277
|
+
B
|
|
3278
|
+
]), si = s(() => {
|
|
3279
|
+
if (u) return u;
|
|
3280
|
+
if (M && j.downloadAttachment) return (e) => j.downloadAttachment(M, e);
|
|
3281
|
+
}, [
|
|
3282
|
+
j,
|
|
3283
|
+
u,
|
|
3284
|
+
M
|
|
3285
|
+
]);
|
|
3286
|
+
function $(e) {
|
|
3287
|
+
return yt(e, h.locale, h.runtimeMessages);
|
|
3288
|
+
}
|
|
3289
|
+
let ci = /* @__PURE__ */ z(At, { children: [p, te === "inline" && Ft ? /* @__PURE__ */ R("div", {
|
|
3290
|
+
className: "ef-chat__run-notice ef-chat__run-notice--error",
|
|
3291
|
+
role: "alert",
|
|
3292
|
+
children: /* @__PURE__ */ R("div", {
|
|
3293
|
+
className: "ef-chat__run-notice-content",
|
|
3294
|
+
children: /* @__PURE__ */ R("div", {
|
|
3295
|
+
className: "ef-chat__run-notice-detail",
|
|
3296
|
+
children: Ft
|
|
3297
|
+
})
|
|
3298
|
+
})
|
|
3299
|
+
}) : null] }), li = /* @__PURE__ */ R(On, {
|
|
3300
|
+
...vt(h.locale, h.composerLabels),
|
|
3301
|
+
allowDraftSession: e,
|
|
3302
|
+
attachmentLabels: d,
|
|
3303
|
+
attachmentDownloader: si,
|
|
3304
|
+
autoFocusComposer: f,
|
|
3305
|
+
composerRef: g,
|
|
3306
|
+
composerHeader: ci,
|
|
3307
|
+
composerTop: Q ? /* @__PURE__ */ R("fieldset", {
|
|
3308
|
+
disabled: !0,
|
|
3309
|
+
style: { display: "contents" },
|
|
3310
|
+
children: m
|
|
3311
|
+
}) : m,
|
|
3312
|
+
createSessionLabel: v ?? (h.locale?.toLowerCase().startsWith("zh") ? "开始对话" : "Start chat"),
|
|
3313
|
+
hideMessageIdentity: h.hideMessageIdentity,
|
|
3314
|
+
currentUserDisplayName: y,
|
|
3315
|
+
debugOptions: oi,
|
|
3316
|
+
disabledInput: Mt || Q || tn || !!h.disabledInput || I?.status === "Pending",
|
|
3317
|
+
draft: Wn,
|
|
3318
|
+
emptyDescription: C ?? $("Create a session to start chatting."),
|
|
3319
|
+
emptyTitle: ee,
|
|
3320
|
+
goal: re,
|
|
3321
|
+
footerAddon: Q ? /* @__PURE__ */ R("fieldset", {
|
|
3322
|
+
disabled: !0,
|
|
3323
|
+
style: { display: "contents" },
|
|
3324
|
+
children: E
|
|
3325
|
+
}) : E,
|
|
3326
|
+
pendingAttachments: Gn,
|
|
3327
|
+
pendingAnnotations: Jn,
|
|
3328
|
+
onPendingAnnotationsChange: Xn,
|
|
3329
|
+
onRemoveAttachment: (e) => rr((t) => t.filter((t) => t.id !== e)),
|
|
3330
|
+
onAttachFile: Wr,
|
|
3331
|
+
renderAttachmentControl: Te,
|
|
3332
|
+
showAttachmentControl: Ee && !!j.uploadAttachment,
|
|
3333
|
+
attachmentUploadPending: Kt,
|
|
3334
|
+
formatAnnotationCount: T,
|
|
3335
|
+
annotationLabels: h.annotationLabels,
|
|
3336
|
+
headerContent: ie,
|
|
3337
|
+
inputPlaceholder: h.inputPlaceholder,
|
|
3338
|
+
inputSuggestions: h.inputSuggestions,
|
|
3339
|
+
skillSuggestionTriggers: h.skillSuggestionTriggers,
|
|
3340
|
+
inputSuggestionLabels: h.inputSuggestionLabels,
|
|
3341
|
+
queuedInputPlaceholder: h.queuedInputPlaceholder,
|
|
3342
|
+
steeringInputPlaceholder: h.steeringInputPlaceholder,
|
|
3343
|
+
liveAguiAnchorMessageCodes: zt,
|
|
3344
|
+
liveAguiEvents: H,
|
|
3345
|
+
liveAguiPendingAnchorMessageCode: Vt,
|
|
3346
|
+
liveAguiPending: on,
|
|
3347
|
+
messages: _r,
|
|
3348
|
+
historyLoading: en,
|
|
3349
|
+
historyLoadingOlder: pt,
|
|
3350
|
+
historyLabels: h.historyLabels,
|
|
3351
|
+
onLoadOlderHistory: st ? () => {
|
|
3352
|
+
Ir();
|
|
3353
|
+
} : void 0,
|
|
3354
|
+
onCreateSession: O ?? Ur,
|
|
3355
|
+
onNewSession: ii,
|
|
3356
|
+
onDraftChange: nr,
|
|
3357
|
+
onPasteAttachment: he ?? Wr,
|
|
3358
|
+
onEditMessage: Mt || Q ? void 0 : $r,
|
|
3359
|
+
deleteTurnLabel: h.turnDeletionLabels?.action,
|
|
3360
|
+
onDeleteTurn: j.deleteTurn && P?.canDeleteTurns && !en && !Jt && !fn && !Mt && !Q && !P.activeRuns.length ? (e) => {
|
|
3361
|
+
Qr(e);
|
|
3362
|
+
} : void 0,
|
|
3363
|
+
onEditQueuedMessage: ei,
|
|
3364
|
+
onRemoveQueuedMessage: ti,
|
|
3365
|
+
onSteerQueuedMessage: (e) => {
|
|
3366
|
+
Xr(e);
|
|
3367
|
+
},
|
|
3368
|
+
onReorderQueuedMessage: ni,
|
|
3369
|
+
onSend: (e) => {
|
|
3370
|
+
Zr(e);
|
|
3371
|
+
},
|
|
3372
|
+
onStop: () => {
|
|
3373
|
+
ri();
|
|
3374
|
+
},
|
|
3375
|
+
protocolEvents: B,
|
|
3376
|
+
queueDisabled: Br || !!I,
|
|
3377
|
+
queuedMessages: gr,
|
|
3378
|
+
runningSubmitModes: mr,
|
|
3379
|
+
runningEnterSubmitMode: h.runningEnterSubmitMode,
|
|
3380
|
+
sendDisabled: zr || !!I,
|
|
3381
|
+
sending: sr,
|
|
3382
|
+
streamingAssistantMessageCode: Xt,
|
|
3383
|
+
session: M,
|
|
3384
|
+
showHistoryRail: Ae,
|
|
3385
|
+
showAgui: ir,
|
|
3386
|
+
showReasoningCards: h.showReasoningCards,
|
|
3387
|
+
showHeader: Oe ?? !h.floating,
|
|
3388
|
+
showStop: hr,
|
|
3389
|
+
sidebarContent: Ne,
|
|
3390
|
+
steerDisabled: Vr || !!I,
|
|
3391
|
+
queuedSteerDisabled: Qt || !pr || !!I || Dt,
|
|
3392
|
+
title: h.title || w,
|
|
3393
|
+
userInputLabels: h.userInputLabels,
|
|
3394
|
+
userInputRequests: Tt,
|
|
3395
|
+
locale: h.locale,
|
|
3396
|
+
workRailLabels: h.workRailLabels,
|
|
3397
|
+
userInputAnswerPending: Dt,
|
|
3398
|
+
userInputAnswerFailed: !!(kt && kt.sessionId === M?.sessionId && kt.requestId === I?.requestId),
|
|
3399
|
+
userInputRequest: I,
|
|
3400
|
+
onAnswerUserInput: Q ? void 0 : (e) => {
|
|
3401
|
+
qr(e);
|
|
3402
|
+
},
|
|
3403
|
+
a2uiSession: Je,
|
|
3404
|
+
a2uiDisabled: Jt || M?.status === "ARCHIVED",
|
|
3405
|
+
onA2UIAction: Kr,
|
|
3406
|
+
renderMarkdownLink: Le
|
|
3407
|
+
});
|
|
3408
|
+
return h.floating === !1 ? li : /* @__PURE__ */ R(kn, {
|
|
3409
|
+
resizeHint: h.resizeHint,
|
|
3410
|
+
showNewSession: h.showNewSession,
|
|
3411
|
+
...vt(h.locale, h.composerLabels),
|
|
3412
|
+
allowDraftSession: e,
|
|
3413
|
+
createSessionLabel: v ?? (h.locale?.toLowerCase().startsWith("zh") ? "开始对话" : "Start chat"),
|
|
3414
|
+
attachmentLabels: d,
|
|
3415
|
+
attachmentDownloader: si,
|
|
3416
|
+
autoFocusComposer: f,
|
|
3417
|
+
composerRef: g,
|
|
3418
|
+
composerHeader: ci,
|
|
3419
|
+
composerTop: Q ? /* @__PURE__ */ R("fieldset", {
|
|
3420
|
+
disabled: !0,
|
|
3421
|
+
style: { display: "contents" },
|
|
3422
|
+
children: m
|
|
3423
|
+
}) : m,
|
|
3424
|
+
hideMessageIdentity: h.hideMessageIdentity,
|
|
3425
|
+
currentUserDisplayName: y,
|
|
3426
|
+
debugOptions: oi,
|
|
3427
|
+
disabledInput: Mt || Q || tn || !!h.disabledInput || I?.status === "Pending",
|
|
3428
|
+
draft: Wn,
|
|
3429
|
+
emptyDescription: C ?? $("Create a session to start chatting."),
|
|
3430
|
+
emptyTitle: ee,
|
|
3431
|
+
goal: re,
|
|
3432
|
+
footerAddon: Q ? /* @__PURE__ */ R("fieldset", {
|
|
3433
|
+
disabled: !0,
|
|
3434
|
+
style: { display: "contents" },
|
|
3435
|
+
children: E
|
|
3436
|
+
}) : E,
|
|
3437
|
+
pendingAttachments: Gn,
|
|
3438
|
+
pendingAnnotations: Jn,
|
|
3439
|
+
onPendingAnnotationsChange: Xn,
|
|
3440
|
+
onRemoveAttachment: (e) => rr((t) => t.filter((t) => t.id !== e)),
|
|
3441
|
+
onAttachFile: Wr,
|
|
3442
|
+
renderAttachmentControl: Te,
|
|
3443
|
+
showAttachmentControl: Ee && !!j.uploadAttachment,
|
|
3444
|
+
attachmentUploadPending: Kt,
|
|
3445
|
+
formatAnnotationCount: T,
|
|
3446
|
+
annotationLabels: h.annotationLabels,
|
|
3447
|
+
inputPlaceholder: h.inputPlaceholder,
|
|
3448
|
+
inputSuggestions: h.inputSuggestions,
|
|
3449
|
+
skillSuggestionTriggers: h.skillSuggestionTriggers,
|
|
3450
|
+
inputSuggestionLabels: h.inputSuggestionLabels,
|
|
3451
|
+
queuedInputPlaceholder: h.queuedInputPlaceholder,
|
|
3452
|
+
steeringInputPlaceholder: h.steeringInputPlaceholder,
|
|
3453
|
+
liveAguiAnchorMessageCodes: zt,
|
|
3454
|
+
liveAguiEvents: H,
|
|
3455
|
+
liveAguiPendingAnchorMessageCode: Vt,
|
|
3456
|
+
liveAguiPending: on,
|
|
3457
|
+
messages: _r,
|
|
3458
|
+
historyLoading: en,
|
|
3459
|
+
historyLoadingOlder: pt,
|
|
3460
|
+
historyLabels: h.historyLabels,
|
|
3461
|
+
onLoadOlderHistory: st ? () => {
|
|
3462
|
+
Ir();
|
|
3463
|
+
} : void 0,
|
|
3464
|
+
onCreateSession: O ?? Ur,
|
|
3465
|
+
onNewSession: ii,
|
|
3466
|
+
onDraftChange: nr,
|
|
3467
|
+
onPasteAttachment: he ?? Wr,
|
|
3468
|
+
onEditMessage: Mt || Q ? void 0 : $r,
|
|
3469
|
+
deleteTurnLabel: h.turnDeletionLabels?.action,
|
|
3470
|
+
onDeleteTurn: j.deleteTurn && P?.canDeleteTurns && !en && !Jt && !fn && !Mt && !Q && !P.activeRuns.length ? (e) => {
|
|
3471
|
+
Qr(e);
|
|
3472
|
+
} : void 0,
|
|
3473
|
+
onEditQueuedMessage: ei,
|
|
3474
|
+
onRemoveQueuedMessage: ti,
|
|
3475
|
+
onSteerQueuedMessage: (e) => {
|
|
3476
|
+
Xr(e);
|
|
3477
|
+
},
|
|
3478
|
+
onReorderQueuedMessage: ni,
|
|
3479
|
+
onSend: (e) => {
|
|
3480
|
+
Zr(e);
|
|
3481
|
+
},
|
|
3482
|
+
onStop: () => {
|
|
3483
|
+
ri();
|
|
3484
|
+
},
|
|
3485
|
+
protocolEvents: B,
|
|
3486
|
+
queueDisabled: Br || !!I,
|
|
3487
|
+
queuedMessages: gr,
|
|
3488
|
+
runningSubmitModes: mr,
|
|
3489
|
+
runningEnterSubmitMode: h.runningEnterSubmitMode,
|
|
3490
|
+
sendDisabled: zr || !!I,
|
|
3491
|
+
sending: sr,
|
|
3492
|
+
streamingAssistantMessageCode: Xt,
|
|
3493
|
+
session: M,
|
|
3494
|
+
showHistoryRail: Ae,
|
|
3495
|
+
showAgui: ir,
|
|
3496
|
+
showReasoningCards: h.showReasoningCards,
|
|
3497
|
+
showStop: hr,
|
|
3498
|
+
sidebarContent: Ne,
|
|
3499
|
+
steerDisabled: Vr || !!I,
|
|
3500
|
+
queuedSteerDisabled: Qt || !pr || !!I || Dt,
|
|
3501
|
+
state: Pe,
|
|
3502
|
+
storageKey: h.storageKey || "agent-ui.chat.runtime.window",
|
|
3503
|
+
title: w,
|
|
3504
|
+
titleSubtitle: ne,
|
|
3505
|
+
userInputLabels: h.userInputLabels,
|
|
3506
|
+
userInputRequests: Tt,
|
|
3507
|
+
locale: h.locale,
|
|
3508
|
+
workRailLabels: h.workRailLabels,
|
|
3509
|
+
userInputAnswerPending: Dt,
|
|
3510
|
+
userInputAnswerFailed: !!(kt && kt.sessionId === M?.sessionId && kt.requestId === I?.requestId),
|
|
3511
|
+
userInputRequest: I,
|
|
3512
|
+
onAnswerUserInput: Q ? void 0 : (e) => {
|
|
3513
|
+
qr(e);
|
|
3514
|
+
},
|
|
3515
|
+
onStateChange: Fe,
|
|
3516
|
+
a2uiSession: Je,
|
|
3517
|
+
a2uiDisabled: Jt || M?.status === "ARCHIVED",
|
|
3518
|
+
onA2UIAction: Kr,
|
|
3519
|
+
renderMarkdownLink: Le
|
|
3520
|
+
});
|
|
3521
|
+
}
|
|
3522
|
+
//#endregion
|
|
3523
|
+
export { Lt as AgentMotion, Vt as ChatA2UI, Bt as ChatGoalIndicator, On as ChatPanel, Pn as ChatRuntimeWindow, kn as ChatWindow, Rt as MotionProvider, Nt as useComposerDisabled, B as useMotion };
|