@mastra/playground-ui 6.8.0 → 6.9.0

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/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # @mastra/playground-ui
2
2
 
3
+ ## 6.9.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Update peer dependencies to match core package version bump (0.23.4) ([#9487](https://github.com/mastra-ai/mastra/pull/9487))
8
+
9
+ ### Patch Changes
10
+
11
+ - update peerdeps ([`5ca1cca`](https://github.com/mastra-ai/mastra/commit/5ca1ccac61ffa7141e6d9fa8f22d3ad4d03bf5dc))
12
+
13
+ - Fixes issue where clicking the reset button in the model picker would fail to restore the original LanguageModelV2 (or any other types) object that was passed during agent construction. ([#9487](https://github.com/mastra-ai/mastra/pull/9487))
14
+
15
+ - Remove unused /model-providers API ([#9554](https://github.com/mastra-ai/mastra/pull/9554))
16
+
17
+ - Fix undefined runtimeContext using memory from playground ([#9548](https://github.com/mastra-ai/mastra/pull/9548))
18
+
19
+ - Updated dependencies [[`5ca1cca`](https://github.com/mastra-ai/mastra/commit/5ca1ccac61ffa7141e6d9fa8f22d3ad4d03bf5dc), [`6d7e90d`](https://github.com/mastra-ai/mastra/commit/6d7e90db09713e6250f4d6c3d3cff1b4740e50f9), [`f78b908`](https://github.com/mastra-ai/mastra/commit/f78b9080e11af765969b36b4a619761056030840), [`23c2614`](https://github.com/mastra-ai/mastra/commit/23c26140fdbf04b8c59e8d7d52106d67dad962ec), [`139588d`](https://github.com/mastra-ai/mastra/commit/139588df7755c9111a3060f72a789c1a8c95e091), [`186b29b`](https://github.com/mastra-ai/mastra/commit/186b29bd51ac1dcc24ad3825fdb7207a6d6391a6), [`e365eda`](https://github.com/mastra-ai/mastra/commit/e365eda45795b43707310531cac1e2ce4e5a0712)]:
20
+ - @mastra/client-js@0.16.9
21
+ - @mastra/react@0.0.15
22
+ - @mastra/core@0.24.0
23
+
24
+ ## 6.9.0-alpha.0
25
+
26
+ ### Minor Changes
27
+
28
+ - Update peer dependencies to match core package version bump (0.23.4) ([#9487](https://github.com/mastra-ai/mastra/pull/9487))
29
+
30
+ ### Patch Changes
31
+
32
+ - update peerdeps ([`5ca1cca`](https://github.com/mastra-ai/mastra/commit/5ca1ccac61ffa7141e6d9fa8f22d3ad4d03bf5dc))
33
+
34
+ - Fixes issue where clicking the reset button in the model picker would fail to restore the original LanguageModelV2 (or any other types) object that was passed during agent construction. ([#9487](https://github.com/mastra-ai/mastra/pull/9487))
35
+
36
+ - Remove unused /model-providers API ([#9554](https://github.com/mastra-ai/mastra/pull/9554))
37
+
38
+ - Fix undefined runtimeContext using memory from playground ([#9548](https://github.com/mastra-ai/mastra/pull/9548))
39
+
40
+ - Updated dependencies [[`5ca1cca`](https://github.com/mastra-ai/mastra/commit/5ca1ccac61ffa7141e6d9fa8f22d3ad4d03bf5dc), [`6d7e90d`](https://github.com/mastra-ai/mastra/commit/6d7e90db09713e6250f4d6c3d3cff1b4740e50f9), [`f78b908`](https://github.com/mastra-ai/mastra/commit/f78b9080e11af765969b36b4a619761056030840), [`23c2614`](https://github.com/mastra-ai/mastra/commit/23c26140fdbf04b8c59e8d7d52106d67dad962ec), [`139588d`](https://github.com/mastra-ai/mastra/commit/139588df7755c9111a3060f72a789c1a8c95e091), [`186b29b`](https://github.com/mastra-ai/mastra/commit/186b29bd51ac1dcc24ad3825fdb7207a6d6391a6), [`e365eda`](https://github.com/mastra-ai/mastra/commit/e365eda45795b43707310531cac1e2ce4e5a0712)]:
41
+ - @mastra/client-js@0.16.9-alpha.0
42
+ - @mastra/react@0.0.15-alpha.0
43
+ - @mastra/core@0.24.0-alpha.0
44
+
3
45
  ## 6.8.0
4
46
 
5
47
  ### Minor Changes
package/dist/index.cjs.js CHANGED
@@ -8745,9 +8745,10 @@ const useAgentMessages = ({
8745
8745
  memory
8746
8746
  }) => {
8747
8747
  const client = react$3.useMastraClient();
8748
+ const { runtimeContext } = usePlaygroundStore();
8748
8749
  return reactQuery.useQuery({
8749
- queryKey: ["memory", "messages", threadId, agentId],
8750
- queryFn: () => client.getThreadMessages(threadId, { agentId }),
8750
+ queryKey: ["memory", "messages", threadId, agentId, "runtimeContext"],
8751
+ queryFn: () => client.getThreadMessages(threadId, { agentId, runtimeContext }),
8751
8752
  enabled: memory && Boolean(threadId),
8752
8753
  staleTime: 0,
8753
8754
  gcTime: 0,
@@ -10145,6 +10146,7 @@ function useAgentWorkingMemory(agentId, threadId, resourceId) {
10145
10146
  const [workingMemoryFormat, setWorkingMemoryFormat] = React.useState("markdown");
10146
10147
  const [isLoading, setIsLoading] = React.useState(true);
10147
10148
  const [isUpdating, setIsUpdating] = React.useState(false);
10149
+ const { runtimeContext } = usePlaygroundStore();
10148
10150
  const refetch = React.useCallback(async () => {
10149
10151
  setIsLoading(true);
10150
10152
  try {
@@ -10153,7 +10155,7 @@ function useAgentWorkingMemory(agentId, threadId, resourceId) {
10153
10155
  setIsLoading(false);
10154
10156
  return;
10155
10157
  }
10156
- const res = await client.getWorkingMemory({ agentId, threadId, resourceId });
10158
+ const res = await client.getWorkingMemory({ agentId, threadId, resourceId, runtimeContext });
10157
10159
  const { workingMemory, source, workingMemoryTemplate, threadExists: threadExists2 } = res;
10158
10160
  setThreadExists(threadExists2);
10159
10161
  setWorkingMemoryData(workingMemory);
@@ -10192,7 +10194,7 @@ function useAgentWorkingMemory(agentId, threadId, resourceId) {
10192
10194
  throw new Error("Invalid JSON working memory");
10193
10195
  }
10194
10196
  }
10195
- await client.updateWorkingMemory({ agentId, threadId, workingMemory: newMemory, resourceId });
10197
+ await client.updateWorkingMemory({ agentId, threadId, workingMemory: newMemory, resourceId, runtimeContext });
10196
10198
  refetch();
10197
10199
  } catch (error) {
10198
10200
  console.error("Error updating working memory", error);
@@ -14139,6 +14141,7 @@ const AgentMetadataModelSwitcher = ({
14139
14141
  defaultProvider,
14140
14142
  defaultModel,
14141
14143
  updateModel,
14144
+ resetModel,
14142
14145
  apiUrl = "/api/agents/providers"
14143
14146
  }) => {
14144
14147
  const [originalProvider] = React.useState(defaultProvider);
@@ -14156,6 +14159,10 @@ const AgentMetadataModelSwitcher = ({
14156
14159
  const [providersLoading, setProvidersLoading] = React.useState(true);
14157
14160
  const [highlightedProviderIndex, setHighlightedProviderIndex] = React.useState(-1);
14158
14161
  const [highlightedModelIndex, setHighlightedModelIndex] = React.useState(-1);
14162
+ React.useEffect(() => {
14163
+ setSelectedModel(defaultModel);
14164
+ setSelectedProvider(defaultProvider || "");
14165
+ }, [defaultModel, defaultProvider]);
14159
14166
  const modelInputRef = React.useRef(null);
14160
14167
  const providerInputRef = React.useRef(null);
14161
14168
  React.useEffect(() => {
@@ -14309,8 +14316,10 @@ const AgentMetadataModelSwitcher = ({
14309
14316
  ] });
14310
14317
  }
14311
14318
  const handleReset = async () => {
14312
- setSelectedProvider(cleanProviderId(originalProvider));
14313
- setSelectedModel(originalModel);
14319
+ if (!resetModel) {
14320
+ console.warn("Reset model function not provided");
14321
+ return;
14322
+ }
14314
14323
  setProviderSearch("");
14315
14324
  setModelSearch("");
14316
14325
  setIsSearchingProvider(false);
@@ -14319,10 +14328,7 @@ const AgentMetadataModelSwitcher = ({
14319
14328
  setShowModelSuggestions(false);
14320
14329
  try {
14321
14330
  setLoading(true);
14322
- await updateModel({
14323
- provider: originalProvider,
14324
- modelId: originalModel
14325
- });
14331
+ await resetModel();
14326
14332
  } catch (error) {
14327
14333
  console.error("Failed to reset model:", error);
14328
14334
  } finally {
@@ -14730,7 +14736,6 @@ Switch.displayName = SwitchPrimitives__namespace.Root.displayName;
14730
14736
 
14731
14737
  const AgentMetadataModelList = ({
14732
14738
  modelList,
14733
- modelProviders,
14734
14739
  updateModelInModelList,
14735
14740
  reorderModelList
14736
14741
  }) => {
@@ -14768,7 +14773,6 @@ const AgentMetadataModelList = ({
14768
14773
  AgentMetadataModelListItem,
14769
14774
  {
14770
14775
  modelConfig,
14771
- modelProviders,
14772
14776
  updateModelInModelList: updateModel,
14773
14777
  showDragHandle: hasMultipleModels,
14774
14778
  dragHandleProps: provided2.dragHandleProps
@@ -14779,7 +14783,6 @@ const AgentMetadataModelList = ({
14779
14783
  };
14780
14784
  const AgentMetadataModelListItem = ({
14781
14785
  modelConfig,
14782
- modelProviders,
14783
14786
  updateModelInModelList,
14784
14787
  showDragHandle,
14785
14788
  dragHandleProps
@@ -14793,7 +14796,6 @@ const AgentMetadataModelListItem = ({
14793
14796
  defaultProvider: modelConfig.model.provider,
14794
14797
  defaultModel: modelConfig.model.modelId,
14795
14798
  updateModel: (params) => updateModelInModelList({ modelConfigId: modelConfig.id, model: params }),
14796
- modelProviders,
14797
14799
  autoSave: true
14798
14800
  }
14799
14801
  ) }),
@@ -14824,7 +14826,7 @@ const AgentMetadata = ({
14824
14826
  promptSlot,
14825
14827
  hasMemoryEnabled,
14826
14828
  updateModel,
14827
- modelProviders,
14829
+ resetModel,
14828
14830
  updateModelInModelList,
14829
14831
  reorderModelList,
14830
14832
  modelVersion
@@ -14840,7 +14842,6 @@ const AgentMetadata = ({
14840
14842
  AgentMetadataModelList,
14841
14843
  {
14842
14844
  modelList: agent.modelList,
14843
- modelProviders,
14844
14845
  updateModelInModelList,
14845
14846
  reorderModelList
14846
14847
  }
@@ -14859,7 +14860,7 @@ const AgentMetadata = ({
14859
14860
  defaultProvider: agent.provider,
14860
14861
  defaultModel: agent.modelId,
14861
14862
  updateModel,
14862
- modelProviders
14863
+ resetModel
14863
14864
  }
14864
14865
  )
14865
14866
  }
@@ -15189,13 +15190,6 @@ const useAgents = () => {
15189
15190
  queryFn: () => client.getAgents(runtimeContext)
15190
15191
  });
15191
15192
  };
15192
- const useModelProviders = () => {
15193
- const client = react$3.useMastraClient();
15194
- return reactQuery.useQuery({
15195
- queryKey: ["model-providers"],
15196
- queryFn: () => client.getModelProviders()
15197
- });
15198
- };
15199
15193
  const useUpdateAgentModel = (agentId) => {
15200
15194
  const client = react$3.useMastraClient();
15201
15195
  const queryClient = reactQuery.useQueryClient();
@@ -15235,6 +15229,19 @@ const useUpdateModelInModelList = (agentId) => {
15235
15229
  }
15236
15230
  });
15237
15231
  };
15232
+ const useResetAgentModel = (agentId) => {
15233
+ const client = react$3.useMastraClient();
15234
+ const queryClient = reactQuery.useQueryClient();
15235
+ return reactQuery.useMutation({
15236
+ mutationFn: async () => client.getAgent(agentId).resetModel(),
15237
+ onSuccess: () => {
15238
+ queryClient.invalidateQueries({ queryKey: ["agent", agentId] });
15239
+ },
15240
+ onError: (err) => {
15241
+ console.error("Error resetting model", err);
15242
+ }
15243
+ });
15244
+ };
15238
15245
 
15239
15246
  const useAgent = (agentId) => {
15240
15247
  const client = react$3.useMastraClient();
@@ -15350,9 +15357,10 @@ const AgentToolPanel = ({ toolId, agentId }) => {
15350
15357
 
15351
15358
  const useMemory = (agentId) => {
15352
15359
  const client = react$3.useMastraClient();
15360
+ const { runtimeContext } = usePlaygroundStore();
15353
15361
  return reactQuery.useQuery({
15354
15362
  queryKey: ["memory", agentId],
15355
- queryFn: () => agentId ? client.getMemoryStatus(agentId) : null,
15363
+ queryFn: () => agentId ? client.getMemoryStatus(agentId, runtimeContext) : null,
15356
15364
  enabled: Boolean(agentId),
15357
15365
  staleTime: 5 * 60 * 1e3,
15358
15366
  // 5 minutes
@@ -15363,9 +15371,10 @@ const useMemory = (agentId) => {
15363
15371
  };
15364
15372
  const useMemoryConfig = (agentId) => {
15365
15373
  const client = react$3.useMastraClient();
15374
+ const { runtimeContext } = usePlaygroundStore();
15366
15375
  return reactQuery.useQuery({
15367
15376
  queryKey: ["memory", "config", agentId],
15368
- queryFn: () => agentId ? client.getMemoryConfig({ agentId }) : null,
15377
+ queryFn: () => agentId ? client.getMemoryConfig({ agentId, runtimeContext }) : null,
15369
15378
  enabled: Boolean(agentId),
15370
15379
  staleTime: 5 * 60 * 1e3,
15371
15380
  // 5 minutes
@@ -15381,9 +15390,10 @@ const useThreads = ({
15381
15390
  isMemoryEnabled
15382
15391
  }) => {
15383
15392
  const client = react$3.useMastraClient();
15393
+ const { runtimeContext } = usePlaygroundStore();
15384
15394
  return reactQuery.useQuery({
15385
15395
  queryKey: ["memory", "threads", resourceId, agentId],
15386
- queryFn: () => isMemoryEnabled ? client.getMemoryThreads({ resourceId, agentId }) : null,
15396
+ queryFn: () => isMemoryEnabled ? client.getMemoryThreads({ resourceId, agentId, runtimeContext }) : null,
15387
15397
  enabled: Boolean(isMemoryEnabled),
15388
15398
  staleTime: 0,
15389
15399
  gcTime: 0,
@@ -15394,8 +15404,9 @@ const useThreads = ({
15394
15404
  const useDeleteThread = () => {
15395
15405
  const client = react$3.useMastraClient();
15396
15406
  const queryClient = reactQuery.useQueryClient();
15407
+ const { runtimeContext } = usePlaygroundStore();
15397
15408
  return reactQuery.useMutation({
15398
- mutationFn: ({ threadId, agentId, networkId }) => client.deleteThread(threadId, { agentId, networkId }),
15409
+ mutationFn: ({ threadId, agentId, networkId }) => client.deleteThread(threadId, { agentId, networkId, runtimeContext }),
15399
15410
  onSuccess: (_, variables) => {
15400
15411
  const { agentId, networkId } = variables;
15401
15412
  if (agentId) {
@@ -15416,6 +15427,7 @@ const useMemorySearch = ({
15416
15427
  resourceId,
15417
15428
  threadId
15418
15429
  }) => {
15430
+ const { runtimeContext } = usePlaygroundStore();
15419
15431
  const searchMemory = async (searchQuery, memoryConfig) => {
15420
15432
  if (!searchQuery.trim()) {
15421
15433
  return { results: [], count: 0, query: searchQuery };
@@ -15423,7 +15435,8 @@ const useMemorySearch = ({
15423
15435
  const params = new URLSearchParams({
15424
15436
  searchQuery,
15425
15437
  resourceId,
15426
- agentId
15438
+ agentId,
15439
+ runtimeContext: btoa(JSON.stringify(runtimeContext))
15427
15440
  });
15428
15441
  if (threadId) {
15429
15442
  params.append("threadId", threadId);
@@ -16783,8 +16796,8 @@ function AgentPromptEnhancer({ agentId }) {
16783
16796
 
16784
16797
  function AgentInformation({ agentId, threadId }) {
16785
16798
  const { data: agent, isLoading } = useAgent(agentId);
16786
- const { data: modelProviders } = useModelProviders();
16787
16799
  const { mutateAsync: updateModel } = useUpdateAgentModel(agentId);
16800
+ const { mutateAsync: resetModel } = useResetAgentModel(agentId);
16788
16801
  const { mutate: reorderModelList } = useReorderModelList(agentId);
16789
16802
  const { mutateAsync: updateModelInModelList } = useUpdateModelInModelList(agentId);
16790
16803
  const { data: memory, isLoading: isMemoryLoading } = useMemory(agentId);
@@ -16829,9 +16842,9 @@ function AgentInformation({ agentId, threadId }) {
16829
16842
  agentId,
16830
16843
  agent,
16831
16844
  updateModel,
16845
+ resetModel,
16832
16846
  updateModelInModelList,
16833
16847
  reorderModelList,
16834
- modelProviders: modelProviders || [],
16835
16848
  hasMemoryEnabled: Boolean(memory?.result),
16836
16849
  promptSlot: /* @__PURE__ */ jsxRuntime.jsx(AgentPromptEnhancer, { agentId }),
16837
16850
  modelVersion: agent.modelVersion
@@ -17411,7 +17424,6 @@ function TemplateForm({
17411
17424
  updateModel: onModelUpdate || (() => Promise.resolve({ message: "Updated" })),
17412
17425
  closeEditor: () => {
17413
17426
  },
17414
- modelProviders: ["openai", "anthropic", "google", "xai", "groq"],
17415
17427
  autoSave: true,
17416
17428
  selectProviderPlaceholder: "Provider"
17417
17429
  }
@@ -20711,11 +20723,11 @@ exports.useMainSidebar = useMainSidebar;
20711
20723
  exports.useMemory = useMemory;
20712
20724
  exports.useMemoryConfig = useMemoryConfig;
20713
20725
  exports.useMemorySearch = useMemorySearch;
20714
- exports.useModelProviders = useModelProviders;
20715
20726
  exports.useModelReset = useModelReset;
20716
20727
  exports.usePlaygroundStore = usePlaygroundStore;
20717
20728
  exports.usePolling = usePolling;
20718
20729
  exports.useReorderModelList = useReorderModelList;
20730
+ exports.useResetAgentModel = useResetAgentModel;
20719
20731
  exports.useScorer = useScorer;
20720
20732
  exports.useScorers = useScorers;
20721
20733
  exports.useScoresByEntityId = useScoresByEntityId;