@invergent/agent-chat-react 1.4.13 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +85 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +86 -44
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { Collapsible as Collapsible$1, Slot, Dialog as Dialog$1, ScrollArea as S
|
|
|
4
4
|
import { clsx } from 'clsx';
|
|
5
5
|
import { twMerge } from 'tailwind-merge';
|
|
6
6
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
7
|
-
import { ChevronDownIcon, AlertTriangle, ChevronDown, ChevronRight, RefreshCw, ChevronRightIcon, GitBranchIcon, XIcon, ThumbsUpIcon, ThumbsDownIcon, ActivityIcon, Loader2Icon, ListTodoIcon, Code, CheckIcon, CopyIcon, TerminalIcon, Trash2Icon, CircleDotIcon, CircleCheckIcon, CircleXIcon, SkullIcon, ClockIcon,
|
|
7
|
+
import { ChevronDownIcon, AlertTriangle, ChevronDown, ChevronRight, RefreshCw, ChevronRightIcon, GitBranchIcon, XIcon, ThumbsUpIcon, ThumbsDownIcon, ActivityIcon, Loader2Icon, GlobeIcon, SearchIcon, ListTodoIcon, XCircleIcon, CheckCircle2Icon, Code, CheckIcon, CopyIcon, TerminalIcon, Trash2Icon, CircleDotIcon, CircleCheckIcon, CircleXIcon, SkullIcon, ClockIcon, CheckCircleIcon, CircleIcon, UsersIcon, MessageSquareIcon, FolderOpenIcon, UploadIcon, RefreshCwIcon, AlertCircleIcon, SquareIcon, ArrowDownIcon, DownloadIcon, TrashIcon, ImageIcon, FileTextIcon, Maximize2Icon, FolderIcon, FileIcon, PlusIcon, CornerDownLeftIcon } from 'lucide-react';
|
|
8
8
|
import { StickToBottom, useStickToBottomContext } from 'use-stick-to-bottom';
|
|
9
9
|
import { cjk } from '@streamdown/cjk';
|
|
10
10
|
import { code } from '@streamdown/code';
|
|
@@ -86,7 +86,7 @@ function Button({
|
|
|
86
86
|
var Conversation = ({ className, ...props }) => /* @__PURE__ */ jsx(
|
|
87
87
|
StickToBottom,
|
|
88
88
|
{
|
|
89
|
-
className: cn("relative flex-1 overflow-y-
|
|
89
|
+
className: cn("relative flex-1 overflow-y-auto", className),
|
|
90
90
|
initial: "smooth",
|
|
91
91
|
resize: "smooth",
|
|
92
92
|
role: "log",
|
|
@@ -99,7 +99,7 @@ var ConversationContent = ({
|
|
|
99
99
|
}) => /* @__PURE__ */ jsx(
|
|
100
100
|
StickToBottom.Content,
|
|
101
101
|
{
|
|
102
|
-
className: cn("flex flex-col gap-
|
|
102
|
+
className: cn("flex flex-col gap-6 py-6 px-6", className),
|
|
103
103
|
...props
|
|
104
104
|
}
|
|
105
105
|
);
|
|
@@ -114,15 +114,15 @@ var ConversationEmptyState = ({
|
|
|
114
114
|
"div",
|
|
115
115
|
{
|
|
116
116
|
className: cn(
|
|
117
|
-
"flex size-full flex-col items-center justify-center gap-
|
|
117
|
+
"flex size-full flex-col items-center justify-center gap-4 p-8 text-center",
|
|
118
118
|
className
|
|
119
119
|
),
|
|
120
120
|
...props,
|
|
121
121
|
children: children ?? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
122
|
-
icon && /* @__PURE__ */ jsx("div", { className: "text-muted-foreground", children: icon }),
|
|
123
|
-
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
124
|
-
/* @__PURE__ */ jsx("h3", { className: "font-
|
|
125
|
-
description && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", children: description })
|
|
122
|
+
icon && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center size-14 rounded-2xl bg-muted/60 text-muted-foreground/60", children: icon }),
|
|
123
|
+
/* @__PURE__ */ jsxs("div", { className: "space-y-1.5", children: [
|
|
124
|
+
/* @__PURE__ */ jsx("h3", { className: "font-semibold text-base text-foreground/80", children: title }),
|
|
125
|
+
description && /* @__PURE__ */ jsx("p", { className: "text-muted-foreground/60 text-sm max-w-sm", children: description })
|
|
126
126
|
] })
|
|
127
127
|
] })
|
|
128
128
|
}
|
|
@@ -139,7 +139,7 @@ var ConversationScrollButton = ({
|
|
|
139
139
|
Button,
|
|
140
140
|
{
|
|
141
141
|
className: cn(
|
|
142
|
-
"absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full dark:bg-background dark:hover:bg-muted",
|
|
142
|
+
"absolute bottom-4 left-[50%] translate-x-[-50%] rounded-full shadow-lg border-border/50 dark:bg-background dark:hover:bg-muted",
|
|
143
143
|
className
|
|
144
144
|
),
|
|
145
145
|
onClick: handleScrollToBottom,
|
|
@@ -201,8 +201,8 @@ var Message = ({ className, from, ...props }) => /* @__PURE__ */ jsx(
|
|
|
201
201
|
"div",
|
|
202
202
|
{
|
|
203
203
|
className: cn(
|
|
204
|
-
"group flex w-full
|
|
205
|
-
from === "user" ? "is-user" : "is-assistant",
|
|
204
|
+
"group flex w-full flex-col gap-2",
|
|
205
|
+
from === "user" ? "is-user max-w-[85%]" : "is-assistant max-w-full",
|
|
206
206
|
className
|
|
207
207
|
),
|
|
208
208
|
...props
|
|
@@ -216,8 +216,8 @@ var MessageContent = ({
|
|
|
216
216
|
"div",
|
|
217
217
|
{
|
|
218
218
|
className: cn(
|
|
219
|
-
"
|
|
220
|
-
"group-[.is-user]:ml-auto group-[.is-user]:rounded-
|
|
219
|
+
"flex w-full min-w-0 max-w-full flex-col gap-2 overflow-hidden break-words",
|
|
220
|
+
"group-[.is-user]:ml-auto group-[.is-user]:rounded-2xl group-[.is-user]:bg-primary/10 group-[.is-user]:px-4 group-[.is-user]:py-3 group-[.is-user]:text-foreground group-[.is-user]:border group-[.is-user]:border-primary/15",
|
|
221
221
|
"group-[.is-assistant]:text-foreground",
|
|
222
222
|
className
|
|
223
223
|
),
|
|
@@ -485,7 +485,7 @@ function Timeline({
|
|
|
485
485
|
"div",
|
|
486
486
|
{
|
|
487
487
|
className: cn(
|
|
488
|
-
"group/timeline flex
|
|
488
|
+
"group/timeline flex flex-col",
|
|
489
489
|
className
|
|
490
490
|
),
|
|
491
491
|
"data-orientation": orientation,
|
|
@@ -504,7 +504,7 @@ function TimelineContent({
|
|
|
504
504
|
return /* @__PURE__ */ jsx(
|
|
505
505
|
"div",
|
|
506
506
|
{
|
|
507
|
-
className: cn("text-foreground text-sm", className),
|
|
507
|
+
className: cn("text-foreground text-sm min-w-0 overflow-hidden", className),
|
|
508
508
|
"data-slot": "timeline-content",
|
|
509
509
|
...props
|
|
510
510
|
}
|
|
@@ -528,7 +528,7 @@ function TimelineIndicator({
|
|
|
528
528
|
{
|
|
529
529
|
"aria-hidden": "true",
|
|
530
530
|
className: cn(
|
|
531
|
-
"border-primary/20 group-data-completed/timeline-item:border-primary absolute size-4 rounded-full border-2
|
|
531
|
+
"border-primary/20 group-data-completed/timeline-item:border-primary absolute size-4 rounded-full border-2 top-1.25 -left-6 -translate-x-1/2",
|
|
532
532
|
className
|
|
533
533
|
),
|
|
534
534
|
"data-slot": "timeline-indicator",
|
|
@@ -543,7 +543,7 @@ function TimelineItem({ step, className, ...props }) {
|
|
|
543
543
|
"div",
|
|
544
544
|
{
|
|
545
545
|
className: cn(
|
|
546
|
-
"group/timeline-item has-[+[data-completed]]:**:data-[slot=timeline-separator]:bg-primary relative flex flex-
|
|
546
|
+
"group/timeline-item has-[+[data-completed]]:**:data-[slot=timeline-separator]:bg-primary relative flex flex-col gap-0.5 ms-8 not-last:pb-6",
|
|
547
547
|
className
|
|
548
548
|
),
|
|
549
549
|
"data-completed": step <= activeStep || void 0,
|
|
@@ -561,7 +561,7 @@ function TimelineSeparator({
|
|
|
561
561
|
{
|
|
562
562
|
"aria-hidden": "true",
|
|
563
563
|
className: cn(
|
|
564
|
-
"bg-primary/10 absolute self-start group-last/timeline-item:hidden
|
|
564
|
+
"bg-primary/10 absolute self-start group-last/timeline-item:hidden -left-6 h-[calc(100%-1rem-0.25rem)] w-0.5 -translate-x-1/2 translate-y-4.5",
|
|
565
565
|
className
|
|
566
566
|
),
|
|
567
567
|
"data-slot": "timeline-separator",
|
|
@@ -1503,9 +1503,14 @@ function SessionSearchBlock({ tc }) {
|
|
|
1503
1503
|
query = args.query ?? "";
|
|
1504
1504
|
} catch {
|
|
1505
1505
|
}
|
|
1506
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-
|
|
1507
|
-
/* @__PURE__ */ jsx(
|
|
1508
|
-
/* @__PURE__ */ jsx("span", { className: "text-
|
|
1506
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm py-0.5", children: [
|
|
1507
|
+
/* @__PURE__ */ jsx(SearchIcon, { className: "size-3.5 text-muted-foreground/60 shrink-0" }),
|
|
1508
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-foreground", children: "Session Search" }),
|
|
1509
|
+
query && /* @__PURE__ */ jsxs("span", { className: "text-muted-foreground/70 truncate text-xs italic", children: [
|
|
1510
|
+
"\u201C",
|
|
1511
|
+
query,
|
|
1512
|
+
"\u201D"
|
|
1513
|
+
] })
|
|
1509
1514
|
] });
|
|
1510
1515
|
}
|
|
1511
1516
|
function WebToolBlock({ tc }) {
|
|
@@ -1522,14 +1527,15 @@ function WebToolBlock({ tc }) {
|
|
|
1522
1527
|
}
|
|
1523
1528
|
} catch {
|
|
1524
1529
|
}
|
|
1525
|
-
const
|
|
1530
|
+
const toolLabel2 = {
|
|
1526
1531
|
web_extract: "Web Fetch",
|
|
1527
1532
|
web_search: "Web Search",
|
|
1528
1533
|
web_crawl: "Web Crawl"
|
|
1529
1534
|
}[tc.toolName] ?? tc.toolName;
|
|
1530
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-
|
|
1531
|
-
/* @__PURE__ */ jsx(
|
|
1532
|
-
/* @__PURE__ */ jsx("span", { className: "text-
|
|
1535
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-sm py-0.5", children: [
|
|
1536
|
+
/* @__PURE__ */ jsx(GlobeIcon, { className: "size-3.5 text-muted-foreground/60 shrink-0" }),
|
|
1537
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-foreground", children: toolLabel2 }),
|
|
1538
|
+
displayText && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/70 truncate text-xs", children: displayText })
|
|
1533
1539
|
] });
|
|
1534
1540
|
}
|
|
1535
1541
|
function Dialog({
|
|
@@ -3543,38 +3549,74 @@ function CoordinatorToolBlock({ tc }) {
|
|
|
3543
3549
|
] })
|
|
3544
3550
|
] });
|
|
3545
3551
|
}
|
|
3552
|
+
var TOOL_LABELS = {
|
|
3553
|
+
kb_list_pages: "Knowledge Base",
|
|
3554
|
+
kb_read_page: "Read KB Page",
|
|
3555
|
+
consult_expert: "Expert",
|
|
3556
|
+
delegate_task: "Delegate",
|
|
3557
|
+
memory: "Memory",
|
|
3558
|
+
skills_list: "Skills",
|
|
3559
|
+
skill_view: "Skill",
|
|
3560
|
+
create_artifact: "Artifact",
|
|
3561
|
+
process: "Process"
|
|
3562
|
+
};
|
|
3563
|
+
function toolLabel(name) {
|
|
3564
|
+
return TOOL_LABELS[name] ?? name.replace(/_/g, " ").replace(/\b\w/g, (c) => c.toUpperCase());
|
|
3565
|
+
}
|
|
3566
|
+
function toolSummary(tc) {
|
|
3567
|
+
try {
|
|
3568
|
+
const args = JSON.parse(tc.args);
|
|
3569
|
+
if (tc.toolName === "kb_list_pages") return args.kb_id ? `Listing pages` : "";
|
|
3570
|
+
if (tc.toolName === "kb_read_page") return args.path ?? "";
|
|
3571
|
+
if (tc.toolName === "consult_expert") return args.question?.slice(0, 60) ?? "";
|
|
3572
|
+
if (tc.toolName === "memory") return args.action ?? "";
|
|
3573
|
+
return "";
|
|
3574
|
+
} catch {
|
|
3575
|
+
return "";
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
function StatusIcon({ tc }) {
|
|
3579
|
+
const status = effectiveStatus(tc);
|
|
3580
|
+
if (status === "running") return /* @__PURE__ */ jsx(Loader2Icon, { className: "size-3.5 animate-spin text-primary" });
|
|
3581
|
+
if (status === "error") return /* @__PURE__ */ jsx(XCircleIcon, { className: "size-3.5 text-red-500" });
|
|
3582
|
+
if (status === "cancelled") return /* @__PURE__ */ jsx(XCircleIcon, { className: "size-3.5 text-muted-foreground/40" });
|
|
3583
|
+
return /* @__PURE__ */ jsx(CheckCircle2Icon, { className: "size-3.5 text-emerald-500" });
|
|
3584
|
+
}
|
|
3546
3585
|
function DefaultToolBlock({ tc }) {
|
|
3547
3586
|
const [expanded, setExpanded] = useState(false);
|
|
3548
|
-
|
|
3587
|
+
const summary = toolSummary(tc);
|
|
3588
|
+
return /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-border/60 bg-muted/20 overflow-hidden", children: [
|
|
3549
3589
|
/* @__PURE__ */ jsxs(
|
|
3550
3590
|
"button",
|
|
3551
3591
|
{
|
|
3552
3592
|
type: "button",
|
|
3553
3593
|
onClick: () => setExpanded(!expanded),
|
|
3554
3594
|
className: cn(
|
|
3555
|
-
"flex w-full items-center gap-
|
|
3556
|
-
"text-sm
|
|
3595
|
+
"flex w-full items-center gap-2 px-3 py-2",
|
|
3596
|
+
"text-sm hover:bg-muted/40 transition-colors cursor-pointer"
|
|
3557
3597
|
),
|
|
3558
3598
|
children: [
|
|
3599
|
+
/* @__PURE__ */ jsx(StatusIcon, { tc }),
|
|
3600
|
+
/* @__PURE__ */ jsx("span", { className: "font-medium text-foreground", children: toolLabel(tc.toolName) }),
|
|
3601
|
+
summary && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground/70 truncate text-xs flex-1 text-left", children: summary }),
|
|
3559
3602
|
/* @__PURE__ */ jsx(
|
|
3560
3603
|
ChevronRightIcon,
|
|
3561
3604
|
{
|
|
3562
3605
|
className: cn(
|
|
3563
|
-
"size-3 shrink-0 transition-transform duration-150",
|
|
3606
|
+
"size-3.5 shrink-0 text-muted-foreground/50 transition-transform duration-150 ml-auto",
|
|
3564
3607
|
expanded && "rotate-90"
|
|
3565
3608
|
)
|
|
3566
3609
|
}
|
|
3567
|
-
)
|
|
3568
|
-
/* @__PURE__ */ jsx("span", { className: "font-medium text-foreground/80", children: tc.toolName })
|
|
3610
|
+
)
|
|
3569
3611
|
]
|
|
3570
3612
|
}
|
|
3571
3613
|
),
|
|
3572
|
-
expanded && /* @__PURE__ */ jsxs("div", { className: "
|
|
3573
|
-
/* @__PURE__ */ jsx("pre", { className: "overflow-x-auto rounded bg-muted/
|
|
3574
|
-
tc.result && /* @__PURE__ */ jsxs("pre", { className: "overflow-x-auto rounded bg-muted/
|
|
3575
|
-
/* @__PURE__ */ jsx("span", { className: "text-emerald-600 dark:text-emerald-400", children: "Result
|
|
3614
|
+
expanded && /* @__PURE__ */ jsxs("div", { className: "border-t border-border/40 px-3 py-2 space-y-2", children: [
|
|
3615
|
+
/* @__PURE__ */ jsx("pre", { className: "overflow-x-auto rounded-md bg-muted/50 px-3 py-2 text-xs text-muted-foreground font-mono whitespace-pre-wrap break-all", children: formatArgs(tc.args) }),
|
|
3616
|
+
tc.result && /* @__PURE__ */ jsxs("pre", { className: "overflow-x-auto rounded-md bg-muted/50 px-3 py-2 text-xs font-mono whitespace-pre-wrap break-all max-h-48 overflow-y-auto", children: [
|
|
3617
|
+
/* @__PURE__ */ jsx("span", { className: "text-emerald-600 dark:text-emerald-400 font-semibold", children: "Result" }),
|
|
3576
3618
|
"\n",
|
|
3577
|
-
truncate(tc.result, 2e3)
|
|
3619
|
+
/* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: truncate(tc.result, 2e3) })
|
|
3578
3620
|
] })
|
|
3579
3621
|
] })
|
|
3580
3622
|
] });
|
|
@@ -6033,14 +6075,14 @@ function ChatThread({
|
|
|
6033
6075
|
}
|
|
6034
6076
|
return null;
|
|
6035
6077
|
}, [messages]);
|
|
6036
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex
|
|
6078
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-1 flex-col overflow-hidden bg-background text-sm", children: [
|
|
6037
6079
|
/* @__PURE__ */ jsxs(Conversation, { className: "relative flex-1 min-h-0", children: [
|
|
6038
|
-
/* @__PURE__ */ jsx(ConversationContent, { className: "mx-auto", children: messages.length === 0 && !disabled ? /* @__PURE__ */ jsx(
|
|
6080
|
+
/* @__PURE__ */ jsx(ConversationContent, { className: "mx-auto w-full max-w-3xl", children: messages.length === 0 && !disabled ? /* @__PURE__ */ jsx(
|
|
6039
6081
|
ConversationEmptyState,
|
|
6040
6082
|
{
|
|
6041
|
-
icon: /* @__PURE__ */ jsx(MessageSquareIcon, { className: "size-
|
|
6042
|
-
title: "
|
|
6043
|
-
description: "
|
|
6083
|
+
icon: /* @__PURE__ */ jsx(MessageSquareIcon, { className: "size-8 opacity-40" }),
|
|
6084
|
+
title: "Start a conversation",
|
|
6085
|
+
description: "Ask me anything \u2014 I can search, analyze, write code, and more."
|
|
6044
6086
|
}
|
|
6045
6087
|
) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6046
6088
|
groups.map((group) => {
|
|
@@ -6088,7 +6130,7 @@ function ChatThread({
|
|
|
6088
6130
|
] }) }),
|
|
6089
6131
|
/* @__PURE__ */ jsx(ConversationScrollButton, {})
|
|
6090
6132
|
] }),
|
|
6091
|
-
/* @__PURE__ */ jsxs("div", { className: "mx-auto w-full max-w-
|
|
6133
|
+
/* @__PURE__ */ jsxs("div", { className: "mx-auto w-full max-w-3xl px-6 pb-5 pt-3", children: [
|
|
6092
6134
|
retryIndicator && /* @__PURE__ */ jsx("div", { className: "mb-2", children: /* @__PURE__ */ jsx(RetryBanner, { indicator: retryIndicator }) }),
|
|
6093
6135
|
/* @__PURE__ */ jsx(
|
|
6094
6136
|
ChatComposer,
|
|
@@ -7730,8 +7772,8 @@ function AgentChat({
|
|
|
7730
7772
|
sessionId,
|
|
7731
7773
|
onFileSelect: handleFileSelect
|
|
7732
7774
|
},
|
|
7733
|
-
children: /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs("section", { className: "flex
|
|
7734
|
-
/* @__PURE__ */ jsx("div", { className: "flex min-w-0 flex-1 flex-col", children: /* @__PURE__ */ jsx(
|
|
7775
|
+
children: /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs("section", { className: "flex flex-1 min-h-0 overflow-hidden bg-background text-sm text-foreground", children: [
|
|
7776
|
+
/* @__PURE__ */ jsx("div", { className: "flex min-w-0 flex-1 flex-col overflow-hidden", children: /* @__PURE__ */ jsx(
|
|
7735
7777
|
ChatThread,
|
|
7736
7778
|
{
|
|
7737
7779
|
sessionId,
|