@mastra/client-js 0.0.0-ai-v5-20250625173645 → 0.0.0-ai-v5-20250710191716

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.cts 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,54 @@ 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
+ }
341
+ interface LoopStreamVNextNetworkParams {
342
+ message: string;
343
+ threadId?: string;
344
+ resourceId?: string;
345
+ maxIterations?: number;
346
+ }
347
+ interface LoopVNextNetworkResponse {
348
+ status: 'success';
349
+ result: {
350
+ text: string;
351
+ };
352
+ steps: WorkflowResult<any, any>['steps'];
353
+ }
278
354
  interface McpServerListResponse {
279
355
  servers: ServerInfo[];
280
356
  next: string | null;
@@ -367,13 +443,19 @@ declare class Agent extends BaseResource {
367
443
  output?: never;
368
444
  experimental_output: T;
369
445
  }): Promise<GenerateReturn<T>>;
446
+ private processChatResponse;
447
+ /**
448
+ * Processes the stream response and handles tool calls
449
+ */
450
+ private processStreamResponse;
370
451
  /**
371
452
  * Streams a response from the agent
372
453
  * @param params - Stream parameters including prompt
373
- * @returns Promise containing the enhanced Response object with processDataStream method
454
+ * @returns Promise containing the enhanced Response object with processDataStream and processTextStream methods
374
455
  */
375
456
  stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
376
457
  processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
458
+ processTextStream: (options?: Omit<Parameters<typeof processTextStream>[0], 'stream'>) => Promise<void>;
377
459
  }>;
378
460
  /**
379
461
  * Gets details about a specific tool available to the agent
@@ -642,6 +724,26 @@ declare class Workflow extends BaseResource {
642
724
  * @returns Promise containing the workflow run execution result
643
725
  */
644
726
  runExecutionResult(runId: string): Promise<GetWorkflowRunExecutionResultResponse>;
727
+ /**
728
+ * Cancels a specific workflow run by its ID
729
+ * @param runId - The ID of the workflow run to cancel
730
+ * @returns Promise containing a success message
731
+ */
732
+ cancelRun(runId: string): Promise<{
733
+ message: string;
734
+ }>;
735
+ /**
736
+ * Sends an event to a specific workflow run by its ID
737
+ * @param params - Object containing the runId, event and data
738
+ * @returns Promise containing a success message
739
+ */
740
+ sendRunEvent(params: {
741
+ runId: string;
742
+ event: string;
743
+ data: unknown;
744
+ }): Promise<{
745
+ message: string;
746
+ }>;
645
747
  /**
646
748
  * Creates a new workflow run
647
749
  * @param params - Optional object containing the optional runId
@@ -688,15 +790,18 @@ declare class Workflow extends BaseResource {
688
790
  runtimeContext?: RuntimeContext | Record<string, any>;
689
791
  }): Promise<WorkflowRunResult>;
690
792
  /**
691
- * Starts a vNext workflow run and returns a stream
793
+ * Starts a workflow run and returns a stream
692
794
  * @param params - Object containing the optional runId, inputData and runtimeContext
693
- * @returns Promise containing the vNext workflow execution results
795
+ * @returns Promise containing the workflow execution results
694
796
  */
