@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.cjs.js CHANGED
@@ -51,7 +51,7 @@ const RadioGroupPrimitive = require('@radix-ui/react-radio-group');
51
51
  const prettier = require('prettier');
52
52
  const prettierPluginBabel = require('prettier/plugins/babel');
53
53
  const prettierPluginEstree = require('prettier/plugins/estree');
54
- const jsonSchemaToZod = require('json-schema-to-zod');
54
+ const jsonToZod = require('@mastra/schema-compat/json-to-zod');
55
55
  const superjson = require('superjson');
56
56
  const SliderPrimitive = require('@radix-ui/react-slider');
57
57
  const reactCodeBlock = require('react-code-block');
@@ -4893,6 +4893,50 @@ toast.promise = ({
4893
4893
  });
4894
4894
  };
4895
4895
 
4896
+ function useTracingSettingsState({ entityId, entityType }) {
4897
+ const [settings, setSettingsState] = React.useState(void 0);
4898
+ const LOCAL_STORAGE_KEY = `tracing-options-${entityType}:${entityId}`;
4899
+ React.useEffect(() => {
4900
+ try {
4901
+ const stored = localStorage.getItem(LOCAL_STORAGE_KEY);
4902
+ if (stored) {
4903
+ const parsed = JSON.parse(stored);
4904
+ setSettingsState(parsed || void 0);
4905
+ }
4906
+ } catch (e) {
4907
+ console.error(e);
4908
+ }
4909
+ }, [LOCAL_STORAGE_KEY]);
4910
+ const setSettings = (settingsValue) => {
4911
+ setSettingsState((prev) => ({ ...prev, ...settingsValue }));
4912
+ localStorage.setItem(LOCAL_STORAGE_KEY, JSON.stringify({ ...settingsValue, entityId, entityType }));
4913
+ };
4914
+ const resetAll = () => {
4915
+ setSettingsState(void 0);
4916
+ localStorage.removeItem(LOCAL_STORAGE_KEY);
4917
+ };
4918
+ return {
4919
+ settings,
4920
+ setSettings,
4921
+ resetAll
4922
+ };
4923
+ }
4924
+
4925
+ const TracingSettingsContext = React.createContext({
4926
+ setSettings: () => {
4927
+ },
4928
+ resetAll: () => {
4929
+ },
4930
+ settings: void 0
4931
+ });
4932
+ const TracingSettingsProvider = ({ children, entityId, entityType }) => {
4933
+ const state = useTracingSettingsState({ entityId, entityType });
4934
+ return /* @__PURE__ */ jsxRuntime.jsx(TracingSettingsContext.Provider, { value: state, children });
4935
+ };
4936
+ const useTracingSettings = () => {
4937
+ return React.useContext(TracingSettingsContext);
4938
+ };
4939
+
4896
4940
  const useExecuteWorkflow = () => {
4897
4941
  const client = react$1.useMastraClient();
4898
4942
  const createWorkflowRun = reactQuery.useMutation({
@@ -4956,6 +5000,7 @@ const useExecuteWorkflow = () => {
4956
5000
  };
4957
5001
  const useStreamWorkflow = () => {
4958
5002
  const client = react$1.useMastraClient();
5003
+ const { settings } = useTracingSettings();
4959
5004
  const [streamResult, setStreamResult] = React.useState({});
4960
5005
  const [isStreaming, setIsStreaming] = React.useState(false);
4961
5006
  const readerRef = React.useRef(null);
@@ -5032,7 +5077,13 @@ const useStreamWorkflow = () => {
5032
5077
  requestContext$1.set(key, value);
5033
5078
  });
5034
5079
  const workflow = client.getWorkflow(workflowId);
5035
- const stream = await workflow.streamVNext({ runId, inputData, requestContext: requestContext$1, closeOnSuspend: true });
5080
+ const stream = await workflow.streamVNext({
5081
+ runId,
5082
+ inputData,
5083
+ requestContext: requestContext$1,
5084
+ closeOnSuspend: true,
5085
+ tracingOptions: settings?.tracingOptions
5086
+ });
5036
5087
  if (!stream) {
5037
5088
  return handleStreamError(new Error("No stream returned"), "No stream returned", setIsStreaming);
5038
5089
  }
@@ -5147,7 +5198,13 @@ const useStreamWorkflow = () => {
5147
5198
  Object.entries(playgroundRequestContext).forEach(([key, value]) => {
5148
5199
  requestContext$1.set(key, value);
5149
5200
  });
5150
- const stream = await workflow.resumeStreamVNext({ runId, step, resumeData, requestContext: requestContext$1 });
5201
+ const stream = await workflow.resumeStreamVNext({
5202
+ runId,
5203
+ step,
5204
+ resumeData,
5205
+ requestContext: requestContext$1,
5206
+ tracingOptions: settings?.tracingOptions
5207
+ });
5151
5208
  if (!stream) {
5152
5209
  return handleStreamError(new Error("No stream returned"), "No stream returned", setIsStreaming);
5153
5210
  }
@@ -5203,7 +5260,11 @@ const useStreamWorkflow = () => {
5203
5260
  Object.entries(playgroundRequestContext).forEach(([key, value]) => {
5204
5261
  requestContext$1.set(key, value);
5205
5262
  });
5206
- const stream = await workflow.timeTravelStream({ ...params, requestContext: requestContext$1 });
5263
+ const stream = await workflow.timeTravelStream({
5264
+ ...params,
5265
+ requestContext: requestContext$1,
5266
+ tracingOptions: settings?.tracingOptions
5267
+ });
5207
5268
  if (!stream) {
5208
5269
  return handleStreamError(new Error("No stream returned"), "No stream returned", setIsStreaming);
5209
5270
  }
@@ -5328,16 +5389,35 @@ const useWorkflow = (workflowId) => {
5328
5389
  });
5329
5390
  };
5330
5391
 
5392
+ const PER_PAGE = 20;
5331
5393
  const useWorkflowRuns = (workflowId, { enabled = true } = {}) => {
5332
5394
  const client = react$1.useMastraClient();
5333
- return reactQuery.useQuery({
5395
+ const { inView: isEndOfListInView, setRef: setEndOfListElement } = useInView();
5396
+ const query = reactQuery.useInfiniteQuery({
5334
5397
  queryKey: ["workflow-runs", workflowId],
5335
- queryFn: () => client.getWorkflow(workflowId).runs({ perPage: 50, page: 0 }),
5398
+ queryFn: ({ pageParam }) => client.getWorkflow(workflowId).runs({ limit: PER_PAGE, offset: pageParam * PER_PAGE }),
5399
+ initialPageParam: 0,
5400
+ getNextPageParam: (lastPage, _, lastPageParam) => {
5401
+ if (lastPage.runs.length < PER_PAGE) {
5402
+ return void 0;
5403
+ }
5404
+ return lastPageParam + 1;
5405
+ },
5406
+ select: (data) => {
5407
+ return data.pages.flatMap((page) => page.runs);
5408
+ },
5409
+ retry: false,
5336
5410
  enabled,
5337
5411
  refetchInterval: 5e3,
5338
5412
  gcTime: 0,
5339
5413
  staleTime: 0
5340
5414
  });
5415
+ React.useEffect(() => {
5416
+ if (isEndOfListInView && query.hasNextPage && !query.isFetchingNextPage) {
5417
+ query.fetchNextPage();
5418
+ }
5419
+ }, [isEndOfListInView, query.hasNextPage, query.isFetchingNextPage]);
5420
+ return { ...query, setEndOfListElement };
5341
5421
  };
5342
5422
  const useWorkflowRunExecutionResult = (workflowId, runId, refetchInterval) => {
5343
5423
  const client = react$1.useMastraClient();
@@ -6930,6 +7010,41 @@ const DiscriminatedUnionField = ({ field, path }) => {
6930
7010
  ] }, field.key);
6931
7011
  };
6932
7012
 
7013
+ react$3.buildZodFieldConfig();
7014
+ function removeEmptyValues(values) {
7015
+ const result = {};
7016
+ for (const key in values) {
7017
+ const value = values[key];
7018
+ if ([null, void 0, "", [], {}].includes(value)) {
7019
+ continue;
7020
+ }
7021
+ if (Array.isArray(value)) {
7022
+ const newArray = value.map((item) => {
7023
+ if (typeof item === "object") {
7024
+ const cleanedItem = removeEmptyValues(item);
7025
+ if (Object.keys(cleanedItem).length > 0) {
7026
+ return cleanedItem;
7027
+ }
7028
+ return null;
7029
+ }
7030
+ return item;
7031
+ });
7032
+ const filteredArray = newArray.filter((item) => item !== null);
7033
+ if (filteredArray.length > 0) {
7034
+ result[key] = filteredArray;
7035
+ }
7036
+ } else if (typeof value === "object") {
7037
+ const cleanedValue = removeEmptyValues(value);
7038
+ if (Object.keys(cleanedValue).length > 0) {
7039
+ result[key] = cleanedValue;
7040
+ }
7041
+ } else {
7042
+ result[key] = value;
7043
+ }
7044
+ }
7045
+ return result;
7046
+ }
7047
+
6933
7048
  function CustomAutoForm({
6934
7049
  schema,
6935
7050
  onSubmit = () => {
@@ -6958,7 +7073,7 @@ function CustomAutoForm({
6958
7073
  }
6959
7074
  }, [onFormInit, methods]);
6960
7075
  const handleSubmit = async (dataRaw) => {
6961
- const data = core.removeEmptyValues(dataRaw);
7076
+ const data = removeEmptyValues(dataRaw);
6962
7077
  const validationResult = schema.validateSchema(data);
6963
7078
  if (validationResult.success) {
6964
7079
  await onSubmit(validationResult.data, methods);
@@ -7038,41 +7153,6 @@ function AutoForm({
7038
7153
  );
7039
7154
  }
7040
7155
 
7041
- react$3.buildZodFieldConfig();
7042
- function removeEmptyValues(values) {
7043
- const result = {};
7044
- for (const key in values) {
7045
- const value = values[key];
7046
- if ([null, void 0, "", [], {}].includes(value)) {
7047
- continue;
7048
- }
7049
- if (Array.isArray(value)) {
7050
- const newArray = value.map((item) => {
7051
- if (typeof item === "object") {
7052
- const cleanedItem = removeEmptyValues(item);
7053
- if (Object.keys(cleanedItem).length > 0) {
7054
- return cleanedItem;
7055
- }
7056
- return null;
7057
- }
7058
- return item;
7059
- });
7060
- const filteredArray = newArray.filter((item) => item !== null);
7061
- if (filteredArray.length > 0) {
7062
- result[key] = filteredArray;
7063
- }
7064
- } else if (typeof value === "object") {
7065
- const cleanedValue = removeEmptyValues(value);
7066
- if (Object.keys(cleanedValue).length > 0) {
7067
- result[key] = cleanedValue;
7068
- }
7069
- } else {
7070
- result[key] = value;
7071
- }
7072
- }
7073
- return result;
7074
- }
7075
-
7076
7156
  const labelVariants = cva("text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70");
7077
7157
  const Label = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(LabelPrimitive__namespace.Root, { ref, className: clsx(labelVariants(), className), ...props }));
7078
7158
  Label.displayName = LabelPrimitive__namespace.Root.displayName;
@@ -7113,6 +7193,9 @@ function inferFieldType(schema, fieldConfig) {
7113
7193
  }
7114
7194
  return "union";
7115
7195
  }
7196
+ if (schema instanceof z.z.ZodDiscriminatedUnion) {
7197
+ return "discriminated-union";
7198
+ }
7116
7199
  return "string";
7117
7200
  }
7118
7201
 
@@ -7241,8 +7324,22 @@ class CustomZodProvider extends v4.ZodProvider {
7241
7324
  }
7242
7325
  validateSchema(values) {
7243
7326
  const cleanedValues = removeEmptyValues(values);
7244
- const result = super.validateSchema(cleanedValues);
7245
- return result;
7327
+ try {
7328
+ const validationResult = this._schema.safeParse(cleanedValues);
7329
+ if (validationResult.success) {
7330
+ return { success: true, data: validationResult.data };
7331
+ } else {
7332
+ return {
7333
+ success: false,
7334
+ errors: validationResult.error.issues.map((error) => ({
7335
+ path: error.path,
7336
+ message: error.message
7337
+ }))
7338
+ };
7339
+ }
7340
+ } catch (error) {
7341
+ throw error;
7342
+ }
7246
7343
  }
7247
7344
  parseSchema() {
7248
7345
  return parseSchema(this._schema);
@@ -7607,7 +7704,7 @@ const WorkflowTimeTravelForm = ({ stepKey, closeModal }) => {
7607
7704
  }
7608
7705
  try {
7609
7706
  const parsed = superjson.parse(stepDefinition.inputSchema);
7610
- return { schema: resolveSerializedZodOutput(jsonSchemaToZod(parsed)), schemaError: null };
7707
+ return { schema: resolveSerializedZodOutput(jsonToZod.jsonSchemaToZod(parsed)), schemaError: null };
7611
7708
  } catch (err) {
7612
7709
  console.error("Failed to parse step schema", err);
7613
7710
  return { schema: z.z.record(z.z.string(), z.z.any()) };
@@ -7737,7 +7834,7 @@ const WorkflowStepActionBar = ({
7737
7834
  const { withoutTimeTravel } = React.useContext(WorkflowRunContext);
7738
7835
  const dialogContentClass = "bg-surface2 rounded-lg border-sm border-border1 max-w-4xl w-full px-0";
7739
7836
  const dialogTitleClass = "border-b-sm border-border1 pb-4 px-6";
7740
- const showTimeTravel = !withoutTimeTravel && stepKey;
7837
+ const showTimeTravel = !withoutTimeTravel && stepKey && !mapConfig;
7741
7838
  return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: (input || output || error || mapConfig || resumeData || onShowNestedGraph || showTimeTravel) && /* @__PURE__ */ jsxRuntime.jsxs(
7742
7839
  "div",
7743
7840
  {
@@ -8602,7 +8699,7 @@ function WorkflowTrigger({
8602
8699
  }
8603
8700
  if (!workflow) return null;
8604
8701
  const isSuspendedSteps = suspendedSteps.length > 0;
8605
- const zodInputSchema = triggerSchema ? resolveSerializedZodOutput(jsonSchemaToZod(superjson.parse(triggerSchema))) : null;
8702
+ const zodInputSchema = triggerSchema ? resolveSerializedZodOutput(jsonToZod.jsonSchemaToZod(superjson.parse(triggerSchema))) : null;
8606
8703
  const workflowActivePaths = streamResultToUse?.steps ?? {};
8607
8704
  const hasWorkflowActivePaths = Object.values(workflowActivePaths).length > 0;
8608
8705
  const doneStatuses = ["success", "failed", "canceled"];
@@ -8638,7 +8735,7 @@ function WorkflowTrigger({
8638
8735
  !isStreamingWorkflow && isSuspendedSteps && suspendedSteps?.map((step) => {
8639
8736
  const stepDefinition = workflow.allSteps[step.stepId];
8640
8737
  if (!stepDefinition || stepDefinition.isWorkflow) return null;
8641
- const stepSchema = stepDefinition?.resumeSchema ? resolveSerializedZodOutput(jsonSchemaToZod(superjson.parse(stepDefinition.resumeSchema))) : z.z.record(z.z.string(), z.z.any());
8738
+ const stepSchema = stepDefinition?.resumeSchema ? resolveSerializedZodOutput(jsonToZod.jsonSchemaToZod(superjson.parse(stepDefinition.resumeSchema))) : z.z.record(z.z.string(), z.z.any());
8642
8739
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col px-4", children: [
8643
8740
  /* @__PURE__ */ jsxRuntime.jsx(Text, { variant: "secondary", className: "text-mastra-el-3", size: "xs", children: step.stepId }),
8644
8741
  step.suspendPayload && /* @__PURE__ */ jsxRuntime.jsx("div", { "data-testid": "suspended-payload", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -9216,6 +9313,104 @@ const EntityHeader = ({ icon, title, isLoading, children }) => {
9216
9313
  ] });
9217
9314
  };
9218
9315
 
9316
+ const Tabs$1 = TabsPrimitive__namespace.Root;
9317
+ const TabsList = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
9318
+ TabsPrimitive__namespace.List,
9319
+ {
9320
+ ref,
9321
+ className: clsx("bg-muted text-muted-foreground inline-flex items-center bg-transparent", className),
9322
+ ...props
9323
+ }
9324
+ ));
9325
+ TabsList.displayName = TabsPrimitive__namespace.List.displayName;
9326
+ const TabsTrigger = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
9327
+ TabsPrimitive__namespace.Trigger,
9328
+ {
9329
+ ref,
9330
+ className: cn(
9331
+ "-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",
9332
+ className
9333
+ ),
9334
+ ...props
9335
+ }
9336
+ ));
9337
+ TabsTrigger.displayName = TabsPrimitive__namespace.Trigger.displayName;
9338
+ const TabsContent = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(TabsPrimitive__namespace.Content, { ref, className: cn("mt-2 -outline-offset-2", className), ...props }));
9339
+ TabsContent.displayName = TabsPrimitive__namespace.Content.displayName;
9340
+
9341
+ const PlaygroundTabs = ({
9342
+ children,
9343
+ defaultTab,
9344
+ value,
9345
+ onValueChange,
9346
+ className
9347
+ }) => {
9348
+ const [internalTab, setInternalTab] = React.useState(defaultTab);
9349
+ const isControlled = value !== void 0 && onValueChange !== void 0;
9350
+ const currentTab = isControlled ? value : internalTab;
9351
+ const handleTabChange = (newValue) => {
9352
+ const typedValue = newValue;
9353
+ if (isControlled) {
9354
+ onValueChange(typedValue);
9355
+ } else {
9356
+ setInternalTab(typedValue);
9357
+ }
9358
+ };
9359
+ return /* @__PURE__ */ jsxRuntime.jsx(Tabs$1, { value: currentTab, onValueChange: handleTabChange, className: cn("h-full", className), children });
9360
+ };
9361
+ const TabList$1 = ({ children, className }) => {
9362
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("w-full overflow-x-auto", className), children: /* @__PURE__ */ jsxRuntime.jsx(TabsList, { className: "border-b border-border1 flex min-w-full shrink-0", children }) });
9363
+ };
9364
+ const Tab$1 = ({ children, value, onClick }) => {
9365
+ return /* @__PURE__ */ jsxRuntime.jsx(
9366
+ TabsTrigger,
9367
+ {
9368
+ value,
9369
+ 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",
9370
+ onClick,
9371
+ children
9372
+ }
9373
+ );
9374
+ };
9375
+ const TabContent$1 = ({ children, value }) => {
9376
+ return /* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value, className: "h-full overflow-hidden flex flex-col", children });
9377
+ };
9378
+
9379
+ const TracingRunOptions = () => {
9380
+ const theme = useCodemirrorTheme$1();
9381
+ const { settings, setSettings } = useTracingSettings();
9382
+ const handleChange = (value) => {
9383
+ if (!value) {
9384
+ return setSettings({ ...settings, tracingOptions: void 0 });
9385
+ }
9386
+ try {
9387
+ const parsed = JSON.parse(value);
9388
+ if (typeof parsed === "object" && parsed !== null) {
9389
+ setSettings({ ...settings, tracingOptions: parsed });
9390
+ }
9391
+ } catch {
9392
+ }
9393
+ };
9394
+ let strValue = "{}";
9395
+ try {
9396
+ strValue = JSON.stringify(settings?.tracingOptions, null, 2);
9397
+ } catch {
9398
+ }
9399
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2 px-5 py-2", children: [
9400
+ /* @__PURE__ */ jsxRuntime.jsx(Txt, { as: "h3", variant: "ui-md", className: "text-icon3", children: "Tracing Options" }),
9401
+ /* @__PURE__ */ jsxRuntime.jsx(
9402
+ CodeMirror,
9403
+ {
9404
+ value: strValue,
9405
+ onChange: handleChange,
9406
+ theme,
9407
+ extensions: [langJson.jsonLanguage],
9408
+ className: "h-[400px] overflow-y-scroll bg-surface3 rounded-lg overflow-hidden p-3"
9409
+ }
9410
+ )
9411
+ ] });
9412
+ };
9413
+
9219
9414
  function WorkflowInformation({ workflowId, initialRunId }) {
9220
9415
  const { data: workflow, isLoading, error } = useWorkflow(workflowId);
9221
9416
  const {
@@ -9229,6 +9424,7 @@ function WorkflowInformation({ workflowId, initialRunId }) {
9229
9424
  cancelWorkflowRun,
9230
9425
  isCancellingWorkflowRun
9231
9426
  } = React.useContext(WorkflowRunContext);
9427
+ const [tab, setTab] = React.useState("current-run");
9232
9428
  const [runId, setRunId] = React.useState("");
9233
9429
  const { handleCopy } = useCopyToClipboard({ text: workflowId });
9234
9430
  const stepsCount = Object.keys(workflow?.steps ?? {}).length;
@@ -9258,39 +9454,46 @@ function WorkflowInformation({ workflowId, initialRunId }) {
9258
9454
  stepsCount > 1 ? "s" : ""
9259
9455
  ] })
9260
9456
  ] }) }),
