@mastra/playground-ui 6.1.2 → 6.1.3-alpha.1

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.es.js CHANGED
@@ -3,7 +3,7 @@ import * as React from 'react';
3
3
  import React__default, { createContext, useContext, forwardRef, memo, useState, useEffect, useRef, useCallback, useMemo, Fragment as Fragment$1, Suspense, useId, startTransition, isValidElement } from 'react';
4
4
  import { MastraClient } from '@mastra/client-js';
5
5
  import { useMessage, MessagePrimitive, ActionBarPrimitive, useAttachment, AttachmentPrimitive, useComposerRuntime, ComposerPrimitive, useComposer, ThreadPrimitive, CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, WebSpeechSynthesisAdapter, useExternalStoreRuntime, AssistantRuntimeProvider } from '@assistant-ui/react';
6
- import { CheckIcon as CheckIcon$1, CopyIcon, Check, Copy, ChevronUpIcon, X, Braces, Loader2, Network, ChevronDown, PauseIcon, HourglassIcon, CircleDashed, Footprints, CircleCheck, CircleX, Workflow, AlertCircleIcon, AlertCircle, CalendarIcon, Brackets, PlusIcon, TrashIcon, Plus, ChevronDownIcon, Minus, Maximize, CirclePause, Circle, StopCircle, BrainIcon, AudioLinesIcon, StopCircleIcon, FileText, CircleXIcon, Link, CloudUpload, Mic, ArrowUp, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, SaveIcon, RefreshCw, ExternalLink, InfoIcon as InfoIcon$1, GaugeIcon, EditIcon, LoaderCircle, ExternalLinkIcon, Users, Brain, NetworkIcon, SearchIcon, TriangleAlertIcon, ChevronRightIcon, ArrowLeftIcon, ArrowRightIcon, XIcon, ChevronsRightIcon, ArrowUpIcon, ArrowDownIcon, AlignLeftIcon, AlignJustifyIcon, CircleAlertIcon, WorkflowIcon as WorkflowIcon$1, PackageIcon, GitBranchIcon, PackageOpenIcon, OctagonXIcon, AlertTriangleIcon, FrownIcon, ChevronUp, ChevronsLeftRight, TimerIcon, ChevronsLeftRightIcon, ChevronFirstIcon, ChevronLastIcon, ListTreeIcon, ArrowRightToLineIcon, CoinsIcon, EyeIcon, ChevronsLeftRightEllipsisIcon, PanelTopIcon, HashIcon, PanelLeftIcon } from 'lucide-react';
6
+ import { CheckIcon as CheckIcon$1, CopyIcon, Check, Copy, ChevronUpIcon, X, Share2, Braces, Loader2, Network, ChevronDown, PauseIcon, HourglassIcon, CircleDashed, Footprints, CircleCheck, CircleX, Workflow, AlertCircleIcon, AlertCircle, CalendarIcon, Brackets, PlusIcon, TrashIcon, Plus, ChevronDownIcon, Minus, Maximize, CirclePause, Circle, StopCircle, BrainIcon, AudioLinesIcon, StopCircleIcon, FileText, CircleXIcon, Link, CloudUpload, Mic, ArrowUp, Search, RefreshCcwIcon, ChevronRight, SortAsc, SortDesc, SaveIcon, RefreshCw, ExternalLink, InfoIcon as InfoIcon$1, GaugeIcon, EditIcon, LoaderCircle, ExternalLinkIcon, Users, Brain, NetworkIcon, SearchIcon, TriangleAlertIcon, ChevronRightIcon, ArrowLeftIcon, ArrowRightIcon, XIcon, ChevronsRightIcon, ArrowUpIcon, ArrowDownIcon, AlignLeftIcon, AlignJustifyIcon, CircleAlertIcon, WorkflowIcon as WorkflowIcon$1, PackageIcon, GitBranchIcon, PackageOpenIcon, OctagonXIcon, AlertTriangleIcon, FrownIcon, ChevronUp, ChevronsLeftRight, TimerIcon, ChevronsLeftRightIcon, ChevronFirstIcon, ChevronLastIcon, ListTreeIcon, ArrowRightToLineIcon, CoinsIcon, EyeIcon, ChevronsLeftRightEllipsisIcon, PanelTopIcon, HashIcon, PanelLeftIcon } from 'lucide-react';
7
7
  import { Slot } from '@radix-ui/react-slot';
8
8
  import * as TooltipPrimitive from '@radix-ui/react-tooltip';
9
9
  import { TooltipProvider as TooltipProvider$1 } from '@radix-ui/react-tooltip';
@@ -18,6 +18,7 @@ import { tags } from '@lezer/highlight';
18
18
  import { draculaInit } from '@uiw/codemirror-theme-dracula';
19
19
  import CodeMirror, { EditorView } from '@uiw/react-codemirror';
20
20
  import { toast } from 'sonner';
21
+ import * as DialogPrimitive from '@radix-ui/react-dialog';
21
22
  import { useDebouncedCallback } from 'use-debounce';
22
23
  import { useQuery, QueryClient, QueryClientProvider } from '@tanstack/react-query';
23
24
  import './index.css';export * from '@tanstack/react-query';
@@ -26,7 +27,6 @@ import '@xyflow/react/dist/style.css';
26
27
  import Dagre from '@dagrejs/dagre';
27
28
  import { Highlight, themes } from 'prism-react-renderer';
28
29
  import * as CollapsiblePrimitive from '@radix-ui/react-collapsible';
29
- import * as DialogPrimitive from '@radix-ui/react-dialog';
30
30
  import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
31
31
  import prettier from 'prettier';
32
32
  import prettierPluginBabel from 'prettier/plugins/babel';
@@ -4340,45 +4340,173 @@ const BadgeWrapper = ({
4340
4340
  initialCollapsed = true,
4341
4341
  icon,
4342
4342
  title,
4343
- collapsible = true
4343
+ collapsible = true,
4344
+ extraInfo
4344
4345
  }) => {
4345
4346
  const [isCollapsed, setIsCollapsed] = useState(initialCollapsed);
4346
- return /* @__PURE__ */ jsxs("div", { className: "mb-2", children: [
4347
- /* @__PURE__ */ jsxs(
4348
- "button",
4347
+ return /* @__PURE__ */ jsxs("div", { className: "mb-4", children: [
4348
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-row gap-2 items-center justify-between", children: [
4349
+ /* @__PURE__ */ jsxs(
4350
+ "button",
4351
+ {
4352
+ onClick: collapsible ? () => setIsCollapsed((s) => !s) : void 0,
4353
+ className: "flex items-center gap-2 disabled:cursor-not-allowed",
4354
+ disabled: !collapsible,
4355
+ type: "button",
4356
+ children: [
4357
+ /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(ChevronUpIcon, { className: cn("transition-all", isCollapsed ? "rotate-90" : "rotate-180") }) }),
4358
+ /* @__PURE__ */ jsx(Badge$1, { icon, children: title })
4359
+ ]
4360
+ }
4361
+ ),
4362
+ extraInfo
4363
+ ] }),
4364
+ !isCollapsed && /* @__PURE__ */ jsx("div", { className: "pt-2", children: /* @__PURE__ */ jsx("div", { className: "p-4 rounded-lg bg-surface2 flex flex-col gap-4", children }) })
4365
+ ] });
4366
+ };
4367
+
4368
+ const Dialog = DialogPrimitive.Root;
4369
+ const DialogPortal = DialogPrimitive.Portal;
4370
+ const DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
4371
+ DialogPrimitive.Overlay,
4372
+ {
4373
+ ref,
4374
+ className: cn(
4375
+ "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
4376
+ className
4377
+ ),
4378
+ ...props
4379
+ }
4380
+ ));
4381
+ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
4382
+ const DialogContent = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
4383
+ /* @__PURE__ */ jsx(DialogOverlay, {}),
4384
+ /* @__PURE__ */ jsxs(
4385
+ DialogPrimitive.Content,
4386
+ {
4387
+ ref,
4388
+ className: cn(
4389
+ "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
4390
+ className
4391
+ ),
4392
+ ...props,
4393
+ children: [
4394
+ children,
4395
+ /* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
4396
+ /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }),
4397
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
4398
+ ] })
4399
+ ]
4400
+ }
4401
+ )
4402
+ ] }));
4403
+ DialogContent.displayName = DialogPrimitive.Content.displayName;
4404
+ const DialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsx("div", { className: cn("flex flex-col space-y-1.5 text-center sm:text-left", className), ...props });
4405
+ DialogHeader.displayName = "DialogHeader";
4406
+ const DialogTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
4407
+ DialogPrimitive.Title,
4408
+ {
4409
+ ref,
4410
+ className: clsx("text-lg font-semibold leading-none tracking-tight", className),
4411
+ ...props
4412
+ }
4413
+ ));
4414
+ DialogTitle.displayName = DialogPrimitive.Title.displayName;
4415
+ const DialogDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(DialogPrimitive.Description, { ref, className: cn("text-sm text-muted-foreground", className), ...props }));
4416
+ DialogDescription.displayName = DialogPrimitive.Description.displayName;
4417
+
4418
+ const variants = {
4419
+ "header-md": "text-header-md leading-header-md",
4420
+ "ui-lg": "text-ui-lg leading-ui-lg",
4421
+ "ui-md": "text-ui-md leading-ui-md",
4422
+ "ui-sm": "text-ui-sm leading-ui-sm",
4423
+ "ui-xs": "text-ui-xs leading-ui-xs"
4424
+ };
4425
+ const fonts = {
4426
+ mono: "font-mono"
4427
+ };
4428
+ const Txt = ({ as: Root = "p", className, variant = "ui-md", font, ...props }) => {
4429
+ return /* @__PURE__ */ jsx(Root, { className: clsx(variants[variant], font && fonts[font], className), ...props });
4430
+ };
4431
+
4432
+ const NetworkChoiceMetadata = ({ selectionReason, open, onOpenChange, input }) => {
4433
+ let inputSlot = null;
4434
+ if (input) {
4435
+ try {
4436
+ inputSlot = typeof input === "object" ? /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: input }) : /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: JSON.parse(input) });
4437
+ } catch {
4438
+ inputSlot = /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap", children: input });
4439
+ }
4440
+ }
4441
+ return /* @__PURE__ */ jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxs(DialogContent, { className: "border-border1 border-sm bg-surface3 p-0 gap-0", children: [
4442
+ /* @__PURE__ */ jsxs(DialogHeader, { className: "p-4", children: [
4443
+ /* @__PURE__ */ jsx(DialogTitle, { children: "Agent Network Metadata" }),
4444
+ /* @__PURE__ */ jsx(DialogDescription, { children: "View the metadata of the agent's network choice." })
4445
+ ] }),
4446
+ /* @__PURE__ */ jsxs("div", { className: "space-y-4 p-4 border-t-sm border-border1", children: [
4447
+ /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
4448
+ /* @__PURE__ */ jsx(Txt, { className: "text-icon3", children: "Selection Reason" }),
4449
+ /* @__PURE__ */ jsx("div", { className: "text-icon6 text-ui-md", children: selectionReason })
4450
+ ] }),
4451
+ inputSlot && /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
4452
+ /* @__PURE__ */ jsx(Txt, { className: "text-icon3", children: "Input" }),
4453
+ /* @__PURE__ */ jsx("div", { className: "text-icon6 text-ui-md", children: inputSlot })
4454
+ ] })
4455
+ ] })
4456
+ ] }) });
4457
+ };
4458
+ const NetworkChoiceMetadataDialogTrigger = ({
4459
+ selectionReason,
4460
+ input
4461
+ }) => {
4462
+ const [isOpen, setIsOpen] = useState(false);
4463
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
4464
+ /* @__PURE__ */ jsx(TooltipIconButton, { tooltip: "Show selection reason", side: "top", onClick: () => setIsOpen((s) => !s), children: /* @__PURE__ */ jsx(Share2, { className: "text-icon3 size-5" }) }),
4465
+ /* @__PURE__ */ jsx(
4466
+ NetworkChoiceMetadata,
4349
4467
  {
4350
- onClick: collapsible ? () => setIsCollapsed((s) => !s) : void 0,
4351
- className: "flex items-center gap-2 disabled:cursor-not-allowed",
4352
- disabled: !collapsible,
4353
- type: "button",
4354
- children: [
4355
- /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(ChevronUpIcon, { className: cn("transition-all", isCollapsed ? "rotate-90" : "rotate-180") }) }),
4356
- /* @__PURE__ */ jsx(Badge$1, { icon, children: title })
4357
- ]
4468
+ selectionReason: selectionReason || "",
4469
+ open: isOpen,
4470
+ onOpenChange: setIsOpen,
4471
+ input
4358
4472
  }
