agentic-ui-kit 0.9.2 → 0.10.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/README.md +18 -1
- package/dist/{ask-user-CwDYhXX4.js → ag-ui-DwCNQQju.js} +415 -2
- package/dist/core.js +2 -2
- package/dist/{extensions-CJ4Asuxk.js → extensions-Col6hZkT.js} +12 -3
- package/dist/index.js +177 -39
- package/dist/styles.css +1 -1
- package/dist/types/core/src/ag-ui.d.ts +104 -0
- package/dist/types/core/src/index.d.ts +2 -0
- package/dist/types/core/src/sse.d.ts +2 -2
- package/dist/types/react/src/components/attachments.d.ts +12 -0
- package/dist/types/react/src/components/composer.d.ts +12 -3
- package/dist/types/react/src/components/messages.d.ts +10 -2
- package/dist/types/react/src/hooks/ag-ui-transport.d.ts +29 -0
- package/dist/types/react/src/index.d.ts +3 -2
- package/dist/types/react/src/primitives/labels.d.ts +2 -0
- package/dist/types/react/src/primitives/overlay.d.ts +13 -2
- package/dist/types/react/src/primitives/tooltip.d.ts +1 -1
- package/dist/types/react/src/views/chat-view.d.ts +2 -1
- package/dist/visuals.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { a as LabelsProvider, c as Button, d as cx, i as useChatInteraction, l as IconButton, n as ChatInteractionProvider, o as defaultLabels, r as useChatExtensions, s as useLabels, t as ChatExtensionsProvider, u as Tooltip } from "./extensions-
|
|
3
|
-
import { a as
|
|
2
|
+
import { a as LabelsProvider, c as Button, d as cx, i as useChatInteraction, l as IconButton, n as ChatInteractionProvider, o as defaultLabels, r as useChatExtensions, s as useLabels, t as ChatExtensionsProvider, u as Tooltip } from "./extensions-Col6hZkT.js";
|
|
3
|
+
import { a as readAskUserInput, c as readEventStream, d as activityTokens, f as applyEvent, n as fromAgUiEvents, o as readAskUserResult, p as awaitingToolCalls, r as toAgUiMessages, t as agUiResume, u as toBlocks, v as settleToolCall } from "./ag-ui-DwCNQQju.js";
|
|
4
4
|
import { clsx } from "clsx";
|
|
5
|
-
import { Children, Fragment, createContext, createElement, isValidElement, memo, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
5
|
+
import { Children, Fragment, createContext, createElement, isValidElement, memo, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
6
6
|
import { Autocomplete, Button as Button$1, Dialog, DialogTrigger, DialogTrigger as DialogTrigger$1, Disclosure as Disclosure$1, DisclosurePanel, Focusable, Header, Heading, Input, Keyboard, Link, Menu as Menu$1, MenuItem as MenuItem$1, MenuSection as MenuSection$1, MenuTrigger, MenuTrigger as MenuTrigger$1, Modal as Modal$1, ModalOverlay, OverlayTriggerStateContext, Popover as Popover$1, SearchField, Separator, SubmenuTrigger, Text, ToggleButton, ToggleButtonGroup, useFilter } from "react-aria-components";
|
|
7
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { AlertTriangle, ArrowDown, ArrowRight, ArrowUp, Check, ChevronDown, ChevronLeft, ChevronRight, ChevronsUpDown, Copy, FileText, Folder, FolderOpen, FolderPlus, Globe, GripVertical, Info, MessageSquare, Mic, MoreHorizontal, PanelLeft, Pencil, Pin, PinOff, Plus, RefreshCw, Share, ShieldQuestion, Square, ThumbsDown, ThumbsUp, Trash2, Volume2, X } from "lucide-react";
|
|
@@ -408,23 +408,43 @@ const modalSizes = {
|
|
|
408
408
|
/** Fills the page inside the overlay's padding. */
|
|
409
409
|
full: "h-full max-h-none max-w-none"
|
|
410
410
|
};
|
|
411
|
-
/**
|
|
412
|
-
|
|
411
|
+
/**
|
|
412
|
+
* A centered dialog over a dimmed page. Escape and (unless `isDismissable={false}`) clicking outside close it;
|
|
413
|
+
* focus stays inside.
|
|
414
|
+
*/
|
|
415
|
+
function Modal({ isOpen, onOpenChange, title, size = "lg", placement = "center", isDismissable = true, isKeyboardDismissDisabled = false, showClose = false, padded = false, children, className, ...props }) {
|
|
416
|
+
const labels = useLabels();
|
|
417
|
+
const icons = useIcons();
|
|
413
418
|
return /* @__PURE__ */ jsx(ModalOverlay, {
|
|
414
419
|
isOpen,
|
|
415
420
|
onOpenChange,
|
|
416
|
-
isDismissable
|
|
421
|
+
isDismissable,
|
|
422
|
+
isKeyboardDismissDisabled,
|
|
417
423
|
className: cx("fixed inset-0 z-50 flex justify-center bg-(--chat-backdrop) p-4 data-entering:animate-chat-fade-in data-exiting:animate-chat-fade-out", placement === "top" ? "items-start pt-[10dvh]" : "items-center"),
|
|
418
424
|
children: /* @__PURE__ */ jsx(Modal$1, {
|
|
419
425
|
className: cx("flex max-h-[85dvh] w-full flex-col rounded-chat-lg border border-chat-popover-border bg-chat-popover font-chat-sans text-chat-fg shadow-chat-popover", modalSizes[size], "data-entering:animate-chat-in data-exiting:animate-chat-out", className),
|
|
420
426
|
children: /* @__PURE__ */ jsxs(Dialog, {
|
|
421
427
|
...props,
|
|
422
|
-
className: "flex min-h-0 flex-1 flex-col outline-none",
|
|
423
|
-
children: [
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
+
className: "relative flex min-h-0 flex-1 flex-col outline-none",
|
|
429
|
+
children: [
|
|
430
|
+
title && /* @__PURE__ */ jsx(Heading, {
|
|
431
|
+
slot: "title",
|
|
432
|
+
className: cx("px-5 pt-4 pb-3 text-base font-medium", showClose && "pr-12"),
|
|
433
|
+
children: title
|
|
434
|
+
}),
|
|
435
|
+
showClose && /* @__PURE__ */ jsx(IconButton, {
|
|
436
|
+
slot: "close",
|
|
437
|
+
label: labels.close,
|
|
438
|
+
size: "sm",
|
|
439
|
+
tooltip: false,
|
|
440
|
+
className: "absolute top-3 right-3 z-10",
|
|
441
|
+
children: icons.remove
|
|
442
|
+
}),
|
|
443
|
+
padded ? /* @__PURE__ */ jsx("div", {
|
|
444
|
+
className: cx("min-h-0 flex-1 overflow-y-auto px-5 pb-4", !title && "pt-4", !title && showClose && "pr-12"),
|
|
445
|
+
children
|
|
446
|
+
}) : children
|
|
447
|
+
]
|
|
428
448
|
})
|
|
429
449
|
})
|
|
430
450
|
});
|
|
@@ -1191,6 +1211,71 @@ function sseTransport({ url, headers, stopUrl, resumeUrl, fetch: fetchImpl = fet
|
|
|
1191
1211
|
} }
|
|
1192
1212
|
};
|
|
1193
1213
|
}
|
|
1214
|
+
// src/hooks/ag-ui-transport.ts
|
|
1215
|
+
/**
|
|
1216
|
+
* A `Transport` for agents that speak AG-UI (https://docs.ag-ui.com) over HTTP + SSE, e.g. LangGraph, Mastra,
|
|
1217
|
+
* CrewAI, Pydantic AI or ADK agents. Page tools (`useAgentTool`) are sent as AG-UI frontend tools and page
|
|
1218
|
+
* context as AG-UI context. An interrupt on a tool call asks the user, and the answer resumes the run.
|
|
1219
|
+
* AG-UI has no stop or rejoin endpoint: Stop closes the stream, and `useChat({ resume: true })` does nothing.
|
|
1220
|
+
*/
|
|
1221
|
+
function agUiTransport({ url, headers, threadId, state, forwardedProps, customKinds, onEvent, onInterrupt, fetch: fetchImpl = fetch }) {
|
|
1222
|
+
const ownThread = crypto.randomUUID();
|
|
1223
|
+
const interrupts = /* @__PURE__ */ new Map();
|
|
1224
|
+
return { async *send(request) {
|
|
1225
|
+
const { message, history, continuation, tools = [], context = {}, signal } = request;
|
|
1226
|
+
const resume = continuation ? agUiResume(message, interrupts) : [];
|
|
1227
|
+
const resumed = new Set(continuation ? message.parts.filter((p) => interrupts.has(p.id)).map((p) => p.id) : []);
|
|
1228
|
+
for (const id of resumed) interrupts.delete(id);
|
|
1229
|
+
const props = forwardedProps ? forwardedProps(request) : {
|
|
1230
|
+
...request.model !== void 0 && { model: request.model },
|
|
1231
|
+
...request.effort !== void 0 && { effort: request.effort }
|
|
1232
|
+
};
|
|
1233
|
+
const input = {
|
|
1234
|
+
threadId: threadId ?? request.conversationId ?? ownThread,
|
|
1235
|
+
runId: crypto.randomUUID(),
|
|
1236
|
+
messages: toAgUiMessages(history, resumed),
|
|
1237
|
+
tools: tools.map((t) => ({
|
|
1238
|
+
name: t.name,
|
|
1239
|
+
description: t.description ?? "",
|
|
1240
|
+
parameters: t.inputSchema ?? {
|
|
1241
|
+
type: "object",
|
|
1242
|
+
properties: {}
|
|
1243
|
+
}
|
|
1244
|
+
})),
|
|
1245
|
+
context: Object.entries(context).map(([description, value]) => ({
|
|
1246
|
+
description,
|
|
1247
|
+
value: typeof value === "string" ? value : JSON.stringify(value)
|
|
1248
|
+
})),
|
|
1249
|
+
...state && { state: state() },
|
|
1250
|
+
...Object.keys(props ?? {}).length > 0 && { forwardedProps: props },
|
|
1251
|
+
...resume.length > 0 && { resume }
|
|
1252
|
+
};
|
|
1253
|
+
const response = await fetchImpl(url, {
|
|
1254
|
+
method: "POST",
|
|
1255
|
+
headers: {
|
|
1256
|
+
"content-type": "application/json",
|
|
1257
|
+
accept: "text/event-stream",
|
|
1258
|
+
...Object.fromEntries(new Headers(typeof headers === "function" ? await headers() : headers))
|
|
1259
|
+
},
|
|
1260
|
+
body: JSON.stringify(input),
|
|
1261
|
+
signal
|
|
1262
|
+
});
|
|
1263
|
+
if (!response.ok || !response.body) throw new Error(`${url} answered ${response.status} ${response.statusText}`.trim());
|
|
1264
|
+
yield* fromAgUiEvents(readEventStream(response.body), {
|
|
1265
|
+
messageId: continuation ? message.id : crypto.randomUUID(),
|
|
1266
|
+
parentId: continuation ? message.parentId : message.id,
|
|
1267
|
+
clientTools: tools.map((t) => t.name),
|
|
1268
|
+
...continuation && { existing: message.parts.map((p) => p.id) },
|
|
1269
|
+
...customKinds && { customKinds },
|
|
1270
|
+
...onEvent && { onEvent },
|
|
1271
|
+
onInterrupt: (interrupt) => {
|
|
1272
|
+
if (interrupt.toolCallId) interrupts.set(interrupt.toolCallId, interrupt);
|
|
1273
|
+
onInterrupt?.(interrupt);
|
|
1274
|
+
},
|
|
1275
|
+
signal
|
|
1276
|
+
});
|
|
1277
|
+
} };
|
|
1278
|
+
}
|
|
1194
1279
|
// src/hooks/smooth-text.ts
|
|
1195
1280
|
/** Slowest reveal, in characters per second, so a trickle of tokens still reads as steady typing. */
|
|
1196
1281
|
const MIN_RATE = 45;
|
|
@@ -2248,6 +2333,8 @@ function TokenCounter({ tokens, variant = "standalone", className }) {
|
|
|
2248
2333
|
});
|
|
2249
2334
|
}
|
|
2250
2335
|
// src/components/activity-group.tsx
|
|
2336
|
+
/** Below this the running group shows no token count. */
|
|
2337
|
+
const MIN_SHOWN_TOKENS = 50;
|
|
2251
2338
|
/**
|
|
2252
2339
|
* The "Ran a command, searched the web ▾" dropdown: a one-line heading that opens a bordered box with one
|
|
2253
2340
|
* row per step. Each row expands on its own; tool rows render through the registered `ToolView`.
|
|
@@ -2261,7 +2348,7 @@ function ActivityGroup({ parts: all, defaultExpanded = false, className }) {
|
|
|
2261
2348
|
if (parts.length === 0) return null;
|
|
2262
2349
|
const live = parts.some(isWorking);
|
|
2263
2350
|
const tokens = activityTokens(parts);
|
|
2264
|
-
const after = live && tokens
|
|
2351
|
+
const after = live && tokens >= MIN_SHOWN_TOKENS && /* @__PURE__ */ jsx(TokenCounter, {
|
|
2265
2352
|
variant: "inline",
|
|
2266
2353
|
tokens,
|
|
2267
2354
|
className: "ml-1.5"
|
|
@@ -2566,9 +2653,9 @@ function AttachmentCard({ attachment: a, onRemove, onOpen, size = "md", classNam
|
|
|
2566
2653
|
children: icons.edit
|
|
2567
2654
|
})]
|
|
2568
2655
|
}),
|
|
2569
|
-
|
|
2656
|
+
onOpen && (image || pasted && !onRemove) && /* @__PURE__ */ jsx("button", {
|
|
2570
2657
|
type: "button",
|
|
2571
|
-
"aria-label": labels.viewPastedText,
|
|
2658
|
+
"aria-label": image ? labels.openImage(a.name) : labels.viewPastedText,
|
|
2572
2659
|
onClick: onOpen,
|
|
2573
2660
|
className: "absolute inset-0 cursor-pointer rounded-[inherit] outline-none focus-visible:ring-2 focus-visible:ring-chat-focus"
|
|
2574
2661
|
}),
|
|
@@ -2587,24 +2674,56 @@ function AttachmentCard({ attachment: a, onRemove, onOpen, size = "md", classNam
|
|
|
2587
2674
|
/** The composer's row of cards above the text. Renders nothing when empty. */
|
|
2588
2675
|
function AttachmentRow({ attachments, onRemove, onEditText }) {
|
|
2589
2676
|
const [editing, setEditing] = useState();
|
|
2677
|
+
const [viewing, setViewing] = useState();
|
|
2590
2678
|
const labels = useLabels();
|
|
2591
2679
|
if (attachments.length === 0) return null;
|
|
2592
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2593
|
-
"
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2680
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2681
|
+
/* @__PURE__ */ jsx("ul", {
|
|
2682
|
+
"aria-label": labels.attachments,
|
|
2683
|
+
className: "flex gap-2.5 overflow-x-auto px-0.5 pt-2.5 pb-1 [scrollbar-width:thin]",
|
|
2684
|
+
children: attachments.map((a) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(AttachmentCard, {
|
|
2685
|
+
attachment: {
|
|
2686
|
+
...a,
|
|
2687
|
+
...a.previewUrl && { url: a.previewUrl }
|
|
2688
|
+
},
|
|
2689
|
+
onRemove: () => onRemove(a.id),
|
|
2690
|
+
...a.kind === "text" && { onOpen: () => setEditing(a) },
|
|
2691
|
+
...a.kind === "image" && !!(a.previewUrl ?? a.url) && { onOpen: () => setViewing(a) }
|
|
2692
|
+
}) }, a.id))
|
|
2693
|
+
}),
|
|
2694
|
+
/* @__PURE__ */ jsx(ImageDialog, {
|
|
2695
|
+
image: viewing && {
|
|
2696
|
+
url: viewing.previewUrl ?? viewing.url,
|
|
2697
|
+
name: viewing.name
|
|
2599
2698
|
},
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2699
|
+
onClose: () => setViewing(void 0)
|
|
2700
|
+
}),
|
|
2701
|
+
/* @__PURE__ */ jsx(PastedTextDialog, {
|
|
2702
|
+
text: editing?.text,
|
|
2703
|
+
onClose: () => setEditing(void 0),
|
|
2704
|
+
...onEditText && editing && { onSave: (text) => onEditText(editing.id, text) }
|
|
2705
|
+
})
|
|
2706
|
+
] });
|
|
2707
|
+
}
|
|
2708
|
+
/** Shows an image attachment at full size in a modal. */
|
|
2709
|
+
function ImageDialog({ image, onClose }) {
|
|
2710
|
+
const [shown, setShown] = useState(image);
|
|
2711
|
+
useEffect(() => {
|
|
2712
|
+
if (image) setShown(image);
|
|
2713
|
+
}, [image]);
|
|
2714
|
+
return /* @__PURE__ */ jsx(Modal, {
|
|
2715
|
+
isOpen: image !== void 0,
|
|
2716
|
+
onOpenChange: (open) => !open && onClose(),
|
|
2717
|
+
"aria-label": shown?.name ?? "",
|
|
2718
|
+
size: "xl",
|
|
2719
|
+
showClose: true,
|
|
2720
|
+
className: "w-auto",
|
|
2721
|
+
children: shown && /* @__PURE__ */ jsx("img", {
|
|
2722
|
+
src: shown.url,
|
|
2723
|
+
alt: shown.name,
|
|
2724
|
+
className: "max-h-[calc(85dvh-2px)] min-h-0 rounded-[inherit] object-contain"
|
|
2725
|
+
})
|
|
2726
|
+
});
|
|
2608
2727
|
}
|
|
2609
2728
|
/** Shows pasted text in a modal, editable when `onSave` is set. */
|
|
2610
2729
|
function PastedTextDialog({ text, onClose, onSave, title }) {
|
|
@@ -2659,28 +2778,41 @@ function messageText(message) {
|
|
|
2659
2778
|
}
|
|
2660
2779
|
const timeClass = "px-1 font-chat-sans text-(length:--chat-ui-font-size-sm) leading-4 text-chat-subtle";
|
|
2661
2780
|
/** The user's turn: a bubble on the right, with time, retry, edit and copy under it on hover. */
|
|
2662
|
-
function UserMessage({ message, onRetry, onEdit, actions, copy = true, time = true, className }) {
|
|
2781
|
+
function UserMessage({ message, onRetry, onEdit, actions, copy = true, time = true, caption, onOpenAttachment, className }) {
|
|
2663
2782
|
const icons = useIcons();
|
|
2664
2783
|
const labels = useLabels();
|
|
2665
2784
|
const text = messageText(message);
|
|
2666
2785
|
const attachments = message.parts.filter((p) => p.type === "attachment");
|
|
2667
2786
|
const [viewing, setViewing] = useState();
|
|
2787
|
+
const [image, setImage] = useState();
|
|
2788
|
+
const opens = (a) => a.text !== void 0 ? { onOpen: () => setViewing(a.text) } : a.url && isImage(a) ? { onOpen: () => onOpenAttachment ? onOpenAttachment(a) : setImage(a) } : {};
|
|
2668
2789
|
return /* @__PURE__ */ jsxs("div", {
|
|
2669
2790
|
className: clsx("group/message flex flex-col items-end", className),
|
|
2670
2791
|
children: [
|
|
2792
|
+
caption != null && caption !== false && /* @__PURE__ */ jsx("div", {
|
|
2793
|
+
className: clsx(timeClass, "mb-1"),
|
|
2794
|
+
children: caption
|
|
2795
|
+
}),
|
|
2671
2796
|
attachments.length > 0 && /* @__PURE__ */ jsx("ul", {
|
|
2672
2797
|
"aria-label": labels.attachments,
|
|
2673
2798
|
className: "mb-2 flex max-w-[85%] flex-wrap justify-end gap-2",
|
|
2674
2799
|
children: attachments.map((a) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(AttachmentCard, {
|
|
2675
2800
|
attachment: a,
|
|
2676
2801
|
size: "sm",
|
|
2677
|
-
...
|
|
2802
|
+
...opens(a)
|
|
2678
2803
|
}) }, a.id))
|
|
2679
2804
|
}),
|
|
2680
2805
|
/* @__PURE__ */ jsx(PastedTextDialog, {
|
|
2681
2806
|
text: viewing,
|
|
2682
2807
|
onClose: () => setViewing(void 0)
|
|
2683
2808
|
}),
|
|
2809
|
+
/* @__PURE__ */ jsx(ImageDialog, {
|
|
2810
|
+
image: image?.url ? {
|
|
2811
|
+
url: image.url,
|
|
2812
|
+
name: image.name
|
|
2813
|
+
} : void 0,
|
|
2814
|
+
onClose: () => setImage(void 0)
|
|
2815
|
+
}),
|
|
2684
2816
|
text && /* @__PURE__ */ jsx(UserBubble, { text }),
|
|
2685
2817
|
/* @__PURE__ */ jsxs("div", {
|
|
2686
2818
|
className: "mt-1 flex items-center gap-0.5 opacity-0 transition-opacity group-hover/message:opacity-100 group-focus-within/message:opacity-100 [@media(hover:none)]:opacity-100",
|
|
@@ -3408,7 +3540,7 @@ function useDictation({ transcribe, format = "wav", partialEvery = 1500, lang, o
|
|
|
3408
3540
|
/** Touch keyboards have no easy Shift+Enter, so there Enter adds a line and the button sends. */
|
|
3409
3541
|
const coarsePointer = () => typeof window !== "undefined" && window.matchMedia?.("(pointer: coarse)").matches;
|
|
3410
3542
|
/** The chat box: growing textarea, toolbar slots, send / stop. Enter sends, Shift+Enter adds a line. */
|
|
3411
|
-
function Composer({ onSubmit, onStop, busy = false, value, onChange, placeholder, variant = "docked", leading, trailing, above, onFiles, onLongPaste, longPasteChars = 2e3, allowEmpty = false, submitDisabled = false, isDisabled = false, dictation, autoFocus, className }) {
|
|
3543
|
+
function Composer({ onSubmit, onStop, busy = false, sendWhileBusy = false, value, onChange, placeholder, variant = "docked", leading, trailing, above, onFiles, onLongPaste, longPasteChars = 2e3, allowEmpty = false, submitDisabled = false, isDisabled = false, dictation, autoFocus, id, ref, className }) {
|
|
3412
3544
|
const icons = useIcons();
|
|
3413
3545
|
const labels = useLabels();
|
|
3414
3546
|
const [own, setOwn] = useState("");
|
|
@@ -3418,6 +3550,7 @@ function Composer({ onSubmit, onStop, busy = false, value, onChange, placeholder
|
|
|
3418
3550
|
onChange?.(next);
|
|
3419
3551
|
};
|
|
3420
3552
|
const area = useRef(null);
|
|
3553
|
+
useImperativeHandle(ref, () => area.current, []);
|
|
3421
3554
|
const fit = useCallback(() => {
|
|
3422
3555
|
const el = area.current;
|
|
3423
3556
|
if (!el) return;
|
|
@@ -3455,7 +3588,8 @@ function Composer({ onSubmit, onStop, busy = false, value, onChange, placeholder
|
|
|
3455
3588
|
}
|
|
3456
3589
|
};
|
|
3457
3590
|
const [dragging, setDragging] = useState(false);
|
|
3458
|
-
const
|
|
3591
|
+
const hasText = text.trim().length > 0;
|
|
3592
|
+
const canSend = !dictation && (!busy || sendWhileBusy) && !isDisabled && !submitDisabled && (allowEmpty || hasText);
|
|
3459
3593
|
const submit = () => {
|
|
3460
3594
|
if (!canSend) return;
|
|
3461
3595
|
onSubmit(text);
|
|
@@ -3500,7 +3634,7 @@ function Composer({ onSubmit, onStop, busy = false, value, onChange, placeholder
|
|
|
3500
3634
|
dictation,
|
|
3501
3635
|
onAccept: () => void acceptDictation(),
|
|
3502
3636
|
finishing
|
|
3503
|
-
}) : busy ? /* @__PURE__ */ jsx(IconButton, {
|
|
3637
|
+
}) : busy && !(sendWhileBusy && hasText) ? /* @__PURE__ */ jsx(IconButton, {
|
|
3504
3638
|
label: labels.stop,
|
|
3505
3639
|
variant: "primary",
|
|
3506
3640
|
onPress: onStop,
|
|
@@ -3539,6 +3673,7 @@ function Composer({ onSubmit, onStop, busy = false, value, onChange, placeholder
|
|
|
3539
3673
|
"aria-label": labels.message,
|
|
3540
3674
|
disabled: isDisabled,
|
|
3541
3675
|
autoFocus,
|
|
3676
|
+
id,
|
|
3542
3677
|
className: clsx("w-full resize-none bg-transparent px-1.5 text-chat-fg outline-none placeholder:text-chat-subtle", "text-base leading-relaxed [scrollbar-width:thin]", compact ? "max-h-[min(10rem,30cqh)] py-1" : variant === "centered" ? "max-h-[min(24rem,45cqh)] min-h-12 pt-1" : "max-h-[min(18rem,35cqh)] min-h-6 pt-1")
|
|
3543
3678
|
}),
|
|
3544
3679
|
compact ? /* @__PURE__ */ jsxs("div", {
|
|
@@ -3867,7 +4002,9 @@ function MessageList({ messages, onRetry, onEdit, onFeedback, onReadAloud, actio
|
|
|
3867
4002
|
...onEdit && { onEdit: () => onEdit(m.id) },
|
|
3868
4003
|
...actions?.extra && { actions: actions.extra(m) },
|
|
3869
4004
|
...actions?.copy === false && { copy: false },
|
|
3870
|
-
...actions?.time === false && { time: false }
|
|
4005
|
+
...actions?.time === false && { time: false },
|
|
4006
|
+
...actions?.caption && { caption: actions.caption(m) },
|
|
4007
|
+
...actions?.onOpenAttachment && { onOpenAttachment: (a) => actions.onOpenAttachment(a, m) }
|
|
3871
4008
|
}, m.id) : /* @__PURE__ */ jsx(AssistantMessage, {
|
|
3872
4009
|
message: m,
|
|
3873
4010
|
...onRetry && { onRetry: () => onRetry(m.id) },
|
|
@@ -4209,6 +4346,7 @@ const densityVars = {
|
|
|
4209
4346
|
"--chat-message-font-size": "0.9375rem"
|
|
4210
4347
|
}
|
|
4211
4348
|
};
|
|
4349
|
+
const noop = () => {};
|
|
4212
4350
|
/** A whole chat: header, the conversation, the docked composer. An empty chat shows `emptyState`. */
|
|
4213
4351
|
function ChatView({ messages, busy = false, onSend, onStop, approvals, onApprove, prompts, onAnswer, onDecline, onRetry, onEdit, onFeedback, onReadAloud, messageActions, renderPart, header, composer, emptyState, disclaimer, renderComposer, density = "full", contentWidth, contentPadding, className }) {
|
|
4214
4352
|
const style = {
|
|
@@ -4216,7 +4354,7 @@ function ChatView({ messages, busy = false, onSend, onStop, approvals, onApprove
|
|
|
4216
4354
|
...contentWidth && { "--chat-content-width": contentWidth },
|
|
4217
4355
|
...contentPadding && { "--chat-content-padding": contentPadding }
|
|
4218
4356
|
};
|
|
4219
|
-
const interaction = useMemo(() =>
|
|
4357
|
+
const interaction = useMemo(() => onSend ? { send: onSend } : {}, [onSend]);
|
|
4220
4358
|
const empty = messages.length === 0;
|
|
4221
4359
|
const [body, short] = useShortPane();
|
|
4222
4360
|
const labels = useLabels();
|
|
@@ -4227,7 +4365,7 @@ function ChatView({ messages, busy = false, onSend, onStop, approvals, onApprove
|
|
|
4227
4365
|
const element = /* @__PURE__ */ jsx(Composer, {
|
|
4228
4366
|
variant: density === "inline" || short && !empty ? "compact" : variant,
|
|
4229
4367
|
busy,
|
|
4230
|
-
onSubmit: onSend,
|
|
4368
|
+
onSubmit: onSend ?? noop,
|
|
4231
4369
|
...onStop && { onStop },
|
|
4232
4370
|
...composer,
|
|
4233
4371
|
...(pending || asking) && { placeholder: labels.replyDirectly }
|
|
@@ -4673,4 +4811,4 @@ function SidebarUser({ name, detail, avatarUrl, menu, popoverProps }) {
|
|
|
4673
4811
|
children: menu
|
|
4674
4812
|
})] });
|
|
4675
4813
|
}
|
|
4676
|
-
export { ActivityGroup, AgentProvider, AgentRegistry, AppShell, ApprovalCard, AskUserAnswers, AskUserPrompt, AssistantMessage, AttachButton, AttachmentCard, AttachmentRow, Badge, Button, Caret, ChatExtensionsProvider, ChatHeader, ChatInteractionProvider, ChatList, ChatListRailButton, ChatNotice, ChatTheme, ChatTitleMenu, ChatTranscript, ChatView, CodeBlock, Composer, ContextMenu, ContextMeter, ContextPanel, CopyButton, CopyField, DRAWER_QUERY, DialogTrigger, DictationButton, DictationControls, Disclosure, Drawer, EffortButton, EffortSlider, EmptyState, IconButton, Markdown, MarkdownLinksProvider, Menu, MenuItem, MenuNote, MenuSearch, MenuSection, MenuSeparator, MenuTrigger, MessageList, Modal, ModelPicker, Panel, PastedTextDialog, Popover, PopoverTrigger, SegmentedControl, Sidebar, SidebarItem, SidebarList, SidebarToggle, SidebarUser, SubmenuTrigger, TokenCounter, ToolPromptCard, ToolViewsProvider, Tooltip, UserMessage, VoiceMeter, activityHeading, activityLabel, askUserToolView, commandTool, defaultIcons, defaultLabels, defaultToolViews, encodeWav, formatDuration, formatRelativeTime, formatTokens, memoryTool, messageText, sseTransport, useAgentContext, useAgentRegistry, useAgentSnapshot, useAgentTool, useAttachments, useChat, useChatExtensions, useChatInteraction, useChatTool, useCountUp, useDictation, useIcons, useLabels, useMediaQuery, useSidebar, useSmoothText, useToolView, useToolViews, userMessage, webFetchTool, webSearchTool };
|
|
4814
|
+
export { ActivityGroup, AgentProvider, AgentRegistry, AppShell, ApprovalCard, AskUserAnswers, AskUserPrompt, AssistantMessage, AttachButton, AttachmentCard, AttachmentRow, Badge, Button, Caret, ChatExtensionsProvider, ChatHeader, ChatInteractionProvider, ChatList, ChatListRailButton, ChatNotice, ChatTheme, ChatTitleMenu, ChatTranscript, ChatView, CodeBlock, Composer, ContextMenu, ContextMeter, ContextPanel, CopyButton, CopyField, DRAWER_QUERY, DialogTrigger, DictationButton, DictationControls, Disclosure, Drawer, EffortButton, EffortSlider, EmptyState, IconButton, ImageDialog, Markdown, MarkdownLinksProvider, Menu, MenuItem, MenuNote, MenuSearch, MenuSection, MenuSeparator, MenuTrigger, MessageList, Modal, ModelPicker, Panel, PastedTextDialog, Popover, PopoverTrigger, SegmentedControl, Sidebar, SidebarItem, SidebarList, SidebarToggle, SidebarUser, SubmenuTrigger, TokenCounter, ToolPromptCard, ToolViewsProvider, Tooltip, UserMessage, VoiceMeter, activityHeading, activityLabel, agUiTransport, askUserToolView, commandTool, defaultIcons, defaultLabels, defaultToolViews, encodeWav, formatDuration, formatRelativeTime, formatTokens, memoryTool, messageText, sseTransport, useAgentContext, useAgentRegistry, useAgentSnapshot, useAgentTool, useAttachments, useChat, useChatExtensions, useChatInteraction, useChatTool, useCountUp, useDictation, useIcons, useLabels, useMediaQuery, useSidebar, useSmoothText, useToolView, useToolViews, userMessage, webFetchTool, webSearchTool };
|