9261
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-y-auto border-t-sm border-border1", children: workflowId ? initialRunId ? /* @__PURE__ */ jsxRuntime.jsx(
9262
- WorkflowRunDetail,
9263
- {
9264
- workflowId,
9265
- runId: initialRunId,
9266
- setRunId,
9267
- workflow: workflow ?? void 0,
9268
- isLoading,
9269
- createWorkflowRun,
9270
- streamWorkflow,
9271
- resumeWorkflow,
9272
- streamResult,
9273
- isStreamingWorkflow,
9274
- isCancellingWorkflowRun,
9275
- cancelWorkflowRun,
9276
- observeWorkflowStream
9277
- }
9278
- ) : /* @__PURE__ */ jsxRuntime.jsx(
9279
- WorkflowTrigger,
9280
- {
9281
- workflowId,
9282
- setRunId,
9283
- workflow: workflow ?? void 0,
9284
- isLoading,
9285
- createWorkflowRun,
9286
- streamWorkflow,
9287
- resumeWorkflow,
9288
- streamResult,
9289
- isStreamingWorkflow,
9290
- isCancellingWorkflowRun,
9291
- cancelWorkflowRun
9292
- }
9293
- ) : null })
9457
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1 overflow-hidden border-t-sm border-border1 flex flex-col", children: /* @__PURE__ */ jsxRuntime.jsxs(PlaygroundTabs, { defaultTab: "current-run", value: tab, onValueChange: setTab, children: [
9458
+ /* @__PURE__ */ jsxRuntime.jsxs(TabList$1, { children: [
9459
+ /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "current-run", children: "Current Run" }),
9460
+ /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "run-options", children: "Run options" })
9461
+ ] }),
9462
+ /* @__PURE__ */ jsxRuntime.jsx(TabContent$1, { value: "current-run", children: workflowId ? initialRunId ? /* @__PURE__ */ jsxRuntime.jsx(
9463
+ WorkflowRunDetail,
9464
+ {
9465
+ workflowId,
9466
+ runId: initialRunId,
9467
+ setRunId,
9468
+ workflow: workflow ?? void 0,
9469
+ isLoading,
9470
+ createWorkflowRun,
9471
+ streamWorkflow,
9472
+ resumeWorkflow,
9473
+ streamResult,
9474
+ isStreamingWorkflow,
9475
+ isCancellingWorkflowRun,
9476
+ cancelWorkflowRun,
9477
+ observeWorkflowStream
9478
+ }
9479
+ ) : /* @__PURE__ */ jsxRuntime.jsx(
9480
+ WorkflowTrigger,
9481
+ {
9482
+ workflowId,
9483
+ setRunId,
9484
+ workflow: workflow ?? void 0,
9485
+ isLoading,
9486
+ createWorkflowRun,
9487
+ streamWorkflow,
9488
+ resumeWorkflow,
9489
+ streamResult,
9490
+ isStreamingWorkflow,
9491
+ isCancellingWorkflowRun,
9492
+ cancelWorkflowRun
9493
+ }
9494
+ ) : null }),
9495
+ /* @__PURE__ */ jsxRuntime.jsx(TabContent$1, { value: "run-options", children: /* @__PURE__ */ jsxRuntime.jsx(TracingRunOptions, {}) })
9496
+ ] }) })
9294
9497
  ] });