695
797
  stream(params: {
696
798
  runId?: string;
697
799
  inputData: Record<string, any>;
698
800
  runtimeContext?: RuntimeContext;
699
- }): Promise<stream_web.ReadableStream<WorkflowWatchResult>>;
801
+ }): Promise<stream_web.ReadableStream<{
802
+ type: string;
803
+ payload: any;
804
+ }>>;
700
805
  /**
701
806
  * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
702
807
  * @param params - Object containing the runId, step, resumeData and runtimeContext
@@ -791,6 +896,73 @@ declare class MCPTool extends BaseResource {
791
896
  }): Promise<any>;
792
897
  }
793
898
 
899
+ declare class VNextNetwork extends BaseResource {
900
+ private networkId;
901
+ constructor(options: ClientOptions, networkId: string);
902
+ /**
903
+ * Retrieves details about the network
904
+ * @returns Promise containing vNext network details
905
+ */
906
+ details(): Promise<GetVNextNetworkResponse>;
907
+ /**
908
+ * Generates a response from the v-next network
909
+ * @param params - Generation parameters including message
910
+ * @returns Promise containing the generated response
911
+ */
912
+ generate(params: GenerateOrStreamVNextNetworkParams): Promise<GenerateVNextNetworkResponse>;
913
+ /**
914
+ * Generates a response from the v-next network using multiple primitives
915
+ * @param params - Generation parameters including message
916
+ * @returns Promise containing the generated response
917
+ */
918
+ loop(params: {
919
+ message: string;
920
+ }): Promise<LoopVNextNetworkResponse>;
921
+ private streamProcessor;
922
+ /**
923
+ * Streams a response from the v-next network
924
+ * @param params - Stream parameters including message
925
+ * @returns Promise containing the results
926
+ */
927
+ stream(params: GenerateOrStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
928
+ /**
929
+ * Streams a response from the v-next network loop
930
+ * @param params - Stream parameters including message
931
+ * @returns Promise containing the results
932
+ */
933
+ loopStream(params: LoopStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
934
+ }
935
+
936
+ declare class NetworkMemoryThread extends BaseResource {
937
+ private threadId;
938
+ private networkId;
939
+ constructor(options: ClientOptions, threadId: string, networkId: string);
940
+ /**
941
+ * Retrieves the memory thread details
942
+ * @returns Promise containing thread details including title and metadata
943
+ */
944
+ get(): Promise<StorageThreadType>;
945
+ /**
946
+ * Updates the memory thread properties
947
+ * @param params - Update parameters including title and metadata
948
+ * @returns Promise containing updated thread details
949
+ */
950
+ update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
951
+ /**
952
+ * Deletes the memory thread
953
+ * @returns Promise containing deletion result
954
+ */
955
+ delete(): Promise<{
956
+ result: string;
957
+ }>;
958
+ /**
959
+ * Retrieves messages associated with the thread
960
+ * @param params - Optional parameters including limit for number of messages to retrieve
961
+ * @returns Promise containing thread messages and UI messages
962
+ */
963
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
964
+ }
965
+
794
966
  declare class MastraClient extends BaseResource {
795
967
  constructor(options: ClientOptions);
796
968
  /**
@@ -838,6 +1010,37 @@ declare class MastraClient extends BaseResource {
838
1010
  getMemoryStatus(agentId: string): Promise<{
839
1011
  result: boolean;
840
1012
  }>;
1013
+ /**
1014
+ * Retrieves memory threads for a resource
1015
+ * @param params - Parameters containing the resource ID
1016
+ * @returns Promise containing array of memory threads
1017
+ */
1018
+ getNetworkMemoryThreads(params: GetNetworkMemoryThreadParams): Promise<GetMemoryThreadResponse>;
1019
+ /**
1020
+ * Creates a new memory thread
1021
+ * @param params - Parameters for creating the memory thread
1022
+ * @returns Promise containing the created memory thread
1023
+ */
1024
+ createNetworkMemoryThread(params: CreateNetworkMemoryThreadParams): Promise<CreateMemoryThreadResponse>;
1025
+ /**
1026
+ * Gets a memory thread instance by ID
1027
+ * @param threadId - ID of the memory thread to retrieve
1028
+ * @returns MemoryThread instance
1029
+ */
1030
+ getNetworkMemoryThread(threadId: string, networkId: string): NetworkMemoryThread;
1031
+ /**
1032
+ * Saves messages to memory
1033
+ * @param params - Parameters containing messages to save
1034
+ * @returns Promise containing the saved messages
1035
+ */
1036
+ saveNetworkMessageToMemory(params: SaveNetworkMessageToMemoryParams): Promise<SaveMessageToMemoryResponse>;
1037
+ /**
1038
+ * Gets the status of the memory system
1039
+ * @returns Promise containing memory system status
1040
+ */
1041
+ getNetworkMemoryStatus(networkId: string): Promise<{
1042
+ result: boolean;
1043
+ }>;
841
1044
  /**
842
1045
  * Retrieves all available tools
843
1046
  * @returns Promise containing map of tool IDs to tool details
@@ -906,13 +1109,24 @@ declare class MastraClient extends BaseResource {
906
1109
  * Retrieves all available networks
907
1110
  * @returns Promise containing map of network IDs to network details
908
1111
  */
909
- getNetworks(): Promise<Record<string, GetNetworkResponse>>;
1112
+ getNetworks(): Promise<Array<GetNetworkResponse>>;
1113
+ /**
1114
+ * Retrieves all available vNext networks
1115
+ * @returns Promise containing map of vNext network IDs to vNext network details
1116
+ */
1117
+ getVNextNetworks(): Promise<Array<GetVNextNetworkResponse>>;
910
1118
  /**
911
1119
  * Gets a network instance by ID
912
1120
  * @param networkId - ID of the network to retrieve
913
1121
  * @returns Network instance
914
1122
  */
915
1123
  getNetwork(networkId: string): Network;
1124
+ /**
1125
+ * Gets a vNext network instance by ID
1126
+ * @param networkId - ID of the vNext network to retrieve
1127
+ * @returns vNext Network instance
1128
+ */
1129
+ getVNextNetwork(networkId: string): VNextNetwork;
916
1130
  /**
917
1131
  * Retrieves a list of available MCP servers.
918
1132
  * @param params - Optional parameters for pagination (limit, offset).
@@ -953,4 +1167,4 @@ declare class MastraClient extends BaseResource {
953
1167
  getA2A(agentId: string): A2A;
954
1168
  }
955
1169
 
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 };
1170
+ 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 };