@mastra/client-js 0.10.13 → 0.10.14-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,19 @@
1
-
2
- 
3
- > @mastra/client-js@0.10.12 build /Users/ward/projects/mastra/mastra-oss/client-sdks/client-js
4
- > tsup src/index.ts --format esm,cjs --dts --clean --treeshake=smallest --splitting
5
-
6
- CLI Building entry: src/index.ts
7
- CLI Using tsconfig: tsconfig.json
8
- CLI tsup v8.5.0
9
- CLI Target: es2022
10
- CLI Cleaning output folder
11
- ESM Build start
12
- CJS Build start
13
- ESM dist/index.js 69.70 KB
14
- ESM ⚡️ Build success in 143ms
15
- CJS dist/index.cjs 69.98 KB
16
- CJS ⚡️ Build success in 144ms
17
- DTS Build start
18
- DTS ⚡️ Build success in 1379ms
19
- DTS dist/index.d.ts 40.80 KB
20
- DTS dist/index.d.cts 40.80 KB
1
+
2
+ > @mastra/client-js@0.10.14-alpha.1 build /home/runner/work/mastra/mastra/client-sdks/client-js
3
+ > tsup src/index.ts --format esm,cjs --dts --clean --treeshake=smallest --splitting
4
+
5
+ CLI Building entry: src/index.ts
6
+ CLI Using tsconfig: tsconfig.json
7
+ CLI tsup v8.5.0
8
+ CLI Target: es2022
9
+ CLI Cleaning output folder
10
+ ESM Build start
11
+ CJS Build start
12
+ ESM dist/index.js 71.12 KB
13
+ ESM ⚡️ Build success in 2103ms
14
+ CJS dist/index.cjs 71.41 KB
15
+ CJS ⚡️ Build success in 2104ms
16
+ DTS Build start
17
+ DTS ⚡️ Build success in 16787ms
18
+ DTS dist/index.d.ts 41.95 KB
19
+ DTS dist/index.d.cts 41.95 KB
package/CHANGELOG.md CHANGED
@@ -1,16 +1,39 @@
1
1
  # @mastra/client-js
2
2
 
3
- ## 0.10.13
3
+ ## 0.10.14-alpha.1
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - @mastra/core@0.10.14
7
+ - Updated dependencies [0b56518]
8
+ - Updated dependencies [2ba5b76]
9
+ - Updated dependencies [c3a30de]
10
+ - Updated dependencies [cf3a184]
11
+ - Updated dependencies [d6bfd60]
12
+ - @mastra/core@0.10.15-alpha.1
13
+
14
+ ## 0.10.14-alpha.0
15
+
16
+ ### Patch Changes
17
+
18
+ - 31f9f6b: Replace crypto randomUUID in client SDK"
19
+ - 1aa60b1: Pipe runtimeContext to vNext network agent stream and generate steps, wire up runtimeContext for vNext Networks in cliet SDK & playground
20
+ - 626b0f4: [Cloud-126] Working Memory Playground - Added working memory to playground to allow users to view/edit working memory
21
+ - Updated dependencies [db5cc15]
22
+ - Updated dependencies [5237998]
23
+ - Updated dependencies [37c1acd]
24
+ - Updated dependencies [1aa60b1]
25
+ - Updated dependencies [89ec9d4]
26
+ - Updated dependencies [626b0f4]
27
+ - Updated dependencies [c22a91f]
28
+ - Updated dependencies [f7403ab]
29
+ - Updated dependencies [6c89d7f]
30
+ - @mastra/core@0.10.15-alpha.0
8
31
 
9
- ## 0.10.12
32
+ ## 0.10.13
10
33
 
11
34
  ### Patch Changes
12
35
 
13
- - @mastra/core@0.10.13
36
+ - @mastra/core@0.10.14
14
37
 
15
38
  ## 0.10.11
16
39
 
package/dist/index.cjs CHANGED
@@ -6,6 +6,7 @@ var uiUtils = require('@ai-sdk/ui-utils');
6
6
  var zod = require('zod');
7
7
  var originalZodToJsonSchema = require('zod-to-json-schema');
8
8
  var tools = require('@mastra/core/tools');
9
+ var uuid = require('@lukeed/uuid');
9
10
  var runtimeContext = require('@mastra/core/runtime-context');
10
11
 
11
12
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
@@ -438,7 +439,7 @@ var Agent = class extends BaseResource {
438
439
  return Math.max(max, toolInvocation.step ?? 0);
439
440
  }, 0) ?? 0) : 0;
