@mastra/playground-ui 7.0.0-beta.5 → 7.0.0-beta.6

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
@@ -19,7 +19,7 @@ import CodeMirror, { EditorView as EditorView$1 } from '@uiw/react-codemirror';
19
19
  import { toast as toast$1 } from 'sonner';
20
20
  import './index.css';export { Toaster } from 'sonner';
21
21
  import * as DialogPrimitive from '@radix-ui/react-dialog';
22
- import { useQuery, useMutation, useQueryClient, QueryClient, QueryClientProvider } from '@tanstack/react-query';
22
+ import { useQuery, useMutation, useInfiniteQuery, useQueryClient, QueryClient, QueryClientProvider } from '@tanstack/react-query';
23
23
  export * from '@tanstack/react-query';
24
24
  import { useMastraClient, mapWorkflowStreamChunkToWatchResult, resolveToChildMessages, useChat, toAssistantUIMessage } from '@mastra/react';
25
25
  import { create } from 'zustand';
@@ -40,8 +40,8 @@ import * as PopoverPrimitive from '@radix-ui/react-popover';
40
40
  import * as SelectPrimitive from '@radix-ui/react-select';
41
41
  import { v4 } from '@lukeed/uuid';
42
42
  import { useFormContext, useFieldArray, useForm, FormProvider } from 'react-hook-form';
43
- import { getLabel, parseSchema as parseSchema$1, getDefaultValues as getDefaultValues$1, removeEmptyValues as removeEmptyValues$1 } from '@autoform/core';
44
- import { useAutoForm, getPathInObject, AutoFormProvider, buildZodFieldConfig } from '@autoform/react';
43
+ import { getLabel, parseSchema as parseSchema$1, getDefaultValues as getDefaultValues$1 } from '@autoform/core';
44
+ import { useAutoForm, getPathInObject, buildZodFieldConfig, AutoFormProvider } from '@autoform/react';
45
45
  import z$3, { z, ZodObject, ZodIntersection } from 'zod';
46
46
  import * as LabelPrimitive from '@radix-ui/react-label';
47
47
  import { ZodProvider, getFieldConfigInZodStack } from '@autoform/zod/v4';
@@ -51,7 +51,7 @@ import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
51
51
  import prettier from 'prettier';
52
52
  import prettierPluginBabel from 'prettier/plugins/babel';
53
53
  import prettierPluginEstree from 'prettier/plugins/estree';
54
- import jsonSchemaToZod from 'json-schema-to-zod';
54
+ import { jsonSchemaToZod } from '@mastra/schema-compat/json-to-zod';
55
55
  import { parse } from 'superjson';
56
56
  import * as SliderPrimitive from '@radix-ui/react-slider';
57
57
  import { CodeBlock as CodeBlock$1 } from 'react-code-block';
@@ -4859,6 +4859,50 @@ toast.promise = ({
4859
4859
  });
4860
4860
  };
4861
4861
 