4359
- ),
4360
- !isCollapsed && /* @__PURE__ */ jsx("div", { className: "pt-2", children: /* @__PURE__ */ jsx("div", { className: "p-4 rounded-lg bg-surface2", children }) })
4473
+ )
4361
4474
  ] });
4362
4475
  };
4363
4476
 
4364
- const ToolBadge = ({ toolName, argsText, result }) => {
4365
- let argSlot;
4477
+ const ToolBadge = ({ toolName, args, result, networkMetadata }) => {
4478
+ let argSlot = null;
4366
4479
  try {
4367
- const parsedArgs = JSON.parse(argsText);
4368
- argSlot = /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: parsedArgs });
4480
+ const { __mastraMetadata: _, ...formattedArgs } = typeof args === "object" ? args : JSON.parse(args);
4481
+ argSlot = /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: formattedArgs });
4369
4482
  } catch {
4370
- argSlot = /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap", children: argsText });
4483
+ argSlot = /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap", children: args });
4371
4484
  }
4372
- return /* @__PURE__ */ jsx(BadgeWrapper, { icon: /* @__PURE__ */ jsx(ToolsIcon, { className: "text-[#ECB047]" }), title: toolName, children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
4373
- /* @__PURE__ */ jsxs("div", { children: [
4374
- /* @__PURE__ */ jsx("p", { className: "font-medium pb-2", children: "Tool arguments" }),
4375
- argSlot
4376
- ] }),
4377
- result !== void 0 && /* @__PURE__ */ jsxs("div", { children: [
4378
- /* @__PURE__ */ jsx("p", { className: "font-medium pb-2", children: "Tool result" }),
4379
- typeof result === "string" ? /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap", children: result }) : /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: result })
4380
- ] })
4381
- ] }) });
4485
+ let resultSlot = typeof result === "string" ? /* @__PURE__ */ jsx("pre", { className: "whitespace-pre-wrap", children: result }) : /* @__PURE__ */ jsx(SyntaxHighlighter$2, { data: result });
4486
+ return /* @__PURE__ */ jsx(
4487
+ BadgeWrapper,
4488
+ {
4489
+ icon: /* @__PURE__ */ jsx(ToolsIcon, { className: "text-[#ECB047]" }),
4490
+ title: toolName,
4491
+ extraInfo: networkMetadata && /* @__PURE__ */ jsx(
4492
+ NetworkChoiceMetadataDialogTrigger,
4493
+ {
4494
+ selectionReason: networkMetadata?.selectionReason || "",
4495
+ input: networkMetadata?.input
4496
+ }
4497
+ ),
4498
+ children: /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
4499
+ /* @__PURE__ */ jsxs("div", { children: [
4500
+ /* @__PURE__ */ jsx("p", { className: "font-medium pb-2", children: "Tool arguments" }),
4501
+ argSlot
4502
+ ] }),
4503
+ result !== void 0 && /* @__PURE__ */ jsxs("div", { children: [
4504
+ /* @__PURE__ */ jsx("p", { className: "font-medium pb-2", children: "Tool result" }),
4505
+ resultSlot
4506
+ ] })
4507
+ ] })
4508
+ }
4509
+ );
4382
4510
  };
4383
4511
 