440
441
  const message = replaceLastMessage ? structuredClone(lastMessage) : {
441
- id: crypto.randomUUID(),
442
+ id: uuid.v4(),
442
443
  createdAt: getCurrentDate(),
443
444
  role: "assistant",
444
445
  content: "",
@@ -483,7 +484,7 @@ var Agent = class extends BaseResource {
483
484
  // changes. This is why we need to add a revision id to ensure that the message
484
485
  // is updated with SWR (without it, the changes get stuck in SWR and are not
485
486
  // forwarded to rendering):
486
- revisionId: crypto.randomUUID()
487
+ revisionId: uuid.v4()
487
488
  };
488
489
  update({
489
490
  message: copiedMessage,
@@ -1673,6 +1674,54 @@ var MCPTool = class extends BaseResource {
1673
1674
  }
1674
1675
  };
1675
1676
 
1677
+ // src/resources/network-memory-thread.ts
1678
+ var NetworkMemoryThread = class extends BaseResource {
1679
+ constructor(options, threadId, networkId) {
1680
+ super(options);
1681
+ this.threadId = threadId;
1682
+ this.networkId = networkId;
1683
+ }
1684
+ /**
1685
+ * Retrieves the memory thread details
1686
+ * @returns Promise containing thread details including title and metadata
1687
+ */
1688
+ get() {
1689
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`);
1690
+ }
1691
+ /**
1692
+ * Updates the memory thread properties
1693
+ * @param params - Update parameters including title and metadata
1694
+ * @returns Promise containing updated thread details
1695
+ */
1696
+ update(params) {
1697
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
1698
+ method: "PATCH",
1699
+ body: params
1700
+ });
1701
+ }
1702
+ /**
1703
+ * Deletes the memory thread
1704
+ * @returns Promise containing deletion result
1705
+ */
1706
+ delete() {
1707
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
1708
+ method: "DELETE"
1709
+ });
1710
+ }
1711
+ /**
1712
+ * Retrieves messages associated with the thread
1713
+ * @param params - Optional parameters including limit for number of messages to retrieve
1714
+ * @returns Promise containing thread messages and UI messages
1715
+ */
1716
+ getMessages(params) {
1717
+ const query = new URLSearchParams({
1718
+ networkId: this.networkId,
1719
+ ...params?.limit ? { limit: params.limit.toString() } : {}
1720
+ });
1721
+ return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
1722
+ }
1723
+ };
1724
+
1676
1725
  // src/resources/vNextNetwork.ts
1677
1726
  var RECORD_SEPARATOR3 = "";
1678
1727
  var VNextNetwork = class extends BaseResource {
@@ -1695,7 +1744,10 @@ var VNextNetwork = class extends BaseResource {
1695
1744
  generate(params) {
1696
1745
  return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
1697
1746
  method: "POST",
1698
- body: params
1747
+ body: {
1748
+ ...params,
1749
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
1750
+ }
1699
1751
  });
1700
1752
  }
1701
1753
  /**
@@ -1706,7 +1758,10 @@ var VNextNetwork = class extends BaseResource {
1706
1758
  loop(params) {
1707
1759
  return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
1708
1760
  method: "POST",
1709
- body: params
1761
+ body: {
1762
+ ...params,
1763
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
1764
+ }
1710
1765
  });
1711
1766
  }
1712
1767
  async *streamProcessor(stream) {
@@ -1755,7 +1810,10 @@ var VNextNetwork = class extends BaseResource {
1755
1810
  async stream(params, onRecord) {
1756
1811
  const response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
1757
1812
  method: "POST",
1758
- body: params,
1813
+ body: {
1814
+ ...params,
1815
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
1816
+ },
1759
1817
  stream: true
1760
1818
  });
1761
1819
  if (!response.ok) {
@@ -1780,7 +1838,10 @@ var VNextNetwork = class extends BaseResource {
1780
1838
  async loopStream(params, onRecord) {
1781
1839
  const response = await this.request(`/api/networks/v-next/${this.networkId}/loop-stream`, {
1782
1840
  method: "POST",
1783
- body: params,
1841
+ body: {
1842
+ ...params,
1843
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
1844
+ },
1784
1845
  stream: true
1785
1846
  });
1786
1847
  if (!response.ok) {
@@ -1799,54 +1860,6 @@ var VNextNetwork = class extends BaseResource {
1799
1860
  }
1800
1861
  };
1801
1862
 
1802
- // src/resources/network-memory-thread.ts
1803
- var NetworkMemoryThread = class extends BaseResource {
1804
- constructor(options, threadId, networkId) {
1805
- super(options);
1806
- this.threadId = threadId;
1807
- this.networkId = networkId;
1808
- }
1809
- /**
1810
- * Retrieves the memory thread details
1811
- * @returns Promise containing thread details including title and metadata
1812
- */
1813
- get() {
1814
- return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`);
1815
- }
1816
- /**
1817
- * Updates the memory thread properties
1818
- * @param params - Update parameters including title and metadata
1819
- * @returns Promise containing updated thread details
1820
- */
1821
- update(params) {
1822
- return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
1823
- method: "PATCH",
1824
- body: params
1825
- });
1826
- }
1827
- /**
1828
- * Deletes the memory thread
1829
- * @returns Promise containing deletion result
1830
- */
1831
- delete() {
1832
- return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
1833
- method: "DELETE"
1834
- });
1835
- }
1836
- /**
1837
- * Retrieves messages associated with the thread
1838
- * @param params - Optional parameters including limit for number of messages to retrieve
1839
- * @returns Promise containing thread messages and UI messages
1840
- */
1841
- getMessages(params) {
1842
- const query = new URLSearchParams({
1843
- networkId: this.networkId,
1844
- ...params?.limit ? { limit: params.limit.toString() } : {}
1845
- });
1846
- return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
1847
- }
1848
- };
1849
-
1850
1863
  // src/client.ts