9295
9498
  }
9296
9499
 
@@ -9528,7 +9731,7 @@ const WorkflowBadge = ({
9528
9731
  const { data: runs, isLoading: isRunsLoading } = useWorkflowRuns(workflowId, {
9529
9732
  enabled: Boolean(runId) && !isStreaming
9530
9733
  });
9531
- const run = runs?.runs.find((run2) => run2.runId === runId);
9734
+ const run = runs?.find((run2) => run2.runId === runId);
9532
9735
  const isLoading = isRunsLoading || !run;
9533
9736
  const snapshot = typeof run?.snapshot === "object" ? run?.snapshot : void 0;
9534
9737
  const selectionReason = metadata?.mode === "network" ? metadata.selectionReason : void 0;
@@ -10368,8 +10571,12 @@ const useSpeechRecognition = ({
10368
10571
  const agent2 = client.getAgent(agentId);
10369
10572
  const check = async () => {
10370
10573
  try {
10371
- await agent2.voice.getSpeakers(requestContext);
10372
- setAgent(agent2);
10574
+ const speakers = await agent2.voice.getSpeakers(requestContext);
10575
+ if (speakers.length > 0) {
10576
+ setAgent(agent2);
10577
+ } else {
10578
+ setAgent(null);
10579
+ }
10373
10580
  } catch (error) {
10374
10581
  setAgent(null);
10375
10582
  }
@@ -11113,8 +11320,12 @@ const useAdapters = (agentId) => {
11113
11320
  const check = async () => {
11114
11321
  const agent = baseClient.getAgent(agentId);
11115
11322
  try {
11116
- await agent.voice.getSpeakers(requestContext);
11117
- setSpeechAdapter(new VoiceAttachmentAdapter(agent));
11323
+ const speakers = await agent.voice.getSpeakers(requestContext);
11324
+ if (speakers.length > 0) {
11325
+ setSpeechAdapter(new VoiceAttachmentAdapter(agent));
11326
+ } else {
11327
+ setSpeechAdapter(new react.WebSpeechSynthesisAdapter());
11328
+ }
11118
11329
  setIsReady(true);
11119
11330
  } catch {
11120
11331
  setSpeechAdapter(new react.WebSpeechSynthesisAdapter());
@@ -11382,6 +11593,7 @@ function MastraRuntimeProvider({
11382
11593
  modelVersion
11383
11594
  }) {
11384
11595
  const { prompt: instructions } = useAgentPromptExperiment();
11596
+ const { settings: tracingSettings } = useTracingSettings();
11385
11597
  const [isLegacyRunning, setIsLegacyRunning] = React.useState(false);
11386
11598
  const [legacyMessages, setLegacyMessages] = React.useState(
11387
11599
  () => memory ? initializeMessageState(initialLegacyMessages || []) : []
@@ -11461,6 +11673,7 @@ function MastraRuntimeProvider({
11461
11673
  threadId,
11462
11674
  modelSettings: modelSettingsArgs,
11463
11675
  signal: controller.signal,
11676
+ tracingOptions: tracingSettings?.tracingOptions,
11464
11677
  onNetworkChunk: async (chunk) => {
11465
11678
  if (chunk.type === "tool-execution-end" && chunk.payload?.toolName === "updateWorkingMemory" && typeof chunk.payload.result === "object" && "success" in chunk.payload.result && chunk.payload.result?.success) {
11466
11679
  refreshWorkingMemory?.();
@@ -11479,7 +11692,8 @@ function MastraRuntimeProvider({
11479
11692
  requestContext: requestContextInstance,
11480
11693
  threadId,
11481
11694
  modelSettings: modelSettingsArgs,
11482
- signal: controller.signal
11695
+ signal: controller.signal,
11696
+ tracingOptions: tracingSettings?.tracingOptions
11483
11697
  });
11484
11698
  await refreshThreadList?.();
11485
11699
  return;
@@ -11491,6 +11705,7 @@ function MastraRuntimeProvider({
11491
11705
  requestContext: requestContextInstance,
11492
11706
  threadId,
11493
11707
  modelSettings: modelSettingsArgs,
11708
+ tracingOptions: tracingSettings?.tracingOptions,
11494
11709
  onChunk: async (chunk) => {
11495
11710
  if (chunk.type === "finish") {
11496
11711
  await refreshThreadList?.();
@@ -15750,7 +15965,7 @@ const AgentToolPanel = ({ toolId, agentId }) => {
15750
15965
  playgroundRequestContext
15751
15966
  });
15752
15967
  };
15753
- const zodInputSchema = tool?.inputSchema ? resolveSerializedZodOutput(jsonSchemaToZod(superjson.parse(tool?.inputSchema))) : z.z.object({});
15968
+ const zodInputSchema = tool?.inputSchema ? resolveSerializedZodOutput(jsonToZod.jsonSchemaToZod(superjson.parse(tool?.inputSchema))) : z.z.object({});
15754
15969
  if (isAgentLoading || error) return null;
15755
15970
  if (!tool)
15756
15971
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-12 text-center px-6", children: /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "header-md", className: "text-icon3", children: "Tool not found" }) });
@@ -16484,69 +16699,6 @@ function AgentMemory({ agentId, threadId }) {
16484
16699
  ] });
16485
16700
  }
16486
16701
 
16487
- const Tabs$1 = TabsPrimitive__namespace.Root;
16488
- const TabsList = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16489
- TabsPrimitive__namespace.List,
16490
- {
16491
- ref,
16492
- className: clsx("bg-muted text-muted-foreground inline-flex items-center bg-transparent", className),
16493
- ...props
16494
- }
16495
- ));
16496
- TabsList.displayName = TabsPrimitive__namespace.List.displayName;
16497
- const TabsTrigger = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
16498
- TabsPrimitive__namespace.Trigger,
16499
- {
16500
- ref,
16501
- className: cn(
16502
- "-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",
16503
- className
16504
- ),
16505
- ...props
16506
- }
16507
- ));
16508
- TabsTrigger.displayName = TabsPrimitive__namespace.Trigger.displayName;
16509
- const TabsContent = React__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(TabsPrimitive__namespace.Content, { ref, className: cn("mt-2 -outline-offset-2", className), ...props }));
16510
- TabsContent.displayName = TabsPrimitive__namespace.Content.displayName;
16511
-
16512
- const PlaygroundTabs = ({
16513
- children,
16514
- defaultTab,
16515
- value,
16516
- onValueChange,
16517
- className
16518
- }) => {
16519
- const [internalTab, setInternalTab] = React.useState(defaultTab);
16520
- const isControlled = value !== void 0 && onValueChange !== void 0;
16521
- const currentTab = isControlled ? value : internalTab;
16522
- const handleTabChange = (newValue) => {
16523
- const typedValue = newValue;
16524
- if (isControlled) {
16525
- onValueChange(typedValue);
16526
- } else {
16527
- setInternalTab(typedValue);
16528
- }
16529
- };
16530
- return /* @__PURE__ */ jsxRuntime.jsx(Tabs$1, { value: currentTab, onValueChange: handleTabChange, className: cn("h-full", className), children });
16531
- };
16532
- const TabList$1 = ({ children, className }) => {
16533
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn("w-full overflow-x-auto", className), children: /* @__PURE__ */ jsxRuntime.jsx(TabsList, { className: "border-b border-border1 flex min-w-full shrink-0", children }) });
16534
- };
16535
- const Tab$1 = ({ children, value, onClick }) => {
16536
- return /* @__PURE__ */ jsxRuntime.jsx(
16537
- TabsTrigger,
16538
- {
16539
- value,
16540
- 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",
16541
- onClick,
16542
- children
16543
- }
16544
- );
16545
- };
16546
- const TabContent$1 = ({ children, value }) => {
16547
- return /* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value, className: "h-full overflow-hidden flex flex-col", children });
16548
- };
16549
-
16550
16702
  function AgentInformation({ agentId, threadId }) {
16551
16703
  const { data: memory } = useMemory(agentId);
16552
16704
  const hasMemory = Boolean(memory?.result);
@@ -16556,11 +16708,13 @@ function AgentInformation({ agentId, threadId }) {
16556
16708
  /* @__PURE__ */ jsxRuntime.jsxs(TabList$1, { children: [
16557
16709
  /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "overview", children: "Overview" }),
16558
16710
  /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "model-settings", children: "Model Settings" }),
16559
- hasMemory && /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "memory", children: "Memory" })
16711
+ hasMemory && /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "memory", children: "Memory" }),
16712
+ /* @__PURE__ */ jsxRuntime.jsx(Tab$1, { value: "tracing-options", children: "Tracing Options" })
16560
16713
  ] }),