4384
4512
  function Skeleton({ className, ...props }) {
@@ -4390,7 +4518,8 @@ const useWorkflow = (workflowId) => {
4390
4518
  return useQuery({
4391
4519
  queryKey: ["workflow", workflowId],
4392
4520
  queryFn: () => client.getWorkflow(workflowId).details(),
4393
- retry: false
4521
+ retry: false,
4522
+ refetchOnWindowFocus: false
4394
4523
  });
4395
4524
  };
4396
4525
  const useLegacyWorkflow = (workflowId) => {
@@ -5269,56 +5398,6 @@ const CollapsibleTrigger = (props) => {
5269
5398
  };
5270
5399
  const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent;
5271
5400
 
5272
- const Dialog = DialogPrimitive.Root;
5273
- const DialogPortal = DialogPrimitive.Portal;
5274
- const DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
5275
- DialogPrimitive.Overlay,
5276
- {
5277
- ref,
5278
- className: cn(
5279
- "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
5280
- className
5281
- ),
5282
- ...props
5283
- }
5284
- ));
5285
- DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
5286
- const DialogContent = React.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { children: [
5287
- /* @__PURE__ */ jsx(DialogOverlay, {}),
5288
- /* @__PURE__ */ jsxs(
5289
- DialogPrimitive.Content,
5290
- {
5291
- ref,
5292
- className: cn(
5293
- "fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",
5294
- className
5295
- ),
5296
- ...props,
5297
- children: [
5298
- children,
5299
- /* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
5300
- /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }),
5301
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
5302
- ] })
5303
- ]
5304
- }
5305
- )
5306
- ] }));
5307
- DialogContent.displayName = DialogPrimitive.Content.displayName;
5308
- const DialogHeader = ({ className, ...props }) => /* @__PURE__ */ jsx("div", { className: cn("flex flex-col space-y-1.5 text-center sm:text-left", className), ...props });
5309
- DialogHeader.displayName = "DialogHeader";
5310
- const DialogTitle = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
5311
- DialogPrimitive.Title,
5312
- {
5313
- ref,
5314
- className: clsx("text-lg font-semibold leading-none tracking-tight", className),
5315
- ...props
5316
- }
5317
- ));
5318
- DialogTitle.displayName = DialogPrimitive.Title.displayName;
5319
- const DialogDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(DialogPrimitive.Description, { ref, className: cn("text-sm text-muted-foreground", className), ...props }));
5320
- DialogDescription.displayName = DialogPrimitive.Description.displayName;
5321
-
5322
5401
  const useAutoscroll = (ref, { enabled = true }) => {
5323
5402
  const shouldScrollRef = useRef(enabled);
5324
5403
  React__default.useEffect(() => {
@@ -5470,9 +5549,9 @@ const mapWorkflowStreamChunkToWatchResult = (prev, chunk) => {
5470
5549
  ...chunk.payload
5471
5550
  },
5472
5551
  workflowState: {
5473
- ...prev.payload.workflowState,
5552
+ ...prev?.payload?.workflowState,
5474
5553
  steps: {
5475
- ...prev.payload.workflowState.steps,
5554
+ ...prev?.payload?.workflowState?.steps,
5476
5555
  [chunk.payload.id]: {
5477
5556
  ...current || {},
5478
5557
  ...chunk.payload
@@ -5488,17 +5567,17 @@ const mapWorkflowStreamChunkToWatchResult = (prev, chunk) => {
5488
5567
  return {
5489
5568
  ...prev,
5490
5569
  payload: {
5491
- ...prev.payload,
5570
+ ...prev?.payload,
5492
5571
  currentStep: {
5493
5572
  id: chunk.payload.id,
5494
- ...prev?.payload?.currentStep || {},
5573
+ ...prev?.payload?.currentStep,
5495
5574
  ...chunk.payload
5496
5575
  },
5497
5576
  workflowState: {
5498
- ...prev.payload.workflowState,
5577
+ ...prev?.payload?.workflowState,
5499
5578
  status: "suspended",
5500
5579
  steps: {
5501
- ...prev.payload.workflowState.steps,
5580
+ ...prev?.payload?.workflowState?.steps,
5502
5581
  [chunk.payload.id]: {
5503
5582
  ...current || {},
5504
5583
  ...chunk.payload
@@ -5514,17 +5593,17 @@ const mapWorkflowStreamChunkToWatchResult = (prev, chunk) => {
5514
5593
  return {
5515
5594
  ...prev,
5516
5595
  payload: {
5517
- ...prev.payload,
5596
+ ...prev?.payload,
5518
5597
  currentStep: {
5519
5598
  id: chunk.payload.id,
5520
5599
  ...prev?.payload?.currentStep || {},
5521
5600
  ...chunk.payload
5522
5601
  },
5523
5602
  workflowState: {
5524
- ...prev.payload.workflowState,
5603
+ ...prev?.payload?.workflowState,
5525
5604
  status: "waiting",
5526
5605
  steps: {
5527
- ...prev.payload.workflowState.steps,
5606
+ ...prev?.payload?.workflowState?.steps,
5528
5607
  [chunk.payload.id]: {
5529
5608
  ...current,
5530
5609
  ...chunk.payload
@@ -5538,20 +5617,20 @@ const mapWorkflowStreamChunkToWatchResult = (prev, chunk) => {
5538
5617
  if (chunk.type === "workflow-step-result") {
5539
5618
  const status = chunk.payload.status;
5540
5619
  const current = prev?.payload?.workflowState?.steps?.[chunk.payload.id] || {};
5541
- return {
5620
+ const next = {
5542
5621
  ...prev,
5543
5622
  payload: {
5544
- ...prev.payload,
5623
+ ...prev?.payload,
5545
5624
  currentStep: {
5546
5625
  id: chunk.payload.id,
5547
5626
  ...prev?.payload?.currentStep || {},
5548
5627
  ...chunk.payload
5549
5628
  },
5550
5629
  workflowState: {
5551
- ...prev.payload.workflowState,
5630
+ ...prev?.payload?.workflowState,
5552
5631
  status,
5553
5632
  steps: {
5554
- ...prev.payload.workflowState.steps,
5633
+ ...prev?.payload?.workflowState?.steps,
5555
5634
  [chunk.payload.id]: {
5556
5635
  ...current,
5557
5636
  ...chunk.payload
@@ -5561,14 +5640,15 @@ const mapWorkflowStreamChunkToWatchResult = (prev, chunk) => {
5561
5640
  },
5562
5641
  eventTimestamp: /* @__PURE__ */ new Date()
5563
5642
  };
5643
+ return next;
5564
5644
  }
5565
5645
  if (chunk.type === "workflow-canceled") {
5566
5646
  return {
5567
5647
  ...prev,
5568
5648
  payload: {
5569
- ...prev.payload,
5649
+ ...prev?.payload,
5570
5650
  workflowState: {
5571
- ...prev.payload.workflowState,
5651
+ ...prev?.payload?.workflowState,
5572
5652
  status: "canceled"
5573
5653
  }
5574
5654
  },
@@ -5579,10 +5659,10 @@ const mapWorkflowStreamChunkToWatchResult = (prev, chunk) => {
5579
5659
  return {
5580
5660
  ...prev,
5581
5661
  payload: {
5582
- ...prev.payload,
5662
+ ...prev?.payload,
5583
5663
  currentStep: void 0,
5584
5664
  workflowState: {
5585
- ...prev.payload.workflowState,
5665
+ ...prev?.payload?.workflowState,
5586
5666
  status: chunk.payload.workflowStatus
5587
5667
  }
5588
5668
  },
@@ -5610,10 +5690,8 @@ function WorkflowRunProvider({
5610
5690
  useEffect(() => {
5611
5691
  if (snapshot?.runId) {
5612
5692
  setResult(convertWorkflowRunStateToWatchResult(snapshot));
5613
- } else {
5614
- setResult(null);
5615
5693
  }
5616
- }, [snapshot?.runId ?? ""]);
5694
+ }, [snapshot]);
5617
5695
  return /* @__PURE__ */ jsx(
5618
5696
  WorkflowRunContext.Provider,
5619
5697
  {
@@ -5723,20 +5801,6 @@ const CodeDialogContent = ({ data }) => {
5723
5801
  }
5724
5802
  };
5725
5803
 
5726
- const variants = {
5727
- "header-md": "text-header-md leading-header-md",
5728
- "ui-lg": "text-ui-lg leading-ui-lg",
5729
- "ui-md": "text-ui-md leading-ui-md",
5730
- "ui-sm": "text-ui-sm leading-ui-sm",
5731
- "ui-xs": "text-ui-xs leading-ui-xs"
5732
- };
5733
- const fonts = {
5734
- mono: "font-mono"
5735
- };
5736
- const Txt = ({ as: Root = "p", className, variant = "ui-md", font, ...props }) => {
5737
- return /* @__PURE__ */ jsx(Root, { className: clsx(variants[variant], font && fonts[font], className), ...props });
5738
- };
5739
-
5740
5804
  const formatJSON = async (code) => {
5741
5805
  const formatted = await prettier.format(code, {
5742
5806
  semi: false,
@@ -6613,7 +6677,7 @@ const PopoverContent = React.forwardRef(({ className, align = "center", sideOffs
6613
6677
  ref,
6614
6678
  align,
6615
6679
  sideOffset,
6616
- className: cn(
6680
+ className: clsx(
6617
6681
  "z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
6618
6682
  className
6619
6683
  ),
@@ -7971,7 +8035,7 @@ function WorkflowTrigger({
7971
8035
  }, [isStreamingWorkflow]);
7972
8036
  useEffect(() => {
7973
8037
  if (!streamResultToUse?.payload?.workflowState?.steps || !result?.runId) return;
7974
- const suspended = Object.entries(streamResultToUse.payload.workflowState.steps).filter(([_, { status }]) => status === "suspended").map(([stepId, { payload: payload2 }]) => ({
8038
+ const suspended = Object.entries(streamResultToUse?.payload?.workflowState?.steps || {}).filter(([_, { status }]) => status === "suspended").map(([stepId, { payload: payload2 }]) => ({
7975
8039
  stepId,
7976
8040
  runId: result.runId,
7977
8041
  suspendPayload: payload2,
@@ -8504,15 +8568,6 @@ const EmptyWorkflowsTable = () => /* @__PURE__ */ jsx("div", { className: "flex
8504
8568
  }
8505
8569
  ) });
8506
8570
 
8507
- const useHandleAgentWorkflowStream = (workflowOutput) => {
8508
- const [streamResult, setStreamResult] = useState({});
8509
- useEffect(() => {
8510
- if (!workflowOutput) return;
8511
- setStreamResult((prev) => mapWorkflowStreamChunkToWatchResult(prev, workflowOutput));
8512
- }, [workflowOutput]);
8513
- return streamResult;
8514
- };
8515
-
8516
8571
  const useWorkflowRuns = (workflowId, { enabled = true } = {}) => {
8517
8572
  const client = useMastraClient();
8518
8573
  return useQuery({
@@ -8522,17 +8577,32 @@ const useWorkflowRuns = (workflowId, { enabled = true } = {}) => {
8522
8577
  });
8523
8578
  };
8524
8579
 
8525
- const WorkflowBadge = ({ workflow, runId, workflowId, isStreaming }) => {
8580
+ const WorkflowBadge = ({ workflow, runId, workflowId, isStreaming, networkMetadata }) => {
8526
8581
  const { data: runs, isLoading: isRunsLoading } = useWorkflowRuns(workflowId, {
8527
8582
  enabled: Boolean(runId) && !isStreaming
8528
8583
  });
8529
8584
  const run = runs?.runs.find((run2) => run2.runId === runId);
8530
8585
  const isLoading = isRunsLoading || !run;
8531
8586
  const snapshot = typeof run?.snapshot === "object" ? run?.snapshot : void 0;
8532
- return /* @__PURE__ */ jsxs(BadgeWrapper, { icon: /* @__PURE__ */ jsx(WorkflowIcon, { className: "text-accent3" }), title: workflow.name, initialCollapsed: false, children: [
8533
- !isStreaming && !isLoading && /* @__PURE__ */ jsx(WorkflowRunProvider, { snapshot, children: /* @__PURE__ */ jsx(WorkflowBadgeExtended, { workflowId, workflow, runId }) }),
8534
- isStreaming && /* @__PURE__ */ jsx(WorkflowBadgeExtended, { workflowId, workflow, runId })
8535
- ] });
8587
+ return /* @__PURE__ */ jsxs(
8588
+ BadgeWrapper,
8589
+ {
8590
+ icon: /* @__PURE__ */ jsx(WorkflowIcon, { className: "text-accent3" }),
8591
+ title: workflow.name,
8592
+ initialCollapsed: false,
8593
+ extraInfo: networkMetadata && /* @__PURE__ */ jsx(
8594
+ NetworkChoiceMetadataDialogTrigger,
8595
+ {
8596
+ selectionReason: networkMetadata?.selectionReason || "",
8597
+ input: networkMetadata?.input
8598
+ }
8599
+ ),
8600
+ children: [
8601
+ !isStreaming && !isLoading && /* @__PURE__ */ jsx(WorkflowRunProvider, { snapshot, children: /* @__PURE__ */ jsx(WorkflowBadgeExtended, { workflowId, workflow, runId }) }),
8602
+ isStreaming && /* @__PURE__ */ jsx(WorkflowBadgeExtended, { workflowId, workflow, runId })
8603
+ ]
8604
+ }
8605
+ );
8536
8606
  };
8537
8607
  const WorkflowBadgeExtended = ({ workflowId, workflow, runId }) => {
8538
8608
  const { Link } = useLinkComponent();
@@ -8544,13 +8614,12 @@ const WorkflowBadgeExtended = ({ workflowId, workflow, runId }) => {
8544
8614
  /* @__PURE__ */ jsx("div", { className: "rounded-md overflow-hidden h-[60vh] w-full", children: /* @__PURE__ */ jsx(WorkflowGraph, { workflowId, workflow }) })
8545
8615
  ] });
8546
8616
  };
8547
- const useWorkflowStream = (partialWorkflowOutput) => {
8548
- const streamResult = useHandleAgentWorkflowStream(partialWorkflowOutput);
8617
+ const useWorkflowStream = (workflowFullState) => {
8549
8618
  const { setResult } = useContext(WorkflowRunContext);
8550
8619
  useEffect(() => {
8551
- if (!streamResult) return;
8552
- setResult(streamResult);
8553
- }, [streamResult]);
8620
+ if (!workflowFullState) return;
8621
+ setResult(workflowFullState);
8622
+ }, [workflowFullState]);
8554
8623
  };
8555
8624
 
8556
8625
  const LoadingBadge = () => {
@@ -8564,12 +8633,61 @@ const LoadingBadge = () => {
8564
8633
  );
8565
8634
  };
8566
8635
 
8567
- const ToolFallback$1 = ({ toolName, argsText, result, args, ...props }) => {
8568
- return /* @__PURE__ */ jsx(WorkflowRunProvider, { children: /* @__PURE__ */ jsx(ToolFallbackInner, { toolName, argsText, result, args, ...props }) });
8636
+ const AgentBadge = ({ agentId, messages = [], networkMetadata }) => {
8637
+ return /* @__PURE__ */ jsx(
8638
+ BadgeWrapper,
8639
+ {
8640
+ icon: /* @__PURE__ */ jsx(AgentIcon, { className: "text-accent1" }),
8641
+ title: agentId,
8642
+ initialCollapsed: false,
8643
+ extraInfo: networkMetadata && /* @__PURE__ */ jsx(
8644
+ NetworkChoiceMetadataDialogTrigger,
8645
+ {
8646
+ selectionReason: networkMetadata?.selectionReason || "",
8647
+ input: networkMetadata?.input
8648
+ }
8649
+ ),
8650
+ children: messages.map((message, index) => {
8651
+ if (message.type === "text") {
8652
+ return /* @__PURE__ */ jsx(React__default.Fragment, { children: message.content }, index);
8653
+ }
8654
+ const result = typeof message.toolOutput === "string" ? JSON.parse(message.toolOutput) : message.toolOutput;
8655
+ return /* @__PURE__ */ jsx(React__default.Fragment, { children: /* @__PURE__ */ jsx(
8656
+ ToolFallback$1,
8657
+ {
8658
+ toolName: message.toolName,
8659
+ argsText: typeof message.args === "string" ? message.args : JSON.stringify(message.args),
8660
+ result,
8661
+ args: message.args,
8662
+ status: { type: "complete" },
8663
+ type: "tool-call",
8664
+ toolCallId: message.toolCallId,
8665
+ addResult: () => {
8666
+ }
8667
+ }
8668
+ ) }, index);
8669
+ })
8670
+ }
8671
+ );
8672
+ };
8673
+
8674
+ const ToolFallback$1 = ({ toolName, result, args, ...props }) => {
8675
+ return /* @__PURE__ */ jsx(WorkflowRunProvider, { children: /* @__PURE__ */ jsx(ToolFallbackInner, { toolName, result, args, ...props }) });
8569
8676
  };
8570
- const ToolFallbackInner = ({ toolName, argsText, result, args }) => {
8571
- useWorkflowStream(args.__mastraMetadata?.partialChunk);
8677
+ const ToolFallbackInner = ({ toolName, result, args }) => {
8678
+ useWorkflowStream(args.__mastraMetadata?.workflowFullState);
8572
8679
  const { data: workflow, isLoading } = useWorkflow(toolName);
8680
+ const isAgent = args.__mastraMetadata?.from === "AGENT";
8681
+ if (isAgent) {
8682
+ return /* @__PURE__ */ jsx(
8683
+ AgentBadge,
8684
+ {
8685
+ agentId: toolName,
8686
+ messages: args?.__mastraMetadata?.messages,
8687
+ networkMetadata: args?.__mastraMetadata?.networkMetadata
8688
+ }
8689
+ );
8690
+ }
8573
8691
  if (isLoading) return /* @__PURE__ */ jsx(LoadingBadge, {});
8574
8692
  if (workflow) {
8575
8693
  return /* @__PURE__ */ jsx(
@@ -8578,11 +8696,20 @@ const ToolFallbackInner = ({ toolName, argsText, result, args }) => {
8578
8696
  workflowId: toolName,
8579
8697
  workflow,
8580
8698
  isStreaming: args.__mastraMetadata?.isStreaming,
8581
- runId: result?.runId
8699
+ runId: result?.runId,
8700
+ networkMetadata: args?.__mastraMetadata?.networkMetadata
8582
8701
  }
8583
8702
  );
8584
8703
  }
8585
- return /* @__PURE__ */ jsx(ToolBadge, { toolName, argsText, result });
8704
+ return /* @__PURE__ */ jsx(
8705
+ ToolBadge,
8706
+ {
8707
+ toolName,
8708
+ args,
8709
+ result,
8710
+ networkMetadata: args?.__mastraMetadata?.networkMetadata
8711
+ }
8712
+ );
8586
8713
  };
8587
8714
 
8588
8715
  const Reasoning = ({ text }) => {
@@ -8838,12 +8965,13 @@ const useSpeechRecognition = ({
8838
8965
  }) => {
8839
8966
  const client = useMastraClient();
8840
8967
  const [agent, setAgent] = useState(null);
8968
+ const { runtimeContext } = usePlaygroundStore();
8841
8969
  useEffect(() => {
8842
8970
  if (!agentId) return;
8843
8971
  const agent2 = client.getAgent(agentId);
8844
8972
  const check = async () => {
8845
8973
  try {
8846
- await agent2.voice.getSpeakers();
8974
+ await agent2.voice.getSpeakers(runtimeContext);
8847
8975
  setAgent(agent2);
8848
8976
  } catch (error) {
8849
8977
  setAgent(null);
@@ -9186,7 +9314,20 @@ const AttachFileDialog = ({ onOpenChange, open }) => {
9186
9314
  ] }) });
9187
9315
  };
9188
9316
 
9189
- const Thread = ({ ToolFallback, agentName, agentId, hasMemory, onInputChange }) => {
9317
+ const ThreadInputContext = createContext({
9318
+ threadInput: "",
9319
+ setThreadInput: () => {
9320
+ }
9321
+ });
9322
+ const ThreadInputProvider = ({ children }) => {
9323
+ const [threadInput, setThreadInput] = useState("");
9324
+ return /* @__PURE__ */ jsx(ThreadInputContext.Provider, { value: { threadInput, setThreadInput }, children });
9325
+ };
9326
+ const useThreadInput = () => {
9327
+ return useContext(ThreadInputContext);
9328
+ };
9329
+
9330
+ const Thread = ({ ToolFallback, agentName, agentId, hasMemory }) => {
9190
9331
  const areaRef = useRef(null);
9191
9332
  useAutoscroll(areaRef, { enabled: true });
9192
9333
  const WrappedAssistantMessage = (props) => {
@@ -9207,7 +9348,7 @@ const Thread = ({ ToolFallback, agentName, agentId, hasMemory, onInputChange })
9207
9348
  ) }),
9208
9349
  /* @__PURE__ */ jsx(ThreadPrimitive.If, { empty: false, children: /* @__PURE__ */ jsx("div", {}) })
9209
9350
  ] }),
9210
- /* @__PURE__ */ jsx(Composer$1, { hasMemory, onInputChange, agentId })
9351
+ /* @__PURE__ */ jsx(Composer$1, { hasMemory, agentId })
9211
9352
  ] });
9212
9353
  };
9213
9354
  const ThreadWrapper$1 = ({ children }) => {
@@ -9229,7 +9370,8 @@ const ThreadWelcome$1 = ({ agentName }) => {
9229
9370
  /* @__PURE__ */ jsx("p", { className: "mt-4 font-medium", children: "How can I help you today?" })
9230
9371
  ] }) });
9231
9372
  };
9232
- const Composer$1 = ({ hasMemory, onInputChange, agentId }) => {
9373
+ const Composer$1 = ({ hasMemory, agentId }) => {
9374
+ const { setThreadInput } = useThreadInput();
9233
9375
  return /* @__PURE__ */ jsxs("div", { className: "mx-4", children: [
9234
9376
  /* @__PURE__ */ jsxs(ComposerPrimitive.Root, { children: [
9235
9377
  /* @__PURE__ */ jsx("div", { className: "max-w-[568px] w-full mx-auto pb-2", children: /* @__PURE__ */ jsx(ComposerAttachments, {}) }),
@@ -9242,7 +9384,7 @@ const Composer$1 = ({ hasMemory, onInputChange, agentId }) => {
9242
9384
  placeholder: "Enter your message...",
9243
9385
  name: "",
9244
9386
  id: "",
9245
- onChange: (e) => onInputChange?.(e.target.value)
9387
+ onChange: (e) => setThreadInput?.(e.target.value)
9246
9388
  }
9247
9389
  ) }),
9248
9390
  /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
@@ -9543,11 +9685,12 @@ const useAdapters = (agentId) => {
9543
9685
  const [isReady, setIsReady] = useState(false);
9544
9686
  const [speechAdapter, setSpeechAdapter] = useState(void 0);
9545
9687
  const baseClient = useMastraClient();
9688
+ const { runtimeContext } = usePlaygroundStore();
9546
9689
  useEffect(() => {
9547
9690
  const check = async () => {
9548
9691
  const agent = baseClient.getAgent(agentId);
9549
9692
  try {
9550
- await agent.voice.getSpeakers();
9693
+ await agent.voice.getSpeakers(runtimeContext);
9551
9694
  setSpeechAdapter(new VoiceAttachmentAdapter(agent));
9552
9695
  setIsReady(true);
9553
9696
  } catch {
@@ -9570,21 +9713,550 @@ const useAdapters = (agentId) => {
9570
9713
  };
9571
9714
  };
9572
9715
 
9573
- const convertMessage$2 = (message) => {
9574
- return message;
9575
- };
9576
- const handleFinishReason = (finishReason) => {
9577
- switch (finishReason) {
9578
- case "tool-calls":
9579
- throw new Error("Stream finished with reason tool-calls, try increasing maxSteps");
9580
- }
9581
- };
9582
- const convertToAIAttachments = async (attachments) => {
9583
- const promises = (attachments ?? []).filter((attachment) => attachment.type === "image" || attachment.type === "document").map(async (attachment) => {
9584
- const isFileFromURL = attachment.name.startsWith("https://");
9585
- if (attachment.type === "document") {
9586
- if (attachment.contentType === "application/pdf") {
9587
- const pdfText = attachment.content?.[0]?.text || "";
9716
+ const handleNetworkMessageFromMemory = (content) => {
9717
+ if (content.resourceType === "workflow") {
9718
+ return {
9719
+ role: "assistant",
9720
+ content: [
9721
+ {
9722
+ type: "tool-call",
9723
+ toolCallId: content.finalResult.runId,
9724
+ toolName: content.resourceId,
9725
+ result: { runId: content.finalResult.runId },
9726
+ args: {
9727
+ __mastraMetadata: {
9728
+ from: "WORKFLOW",
9729
+ networkMetadata: {
9730
+ selectionReason: content?.selectionReason,
9731
+ input: content?.input
9732
+ }
9733
+ }
9734
+ }
9735
+ }
9736
+ ]
9737
+ };
9738
+ }
9739
+ if (content.resourceType === "agent") {
9740
+ const badgeMessages = [];
9741
+ let toolCalls = {};
9742
+ const messages = content.finalResult.messages.slice(1);
9743
+ for (const message of messages) {
9744
+ if (typeof message.content === "string") {
9745
+ badgeMessages.push({
9746
+ type: "text",
9747
+ content: message.content
9748
+ });
9749
+ continue;
9750
+ }
9751
+ for (const part of message.content) {
9752
+ if (part.type === "text") {
9753
+ badgeMessages.push({
9754
+ type: "text",
9755
+ content: part.content
9756
+ });
9757
+ } else if (part.type === "tool-result") {
9758
+ badgeMessages.push({
9759
+ type: "tool",
9760
+ toolName: part.toolName,
9761
+ toolOutput: part.result,
9762
+ // tool output
9763
+ toolCallId: part.toolCallId,
9764
+ args: toolCalls?.[part.toolCallId]?.args || {}
9765
+ });
9766
+ } else if (part.type === "tool-call") {
9767
+ toolCalls[part.toolCallId] = part;
9768
+ }
9769
+ }
9770
+ }
9771
+ return {
9772
+ role: "assistant",
9773
+ content: [
9774
+ {
9775
+ type: "tool-call",
9776
+ toolCallId: content.finalResult.runId,
9777
+ toolName: content.resourceId,
9778
+ result: { runId: content.finalResult.runId },
9779
+ args: {
9780
+ __mastraMetadata: {
9781
+ from: "AGENT",
9782
+ networkMetadata: {
9783
+ selectionReason: content?.selectionReason || "",
9784
+ input: content?.input || ""
9785
+ },
9786
+ messages: badgeMessages
9787
+ }
9788
+ }
9789
+ }
9790
+ ]
9791
+ };
9792
+ }
9793
+ if (content.resourceType === "tool") {
9794
+ return {
9795
+ role: "assistant",
9796
+ content: [
9797
+ {
9798
+ type: "tool-call",
9799
+ toolCallId: content.finalResult.toolCallId,
9800
+ toolName: content.resourceId,
9801
+ result: content.finalResult.result,
9802
+ args: {
9803
+ ...content?.input,
9804
+ __mastraMetadata: {
9805
+ networkMetadata: {
9806
+ selectionReason: content?.selectionReason || "",
9807
+ input: content?.input || ""
9808
+ }
9809
+ }
9810
+ }
9811
+ }
9812
+ ]
9813
+ };
9814
+ }
9815
+ return { role: "assistant", content: [{ type: "text", text: "Unknown response" }] };
9816
+ };
9817
+
9818
+ const handleStreamChunk = async ({
9819
+ chunk,
9820
+ setMessages,
9821
+ refreshWorkingMemory,
9822
+ _sideEffects
9823
+ }) => {
9824
+ function updater() {
9825
+ setMessages((currentConversation) => {
9826
+ const message = {
9827
+ role: "assistant",
9828
+ content: [{ type: "text", text: _sideEffects.content }]
9829
+ };
9830
+ if (!_sideEffects.assistantMessageAdded) {
9831
+ _sideEffects.assistantMessageAdded = true;
9832
+ if (_sideEffects.assistantToolCallAddedForUpdater) {
9833
+ _sideEffects.assistantToolCallAddedForUpdater = false;
9834
+ }
9835
+ return [...currentConversation, message];
9836
+ }
9837
+ if (_sideEffects.assistantToolCallAddedForUpdater) {
9838
+ _sideEffects.assistantToolCallAddedForUpdater = false;
9839
+ return [...currentConversation, message];
9840
+ }
9841
+ return [...currentConversation.slice(0, -1), message];
9842
+ });
9843
+ }
9844
+ switch (chunk.type) {
9845
+ case "text-delta": {
9846
+ if (_sideEffects.assistantToolCallAddedForContent) {
9847
+ _sideEffects.assistantToolCallAddedForContent = false;
9848
+ _sideEffects.content = chunk.payload.text;
9849
+ } else {
9850
+ _sideEffects.content += chunk.payload.text;
9851
+ }
9852
+ updater();
9853
+ break;
9854
+ }
9855
+ case "tool-output": {
9856
+ if (chunk.payload.output?.type.startsWith("workflow-")) {
9857
+ handleWorkflowChunk({ workflowChunk: chunk.payload.output, setMessages, entityName: chunk.payload.toolName });
9858
+ }
9859
+ break;
9860
+ }
9861
+ case "tool-call": {
9862
+ setMessages((currentConversation) => {
9863
+ const lastMessage = currentConversation[currentConversation.length - 1];
9864
+ if (lastMessage && lastMessage.role === "assistant") {
9865
+ const updatedMessage = {
9866
+ ...lastMessage,
9867
+ content: Array.isArray(lastMessage.content) ? [
9868
+ ...lastMessage.content,
9869
+ {
9870
+ type: "tool-call",
9871
+ toolCallId: chunk.payload.toolCallId,
9872
+ toolName: chunk.payload.toolName,
9873
+ args: {
9874
+ ...chunk.payload.args,
9875
+ __mastraMetadata: {
9876
+ ...chunk.payload.args?.__mastraMetadata,
9877
+ isStreaming: true
9878
+ }
9879
+ }
9880
+ }
9881
+ ] : [
9882
+ ...typeof lastMessage.content === "string" ? [{ type: "text", text: lastMessage.content }] : [],
9883
+ {
9884
+ type: "tool-call",
9885
+ toolCallId: chunk.payload.toolCallId,
9886
+ toolName: chunk.payload.toolName,
9887
+ args: {
9888
+ ...chunk.payload.args,
9889
+ __mastraMetadata: {
9890
+ ...chunk.payload.args?.__mastraMetadata,
9891
+ isStreaming: true
9892
+ }
9893
+ }
9894
+ }
9895
+ ]
9896
+ };
9897
+ _sideEffects.assistantToolCallAddedForUpdater = true;
9898
+ _sideEffects.assistantToolCallAddedForContent = true;
9899
+ return [...currentConversation.slice(0, -1), updatedMessage];
9900
+ }
9901
+ const newMessage = {
9902
+ role: "assistant",
9903
+ content: [
9904
+ { type: "text", text: _sideEffects.content },
9905
+ {
9906
+ type: "tool-call",
9907
+ toolCallId: chunk.payload.toolCallId,
9908
+ toolName: chunk.payload.toolName,
9909
+ args: {
9910
+ ...chunk.payload.args,
9911
+ __mastraMetadata: { ...chunk.payload.args?.__mastraMetadata, isStreaming: true }
9912
+ }
9913
+ }
9914
+ ]
9915
+ };
9916
+ _sideEffects.assistantToolCallAddedForUpdater = true;
9917
+ _sideEffects.assistantToolCallAddedForContent = true;
9918
+ return [...currentConversation, newMessage];
9919
+ });
9920
+ _sideEffects.toolCallIdToName.current[chunk.payload.toolCallId] = chunk.payload.toolName;
9921
+ break;
9922
+ }
9923
+ case "tool-result": {
9924
+ setMessages((currentConversation) => {
9925
+ const lastMessage = currentConversation[currentConversation.length - 1];
9926
+ if (lastMessage && lastMessage.role === "assistant" && Array.isArray(lastMessage.content)) {
9927
+ const updatedContent = lastMessage.content.map((part) => {
9928
+ if (typeof part === "object" && part.type === "tool-call" && part.toolCallId === chunk.payload.toolCallId) {
9929
+ return {
9930
+ ...part,
9931
+ result: chunk.payload.result
9932
+ };
9933
+ }
9934
+ return part;
9935
+ });
9936
+ const updatedMessage = {
9937
+ ...lastMessage,
9938
+ content: updatedContent
9939
+ };
9940
+ return [...currentConversation.slice(0, -1), updatedMessage];
9941
+ }
9942
+ return currentConversation;
9943
+ });
9944
+ try {
9945
+ const toolName = _sideEffects.toolCallIdToName.current[chunk.payload.toolCallId];
9946
+ if (toolName === "updateWorkingMemory" && chunk.payload.result?.success) {
9947
+ await refreshWorkingMemory?.();
9948
+ }
9949
+ } finally {
9950
+ delete _sideEffects.toolCallIdToName.current[chunk.payload.toolCallId];
9951
+ }
9952
+ break;
9953
+ }
9954
+ case "error": {
9955
+ if (typeof chunk.payload.error === "string") {
9956
+ throw new Error(chunk.payload.error);
9957
+ }
9958
+ break;
9959
+ }
9960
+ case "finish": {
9961
+ handleFinishReason$1(chunk.payload.finishReason);
9962
+ break;
9963
+ }
9964
+ case "reasoning-delta": {
9965
+ setMessages((currentConversation) => {
9966
+ const lastMessage = currentConversation[currentConversation.length - 1];
9967
+ if (lastMessage && lastMessage.role === "assistant" && Array.isArray(lastMessage.content)) {
9968
+ const updatedContent = lastMessage.content.map((part) => {
9969
+ if (typeof part === "object" && part.type === "reasoning") {
9970
+ return {
9971
+ ...part,
9972
+ text: part.text + chunk.payload.text
9973
+ };
9974
+ }
9975
+ return part;
9976
+ });
9977
+ const updatedMessage = {
9978
+ ...lastMessage,
9979
+ content: updatedContent
9980
+ };
9981
+ return [...currentConversation.slice(0, -1), updatedMessage];
9982
+ }
9983
+ const newMessage = {
9984
+ role: "assistant",
9985
+ content: [
9986
+ {
9987
+ type: "reasoning",
9988
+ text: chunk.payload.text
9989
+ },
9990
+ { type: "text", text: _sideEffects.content }
9991
+ ]
9992
+ };
9993
+ return [...currentConversation, newMessage];
9994
+ });
9995
+ break;
9996
+ }
9997
+ }
9998
+ };
9999
+ const handleFinishReason$1 = (finishReason) => {
10000
+ switch (finishReason) {
10001
+ case "tool-calls":
10002
+ throw new Error("Stream finished with reason tool-calls, try increasing maxSteps");
10003
+ }
10004
+ };
10005
+ const handleWorkflowChunk = ({ workflowChunk, setMessages, entityName }) => {
10006
+ flushSync(() => {
10007
+ setMessages((currentConversation) => {
10008
+ const lastMessage = currentConversation[currentConversation.length - 1];
10009
+ const contentArray = Array.isArray(lastMessage.content) ? lastMessage.content : [{ type: "text", text: lastMessage.content }];
10010
+ const newMessage = {
10011
+ ...lastMessage,
10012
+ content: contentArray.map((part) => {
10013
+ if (part.type === "tool-call") {
10014
+ return {
10015
+ ...part,
10016
+ toolName: part?.entityName || entityName,
10017
+ args: {
10018
+ ...part.args,
10019
+ __mastraMetadata: {
10020
+ ...part.args?.__mastraMetadata,
10021
+ workflowFullState: mapWorkflowStreamChunkToWatchResult(
10022
+ part.args?.__mastraMetadata?.workflowFullState || {},
10023
+ workflowChunk
10024
+ ),
10025
+ isStreaming: true
10026
+ }
10027
+ }
10028
+ };
10029
+ }
10030
+ return part;
10031
+ })
10032
+ };
10033
+ return [...currentConversation.slice(0, -1), newMessage];
10034
+ });
10035
+ });
10036
+ };
10037
+ const handleAgentChunk = ({ agentChunk, setMessages, entityName }) => {
10038
+ switch (agentChunk.type) {
10039
+ case "tool-result": {
10040
+ setMessages((currentConversation) => {
10041
+ const lastMessage = currentConversation[currentConversation.length - 1];
10042
+ const contentArray = Array.isArray(lastMessage.content) ? lastMessage.content : [{ type: "text", text: lastMessage.content }];
10043
+ const newMessage = {
10044
+ ...lastMessage,
10045
+ content: contentArray.map((part) => {
10046
+ if (part.type === "tool-call") {
10047
+ const messages = part.args?.__mastraMetadata?.messages || [];
10048
+ const next = {
10049
+ ...part,
10050
+ toolName: part?.entityName || entityName,
10051
+ args: {
10052
+ ...part.args,
10053
+ __mastraMetadata: {
10054
+ ...part.args?.__mastraMetadata,
10055
+ isStreaming: true,
10056
+ messages: [
10057
+ ...messages.slice(0, -1),
10058
+ {
10059
+ ...messages[messages.length - 1],
10060
+ type: "tool",
10061
+ toolName: agentChunk.payload.toolName,
10062
+ args: agentChunk.payload.args,
10063
+ toolOutput: agentChunk.payload.result
10064
+ }
10065
+ ]
10066
+ }
10067
+ }
10068
+ };
10069
+ return next;
10070
+ }
10071
+ return part;
10072
+ })
10073
+ };
10074
+ return [...currentConversation.slice(0, -1), newMessage];
10075
+ });
10076
+ break;
10077
+ }
10078
+ case "tool-call": {
10079
+ setMessages((currentConversation) => {
10080
+ const lastMessage = currentConversation[currentConversation.length - 1];
10081
+ const contentArray = Array.isArray(lastMessage.content) ? lastMessage.content : [{ type: "text", text: lastMessage.content }];
10082
+ const newMessage = {
10083
+ ...lastMessage,
10084
+ content: contentArray.map((part) => {
10085
+ if (part.type === "tool-call") {
10086
+ const messages = part.args?.__mastraMetadata?.messages || [];
10087
+ const next = {
10088
+ ...part,
10089
+ toolName: part?.entityName || entityName,
10090
+ args: {
10091
+ ...part.args,
10092
+ __mastraMetadata: {
10093
+ ...part.args?.__mastraMetadata,
10094
+ isStreaming: true,
10095
+ messages: [
10096
+ ...messages,
10097
+ {
10098
+ type: "tool",
10099
+ toolCallId: agentChunk.payload.toolCallId,
10100
+ toolName: agentChunk.payload.toolName,
10101
+ args: {
10102
+ ...agentChunk.payload.args,
10103
+ __mastraMetadata: {
10104
+ ...agentChunk.payload.args?.__mastraMetadata,
10105
+ isStreaming: true
10106
+ }
10107
+ }
10108
+ }
10109
+ ]
10110
+ }
10111
+ }
10112
+ };
10113
+ return next;
10114
+ }
10115
+ return part;
10116
+ })
10117
+ };
10118
+ return [...currentConversation.slice(0, -1), newMessage];
10119
+ });
10120
+ break;
10121
+ }
10122
+ case "text-delta": {
10123
+ setMessages((currentConversation) => {
10124
+ const lastMessage = currentConversation[currentConversation.length - 1];
10125
+ const contentArray = Array.isArray(lastMessage.content) ? lastMessage.content : [{ type: "text", text: lastMessage.content }];
10126
+ const newMessage = {
10127
+ ...lastMessage,
10128
+ content: contentArray.map((part) => {
10129
+ if (part.type === "tool-call") {
10130
+ const messages = part.args?.__mastraMetadata?.messages || [];
10131
+ const lastMastraMessage = messages[messages.length - 1];
10132
+ const nextMessages = lastMastraMessage?.type === "text" ? [
10133
+ ...messages.slice(0, -1),
10134
+ { type: "text", content: (lastMastraMessage?.content || "") + agentChunk.payload.text }
10135
+ ] : [...messages, { type: "text", content: agentChunk.payload.text }];
10136
+ return {
10137
+ ...part,
10138
+ toolName: part?.entityName || entityName,
10139
+ args: {
10140
+ ...part.args,
10141
+ __mastraMetadata: {
10142
+ ...part.args?.__mastraMetadata,
10143
+ isStreaming: true,
10144
+ messages: nextMessages
10145
+ }
10146
+ }
10147
+ };
10148
+ }
10149
+ return part;
10150
+ })
10151
+ };
10152
+ return [...currentConversation.slice(0, -1), newMessage];
10153
+ });
10154
+ break;
10155
+ }
10156
+ case "tool-output": {
10157
+ flushSync(() => {
10158
+ setMessages((currentConversation) => {
10159
+ if (!agentChunk.payload.output.type.startsWith("workflow-")) return currentConversation;
10160
+ const lastMessage = currentConversation[currentConversation.length - 1];
10161
+ const contentArray = Array.isArray(lastMessage.content) ? lastMessage.content : [{ type: "text", text: lastMessage.content }];
10162
+ const newMessage = {
10163
+ ...lastMessage,
10164
+ content: contentArray.map((part) => {
10165
+ if (part.type === "tool-call") {
10166
+ const messages = part.args?.__mastraMetadata?.messages || [];
10167
+ const lastMastraMessage = messages[messages.length - 1];
10168
+ const nextMessages = lastMastraMessage?.type === "tool" ? [
10169
+ ...messages.slice(0, -1),
10170
+ {
10171
+ ...lastMastraMessage,
10172
+ args: {
10173
+ ...agentChunk.payload.args,
10174
+ __mastraMetadata: {
10175
+ ...agentChunk.payload.args?.__mastraMetadata,
10176
+ workflowFullState: mapWorkflowStreamChunkToWatchResult(
10177
+ lastMastraMessage.args?.__mastraMetadata?.workflowFullState || {},
10178
+ agentChunk.payload.output
10179
+ ),
10180
+ isStreaming: true
10181
+ }
10182
+ }
10183
+ }
10184
+ ] : messages;
10185
+ return {
10186
+ ...part,
10187
+ toolName: part?.entityName || entityName,
10188
+ args: {
10189
+ ...part.args,
10190
+ __mastraMetadata: {
10191
+ ...part.args?.__mastraMetadata,
10192
+ isStreaming: true,
10193
+ messages: nextMessages
10194
+ }
10195
+ }
10196
+ };
10197
+ }
10198
+ return part;
10199
+ })
10200
+ };
10201
+ return [...currentConversation.slice(0, -1), newMessage];
10202
+ });
10203
+ });
10204
+ break;
10205
+ }
10206
+ }
10207
+ };
10208
+ const createRootToolAssistantMessage = ({
10209
+ chunk,
10210
+ entityName,
10211
+ setMessages,
10212
+ runId,
10213
+ _sideEffects,
10214
+ from,
10215
+ networkMetadata
10216
+ }) => {
10217
+ setMessages((currentConversation) => {
10218
+ if (!entityName || !runId) return currentConversation;
10219
+ const newMessage = {
10220
+ role: "assistant",
10221
+ content: [
10222
+ { type: "text", text: _sideEffects.content },
10223
+ {
10224
+ type: "tool-call",
10225
+ toolCallId: runId,
10226
+ toolName: entityName,
10227
+ args: {
10228
+ ...chunk?.payload?.args,
10229
+ __mastraMetadata: {
10230
+ from,
10231
+ networkMetadata,
10232
+ ...chunk.payload.args?.__mastraMetadata,
10233
+ isStreaming: true
10234
+ }
10235
+ }
10236
+ }
10237
+ ]
10238
+ };
10239
+ _sideEffects.assistantToolCallAddedForUpdater = true;
10240
+ _sideEffects.assistantToolCallAddedForContent = true;
10241
+ return [...currentConversation, newMessage];
10242
+ });
10243
+ };
10244
+
10245
+ const convertMessage$2 = (message) => {
10246
+ return message;
10247
+ };
10248
+ const handleFinishReason = (finishReason) => {
10249
+ switch (finishReason) {
10250
+ case "tool-calls":
10251
+ throw new Error("Stream finished with reason tool-calls, try increasing maxSteps");
10252
+ }
10253
+ };
10254
+ const convertToAIAttachments = async (attachments) => {
10255
+ const promises = (attachments ?? []).filter((attachment) => attachment.type === "image" || attachment.type === "document").map(async (attachment) => {
10256
+ const isFileFromURL = attachment.name.startsWith("https://");
10257
+ if (attachment.type === "document") {
10258
+ if (attachment.contentType === "application/pdf") {
10259
+ const pdfText = attachment.content?.[0]?.text || "";
9588
10260
  return {
9589
10261
  role: "user",
9590
10262
  content: [
@@ -9644,7 +10316,7 @@ function MastraRuntimeProvider({
9644
10316
  instructions,
9645
10317
  chatWithGenerate,
9646
10318
  chatWithGenerateVNext,
9647
- chatWithStreamVNext,
10319
+ chatWithNetwork,
9648
10320
  providerOptions
9649
10321
  } = settings?.modelSettings ?? {};
9650
10322
  const toolCallIdToName = useRef({});
@@ -9657,6 +10329,14 @@ function MastraRuntimeProvider({
9657
10329
  if (messages.length === 0 || currentThreadId !== threadId || hasNewInitialMessages && currentThreadId === threadId) {
9658
10330
  if (initialMessages && threadId && memory) {
9659
10331
  const convertedMessages = initialMessages?.map((message) => {
10332
+ let content;
10333
+ try {
10334
+ content = JSON.parse(message.content);
10335
+ if (content.isNetwork) {
10336
+ return handleNetworkMessageFromMemory(content);
10337
+ }
10338
+ } catch (e) {
10339
+ }
9660
10340
  const attachmentsAsContentParts = (message.experimental_attachments || []).map((image) => ({
9661
10341
  type: image.contentType.startsWith(`image/`) ? "image" : image.contentType.startsWith(`audio/`) ? "audio" : "file",
9662
10342
  mimeType: image.contentType,
@@ -9803,63 +10483,15 @@ function MastraRuntimeProvider({
9803
10483
  }
9804
10484
  };
9805
10485
  if (modelVersion === "v2") {
9806
- if (chatWithGenerateVNext) {
9807
- const response = await agent.generateVNext({
10486
+ if (chatWithNetwork) {
10487
+ const response = await agent.network({
9808
10488
  messages: [
9809
10489
  {
9810
10490
  role: "user",
9811
10491
  content: input
9812
- },
9813
- ...attachments
9814
- ],
9815
- runId: agentId,
9816
- modelSettings: {
9817
- frequencyPenalty,
9818
- presencePenalty,
9819
- maxRetries,
9820
- temperature,
9821
- topK,
9822
- topP,
9823
- maxOutputTokens: maxTokens
9824
- },
9825
- providerOptions,
9826
- instructions,
9827
- runtimeContext: runtimeContextInstance,
9828
- ...memory ? { threadId, resourceId: agentId } : {}
9829
- });
9830
- handleGenerateResponse(response);
9831
- setIsRunning(false);
9832
- return;
9833
- } else {
9834
- let updater = function() {
9835
- setMessages((currentConversation) => {
9836
- const message2 = {
9837
- role: "assistant",
9838
- content: [{ type: "text", text: content }]
9839
- };
9840
- if (!assistantMessageAdded) {
9841
- assistantMessageAdded = true;
9842
- if (assistantToolCallAddedForUpdater) {
9843
- assistantToolCallAddedForUpdater = false;
9844
- }
9845
- return [...currentConversation, message2];
9846
10492
  }
9847
- if (assistantToolCallAddedForUpdater) {
9848
- assistantToolCallAddedForUpdater = false;
9849
- return [...currentConversation, message2];
9850
- }
9851
- return [...currentConversation.slice(0, -1), message2];
9852
- });
9853
- };
9854
- const response = await agent.streamVNext({
9855
- messages: [
9856
- {
9857
- role: "user",
9858
- content: input
9859
- },
9860
- ...attachments
9861
10493
  ],
9862
- runId: agentId,
10494
+ maxSteps,
9863
10495
  modelSettings: {
9864
10496
  frequencyPenalty,
9865
10497
  presencePenalty,
@@ -9869,203 +10501,159 @@ function MastraRuntimeProvider({
9869
10501
  topK,
9870
10502
  topP
9871
10503
  },
9872
- instructions,
10504
+ runId: agentId,
9873
10505
  runtimeContext: runtimeContextInstance,
9874
- ...memory ? { threadId, resourceId: agentId } : {},
9875
- providerOptions
10506
+ ...memory ? { thread: threadId, resourceId: agentId } : {}
9876
10507
  });
9877
- if (!response.body) {
9878
- throw new Error("No response body");
9879
- }
9880
- let content = "";
9881
- let assistantMessageAdded = false;
9882
- let assistantToolCallAddedForUpdater = false;
9883
- let assistantToolCallAddedForContent = false;
10508
+ const _sideEffects = {
10509
+ assistantMessageAdded: false,
10510
+ assistantToolCallAddedForUpdater: false,
10511
+ assistantToolCallAddedForContent: false,
10512
+ content: "",
10513
+ toolCallIdToName
10514
+ };
10515
+ let currentEntityId;
9884
10516
  await response.processDataStream({
9885
10517
  onChunk: async (chunk) => {
9886
- switch (chunk.type) {
9887
- case "text-delta": {
9888
- if (assistantToolCallAddedForContent) {
9889
- assistantToolCallAddedForContent = false;
9890
- content = chunk.payload.text;
9891
- } else {
9892
- content += chunk.payload.text;
9893
- }
9894
- updater();
9895
- break;
9896
- }
9897
- case "tool-output": {
9898
- if (!chunk.payload.output?.type.startsWith("workflow-")) return;
9899
- flushSync(() => {
9900
- setMessages((currentConversation) => {
9901
- const lastMessage = currentConversation[currentConversation.length - 1];
9902
- const contentArray = Array.isArray(lastMessage.content) ? lastMessage.content : [{ type: "text", text: lastMessage.content }];
9903
- const newMessage = {
9904
- ...lastMessage,
9905
- content: contentArray.map((part) => {
9906
- if (part.type === "tool-call") {
9907
- return {
9908
- ...part,
9909
- ...chunk.payload,
9910
- args: {
9911
- ...part.args,
9912
- __mastraMetadata: {
9913
- ...part.args?.__mastraMetadata,
9914
- partialChunk: chunk?.payload?.output,
9915
- isStreaming: true
9916
- }
9917
- }
9918
- };
9919
- }
9920
- return part;
9921
- })
9922
- };
9923
- return [...currentConversation.slice(0, -1), newMessage];
9924
- });
9925
- });
9926
- break;
9927
- }
9928
- case "tool-call": {
9929
- setMessages((currentConversation) => {
9930
- const lastMessage = currentConversation[currentConversation.length - 1];
9931
- if (lastMessage && lastMessage.role === "assistant") {
9932
- const updatedMessage = {
9933
- ...lastMessage,
9934
- content: Array.isArray(lastMessage.content) ? [
9935
- ...lastMessage.content,
9936
- {
9937
- type: "tool-call",
9938
- toolCallId: chunk.payload.toolCallId,
9939
- toolName: chunk.payload.toolName,
9940
- args: {
9941
- ...chunk.payload.args,
9942
- __mastraMetadata: {
9943
- ...chunk.payload.args?.__mastraMetadata,
9944
- isStreaming: true
9945
- }
9946
- }
9947
- }
9948
- ] : [
9949
- ...typeof lastMessage.content === "string" ? [{ type: "text", text: lastMessage.content }] : [],
9950
- {
9951
- type: "tool-call",
9952
- toolCallId: chunk.payload.toolCallId,
9953
- toolName: chunk.payload.toolName,
9954
- args: {
9955
- ...chunk.payload.args,
9956
- __mastraMetadata: {
9957
- ...chunk.payload.args?.__mastraMetadata,
9958
- isStreaming: true
9959
- }
9960
- }
9961
- }
9962
- ]
9963
- };
9964
- assistantToolCallAddedForUpdater = true;
9965
- assistantToolCallAddedForContent = true;
9966
- return [...currentConversation.slice(0, -1), updatedMessage];
9967
- }
9968
- const newMessage = {
9969
- role: "assistant",
9970
- content: [
9971
- { type: "text", text: content },
9972
- {
9973
- type: "tool-call",
9974
- toolCallId: chunk.payload.toolCallId,
9975
- toolName: chunk.payload.toolName,
9976
- args: {
9977
- ...chunk.payload.args,
9978
- __mastraMetadata: { ...chunk.payload.args?.__mastraMetadata, isStreaming: true }
10518
+ if (chunk.type.startsWith("agent-execution-event-")) {
10519
+ const agentChunk = chunk.payload;
10520
+ if (!currentEntityId) return;
10521
+ await handleAgentChunk({ agentChunk, setMessages, entityName: currentEntityId });
10522
+ } else if (chunk.type === "tool-execution-start") {
10523
+ await handleStreamChunk({
10524
+ chunk: {
10525
+ ...chunk,
10526
+ type: "tool-call",
10527
+ payload: {
10528
+ ...chunk?.payload,
10529
+ toolCallId: chunk?.payload?.args?.toolCallId,
10530
+ toolName: chunk?.payload?.args?.toolName,
10531
+ args: {
10532
+ ...chunk?.payload?.args?.args,
10533
+ __mastraMetadata: {
10534
+ ...chunk?.payload?.args?.__mastraMetadata,
10535
+ networkMetadata: {
10536
+ selectionReason: chunk?.payload?.args?.selectionReason || "",
10537
+ input: chunk?.payload?.args?.args
9979
10538
  }
9980
10539
  }
9981
- ]
9982
- };
9983
- assistantToolCallAddedForUpdater = true;
9984
- assistantToolCallAddedForContent = true;
9985
- return [...currentConversation, newMessage];
9986
- });
9987
- toolCallIdToName.current[chunk.payload.toolCallId] = chunk.payload.toolName;
9988
- break;
9989
- }
9990
- case "tool-result": {
9991
- setMessages((currentConversation) => {
9992
- const lastMessage = currentConversation[currentConversation.length - 1];
9993
- if (lastMessage && lastMessage.role === "assistant" && Array.isArray(lastMessage.content)) {
9994
- const updatedContent = lastMessage.content.map((part) => {
9995
- if (typeof part === "object" && part.type === "tool-call" && part.toolCallId === chunk.payload.toolCallId) {
9996
- return {
9997
- ...part,
9998
- result: chunk.payload.result
9999
- };
10000
- }
10001
- return part;
10002
- });
10003
- const updatedMessage = {
10004
- ...lastMessage,
10005
- content: updatedContent
10006
- };
10007
- return [...currentConversation.slice(0, -1), updatedMessage];
10008
- }
10009
- return currentConversation;
10010
- });
10011
- try {
10012
- const toolName = toolCallIdToName.current[chunk.payload.toolCallId];
10013
- if (toolName === "updateWorkingMemory" && chunk.payload.result?.success) {
10014
- await refreshWorkingMemory?.();
10540
+ }
10015
10541
  }
10016
- } finally {
10017
- delete toolCallIdToName.current[chunk.payload.toolCallId];
10018
- }
10019
- break;
10020
- }
10021
- case "error": {
10022
- if (typeof chunk.payload.error === "string") {
10023
- throw new Error(chunk.payload.error);
10542
+ },
10543
+ setMessages,
10544
+ refreshWorkingMemory,
10545
+ _sideEffects
10546
+ });
10547
+ } else if (chunk.type === "tool-execution-end") {
10548
+ await handleStreamChunk({
10549
+ chunk: { ...chunk, type: "tool-result" },
10550
+ setMessages,
10551
+ refreshWorkingMemory,
10552
+ _sideEffects
10553
+ });
10554
+ } else if (chunk.type.startsWith("workflow-execution-event-")) {
10555
+ const workflowChunk = chunk.payload;
10556
+ if (!currentEntityId) return;
10557
+ await handleWorkflowChunk({ workflowChunk, setMessages, entityName: currentEntityId });
10558
+ } else if (chunk.type === "workflow-execution-start" || chunk.type === "agent-execution-start") {
10559
+ currentEntityId = chunk.payload?.args?.resourceId;
10560
+ const runId = chunk.payload.runId;
10561
+ if (!currentEntityId || !runId) return;
10562
+ createRootToolAssistantMessage({
10563
+ entityName: currentEntityId,
10564
+ setMessages,
10565
+ runId,
10566
+ _sideEffects,
10567
+ chunk,
10568
+ from: chunk.type === "agent-execution-start" ? "AGENT" : "WORKFLOW",
10569
+ networkMetadata: {
10570
+ selectionReason: chunk?.payload?.args?.selectionReason || "",
10571
+ input: chunk?.payload?.args?.prompt
10024
10572
  }
10025
- break;
10026
- }
10027
- case "finish": {
10028
- handleFinishReason(chunk.payload.finishReason);
10029
- break;
10030
- }
10031
- case "reasoning-delta": {
10032
- setMessages((currentConversation) => {
10033
- const lastMessage = currentConversation[currentConversation.length - 1];
10034
- if (lastMessage && lastMessage.role === "assistant" && Array.isArray(lastMessage.content)) {
10035
- const updatedContent = lastMessage.content.map((part) => {
10036
- if (typeof part === "object" && part.type === "reasoning") {
10037
- return {
10038
- ...part,
10039
- text: part.text + chunk.payload.text
10040
- };
10041
- }
10042
- return part;
10043
- });
10044
- const updatedMessage = {
10045
- ...lastMessage,
10046
- content: updatedContent
10047
- };
10048
- return [...currentConversation.slice(0, -1), updatedMessage];
10049
- }
10050
- const newMessage = {
10051
- role: "assistant",
10052
- content: [
10053
- {
10054
- type: "reasoning",
10055
- text: chunk.payload.text
10056
- },
10057
- { type: "text", text: content }
10058
- ]
10059
- };
10060
- return [...currentConversation, newMessage];
10061
- });
10062
- break;
10063
- }
10573
+ });
10574
+ _sideEffects.toolCallIdToName.current[runId] = currentEntityId;
10575
+ } else if (chunk.type === "network-execution-event-step-finish") {
10576
+ setMessages((currentConversation) => {
10577
+ return [
10578
+ ...currentConversation,
10579
+ { role: "assistant", content: [{ type: "text", text: chunk?.payload?.result || "" }] }
10580
+ ];
10581
+ });
10582
+ } else {
10583
+ await handleStreamChunk({ chunk, setMessages, refreshWorkingMemory, _sideEffects });
10064
10584
  }
10065
10585
  }
10066
10586
  });
10067
- setIsRunning(false);
10068
- return;
10587
+ } else {
10588
+ if (chatWithGenerateVNext) {
10589
+ const response = await agent.generateVNext({
10590
+ messages: [
10591
+ {
10592
+ role: "user",
10593
+ content: input
10594
+ },
10595
+ ...attachments
10596
+ ],
10597
+ runId: agentId,
10598
+ modelSettings: {
10599
+ frequencyPenalty,
10600
+ presencePenalty,
10601
+ maxRetries,
10602
+ temperature,
10603
+ topK,
10604
+ topP,
10605
+ maxOutputTokens: maxTokens
10606
+ },
10607
+ providerOptions,
10608
+ instructions,
10609
+ runtimeContext: runtimeContextInstance,
10610
+ ...memory ? { threadId, resourceId: agentId } : {}
10611
+ });
10612
+ handleGenerateResponse(response);
10613
+ setIsRunning(false);
10614
+ return;
10615
+ } else {
10616
+ const response = await agent.streamVNext({
10617
+ messages: [
10618
+ {
10619
+ role: "user",
10620
+ content: input
10621
+ },
10622
+ ...attachments
10623
+ ],
10624
+ runId: agentId,
10625
+ modelSettings: {
10626
+ frequencyPenalty,
10627
+ presencePenalty,
10628
+ maxRetries,
10629
+ maxOutputTokens: maxTokens,
10630
+ temperature,
10631
+ topK,
10632
+ topP
10633
+ },
10634
+ instructions,
10635
+ runtimeContext: runtimeContextInstance,
10636
+ ...memory ? { threadId, resourceId: agentId } : {},
10637
+ providerOptions
10638
+ });
10639
+ if (!response.body) {
10640
+ throw new Error("No response body");
10641
+ }
10642
+ const _sideEffects = {
10643
+ assistantMessageAdded: false,
10644
+ assistantToolCallAddedForUpdater: false,
10645
+ assistantToolCallAddedForContent: false,
10646
+ content: "",
10647
+ toolCallIdToName
10648
+ };
10649
+ await response.processDataStream({
10650
+ onChunk: async (chunk) => {
10651
+ await handleStreamChunk({ chunk, setMessages, refreshWorkingMemory, _sideEffects });
10652
+ }
10653
+ });
10654
+ setIsRunning(false);
10655
+ return;
10656
+ }
10069
10657
  }
10070
10658
  } else {
10071
10659
  if (chatWithGenerate) {
@@ -10448,7 +11036,6 @@ const AgentChat = ({
10448
11036
  initialMessages,
10449
11037
  memory,
10450
11038
  refreshThreadList,
10451
- onInputChange,
10452
11039
  modelVersion
10453
11040
  }) => {
10454
11041
  const { settings } = useAgentSettings();
@@ -10465,7 +11052,7 @@ const AgentChat = ({
10465
11052
  refreshThreadList,
10466
11053
  settings,
10467
11054
  runtimeContext,
10468
- children: /* @__PURE__ */ jsx(Thread, { agentName: agentName ?? "", hasMemory: memory, onInputChange, agentId })
11055
+ children: /* @__PURE__ */ jsx(Thread, { agentName: agentName ?? "", hasMemory: memory, agentId })
10469
11056
  }
10470
11057
  );
10471
11058
  };
@@ -11072,7 +11659,11 @@ const AgentSettings = ({ modelVersion }) => {
11072
11659
  const { settings, setSettings, resetAll } = useAgentSettings();
11073
11660
  let radioValue;
11074
11661
  if (modelVersion === "v2") {
11075
- radioValue = settings?.modelSettings?.chatWithGenerateVNext ? "generateVNext" : "streamVNext";
11662
+ if (settings?.modelSettings?.chatWithNetwork) {
11663
+ radioValue = "network";
11664
+ } else {
11665
+ radioValue = settings?.modelSettings?.chatWithGenerateVNext ? "generateVNext" : "streamVNext";
11666
+ }
11076
11667
  } else {
11077
11668
  radioValue = settings?.modelSettings?.chatWithGenerate ? "generate" : "stream";
11078
11669
  }
@@ -11089,7 +11680,8 @@ const AgentSettings = ({ modelVersion }) => {
11089
11680
  ...settings?.modelSettings,
11090
11681
  chatWithGenerate: value === "generate",
11091
11682
  chatWithGenerateVNext: value === "generateVNext",
11092
- chatWithStreamVNext: value === "streamVNext"
11683
+ chatWithStreamVNext: value === "streamVNext",
11684
+ chatWithNetwork: value === "network"
11093
11685
  }
11094
11686
  }),
11095
11687
  className: "flex flex-row gap-4",
@@ -11109,6 +11701,10 @@ const AgentSettings = ({ modelVersion }) => {
11109
11701
  modelVersion === "v2" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
11110
11702
  /* @__PURE__ */ jsx(RadioGroupItem, { value: "streamVNext", id: "streamVNext", className: "text-icon6" }),
11111
11703
  /* @__PURE__ */ jsx(Label, { className: "text-icon6 text-ui-md", htmlFor: "streamVNext", children: "Stream vNext" })
11704
+ ] }),
11705
+ modelVersion === "v2" && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
11706
+ /* @__PURE__ */ jsx(RadioGroupItem, { value: "network", id: "network", className: "text-icon6" }),
11707
+ /* @__PURE__ */ jsx(Label, { className: "text-icon6 text-ui-md", htmlFor: "network", children: "Network" })
11112
11708
  ] })
11113
11709
  ]
11114
11710
  }
@@ -12242,10 +12838,18 @@ const AgentMetadataModelSwitcher = ({
12242
12838
  ] }) });
12243
12839
  };
12244
12840
 
12841
+ const AgentMetadataNetworkList = ({ agents, computeAgentLink }) => {
12842
+ const { Link } = useLinkComponent();
12843
+ if (agents.length === 0) {
12844
+ return /* @__PURE__ */ jsx(AgentMetadataListEmpty, { children: "No tools" });
12845
+ }
12846
+ return /* @__PURE__ */ jsx(AgentMetadataList, { children: agents.map((agent) => /* @__PURE__ */ jsx(AgentMetadataListItem, { children: /* @__PURE__ */ jsx(Link, { href: computeAgentLink(agent), children: /* @__PURE__ */ jsx(Badge$1, { variant: "success", icon: /* @__PURE__ */ jsx(AgentIcon, {}), children: agent.name }) }) }, agent.id)) });
12847
+ };
12245
12848
  const AgentMetadata = ({
12246
12849
  agent,
12247
12850
  promptSlot,
12248
12851
  hasMemoryEnabled,
12852
+ computeAgentLink,
12249
12853
  computeToolLink,
12250
12854
  computeWorkflowLink,
12251
12855
  updateModel,
@@ -12253,6 +12857,8 @@ const AgentMetadata = ({
12253
12857
  }) => {
12254
12858
  const [isEditingModel, setIsEditingModel] = useState(false);
12255
12859
  const providerIcon = providerMapToIcon[agent.provider || "openai.chat"];
12860
+ const networkAgentsMap = agent.agents ?? {};
12861
+ const networkAgents = Object.values(networkAgentsMap);
12256
12862
  const agentTools = agent.tools ?? {};
12257
12863
  const tools = Object.keys(agentTools).map((key) => agentTools[key]);
12258
12864
  const agentWorkflows = agent.workflows ?? {};
@@ -12269,7 +12875,16 @@ const AgentMetadata = ({
12269
12875
  }
12270
12876
  ) : /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
12271
12877
  /* @__PURE__ */ jsx(Badge$1, { icon: providerIcon, className: "font-medium", children: agent.modelId || "N/A" }),
12272
- /* @__PURE__ */ jsx("button", { onClick: () => setIsEditingModel(true), className: "text-icon3 hover:text-icon6", children: /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(EditIcon, {}) }) })
12878
+ /* @__PURE__ */ jsx(
12879
+ "button",
12880
+ {
12881
+ title: "Edit model",
12882
+ type: "button",
12883
+ onClick: () => setIsEditingModel(true),
12884
+ className: "text-icon3 hover:text-icon6",
12885
+ children: /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(EditIcon, {}) })
12886
+ }
12887
+ )
12273
12888
  ] }) }),
12274
12889
  /* @__PURE__ */ jsx(
12275
12890
  AgentMetadataSection,
@@ -12282,6 +12897,17 @@ const AgentMetadata = ({
12282
12897
  children: /* @__PURE__ */ jsx(Badge$1, { icon: /* @__PURE__ */ jsx(MemoryIcon, {}), variant: hasMemoryEnabled ? "success" : "error", className: "font-medium", children: hasMemoryEnabled ? "On" : "Off" })
12283
12898
  }
12284
12899
  ),
12900
+ networkAgents.length > 0 && /* @__PURE__ */ jsx(
12901
+ AgentMetadataSection,
12902
+ {
12903
+ title: "Agents",
12904
+ hint: {
12905
+ link: "https://mastra.ai/en/docs/agents/overview",
12906
+ title: "Agents documentation"
12907
+ },
12908
+ children: /* @__PURE__ */ jsx(AgentMetadataNetworkList, { agents: networkAgents, computeAgentLink })
12909
+ }
12910
+ ),
12285
12911
  /* @__PURE__ */ jsx(
12286
12912
  AgentMetadataSection,
12287
12913
  {
@@ -15749,42 +16375,31 @@ function TemplateInfo({
15749
16375
  }) {
15750
16376
  const branchName = templateSlug ? `feat/install-template-${templateSlug}` : "feat/install-template-[slug]";
15751
16377
  return /* @__PURE__ */ jsxs(Fragment, { children: [
15752
- /* @__PURE__ */ jsxs("div", { className: cn("grid lg:grid-cols-[1fr_1fr] gap-x-[6rem] mt-[2rem] lg:min-h-[4rem] items-center "), children: [
15753
- /* @__PURE__ */ jsxs(
15754
- "div",
15755
- {
15756
- className: cn(
15757
- "text-[1.5rem] flex items-center gap-[0.75rem] ",
15758
- "[&>svg]:w-[1.2em] [&>svg]:h-[1.2em] [&>svg]:opacity-50",
16378
+ /* @__PURE__ */ jsx("div", { className: cn("grid mt-[2rem] items-center"), children: /* @__PURE__ */ jsxs(
16379
+ "div",
16380
+ {
16381
+ className: cn(
16382
+ "text-[1.5rem] flex items-center gap-[0.75rem]",
16383
+ "[&>svg]:w-[1.2em] [&>svg]:h-[1.2em] [&>svg]:opacity-50",
16384
+ {
16385
+ "[&>svg]:opacity-20": isLoading
16386
+ }
16387
+ ),
16388
+ children: [
16389
+ /* @__PURE__ */ jsx(PackageIcon, {}),
16390
+ /* @__PURE__ */ jsx(
16391
+ "h2",
15759
16392
  {
15760
- "[&>svg]:opacity-20": isLoading
16393
+ className: cn({
16394
+ "bg-surface4 flex rounded-lg min-w-[50%]": isLoading
16395
+ }),
16396
+ children: isLoading ? /* @__PURE__ */ jsx(Fragment, { children: " " }) : title
15761
16397
  }
15762
- ),
15763
- children: [
15764
- /* @__PURE__ */ jsx(PackageIcon, {}),
15765
- /* @__PURE__ */ jsx(
15766
- "h2",
15767
- {
15768
- className: cn({
15769
- "bg-surface4 flex rounded-lg min-w-[50%]": isLoading
15770
- }),
15771
- children: isLoading ? /* @__PURE__ */ jsx(Fragment, { children: " " }) : title
15772
- }
15773
- )
15774
- ]
15775
- }
15776
- ),
15777
- /* @__PURE__ */ jsx(
15778
- "div",
15779
- {
15780
- className: "w-full h-full bg-cover bg-center transition-scale duration-150 rounded-lg overflow-hidden min-h-[2rem] mt-[2rem] lg:mt-0",
15781
- style: {
15782
- backgroundImage: `url(${imageURL})`
15783
- }
15784
- }
15785
- )
15786
- ] }),
15787
- /* @__PURE__ */ jsxs("div", { className: "grid lg:grid-cols-[1fr_1fr] gap-x-[6rem] mt-[2rem] ", children: [
16398
+ )
16399
+ ]
16400
+ }
16401
+ ) }),
16402
+ /* @__PURE__ */ jsxs("div", { className: "grid lg:grid-cols-[1fr_1fr] gap-x-[6rem] ", children: [
15788
16403
  /* @__PURE__ */ jsxs("div", { className: "grid", children: [
15789
16404
  /* @__PURE__ */ jsx(
15790
16405
  "p",
@@ -18382,5 +18997,5 @@ const MemorySearch = ({
18382
18997
  ] });
18383
18998
  };
18384
18999
 
18385
- export { AgentChat, AgentCoinIcon, AgentEntityHeader, AgentEvals, AgentIcon, AgentMetadata, AgentMetadataList, AgentMetadataListEmpty, AgentMetadataListItem, AgentMetadataPrompt, AgentMetadataScorerList, AgentMetadataSection, AgentMetadataToolList, AgentMetadataWorkflowList, AgentMetadataWrapper, AgentNetworkCoinIcon, AgentSettings, AgentSettingsContext, AgentSettingsProvider, AgentsTable, AgentsTableSkeleton, AiIcon, AlertDialog, ApiIcon, Badge$1 as Badge, BranchIcon, Breadcrumb, Button$1 as Button, Cell, ChatThreads, CheckIcon, ChevronIcon, Collapsible, CollapsibleContent, CollapsibleTrigger, CommitIcon, CrossIcon, Crumb, DarkLogo, DataTable, DateTimeCell, DateTimePicker, DateTimePickerContent, DbIcon, DebugIcon, DefaultTrigger, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EmptyAgentsTable, EmptyScorerList, EmptyState, EmptyWorkflowsTable, Entity, EntityContent, EntityDescription, EntityHeader, EntityIcon, EntityMainHeader, EntityName, Entry, EntryCell, EntryList, EntryListItem, EntryListPageHeader, EntryListStatusCell, EntryListTextCell, EntryListToolbar, EnvIcon, EvaluatorCoinIcon, FiltersIcon, FolderIcon, FormActions, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, InputField, JudgeIcon, Kbd, KeyValueList, LatencyIcon, LegacyWorkflowGraph, LegacyWorkflowTrigger, LinkComponentProvider, LogsIcon, MainContentContent, MainContentLayout, MastraClientProvider, MastraResizablePanel, McpCoinIcon, McpServerIcon, MemoryIcon, MemorySearch, NetworkChat, NetworkContext, NetworkProvider, NetworkTable, NetworkTableEmpty, NetworkTableSkeleton, OpenAIIcon, PageHeader, PlaygroundQueryClient, PlaygroundTabs, PromptIcon, RadioGroup, RadioGroupField, RadioGroupItem, RepoIcon, Row, RuntimeContext, RuntimeContextWrapper, ScoreIcon, ScorerList, ScorerSkeleton, SearchField, Searchbar, SelectField, SettingsIcon, SideDialog, SideDialogCodeSection, SideDialogContent, SideDialogFooter, SideDialogFooterGroup, SideDialogHeader, SideDialogHeading, SideDialogKeyValueList, SideDialogSection, SideDialogTop, SlashIcon, SliderField, Tab, TabContent, TabList, Table$1 as Table, Tbody, TemplateFailure, TemplateForm, TemplateInfo, TemplateInstallation, TemplateSuccess, TemplatesList, TemplatesTools, TextAndIcon, TextareaField, Th, Thead, ThreadDeleteButton, ThreadItem, ThreadLink, ThreadList, Threads, ToolCoinIcon, ToolList, ToolListEmpty, ToolListSkeleton, ToolsIcon, TraceDialog, TraceIcon, TraceTimeline, TraceTimelineLegend, TraceTimelineSpan, TracesTools, TracesView, TracesViewSkeleton, TsIcon, Txt, TxtCell, UnitCell, VNextNetworkChat, VariablesIcon, WorkflowCoinIcon, WorkflowGraph, WorkflowIcon, WorkflowRunContext, WorkflowRunProvider, WorkflowRuns, WorkflowTable, WorkflowTableSkeleton, WorkflowTrigger, WorkingMemoryContext, WorkingMemoryProvider, allowedAiSpanAttributes, cleanString, convertWorkflowRunStateToWatchResult, formatDuration, formatHierarchicalSpans, formatOtelTimestamp, formatOtelTimestamp2, getColumnTemplate, getShortId, getSpanTypeUi, mapWorkflowStreamChunkToWatchResult, providerMapToIcon, spanTypePrefixes, transformKey, useAgentSettings, useCurrentRun, useInView, useLinkComponent, useMastraClient, usePlaygroundStore, usePolling, useScorer, useScorers, useScoresByEntityId, useScoresByScorerId, useSpeechRecognition, useWorkingMemory };
19000
+ export { AgentChat, AgentCoinIcon, AgentEntityHeader, AgentEvals, AgentIcon, AgentMetadata, AgentMetadataList, AgentMetadataListEmpty, AgentMetadataListItem, AgentMetadataNetworkList, AgentMetadataPrompt, AgentMetadataScorerList, AgentMetadataSection, AgentMetadataToolList, AgentMetadataWorkflowList, AgentMetadataWrapper, AgentNetworkCoinIcon, AgentSettings, AgentSettingsContext, AgentSettingsProvider, AgentsTable, AgentsTableSkeleton, AiIcon, AlertDialog, ApiIcon, Badge$1 as Badge, BranchIcon, Breadcrumb, Button$1 as Button, Cell, ChatThreads, CheckIcon, ChevronIcon, Collapsible, CollapsibleContent, CollapsibleTrigger, CommitIcon, CrossIcon, Crumb, DarkLogo, DataTable, DateTimeCell, DateTimePicker, DateTimePickerContent, DbIcon, DebugIcon, DefaultTrigger, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EmptyAgentsTable, EmptyScorerList, EmptyState, EmptyWorkflowsTable, Entity, EntityContent, EntityDescription, EntityHeader, EntityIcon, EntityMainHeader, EntityName, Entry, EntryCell, EntryList, EntryListItem, EntryListPageHeader, EntryListStatusCell, EntryListTextCell, EntryListToolbar, EnvIcon, EvaluatorCoinIcon, FiltersIcon, FolderIcon, FormActions, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, InputField, JudgeIcon, Kbd, KeyValueList, LatencyIcon, LegacyWorkflowGraph, LegacyWorkflowTrigger, LinkComponentProvider, LogsIcon, MainContentContent, MainContentLayout, MastraClientProvider, MastraResizablePanel, McpCoinIcon, McpServerIcon, MemoryIcon, MemorySearch, NetworkChat, NetworkContext, NetworkProvider, NetworkTable, NetworkTableEmpty, NetworkTableSkeleton, OpenAIIcon, PageHeader, PlaygroundQueryClient, PlaygroundTabs, PromptIcon, RadioGroup, RadioGroupField, RadioGroupItem, RepoIcon, Row, RuntimeContext, RuntimeContextWrapper, ScoreIcon, ScorerList, ScorerSkeleton, SearchField, Searchbar, SelectField, SettingsIcon, SideDialog, SideDialogCodeSection, SideDialogContent, SideDialogFooter, SideDialogFooterGroup, SideDialogHeader, SideDialogHeading, SideDialogKeyValueList, SideDialogSection, SideDialogTop, SlashIcon, SliderField, Tab, TabContent, TabList, Table$1 as Table, Tbody, TemplateFailure, TemplateForm, TemplateInfo, TemplateInstallation, TemplateSuccess, TemplatesList, TemplatesTools, TextAndIcon, TextareaField, Th, Thead, ThreadDeleteButton, ThreadInputProvider, ThreadItem, ThreadLink, ThreadList, Threads, ToolCoinIcon, ToolList, ToolListEmpty, ToolListSkeleton, ToolsIcon, TraceDialog, TraceIcon, TraceTimeline, TraceTimelineLegend, TraceTimelineSpan, TracesTools, TracesView, TracesViewSkeleton, TsIcon, Txt, TxtCell, UnitCell, VNextNetworkChat, VariablesIcon, WorkflowCoinIcon, WorkflowGraph, WorkflowIcon, WorkflowRunContext, WorkflowRunProvider, WorkflowRuns, WorkflowTable, WorkflowTableSkeleton, WorkflowTrigger, WorkingMemoryContext, WorkingMemoryProvider, allowedAiSpanAttributes, cleanString, convertWorkflowRunStateToWatchResult, formatDuration, formatHierarchicalSpans, formatOtelTimestamp, formatOtelTimestamp2, getColumnTemplate, getShortId, getSpanTypeUi, mapWorkflowStreamChunkToWatchResult, providerMapToIcon, spanTypePrefixes, transformKey, useAgentSettings, useCurrentRun, useInView, useLinkComponent, useMastraClient, usePlaygroundStore, usePolling, useScorer, useScorers, useScoresByEntityId, useScoresByScorerId, useSpeechRecognition, useThreadInput, useWorkingMemory };
18386
19001
  //# sourceMappingURL=index.es.js.map