@assistant-ui/react 0.5.89 → 0.5.91

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.mjs CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  toLanguageModelMessages,
11
11
  toLanguageModelTools,
12
12
  toolResultStream
13
- } from "./chunk-CKNRD26B.mjs";
13
+ } from "./chunk-C57XMNDQ.mjs";
14
14
  import {
15
15
  __export
16
16
  } from "./chunk-BJPOCE4O.mjs";
@@ -2326,6 +2326,7 @@ var defaultComponents = {
2326
2326
  /* @__PURE__ */ jsx23(ContentPartPrimitiveInProgress, { children: /* @__PURE__ */ jsx23("span", { style: { fontFamily: "revert" }, children: " \u25CF" }) })
2327
2327
  ] }),
2328
2328
  Image: () => /* @__PURE__ */ jsx23(ContentPartPrimitiveImage, {}),
2329
+ Unstable_Audio: () => null,
2329
2330
  UI: () => /* @__PURE__ */ jsx23(ContentPartPrimitiveDisplay, {})
2330
2331
  };
2331
2332
  var MessageContentPartComponent = ({
@@ -2334,33 +2335,32 @@ var MessageContentPartComponent = ({
2334
2335
  Empty,
2335
2336
  Image: Image2 = defaultComponents.Image,
2336
2337
  UI = defaultComponents.UI,
2338
+ Unstable_Audio: Audio = defaultComponents.Unstable_Audio,
2337
2339
  tools: { by_name = {}, Fallback: Fallback2 = void 0 } = {}
2338
2340
  } = {}
2339
2341
  }) => {
2340
2342
  const contentPartRuntime = useContentPartRuntime();
2341
2343
  const part = useContentPart();
2342
2344
  const type = part.type;
2345
+ if (type === "tool-call") {
2346
+ const Tool = by_name[part.toolName] || Fallback2;
2347
+ const addResult = (result) => contentPartRuntime.addToolResult(result);
2348
+ return /* @__PURE__ */ jsx23(ToolUIDisplay, { ...part, part, UI: Tool, addResult });
2349
+ }
2350
+ if (part.status.type === "requires-action")
2351
+ throw new Error("Encountered unexpected requires-action status");
2343
2352
  switch (type) {
2344
2353
  case "text":
2345
- if (part.status.type === "requires-action")
2346
- throw new Error("Encountered unexpected requires-action status");
2347
2354
  if (part.part === EMPTY_CONTENT && !!Empty) {
2348
2355
  return /* @__PURE__ */ jsx23(Empty, { status: part.status });
2349
2356
  }
2350
2357
  return /* @__PURE__ */ jsx23(Text2, { ...part, part });
2351
2358
  case "image":
2352
- if (part.status.type === "requires-action")
2353
- throw new Error("Encountered unexpected requires-action status");
2354
2359
  return /* @__PURE__ */ jsx23(Image2, { ...part, part });
2360
+ case "audio":
2361
+ return /* @__PURE__ */ jsx23(Audio, { ...part, part });
2355
2362
  case "ui":
2356
- if (part.status.type === "requires-action")
2357
- throw new Error("Encountered unexpected requires-action status");
2358
2363
  return /* @__PURE__ */ jsx23(UI, { ...part, part });
2359
- case "tool-call": {
2360
- const Tool = by_name[part.toolName] || Fallback2;
2361
- const addResult = (result) => contentPartRuntime.addToolResult(result);
2362
- return /* @__PURE__ */ jsx23(ToolUIDisplay, { ...part, part, UI: Tool, addResult });
2363
- }
2364
2364
  default:
2365
2365
  const unhandledType = type;
2366
2366
  throw new Error(`Unknown content part type: ${unhandledType}`);
@@ -2379,7 +2379,7 @@ var MessageContentPartImpl = ({
2379
2379
  };
2380
2380
  var MessageContentPart = memo2(
2381
2381
  MessageContentPartImpl,
2382
- (prev, next) => prev.partIndex === next.partIndex && prev.components?.Text === next.components?.Text && prev.components?.Image === next.components?.Image && prev.components?.UI === next.components?.UI && prev.components?.tools === next.components?.tools
2382
+ (prev, next) => prev.partIndex === next.partIndex && prev.components?.Text === next.components?.Text && prev.components?.Image === next.components?.Image && prev.components?.Unstable_Audio === next.components?.Unstable_Audio && prev.components?.UI === next.components?.UI && prev.components?.tools === next.components?.tools
2383
2383
  );
2384
2384
  var MessagePrimitiveContent = ({
2385
2385
  components
@@ -5004,6 +5004,7 @@ var fromThreadMessageLike = (like, fallbackId, fallbackStatus) => {
5004
5004
  case "text":
5005
5005
  case "ui":
5006
5006
  case "image":
5007
+ case "audio":
5007
5008
  return part;
5008
5009
  default: {
5009
5010
  const unhandledType = type;
@@ -6036,6 +6037,8 @@ DialogContent.displayName = DialogPrimitive.Content.displayName;
6036
6037
 
6037
6038
  // src/ui/attachment.tsx
6038
6039
  import { AvatarFallback as AvatarFallback2 } from "@radix-ui/react-avatar";
6040
+ import { useShallow } from "zustand/shallow";
6041
+ import { DialogTitle } from "@radix-ui/react-dialog";
6039
6042
  import { jsx as jsx46, jsxs as jsxs9 } from "react/jsx-runtime";
6040
6043
  var AttachmentRoot = withDefaults(attachment_exports.Root, {
6041
6044
  className: "aui-attachment-root"
@@ -6057,13 +6060,15 @@ var useFileSrc = (file) => {
6057
6060
  return src;
6058
6061
  };
6059
6062
  var useAttachmentSrc = () => {
6060
- const { file, src } = useAttachment((a) => {
6061
- if (a.type !== "image") return {};
6062
- if (a.file) return { file: a.file };
6063
- const src2 = a.content?.filter((c) => c.type === "image")[0]?.image;
6064
- if (!src2) return {};
6065
- return { src: src2 };
6066
- });
6063
+ const { file, src } = useAttachment(
6064
+ useShallow((a) => {
6065
+ if (a.type !== "image") return {};
6066
+ if (a.file) return { file: a.file };
6067
+ const src2 = a.content?.filter((c) => c.type === "image")[0]?.image;
6068
+ if (!src2) return {};
6069
+ return { src: src2 };
6070
+ })
6071
+ );
6067
6072
  return useFileSrc(file) ?? src;
6068
6073
  };
6069
6074
  var AttachmentPreview = ({ src }) => {
@@ -6093,7 +6098,10 @@ var AttachmentPreviewDialog = ({ children }) => {
6093
6098
  if (!src) return children;
6094
6099
  return /* @__PURE__ */ jsxs9(Dialog, { children: [
6095
6100
  /* @__PURE__ */ jsx46(DialogTrigger, { className: "aui-attachment-preview-trigger", asChild: true, children }),
6096
- /* @__PURE__ */ jsx46(DialogContent, { children: /* @__PURE__ */ jsx46(AttachmentPreview, { src }) })
6101
+ /* @__PURE__ */ jsxs9(DialogContent, { children: [
6102
+ /* @__PURE__ */ jsx46(DialogTitle, { className: "aui-sr-only", children: "Image Attachment Preview" }),
6103
+ /* @__PURE__ */ jsx46(AttachmentPreview, { src })
6104
+ ] })
6097
6105
  ] });
6098
6106
  };
6099
6107
  var AttachmentThumb = () => {