4862
+ function useTracingSettingsState({ entityId, entityType }) {
4863
+ const [settings, setSettingsState] = useState(void 0);
4864
+ const LOCAL_STORAGE_KEY = `tracing-options-${entityType}:${entityId}`;
4865
+ useEffect(() => {
4866
+ try {
4867
+ const stored = localStorage.getItem(LOCAL_STORAGE_KEY);
4868
+ if (stored) {
4869
+ const parsed = JSON.parse(stored);
4870
+ setSettingsState(parsed || void 0);
4871
+ }
4872
+ } catch (e) {
4873
+ console.error(e);
4874
+ }
4875
+ }, [LOCAL_STORAGE_KEY]);
4876
+ const setSettings = (settingsValue) => {
4877
+ setSettingsState((prev) => ({ ...prev, ...settingsValue }));
4878
+ localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify({ ...settingsValue, entityId, entityType }));
4879
+ };
4880
+ const resetAll = () => {
4881
+ setSettingsState(void 0);
4882
+ localStorage.removeItem(LOCAL_STORAGE_KEY);
4883
+ };
4884
+ return {
4885
+ settings,
4886
+ setSettings,
4887
+ resetAll
4888
+ };
4889
+ }
4890
+
4891
+ const TracingSettingsContext = createContext({
4892
+ setSettings: () => {
4893
+ },
4894
+ resetAll: () => {
4895
+ },
4896
+ settings: void 0
4897
+ });
4898
+ const TracingSettingsProvider = ({ children, entityId, entityType }) => {
4899
+ const state = useTracingSettingsState({ entityId, entityType });
4900
+ return /* @__PURE__ */ jsx(TracingSettingsContext.Provider, { value: state, children });
4901
+ };
4902
+ const useTracingSettings = () => {
4903
+ return useContext(TracingSettingsContext);
4904
+ };
4905
+
4862
4906
  const useExecuteWorkflow = () => {
4863
4907
  const client = useMastraClient();
4864
4908
  const createWorkflowRun = useMutation({
@@ -4922,6 +4966,7 @@ const useExecuteWorkflow = () => {
4922
4966
  };
4923
4967
  const useStreamWorkflow = () => {
4924
4968
  const client = useMastraClient();
4969
+ const { settings } = useTracingSettings();
4925
4970
  const [streamResult, setStreamResult] = useState({});
4926
4971
  const [isStreaming, setIsStreaming] = useState(false);
4927
4972
  const readerRef = useRef(null);
@@ -4998,7 +5043,13 @@ const useStreamWorkflow = () => {
4998
5043
  requestContext.set(key, value);
4999
5044
  });
5000
5045
  const workflow = client.getWorkflow(workflowId);
5001
- const stream = await workflow.streamVNext({ runId, inputData, requestContext, closeOnSuspend: true });
5046
+ const stream = await workflow.streamVNext({
5047
+ runId,
5048
+ inputData,
5049
+ requestContext,
5050
+ closeOnSuspend: true,
5051
+ tracingOptions: settings?.tracingOptions
5052
+ });
5002
5053
  if (!stream) {
5003
5054
  return handleStreamError(new Error("No stream returned"), "No stream returned", setIsStreaming);
5004
5055
  }
@@ -5113,7 +5164,13 @@ const useStreamWorkflow = () => {
5113
5164
  Object.entries(playgroundRequestContext).forEach(([key, value]) => {
5114
5165
  requestContext.set(key, value);
5115
5166
  });
5116
- const stream = await workflow.resumeStreamVNext({ runId, step, resumeData, requestContext });
5167
+ const stream = await workflow.resumeStreamVNext({
5168
+ runId,
5169
+ step,
5170
+ resumeData,
5171
+ requestContext,
5172
+ tracingOptions: settings?.tracingOptions
5173
+ });
5117
5174
  if (!stream) {
5118
5175
  return handleStreamError(new Error("No stream returned"), "No stream returned", setIsStreaming);
5119
5176
  }
@@ -5169,7 +5226,11 @@ const useStreamWorkflow = () => {
5169
5226
  Object.entries(playgroundRequestContext).forEach(([key, value]) => {
5170
5227
  requestContext.set(key, value);
5171
5228
  });
5172
- const stream = await workflow.timeTravelStream({ ...params, requestContext });
5229
+ const stream = await workflow.timeTravelStream({
5230
+ ...params,
5231
+ requestContext,
5232
+ tracingOptions: settings?.tracingOptions
5233
+ });
5173
5234
  if (!stream) {
5174
5235
  return handleStreamError(new Error("No stream returned"), "No stream returned", setIsStreaming);
5175
5236
  }
@@ -5294,16 +5355,35 @@ const useWorkflow = (workflowId) => {
5294
5355
  });
5295
5356
  };
5296
5357
 
5358
+ const PER_PAGE = 20;
5297
5359
  const useWorkflowRuns = (workflowId, { enabled = true } = {}) => {
5298
5360
  const client = useMastraClient();
5299
- return useQuery({
5361
+ const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();
5362
+ const query = useInfiniteQuery({
5300
5363
  queryKey: ["workflow-runs", workflowId],
5301
- queryFn: () => client.getWorkflow(workflowId).runs({ perPage: 50, page: 0 }),
5364
+ queryFn: ({ pageParam }) => client.getWorkflow(workflowId).runs({ limit: PER_PAGE, offset: pageParam * PER_PAGE }),
5365
+ initialPageParam: 0,
5366
+ getNextPageParam: (lastPage, _, lastPageParam) => {
5367
+ if (lastPage.runs.length < PER_PAGE) {
5368
+ return void 0;
5369
+ }
5370
+ return lastPageParam + 1;
5371
+ },
5372
+ select: (data) => {
5373
+ return data.pages.flatMap((page) => page.runs);
5374
+ },
5375
+ retry: false,
5302
5376
  enabled,
5303
5377
  refetchInterval: 5e3,
5304
5378
  gcTime: 0,
5305
5379
  staleTime: 0
5306
5380
  });
5381
+ useEffect(() => {
5382
+ if (isEndOfListInView && query.hasNextPage && !query.isFetchingNextPage) {
5383
+ query.fetchNextPage();
5384
+ }
5385
+ }, [isEndOfListInView, query.hasNextPage, query.isFetchingNextPage]);
5386
+ return { ...query, setEndOfListElement };
5307
5387
  };
5308
5388
  const useWorkflowRunExecutionResult = (workflowId, runId, refetchInterval) => {
5309
5389
  const client = useMastraClient();
@@ -6896,6 +6976,41 @@ const DiscriminatedUnionField = ({ field, path }) => {
6896
6976
  ] }, field.key);
6897
6977
  };
6898
6978
 
6979
+ buildZodFieldConfig();
6980
+ function removeEmptyValues(values) {
6981
+ const result = {};
6982
+ for (const key in values) {
6983
+ const value = values[key];
6984
+ if ([null, void 0, "", [], {}].includes(value)) {
6985
+ continue;
6986
+ }
6987
+ if (Array.isArray(value)) {
6988
+ const newArray = value.map((item) => {
6989
+ if (typeof item === "object") {
6990
+ const cleanedItem = removeEmptyValues(item);
6991
+ if (Object.keys(cleanedItem).length > 0) {
6992
+ return cleanedItem;
6993
+ }
6994
+ return null;
6995
+ }
6996
+ return item;
6997
+ });
6998
+ const filteredArray = newArray.filter((item) => item !== null);
6999
+ if (filteredArray.length > 0) {
7000
+ result[key] = filteredArray;
7001
+ }
7002
+ } else if (typeof value === "object") {
7003
+ const cleanedValue = removeEmptyValues(value);
7004
+ if (Object.keys(cleanedValue).length > 0) {
7005
+ result[key] = cleanedValue;
7006
+ }
7007
+ } else {
7008
+ result[key] = value;
7009
+ }
7010
+ }
7011
+ return result;
7012
+ }
7013
+
6899
7014
  function CustomAutoForm({
6900
7015
  schema,
6901
7016
  onSubmit = () => {
@@ -6924,7 +7039,7 @@ function CustomAutoForm({
6924
7039
  }
6925
7040
  }, [onFormInit, methods]);
6926
7041
  const handleSubmit = async (dataRaw) => {
6927
- const data = removeEmptyValues$1(dataRaw);
7042
+ const data = removeEmptyValues(dataRaw);
6928
7043
  const validationResult = schema.validateSchema(data);
6929
7044
  if (validationResult.success) {
6930
7045
  await onSubmit(validationResult.data, methods);
@@ -7004,41 +7119,6 @@ function AutoForm({
7004
7119
  );
7005
7120
  }
7006
7121
 
7007
- buildZodFieldConfig();
7008
- function removeEmptyValues(values) {
7009
- const result = {};
7010
- for (const key in values) {
7011
- const value = values[key];
7012
- if ([null, void 0, "", [], {}].includes(value)) {
7013
- continue;
7014
- }
7015
- if (Array.isArray(value)) {
7016
- const newArray = value.map((item) => {
7017
- if (typeof item === "object") {
7018
- const cleanedItem = removeEmptyValues(item);
7019
- if (Object.keys(cleanedItem).length > 0) {
7020
- return cleanedItem;
7021
- }
7022
- return null;
7023
- }
7024
- return item;
7025
- });
7026
- const filteredArray = newArray.filter((item) => item !== null);
7027
- if (filteredArray.length > 0) {
7028
- result[key] = filteredArray;
7029
- }
7030
- } else if (typeof value === "object") {
7031
- const cleanedValue = removeEmptyValues(value);
7032
- if (Object.keys(cleanedValue).length > 0) {
7033
- result[key] = cleanedValue;
7034
- }
7035
- } else {
7036
- result[key] = value;
7037
- }
7038
- }
7039
- return result;
7040
- }
7041
-
7042
7122
  const labelVariants = cva("text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
7043
7123
  const Label = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(LabelPrimitive.Root, { ref, className: clsx(labelVariants(), className), ...props }));
7044
7124
  Label.displayName = LabelPrimitive.Root.displayName;
@@ -7079,6 +7159,9 @@ function inferFieldType(schema, fieldConfig) {
7079
7159
  }
7080
7160
  return "union";
7081
7161
  }
7162
+ if (schema instanceof z.ZodDiscriminatedUnion) {
7163
+ return "discriminated-union";
7164
+ }
7082
7165
  return "string";
7083
7166
  }
7084
7167
 
@@ -7207,8 +7290,22 @@ class CustomZodProvider extends ZodProvider {
7207
7290
  }
7208
7291
  validateSchema(values) {
7209
7292
  const cleanedValues = removeEmptyValues(values);
7210
- const result = super.validateSchema(cleanedValues);
7211
- return result;
7293
+ try {
7294
+ const validationResult = this._schema.safeParse(cleanedValues);
7295
+ if (validationResult.success) {
7296
+ return { success: true, data: validationResult.data };
7297
+ } else {
7298
+ return {
7299
+ success: false,
7300
+ errors: validationResult.error.issues.map((error) => ({
7301
+ path: error.path,
7302
+ message: error.message
7303
+ }))
7304
+ };
7305
+ }
7306
+ } catch (error) {
7307
+ throw error;
7308
+ }
7212
7309
  }
7213
7310
  parseSchema() {
7214
7311
  return parseSchema(this._schema);
@@ -7703,7 +7800,7 @@ const WorkflowStepActionBar = ({
7703
7800
  const { withoutTimeTravel } = useContext(WorkflowRunContext);
7704
7801
  const dialogContentClass = "bg-surface2 rounded-lg border-sm border-border1 max-w-4xl w-full px-0";
7705
7802
  const dialogTitleClass = "border-b-sm border-border1 pb-4 px-6";
7706
- const showTimeTravel = !withoutTimeTravel && stepKey;
7803
+ const showTimeTravel = !withoutTimeTravel && stepKey && !mapConfig;
7707
7804
  return /* @__PURE__ */ jsx(Fragment, { children: (input || output || error || mapConfig || resumeData || onShowNestedGraph || showTimeTravel) && /* @__PURE__ */ jsxs(
7708
7805
  "div",
7709
7806
  {
@@ -9182,6 +9279,104 @@ const EntityHeader = ({ icon, title, isLoading, children }) => {
9182
9279
  ] });
9183
9280
  };
9184
9281
 
9282
+ const Tabs$1 = TabsPrimitive.Root;
9283
+ const TabsList = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
9284
+ TabsPrimitive.List,
9285
+ {
9286
+ ref,
9287
+ className: clsx("bg-muted text-muted-foreground inline-flex items-center bg-transparent", className),
9288
+ ...props
9289
+ }
9290
+ ));
9291
+ TabsList.displayName = TabsPrimitive.List.displayName;
9292
+ const TabsTrigger = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
9293
+ TabsPrimitive.Trigger,
9294
+ {
9295
+ ref,
9296
+ className: cn(
9297
+ "-outline-offset-2 data-[state=active]:bg-background data-[state=active]:text-foreground whitespace-nowrap text-ui-lg text-icon3 -mb-[0.5px] inline-flex items-center justify-center border-b-2 border-transparent p-3 font-medium disabled:pointer-events-none disabled:opacity-50 data-[state=active]:border-b-2 data-[state=active]:border-white data-[state=active]:shadow",
9298
+ className
9299
+ ),
9300
+ ...props
9301
+ }
9302
+ ));
9303
+ TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
9304
+ const TabsContent = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(TabsPrimitive.Content, { ref, className: cn("mt-2 -outline-offset-2", className), ...props }));
9305
+ TabsContent.displayName = TabsPrimitive.Content.displayName;
9306
+
9307
+ const PlaygroundTabs = ({
9308
+ children,
9309
+ defaultTab,
9310
+ value,
9311
+ onValueChange,
9312
+ className
9313
+ }) => {
9314
+ const [internalTab, setInternalTab] = useState(defaultTab);
9315
+ const isControlled = value !== void 0 && onValueChange !== void 0;
9316
+ const currentTab = isControlled ? value : internalTab;
9317
+ const handleTabChange = (newValue) => {
9318
+ const typedValue = newValue;
9319
+ if (isControlled) {
9320
+ onValueChange(typedValue);
9321
+ } else {
9322
+ setInternalTab(typedValue);
9323
+ }
9324
+ };
9325
+ return /* @__PURE__ */ jsx(Tabs$1, { value: currentTab, onValueChange: handleTabChange, className: cn("h-full", className), children });
9326
+ };
9327
+ const TabList$1 = ({ children, className }) => {
9328
+ return /* @__PURE__ */ jsx("div", { className: cn("w-full overflow-x-auto", className), children: /* @__PURE__ */ jsx(TabsList, { className: "border-b border-border1 flex min-w-full shrink-0", children }) });
9329
+ };
9330
+ const Tab$1 = ({ children, value, onClick }) => {
9331
+ return /* @__PURE__ */ jsx(
9332
+ TabsTrigger,
9333
+ {
9334
+ value,
9335
+ className: "text-xs p-3 text-mastra-el-3 data-[state=active]:text-mastra-el-5 data-[state=active]:border-b-2 whitespace-nowrap flex-shrink-0",
9336
+ onClick,
9337
+ children
9338
+ }
9339
+ );
9340
+ };
9341
+ const TabContent$1 = ({ children, value }) => {
9342
+ return /* @__PURE__ */ jsx(TabsContent, { value, className: "h-full overflow-hidden flex flex-col", children });
9343
+ };
9344
+
9345
+ const TracingRunOptions = () => {
9346
+ const theme = useCodemirrorTheme$1();
9347
+ const { settings, setSettings } = useTracingSettings();
9348
+ const handleChange = (value) => {
9349
+ if (!value) {
9350
+ return setSettings({ ...settings, tracingOptions: void 0 });
9351
+ }
9352
+ try {
9353
+ const parsed = JSON.parse(value);
9354
+ if (typeof parsed === "object" && parsed !== null) {
9355
+ setSettings({ ...settings, tracingOptions: parsed });
9356
+ }
9357
+ } catch {
9358
+ }
9359
+ };
9360
+ let strValue = "{}";
9361
+ try {
9362
+ strValue = JSON.stringify(settings?.tracingOptions, null, 2);
9363
+ } catch {
9364
+ }
9365
+ return /* @__PURE__ */ jsxs("div", { className: "space-y-2 px-5 py-2", children: [
9366
+ /* @__PURE__ */ jsx(Txt, { as: "h3", variant: "ui-md", className: "text-icon3", children: "Tracing Options" }),
9367
+ /* @__PURE__ */ jsx(
9368
+ CodeMirror,
9369
+ {
9370
+ value: strValue,
9371
+ onChange: handleChange,
9372
+ theme,
9373
+ extensions: [jsonLanguage],
9374
+ className: "h-[400px] overflow-y-scroll bg-surface3 rounded-lg overflow-hidden p-3"
9375
+ }
9376
+ )
9377
+ ] });
9378
+ };
9379
+
9185
9380
  function WorkflowInformation({ workflowId, initialRunId }) {
9186
9381
  const { data: workflow, isLoading, error } = useWorkflow(workflowId);
9187
9382
  const {
@@ -9195,6 +9390,7 @@ function WorkflowInformation({ workflowId, initialRunId }) {
9195
9390
  cancelWorkflowRun,
9196
9391
  isCancellingWorkflowRun
9197
9392
  } = useContext(WorkflowRunContext);
9393
+ const [tab, setTab] = useState("current-run");
9198
9394
  const [runId, setRunId] = useState("");
9199
9395
  const { handleCopy } = useCopyToClipboard({ text: workflowId });
9200
9396
  const stepsCount = Object.keys(workflow?.steps ?? {}).length;
@@ -9224,39 +9420,46 @@ function WorkflowInformation({ workflowId, initialRunId }) {
9224
9420
  stepsCount > 1 ? "s" : ""
9225
9421
  ] })
9226
9422
  ] }) }),