16561
16714
  /* @__PURE__ */ jsxRuntime.jsx(TabContent$1, { value: "overview", children: /* @__PURE__ */ jsxRuntime.jsx(AgentMetadata, { agentId }) }),
16562
16715
  /* @__PURE__ */ jsxRuntime.jsx(TabContent$1, { value: "model-settings", children: /* @__PURE__ */ jsxRuntime.jsx(AgentSettings, { agentId }) }),
16563
- hasMemory && /* @__PURE__ */ jsxRuntime.jsx(TabContent$1, { value: "memory", children: /* @__PURE__ */ jsxRuntime.jsx(AgentMemory, { agentId, threadId }) })
16716
+ hasMemory && /* @__PURE__ */ jsxRuntime.jsx(TabContent$1, { value: "memory", children: /* @__PURE__ */ jsxRuntime.jsx(AgentMemory, { agentId, threadId }) }),
16717
+ /* @__PURE__ */ jsxRuntime.jsx(TabContent$1, { value: "tracing-options", children: /* @__PURE__ */ jsxRuntime.jsx(TracingRunOptions, {}) })
16564
16718
  ] })
16565
16719
  ] });
16566
16720
  }
@@ -16820,7 +16974,7 @@ const ToolPanel = ({ toolId }) => {
16820
16974
  requestContext: playgroundRequestContext
16821
16975
  });
