agentic-ui-kit 0.9.1 → 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 +195 -50
- 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,11 +1,12 @@
|
|
|
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";
|
|
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, Popover as Popover$1, SearchField, Separator, SubmenuTrigger, Text, ToggleButton, ToggleButtonGroup, useFilter } from "react-aria-components";
|
|
5
|
+
import { Children, Fragment, createContext, createElement, isValidElement, memo, useCallback, useContext, useEffect, useId, useImperativeHandle, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
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";
|
|
9
|
+
import { useIsHidden } from "react-aria/private/collections/Hidden";
|
|
9
10
|
import { UNSAFE_PortalProvider } from "react-aria";
|
|
10
11
|
import { createMathPlugin } from "@streamdown/math";
|
|
11
12
|
import { Streamdown, defaultComponents, defaultRehypePlugins } from "streamdown";
|
|
@@ -242,22 +243,28 @@ function useNarrower(max) {
|
|
|
242
243
|
}
|
|
243
244
|
/** Floating panel for menus and pickers: surface color, rounded, soft shadow, fades in. On phones it's a bottom sheet. */
|
|
244
245
|
function Popover({ className, offset = 6, sheet = 768, width = "auto", fullWidthOnPhones, children, ...props }) {
|
|
245
|
-
|
|
246
|
-
|
|
246
|
+
const asSheet = useNarrower(sheet);
|
|
247
|
+
const isHidden = useIsHidden();
|
|
248
|
+
const triggerState = useContext(OverlayTriggerStateContext);
|
|
249
|
+
if (asSheet) {
|
|
250
|
+
const content = typeof children === "function" ? children({
|
|
251
|
+
placement: "bottom",
|
|
252
|
+
trigger: null,
|
|
253
|
+
isEntering: false,
|
|
254
|
+
isExiting: false,
|
|
255
|
+
defaultChildren: void 0
|
|
256
|
+
}) : children;
|
|
257
|
+
if (isHidden) return /* @__PURE__ */ jsx(Fragment$1, { children: content });
|
|
258
|
+
const isOpen = props.isOpen ?? triggerState?.isOpen ?? false;
|
|
259
|
+
const onOpenChange = props.onOpenChange ?? triggerState?.setOpen;
|
|
247
260
|
return /* @__PURE__ */ jsx(ModalOverlay, {
|
|
248
|
-
|
|
261
|
+
isOpen,
|
|
249
262
|
...onOpenChange && { onOpenChange },
|
|
250
263
|
isDismissable: true,
|
|
251
264
|
className: "fixed inset-0 z-50 flex items-end bg-(--chat-backdrop) data-entering:animate-chat-fade-in data-exiting:animate-chat-fade-out",
|
|
252
265
|
children: /* @__PURE__ */ jsx(Modal$1, {
|
|
253
266
|
className: cx("flex max-h-[85dvh] w-full flex-col overflow-auto rounded-t-chat-lg border-t border-chat-popover-border bg-chat-popover pb-[env(safe-area-inset-bottom)] font-chat-sans text-chat-fg shadow-chat-popover outline-none", "data-entering:animate-chat-sheet-in data-exiting:animate-chat-sheet-out", className),
|
|
254
|
-
children:
|
|
255
|
-
placement: "bottom",
|
|
256
|
-
trigger: null,
|
|
257
|
-
isEntering: false,
|
|
258
|
-
isExiting: false,
|
|
259
|
-
defaultChildren: void 0
|
|
260
|
-
}) : children
|
|
267
|
+
children: content
|
|
261
268
|
})
|
|
262
269
|
});
|
|
263
270
|
}
|
|
@@ -401,23 +408,43 @@ const modalSizes = {
|
|
|
401
408
|
/** Fills the page inside the overlay's padding. */
|
|
402
409
|
full: "h-full max-h-none max-w-none"
|
|
403
410
|
};
|
|
404
|
-
/**
|
|
405
|
-
|
|
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();
|
|
406
418
|
return /* @__PURE__ */ jsx(ModalOverlay, {
|
|
407
419
|
isOpen,
|
|
408
420
|
onOpenChange,
|
|
409
|
-
isDismissable
|
|
421
|
+
isDismissable,
|
|
422
|
+
isKeyboardDismissDisabled,
|
|
410
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"),
|
|
411
424
|
children: /* @__PURE__ */ jsx(Modal$1, {
|
|
412
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),
|
|
413
426
|
children: /* @__PURE__ */ jsxs(Dialog, {
|
|
414
427
|
...props,
|
|
415
|
-
className: "flex min-h-0 flex-1 flex-col outline-none",
|
|
416
|
-
children: [
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
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
|
+
]
|
|
421
448
|
})
|
|
422
449
|
})
|
|
423
450
|
});
|
|
@@ -1184,6 +1211,71 @@ function sseTransport({ url, headers, stopUrl, resumeUrl, fetch: fetchImpl = fet
|
|
|
1184
1211
|
} }
|
|
1185
1212
|
};
|
|
1186
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
|
+
}
|
|
1187
1279
|
// src/hooks/smooth-text.ts
|
|
1188
1280
|
/** Slowest reveal, in characters per second, so a trickle of tokens still reads as steady typing. */
|
|
1189
1281
|
const MIN_RATE = 45;
|
|
@@ -2241,6 +2333,8 @@ function TokenCounter({ tokens, variant = "standalone", className }) {
|
|
|
2241
2333
|
});
|
|
2242
2334
|
}
|
|
2243
2335
|
// src/components/activity-group.tsx
|
|
2336
|
+
/** Below this the running group shows no token count. */
|
|
2337
|
+
const MIN_SHOWN_TOKENS = 50;
|
|
2244
2338
|
/**
|
|
2245
2339
|
* The "Ran a command, searched the web ▾" dropdown: a one-line heading that opens a bordered box with one
|
|
2246
2340
|
* row per step. Each row expands on its own; tool rows render through the registered `ToolView`.
|
|
@@ -2254,7 +2348,7 @@ function ActivityGroup({ parts: all, defaultExpanded = false, className }) {
|
|
|
2254
2348
|
if (parts.length === 0) return null;
|
|
2255
2349
|
const live = parts.some(isWorking);
|
|
2256
2350
|
const tokens = activityTokens(parts);
|
|
2257
|
-
const after = live && tokens
|
|
2351
|
+
const after = live && tokens >= MIN_SHOWN_TOKENS && /* @__PURE__ */ jsx(TokenCounter, {
|
|
2258
2352
|
variant: "inline",
|
|
2259
2353
|
tokens,
|
|
2260
2354
|
className: "ml-1.5"
|
|
@@ -2559,9 +2653,9 @@ function AttachmentCard({ attachment: a, onRemove, onOpen, size = "md", classNam
|
|
|
2559
2653
|
children: icons.edit
|
|
2560
2654
|
})]
|
|
2561
2655
|
}),
|
|
2562
|
-
|
|
2656
|
+
onOpen && (image || pasted && !onRemove) && /* @__PURE__ */ jsx("button", {
|
|
2563
2657
|
type: "button",
|
|
2564
|
-
"aria-label": labels.viewPastedText,
|
|
2658
|
+
"aria-label": image ? labels.openImage(a.name) : labels.viewPastedText,
|
|
2565
2659
|
onClick: onOpen,
|
|
2566
2660
|
className: "absolute inset-0 cursor-pointer rounded-[inherit] outline-none focus-visible:ring-2 focus-visible:ring-chat-focus"
|
|
2567
2661
|
}),
|
|
@@ -2580,24 +2674,56 @@ function AttachmentCard({ attachment: a, onRemove, onOpen, size = "md", classNam
|
|
|
2580
2674
|
/** The composer's row of cards above the text. Renders nothing when empty. */
|
|
2581
2675
|
function AttachmentRow({ attachments, onRemove, onEditText }) {
|
|
2582
2676
|
const [editing, setEditing] = useState();
|
|
2677
|
+
const [viewing, setViewing] = useState();
|
|
2583
2678
|
const labels = useLabels();
|
|
2584
2679
|
if (attachments.length === 0) return null;
|
|
2585
|
-
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
2586
|
-
"
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
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
|
|
2592
2698
|
},
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
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
|
+
});
|
|
2601
2727
|
}
|
|
2602
2728
|
/** Shows pasted text in a modal, editable when `onSave` is set. */
|
|
2603
2729
|
function PastedTextDialog({ text, onClose, onSave, title }) {
|
|
@@ -2652,28 +2778,41 @@ function messageText(message) {
|
|
|
2652
2778
|
}
|
|
2653
2779
|
const timeClass = "px-1 font-chat-sans text-(length:--chat-ui-font-size-sm) leading-4 text-chat-subtle";
|
|
2654
2780
|
/** The user's turn: a bubble on the right, with time, retry, edit and copy under it on hover. */
|
|
2655
|
-
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 }) {
|
|
2656
2782
|
const icons = useIcons();
|
|
2657
2783
|
const labels = useLabels();
|
|
2658
2784
|
const text = messageText(message);
|
|
2659
2785
|
const attachments = message.parts.filter((p) => p.type === "attachment");
|
|
2660
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) } : {};
|
|
2661
2789
|
return /* @__PURE__ */ jsxs("div", {
|
|
2662
2790
|
className: clsx("group/message flex flex-col items-end", className),
|
|
2663
2791
|
children: [
|
|
2792
|
+
caption != null && caption !== false && /* @__PURE__ */ jsx("div", {
|
|
2793
|
+
className: clsx(timeClass, "mb-1"),
|
|
2794
|
+
children: caption
|
|
2795
|
+
}),
|
|
2664
2796
|
attachments.length > 0 && /* @__PURE__ */ jsx("ul", {
|
|
2665
2797
|
"aria-label": labels.attachments,
|
|
2666
2798
|
className: "mb-2 flex max-w-[85%] flex-wrap justify-end gap-2",
|
|
2667
2799
|
children: attachments.map((a) => /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(AttachmentCard, {
|
|
2668
2800
|
attachment: a,
|
|
2669
2801
|
size: "sm",
|
|
2670
|
-
...
|
|
2802
|
+
...opens(a)
|
|
2671
2803
|
}) }, a.id))
|
|
2672
2804
|
}),
|
|
2673
2805
|
/* @__PURE__ */ jsx(PastedTextDialog, {
|
|
2674
2806
|
text: viewing,
|
|
2675
2807
|
onClose: () => setViewing(void 0)
|
|
2676
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
|
+
}),
|
|
2677
2816
|
text && /* @__PURE__ */ jsx(UserBubble, { text }),
|
|
2678
2817
|
/* @__PURE__ */ jsxs("div", {
|
|
2679
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",
|
|
@@ -3401,7 +3540,7 @@ function useDictation({ transcribe, format = "wav", partialEvery = 1500, lang, o
|
|
|
3401
3540
|
/** Touch keyboards have no easy Shift+Enter, so there Enter adds a line and the button sends. */
|
|
3402
3541
|
const coarsePointer = () => typeof window !== "undefined" && window.matchMedia?.("(pointer: coarse)").matches;
|
|
3403
3542
|
/** The chat box: growing textarea, toolbar slots, send / stop. Enter sends, Shift+Enter adds a line. */
|
|
3404
|
-
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 }) {
|
|
3405
3544
|
const icons = useIcons();
|
|
3406
3545
|
const labels = useLabels();
|
|
3407
3546
|
const [own, setOwn] = useState("");
|
|
@@ -3411,6 +3550,7 @@ function Composer({ onSubmit, onStop, busy = false, value, onChange, placeholder
|
|
|
3411
3550
|
onChange?.(next);
|
|
3412
3551
|
};
|
|
3413
3552
|
const area = useRef(null);
|
|
3553
|
+
useImperativeHandle(ref, () => area.current, []);
|
|
3414
3554
|
const fit = useCallback(() => {
|
|
3415
3555
|
const el = area.current;
|
|
3416
3556
|
if (!el) return;
|
|
@@ -3448,7 +3588,8 @@ function Composer({ onSubmit, onStop, busy = false, value, onChange, placeholder
|
|
|
3448
3588
|
}
|
|
3449
3589
|
};
|
|
3450
3590
|
const [dragging, setDragging] = useState(false);
|
|
3451
|
-
const
|
|
3591
|
+
const hasText = text.trim().length > 0;
|
|
3592
|
+
const canSend = !dictation && (!busy || sendWhileBusy) && !isDisabled && !submitDisabled && (allowEmpty || hasText);
|
|
3452
3593
|
const submit = () => {
|
|
3453
3594
|
if (!canSend) return;
|
|
3454
3595
|
onSubmit(text);
|
|
@@ -3493,7 +3634,7 @@ function Composer({ onSubmit, onStop, busy = false, value, onChange, placeholder
|
|
|
3493
3634
|
dictation,
|
|
3494
3635
|
onAccept: () => void acceptDictation(),
|
|
3495
3636
|
finishing
|
|
3496
|
-
}) : busy ? /* @__PURE__ */ jsx(IconButton, {
|
|
3637
|
+
}) : busy && !(sendWhileBusy && hasText) ? /* @__PURE__ */ jsx(IconButton, {
|
|
3497
3638
|
label: labels.stop,
|
|
3498
3639
|
variant: "primary",
|
|
3499
3640
|
onPress: onStop,
|
|
@@ -3532,6 +3673,7 @@ function Composer({ onSubmit, onStop, busy = false, value, onChange, placeholder
|
|
|
3532
3673
|
"aria-label": labels.message,
|
|
3533
3674
|
disabled: isDisabled,
|
|
3534
3675
|
autoFocus,
|
|
3676
|
+
id,
|
|
3535
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")
|
|
3536
3678
|
}),
|
|
3537
3679
|
compact ? /* @__PURE__ */ jsxs("div", {
|
|
@@ -3860,7 +4002,9 @@ function MessageList({ messages, onRetry, onEdit, onFeedback, onReadAloud, actio
|
|
|
3860
4002
|
...onEdit && { onEdit: () => onEdit(m.id) },
|
|
3861
4003
|
...actions?.extra && { actions: actions.extra(m) },
|
|
3862
4004
|
...actions?.copy === false && { copy: false },
|
|
3863
|
-
...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) }
|
|
3864
4008
|
}, m.id) : /* @__PURE__ */ jsx(AssistantMessage, {
|
|
3865
4009
|
message: m,
|
|
3866
4010
|
...onRetry && { onRetry: () => onRetry(m.id) },
|
|
@@ -4202,6 +4346,7 @@ const densityVars = {
|
|
|
4202
4346
|
"--chat-message-font-size": "0.9375rem"
|
|
4203
4347
|
}
|
|
4204
4348
|
};
|
|
4349
|
+
const noop = () => {};
|
|
4205
4350
|
/** A whole chat: header, the conversation, the docked composer. An empty chat shows `emptyState`. */
|
|
4206
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 }) {
|
|
4207
4352
|
const style = {
|
|
@@ -4209,7 +4354,7 @@ function ChatView({ messages, busy = false, onSend, onStop, approvals, onApprove
|
|
|
4209
4354
|
...contentWidth && { "--chat-content-width": contentWidth },
|
|
4210
4355
|
...contentPadding && { "--chat-content-padding": contentPadding }
|
|
4211
4356
|
};
|
|
4212
|
-
const interaction = useMemo(() =>
|
|
4357
|
+
const interaction = useMemo(() => onSend ? { send: onSend } : {}, [onSend]);
|
|
4213
4358
|
const empty = messages.length === 0;
|
|
4214
4359
|
const [body, short] = useShortPane();
|
|
4215
4360
|
const labels = useLabels();
|
|
@@ -4220,7 +4365,7 @@ function ChatView({ messages, busy = false, onSend, onStop, approvals, onApprove
|
|
|
4220
4365
|
const element = /* @__PURE__ */ jsx(Composer, {
|
|
4221
4366
|
variant: density === "inline" || short && !empty ? "compact" : variant,
|
|
4222
4367
|
busy,
|
|
4223
|
-
onSubmit: onSend,
|
|
4368
|
+
onSubmit: onSend ?? noop,
|
|
4224
4369
|
...onStop && { onStop },
|
|
4225
4370
|
...composer,
|
|
4226
4371
|
...(pending || asking) && { placeholder: labels.replyDirectly }
|
|
@@ -4666,4 +4811,4 @@ function SidebarUser({ name, detail, avatarUrl, menu, popoverProps }) {
|
|
|
4666
4811
|
children: menu
|
|
4667
4812
|
})] });
|
|
4668
4813
|
}
|
|
4669
|
-
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 };
|