@mastra/client-js 0.0.0-ai-v5-20250626003446 → 0.0.0-ai-v5-20250718021026

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.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { AbstractAgent } from '@ag-ui/client';
2
2
  import { ServerInfo, MCPToolType, ServerDetailInfo } from '@mastra/core/mcp';
3
- import { UIMessage, processDataStream } from '@ai-sdk/ui-utils';
3
+ import { UIMessage, processDataStream, processTextStream } from '@ai-sdk/ui-utils';
4
4
  import { CoreMessage, StorageThreadType, MastraMessageV1, LegacyWorkflowRuns, WorkflowRuns, WorkflowRun, QueryResult, GenerateReturn } from '@mastra/core';
5
5
  import { JSONSchema7 } from 'json-schema';
6
6
  import { ZodSchema } from 'zod';
@@ -23,13 +23,14 @@ interface ClientOptions {
23
23
  maxBackoffMs?: number;
24
24
  /** Custom headers to include with requests */
25
25
  headers?: Record<string, string>;
26
+ /** Abort signal for request */
27
+ abortSignal?: AbortSignal;
26
28
  }
27
29
  interface RequestOptions {
28
30
  method?: string;
29
31
  headers?: Record<string, string>;
30
32
  body?: any;
31
33
  stream?: boolean;
32
- signal?: AbortSignal;
33
34
  }
34
35
  type WithoutMethods<T> = {
35
36
  [K in keyof T as T[K] extends (...args: any[]) => any ? never : T[K] extends {
@@ -52,14 +53,14 @@ type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> =
52
53
  experimental_output?: T;
53
54
  runtimeContext?: RuntimeContext | Record<string, any>;
54
55
  clientTools?: ToolsInput;
55
- } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
56
+ } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>>;
56
57
  type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
57
58
  messages: string | string[] | CoreMessage[] | UIMessage[];
58
59
  output?: T;
59
60
  experimental_output?: T;
60
61
  runtimeContext?: RuntimeContext | Record<string, any>;
61
62
  clientTools?: ToolsInput;
62
- } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
63
+ } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>>;
63
64
  interface GetEvalsByAgentIdResponse extends GetAgentResponse {
64
65
  evals: any[];
65
66
  instructions: string;
@@ -114,6 +115,17 @@ interface GetWorkflowResponse {
114
115
  suspendSchema: string;
115
116
  };
116
117
  };
118
+ allSteps: {
119
+ [key: string]: {
120
+ id: string;
121
+ description: string;
122
+ inputSchema: string;
123
+ outputSchema: string;
124
+ resumeSchema: string;
125
+ suspendSchema: string;
126
+ isWorkflow: boolean;
127
+ };
128
+ };
117
129
  stepGraph: Workflow$1['serializedStepGraph'];
118
130
  inputSchema: string;
119
131
  outputSchema: string;
@@ -152,6 +164,10 @@ interface SaveMessageToMemoryParams {
152
164
  messages: MastraMessageV1[];
153
165
  agentId: string;
154
166
  }
167
+ interface SaveNetworkMessageToMemoryParams {
168
+ messages: MastraMessageV1[];
169
+ networkId: string;
170
+ }
155
171
  type SaveMessageToMemoryResponse = MastraMessageV1[];
