@meshagent/meshagent-tailwind 0.55.1 → 0.56.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/README.md +34 -3
- package/dist/cjs/chat/agent-thread.d.ts +42 -7
- package/dist/cjs/chat/agent-thread.js +422 -183
- package/dist/cjs/chat/chat-input-state.d.ts +2 -0
- package/dist/cjs/chat/chat-input-state.js +41 -0
- package/dist/cjs/chat/chat-input.d.ts +14 -2
- package/dist/cjs/chat/chat-input.js +41 -76
- package/dist/cjs/chat/chat-scroller.js +45 -43
- package/dist/cjs/chat/chat-thread-timeline.d.ts +2 -0
- package/dist/cjs/chat/chat-thread-timeline.js +83 -10
- package/dist/cjs/chat/composer-action-button.d.ts +11 -0
- package/dist/cjs/chat/composer-action-button.js +68 -0
- package/dist/cjs/chat/use-chat-virtualizer.d.ts +14 -17
- package/dist/cjs/chat/use-chat-virtualizer.js +288 -222
- package/dist/cjs/chat/virtualization.d.ts +0 -5
- package/dist/cjs/chat/virtualization.js +4 -6
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/esm/chat/agent-thread.d.ts +42 -7
- package/dist/esm/chat/agent-thread.js +424 -186
- package/dist/esm/chat/chat-input-state.d.ts +2 -0
- package/dist/esm/chat/chat-input-state.js +21 -0
- package/dist/esm/chat/chat-input.d.ts +14 -2
- package/dist/esm/chat/chat-input.js +41 -76
- package/dist/esm/chat/chat-scroller.js +46 -44
- package/dist/esm/chat/chat-thread-timeline.d.ts +2 -0
- package/dist/esm/chat/chat-thread-timeline.js +83 -10
- package/dist/esm/chat/composer-action-button.d.ts +11 -0
- package/dist/esm/chat/composer-action-button.js +48 -0
- package/dist/esm/chat/use-chat-virtualizer.d.ts +14 -17
- package/dist/esm/chat/use-chat-virtualizer.js +290 -226
- package/dist/esm/chat/virtualization.d.ts +0 -5
- package/dist/esm/chat/virtualization.js +4 -6
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/index.css +1 -1
- package/package.json +6 -5
|
@@ -32,6 +32,7 @@ __export(agent_thread_exports, {
|
|
|
32
32
|
AgentThreadFeed: () => AgentThreadFeed,
|
|
33
33
|
AgentThreadInput: () => AgentThreadInput,
|
|
34
34
|
AgentThreadProvider: () => AgentThreadProvider,
|
|
35
|
+
AgentThreadSubmitButton: () => AgentThreadSubmitButton,
|
|
35
36
|
AgentToolChoice: () => AgentToolChoice,
|
|
36
37
|
AgentUsageFooter: () => AgentUsageFooter,
|
|
37
38
|
AgentUsageSnapshot: () => import_chat_thread_timeline2.AgentUsageSnapshot,
|
|
@@ -42,7 +43,9 @@ __export(agent_thread_exports, {
|
|
|
42
43
|
formatAgentUsageFooter: () => formatAgentUsageFooter,
|
|
43
44
|
formatAgentUsageTokenCount: () => formatAgentUsageTokenCount,
|
|
44
45
|
formatAgentUsageTooltip: () => formatAgentUsageTooltip,
|
|
45
|
-
shouldReplaceAgentUsageSnapshot: () => import_chat_thread_timeline2.shouldReplaceAgentUsageSnapshot
|
|
46
|
+
shouldReplaceAgentUsageSnapshot: () => import_chat_thread_timeline2.shouldReplaceAgentUsageSnapshot,
|
|
47
|
+
useAgentThreadFeedState: () => useAgentThreadFeedState,
|
|
48
|
+
useAgentThreadStatus: () => useAgentThreadStatus
|
|
46
49
|
});
|
|
47
50
|
module.exports = __toCommonJS(agent_thread_exports);
|
|
48
51
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -61,7 +64,9 @@ var import_button = require("../components/ui/button.js");
|
|
|
61
64
|
var import_spinner = require("../components/ui/spinner.js");
|
|
62
65
|
var import_utils = require("../lib/utils.js");
|
|
63
66
|
var import_chat_input = require("./chat-input.js");
|
|
67
|
+
var import_chat_input_state = require("./chat-input-state.js");
|
|
64
68
|
var import_chat_message = require("./chat-message.js");
|
|
69
|
+
var import_composer_action_button = require("./composer-action-button.js");
|
|
65
70
|
var import_chat_scroller = require("./chat-scroller.js");
|
|
66
71
|
var import_chat_typing_indicator = require("./chat-typing-indicator.js");
|
|
67
72
|
var import_file_attachment = require("./file-attachment.js");
|
|
@@ -85,9 +90,7 @@ function stringValue(value) {
|
|
|
85
90
|
}
|
|
86
91
|
function mergeAgentMessageEvents(persistedEvents, liveEvents) {
|
|
87
92
|
const merged = [...persistedEvents];
|
|
88
|
-
const indexByMessageId = new Map(
|
|
89
|
-
merged.map((event, index) => [event.message.messageId, index])
|
|
90
|
-
);
|
|
93
|
+
const indexByMessageId = new Map(merged.map((event, index) => [event.message.messageId, index]));
|
|
91
94
|
for (const event of liveEvents) {
|
|
92
95
|
const existingIndex = indexByMessageId.get(event.message.messageId);
|
|
93
96
|
if (existingIndex === void 0) {
|
|
@@ -132,7 +135,9 @@ function timeAgo(date) {
|
|
|
132
135
|
}
|
|
133
136
|
function isShellTool(message) {
|
|
134
137
|
const values = [message.toolkit, message.tool].filter((value) => typeof value === "string").map((value) => value.trim().toLowerCase());
|
|
135
|
-
return values.some(
|
|
138
|
+
return values.some(
|
|
139
|
+
(value) => value === "shell" || value === "exec" || value === "local_shell" || value === "local_shell_call" || value.includes("shell") || value.includes("exec")
|
|
140
|
+
);
|
|
136
141
|
}
|
|
137
142
|
function canCollapseAsCommentary(message) {
|
|
138
143
|
if (message.phase === "final_answer") {
|
|
@@ -249,7 +254,10 @@ function formatAgentUsageTooltip(usage) {
|
|
|
249
254
|
}
|
|
250
255
|
return lines.join("\n");
|
|
251
256
|
}
|
|
252
|
-
function AgentUsageFooter({
|
|
257
|
+
function AgentUsageFooter({
|
|
258
|
+
usage,
|
|
259
|
+
className
|
|
260
|
+
}) {
|
|
253
261
|
const tooltip = usage === null ? void 0 : formatAgentUsageTooltip(usage);
|
|
254
262
|
const label = usage === null ? "" : formatAgentUsageFooter(usage);
|
|
255
263
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -310,10 +318,16 @@ function ChatBubble({ text, mine }) {
|
|
|
310
318
|
if (text.trim() === "") {
|
|
311
319
|
return null;
|
|
312
320
|
}
|
|
313
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
314
|
-
"
|
|
315
|
-
|
|
316
|
-
|
|
321
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
322
|
+
"div",
|
|
323
|
+
{
|
|
324
|
+
className: (0, import_utils.cn)(
|
|
325
|
+
"w-fit max-w-[85%] rounded-md px-4 py-3 text-sm leading-6 shadow-xs sm:max-w-2xl",
|
|
326
|
+
mine ? "bg-secondary/85 text-foreground" : "bg-muted/70 text-foreground"
|
|
327
|
+
),
|
|
328
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MarkdownBlock, { text })
|
|
329
|
+
}
|
|
330
|
+
);
|
|
317
331
|
}
|
|
318
332
|
function ReasoningTrace({ text, className }) {
|
|
319
333
|
if (text.trim() === "") {
|
|
@@ -327,7 +341,16 @@ function trimShellText(value) {
|
|
|
327
341
|
}
|
|
328
342
|
return value.length < 1024 ? value : value.slice(0, 1024) + "...";
|
|
329
343
|
}
|
|
330
|
-
function ShellLine({
|
|
344
|
+
function ShellLine({
|
|
345
|
+
command,
|
|
346
|
+
result,
|
|
347
|
+
stdout,
|
|
348
|
+
stderr,
|
|
349
|
+
argumentsText,
|
|
350
|
+
logs,
|
|
351
|
+
title = "Terminal",
|
|
352
|
+
className
|
|
353
|
+
}) {
|
|
331
354
|
const displayCommand = command?.trim() || title;
|
|
332
355
|
const [expanded, setExpanded] = (0, import_react.useState)(title.toLowerCase().includes("error"));
|
|
333
356
|
const trimmedResult = trimShellText(result);
|
|
@@ -353,7 +376,16 @@ function ShellLine({ command, result, stdout, stderr, argumentsText, logs, title
|
|
|
353
376
|
children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.ChevronDown, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.ChevronRight, { className: "h-4 w-4" })
|
|
354
377
|
}
|
|
355
378
|
),
|
|
356
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
379
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
380
|
+
"pre",
|
|
381
|
+
{
|
|
382
|
+
className: (0, import_utils.cn)(
|
|
383
|
+
"min-w-0 flex-1 overflow-hidden whitespace-pre-wrap break-words font-mono text-xs leading-5 text-foreground",
|
|
384
|
+
expanded ? null : "line-clamp-1"
|
|
385
|
+
),
|
|
386
|
+
children: displayCommand
|
|
387
|
+
}
|
|
388
|
+
)
|
|
357
389
|
] }),
|
|
358
390
|
expanded && hasDetails ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-2 border-t px-4 py-3", children: [
|
|
359
391
|
trimmedResult != null ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", { className: "whitespace-pre-wrap break-words font-mono text-xs leading-5 text-foreground", children: trimmedResult }) : null,
|
|
@@ -384,7 +416,13 @@ function eventLineDetails(details) {
|
|
|
384
416
|
const lines = typeof details === "string" ? details.split(/\r?\n/) : details;
|
|
385
417
|
return lines.map((line) => line.trim()).filter((line) => line !== "");
|
|
386
418
|
}
|
|
387
|
-
function EventLine({
|
|
419
|
+
function EventLine({
|
|
420
|
+
headline,
|
|
421
|
+
details,
|
|
422
|
+
state = "info",
|
|
423
|
+
failed = false,
|
|
424
|
+
className
|
|
425
|
+
}) {
|
|
388
426
|
const normalizedHeadline = headline.trim();
|
|
389
427
|
const detailLines = eventLineDetails(details);
|
|
390
428
|
if (normalizedHeadline === "") {
|
|
@@ -420,7 +458,14 @@ function ToolCallLine({ message }) {
|
|
|
420
458
|
const [expanded, setExpanded] = (0, import_react.useState)(message.failed === true);
|
|
421
459
|
const hasDetails = detailLines.length > 0;
|
|
422
460
|
if (!hasDetails) {
|
|
423
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
461
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
462
|
+
EventLine,
|
|
463
|
+
{
|
|
464
|
+
headline: message.text,
|
|
465
|
+
state: message.state ?? (message.failed === true ? "failed" : "completed"),
|
|
466
|
+
failed: message.failed
|
|
467
|
+
}
|
|
468
|
+
);
|
|
424
469
|
}
|
|
425
470
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ml-1.5 max-w-[85%] overflow-hidden rounded-md border bg-background text-sm sm:max-w-2xl", children: [
|
|
426
471
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
@@ -433,11 +478,30 @@ function ToolCallLine({ message }) {
|
|
|
433
478
|
"aria-label": expanded ? "Collapse tool details" : "Expand tool details",
|
|
434
479
|
children: [
|
|
435
480
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "mt-0.5 inline-flex h-5 w-5 shrink-0 items-center justify-center text-muted-foreground", children: expanded ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.ChevronDown, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_lucide_react.ChevronRight, { className: "h-4 w-4" }) }),
|
|
436
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
481
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
482
|
+
"span",
|
|
483
|
+
{
|
|
484
|
+
className: (0, import_utils.cn)(
|
|
485
|
+
"min-w-0 flex-1 text-xs font-semibold leading-5",
|
|
486
|
+
eventLineStateClass(message.state, message.failed)
|
|
487
|
+
),
|
|
488
|
+
children: message.text
|
|
489
|
+
}
|
|
490
|
+
)
|
|
437
491
|
]
|
|
438
492
|
}
|
|
439
493
|
),
|
|
440
|
-
expanded ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "space-y-2 border-t px-4 py-3", children: detailLines.map((line, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
494
|
+
expanded ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "space-y-2 border-t px-4 py-3", children: detailLines.map((line, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
495
|
+
"pre",
|
|
496
|
+
{
|
|
497
|
+
className: (0, import_utils.cn)(
|
|
498
|
+
"whitespace-pre-wrap break-words font-mono text-xs leading-5",
|
|
499
|
+
message.failed === true ? "text-destructive" : "text-muted-foreground"
|
|
500
|
+
),
|
|
501
|
+
children: trimShellText(line)
|
|
502
|
+
},
|
|
503
|
+
index
|
|
504
|
+
)) }) : null
|
|
441
505
|
] });
|
|
442
506
|
}
|
|
443
507
|
function AttachmentView({ room, path }) {
|
|
@@ -445,7 +509,9 @@ function AttachmentView({ room, path }) {
|
|
|
445
509
|
}
|
|
446
510
|
function ChatImageAttachment({ room, path }) {
|
|
447
511
|
const imagePath = attachmentImagePath(path) ?? path;
|
|
448
|
-
const [url, setUrl] = (0, import_react.useState)(
|
|
512
|
+
const [url, setUrl] = (0, import_react.useState)(
|
|
513
|
+
() => isInlineImageUrl(imagePath) || isHttpUrl(imagePath) ? imagePath : null
|
|
514
|
+
);
|
|
449
515
|
const [error, setError] = (0, import_react.useState)(null);
|
|
450
516
|
(0, import_react.useEffect)(() => {
|
|
451
517
|
let cancelled = false;
|
|
@@ -489,14 +555,21 @@ function ChatImageAttachment({ room, path }) {
|
|
|
489
555
|
}
|
|
490
556
|
);
|
|
491
557
|
}
|
|
492
|
-
function AttachmentDownloadButton({
|
|
558
|
+
function AttachmentDownloadButton({
|
|
559
|
+
room,
|
|
560
|
+
path,
|
|
561
|
+
className
|
|
562
|
+
}) {
|
|
493
563
|
const preview = normalizeAttachmentPath(path);
|
|
494
564
|
const filename = (0, import_file_preview.filePreviewName)(preview);
|
|
495
565
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
496
566
|
"button",
|
|
497
567
|
{
|
|
498
568
|
type: "button",
|
|
499
|
-
className: (0, import_utils.cn)(
|
|
569
|
+
className: (0, import_utils.cn)(
|
|
570
|
+
"inline-flex max-w-full items-center gap-2 rounded-md bg-muted/60 px-3 py-2 text-left shadow-xs transition-colors hover:bg-muted/80",
|
|
571
|
+
className
|
|
572
|
+
),
|
|
500
573
|
onClick: () => {
|
|
501
574
|
if (isInlineImageUrl(path) || isHttpUrl(path)) {
|
|
502
575
|
window.open(path, "_blank", "noopener,noreferrer");
|
|
@@ -518,7 +591,16 @@ function AttachmentDownloadButton({ room, path, className }) {
|
|
|
518
591
|
function ChatThreadPreview({ room, path, className }) {
|
|
519
592
|
const normalizedPath = normalizeAttachmentPath(path);
|
|
520
593
|
if (attachmentImagePath(path) != null) {
|
|
521
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
594
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
595
|
+
"div",
|
|
596
|
+
{
|
|
597
|
+
className: (0, import_utils.cn)(
|
|
598
|
+
"h-[312.5px] w-[312.5px] max-w-full overflow-hidden rounded-2xl bg-background",
|
|
599
|
+
className
|
|
600
|
+
),
|
|
601
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChatImageAttachment, { room, path })
|
|
602
|
+
}
|
|
603
|
+
);
|
|
522
604
|
}
|
|
523
605
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AttachmentDownloadButton, { room, path: normalizedPath, className });
|
|
524
606
|
}
|
|
@@ -614,12 +696,37 @@ function ThreadMessageView({
|
|
|
614
696
|
const previousAuthor = previous?.authorName ?? (previous?.role === "user" ? localParticipantName : displayParticipantName(agentName));
|
|
615
697
|
const shouldShowHeader = !forceHideHeader && (previous?.kind !== "message" || previousAuthor !== authorName);
|
|
616
698
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex flex-col gap-2", children: [
|
|
617
|
-
shouldShowHeader ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_utils.cn)("flex w-full", mine ? "justify-end" : "justify-start"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_utils.cn)("max-w-[85%] px-1 sm:max-w-2xl", mine ? "text-right" : "text-left"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
699
|
+
shouldShowHeader ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_utils.cn)("flex w-full", mine ? "justify-end" : "justify-start"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_utils.cn)("max-w-[85%] px-1 sm:max-w-2xl", mine ? "text-right" : "text-left"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
700
|
+
"div",
|
|
701
|
+
{
|
|
702
|
+
className: (0, import_utils.cn)(
|
|
703
|
+
"flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",
|
|
704
|
+
mine ? "justify-end" : "justify-start"
|
|
705
|
+
),
|
|
706
|
+
children: [
|
|
707
|
+
authorName.trim() !== "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "font-semibold text-foreground", children: displayParticipantName(authorName) }) : null,
|
|
708
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: timeAgo(message.createdAt) })
|
|
709
|
+
]
|
|
710
|
+
}
|
|
711
|
+
) }) }) : null,
|
|
621
712
|
message.text.trim() !== "" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_utils.cn)("flex w-full", mine ? "justify-end" : "justify-start"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ChatBubble, { text: message.text, mine }) }) : null,
|
|
622
|
-
message.attachments.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_utils.cn)("flex w-full", mine ? "justify-end" : "justify-start"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
713
|
+
message.attachments.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: (0, import_utils.cn)("flex w-full", mine ? "justify-end" : "justify-start"), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
714
|
+
"div",
|
|
715
|
+
{
|
|
716
|
+
className: (0, import_utils.cn)(
|
|
717
|
+
"flex max-w-[85%] flex-wrap gap-3 px-1 sm:max-w-2xl",
|
|
718
|
+
mine ? "justify-end" : "justify-start"
|
|
719
|
+
),
|
|
720
|
+
children: message.attachments.map((attachment, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
721
|
+
AttachmentView,
|
|
722
|
+
{
|
|
723
|
+
room,
|
|
724
|
+
path: attachment
|
|
725
|
+
},
|
|
726
|
+
`${message.id}:attachment:${attachment}:${index}`
|
|
727
|
+
))
|
|
728
|
+
}
|
|
729
|
+
) }) : null,
|
|
623
730
|
message.image ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex w-full justify-start", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(GeneratedImageView, { image: message.image }) }) : null
|
|
624
731
|
] });
|
|
625
732
|
}
|
|
@@ -632,10 +739,7 @@ function EmptyState({ title, description }) {
|
|
|
632
739
|
function LoadingState() {
|
|
633
740
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "h-full mx-auto flex max-w-2xl flex-col items-center justify-center px-6 py-20 text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_spinner.Spinner, { size: "lg" }) });
|
|
634
741
|
}
|
|
635
|
-
function ErrorBanner({
|
|
636
|
-
message,
|
|
637
|
-
onRetry
|
|
638
|
-
}) {
|
|
742
|
+
function ErrorBanner({ message, onRetry }) {
|
|
639
743
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mx-auto flex w-full max-w-[912px] items-center justify-between gap-3 whitespace-pre-wrap rounded-md border border-destructive/30 bg-destructive/5 px-4 py-3 text-sm text-destructive", children: [
|
|
640
744
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: message }),
|
|
641
745
|
onRetry ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { type: "button", variant: "outline", size: "sm", onClick: onRetry, children: "Retry restore" }) : null
|
|
@@ -691,7 +795,9 @@ function processClientToolRequests({
|
|
|
691
795
|
if (toolsByName.size === 0) {
|
|
692
796
|
return;
|
|
693
797
|
}
|
|
694
|
-
const requests = session.messages.map((event) => event.message).filter(
|
|
798
|
+
const requests = session.messages.map((event) => event.message).filter(
|
|
799
|
+
(message) => message instanceof import_meshagent_agents.AgentClientToolCallRequested
|
|
800
|
+
).filter((message) => message.toolkit === "client" && toolsByName.has(message.tool));
|
|
695
801
|
const handledRequests = handledRequestsForSession(session);
|
|
696
802
|
if (!initializedClientToolSessions.has(session)) {
|
|
697
803
|
initializedClientToolSessions.add(session);
|
|
@@ -707,9 +813,11 @@ function processClientToolRequests({
|
|
|
707
813
|
return;
|
|
708
814
|
}
|
|
709
815
|
replayingClientToolSessions.delete(session);
|
|
710
|
-
const
|
|
816
|
+
const completedRequestIds = new Set(
|
|
817
|
+
(0, import_chat_thread_timeline.buildChatThreadTimeline)(session.messages).items.filter((item) => item.kind === "tool_call" && item.toolkit === "client" && (item.state === "completed" || item.state === "failed")).map((item) => item.clientToolRequestId ?? item.id)
|
|
818
|
+
);
|
|
711
819
|
for (const request of requests) {
|
|
712
|
-
if (
|
|
820
|
+
if (completedRequestIds.has(request.requestId)) {
|
|
713
821
|
handledRequests.add(request.requestId);
|
|
714
822
|
}
|
|
715
823
|
}
|
|
@@ -783,14 +891,20 @@ function AgentThreadProvider({
|
|
|
783
891
|
closeThreadOnUnmount = false,
|
|
784
892
|
onPersistedEventsInjectionStarted,
|
|
785
893
|
onPersistedEventsInjected,
|
|
786
|
-
onEventsChanged
|
|
894
|
+
onEventsChanged,
|
|
895
|
+
onSubmissionStarted,
|
|
896
|
+
onSubmissionFailed
|
|
787
897
|
}) {
|
|
788
898
|
const [attachments, setAttachments] = (0, import_react.useState)([]);
|
|
899
|
+
const [composerValue, setComposerValue] = (0, import_react.useState)("");
|
|
789
900
|
const [sendError, setSendError] = (0, import_react.useState)(null);
|
|
790
901
|
const [restorationError, setRestorationError] = (0, import_react.useState)(null);
|
|
791
902
|
const [restorationAttempt, setRestorationAttempt] = (0, import_react.useState)(0);
|
|
792
903
|
const [version, setVersion] = (0, import_react.useState)(0);
|
|
793
|
-
const [clientToolCallOverrides, setClientToolCallOverrides] = (0, import_react.useState)(
|
|
904
|
+
const [clientToolCallOverrides, setClientToolCallOverrides] = (0, import_react.useState)(
|
|
905
|
+
() => /* @__PURE__ */ new Map()
|
|
906
|
+
);
|
|
907
|
+
const attachmentStatusVersion = (0, import_chat_input_state.useAttachmentStatusVersion)(attachments);
|
|
794
908
|
const sessionRef = (0, import_react.useRef)(null);
|
|
795
909
|
const mountedRef = (0, import_react.useRef)(true);
|
|
796
910
|
const persistedEventsRef = (0, import_react.useRef)(persistedEvents);
|
|
@@ -799,14 +913,11 @@ function AgentThreadProvider({
|
|
|
799
913
|
const restorationReadyRef = (0, import_react.useRef)(!injectPersistedEvents);
|
|
800
914
|
const pendingCloseRef = (0, import_react.useRef)(null);
|
|
801
915
|
const ownsChatClient = chatClient == null;
|
|
802
|
-
const activeChatClient = (0, import_react.useMemo)(
|
|
803
|
-
()
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
},
|
|
808
|
-
[agentName, chatClient, room]
|
|
809
|
-
);
|
|
916
|
+
const activeChatClient = (0, import_react.useMemo)(() => {
|
|
917
|
+
if (chatClient != null) return chatClient;
|
|
918
|
+
if (room != null) return new import_meshagent_agents.MessagingChatClient({ room, agentName });
|
|
919
|
+
throw new Error("AgentThread requires either a room or a chat client.");
|
|
920
|
+
}, [agentName, chatClient, room]);
|
|
810
921
|
const resolvedClientToolkits = (0, import_react.useMemo)(
|
|
811
922
|
() => (0, import_chat_feed_widget.resolveClientToolkitDescriptions)(clientToolkits, chatFeedWidgets, clientTools),
|
|
812
923
|
[chatFeedWidgets, clientToolkits, clientTools]
|
|
@@ -893,7 +1004,9 @@ function AgentThreadProvider({
|
|
|
893
1004
|
return;
|
|
894
1005
|
}
|
|
895
1006
|
restorationReadyRef.current = false;
|
|
896
|
-
setRestorationError(
|
|
1007
|
+
setRestorationError(
|
|
1008
|
+
"Unable to restore conversation context: the server thread did not finish loading within 30 seconds."
|
|
1009
|
+
);
|
|
897
1010
|
setVersion((current) => current + 1);
|
|
898
1011
|
}, threadLoadTimeoutMs);
|
|
899
1012
|
}
|
|
@@ -1061,24 +1174,32 @@ function AgentThreadProvider({
|
|
|
1061
1174
|
}
|
|
1062
1175
|
return persistedEvents == null ? (0, import_chat_thread_timeline.buildChatThreadTimeline)(session.messages, session.pendingInputs) : (0, import_chat_thread_timeline.buildMergedChatThreadTimeline)(persistedEvents, session.messages, session.pendingInputs);
|
|
1063
1176
|
}, [deferLiveEvents, persistedEvents, session, version]);
|
|
1064
|
-
const timelineItems = (0, import_react.useMemo)(
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1177
|
+
const timelineItems = (0, import_react.useMemo)(
|
|
1178
|
+
() => (timeline?.items ?? []).map((item) => {
|
|
1179
|
+
const override = session == null ? void 0 : clientToolCallOverrides.get(clientToolCallKey(session.threadPath, item.clientToolRequestId ?? item.id));
|
|
1180
|
+
if (override == null || item.kind !== "tool_call" || item.state === "completed" || item.state === "failed") {
|
|
1181
|
+
return item;
|
|
1182
|
+
}
|
|
1183
|
+
return {
|
|
1184
|
+
...item,
|
|
1185
|
+
state: override.status,
|
|
1186
|
+
failed: override.status === "failed",
|
|
1187
|
+
output: override.output ?? item.output
|
|
1188
|
+
};
|
|
1189
|
+
}),
|
|
1190
|
+
[clientToolCallOverrides, session, timeline]
|
|
1191
|
+
);
|
|
1076
1192
|
const showThreadLoading = (deferLiveEvents || session === null || session.isLoading) && timelineItems.length === 0;
|
|
1077
1193
|
const feedTimelineItems = (0, import_react.useMemo)(
|
|
1078
|
-
() => timelineItems.filter(
|
|
1194
|
+
() => timelineItems.filter(
|
|
1195
|
+
(item) => !(item.kind === "tool_call" && item.toolkit === "client" && item.tool != null && clientToolsByName.has(item.tool))
|
|
1196
|
+
),
|
|
1079
1197
|
[clientToolsByName, timelineItems]
|
|
1080
1198
|
);
|
|
1081
|
-
const renderedItems = (0, import_react.useMemo)(
|
|
1199
|
+
const renderedItems = (0, import_react.useMemo)(
|
|
1200
|
+
() => collapseMessages ? groupThreadItems(feedTimelineItems, chatFeedWidgetsByName) : feedTimelineItems,
|
|
1201
|
+
[chatFeedWidgetsByName, collapseMessages, feedTimelineItems]
|
|
1202
|
+
);
|
|
1082
1203
|
const status = (0, import_react.useMemo)(() => {
|
|
1083
1204
|
if (session == null) return null;
|
|
1084
1205
|
let current = null;
|
|
@@ -1099,7 +1220,19 @@ function AgentThreadProvider({
|
|
|
1099
1220
|
const usage = timeline?.usage ?? null;
|
|
1100
1221
|
const statusText = status?.status?.trim() || null;
|
|
1101
1222
|
const turnId = stringValue(status?.turnId);
|
|
1102
|
-
const
|
|
1223
|
+
const interruptibleTurnId = (0, import_react.useMemo)(() => {
|
|
1224
|
+
let active = null;
|
|
1225
|
+
for (const event of session?.messages ?? []) {
|
|
1226
|
+
if (event.message instanceof import_meshagent_agents.TurnStarted) {
|
|
1227
|
+
active = event.message.turnId;
|
|
1228
|
+
}
|
|
1229
|
+
if (event.message instanceof import_meshagent_agents.TurnEnded && event.message.turnId === active) {
|
|
1230
|
+
active = null;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
return active ?? turnId;
|
|
1234
|
+
}, [session, version, turnId]);
|
|
1235
|
+
const canInterruptActiveTurn = interruptibleTurnId != null && (agentParticipant != null || chatClient != null);
|
|
1103
1236
|
const renderedItemsNewestFirst = (0, import_react.useMemo)(() => [...renderedItems].reverse(), [renderedItems]);
|
|
1104
1237
|
const firstRenderedItemId = renderedItems[0]?.id;
|
|
1105
1238
|
const lastRenderedItemId = renderedItems[renderedItems.length - 1]?.id;
|
|
@@ -1110,94 +1243,149 @@ function AgentThreadProvider({
|
|
|
1110
1243
|
});
|
|
1111
1244
|
return previousById;
|
|
1112
1245
|
}, [renderedItems]);
|
|
1113
|
-
const selectAttachments = (0, import_react.useCallback)(
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
const handleSend = (0, import_react.useCallback)(
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1246
|
+
const selectAttachments = (0, import_react.useCallback)(
|
|
1247
|
+
(files) => {
|
|
1248
|
+
if (room == null) return;
|
|
1249
|
+
const nextAttachments = files.map(
|
|
1250
|
+
(file) => new import_file_attachment.MeshagentFileUpload(room, `uploaded-files/${file.name}`, (0, import_file_attachment.fileToAsyncIterable)(file), file.size)
|
|
1251
|
+
);
|
|
1252
|
+
setAttachments((current) => [...current, ...nextAttachments]);
|
|
1253
|
+
},
|
|
1254
|
+
[room]
|
|
1255
|
+
);
|
|
1256
|
+
const handleSend = (0, import_react.useCallback)(
|
|
1257
|
+
async (message) => {
|
|
1258
|
+
if (message.text.trim() === "" && message.attachments.length === 0) {
|
|
1259
|
+
return;
|
|
1260
|
+
}
|
|
1261
|
+
if (!agentParticipant && chatClient == null) {
|
|
1262
|
+
setSendError("This thread requires an online agent that supports agent messages.");
|
|
1263
|
+
return;
|
|
1264
|
+
}
|
|
1265
|
+
const openSession = sessionRef.current;
|
|
1266
|
+
if (openSession === null) {
|
|
1267
|
+
setSendError("No thread session is open.");
|
|
1268
|
+
return;
|
|
1269
|
+
}
|
|
1270
|
+
const normalizedAttachments = message.attachments.map(normalizeAgentAttachmentUrl).filter((attachment) => attachment !== null);
|
|
1271
|
+
const steeringTurnId = status?.mode === "steerable" && turnId != null ? turnId : void 0;
|
|
1272
|
+
onSubmissionStarted?.(message, steeringTurnId);
|
|
1273
|
+
try {
|
|
1274
|
+
await openSession.sendText({
|
|
1275
|
+
messageId: message.id,
|
|
1276
|
+
text: message.text,
|
|
1277
|
+
attachments: normalizedAttachments.map((url) => new import_meshagent_agents.AgentFileContent({ url })),
|
|
1278
|
+
turnId,
|
|
1279
|
+
steer: status?.mode === "steerable" && turnId != null,
|
|
1280
|
+
senderName: localParticipantName.trim() || void 0,
|
|
1281
|
+
clientToolkits: resolvedClientToolkits
|
|
1282
|
+
});
|
|
1283
|
+
setSendError(null);
|
|
1284
|
+
setVersion((current) => current + 1);
|
|
1285
|
+
} catch (error) {
|
|
1286
|
+
onSubmissionFailed?.(message, error);
|
|
1287
|
+
setSendError(describeError(error));
|
|
1288
|
+
}
|
|
1289
|
+
},
|
|
1290
|
+
[
|
|
1291
|
+
agentParticipant,
|
|
1292
|
+
chatClient,
|
|
1293
|
+
resolvedClientToolkits,
|
|
1294
|
+
localParticipantName,
|
|
1295
|
+
status?.mode,
|
|
1296
|
+
turnId,
|
|
1297
|
+
onSubmissionStarted,
|
|
1298
|
+
onSubmissionFailed
|
|
1299
|
+
]
|
|
1300
|
+
);
|
|
1153
1301
|
const composerDisabled = composerDisabledProp || loadThread && !restorationReadyRef.current || injectPersistedEvents && restoredPathRef.current !== path || agentParticipant == null && chatClient == null;
|
|
1154
|
-
const
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1302
|
+
const allAttachmentsUploaded = (0, import_react.useMemo)(
|
|
1303
|
+
() => attachments.every((attachment) => attachment.status === import_file_attachment.UploadStatus.Completed),
|
|
1304
|
+
[attachmentStatusVersion, attachments]
|
|
1305
|
+
);
|
|
1306
|
+
const canSubmit = !composerDisabled && (composerValue.trim() !== "" || attachments.length > 0) && allAttachmentsUploaded;
|
|
1307
|
+
const handleComposerSubmit = (0, import_react.useCallback)(
|
|
1308
|
+
(message) => {
|
|
1309
|
+
if (!canSubmit) {
|
|
1310
|
+
return;
|
|
1311
|
+
}
|
|
1312
|
+
void handleSend(message);
|
|
1313
|
+
setComposerValue("");
|
|
1314
|
+
setAttachments([]);
|
|
1315
|
+
},
|
|
1316
|
+
[canSubmit, handleSend]
|
|
1317
|
+
);
|
|
1318
|
+
const submitDraft = (0, import_react.useCallback)(() => {
|
|
1319
|
+
handleComposerSubmit(
|
|
1320
|
+
new import_chat_message.ChatMessage({
|
|
1321
|
+
id: (0, import_uuid.v4)(),
|
|
1322
|
+
text: composerValue.trim(),
|
|
1323
|
+
attachments: attachments.map((attachment) => attachment.path)
|
|
1324
|
+
})
|
|
1325
|
+
);
|
|
1326
|
+
}, [attachments, composerValue, handleComposerSubmit]);
|
|
1327
|
+
const handleWidgetMessage = (0, import_react.useCallback)(
|
|
1328
|
+
(message) => {
|
|
1329
|
+
const text = message.trim();
|
|
1330
|
+
if (text === "" || composerDisabled) {
|
|
1331
|
+
return;
|
|
1332
|
+
}
|
|
1333
|
+
void handleSend(
|
|
1334
|
+
new import_chat_message.ChatMessage({
|
|
1335
|
+
id: (0, import_uuid.v4)(),
|
|
1336
|
+
text
|
|
1337
|
+
})
|
|
1338
|
+
);
|
|
1339
|
+
},
|
|
1340
|
+
[composerDisabled, handleSend]
|
|
1341
|
+
);
|
|
1164
1342
|
const cancelTurn = (0, import_react.useCallback)(async () => {
|
|
1165
1343
|
const openSession = sessionRef.current;
|
|
1166
|
-
if (openSession === null ||
|
|
1344
|
+
if (openSession === null || interruptibleTurnId == null) {
|
|
1167
1345
|
return;
|
|
1168
1346
|
}
|
|
1169
|
-
await openSession.interruptTurn(
|
|
1170
|
-
}, [
|
|
1171
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1347
|
+
await openSession.interruptTurn(interruptibleTurnId);
|
|
1348
|
+
}, [interruptibleTurnId]);
|
|
1349
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1350
|
+
AgentThreadContext.Provider,
|
|
1351
|
+
{
|
|
1352
|
+
value: {
|
|
1353
|
+
room,
|
|
1354
|
+
agentName,
|
|
1355
|
+
emptyStateTitle,
|
|
1356
|
+
emptyStateDescription,
|
|
1357
|
+
chatFeedWidgetsByName,
|
|
1358
|
+
timelineItems,
|
|
1359
|
+
renderedItemsNewestFirst,
|
|
1360
|
+
firstRenderedItemId,
|
|
1361
|
+
lastRenderedItemId,
|
|
1362
|
+
previousItemById,
|
|
1363
|
+
showThreadLoading,
|
|
1364
|
+
localParticipantName,
|
|
1365
|
+
status,
|
|
1366
|
+
statusText,
|
|
1367
|
+
canInterruptActiveTurn,
|
|
1368
|
+
restorationError,
|
|
1369
|
+
retryRestoration,
|
|
1370
|
+
handleWidgetMessage,
|
|
1371
|
+
cancelTurn,
|
|
1372
|
+
sendError,
|
|
1373
|
+
composerDisabled,
|
|
1374
|
+
composerValue,
|
|
1375
|
+
setComposerValue,
|
|
1376
|
+
canSubmit,
|
|
1377
|
+
handleComposerSubmit,
|
|
1378
|
+
submitDraft,
|
|
1379
|
+
attachments,
|
|
1380
|
+
setAttachments,
|
|
1381
|
+
selectAttachments,
|
|
1382
|
+
enableFileUpload: enableFileUpload && room != null,
|
|
1383
|
+
inputAvailable: agentParticipant != null || chatClient != null,
|
|
1384
|
+
usage
|
|
1385
|
+
},
|
|
1386
|
+
children
|
|
1387
|
+
}
|
|
1388
|
+
);
|
|
1201
1389
|
}
|
|
1202
1390
|
function useAgentThreadContext(componentName) {
|
|
1203
1391
|
const context = (0, import_react.useContext)(AgentThreadContext);
|
|
@@ -1206,14 +1394,25 @@ function useAgentThreadContext(componentName) {
|
|
|
1206
1394
|
}
|
|
1207
1395
|
return context;
|
|
1208
1396
|
}
|
|
1209
|
-
function
|
|
1397
|
+
function useAgentThreadFeedState() {
|
|
1398
|
+
const { renderedItemsNewestFirst } = useAgentThreadContext("useAgentThreadFeedState");
|
|
1399
|
+
return (0, import_react.useMemo)(() => ({ items: [...renderedItemsNewestFirst].reverse() }), [renderedItemsNewestFirst]);
|
|
1400
|
+
}
|
|
1401
|
+
function useAgentThreadStatus() {
|
|
1402
|
+
const { canInterruptActiveTurn, cancelTurn } = useAgentThreadContext("useAgentThreadStatus");
|
|
1403
|
+
return { canInterrupt: canInterruptActiveTurn, interrupt: cancelTurn };
|
|
1404
|
+
}
|
|
1405
|
+
function AgentThreadFeed({
|
|
1406
|
+
renderAfterItem,
|
|
1407
|
+
renderUnanchored,
|
|
1408
|
+
showStatusIndicator = true
|
|
1409
|
+
} = {}) {
|
|
1210
1410
|
const {
|
|
1211
1411
|
room,
|
|
1212
1412
|
agentName,
|
|
1213
1413
|
emptyStateTitle,
|
|
1214
1414
|
emptyStateDescription,
|
|
1215
1415
|
chatFeedWidgetsByName,
|
|
1216
|
-
timelineItems,
|
|
1217
1416
|
renderedItemsNewestFirst,
|
|
1218
1417
|
firstRenderedItemId,
|
|
1219
1418
|
lastRenderedItemId,
|
|
@@ -1228,9 +1427,11 @@ function AgentThreadFeed() {
|
|
|
1228
1427
|
handleWidgetMessage,
|
|
1229
1428
|
cancelTurn
|
|
1230
1429
|
} = useAgentThreadContext("AgentThreadFeed");
|
|
1430
|
+
const unanchoredContent = renderUnanchored?.();
|
|
1431
|
+
const hasUnanchoredContent = import_react.Children.toArray(unanchoredContent).length > 0;
|
|
1231
1432
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1232
1433
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "relative flex h-full min-h-0 flex-1 flex-col", children: [
|
|
1233
|
-
showThreadLoading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "min-h-0 flex-1 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingState, {}) }) :
|
|
1434
|
+
showThreadLoading ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "min-h-0 flex-1 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LoadingState, {}) }) : renderedItemsNewestFirst.length === 0 ? hasUnanchoredContent ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "min-h-0 flex-1 overflow-y-auto", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mx-auto w-full max-w-[912px] px-4 py-3", children: unanchoredContent }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "min-h-0 flex-1 overflow-hidden", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(EmptyState, { title: emptyStateTitle, description: emptyStateDescription }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1234
1435
|
import_chat_scroller.ChatScroller,
|
|
1235
1436
|
{
|
|
1236
1437
|
bottomThresholdPx: 24,
|
|
@@ -1239,26 +1440,36 @@ function AgentThreadFeed() {
|
|
|
1239
1440
|
getMessageAuthorId: (item) => item.role,
|
|
1240
1441
|
messages: renderedItemsNewestFirst,
|
|
1241
1442
|
renderMessage: (item) => {
|
|
1242
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.
|
|
1243
|
-
"
|
|
1244
|
-
item.id === firstRenderedItemId ? "pt-6" : null,
|
|
1245
|
-
item.id === lastRenderedItemId ? statusText ? "pb-24" : "pb-6" : null
|
|
1246
|
-
), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1247
|
-
ThreadMessageView,
|
|
1443
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1444
|
+
"div",
|
|
1248
1445
|
{
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1446
|
+
className: (0, import_utils.cn)(
|
|
1447
|
+
"mx-auto w-full max-w-[912px] px-1 py-3",
|
|
1448
|
+
item.id === firstRenderedItemId ? "pt-6" : null,
|
|
1449
|
+
item.id === lastRenderedItemId ? showStatusIndicator && statusText ? "pb-24" : "pb-6" : null
|
|
1450
|
+
),
|
|
1451
|
+
children: [
|
|
1452
|
+
item.id === firstRenderedItemId ? unanchoredContent : null,
|
|
1453
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1454
|
+
ThreadMessageView,
|
|
1455
|
+
{
|
|
1456
|
+
room,
|
|
1457
|
+
message: item,
|
|
1458
|
+
previous: previousItemById.get(item.id) ?? null,
|
|
1459
|
+
localParticipantName,
|
|
1460
|
+
agentName,
|
|
1461
|
+
chatFeedWidgetsByName,
|
|
1462
|
+
onSendMessage: handleWidgetMessage
|
|
1463
|
+
}
|
|
1464
|
+
),
|
|
1465
|
+
renderAfterItem?.(item)
|
|
1466
|
+
]
|
|
1256
1467
|
}
|
|
1257
|
-
)
|
|
1468
|
+
);
|
|
1258
1469
|
}
|
|
1259
1470
|
}
|
|
1260
1471
|
),
|
|
1261
|
-
statusText ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 flex justify-center px-4 pb-4", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pointer-events-auto w-full max-w-[912px]", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1472
|
+
showStatusIndicator && statusText ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pointer-events-none absolute inset-x-0 bottom-0 flex justify-center px-4 pb-4", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "pointer-events-auto w-full max-w-[912px]", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1262
1473
|
import_chat_typing_indicator.ChatTypingIndicator,
|
|
1263
1474
|
{
|
|
1264
1475
|
typing: false,
|
|
@@ -1273,21 +1484,24 @@ function AgentThreadFeed() {
|
|
|
1273
1484
|
}
|
|
1274
1485
|
) }) }) : null
|
|
1275
1486
|
] }),
|
|
1276
|
-
restorationError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "px-4 pb-2", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1277
|
-
ErrorBanner,
|
|
1278
|
-
{
|
|
1279
|
-
message: restorationError,
|
|
1280
|
-
onRetry: retryRestoration
|
|
1281
|
-
}
|
|
1282
|
-
) }) : null
|
|
1487
|
+
restorationError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "px-4 pb-2", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorBanner, { message: restorationError, onRetry: retryRestoration }) }) : null
|
|
1283
1488
|
] });
|
|
1284
1489
|
}
|
|
1285
|
-
function AgentThreadInput(
|
|
1490
|
+
function AgentThreadInput({
|
|
1491
|
+
className,
|
|
1492
|
+
inputRowClassName,
|
|
1493
|
+
textareaClassName,
|
|
1494
|
+
leadingButton,
|
|
1495
|
+
showSubmitButton = true,
|
|
1496
|
+
submitButtonComponent
|
|
1497
|
+
} = {}) {
|
|
1286
1498
|
const {
|
|
1287
1499
|
agentName,
|
|
1288
1500
|
sendError,
|
|
1289
1501
|
composerDisabled,
|
|
1290
|
-
|
|
1502
|
+
composerValue,
|
|
1503
|
+
setComposerValue,
|
|
1504
|
+
handleComposerSubmit,
|
|
1291
1505
|
attachments,
|
|
1292
1506
|
setAttachments,
|
|
1293
1507
|
selectAttachments,
|
|
@@ -1297,23 +1511,48 @@ function AgentThreadInput() {
|
|
|
1297
1511
|
} = useAgentThreadContext("AgentThreadInput");
|
|
1298
1512
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
1299
1513
|
sendError ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "px-4 pb-2", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorBanner, { message: sendError }) }) : null,
|
|
1300
|
-
/* @__PURE__ */ (0, import_jsx_runtime.
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1514
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1515
|
+
import_chat_input.ChatInput,
|
|
1516
|
+
{
|
|
1517
|
+
className,
|
|
1518
|
+
inputRowClassName,
|
|
1519
|
+
textareaClassName,
|
|
1520
|
+
leadingButton,
|
|
1521
|
+
onSubmit: handleComposerSubmit,
|
|
1522
|
+
attachments,
|
|
1523
|
+
onFilesSelected: selectAttachments,
|
|
1524
|
+
setAttachments,
|
|
1525
|
+
enableFileUpload,
|
|
1526
|
+
disabled: composerDisabled,
|
|
1527
|
+
clearOnSubmit: false,
|
|
1528
|
+
value: composerValue,
|
|
1529
|
+
onValueChange: setComposerValue,
|
|
1530
|
+
showSubmitButton,
|
|
1531
|
+
submitButtonComponent,
|
|
1532
|
+
placeholder: inputAvailable ? "Type a message" : `Waiting for ${displayParticipantName(agentName)}`
|
|
1533
|
+
}
|
|
1534
|
+
) })
|
|
1315
1535
|
] });
|
|
1316
1536
|
}
|
|
1537
|
+
function AgentThreadSubmitButton({
|
|
1538
|
+
className,
|
|
1539
|
+
icon,
|
|
1540
|
+
title,
|
|
1541
|
+
ariaLabel
|
|
1542
|
+
} = {}) {
|
|
1543
|
+
const { canSubmit, submitDraft } = useAgentThreadContext("AgentThreadSubmitButton");
|
|
1544
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1545
|
+
import_composer_action_button.ComposerActionButton,
|
|
1546
|
+
{
|
|
1547
|
+
className,
|
|
1548
|
+
disabled: !canSubmit,
|
|
1549
|
+
onClick: submitDraft,
|
|
1550
|
+
icon,
|
|
1551
|
+
title,
|
|
1552
|
+
ariaLabel
|
|
1553
|
+
}
|
|
1554
|
+
);
|
|
1555
|
+
}
|
|
1317
1556
|
function AgentThread(props) {
|
|
1318
1557
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgentThreadProvider, { ...props, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "flex h-full min-h-0 flex-1 flex-col", children: [
|
|
1319
1558
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(AgentThreadFeed, {}),
|