16822
16976
  };
16823
- const zodInputSchema = tool?.inputSchema ? resolveSerializedZodOutput(jsonSchemaToZod(superjson.parse(tool?.inputSchema))) : z.z.object({});
16977
+ const zodInputSchema = tool?.inputSchema ? resolveSerializedZodOutput(jsonToZod.jsonSchemaToZod(superjson.parse(tool?.inputSchema))) : z.z.object({});
16824
16978
  if (isLoading || error) return null;
16825
16979
  if (!tool)
16826
16980
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-12 text-center px-6", children: /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "header-md", className: "text-icon3", children: "Tool not found" }) });
@@ -19090,23 +19244,27 @@ const parseError = (error) => {
19090
19244
 
19091
19245
  const WorkflowRunList = ({ workflowId, runId }) => {
19092
19246
  const { Link, paths } = useLinkComponent();
19093
- const { isLoading, data: runs } = useWorkflowRuns(workflowId);
19094
- const actualRuns = runs?.runs || [];
19247
+ const { isLoading, data: runs, setEndOfListElement, isFetchingNextPage } = useWorkflowRuns(workflowId);
19248
+ const actualRuns = runs || [];
19095
19249
  if (isLoading) {
19096
19250
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children: /* @__PURE__ */ jsxRuntime.jsx(Skeleton, { className: "h-[600px]" }) });
19097
19251
  }