156
172
  interface CreateMemoryThreadParams {
157
173
  title?: string;
@@ -160,11 +176,22 @@ interface CreateMemoryThreadParams {
160
176
  threadId?: string;
161
177
  agentId: string;
162
178
  }
179
+ interface CreateNetworkMemoryThreadParams {
180
+ title?: string;
181
+ metadata?: Record<string, any>;
182
+ resourceId: string;
183
+ threadId?: string;
184
+ networkId: string;
185
+ }
163
186
  type CreateMemoryThreadResponse = StorageThreadType;
164
187
  interface GetMemoryThreadParams {
165
188
  resourceId: string;
166
189
  agentId: string;
167
190
  }
191
+ interface GetNetworkMemoryThreadParams {
192
+ resourceId: string;
193
+ networkId: string;
194
+ }
168
195
  type GetMemoryThreadResponse = StorageThreadType[];
169
196
  interface UpdateMemoryThreadParams {
170
197
  title: string;
@@ -262,6 +289,7 @@ interface GetTelemetryParams {
262
289
  toDate?: Date;
263
290
  }
264
291
  interface GetNetworkResponse {
292
+ id: string;
265
293
  name: string;
266
294
  instructions: string;
267
295
  agents: Array<{
@@ -275,6 +303,56 @@ interface GetNetworkResponse {
275
303
  };
276
304
  state?: Record<string, any>;
277
305
  }
306
+ interface GetVNextNetworkResponse {
307
+ id: string;
308
+ name: string;
309
+ instructions: string;
310
+ agents: Array<{
311
+ name: string;
312
+ provider: string;
313
+ modelId: string;
314
+ }>;
315
+ routingModel: {
316
+ provider: string;
317
+ modelId: string;
318
+ };
319
+ workflows: Array<{
320
+ name: string;
321
+ description: string;
322
+ inputSchema: string | undefined;
323
+ outputSchema: string | undefined;
324
+ }>;
325
+ tools: Array<{
326
+ id: string;
327
+ description: string;
328
+ }>;
329
+ }
330
+ interface GenerateVNextNetworkResponse {
331
+ task: string;
332
+ result: string;
333
+ resourceId: string;
334
+ resourceType: 'none' | 'tool' | 'agent' | 'workflow';
335
+ }
336
+ interface GenerateOrStreamVNextNetworkParams {
337
+ message: string;
338
+ threadId?: string;
339
+ resourceId?: string;
340
+ runtimeContext?: RuntimeContext | Record<string, any>;
341
+ }
342
+ interface LoopStreamVNextNetworkParams {
343
+ message: string;
344
+ threadId?: string;
345
+ resourceId?: string;
346
+ maxIterations?: number;
347
+ runtimeContext?: RuntimeContext | Record<string, any>;
348
+ }
349
+ interface LoopVNextNetworkResponse {
350
+ status: 'success';
351
+ result: {
352
+ text: string;
353
+ };
354
+ steps: WorkflowResult<any, any>['steps'];
355
+ }
278
356
  interface McpServerListResponse {
279
357
  servers: ServerInfo[];
280
358
  next: string | null;
@@ -367,13 +445,19 @@ declare class Agent extends BaseResource {
367
445
  output?: never;
368
446
  experimental_output: T;
369
447
  }): Promise<GenerateReturn<T>>;
448
+ private processChatResponse;
449
+ /**
450
+ * Processes the stream response and handles tool calls
451
+ */
452
+ private processStreamResponse;
370
453
  /**
371
454
  * Streams a response from the agent
372
455
  * @param params - Stream parameters including prompt
373
- * @returns Promise containing the enhanced Response object with processDataStream method
456
+ * @returns Promise containing the enhanced Response object with processDataStream and processTextStream methods
374
457
  */
375
458
  stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
376
459
  processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
460
+ processTextStream: (options?: Omit<Parameters<typeof processTextStream>[0], 'stream'>) => Promise<void>;
377
461
  }>;
378
462
  /**
379
463
  * Gets details about a specific tool available to the agent
@@ -642,6 +726,26 @@ declare class Workflow extends BaseResource {
642
726
  * @returns Promise containing the workflow run execution result
643
727
  */
644
728
  runExecutionResult(runId: string): Promise<GetWorkflowRunExecutionResultResponse>;
729
+ /**
730
+ * Cancels a specific workflow run by its ID
731
+ * @param runId - The ID of the workflow run to cancel
732
+ * @returns Promise containing a success message
733
+ */
734
+ cancelRun(runId: string): Promise<{
735
+ message: string;
736
+ }>;
737
+ /**
738
+ * Sends an event to a specific workflow run by its ID
739
+ * @param params - Object containing the runId, event and data
740
+ * @returns Promise containing a success message
741
+ */
742
+ sendRunEvent(params: {
743
+ runId: string;
744
+ event: string;
745
+ data: unknown;
746
+ }): Promise<{
747
+ message: string;
748
+ }>;
645
749
  /**
646
750
  * Creates a new workflow run
647
751
  * @param params - Optional object containing the optional runId
@@ -688,15 +792,18 @@ declare class Workflow extends BaseResource {
688
792
  runtimeContext?: RuntimeContext | Record<string, any>;
689
793
  }): Promise<WorkflowRunResult>;
690
794
  /**
691
- * Starts a vNext workflow run and returns a stream
795
+ * Starts a workflow run and returns a stream
692
796
  * @param params - Object containing the optional runId, inputData and runtimeContext
693
- * @returns Promise containing the vNext workflow execution results
797
+ * @returns Promise containing the workflow execution results
694
798
  */
695
799
  stream(params: {
696
800
  runId?: string;
697
801
  inputData: Record<string, any>;
698
802
  runtimeContext?: RuntimeContext;
699
- }): Promise<stream_web.ReadableStream<WorkflowWatchResult>>;
803
+ }): Promise<stream_web.ReadableStream<{
804
+ type: string;
805
+ payload: any;
806
+ }>>;
700
807
  /**
701
808
  * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
702
809
  * @param params - Object containing the runId, step, resumeData and runtimeContext
@@ -791,6 +898,74 @@ declare class MCPTool extends BaseResource {
791
898
  }): Promise<any>;
792
899
  }
793
900
 
901
+ declare class NetworkMemoryThread extends BaseResource {
902
+ private threadId;
903
+ private networkId;
904
+ constructor(options: ClientOptions, threadId: string, networkId: string);
905
+ /**
906
+ * Retrieves the memory thread details
907
+ * @returns Promise containing thread details including title and metadata
908
+ */
909
+ get(): Promise<StorageThreadType>;
910
+ /**
911
+ * Updates the memory thread properties
912
+ * @param params - Update parameters including title and metadata
913
+ * @returns Promise containing updated thread details
914
+ */
915
+ update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
916
+ /**
917
+ * Deletes the memory thread
918
+ * @returns Promise containing deletion result
919
+ */
920
+ delete(): Promise<{
921
+ result: string;
922
+ }>;
923
+ /**
924
+ * Retrieves messages associated with the thread
925
+ * @param params - Optional parameters including limit for number of messages to retrieve
926
+ * @returns Promise containing thread messages and UI messages
927
+ */
928
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
929
+ }
930
+
931
+ declare class VNextNetwork extends BaseResource {
932
+ private networkId;
933
+ constructor(options: ClientOptions, networkId: string);
934
+ /**
935
+ * Retrieves details about the network
936
+ * @returns Promise containing vNext network details
937
+ */
938
+ details(): Promise<GetVNextNetworkResponse>;
939
+ /**
940
+ * Generates a response from the v-next network
941
+ * @param params - Generation parameters including message
942
+ * @returns Promise containing the generated response
943
+ */
944
+ generate(params: GenerateOrStreamVNextNetworkParams): Promise<GenerateVNextNetworkResponse>;
945
+ /**
946
+ * Generates a response from the v-next network using multiple primitives
947
+ * @param params - Generation parameters including message
948
+ * @returns Promise containing the generated response
949
+ */
950
+ loop(params: {
951
+ message: string;
952
+ runtimeContext?: RuntimeContext | Record<string, any>;
953
+ }): Promise<LoopVNextNetworkResponse>;
954
+ private streamProcessor;
955
+ /**
956
+ * Streams a response from the v-next network
957
+ * @param params - Stream parameters including message
958
+ * @returns Promise containing the results
959
+ */
960
+ stream(params: GenerateOrStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
961
+ /**
962
+ * Streams a response from the v-next network loop
963
+ * @param params - Stream parameters including message
964
+ * @returns Promise containing the results
965
+ */
966
+ loopStream(params: LoopStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
967
+ }
968
+
794
969
  declare class MastraClient extends BaseResource {
795
970
  constructor(options: ClientOptions);
796
971
  /**
@@ -838,6 +1013,37 @@ declare class MastraClient extends BaseResource {
838
1013
  getMemoryStatus(agentId: string): Promise<{
839
1014
  result: boolean;
840
1015
  }>;
1016
+ /**
1017
+ * Retrieves memory threads for a resource
1018
+ * @param params - Parameters containing the resource ID
1019
+ * @returns Promise containing array of memory threads
1020
+ */
1021
+ getNetworkMemoryThreads(params: GetNetworkMemoryThreadParams): Promise<GetMemoryThreadResponse>;
1022
+ /**
1023
+ * Creates a new memory thread
1024
+ * @param params - Parameters for creating the memory thread
1025
+ * @returns Promise containing the created memory thread
1026
+ */
1027
+ createNetworkMemoryThread(params: CreateNetworkMemoryThreadParams): Promise<CreateMemoryThreadResponse>;
1028
+ /**
1029
+ * Gets a memory thread instance by ID
1030
+ * @param threadId - ID of the memory thread to retrieve
1031
+ * @returns MemoryThread instance
1032
+ */
1033
+ getNetworkMemoryThread(threadId: string, networkId: string): NetworkMemoryThread;
1034
+ /**
1035
+ * Saves messages to memory
1036
+ * @param params - Parameters containing messages to save
1037
+ * @returns Promise containing the saved messages
1038
+ */
1039
+ saveNetworkMessageToMemory(params: SaveNetworkMessageToMemoryParams): Promise<SaveMessageToMemoryResponse>;
1040
+ /**
1041
+ * Gets the status of the memory system
1042
+ * @returns Promise containing memory system status
1043
+ */
1044
+ getNetworkMemoryStatus(networkId: string): Promise<{
1045
+ result: boolean;
1046
+ }>;
841
1047
  /**
842
1048
  * Retrieves all available tools
843
1049
  * @returns Promise containing map of tool IDs to tool details
@@ -906,13 +1112,24 @@ declare class MastraClient extends BaseResource {
906
1112
  * Retrieves all available networks
907
1113
  * @returns Promise containing map of network IDs to network details
908
1114
  */
909
- getNetworks(): Promise<Record<string, GetNetworkResponse>>;
1115
+ getNetworks(): Promise<Array<GetNetworkResponse>>;
1116
+ /**
1117
+ * Retrieves all available vNext networks
1118
+ * @returns Promise containing map of vNext network IDs to vNext network details
1119
+ */
1120
+ getVNextNetworks(): Promise<Array<GetVNextNetworkResponse>>;
910
1121
  /**
911
1122
  * Gets a network instance by ID
912
1123
  * @param networkId - ID of the network to retrieve
913
1124
  * @returns Network instance
914
1125
  */
915
1126
  getNetwork(networkId: string): Network;
1127
+ /**
1128
+ * Gets a vNext network instance by ID
1129
+ * @param networkId - ID of the vNext network to retrieve
1130
+ * @returns vNext Network instance
1131
+ */
1132
+ getVNextNetwork(networkId: string): VNextNetwork;
916
1133
  /**
917
1134
  * Retrieves a list of available MCP servers.
918
1135
  * @param params - Optional parameters for pagination (limit, offset).
@@ -951,6 +1168,31 @@ declare class MastraClient extends BaseResource {
951
1168
  * @returns A2A client instance
952
1169
  */
953
1170
  getA2A(agentId: string): A2A;
1171
+ /**
1172
+ * Retrieves the working memory for a specific thread (optionally resource-scoped).
1173
+ * @param agentId - ID of the agent.
1174
+ * @param threadId - ID of the thread.
1175
+ * @param resourceId - Optional ID of the resource.
1176
+ * @returns Working memory for the specified thread or resource.
1177
+ */
1178
+ getWorkingMemory({ agentId, threadId, resourceId, }: {
1179
+ agentId: string;
1180
+ threadId: string;
1181
+ resourceId?: string;
1182
+ }): Promise<unknown>;
1183
+ /**
1184
+ * Updates the working memory for a specific thread (optionally resource-scoped).
1185
+ * @param agentId - ID of the agent.
1186
+ * @param threadId - ID of the thread.
1187
+ * @param workingMemory - The new working memory content.
1188
+ * @param resourceId - Optional ID of the resource.
1189
+ */
1190
+ updateWorkingMemory({ agentId, threadId, workingMemory, resourceId, }: {
1191
+ agentId: string;
1192
+ threadId: string;
1193
+ workingMemory: string;
1194
+ resourceId?: string;
1195
+ }): Promise<unknown>;
954
1196
  }
955
1197
 
956
- export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLegacyWorkflowResponse, type GetLegacyWorkflowRunsResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunByIdResponse, type GetWorkflowRunExecutionResultResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, type LegacyWorkflowRunResult, MastraClient, type McpServerListResponse, type McpServerToolListResponse, type McpToolInfo, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult, type WorkflowWatchResult };
1198
+ 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 };