@mastra/react 0.0.0-unified-sidebar-20251010130811 → 0.0.0-usechat-duplicate-20251016110554

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +72 -2
  2. package/dist/{index.cjs.js → index.cjs} +462 -17
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/{index.es.js → index.js} +411 -20
  5. package/dist/index.js.map +1 -0
  6. package/dist/react.css +719 -0
  7. package/dist/src/agent/hooks.d.ts +14 -4
  8. package/dist/src/index.d.ts +1 -0
  9. package/dist/src/lib/ai-sdk/transformers/AISdkNetworkTransformer.d.ts +1 -0
  10. package/dist/src/ui/Code/Code.d.ts +13 -0
  11. package/dist/src/ui/Code/highlight.d.ts +3 -0
  12. package/dist/src/ui/Code/index.d.ts +1 -0
  13. package/dist/src/ui/Entity/Entity.d.ts +13 -0
  14. package/dist/src/ui/Entity/Entity.stories.d.ts +22 -0
  15. package/dist/src/ui/Entity/Entry.d.ts +9 -0
  16. package/dist/src/ui/Entity/ToolApproval.d.ts +10 -0
  17. package/dist/src/ui/Entity/context.d.ts +10 -0
  18. package/dist/src/ui/Entity/index.d.ts +4 -0
  19. package/dist/src/ui/Entity/types.d.ts +1 -0
  20. package/dist/src/ui/Icon/Icon.d.ts +11 -0
  21. package/dist/src/ui/Icon/index.d.ts +1 -0
  22. package/dist/src/ui/IconButton/IconButton.d.ts +8 -0
  23. package/dist/src/ui/IconButton/IconButton.stories.d.ts +12 -0
  24. package/dist/src/ui/IconButton/index.d.ts +1 -0
  25. package/dist/src/ui/Icons/AgentIcon.d.ts +2 -0
  26. package/dist/src/ui/Icons/ToolsIcon.d.ts +2 -0
  27. package/dist/src/ui/Icons/WorkflowIcon.d.ts +2 -0
  28. package/dist/src/ui/Icons/index.d.ts +3 -0
  29. package/dist/src/ui/Message/Message.d.ts +25 -0
  30. package/dist/src/ui/Message/Message.stories.d.ts +13 -0
  31. package/dist/src/ui/Message/index.d.ts +1 -0
  32. package/dist/src/ui/Tooltip/Tooltip.d.ts +8 -0
  33. package/dist/src/ui/Tooltip/Tooltip.stories.d.ts +12 -0
  34. package/dist/src/ui/Tooltip/index.d.ts +1 -0
  35. package/dist/src/ui/index.d.ts +7 -0
  36. package/package.json +44 -10
  37. package/dist/index.cjs.js.map +0 -1
  38. package/dist/index.es.js.map +0 -1
@@ -1,7 +1,12 @@
1
- import { jsx } from 'react/jsx-runtime';
2
- import { createContext, useContext, useState } from 'react';
1
+ import { jsx, jsxs } from 'react/jsx-runtime';
2
+ import { createContext, useContext, useState, Fragment, useLayoutEffect, useRef, useEffect } from 'react';
3
3
  import { MastraClient } from '@mastra/client-js';
4
4
  import { flushSync } from 'react-dom';
5
+ import { ChevronDownIcon, CheckIcon, CopyIcon } from 'lucide-react';
6
+ import { twMerge } from 'tailwind-merge';
7
+ import { toJsxRuntime } from 'hast-util-to-jsx-runtime';
8
+ import { codeToHast } from 'shiki/bundle/web';
9
+ import { TooltipProvider, Root, TooltipPortal, TooltipContent as TooltipContent$1, TooltipTrigger as TooltipTrigger$1 } from '@radix-ui/react-tooltip';
5
10
 
6
11
  const MastraClientContext = createContext({});