1851
1864
  var MastraClient = class extends BaseResource {
1852
1865
  constructor(options) {
@@ -2241,6 +2254,41 @@ var MastraClient = class extends BaseResource {
2241
2254
  getA2A(agentId) {
2242
2255
  return new A2A(this.options, agentId);
2243
2256
  }
2257
+ /**
2258
+ * Retrieves the working memory for a specific thread (optionally resource-scoped).
2259
+ * @param agentId - ID of the agent.
2260
+ * @param threadId - ID of the thread.
2261
+ * @param resourceId - Optional ID of the resource.
2262
+ * @returns Working memory for the specified thread or resource.
2263
+ */
2264
+ getWorkingMemory({
2265
+ agentId,
2266
+ threadId,
2267
+ resourceId
2268
+ }) {
2269
+ return this.request(`/api/memory/threads/${threadId}/working-memory?agentId=${agentId}&resourceId=${resourceId}`);
2270
+ }
2271
+ /**
2272
+ * Updates the working memory for a specific thread (optionally resource-scoped).
2273
+ * @param agentId - ID of the agent.
2274
+ * @param threadId - ID of the thread.
2275
+ * @param workingMemory - The new working memory content.
2276
+ * @param resourceId - Optional ID of the resource.
2277
+ */
2278
+ updateWorkingMemory({
2279
+ agentId,
2280
+ threadId,
2281
+ workingMemory,
2282
+ resourceId
2283
+ }) {
2284
+ return this.request(`/api/memory/threads/${threadId}/working-memory?agentId=${agentId}`, {
2285
+ method: "POST",
2286
+ body: {
2287
+ workingMemory,
2288
+ resourceId
2289
+ }
2290
+ });
2291
+ }
2244
2292
  };
2245
2293
 
2246
2294
  exports.MastraClient = MastraClient;
package/dist/index.d.cts CHANGED
@@ -333,12 +333,14 @@ interface GenerateOrStreamVNextNetworkParams {
333
333
  message: string;
334
334
  threadId?: string;
335
335
  resourceId?: string;
336
+ runtimeContext?: RuntimeContext | Record<string, any>;
336
337
  }
337
338
  interface LoopStreamVNextNetworkParams {
338
339
  message: string;
339
340
  threadId?: string;
340
341
  resourceId?: string;
341
342
  maxIterations?: number;
343
+ runtimeContext?: RuntimeContext | Record<string, any>;
342
344
  }
343
345
  interface LoopVNextNetworkResponse {
344
346
  status: 'success';
@@ -892,6 +894,36 @@ declare class MCPTool extends BaseResource {
892
894
  }): Promise<any>;
893
895
  }
894
896
 
897
+ declare class NetworkMemoryThread extends BaseResource {
898
+ private threadId;
899
+ private networkId;
900
+ constructor(options: ClientOptions, threadId: string, networkId: string);
901
+ /**
902
+ * Retrieves the memory thread details
903
+ * @returns Promise containing thread details including title and metadata
904
+ */
905
+ get(): Promise<StorageThreadType>;
906
+ /**
907
+ * Updates the memory thread properties
908
+ * @param params - Update parameters including title and metadata
909
+ * @returns Promise containing updated thread details
910
+ */
911
+ update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
912
+ /**
913
+ * Deletes the memory thread
914
+ * @returns Promise containing deletion result
915
+ */
916
+ delete(): Promise<{
917
+ result: string;
918
+ }>;
919
+ /**
920
+ * Retrieves messages associated with the thread
921
+ * @param params - Optional parameters including limit for number of messages to retrieve
922
+ * @returns Promise containing thread messages and UI messages
923
+ */
924
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
925
+ }
926
+
895
927
  declare class VNextNetwork extends BaseResource {
896
928
  private networkId;
897
929
  constructor(options: ClientOptions, networkId: string);
@@ -913,6 +945,7 @@ declare class VNextNetwork extends BaseResource {
913
945
  */
914
946
  loop(params: {
915
947
  message: string;
948
+ runtimeContext?: RuntimeContext | Record<string, any>;
916
949
  }): Promise<LoopVNextNetworkResponse>;
917
950
  private streamProcessor;
918
951
  /**
@@ -929,36 +962,6 @@ declare class VNextNetwork extends BaseResource {
929
962
  loopStream(params: LoopStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
930
963
  }
931
964
 
932
- declare class NetworkMemoryThread extends BaseResource {
933
- private threadId;
934
- private networkId;
935
- constructor(options: ClientOptions, threadId: string, networkId: string);
936
- /**
937
- * Retrieves the memory thread details
938
- * @returns Promise containing thread details including title and metadata
939
- */
940
- get(): Promise<StorageThreadType>;
941
- /**
942
- * Updates the memory thread properties
943
- * @param params - Update parameters including title and metadata
944
- * @returns Promise containing updated thread details
945
- */
946
- update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
947
- /**
948
- * Deletes the memory thread
949
- * @returns Promise containing deletion result
950
- */
951
- delete(): Promise<{
952
- result: string;
953
- }>;
954
- /**
955
- * Retrieves messages associated with the thread
956
- * @param params - Optional parameters including limit for number of messages to retrieve
957
- * @returns Promise containing thread messages and UI messages
958
- */
959
- getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
960
- }
961
-
962
965
  declare class MastraClient extends BaseResource {
963
966
  constructor(options: ClientOptions);
964
967
  /**
@@ -1161,6 +1164,31 @@ declare class MastraClient extends BaseResource {
1161
1164
  * @returns A2A client instance
1162
1165
  */
1163
1166
  getA2A(agentId: string): A2A;
1167
+ /**
1168
+ * Retrieves the working memory for a specific thread (optionally resource-scoped).
1169
+ * @param agentId - ID of the agent.
1170
+ * @param threadId - ID of the thread.
1171
+ * @param resourceId - Optional ID of the resource.
1172
+ * @returns Working memory for the specified thread or resource.
1173
+ */
1174
+ getWorkingMemory({ agentId, threadId, resourceId, }: {
1175
+ agentId: string;
1176
+ threadId: string;
1177
+ resourceId?: string;
1178
+ }): Promise<unknown>;
1179
+ /**
1180
+ * Updates the working memory for a specific thread (optionally resource-scoped).
1181
+ * @param agentId - ID of the agent.
1182
+ * @param threadId - ID of the thread.
1183
+ * @param workingMemory - The new working memory content.
1184
+ * @param resourceId - Optional ID of the resource.
1185
+ */
1186
+ updateWorkingMemory({ agentId, threadId, workingMemory, resourceId, }: {
1187
+ agentId: string;
1188
+ threadId: string;
1189
+ workingMemory: string;
1190
+ resourceId?: string;
1191
+ }): Promise<unknown>;
1164
1192
  }
1165
1193
 
1166
1194
  export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type CreateNetworkMemoryThreadParams, type GenerateOrStreamVNextNetworkParams, type GenerateParams, type GenerateVNextNetworkResponse, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkMemoryThreadParams, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextNetworkResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunByIdResponse, type GetWorkflowRunExecutionResultResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, type LoopStreamVNextNetworkParams, type LoopVNextNetworkResponse, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type SaveNetworkMessageToMemoryParams, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
package/dist/index.d.ts CHANGED
@@ -333,12 +333,14 @@ interface GenerateOrStreamVNextNetworkParams {
333
333
  message: string;
334
334
  threadId?: string;
335
335
  resourceId?: string;
336
+ runtimeContext?: RuntimeContext | Record<string, any>;
336
337
  }
337
338
  interface LoopStreamVNextNetworkParams {
338
339
  message: string;
339
340
  threadId?: string;
340
341
  resourceId?: string;
341
342
  maxIterations?: number;
343
+ runtimeContext?: RuntimeContext | Record<string, any>;
342
344
  }
343
345
  interface LoopVNextNetworkResponse {
344
346
  status: 'success';
@@ -892,6 +894,36 @@ declare class MCPTool extends BaseResource {
892
894
  }): Promise<any>;
893
895
  }
894
896
 
897
+ declare class NetworkMemoryThread extends BaseResource {
898
+ private threadId;
899
+ private networkId;
900
+ constructor(options: ClientOptions, threadId: string, networkId: string);
901
+ /**
902
+ * Retrieves the memory thread details
903
+ * @returns Promise containing thread details including title and metadata
904
+ */
905
+ get(): Promise<StorageThreadType>;
906
+ /**
907
+ * Updates the memory thread properties
908
+ * @param params - Update parameters including title and metadata
909
+ * @returns Promise containing updated thread details
910
+ */
911
+ update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
912
+ /**
913
+ * Deletes the memory thread
914
+ * @returns Promise containing deletion result
915
+ */
916
+ delete(): Promise<{
917
+ result: string;
918
+ }>;
919
+ /**
920
+ * Retrieves messages associated with the thread
921
+ * @param params - Optional parameters including limit for number of messages to retrieve
922
+ * @returns Promise containing thread messages and UI messages
923
+ */
924
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
925
+ }
926
+
895
927
  declare class VNextNetwork extends BaseResource {
896
928
  private networkId;
897
929
  constructor(options: ClientOptions, networkId: string);
@@ -913,6 +945,7 @@ declare class VNextNetwork extends BaseResource {
913
945
  */
914
946
  loop(params: {
915
947
  message: string;
948
+ runtimeContext?: RuntimeContext | Record<string, any>;
916
949
  }): Promise<LoopVNextNetworkResponse>;
917
950
  private streamProcessor;
918
951
  /**
@@ -929,36 +962,6 @@ declare class VNextNetwork extends BaseResource {
929
962
  loopStream(params: LoopStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
930
963
  }
931
964
 
932
- declare class NetworkMemoryThread extends BaseResource {
933
- private threadId;
934
- private networkId;
935
- constructor(options: ClientOptions, threadId: string, networkId: string);
936
- /**
937
- * Retrieves the memory thread details
938
- * @returns Promise containing thread details including title and metadata
939
- */
940
- get(): Promise<StorageThreadType>;
941
- /**
942
- * Updates the memory thread properties
943
- * @param params - Update parameters including title and metadata
944
- * @returns Promise containing updated thread details
945
- */
946
- update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
947
- /**
948
- * Deletes the memory thread
949
- * @returns Promise containing deletion result
950
- */
951
- delete(): Promise<{
952
- result: string;
953
- }>;
954
- /**
955
- * Retrieves messages associated with the thread
956
- * @param params - Optional parameters including limit for number of messages to retrieve
957
- * @returns Promise containing thread messages and UI messages
958
- */
959
- getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
960
- }
961
-
962
965
  declare class MastraClient extends BaseResource {
963
966
  constructor(options: ClientOptions);
964
967
  /**
@@ -1161,6 +1164,31 @@ declare class MastraClient extends BaseResource {
1161
1164
  * @returns A2A client instance
1162
1165
  */
1163
1166
  getA2A(agentId: string): A2A;
1167
+ /**
1168
+ * Retrieves the working memory for a specific thread (optionally resource-scoped).
1169
+ * @param agentId - ID of the agent.
1170
+ * @param threadId - ID of the thread.
1171
+ * @param resourceId - Optional ID of the resource.
1172
+ * @returns Working memory for the specified thread or resource.
1173
+ */
1174
+ getWorkingMemory({ agentId, threadId, resourceId, }: {
1175
+ agentId: string;
1176
+ threadId: string;
1177
+ resourceId?: string;
1178
+ }): Promise<unknown>;
1179
+ /**
1180
+ * Updates the working memory for a specific thread (optionally resource-scoped).
1181
+ * @param agentId - ID of the agent.
1182
+ * @param threadId - ID of the thread.
1183
+ * @param workingMemory - The new working memory content.
1184
+ * @param resourceId - Optional ID of the resource.
1185
+ */
1186
+ updateWorkingMemory({ agentId, threadId, workingMemory, resourceId, }: {
1187
+ agentId: string;
1188
+ threadId: string;
1189
+ workingMemory: string;
1190
+ resourceId?: string;
1191
+ }): Promise<unknown>;
1164
1192
  }
1165
1193
 
1166
1194
  export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type CreateNetworkMemoryThreadParams, type GenerateOrStreamVNextNetworkParams, type GenerateParams, type GenerateVNextNetworkResponse, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkMemoryThreadParams, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextNetworkResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunByIdResponse, type GetWorkflowRunExecutionResultResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, type LoopStreamVNextNetworkParams, type LoopVNextNetworkResponse, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type SaveNetworkMessageToMemoryParams, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ import { processTextStream, processDataStream, parsePartialJson } from '@ai-sdk/
4
4
  import { ZodSchema } from 'zod';
5
5
  import originalZodToJsonSchema from 'zod-to-json-schema';
6
6
  import { isVercelTool } from '@mastra/core/tools';
7
+ import { v4 } from '@lukeed/uuid';
7
8
  import { RuntimeContext } from '@mastra/core/runtime-context';
8
9
 
9
10
  // src/adapters/agui.ts
@@ -432,7 +433,7 @@ var Agent = class extends BaseResource {
432
433
  return Math.max(max, toolInvocation.step ?? 0);
433
434
  }, 0) ?? 0) : 0;