9227
- /* @__PURE__ */ jsx("div", { className: "overflow-y-auto border-t-sm border-border1", children: workflowId ? initialRunId ? /* @__PURE__ */ jsx(
9228
- WorkflowRunDetail,
9229
- {
9230
- workflowId,
9231
- runId: initialRunId,
9232
- setRunId,
9233
- workflow: workflow ?? void 0,
9234
- isLoading,
9235
- createWorkflowRun,
9236
- streamWorkflow,
9237
- resumeWorkflow,
9238
- streamResult,
9239
- isStreamingWorkflow,
9240
- isCancellingWorkflowRun,
9241
- cancelWorkflowRun,
9242
- observeWorkflowStream
9243
- }
9244
- ) : /* @__PURE__ */ jsx(
9245
- WorkflowTrigger,
9246
- {
9247
- workflowId,
9248
- setRunId,
9249
- workflow: workflow ?? void 0,
9250
- isLoading,
9251
- createWorkflowRun,
9252
- streamWorkflow,
9253
- resumeWorkflow,
9254
- streamResult,
9255
- isStreamingWorkflow,
9256
- isCancellingWorkflowRun,
9257
- cancelWorkflowRun
9258
- }
9259
- ) : null })
9423
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden border-t-sm border-border1 flex flex-col", children: /* @__PURE__ */ jsxs(PlaygroundTabs, { defaultTab: "current-run", value: tab, onValueChange: setTab, children: [
9424
+ /* @__PURE__ */ jsxs(TabList$1, { children: [
9425
+ /* @__PURE__ */ jsx(Tab$1, { value: "current-run", children: "Current Run" }),
9426
+ /* @__PURE__ */ jsx(Tab$1, { value: "run-options", children: "Run options" })
9427
+ ] }),
9428
+ /* @__PURE__ */ jsx(TabContent$1, { value: "current-run", children: workflowId ? initialRunId ? /* @__PURE__ */ jsx(
9429
+ WorkflowRunDetail,
9430
+ {
9431
+ workflowId,
9432
+ runId: initialRunId,
9433
+ setRunId,
9434
+ workflow: workflow ?? void 0,
9435
+ isLoading,
9436
+ createWorkflowRun,
9437
+ streamWorkflow,
9438
+ resumeWorkflow,
9439
+ streamResult,
9440
+ isStreamingWorkflow,
9441
+ isCancellingWorkflowRun,
9442
+ cancelWorkflowRun,
9443
+ observeWorkflowStream
9444
+ }
9445
+ ) : /* @__PURE__ */ jsx(
9446
+ WorkflowTrigger,
9447
+ {
9448
+ workflowId,
9449
+ setRunId,
9450
+ workflow: workflow ?? void 0,
9451
+ isLoading,
9452
+ createWorkflowRun,
9453
+ streamWorkflow,
9454
+ resumeWorkflow,
9455
+ streamResult,
9456
+ isStreamingWorkflow,
9457
+ isCancellingWorkflowRun,
9458
+ cancelWorkflowRun
9459
+ }
9460
+ ) : null }),
9461
+ /* @__PURE__ */ jsx(TabContent$1, { value: "run-options", children: /* @__PURE__ */ jsx(TracingRunOptions, {}) })
9462
+ ] }) })
9260
9463
  ] });