7
12
  const MastraClientProvider = ({ children, baseUrl, headers }) => {
@@ -407,7 +412,7 @@ const toUIMessage = ({ chunk, conversation, metadata }) => {
407
412
  parts: [
408
413
  {
409
414
  type: "text",
410
- text: chunk.payload.error
415
+ text: typeof chunk.payload.error === "string" ? chunk.payload.error : JSON.stringify(chunk.payload.error)
411
416
  }
412
417
  ],
413
418
  metadata: {
@@ -545,6 +550,9 @@ const toAssistantUIMessage = (message) => {
545
550
  class AISdkNetworkTransformer {
546
551
  transform({ chunk, conversation, metadata }) {
547
552
  const newConversation = [...conversation];
553
+ if (chunk.type === "routing-agent-text-delta") {
554
+ return this.handleRoutingAgentConversation(chunk, newConversation);
555
+ }
548
556
  if (chunk.type.startsWith("agent-execution-")) {
549
557
  return this.handleAgentConversation(chunk, newConversation, metadata);
550
558
  }
@@ -555,22 +563,80 @@ class AISdkNetworkTransformer {
555
563
  return this.handleToolConversation(chunk, newConversation, metadata);
556
564
  }
557
565
  if (chunk.type === "network-execution-event-step-finish") {
558
- const newMessage = {
559
- id: `network-execution-event-step-finish-${chunk.runId}-${Date.now()}`,
560
- role: "assistant",
561
- parts: [
566
+ const lastMessage = newConversation[newConversation.length - 1];
567
+ if (!lastMessage || lastMessage.role !== "assistant") return newConversation;
568
+ const agentChunk = chunk.payload;
569
+ const parts = [...lastMessage.parts];
570
+ const textPartIndex = parts.findIndex((part) => part.type === "text");
571
+ if (textPartIndex === -1) {
572
+ parts.push({
573
+ type: "text",
574
+ text: agentChunk.result,
575
+ state: "done"
576
+ });
577
+ return [
578
+ ...newConversation.slice(0, -1),
562
579
  {
563
- type: "text",
564
- text: chunk.payload?.result || "",
565
- state: "done"
580
+ ...lastMessage,
581
+ parts
566
582
  }
567
- ],
568
- metadata
569
- };
570
- return [...newConversation, newMessage];
583
+ ];
584
+ }
585
+ const textPart = parts[textPartIndex];
586
+ if (textPart.type === "text") {
587
+ parts[textPartIndex] = {
588
+ ...textPart,
589
+ state: "done"
590
+ };
591
+ return [
592
+ ...newConversation.slice(0, -1),
593
+ {
594
+ ...lastMessage,
595
+ parts
596
+ }
597
+ ];
598
+ }
599
+ return newConversation;
571
600
  }
572
601
  return newConversation;
573
602
  }
603
+ handleRoutingAgentConversation = (chunk, newConversation) => {
604
+ const lastMessage = newConversation[newConversation.length - 1];
605
+ if (!lastMessage || lastMessage.role !== "assistant") return newConversation;
606
+ const agentChunk = chunk.payload;
607
+ const parts = [...lastMessage.parts];
608
+ const textPartIndex = parts.findIndex((part) => part.type === "text");
609
+ if (textPartIndex === -1) {
610
+ parts.push({
611
+ type: "text",
612
+ text: agentChunk.text,
613
+ state: "streaming"
614
+ });
615
+ return [
616
+ ...newConversation.slice(0, -1),
617
+ {
618
+ ...lastMessage,
619
+ parts
620
+ }
621
+ ];
622
+ }
623
+ const textPart = parts[textPartIndex];
624
+ if (textPart.type === "text") {
625
+ parts[textPartIndex] = {
626
+ ...textPart,
627
+ text: textPart.text + agentChunk.text,
628
+ state: "streaming"
629
+ };
630
+ return [
631
+ ...newConversation.slice(0, -1),
632
+ {
633
+ ...lastMessage,
634
+ parts
635
+ }
636
+ ];
637
+ }
638
+ return newConversation;
639
+ };
574
640
  handleAgentConversation = (chunk, newConversation, metadata) => {
575
641
  if (chunk.type === "agent-execution-start") {
576
642
  const primitiveId = chunk.payload?.args?.primitiveId;
@@ -1085,16 +1151,341 @@ const useChat = ({ agentId, initializeMessages }) => {
1085
1151
  });
1086
1152
  setIsRunning(false);
1087
1153
  };
1154
+ const sendMessage = async ({ mode = "stream", ...args }) => {
1155
+ const nextMessage = { role: "user", content: [{ type: "text", text: args.message }] };
1156
+ const messages2 = args.coreUserMessages ? [nextMessage, ...args.coreUserMessages] : [nextMessage];
1157
+ setMessages((s) => [...s, { role: "user", parts: [{ type: "text", text: args.message }] }]);
1158
+ if (mode === "generate") {
1159
+ await generate({ ...args, coreUserMessages: messages2 });
1160
+ } else if (mode === "stream") {
1161
+ await stream({ ...args, coreUserMessages: messages2 });
1162
+ } else if (mode === "network") {
1163
+ await network({ ...args, coreUserMessages: messages2 });
1164
+ }
1165
+ };
1088
1166
  return {
1089
- network,
1090
- stream,
1091
- generate,
1167
+ setMessages,
1168
+ sendMessage,
1092
1169
  isRunning,
1093
1170
  messages,
1094
- setMessages,
1095
1171
  cancelRun: () => setIsRunning(false)
1096
1172
  };
1097
1173
  };
1098
1174
 
1099
- export { MastraReactProvider, mapWorkflowStreamChunkToWatchResult, toAssistantUIMessage, toUIMessage, useChat, useMastraClient };
1100
- //# sourceMappingURL=index.es.js.map
1175
+ const EntityContext = createContext({
1176
+ expanded: false,
1177
+ setExpanded: () => {
1178
+ },
1179
+ variant: "initial",
1180
+ disabled: false
1181
+ });
1182
+ const EntityProvider = EntityContext.Provider;
1183
+ const useEntity = () => useContext(EntityContext);
1184
+
1185
+ const IconSizes = {
1186
+ sm: "mastra:[&>svg]:size-3",
1187
+ md: "mastra:[&>svg]:size-4",
1188
+ lg: "mastra:[&>svg]:size-5"
1189
+ };
1190
+ const Icon = ({ children, className, size = "md", ...props }) => {
1191
+ return /* @__PURE__ */ jsx("div", { className: className || IconSizes[size], ...props, children });
1192
+ };
1193
+
1194
+ const Entity = ({
1195
+ className,
1196
+ variant = "initial",
1197
+ initialExpanded = false,
1198
+ disabled = false,
1199
+ ...props
1200
+ }) => {
1201
+ const [expanded, setExpanded] = useState(initialExpanded);
1202
+ return /* @__PURE__ */ jsx(EntityProvider, { value: { expanded, setExpanded, variant, disabled }, children: /* @__PURE__ */ jsx("div", { className, ...props }) });
1203
+ };
1204
+ const EntityTriggerClass = twMerge(
1205
+ "mastra:aria-disabled:cursor-not-allowed mastra:aria-disabled:bg-surface5 mastra:aria-disabled:text-text3",
1206
+ "mastra:aria-expanded:rounded-b-none mastra:aria-expanded:border-b-0",
1207
+ "mastra:bg-surface3 mastra:text-text6 mastra:hover:bg-surface4 mastra:active:bg-surface5",
1208
+ "mastra:rounded-lg mastra:py-2 mastra:px-4 mastra:border mastra:border-border1",
1209
+ "mastra:cursor-pointer mastra:inline-flex mastra:items-center mastra:gap-1 mastra:font-mono"
1210
+ );
1211
+ const EntityTriggerVariantClasses = {
1212
+ agent: "mastra:[&_svg.mastra-icon]:text-accent1",
1213
+ workflow: "mastra:[&_svg.mastra-icon]:text-accent3",
1214
+ tool: "mastra:[&_svg.mastra-icon]:text-accent6",
1215
+ memory: "mastra:[&_svg.mastra-icon]:text-accent2",
1216
+ initial: "mastra:[&_svg.mastra-icon]:text-text3"
1217
+ };
1218
+ const EntityTrigger = ({ className, children, ...props }) => {
1219
+ const { expanded, setExpanded, variant, disabled } = useEntity();
1220
+ const handleClick = (e) => {
1221
+ if (disabled) return;
1222
+ setExpanded(!expanded);
1223
+ props?.onClick?.(e);
1224
+ };
1225
+ return /* @__PURE__ */ jsx(
1226
+ "button",
1227
+ {
1228
+ className: className || twMerge(EntityTriggerClass, !disabled && EntityTriggerVariantClasses[variant]),
1229
+ ...props,
1230
+ onClick: handleClick,
1231
+ "aria-expanded": expanded,
1232
+ "aria-disabled": disabled,
1233
+ children
1234
+ }
1235
+ );
1236
+ };
1237
+ const EntityContentClass = twMerge(
1238
+ "mastra:space-y-4",
1239
+ "mastra:rounded-lg mastra:rounded-tl-none mastra:p-4 mastra:border mastra:border-border1 mastra:-mt-[0.5px]",
1240
+ "mastra:bg-surface3 mastra:text-text6"
1241
+ );
1242
+ const EntityContent = ({ className, ...props }) => {
1243
+ const { expanded } = useEntity();
1244
+ if (!expanded) return null;
1245
+ return /* @__PURE__ */ jsx("div", { className: className || EntityContentClass, ...props });
1246
+ };
1247
+ const EntityCaret = ({ className, ...props }) => {
1248
+ const { expanded } = useEntity();
1249
+ return /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(
1250
+ ChevronDownIcon,
1251
+ {
1252
+ className: twMerge(
1253
+ `mastra:text-text3 mastra:transition-transform mastra:duration-200 mastra:ease-in-out`,
1254
+ expanded ? "mastra:rotate-0" : "mastra:-rotate-90",
1255
+ className
1256
+ ),
1257
+ ...props
1258
+ }
1259
+ ) });
1260
+ };
1261
+
1262
+ const ToolApprovalClass = twMerge(
1263
+ "mastra:rounded-lg mastra:border mastra:border-border1 mastra:max-w-1/2 mastra:mt-2",
1264
+ "mastra:bg-surface3 mastra:text-text6"
1265
+ );
1266
+ const ToolApproval = ({ className, ...props }) => {
1267
+ return /* @__PURE__ */ jsx("div", { className: className || ToolApprovalClass, ...props });
1268
+ };
1269
+ const ToolApprovalTitleClass = twMerge("mastra:text-text6 mastra:inline-flex mastra:items-center mastra:gap-1");
1270
+ const ToolApprovalTitle = ({ className, ...props }) => {
1271
+ return /* @__PURE__ */ jsx("div", { className: className || ToolApprovalTitleClass, ...props });
1272
+ };
1273
+ const ToolApprovalHeaderClass = twMerge(
1274
+ "mastra:flex mastra:justify-between mastra:items-center mastra:gap-2",
1275
+ "mastra:border-b mastra:border-border1 mastra:px-4 mastra:py-2"
1276
+ );
1277
+ const ToolApprovalHeader = ({ className, ...props }) => {
1278
+ return /* @__PURE__ */ jsx("div", { className: className || ToolApprovalHeaderClass, ...props });
1279
+ };
1280
+ const ToolApprovalContentClass = twMerge("mastra:text-text6 mastra:p-4");
1281
+ const ToolApprovalContent = ({ className, ...props }) => {
1282
+ return /* @__PURE__ */ jsx("div", { className: className || ToolApprovalContentClass, ...props });
1283
+ };
1284
+ const ToolApprovalActionsClass = twMerge("mastra:flex mastra:gap-2 mastra:items-center");
1285
+ const ToolApprovalActions = ({ className, ...props }) => {
1286
+ return /* @__PURE__ */ jsx("div", { className: className || ToolApprovalActionsClass, ...props });
1287
+ };
1288
+
1289
+ const EntryClass = "mastra:space-y-2";
1290
+ const Entry = ({ className, ...props }) => {
1291
+ return /* @__PURE__ */ jsx("div", { className: className || EntryClass, ...props });
1292
+ };
1293
+ const EntryTitleClass = "mastra:font-mono mastra:text-sm mastra:text-text3";
1294
+ const EntryTitle = ({ className, as: Root = "h3", ...props }) => {
1295
+ return /* @__PURE__ */ jsx(Root, { className: className || EntryTitleClass, ...props });
1296
+ };
1297
+
1298
+ async function highlight(code, lang) {
1299
+ const out = await codeToHast(code, {
1300
+ lang,
1301
+ theme: "dracula-soft"
1302
+ });
1303
+ return toJsxRuntime(out, {
1304
+ Fragment,
1305
+ jsx,
1306
+ jsxs
1307
+ });
1308
+ }
1309
+
1310
+ const Tooltip = ({ children }) => {
1311
+ return /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsx(Root, { children }) });
1312
+ };
1313
+ const TooltipContentClass = "mastra:bg-surface4 mastra:text-text6 mastra mastra:rounded-lg mastra:py-1 mastra:px-2 mastra:text-xs mastra:border mastra:border-border1 mastra-tooltip-enter";
1314
+ const TooltipContent = ({ children, className, ...props }) => {
1315
+ return /* @__PURE__ */ jsx(TooltipPortal, { children: /* @__PURE__ */ jsx(TooltipContent$1, { className: className || TooltipContentClass, ...props, children }) });
1316
+ };
1317
+ const TooltipTrigger = (props) => {
1318
+ return /* @__PURE__ */ jsx(TooltipTrigger$1, { ...props, asChild: true });
1319
+ };
1320
+
1321
+ const IconButtonClass = "mastra:text-text3 mastra:hover:text-text6 mastra:active:text-text6 mastra:hover:bg-surface4 mastra:active:bg-surface5 mastra:rounded-md mastra:cursor-pointer";
1322
+ const IconButton = ({ children, tooltip, size = "md", className, ...props }) => {
1323
+ return /* @__PURE__ */ jsxs(Tooltip, { children: [
1324
+ /* @__PURE__ */ jsx(TooltipTrigger, { children: /* @__PURE__ */ jsx(
1325
+ "button",
1326
+ {
1327
+ ...props,
1328
+ className: className || twMerge(IconButtonClass, size === "md" && "mastra:p-0.5", size === "lg" && "mastra:p-1"),
1329
+ children: /* @__PURE__ */ jsx(Icon, { size, children })
1330
+ }
1331
+ ) }),
1332
+ /* @__PURE__ */ jsx(TooltipContent, { children: tooltip })
1333
+ ] });
1334
+ };
1335
+
1336
+ const CodeBlockClass = "mastra:rounded-lg mastra:[&>pre]:p-4 mastra:overflow-hidden mastra:[&>pre]:!bg-surface4 mastra:[&>pre>code]:leading-5 mastra:relative";
1337
+ const CodeBlock = ({ code, language, className, cta }) => {
1338
+ const [nodes, setNodes] = useState(null);
1339
+ useLayoutEffect(() => {
1340
+ void highlight(code, language).then(setNodes);
1341
+ }, [language]);
1342
+ return /* @__PURE__ */ jsxs("div", { className: className || CodeBlockClass, children: [
1343
+ nodes ?? null,
1344
+ cta
1345
+ ] });
1346
+ };
1347
+ const CodeCopyButton = ({ code }) => {
1348
+ const [isCopied, setIsCopied] = useState(false);
1349
+ const handleCopy = () => {
1350
+ navigator.clipboard.writeText(code);
1351
+ setIsCopied(true);
1352
+ setTimeout(() => setIsCopied(false), 2e3);
1353
+ };
1354
+ return /* @__PURE__ */ jsx("div", { className: "mastra:absolute mastra:top-2 mastra:right-2", children: /* @__PURE__ */ jsx(IconButton, { tooltip: "Copy", onClick: handleCopy, children: isCopied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {}) }) });
1355
+ };
1356
+
1357
+ const AgentIcon = ({ className, ...props }) => /* @__PURE__ */ jsxs(
1358
+ "svg",
1359
+ {
1360
+ width: "17",
1361
+ height: "16",
1362
+ viewBox: "0 0 17 16",
1363
+ fill: "none",
1364
+ xmlns: "http://www.w3.org/2000/svg",
1365
+ ...props,
1366
+ className: twMerge("mastra-icon", className),
1367
+ children: [
1368
+ /* @__PURE__ */ jsx(
1369
+ "path",
1370
+ {
1371
+ fillRule: "evenodd",
1372
+ clipRule: "evenodd",
1373
+ d: "M8.5 15C10.3565 15 12.137 14.2625 13.4497 12.9497C14.7625 11.637 15.5 9.85652 15.5 8C15.5 6.14348 14.7625 4.36301 13.4497 3.05025C12.137 1.7375 10.3565 1 8.5 1C6.64348 1 4.86301 1.7375 3.55025 3.05025C2.2375 4.36301 1.5 6.14348 1.5 8C1.5 9.85652 2.2375 11.637 3.55025 12.9497C4.86301 14.2625 6.64348 15 8.5 15ZM5.621 10.879L4.611 11.889C3.84179 11.1198 3.31794 10.1398 3.1057 9.07291C2.89346 8.00601 3.00236 6.90013 3.41864 5.89512C3.83491 4.89012 4.53986 4.03112 5.44434 3.42676C6.34881 2.8224 7.41219 2.49983 8.5 2.49983C9.58781 2.49983 10.6512 2.8224 11.5557 3.42676C12.4601 4.03112 13.1651 4.89012 13.5814 5.89512C13.9976 6.90013 14.1065 8.00601 13.8943 9.07291C13.6821 10.1398 13.1582 11.1198 12.389 11.889L11.379 10.879C11.1004 10.6003 10.7696 10.3792 10.4055 10.2284C10.0414 10.0776 9.6511 9.99995 9.257 10H7.743C7.3489 9.99995 6.95865 10.0776 6.59455 10.2284C6.23045 10.3792 5.89963 10.6003 5.621 10.879Z",
1374
+ fill: "currentColor"
1375
+ }
1376
+ ),
1377
+ /* @__PURE__ */ jsx(
1378
+ "path",
1379
+ {
1380
+ d: "M8.5 4C7.96957 4 7.46086 4.21071 7.08579 4.58579C6.71071 4.96086 6.5 5.46957 6.5 6V6.5C6.5 7.03043 6.71071 7.53914 7.08579 7.91421C7.46086 8.28929 7.96957 8.5 8.5 8.5C9.03043 8.5 9.53914 8.28929 9.91421 7.91421C10.2893 7.53914 10.5 7.03043 10.5 6.5V6C10.5 5.46957 10.2893 4.96086 9.91421 4.58579C9.53914 4.21071 9.03043 4 8.5 4Z",
1381
+ fill: "currentColor"
1382
+ }
1383
+ )
1384
+ ]
1385
+ }
1386
+ );
1387
+
1388
+ const ToolsIcon = ({ className, ...props }) => /* @__PURE__ */ jsx(
1389
+ "svg",
1390
+ {
1391
+ width: "17",
1392
+ height: "16",
1393
+ viewBox: "0 0 17 16",
1394
+ fill: "none",
1395
+ xmlns: "http://www.w3.org/2000/svg",
1396
+ ...props,
1397
+ className: twMerge("mastra-icon", className),
1398
+ children: /* @__PURE__ */ jsx(
1399
+ "path",
1400
+ {
1401
+ fillRule: "evenodd",
1402
+ clipRule: "evenodd",
1403
+ d: "M7.5605 1.42351C8.0791 0.904904 8.92215 0.906157 9.4395 1.42351L10.6922 2.67617C11.2108 3.19477 11.2095 4.03782 10.6922 4.55517L9.4395 5.80783C8.9209 6.32643 8.07785 6.32518 7.5605 5.80783L6.30784 4.55517C5.78923 4.03656 5.79049 3.19352 6.30784 2.67617L7.5605 1.42351ZM3.17618 5.80783C3.69478 5.28923 4.53782 5.29048 5.05517 5.80783L6.30784 7.0605C6.82644 7.5791 6.82519 8.42214 6.30784 8.93949L5.05517 10.1922C4.53657 10.7108 3.69353 10.7095 3.17618 10.1922L1.92351 8.93949C1.40491 8.42089 1.40616 7.57785 1.92351 7.0605L3.17618 5.80783ZM11.9448 5.80783C12.4634 5.28923 13.3065 5.29048 13.8238 5.80783L15.0765 7.0605C15.5951 7.5791 15.5938 8.42214 15.0765 8.93949L13.8238 10.1922C13.3052 10.7108 12.4622 10.7095 11.9448 10.1922L10.6922 8.93949C10.1736 8.42089 10.1748 7.57785 10.6922 7.0605L11.9448 5.80783ZM7.5605 10.1922C8.0791 9.67355 8.92215 9.67481 9.4395 10.1922L10.6922 11.4448C11.2108 11.9634 11.2095 12.8065 10.6922 13.3238L9.4395 14.5765C8.9209 15.0951 8.07785 15.0938 7.5605 14.5765L6.30784 13.3238C5.78923 12.8052 5.79049 11.9622 6.30784 11.4448L7.5605 10.1922Z",
1404
+ fill: "currentColor"
1405
+ }
1406
+ )
1407
+ }
1408
+ );
1409
+
1410
+ const WorkflowIcon = ({ className, ...props }) => /* @__PURE__ */ jsx(
1411
+ "svg",
1412
+ {
1413
+ width: "17",
1414
+ height: "16",
1415
+ viewBox: "0 0 17 16",
1416
+ fill: "none",
1417
+ xmlns: "http://www.w3.org/2000/svg",
1418
+ ...props,
1419
+ className: twMerge("mastra-icon", className),
1420
+ children: /* @__PURE__ */ jsx(
1421
+ "path",
1422
+ {
1423
+ fillRule: "evenodd",
1424
+ clipRule: "evenodd",
1425
+ d: "M6.24388 2.4018C6.24388 2.0394 6.53767 1.74561 6.90008 1.74561H10.0991C10.4614 1.74561 10.7553 2.0394 10.7553 2.4018V4.57546C10.7553 4.93787 10.4614 5.23166 10.0991 5.23166H9.31982V7.35469L10.0033 9.22664C9.90442 9.20146 9.80035 9.1761 9.6915 9.14986L9.62652 9.13422C9.30473 9.05687 8.92256 8.96501 8.61993 8.84491C8.5819 8.82981 8.54147 8.81292 8.49957 8.79391C8.45767 8.81292 8.41724 8.82981 8.3792 8.84491C8.07657 8.96501 7.6944 9.05687 7.37261 9.13422L7.30763 9.14986C7.19879 9.1761 7.09471 9.20146 6.99577 9.22664L7.67932 7.35469V5.23166H6.90008C6.53767 5.23166 6.24388 4.93787 6.24388 4.57546V2.4018ZM6.99577 9.22664C6.99577 9.22664 6.99578 9.22664 6.99577 9.22664L6.43283 10.7683H6.81806C7.18047 10.7683 7.47426 11.0622 7.47426 11.4245V13.5982C7.47426 13.9606 7.18047 14.2544 6.81806 14.2544H3.61909C3.25668 14.2544 2.96289 13.9606 2.96289 13.5982V11.4245C2.96289 11.0622 3.25668 10.7683 3.61909 10.7683H4.26617C4.2921 10.4663 4.32783 10.1494 4.37744 9.85171C4.43762 9.49063 4.52982 9.08135 4.68998 8.76102C4.93975 8.2615 5.44743 8.01751 5.7771 7.88788C6.14684 7.74249 6.57537 7.63889 6.92317 7.55505C7.24707 7.47696 7.49576 7.41679 7.67932 7.35469L6.99577 9.22664ZM6.43283 10.7683L6.99577 9.22664C6.75846 9.28705 6.55067 9.34646 6.37745 9.41458C6.22784 9.47341 6.1623 9.51712 6.14023 9.53254C6.09752 9.63631 6.04409 9.83055 5.99562 10.1214C5.96201 10.3231 5.93498 10.5439 5.91341 10.7683H6.43283ZM10.0033 9.22664L9.31982 7.35469C9.50338 7.41679 9.75206 7.47696 10.076 7.55505C10.4238 7.63889 10.8523 7.74249 11.2221 7.88788C11.5517 8.01751 12.0594 8.2615 12.3091 8.76102C12.4693 9.08135 12.5615 9.49063 12.6217 9.85171C12.6713 10.1494 12.707 10.4663 12.733 10.7683H13.38C13.7424 10.7683 14.0362 11.0622 14.0362 11.4245V13.5982C14.0362 13.9606 13.7424 14.2544 13.38 14.2544H10.1811C9.81867 14.2544 9.52488 13.9606 9.52488 13.5982V11.4245C9.52488 11.0622 9.81867 10.7683 10.1811 10.7683H10.5663L10.0033 9.22664ZM10.0033 9.22664L10.5663 10.7683H11.0857C11.0642 10.5439 11.0372 10.3231 11.0035 10.1214C10.9551 9.83055 10.9016 9.63631 10.8589 9.53254C10.8369 9.51712 10.7713 9.47341 10.6217 9.41458C10.4485 9.34646 10.2407 9.28705 10.0033 9.22664Z",
1426
+ fill: "currentColor"
1427
+ }
1428
+ )
1429
+ }
1430
+ );
1431
+
1432
+ const MessageClass = "mastra:flex mastra:flex-col mastra:w-full mastra:py-4 mastra:gap-2 mastra:group";
1433
+ const Message = ({ position, className, children, ...props }) => {
1434
+ return /* @__PURE__ */ jsx(
1435
+ "div",
1436
+ {
1437
+ className: className || twMerge(
1438
+ MessageClass,
1439
+ position === "left" ? "" : "mastra:items-end mastra:[&_.mastra-message-content]:bg-surface4 mastra:[&_.mastra-message-content]:px-4"
1440
+ ),
1441
+ ...props,
1442
+ children
1443
+ }
1444
+ );
1445
+ };
1446
+ const MessageContentClass = "mastra:max-w-4/5 mastra:py-2 mastra:text-text6 mastra:rounded-lg mastra-message-content mastra:text-md";
1447
+ const MessageContent = ({ children, className, isStreaming, ...props }) => {
1448
+ return /* @__PURE__ */ jsxs("div", { className: className || MessageContentClass, ...props, children: [
1449
+ children,
1450
+ isStreaming && /* @__PURE__ */ jsx(MessageStreaming, {})
1451
+ ] });
1452
+ };
1453
+ const MessageActionsClass = "mastra:gap-2 mastra:flex mastra:opacity-0 mastra:group-hover:opacity-100 mastra:group-focus-within:opacity-100 mastra:items-center";
1454
+ const MessageActions = ({ children, className, ...props }) => {
1455
+ return /* @__PURE__ */ jsx("div", { className: className || MessageActionsClass, ...props, children });
1456
+ };
1457
+ const MessageUsagesClass = "mastra:flex mastra:gap-2 mastra:items-center";
1458
+ const MessageUsages = ({ children, className, ...props }) => {
1459
+ return /* @__PURE__ */ jsx("div", { className: className || MessageUsagesClass, ...props, children });
1460
+ };
1461
+ const MessageUsageClass = "mastra:flex mastra:gap-2 mastra:items-center mastra:font-mono mastra:text-xs mastra:bg-surface3 mastra:rounded-lg mastra:px-2 mastra:py-1";
1462
+ const MessageUsage = ({ children, className, ...props }) => {
1463
+ return /* @__PURE__ */ jsx("dl", { className: className || MessageUsageClass, ...props, children });
1464
+ };
1465
+ const MessageUsageEntryClass = "mastra:text-text3 mastra:text-xs mastra:flex mastra:gap-1 mastra:items-center";
1466
+ const MessageUsageEntry = ({ children, className, ...props }) => {
1467
+ return /* @__PURE__ */ jsx("dt", { className: className || MessageUsageEntryClass, ...props, children });
1468
+ };
1469
+ const MessageUsageValueClass = "mastra:text-text6 mastra:text-xs";
1470
+ const MessageUsageValue = ({ children, className, ...props }) => {
1471
+ return /* @__PURE__ */ jsx("dd", { className: className || MessageUsageValueClass, ...props, children });
1472
+ };
1473
+ const MessageListClass = "mastra:overflow-y-auto mastra:h-full mastra-list";
1474
+ const MessageList = ({ children, className, ...props }) => {
1475
+ const listRef = useRef(null);
1476
+ useEffect(() => {
1477
+ const scrollToBottom = () => {
1478
+ if (!listRef.current) return;
1479
+ listRef.current.scrollTo({ top: listRef.current.scrollHeight, behavior: "smooth" });
1480
+ };
1481
+ requestAnimationFrame(scrollToBottom);
1482
+ });
1483
+ return /* @__PURE__ */ jsx("div", { className: className || MessageListClass, ...props, ref: listRef, children });
1484
+ };
1485
+ const MessageStreamingClass = "mastra:inline-block mastra:w-[2px] mastra:h-[1em] mastra:bg-text5 mastra:ml-0.5 mastra:align-text-bottom mastra:animate-pulse";
1486
+ const MessageStreaming = ({ className, ...props }) => {
1487
+ return /* @__PURE__ */ jsx("span", { className: className || MessageStreamingClass, ...props });
1488
+ };
1489
+
1490
+ export { AgentIcon, CodeBlock, CodeBlockClass, CodeCopyButton, Entity, EntityCaret, EntityContent, EntityContentClass, EntityTrigger, EntityTriggerClass, EntityTriggerVariantClasses, Entry, EntryClass, EntryTitle, EntryTitleClass, Icon, IconButton, IconButtonClass, IconSizes, MastraReactProvider, Message, MessageActions, MessageActionsClass, MessageClass, MessageContent, MessageContentClass, MessageList, MessageListClass, MessageStreaming, MessageStreamingClass, MessageUsage, MessageUsageClass, MessageUsageEntry, MessageUsageEntryClass, MessageUsageValue, MessageUsageValueClass, MessageUsages, MessageUsagesClass, ToolApproval, ToolApprovalActions, ToolApprovalActionsClass, ToolApprovalClass, ToolApprovalContent, ToolApprovalContentClass, ToolApprovalHeader, ToolApprovalHeaderClass, ToolApprovalTitle, ToolApprovalTitleClass, ToolsIcon, Tooltip, TooltipContent, TooltipContentClass, TooltipTrigger, WorkflowIcon, mapWorkflowStreamChunkToWatchResult, toAssistantUIMessage, toUIMessage, useChat, useEntity, useMastraClient };
1491
+ //# sourceMappingURL=index.js.map