434
435
  const message = replaceLastMessage ? structuredClone(lastMessage) : {
435
- id: crypto.randomUUID(),
436
+ id: v4(),
436
437
  createdAt: getCurrentDate(),
437
438
  role: "assistant",
438
439
  content: "",
@@ -477,7 +478,7 @@ var Agent = class extends BaseResource {
477
478
  // changes. This is why we need to add a revision id to ensure that the message
478
479
  // is updated with SWR (without it, the changes get stuck in SWR and are not
479
480
  // forwarded to rendering):
480
- revisionId: crypto.randomUUID()
481
+ revisionId: v4()
481
482
  };
482
483
  update({
483
484
  message: copiedMessage,
@@ -1667,6 +1668,54 @@ var MCPTool = class extends BaseResource {
1667
1668
  }
1668
1669
  };
1669
1670
 
1671
+ // src/resources/network-memory-thread.ts
1672
+ var NetworkMemoryThread = class extends BaseResource {
1673
+ constructor(options, threadId, networkId) {
1674
+ super(options);
1675
+ this.threadId = threadId;
1676
+ this.networkId = networkId;
1677
+ }
1678
+ /**
1679
+ * Retrieves the memory thread details
1680
+ * @returns Promise containing thread details including title and metadata
1681
+ */
1682
+ get() {
1683
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`);
1684
+ }
1685
+ /**
1686
+ * Updates the memory thread properties
1687
+ * @param params - Update parameters including title and metadata
1688
+ * @returns Promise containing updated thread details
1689
+ */
1690
+ update(params) {
1691
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
1692
+ method: "PATCH",
1693
+ body: params
1694
+ });
1695
+ }
1696
+ /**
1697
+ * Deletes the memory thread
1698
+ * @returns Promise containing deletion result
1699
+ */
1700
+ delete() {
1701
+ return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
1702
+ method: "DELETE"
1703
+ });
1704
+ }
1705
+ /**
1706
+ * Retrieves messages associated with the thread
1707
+ * @param params - Optional parameters including limit for number of messages to retrieve
1708
+ * @returns Promise containing thread messages and UI messages
1709
+ */
1710
+ getMessages(params) {
1711
+ const query = new URLSearchParams({
1712
+ networkId: this.networkId,
1713
+ ...params?.limit ? { limit: params.limit.toString() } : {}
1714
+ });
1715
+ return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
1716
+ }
1717
+ };
1718
+
1670
1719
  // src/resources/vNextNetwork.ts
1671
1720
  var RECORD_SEPARATOR3 = "";
1672
1721
  var VNextNetwork = class extends BaseResource {
@@ -1689,7 +1738,10 @@ var VNextNetwork = class extends BaseResource {
1689
1738
  generate(params) {
1690
1739
  return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
1691
1740
  method: "POST",
1692
- body: params
1741
+ body: {
1742
+ ...params,
1743
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
1744
+ }
1693
1745
  });
1694
1746
  }
1695
1747
  /**
@@ -1700,7 +1752,10 @@ var VNextNetwork = class extends BaseResource {
1700
1752
  loop(params) {
1701
1753
  return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
1702
1754
  method: "POST",
1703
- body: params
1755
+ body: {
1756
+ ...params,
1757
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
1758
+ }
1704
1759
  });
1705
1760
  }
1706
1761
  async *streamProcessor(stream) {
@@ -1749,7 +1804,10 @@ var VNextNetwork = class extends BaseResource {
1749
1804
  async stream(params, onRecord) {
1750
1805
  const response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
1751
1806
  method: "POST",
1752
- body: params,
1807
+ body: {
1808
+ ...params,
1809
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
1810
+ },
1753
1811
  stream: true
1754
1812
  });
1755
1813
  if (!response.ok) {
@@ -1774,7 +1832,10 @@ var VNextNetwork = class extends BaseResource {
1774
1832
  async loopStream(params, onRecord) {
1775
1833
  const response = await this.request(`/api/networks/v-next/${this.networkId}/loop-stream`, {
1776
1834
  method: "POST",
1777
- body: params,
1835
+ body: {
1836
+ ...params,
1837
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext)
1838
+ },
1778
1839
  stream: true
1779
1840
  });
1780
1841
  if (!response.ok) {
@@ -1793,54 +1854,6 @@ var VNextNetwork = class extends BaseResource {
1793
1854
  }
1794
1855
  };
1795
1856
 
1796
- // src/resources/network-memory-thread.ts
1797
- var NetworkMemoryThread = class extends BaseResource {
1798
- constructor(options, threadId, networkId) {
1799
- super(options);
1800
- this.threadId = threadId;
1801
- this.networkId = networkId;
1802
- }
1803
- /**
1804
- * Retrieves the memory thread details
1805
- * @returns Promise containing thread details including title and metadata
1806
- */
1807
- get() {
1808
- return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`);
1809
- }
1810
- /**
1811
- * Updates the memory thread properties
1812
- * @param params - Update parameters including title and metadata
1813
- * @returns Promise containing updated thread details
1814
- */
1815
- update(params) {
1816
- return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
1817
- method: "PATCH",
1818
- body: params
1819
- });
1820
- }
1821
- /**
1822
- * Deletes the memory thread
1823
- * @returns Promise containing deletion result
1824
- */
1825
- delete() {
1826
- return this.request(`/api/memory/network/threads/${this.threadId}?networkId=${this.networkId}`, {
1827
- method: "DELETE"
1828
- });
1829
- }
1830
- /**
1831
- * Retrieves messages associated with the thread
1832
- * @param params - Optional parameters including limit for number of messages to retrieve
1833
- * @returns Promise containing thread messages and UI messages
1834
- */
1835
- getMessages(params) {
1836
- const query = new URLSearchParams({
1837
- networkId: this.networkId,
1838
- ...params?.limit ? { limit: params.limit.toString() } : {}
1839
- });
1840
- return this.request(`/api/memory/network/threads/${this.threadId}/messages?${query.toString()}`);
1841
- }
1842
- };
1843
-
1844
1857
  // src/client.ts