9261
9464
  }
9262
9465
 
@@ -9494,7 +9697,7 @@ const WorkflowBadge = ({
9494
9697
  const { data: runs, isLoading: isRunsLoading } = useWorkflowRuns(workflowId, {
9495
9698
  enabled: Boolean(runId) && !isStreaming
9496
9699
  });
9497
- const run = runs?.runs.find((run2) => run2.runId === runId);
9700
+ const run = runs?.find((run2) => run2.runId === runId);
9498
9701
  const isLoading = isRunsLoading || !run;
9499
9702
  const snapshot = typeof run?.snapshot === "object" ? run?.snapshot : void 0;
9500
9703
  const selectionReason = metadata?.mode === "network" ? metadata.selectionReason : void 0;
@@ -10334,8 +10537,12 @@ const useSpeechRecognition = ({
10334
10537
  const agent2 = client.getAgent(agentId);
10335
10538
  const check = async () => {
10336
10539
  try {
10337
- await agent2.voice.getSpeakers(requestContext);
10338
- setAgent(agent2);
10540
+ const speakers = await agent2.voice.getSpeakers(requestContext);
10541
+ if (speakers.length > 0) {
10542
+ setAgent(agent2);
10543
+ } else {
10544
+ setAgent(null);
10545
+ }
10339
10546
  } catch (error) {
10340
10547
  setAgent(null);
10341
10548
  }
@@ -11079,8 +11286,12 @@ const useAdapters = (agentId) => {
11079
11286
  const check = async () => {
11080
11287
  const agent = baseClient.getAgent(agentId);
11081
11288
  try {
11082
- await agent.voice.getSpeakers(requestContext);
11083
- setSpeechAdapter(new VoiceAttachmentAdapter(agent));
11289
+ const speakers = await agent.voice.getSpeakers(requestContext);
11290
+ if (speakers.length > 0) {
11291
+ setSpeechAdapter(new VoiceAttachmentAdapter(agent));
11292
+ } else {
11293
+ setSpeechAdapter(new WebSpeechSynthesisAdapter());
11294
+ }
11084
11295
  setIsReady(true);
11085
11296
  } catch {
11086
11297
  setSpeechAdapter(new WebSpeechSynthesisAdapter());
@@ -11348,6 +11559,7 @@ function MastraRuntimeProvider({
11348
11559
  modelVersion
11349
11560
  }) {
11350
11561
  const { prompt: instructions } = useAgentPromptExperiment();
11562
+ const { settings: tracingSettings } = useTracingSettings();
11351
11563
  const [isLegacyRunning, setIsLegacyRunning] = useState(false);
11352
11564
  const [legacyMessages, setLegacyMessages] = useState(
11353
11565
  () => memory ? initializeMessageState(initialLegacyMessages || []) : []
@@ -11427,6 +11639,7 @@ function MastraRuntimeProvider({
11427
11639
  threadId,
11428
11640
  modelSettings: modelSettingsArgs,
11429
11641
  signal: controller.signal,
11642
+ tracingOptions: tracingSettings?.tracingOptions,
11430
11643
  onNetworkChunk: async (chunk) => {
11431
11644
  if (chunk.type === "tool-execution-end" && chunk.payload?.toolName === "updateWorkingMemory" && typeof chunk.payload.result === "object" && "success" in chunk.payload.result && chunk.payload.result?.success) {
11432
11645
  refreshWorkingMemory?.();
@@ -11445,7 +11658,8 @@ function MastraRuntimeProvider({
11445
11658
  requestContext: requestContextInstance,
11446
11659
  threadId,
11447
11660
  modelSettings: modelSettingsArgs,
11448
- signal: controller.signal
11661
+ signal: controller.signal,
11662
+ tracingOptions: tracingSettings?.tracingOptions
11449
11663
  });
11450
11664
  await refreshThreadList?.();
11451
11665
  return;
@@ -11457,6 +11671,7 @@ function MastraRuntimeProvider({
11457
11671
  requestContext: requestContextInstance,
11458
11672
  threadId,
11459
11673
  modelSettings: modelSettingsArgs,
11674
+ tracingOptions: tracingSettings?.tracingOptions,
11460
11675
  onChunk: async (chunk) => {
11461
11676
  if (chunk.type === "finish") {
11462
11677
  await refreshThreadList?.();
@@ -16450,69 +16665,6 @@ function AgentMemory({ agentId, threadId }) {
16450
16665
  ] });
16451
16666
  }
16452
16667
 
16453
- const Tabs$1 = TabsPrimitive.Root;
16454
- const TabsList = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
16455
- TabsPrimitive.List,
16456
- {
16457
- ref,
16458
- className: clsx("bg-muted text-muted-foreground inline-flex items-center bg-transparent", className),
16459
- ...props
16460
- }
16461
- ));
16462
- TabsList.displayName = TabsPrimitive.List.displayName;
16463
- const TabsTrigger = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
16464
- TabsPrimitive.Trigger,
16465
- {
16466
- ref,
16467
- className: cn(
16468
- "-outline-offset-2 data-[state=active]:bg-background data-[state=active]:text-foreground whitespace-nowrap text-ui-lg text-icon3 -mb-[0.5px] inline-flex items-center justify-center border-b-2 border-transparent p-3 font-medium disabled:pointer-events-none disabled:opacity-50 data-[state=active]:border-b-2 data-[state=active]:border-white data-[state=active]:shadow",
16469
- className
16470
- ),
16471
- ...props
16472
- }
16473
- ));
16474
- TabsTrigger.displayName = TabsPrimitive.Trigger.displayName;
16475
- const TabsContent = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(TabsPrimitive.Content, { ref, className: cn("mt-2 -outline-offset-2", className), ...props }));
16476
- TabsContent.displayName = TabsPrimitive.Content.displayName;
16477
-
16478
- const PlaygroundTabs = ({
16479
- children,
16480
- defaultTab,
16481
- value,
16482
- onValueChange,
16483
- className
16484
- }) => {
16485
- const [internalTab, setInternalTab] = useState(defaultTab);
16486
- const isControlled = value !== void 0 && onValueChange !== void 0;
16487
- const currentTab = isControlled ? value : internalTab;
16488
- const handleTabChange = (newValue) => {
16489
- const typedValue = newValue;
16490
- if (isControlled) {
16491
- onValueChange(typedValue);
16492
- } else {
16493
- setInternalTab(typedValue);
16494
- }
16495
- };
16496
- return /* @__PURE__ */ jsx(Tabs$1, { value: currentTab, onValueChange: handleTabChange, className: cn("h-full", className), children });
16497
- };
16498
- const TabList$1 = ({ children, className }) => {
16499
- return /* @__PURE__ */ jsx("div", { className: cn("w-full overflow-x-auto", className), children: /* @__PURE__ */ jsx(TabsList, { className: "border-b border-border1 flex min-w-full shrink-0", children }) });
16500
- };
16501
- const Tab$1 = ({ children, value, onClick }) => {
16502
- return /* @__PURE__ */ jsx(
16503
- TabsTrigger,
16504
- {
16505
- value,
16506
- className: "text-xs p-3 text-mastra-el-3 data-[state=active]:text-mastra-el-5 data-[state=active]:border-b-2 whitespace-nowrap flex-shrink-0",
16507
- onClick,
16508
- children
16509
- }
16510
- );
16511
- };
16512
- const TabContent$1 = ({ children, value }) => {
16513
- return /* @__PURE__ */ jsx(TabsContent, { value, className: "h-full overflow-hidden flex flex-col", children });
16514
- };
16515
-
16516
16668
  function AgentInformation({ agentId, threadId }) {
16517
16669
  const { data: memory } = useMemory(agentId);
16518
16670
  const hasMemory = Boolean(memory?.result);
@@ -16522,11 +16674,13 @@ function AgentInformation({ agentId, threadId }) {
16522
16674
  /* @__PURE__ */ jsxs(TabList$1, { children: [
16523
16675
  /* @__PURE__ */ jsx(Tab$1, { value: "overview", children: "Overview" }),
16524
16676
  /* @__PURE__ */ jsx(Tab$1, { value: "model-settings", children: "Model Settings" }),
16525
- hasMemory && /* @__PURE__ */ jsx(Tab$1, { value: "memory", children: "Memory" })
16677
+ hasMemory && /* @__PURE__ */ jsx(Tab$1, { value: "memory", children: "Memory" }),
16678
+ /* @__PURE__ */ jsx(Tab$1, { value: "tracing-options", children: "Tracing Options" })
16526
16679
  ] }),
16527
16680
  /* @__PURE__ */ jsx(TabContent$1, { value: "overview", children: /* @__PURE__ */ jsx(AgentMetadata, { agentId }) }),
16528
16681
  /* @__PURE__ */ jsx(TabContent$1, { value: "model-settings", children: /* @__PURE__ */ jsx(AgentSettings, { agentId }) }),
16529
- hasMemory && /* @__PURE__ */ jsx(TabContent$1, { value: "memory", children: /* @__PURE__ */ jsx(AgentMemory, { agentId, threadId }) })
16682
+ hasMemory && /* @__PURE__ */ jsx(TabContent$1, { value: "memory", children: /* @__PURE__ */ jsx(AgentMemory, { agentId, threadId }) }),
16683
+ /* @__PURE__ */ jsx(TabContent$1, { value: "tracing-options", children: /* @__PURE__ */ jsx(TracingRunOptions, {}) })
16530
16684
  ] })
16531
16685
  ] });
16532
16686
  }
@@ -19056,23 +19210,27 @@ const parseError = (error) => {
19056
19210
 
19057
19211
  const WorkflowRunList = ({ workflowId, runId }) => {
19058
19212
  const { Link, paths } = useLinkComponent();
19059
- const { isLoading, data: runs } = useWorkflowRuns(workflowId);
19060
- const actualRuns = runs?.runs || [];
19213
+ const { isLoading, data: runs, setEndOfListElement, isFetchingNextPage } = useWorkflowRuns(workflowId);
19214
+ const actualRuns = runs || [];
19061
19215
  if (isLoading) {
19062
19216
  return /* @__PURE__ */ jsx("div", { className: "p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-[600px]" }) });
19063
19217
  }
19064
- return /* @__PURE__ */ jsx("div", { className: "overflow-y-auto h-full w-full", children: /* @__PURE__ */ jsx(Threads, { children: /* @__PURE__ */ jsxs(ThreadList, { children: [
19065
- /* @__PURE__ */ jsx(ThreadItem, { children: /* @__PURE__ */ jsx(ThreadLink, { as: Link, to: paths.workflowLink(workflowId), children: /* @__PURE__ */ jsxs("span", { className: "text-accent1 flex items-center gap-4", children: [
19066
- /* @__PURE__ */ jsx(Icon, { className: "bg-surface4 rounded-lg", size: "lg", children: /* @__PURE__ */ jsx(Plus, {}) }),
19067
- "New workflow run"
19068
- ] }) }) }),
19069
- actualRuns.length === 0 && /* @__PURE__ */ jsx(Txt, { variant: "ui-md", className: "text-icon3 py-3 px-5", children: "Your run history will appear here once you run the workflow" }),
19070
- actualRuns.map((run) => /* @__PURE__ */ jsx(ThreadItem, { isActive: run.runId === runId, className: "h-auto", children: /* @__PURE__ */ jsxs(ThreadLink, { as: Link, to: paths.workflowRunLink(workflowId, run.runId), children: [
19071
- typeof run?.snapshot === "object" && /* @__PURE__ */ jsx("div", { className: "pb-1", children: /* @__PURE__ */ jsx(WorkflowRunStatusBadge, { status: run.snapshot.status }) }),
19072
- /* @__PURE__ */ jsx("span", { className: "truncate max-w-[14rem] text-muted-foreground", children: run.runId }),
19073
- /* @__PURE__ */ jsx("span", { children: typeof run?.snapshot === "string" ? "" : run?.snapshot?.timestamp ? formatDate(run?.snapshot?.timestamp, "MMM d, yyyy h:mm a") : "" })
19074
- ] }) }, run.runId))
19075
- ] }) }) });
19218
+ return /* @__PURE__ */ jsxs("div", { className: "overflow-y-auto h-full w-full", children: [
19219
+ /* @__PURE__ */ jsx(Threads, { children: /* @__PURE__ */ jsxs(ThreadList, { children: [
19220
+ /* @__PURE__ */ jsx(ThreadItem, { children: /* @__PURE__ */ jsx(ThreadLink, { as: Link, to: paths.workflowLink(workflowId), children: /* @__PURE__ */ jsxs("span", { className: "text-accent1 flex items-center gap-4", children: [
19221
+ /* @__PURE__ */ jsx(Icon, { className: "bg-surface4 rounded-lg", size: "lg", children: /* @__PURE__ */ jsx(Plus, {}) }),
19222
+ "New workflow run"
19223
+ ] }) }) }),
19224
+ actualRuns.length === 0 && /* @__PURE__ */ jsx(Txt, { variant: "ui-md", className: "text-icon3 py-3 px-5", children: "Your run history will appear here once you run the workflow" }),
19225
+ actualRuns.map((run) => /* @__PURE__ */ jsx(ThreadItem, { isActive: run.runId === runId, className: "h-auto", children: /* @__PURE__ */ jsxs(ThreadLink, { as: Link, to: paths.workflowRunLink(workflowId, run.runId), children: [
19226
+ typeof run?.snapshot === "object" && /* @__PURE__ */ jsx("div", { className: "pb-1", children: /* @__PURE__ */ jsx(WorkflowRunStatusBadge, { status: run.snapshot.status }) }),
19227
+ /* @__PURE__ */ jsx("span", { className: "truncate max-w-[14rem] text-muted-foreground", children: run.runId }),
19228
+ /* @__PURE__ */ jsx("span", { children: typeof run?.snapshot === "string" ? "" : run?.snapshot?.timestamp ? formatDate(run?.snapshot?.timestamp, "MMM d, yyyy h:mm a") : "" })
19229
+ ] }) }, run.runId))
19230
+ ] }) }),
19231
+ isFetchingNextPage && /* @__PURE__ */ jsx("div", { className: "flex justify-center items-center", children: /* @__PURE__ */ jsx(Icon, { children: /* @__PURE__ */ jsx(Spinner, {}) }) }),
19232
+ /* @__PURE__ */ jsx("div", { ref: setEndOfListElement })
19233
+ ] });
19076
19234
  };
19077
19235
  const WorkflowRunStatusBadge = ({ status }) => {
19078
19236
  if (status === "running") {
@@ -19505,5 +19663,5 @@ function MCPServerCombobox({
19505
19663
  );
19506
19664
  }
19507
19665
 
19508
- export { AgentChat, AgentCoinIcon, AgentCombobox, AgentEntityHeader, AgentIcon, AgentInformation, AgentInformationLayout, AgentInformationTabLayout, AgentMemory, AgentMetadata, AgentMetadataList, AgentMetadataListEmpty, AgentMetadataListItem, AgentMetadataNetworkList, AgentMetadataScorerList, AgentMetadataSection, AgentMetadataToolList, AgentMetadataWorkflowList, AgentMetadataWrapper, AgentNetworkCoinIcon, AgentPromptExperimentProvider, AgentSettings, AgentSettingsContext, AgentSettingsProvider, AgentToolPanel, AgentsTable, AiIcon, Alert$1 as Alert, AlertDescription$1 as AlertDescription, AlertDialog, AlertTitle$1 as AlertTitle, ApiIcon, Badge, BranchIcon, Breadcrumb, Button$1 as Button, ButtonsGroup, Cell, ChatThreads, CheckIcon, ChevronIcon, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, CommitIcon, CrossIcon, Crumb, DateTimeCell, DateTimePicker, DateTimePickerContent, DbIcon, DebugIcon, DefaultTrigger, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EmptyState, Entity, EntityContent, EntityDescription, EntityHeader, EntityIcon, EntityName, Entry, EntryCell, EntryList, EntryListSkeleton, EnvIcon, FiltersIcon, FolderIcon, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, InputField, JudgeIcon, Kbd, KeyValueList, LatencyIcon, LinkComponentProvider, LogoWithoutText, LogsIcon, MCPDetail, MCPServerCombobox, MCPTable, MCPToolPanel, MainContentContent, MainContentLayout, MainSidebar, MainSidebarProvider, McpCoinIcon, McpServerIcon, MemoryIcon, MemorySearch, Notification, OpenAIIcon, PageHeader, PlaygroundQueryClient, PlaygroundTabs, PromptIcon, RadioGroup, RadioGroupItem, RepoIcon, RequestContext, RequestContextWrapper, Row, ScoreDialog, ScorerCombobox, ScorersTable, ScoresList, ScoresTools, SearchField, Searchbar, SearchbarWrapper, Section, Sections, SelectField, SettingsIcon, SideDialog, Skeleton, SlashIcon, SpanScoreList, SpanScoring, SpanTabs, Tab$1 as Tab, TabContent$1 as TabContent, TabList$1 as TabList, Table, Tbody, TemplateFailure, TemplateForm, TemplateInfo, TemplateInstallation, TemplateSuccess, TemplatesList, TemplatesTools, TextAndIcon, Th, Thead, ThreadDeleteButton, ThreadInputProvider, ThreadItem, ThreadLink, ThreadList, Threads, ToolCoinIcon, ToolCombobox, ToolFallback, ToolIconMap, ToolInformation, ToolPanel, ToolTable, ToolsIcon, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TraceDialog, TraceIcon, TraceTimeline, TraceTimelineLegend, TraceTimelineSpan, TracesList, TracesTools, TsIcon, Txt, TxtCell, VariablesIcon, WorkflowCoinIcon, WorkflowCombobox, WorkflowGraph, WorkflowIcon, WorkflowInformation, WorkflowRunContext, WorkflowRunDetail, WorkflowRunList, WorkflowRunProvider, WorkflowTable, WorkflowTrigger, WorkingMemoryContext, WorkingMemoryProvider, convertWorkflowRunStateToStreamResult, extractPrompt, formatHierarchicalSpans, getColumnTemplate, getShortId, getSpanTypeUi, getToNextEntryFn, getToPreviousEntryFn, parseError, providerMapToIcon, scoresListColumns, spanTypePrefixes, toast, traceScoresListColumns, tracesListColumns, useAgent, useAgentInformationSettings, useAgentInformationTab, useAgentPromptExperiment, useAgentSettings, useAgents, useCancelWorkflowRun, useCurrentRun, useDeleteThread, useExecuteAgentTool, useExecuteMCPTool, useExecuteTool, useExecuteWorkflow, useInView, useLinkComponent, useMCPServerTool, useMCPServerTools, useMCPServers, useMainSidebar, useMemory, useMemoryConfig, useMemorySearch, usePlaygroundStore, useReorderModelList, useResetAgentModel, useScorer, useScorers, useScoresByScorerId, useSpeechRecognition, useStreamWorkflow, useThreadInput, useThreads, useTool, useTools, useTraceSpanScores, useUpdateAgentModel, useUpdateModelInModelList, useWorkflow, useWorkflowRunExecutionResult, useWorkflowRuns, useWorkflows, useWorkingMemory };
19666
+ export { AgentChat, AgentCoinIcon, AgentCombobox, AgentEntityHeader, AgentIcon, AgentInformation, AgentInformationLayout, AgentInformationTabLayout, AgentMemory, AgentMetadata, AgentMetadataList, AgentMetadataListEmpty, AgentMetadataListItem, AgentMetadataNetworkList, AgentMetadataScorerList, AgentMetadataSection, AgentMetadataToolList, AgentMetadataWorkflowList, AgentMetadataWrapper, AgentNetworkCoinIcon, AgentPromptExperimentProvider, AgentSettings, AgentSettingsContext, AgentSettingsProvider, AgentToolPanel, AgentsTable, AiIcon, Alert$1 as Alert, AlertDescription$1 as AlertDescription, AlertDialog, AlertTitle$1 as AlertTitle, ApiIcon, Badge, BranchIcon, Breadcrumb, Button$1 as Button, ButtonsGroup, Cell, ChatThreads, CheckIcon, ChevronIcon, Collapsible, CollapsibleContent, CollapsibleTrigger, Combobox, CommitIcon, CrossIcon, Crumb, DateTimeCell, DateTimePicker, DateTimePickerContent, DbIcon, DebugIcon, DefaultTrigger, DeploymentIcon, DividerIcon, DocsIcon, DynamicForm, EmptyState, Entity, EntityContent, EntityDescription, EntityHeader, EntityIcon, EntityName, Entry, EntryCell, EntryList, EntryListSkeleton, EnvIcon, FiltersIcon, FolderIcon, GithubCoinIcon, GithubIcon, GoogleIcon, Header, HeaderAction, HeaderGroup, HeaderTitle, HomeIcon, Icon, InfoIcon, InputField, JudgeIcon, Kbd, KeyValueList, LatencyIcon, LinkComponentProvider, LogoWithoutText, LogsIcon, MCPDetail, MCPServerCombobox, MCPTable, MCPToolPanel, MainContentContent, MainContentLayout, MainSidebar, MainSidebarProvider, McpCoinIcon, McpServerIcon, MemoryIcon, MemorySearch, Notification, OpenAIIcon, PageHeader, PlaygroundQueryClient, PlaygroundTabs, PromptIcon, RadioGroup, RadioGroupItem, RepoIcon, RequestContext, RequestContextWrapper, Row, ScoreDialog, ScorerCombobox, ScorersTable, ScoresList, ScoresTools, SearchField, Searchbar, SearchbarWrapper, Section, Sections, SelectField, SettingsIcon, SideDialog, Skeleton, SlashIcon, SpanScoreList, SpanScoring, SpanTabs, Tab$1 as Tab, TabContent$1 as TabContent, TabList$1 as TabList, Table, Tbody, TemplateFailure, TemplateForm, TemplateInfo, TemplateInstallation, TemplateSuccess, TemplatesList, TemplatesTools, TextAndIcon, Th, Thead, ThreadDeleteButton, ThreadInputProvider, ThreadItem, ThreadLink, ThreadList, Threads, ToolCoinIcon, ToolCombobox, ToolFallback, ToolIconMap, ToolInformation, ToolPanel, ToolTable, ToolsIcon, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, TraceDialog, TraceIcon, TraceTimeline, TraceTimelineLegend, TraceTimelineSpan, TracesList, TracesTools, TracingSettingsContext, TracingSettingsProvider, TsIcon, Txt, TxtCell, VariablesIcon, WorkflowCoinIcon, WorkflowCombobox, WorkflowGraph, WorkflowIcon, WorkflowInformation, WorkflowRunContext, WorkflowRunDetail, WorkflowRunList, WorkflowRunProvider, WorkflowTable, WorkflowTrigger, WorkingMemoryContext, WorkingMemoryProvider, convertWorkflowRunStateToStreamResult, extractPrompt, formatHierarchicalSpans, getColumnTemplate, getShortId, getSpanTypeUi, getToNextEntryFn, getToPreviousEntryFn, parseError, providerMapToIcon, scoresListColumns, spanTypePrefixes, toast, traceScoresListColumns, tracesListColumns, useAgent, useAgentInformationSettings, useAgentInformationTab, useAgentPromptExperiment, useAgentSettings, useAgents, useCancelWorkflowRun, useCurrentRun, useDeleteThread, useExecuteAgentTool, useExecuteMCPTool, useExecuteTool, useExecuteWorkflow, useInView, useLinkComponent, useMCPServerTool, useMCPServerTools, useMCPServers, useMainSidebar, useMemory, useMemoryConfig, useMemorySearch, usePlaygroundStore, useReorderModelList, useResetAgentModel, useScorer, useScorers, useScoresByScorerId, useSpeechRecognition, useStreamWorkflow, useThreadInput, useThreads, useTool, useTools, useTraceSpanScores, useTracingSettings, useUpdateAgentModel, useUpdateModelInModelList, useWorkflow, useWorkflowRunExecutionResult, useWorkflowRuns, useWorkflows, useWorkingMemory };
19509
19667
  //# sourceMappingURL=index.es.js.map