19098
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-y-auto h-full w-full", children: /* @__PURE__ */ jsxRuntime.jsx(Threads, { children: /* @__PURE__ */ jsxRuntime.jsxs(ThreadList, { children: [
19099
- /* @__PURE__ */ jsxRuntime.jsx(ThreadItem, { children: /* @__PURE__ */ jsxRuntime.jsx(ThreadLink, { as: Link, to: paths.workflowLink(workflowId), children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-accent1 flex items-center gap-4", children: [
19100
- /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "bg-surface4 rounded-lg", size: "lg", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, {}) }),
19101
- "New workflow run"
19102
- ] }) }) }),
19103
- actualRuns.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-md", className: "text-icon3 py-3 px-5", children: "Your run history will appear here once you run the workflow" }),
19104
- actualRuns.map((run) => /* @__PURE__ */ jsxRuntime.jsx(ThreadItem, { isActive: run.runId === runId, className: "h-auto", children: /* @__PURE__ */ jsxRuntime.jsxs(ThreadLink, { as: Link, to: paths.workflowRunLink(workflowId, run.runId), children: [
19105
- typeof run?.snapshot === "object" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pb-1", children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowRunStatusBadge, { status: run.snapshot.status }) }),
19106
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate max-w-[14rem] text-muted-foreground", children: run.runId }),
19107
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: typeof run?.snapshot === "string" ? "" : run?.snapshot?.timestamp ? dateFns.formatDate(run?.snapshot?.timestamp, "MMM d, yyyy h:mm a") : "" })
19108
- ] }) }, run.runId))
19109
- ] }) }) });
19252
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "overflow-y-auto h-full w-full", children: [
19253
+ /* @__PURE__ */ jsxRuntime.jsx(Threads, { children: /* @__PURE__ */ jsxRuntime.jsxs(ThreadList, { children: [
19254
+ /* @__PURE__ */ jsxRuntime.jsx(ThreadItem, { children: /* @__PURE__ */ jsxRuntime.jsx(ThreadLink, { as: Link, to: paths.workflowLink(workflowId), children: /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-accent1 flex items-center gap-4", children: [
19255
+ /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "bg-surface4 rounded-lg", size: "lg", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Plus, {}) }),
19256
+ "New workflow run"
19257
+ ] }) }) }),
19258
+ actualRuns.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "ui-md", className: "text-icon3 py-3 px-5", children: "Your run history will appear here once you run the workflow" }),
19259
+ actualRuns.map((run) => /* @__PURE__ */ jsxRuntime.jsx(ThreadItem, { isActive: run.runId === runId, className: "h-auto", children: /* @__PURE__ */ jsxRuntime.jsxs(ThreadLink, { as: Link, to: paths.workflowRunLink(workflowId, run.runId), children: [
19260
+ typeof run?.snapshot === "object" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "pb-1", children: /* @__PURE__ */ jsxRuntime.jsx(WorkflowRunStatusBadge, { status: run.snapshot.status }) }),
19261
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate max-w-[14rem] text-muted-foreground", children: run.runId }),
19262
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: typeof run?.snapshot === "string" ? "" : run?.snapshot?.timestamp ? dateFns.formatDate(run?.snapshot?.timestamp, "MMM d, yyyy h:mm a") : "" })
19263
+ ] }) }, run.runId))
19264
+ ] }) }),
19265
+ isFetchingNextPage && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center items-center", children: /* @__PURE__ */ jsxRuntime.jsx(Icon, { children: /* @__PURE__ */ jsxRuntime.jsx(Spinner, {}) }) }),
19266
+ /* @__PURE__ */ jsxRuntime.jsx("div", { ref: setEndOfListElement })
19267
+ ] });
19110
19268
  };