1845
1858
  var MastraClient = class extends BaseResource {
1846
1859
  constructor(options) {
@@ -2235,6 +2248,41 @@ var MastraClient = class extends BaseResource {
2235
2248
  getA2A(agentId) {
2236
2249
  return new A2A(this.options, agentId);
2237
2250
  }
2251
+ /**
2252
+ * Retrieves the working memory for a specific thread (optionally resource-scoped).
2253
+ * @param agentId - ID of the agent.
2254
+ * @param threadId - ID of the thread.
2255
+ * @param resourceId - Optional ID of the resource.
2256
+ * @returns Working memory for the specified thread or resource.
2257
+ */
2258
+ getWorkingMemory({
2259
+ agentId,
2260
+ threadId,
2261
+ resourceId
2262
+ }) {
2263
+ return this.request(`/api/memory/threads/${threadId}/working-memory?agentId=${agentId}&resourceId=${resourceId}`);
2264
+ }
2265
+ /**
2266
+ * Updates the working memory for a specific thread (optionally resource-scoped).
2267
+ * @param agentId - ID of the agent.
2268
+ * @param threadId - ID of the thread.
2269
+ * @param workingMemory - The new working memory content.
2270
+ * @param resourceId - Optional ID of the resource.
2271
+ */
2272
+ updateWorkingMemory({
2273
+ agentId,
2274
+ threadId,
2275
+ workingMemory,
2276
+ resourceId
2277
+ }) {
2278
+ return this.request(`/api/memory/threads/${threadId}/working-memory?agentId=${agentId}`, {
2279
+ method: "POST",
2280
+ body: {
2281
+ workingMemory,
2282
+ resourceId
2283
+ }
2284
+ });
2285
+ }
2238
2286
  };
2239
2287
 
2240
2288
  export { MastraClient };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastra/client-js",
3
- "version": "0.10.13",
3
+ "version": "0.10.14-alpha.1",
4
4
  "description": "The official TypeScript library for the Mastra Client API",
5
5
  "author": "",
6
6
  "type": "module",
@@ -29,11 +29,12 @@
29
29
  "dependencies": {
30
30
  "@ag-ui/client": "^0.0.27",
31
31
  "@ai-sdk/ui-utils": "^1.2.11",
32
+ "@lukeed/uuid": "^2.0.1",
32
33
  "json-schema": "^0.4.0",
33
34
  "rxjs": "7.8.1",
34
35
  "zod": "^3.25.67",
35
36
  "zod-to-json-schema": "^3.24.5",
36
- "@mastra/core": "0.10.14"
37
+ "@mastra/core": "0.10.15-alpha.1"
37
38
  },
38
39
  "peerDependencies": {
39
40
  "zod": "^3.0.0"
package/src/client.ts CHANGED
@@ -13,6 +13,8 @@ import {
13
13
  MCPTool,
14
14
  LegacyWorkflow,
15
15
  } from './resources';
16
+ import { NetworkMemoryThread } from './resources/network-memory-thread';
17
+ import { VNextNetwork } from './resources/vNextNetwork';
16
18
  import type {
17
19
  ClientOptions,
18
20
  CreateMemoryThreadParams,
@@ -38,8 +40,6 @@ import type {
38
40
  CreateNetworkMemoryThreadParams,
39
41
  SaveNetworkMessageToMemoryParams,
40
42
  } from './types';
41
- import { VNextNetwork } from './resources/vNextNetwork';
42
- import { NetworkMemoryThread } from './resources/network-memory-thread';
43
43
 
44
44
  export class MastraClient extends BaseResource {
45
45
  constructor(options: ClientOptions) {
@@ -477,4 +477,50 @@ export class MastraClient extends BaseResource {
477
477
  public getA2A(agentId: string) {
478
478
  return new A2A(this.options, agentId);
479
479
  }
480
+
481
+ /**
482
+ * Retrieves the working memory for a specific thread (optionally resource-scoped).
483
+ * @param agentId - ID of the agent.
484
+ * @param threadId - ID of the thread.
485
+ * @param resourceId - Optional ID of the resource.
486
+ * @returns Working memory for the specified thread or resource.
487
+ */
488
+ public getWorkingMemory({
489
+ agentId,
490
+ threadId,
491
+ resourceId,
492
+ }: {
493
+ agentId: string;
494
+ threadId: string;
495
+ resourceId?: string;
496
+ }) {
497
+ return this.request(`/api/memory/threads/${threadId}/working-memory?agentId=${agentId}&resourceId=${resourceId}`);
498
+ }
499
+
500
+ /**
501
+ * Updates the working memory for a specific thread (optionally resource-scoped).
502
+ * @param agentId - ID of the agent.
503
+ * @param threadId - ID of the thread.
504
+ * @param workingMemory - The new working memory content.
505
+ * @param resourceId - Optional ID of the resource.
506
+ */
507
+ public updateWorkingMemory({
508
+ agentId,
509
+ threadId,
510
+ workingMemory,
511
+ resourceId,
512
+ }: {
513
+ agentId: string;
514
+ threadId: string;
515
+ workingMemory: string;
516
+ resourceId?: string;
517
+ }) {
518
+ return this.request(`/api/memory/threads/${threadId}/working-memory?agentId=${agentId}`, {
519
+ method: 'POST',
520
+ body: {
521
+ workingMemory,
522
+ resourceId,
523
+ },
524
+ });
525
+ }
480
526
  }
@@ -15,6 +15,7 @@ import type { JSONSchema7 } from 'json-schema';
15
15
  import { ZodSchema } from 'zod';
16
16
  import { zodToJsonSchema } from '../utils/zod-to-json-schema';
17
17
  import { processClientTools } from '../utils/process-client-tools';
18
+ import { v4 as uuid } from '@lukeed/uuid';
18
19
 
19
20
  import type {
20
21
  GenerateParams,
@@ -228,7 +229,7 @@ export class Agent extends BaseResource {
228
229
  const message: UIMessage = replaceLastMessage
229
230
  ? structuredClone(lastMessage)
230
231
  : {
231
- id: crypto.randomUUID(),
232
+ id: uuid(),
232
233
  createdAt: getCurrentDate(),
233
234
  role: 'assistant',
234
235
  content: '',
@@ -288,7 +289,7 @@ export class Agent extends BaseResource {
288
289
  // changes. This is why we need to add a revision id to ensure that the message
289
290
  // is updated with SWR (without it, the changes get stuck in SWR and are not
290
291
  // forwarded to rendering):
291
- revisionId: crypto.randomUUID(),
292
+ revisionId: uuid(),
292
293
  } as UIMessage;
293
294
 
294
295
  update({
@@ -10,6 +10,8 @@ import type {
10
10
  } from '../types';
11
11
 
12
12
  import { BaseResource } from './base';
13
+ import { parseClientRuntimeContext } from '../utils';
14
+ import type { RuntimeContext } from '@mastra/core/runtime-context';
13
15
 
14
16
  const RECORD_SEPARATOR = '\x1E';
15
17
 
@@ -37,7 +39,10 @@ export class VNextNetwork extends BaseResource {
37
39
  generate(params: GenerateOrStreamVNextNetworkParams): Promise<GenerateVNextNetworkResponse> {
38
40
  return this.request(`/api/networks/v-next/${this.networkId}/generate`, {
39
41
  method: 'POST',
40
- body: params,
42
+ body: {
43
+ ...params,
44
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext),
45
+ },
41
46
  });
42
47
  }
43
48
 
@@ -46,10 +51,16 @@ export class VNextNetwork extends BaseResource {
46
51
  * @param params - Generation parameters including message
47
52
  * @returns Promise containing the generated response
48
53
  */
49
- loop(params: { message: string }): Promise<LoopVNextNetworkResponse> {
54
+ loop(params: {
55
+ message: string;
56
+ runtimeContext?: RuntimeContext | Record<string, any>;
57
+ }): Promise<LoopVNextNetworkResponse> {
50
58
  return this.request(`/api/networks/v-next/${this.networkId}/loop`, {
51
59
  method: 'POST',
52
- body: params,
60
+ body: {
61
+ ...params,
62
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext),
63
+ },
53
64
  });
54
65
  }
55
66
 
@@ -125,7 +136,10 @@ export class VNextNetwork extends BaseResource {
125
136
  async stream(params: GenerateOrStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void) {
126
137
  const response: Response = await this.request(`/api/networks/v-next/${this.networkId}/stream`, {
127
138
  method: 'POST',
128
- body: params,
139
+ body: {
140
+ ...params,
141
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext),
142
+ },
129
143
  stream: true,
130
144
  });
131
145
 
@@ -154,7 +168,10 @@ export class VNextNetwork extends BaseResource {
154
168
  async loopStream(params: LoopStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void) {
155
169
  const response: Response = await this.request(`/api/networks/v-next/${this.networkId}/loop-stream`, {
156
170
  method: 'POST',
157
- body: params,
171
+ body: {
172
+ ...params,
173
+ runtimeContext: parseClientRuntimeContext(params.runtimeContext),
174
+ },
158
175
  stream: true,
159
176
  });
160
177
 
package/src/types.ts CHANGED
@@ -390,6 +390,7 @@ export interface GenerateOrStreamVNextNetworkParams {
390
390
  message: string;
391
391
  threadId?: string;
392
392
  resourceId?: string;
393
+ runtimeContext?: RuntimeContext | Record<string, any>;
393
394
  }
394
395
 
395
396
  export interface LoopStreamVNextNetworkParams {
@@ -397,6 +398,7 @@ export interface LoopStreamVNextNetworkParams {
397
398
  threadId?: string;
398
399
  resourceId?: string;
399
400
  maxIterations?: number;
401
+ runtimeContext?: RuntimeContext | Record<string, any>;
400
402
  }
401
403
 
402
404
  export interface LoopVNextNetworkResponse {