19111
19269
  const WorkflowRunStatusBadge = ({ status }) => {
19112
19270
  if (status === "running") {
@@ -19310,7 +19468,7 @@ const MCPToolPanel = ({ toolId, serverId }) => {
19310
19468
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "py-12 text-center px-6", children: /* @__PURE__ */ jsxRuntime.jsx(Txt, { variant: "header-md", className: "text-icon3", children: "Tool not found" }) });
19311
19469
  let zodInputSchema;
19312
19470
  try {
19313
- zodInputSchema = resolveSerializedZodOutput(jsonSchemaToZod(tool.inputSchema));
19471
+ zodInputSchema = resolveSerializedZodOutput(jsonToZod.jsonSchemaToZod(tool.inputSchema));
19314
19472
  } catch (e) {
19315
19473
  console.error("Error processing input schema:", e);
19316
19474
  toast.error("Failed to process tool input schema.");
@@ -19715,6 +19873,8 @@ exports.TraceTimelineLegend = TraceTimelineLegend;
19715
19873
  exports.TraceTimelineSpan = TraceTimelineSpan;
19716
19874
  exports.TracesList = TracesList;
19717
19875
  exports.TracesTools = TracesTools;
19876
+ exports.TracingSettingsContext = TracingSettingsContext;
19877
+ exports.TracingSettingsProvider = TracingSettingsProvider;
19718
19878
  exports.TsIcon = TsIcon;
19719
19879
  exports.Txt = Txt;
19720
19880
  exports.TxtCell = TxtCell;
@@ -19782,6 +19942,7 @@ exports.useThreads = useThreads;
19782
19942
  exports.useTool = useTool;
19783
19943
  exports.useTools = useTools;
19784
19944
  exports.useTraceSpanScores = useTraceSpanScores;
19945
+ exports.useTracingSettings = useTracingSettings;
19785
19946
  exports.useUpdateAgentModel = useUpdateAgentModel;
19786
19947
  exports.useUpdateModelInModelList = useUpdateModelInModelList;
19787
19948
  exports.useWorkflow = useWorkflow;