@mastra/client-js 0.0.0-message-ordering-20250415215612 → 0.0.0-message-list-update-20250715150321

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,8 +1,16 @@
1
- import { CoreMessage, AiMessageType, StorageThreadType, MessageType, StepAction, StepGraph, WorkflowRunResult as WorkflowRunResult$1, QueryResult, BaseLogMessage, GenerateReturn } from '@mastra/core';
1
+ import { AbstractAgent } from '@ag-ui/client';
2
+ import { ServerInfo, MCPToolType, ServerDetailInfo } from '@mastra/core/mcp';
3
+ import { processDataStream, processTextStream } from '@ai-sdk/ui-utils';
4
+ import { CoreMessage, AiMessageType, StorageThreadType, MastraMessageV1, LegacyWorkflowRuns, WorkflowRuns, WorkflowRun, QueryResult, GenerateReturn } from '@mastra/core';
2
5
  import { JSONSchema7 } from 'json-schema';
3
6
  import { ZodSchema } from 'zod';
4
- import { processDataStream } from '@ai-sdk/ui-utils';
5
- import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
7
+ import { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
8
+ import { LogLevel, BaseLogMessage } from '@mastra/core/logger';
9
+ import { RuntimeContext } from '@mastra/core/runtime-context';
10
+ import { Workflow as Workflow$1, WatchEvent, WorkflowResult } from '@mastra/core/workflows';
11
+ import { StepAction, StepGraph, LegacyWorkflowRunResult as LegacyWorkflowRunResult$1 } from '@mastra/core/workflows/legacy';
12
+ import * as stream_web from 'stream/web';
13
+ import { AgentCard, TaskSendParams, Task, TaskQueryParams, TaskIdParams } from '@mastra/core/a2a';
6
14
 
7
15
  interface ClientOptions {
8
16
  /** Base URL for API requests */
@@ -15,29 +23,49 @@ interface ClientOptions {
15
23
  maxBackoffMs?: number;
16
24
  /** Custom headers to include with requests */
17
25
  headers?: Record<string, string>;
26
+ /** Abort signal for request */
27
+ abortSignal?: AbortSignal;
18
28
  }
19
29
  interface RequestOptions {
20
30
  method?: string;
21
31
  headers?: Record<string, string>;
22
32
  body?: any;
23
33
  stream?: boolean;
24
- signal?: AbortSignal;
25
34
  }
35
+ type WithoutMethods<T> = {
36
+ [K in keyof T as T[K] extends (...args: any[]) => any ? never : T[K] extends {
37
+ (): any;
38
+ } ? never : T[K] extends undefined | ((...args: any[]) => any) ? never : K]: T[K];
39
+ };
26
40
  interface GetAgentResponse {
27
41
  name: string;
28
42
  instructions: string;
29
43
  tools: Record<string, GetToolResponse>;
44
+ workflows: Record<string, GetWorkflowResponse>;
30
45
  provider: string;
31
46
  modelId: string;
47
+ defaultGenerateOptions: WithoutMethods<AgentGenerateOptions>;
48
+ defaultStreamOptions: WithoutMethods<AgentStreamOptions>;
32
49
  }
33
50
  type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
34
51
  messages: string | string[] | CoreMessage[] | AiMessageType[];
35
- } & Partial<AgentGenerateOptions<T>>;
52
+ output?: T;
53
+ experimental_output?: T;
54
+ runtimeContext?: RuntimeContext | Record<string, any>;
55
+ clientTools?: ToolsInput;
56
+ } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>>;
36
57
  type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
37
58
  messages: string | string[] | CoreMessage[] | AiMessageType[];
38
- } & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
59
+ output?: T;
60
+ experimental_output?: T;
61
+ runtimeContext?: RuntimeContext | Record<string, any>;
62
+ clientTools?: ToolsInput;
63
+ } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools' | 'abortSignal'>>;
39
64
  interface GetEvalsByAgentIdResponse extends GetAgentResponse {
40
65
  evals: any[];
66
+ instructions: string;
67
+ name: string;
68
+ id: string;
41
69
  }
42
70
  interface GetToolResponse {
43
71
  id: string;
@@ -45,7 +73,7 @@ interface GetToolResponse {
45
73
  inputSchema: string;
46
74
  outputSchema: string;
47
75
  }
48
- interface GetWorkflowResponse {
76
+ interface GetLegacyWorkflowResponse {
49
77
  name: string;
50
78
  triggerSchema: string;
51
79
  steps: Record<string, StepAction<any, any, any, any>>;
@@ -53,16 +81,59 @@ interface GetWorkflowResponse {
53
81
  stepSubscriberGraph: Record<string, StepGraph>;
54
82
  workflowId?: string;
55
83
  }
56
- type WorkflowRunResult = {
84
+ interface GetWorkflowRunsParams {
85
+ fromDate?: Date;
86
+ toDate?: Date;
87
+ limit?: number;
88
+ offset?: number;
89
+ resourceId?: string;
90
+ }
91
+ type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
92
+ type GetWorkflowRunsResponse = WorkflowRuns;
93
+ type GetWorkflowRunByIdResponse = WorkflowRun;
94
+ type GetWorkflowRunExecutionResultResponse = WatchEvent['payload']['workflowState'];
95
+ type LegacyWorkflowRunResult = {
57
96
  activePaths: Record<string, {
58
97
  status: string;
59
98
  suspendPayload?: any;
60
99
  stepPath: string[];
61
100
  }>;
62
- results: WorkflowRunResult$1<any, any, any>['results'];
101
+ results: LegacyWorkflowRunResult$1<any, any, any>['results'];
63
102
  timestamp: number;
64
103
  runId: string;
65
104
  };
105
+ interface GetWorkflowResponse {
106
+ name: string;
107
+ description?: string;
108
+ steps: {
109
+ [key: string]: {
110
+ id: string;
111
+ description: string;
112
+ inputSchema: string;
113
+ outputSchema: string;
114
+ resumeSchema: string;
115
+ suspendSchema: string;
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
+ };
129
+ stepGraph: Workflow$1['serializedStepGraph'];
130
+ inputSchema: string;
131
+ outputSchema: string;
132
+ }
133
+ type WorkflowWatchResult = WatchEvent & {
134
+ runId: string;
135
+ };
136
+ type WorkflowRunResult = WorkflowResult<any, any>;
66
137
  interface UpsertVectorParams {
67
138
  indexName: string;
68
139
  vectors: number[][];
@@ -90,27 +161,48 @@ interface GetVectorIndexResponse {
90
161
  count: number;
91
162
  }
92
163
  interface SaveMessageToMemoryParams {
93
- messages: MessageType[];
164
+ messages: MastraMessageV1[];
94
165
  agentId: string;
95
166
  }
96
- type SaveMessageToMemoryResponse = MessageType[];
167
+ interface SaveNetworkMessageToMemoryParams {
168
+ messages: MastraMessageV1[];
169
+ networkId: string;
170
+ }
171
+ type SaveMessageToMemoryResponse = MastraMessageV1[];
97
172
  interface CreateMemoryThreadParams {
98
- title: string;
99
- metadata: Record<string, any>;
100
- resourceid: string;
101
- threadId: string;
173
+ title?: string;
174
+ metadata?: Record<string, any>;
175
+ resourceId: string;
176
+ threadId?: string;
102
177
  agentId: string;
103
178
  }
179
+ interface CreateNetworkMemoryThreadParams {
180
+ title?: string;
181
+ metadata?: Record<string, any>;
182
+ resourceId: string;
183
+ threadId?: string;
184
+ networkId: string;
185
+ }
104
186
  type CreateMemoryThreadResponse = StorageThreadType;
105
187
  interface GetMemoryThreadParams {
106
188
  resourceId: string;
107
189
  agentId: string;
108
190
  }
191
+ interface GetNetworkMemoryThreadParams {
192
+ resourceId: string;
193
+ networkId: string;
194
+ }
109
195
  type GetMemoryThreadResponse = StorageThreadType[];
110
196
  interface UpdateMemoryThreadParams {
111
197
  title: string;
112
198
  metadata: Record<string, any>;
113
- resourceid: string;
199
+ resourceId: string;
200
+ }
201
+ interface GetMemoryThreadMessagesParams {
202
+ /**
203
+ * Limit the number of messages to retrieve (default: 40)
204
+ */
205
+ limit?: number;
114
206
  }
115
207
  interface GetMemoryThreadMessagesResponse {
116
208
  messages: CoreMessage[];
@@ -118,12 +210,30 @@ interface GetMemoryThreadMessagesResponse {
118
210
  }
119
211
  interface GetLogsParams {
120
212
  transportId: string;
213
+ fromDate?: Date;
214
+ toDate?: Date;
215
+ logLevel?: LogLevel;
216
+ filters?: Record<string, string>;
217
+ page?: number;
218
+ perPage?: number;
121
219
  }
122
220
  interface GetLogParams {
123
221
  runId: string;
124
222
  transportId: string;
223
+ fromDate?: Date;
224
+ toDate?: Date;
225
+ logLevel?: LogLevel;
226
+ filters?: Record<string, string>;
227
+ page?: number;
228
+ perPage?: number;
125
229
  }
126
- type GetLogsResponse = BaseLogMessage[];
230
+ type GetLogsResponse = {
231
+ logs: BaseLogMessage[];
232
+ total: number;
233
+ page: number;
234
+ perPage: number;
235
+ hasMore: boolean;
236
+ };
127
237
  type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
128
238
  type SpanStatus = {
129
239
  code: number;
@@ -171,8 +281,11 @@ interface GetTelemetryParams {
171
281
  page?: number;
172
282
  perPage?: number;
173
283
  attribute?: Record<string, string>;
284
+ fromDate?: Date;
285
+ toDate?: Date;
174
286
  }
175
287
  interface GetNetworkResponse {
288
+ id: string;
176
289
  name: string;
177
290
  instructions: string;
178
291
  agents: Array<{
@@ -186,6 +299,71 @@ interface GetNetworkResponse {
186
299
  };
187
300
  state?: Record<string, any>;
188
301
  }
302
+ interface GetVNextNetworkResponse {
303
+ id: string;
304
+ name: string;
305
+ instructions: string;
306
+ agents: Array<{
307
+ name: string;
308
+ provider: string;
309
+ modelId: string;
310
+ }>;
311
+ routingModel: {
312
+ provider: string;
313
+ modelId: string;
314
+ };
315
+ workflows: Array<{
316
+ name: string;
317
+ description: string;
318
+ inputSchema: string | undefined;
319
+ outputSchema: string | undefined;
320
+ }>;
321
+ tools: Array<{
322
+ id: string;
323
+ description: string;
324
+ }>;
325
+ }
326
+ interface GenerateVNextNetworkResponse {
327
+ task: string;
328
+ result: string;
329
+ resourceId: string;
330
+ resourceType: 'none' | 'tool' | 'agent' | 'workflow';
331
+ }
332
+ interface GenerateOrStreamVNextNetworkParams {
333
+ message: string;
334
+ threadId?: string;
335
+ resourceId?: string;
336
+ runtimeContext?: RuntimeContext | Record<string, any>;
337
+ }
338
+ interface LoopStreamVNextNetworkParams {
339
+ message: string;
340
+ threadId?: string;
341
+ resourceId?: string;
342
+ maxIterations?: number;
343
+ runtimeContext?: RuntimeContext | Record<string, any>;
344
+ }
345
+ interface LoopVNextNetworkResponse {
346
+ status: 'success';
347
+ result: {
348
+ text: string;
349
+ };
350
+ steps: WorkflowResult<any, any>['steps'];
351
+ }
352
+ interface McpServerListResponse {
353
+ servers: ServerInfo[];
354
+ next: string | null;
355
+ total_count: number;
356
+ }
357
+ interface McpToolInfo {
358
+ id: string;
359
+ name: string;
360
+ description?: string;
361
+ inputSchema: string;
362
+ toolType?: MCPToolType;
363
+ }
364
+ interface McpServerToolListResponse {
365
+ tools: McpToolInfo[];
366
+ }
189
367
 
190
368
  declare class BaseResource {
191
369
  readonly options: ClientOptions;
@@ -218,7 +396,9 @@ declare class AgentVoice extends BaseResource {
218
396
  * @param options - Optional provider-specific options
219
397
  * @returns Promise containing the transcribed text
220
398
  */
221
- listen(audio: Blob, options?: Record<string, any>): Promise<Response>;
399
+ listen(audio: Blob, options?: Record<string, any>): Promise<{
400
+ text: string;
401
+ }>;
222
402
  /**
223
403
  * Get available speakers for the agent's voice provider
224
404
  * @returns Promise containing list of available speakers
@@ -227,6 +407,13 @@ declare class AgentVoice extends BaseResource {
227
407
  voiceId: string;
228
408
  [key: string]: any;
229
409
  }>>;
410
+ /**
411
+ * Get the listener configuration for the agent's voice provider
412
+ * @returns Promise containing a check if the agent has listening capabilities
413
+ */
414
+ getListener(): Promise<{
415
+ enabled: boolean;
416
+ }>;
230
417
  }
231
418
  declare class Agent extends BaseResource {
232
419
  private agentId;
@@ -242,14 +429,31 @@ declare class Agent extends BaseResource {
242
429
  * @param params - Generation parameters including prompt
243
430
  * @returns Promise containing the generated response
244
431
  */
245
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>): Promise<GenerateReturn<T>>;
432
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
433
+ output?: never;
434
+ experimental_output?: never;
435
+ }): Promise<GenerateReturn<T>>;
436
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
437
+ output: T;
438
+ experimental_output?: never;
439
+ }): Promise<GenerateReturn<T>>;
440
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
441
+ output?: never;
442
+ experimental_output: T;
443
+ }): Promise<GenerateReturn<T>>;
444
+ private processChatResponse;
445
+ /**
446
+ * Processes the stream response and handles tool calls
447
+ */
448
+ private processStreamResponse;
246
449
  /**
247
450
  * Streams a response from the agent
248
451
  * @param params - Stream parameters including prompt
249
- * @returns Promise containing the enhanced Response object with processDataStream method
452
+ * @returns Promise containing the enhanced Response object with processDataStream and processTextStream methods
250
453
  */
251
454
  stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
252
455
  processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
456
+ processTextStream: (options?: Omit<Parameters<typeof processTextStream>[0], 'stream'>) => Promise<void>;
253
457
  }>;
254
458
  /**
255
459
  * Gets details about a specific tool available to the agent
@@ -257,6 +461,16 @@ declare class Agent extends BaseResource {
257
461
  * @returns Promise containing tool details
258
462
  */
259
463
  getTool(toolId: string): Promise<GetToolResponse>;
464
+ /**
465
+ * Executes a tool for the agent
466
+ * @param toolId - ID of the tool to execute
467
+ * @param params - Parameters required for tool execution
468
+ * @returns Promise containing the tool execution results
469
+ */
470
+ executeTool(toolId: string, params: {
471
+ data: any;
472
+ runtimeContext?: RuntimeContext;
473
+ }): Promise<any>;
260
474
  /**
261
475
  * Retrieves evaluation results for the agent
262
476
  * @returns Promise containing agent evaluations
@@ -317,9 +531,10 @@ declare class MemoryThread extends BaseResource {
317
531
  }>;
318
532
  /**
319
533
  * Retrieves messages associated with the thread
534
+ * @param params - Optional parameters including limit for number of messages to retrieve
320
535
  * @returns Promise containing thread messages and UI messages
321
536
  */
322
- getMessages(): Promise<GetMemoryThreadMessagesResponse>;
537
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
323
538
  }
324
539
 
325
540
  declare class Vector extends BaseResource {
@@ -368,23 +583,22 @@ declare class Vector extends BaseResource {
368
583
  query(params: QueryVectorParams): Promise<QueryVectorResponse>;
369
584
  }
370
585
 
371
- declare class Workflow extends BaseResource {
586
+ declare class LegacyWorkflow extends BaseResource {
372
587
  private workflowId;
373
588
  constructor(options: ClientOptions, workflowId: string);
374
589
  /**
375
- * Retrieves details about the workflow
376
- * @returns Promise containing workflow details including steps and graphs
590
+ * Retrieves details about the legacy workflow
591
+ * @returns Promise containing legacy workflow details including steps and graphs
377
592
  */
378
- details(): Promise<GetWorkflowResponse>;
593
+ details(): Promise<GetLegacyWorkflowResponse>;
379
594
  /**
380
- * @deprecated Use `startAsync` instead
381
- * Executes the workflow with the provided parameters
382
- * @param params - Parameters required for workflow execution
383
- * @returns Promise containing the workflow execution results
595
+ * Retrieves all runs for a legacy workflow
596
+ * @param params - Parameters for filtering runs
597
+ * @returns Promise containing legacy workflow runs array
384
598
  */
385
- execute(params: Record<string, any>): Promise<WorkflowRunResult>;
599
+ runs(params?: GetWorkflowRunsParams): Promise<GetLegacyWorkflowRunsResponse>;
386
600
  /**
387
- * Creates a new workflow run
601
+ * Creates a new legacy workflow run
388
602
  * @returns Promise containing the generated run ID
389
603
  */
390
604
  createRun(params?: {
@@ -393,7 +607,7 @@ declare class Workflow extends BaseResource {
393
607
  runId: string;
394
608
  }>;
395
609
  /**
396
- * Starts a workflow run synchronously without waiting for the workflow to complete
610
+ * Starts a legacy workflow run synchronously without waiting for the workflow to complete
397
611
  * @param params - Object containing the runId and triggerData
398
612
  * @returns Promise containing success message
399
613
  */
@@ -404,11 +618,11 @@ declare class Workflow extends BaseResource {
404
618
  message: string;
405
619
  }>;
406
620
  /**
407
- * Resumes a suspended workflow step synchronously without waiting for the workflow to complete
621
+ * Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
408
622
  * @param stepId - ID of the step to resume
409
- * @param runId - ID of the workflow run
410
- * @param context - Context to resume the workflow with
411
- * @returns Promise containing the workflow resume results
623
+ * @param runId - ID of the legacy workflow run
624
+ * @param context - Context to resume the legacy workflow with
625
+ * @returns Promise containing the legacy workflow resume results
412
626
  */
413
627
  resume({ stepId, runId, context, }: {
414
628
  stepId: string;
@@ -425,9 +639,9 @@ declare class Workflow extends BaseResource {
425
639
  startAsync(params: {
426
640
  runId?: string;
427
641
  triggerData: Record<string, any>;
428
- }): Promise<WorkflowRunResult>;
642
+ }): Promise<LegacyWorkflowRunResult>;
429
643
  /**
430
- * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
644
+ * Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
431
645
  * @param params - Object containing the runId, stepId, and context
432
646
  * @returns Promise containing the workflow resume results
433
647
  */
@@ -435,7 +649,7 @@ declare class Workflow extends BaseResource {
435
649
  runId: string;
436
650
  stepId: string;
437
651
  context: Record<string, any>;
438
- }): Promise<WorkflowRunResult>;
652
+ }): Promise<LegacyWorkflowRunResult>;
439
653
  /**
440
654
  * Creates an async generator that processes a readable stream and yields records
441
655
  * separated by the Record Separator character (\x1E)
@@ -445,13 +659,13 @@ declare class Workflow extends BaseResource {
445
659
  */
446
660
  private streamProcessor;
447
661
  /**
448
- * Watches workflow transitions in real-time
662
+ * Watches legacy workflow transitions in real-time
449
663
  * @param runId - Optional run ID to filter the watch stream
450
- * @returns AsyncGenerator that yields parsed records from the workflow watch stream
664
+ * @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
451
665
  */
452
666
  watch({ runId }: {
453
667
  runId?: string;
454
- }, onRecord: (record: WorkflowRunResult) => void): Promise<void>;
668
+ }, onRecord: (record: LegacyWorkflowRunResult) => void): Promise<void>;
455
669
  }
456
670
 
457
671
  declare class Tool extends BaseResource {
@@ -469,9 +683,285 @@ declare class Tool extends BaseResource {
469
683
  */
470
684
  execute(params: {
471
685
  data: any;
686
+ runId?: string;
687
+ runtimeContext?: RuntimeContext | Record<string, any>;
472
688
  }): Promise<any>;
473
689
  }
474
690
 
691
+ declare class Workflow extends BaseResource {
692
+ private workflowId;
693
+ constructor(options: ClientOptions, workflowId: string);
694
+ /**
695
+ * Creates an async generator that processes a readable stream and yields workflow records
696
+ * separated by the Record Separator character (\x1E)
697
+ *
698
+ * @param stream - The readable stream to process
699
+ * @returns An async generator that yields parsed records
700
+ */
701
+ private streamProcessor;
702
+ /**
703
+ * Retrieves details about the workflow
704
+ * @returns Promise containing workflow details including steps and graphs
705
+ */
706
+ details(): Promise<GetWorkflowResponse>;
707
+ /**
708
+ * Retrieves all runs for a workflow
709
+ * @param params - Parameters for filtering runs
710
+ * @returns Promise containing workflow runs array
711
+ */
712
+ runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
713
+ /**
714
+ * Retrieves a specific workflow run by its ID
715
+ * @param runId - The ID of the workflow run to retrieve
716
+ * @returns Promise containing the workflow run details
717
+ */
718
+ runById(runId: string): Promise<GetWorkflowRunByIdResponse>;
719
+ /**
720
+ * Retrieves the execution result for a specific workflow run by its ID
721
+ * @param runId - The ID of the workflow run to retrieve the execution result for
722
+ * @returns Promise containing the workflow run execution result
723
+ */
724
+ runExecutionResult(runId: string): Promise<GetWorkflowRunExecutionResultResponse>;
725
+ /**
726
+ * Cancels a specific workflow run by its ID
727
+ * @param runId - The ID of the workflow run to cancel
728
+ * @returns Promise containing a success message
729
+ */
730
+ cancelRun(runId: string): Promise<{
731
+ message: string;
732
+ }>;
733
+ /**
734
+ * Sends an event to a specific workflow run by its ID
735
+ * @param params - Object containing the runId, event and data
736
+ * @returns Promise containing a success message
737
+ */
738
+ sendRunEvent(params: {
739
+ runId: string;
740
+ event: string;
741
+ data: unknown;
742
+ }): Promise<{
743
+ message: string;
744
+ }>;
745
+ /**
746
+ * Creates a new workflow run
747
+ * @param params - Optional object containing the optional runId
748
+ * @returns Promise containing the runId of the created run
749
+ */
750
+ createRun(params?: {
751
+ runId?: string;
752
+ }): Promise<{
753
+ runId: string;
754
+ }>;
755
+ /**
756
+ * Starts a workflow run synchronously without waiting for the workflow to complete
757
+ * @param params - Object containing the runId, inputData and runtimeContext
758
+ * @returns Promise containing success message
759
+ */
760
+ start(params: {
761
+ runId: string;
762
+ inputData: Record<string, any>;
763
+ runtimeContext?: RuntimeContext | Record<string, any>;
764
+ }): Promise<{
765
+ message: string;
766
+ }>;
767
+ /**
768
+ * Resumes a suspended workflow step synchronously without waiting for the workflow to complete
769
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
770
+ * @returns Promise containing success message
771
+ */
772
+ resume({ step, runId, resumeData, ...rest }: {
773
+ step: string | string[];
774
+ runId: string;
775
+ resumeData?: Record<string, any>;
776
+ runtimeContext?: RuntimeContext | Record<string, any>;
777
+ }): Promise<{
778
+ message: string;
779
+ }>;
780
+ /**
781
+ * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
782
+ * @param params - Object containing the optional runId, inputData and runtimeContext
783
+ * @returns Promise containing the workflow execution results
784
+ */
785
+ startAsync(params: {
786
+ runId?: string;
787
+ inputData: Record<string, any>;
788
+ runtimeContext?: RuntimeContext | Record<string, any>;
789
+ }): Promise<WorkflowRunResult>;
790
+ /**
791
+ * Starts a workflow run and returns a stream
792
+ * @param params - Object containing the optional runId, inputData and runtimeContext
793
+ * @returns Promise containing the workflow execution results
794
+ */
795
+ stream(params: {
796
+ runId?: string;
797
+ inputData: Record<string, any>;
798
+ runtimeContext?: RuntimeContext;
799
+ }): Promise<stream_web.ReadableStream<{
800
+ type: string;
801
+ payload: any;
802
+ }>>;
803
+ /**
804
+ * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
805
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
806
+ * @returns Promise containing the workflow resume results
807
+ */
808
+ resumeAsync(params: {
809
+ runId: string;
810
+ step: string | string[];
811
+ resumeData?: Record<string, any>;
812
+ runtimeContext?: RuntimeContext | Record<string, any>;
813
+ }): Promise<WorkflowRunResult>;
814
+ /**
815
+ * Watches workflow transitions in real-time
816
+ * @param runId - Optional run ID to filter the watch stream
817
+ * @returns AsyncGenerator that yields parsed records from the workflow watch stream
818
+ */
819
+ watch({ runId }: {
820
+ runId?: string;
821
+ }, onRecord: (record: WorkflowWatchResult) => void): Promise<void>;
822
+ /**
823
+ * Creates a new ReadableStream from an iterable or async iterable of objects,
824
+ * serializing each as JSON and separating them with the record separator (\x1E).
825
+ *
826
+ * @param records - An iterable or async iterable of objects to stream
827
+ * @returns A ReadableStream emitting the records as JSON strings separated by the record separator
828
+ */
829
+ static createRecordStream(records: Iterable<any> | AsyncIterable<any>): ReadableStream;
830
+ }
831
+
832
+ /**
833
+ * Class for interacting with an agent via the A2A protocol
834
+ */
835
+ declare class A2A extends BaseResource {
836
+ private agentId;
837
+ constructor(options: ClientOptions, agentId: string);
838
+ /**
839
+ * Get the agent card with metadata about the agent
840
+ * @returns Promise containing the agent card information
841
+ */
842
+ getCard(): Promise<AgentCard>;
843
+ /**
844
+ * Send a message to the agent and get a response
845
+ * @param params - Parameters for the task
846
+ * @returns Promise containing the task response
847
+ */
848
+ sendMessage(params: TaskSendParams): Promise<{
849
+ task: Task;
850
+ }>;
851
+ /**
852
+ * Get the status and result of a task
853
+ * @param params - Parameters for querying the task
854
+ * @returns Promise containing the task response
855
+ */
856
+ getTask(params: TaskQueryParams): Promise<Task>;
857
+ /**
858
+ * Cancel a running task
859
+ * @param params - Parameters identifying the task to cancel
860
+ * @returns Promise containing the task response
861
+ */
862
+ cancelTask(params: TaskIdParams): Promise<{
863
+ task: Task;
864
+ }>;
865
+ /**
866
+ * Send a message and subscribe to streaming updates (not fully implemented)
867
+ * @param params - Parameters for the task
868
+ * @returns Promise containing the task response
869
+ */
870
+ sendAndSubscribe(params: TaskSendParams): Promise<Response>;
871
+ }
872
+
873
+ /**
874
+ * Represents a specific tool available on a specific MCP server.
875
+ * Provides methods to get details and execute the tool.
876
+ */
877
+ declare class MCPTool extends BaseResource {
878
+ private serverId;
879
+ private toolId;
880
+ constructor(options: ClientOptions, serverId: string, toolId: string);
881
+ /**
882
+ * Retrieves details about this specific tool from the MCP server.
883
+ * @returns Promise containing the tool's information (name, description, schema).
884
+ */
885
+ details(): Promise<McpToolInfo>;
886
+ /**
887
+ * Executes this specific tool on the MCP server.
888
+ * @param params - Parameters for tool execution, including data/args and optional runtimeContext.
889
+ * @returns Promise containing the result of the tool execution.
890
+ */
891
+ execute(params: {
892
+ data?: any;
893
+ runtimeContext?: RuntimeContext;
894
+ }): Promise<any>;
895
+ }
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
+
927
+ declare class VNextNetwork extends BaseResource {
928
+ private networkId;
929
+ constructor(options: ClientOptions, networkId: string);
930
+ /**
931
+ * Retrieves details about the network
932
+ * @returns Promise containing vNext network details
933
+ */
934
+ details(): Promise<GetVNextNetworkResponse>;
935
+ /**
936
+ * Generates a response from the v-next network
937
+ * @param params - Generation parameters including message
938
+ * @returns Promise containing the generated response
939
+ */
940
+ generate(params: GenerateOrStreamVNextNetworkParams): Promise<GenerateVNextNetworkResponse>;
941
+ /**
942
+ * Generates a response from the v-next network using multiple primitives
943
+ * @param params - Generation parameters including message
944
+ * @returns Promise containing the generated response
945
+ */
946
+ loop(params: {
947
+ message: string;
948
+ runtimeContext?: RuntimeContext | Record<string, any>;
949
+ }): Promise<LoopVNextNetworkResponse>;
950
+ private streamProcessor;
951
+ /**
952
+ * Streams a response from the v-next network
953
+ * @param params - Stream parameters including message
954
+ * @returns Promise containing the results
955
+ */
956
+ stream(params: GenerateOrStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
957
+ /**
958
+ * Streams a response from the v-next network loop
959
+ * @param params - Stream parameters including message
960
+ * @returns Promise containing the results
961
+ */
962
+ loopStream(params: LoopStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
963
+ }
964
+
475
965
  declare class MastraClient extends BaseResource {
476
966
  constructor(options: ClientOptions);
477
967
  /**
@@ -479,6 +969,9 @@ declare class MastraClient extends BaseResource {
479
969
  * @returns Promise containing map of agent IDs to agent details
480
970
  */
481
971
  getAgents(): Promise<Record<string, GetAgentResponse>>;
972
+ getAGUI({ resourceId }: {
973
+ resourceId: string;
974
+ }): Promise<Record<string, AbstractAgent>>;
482
975
  /**
483
976
  * Gets an agent instance by ID
484
977
  * @param agentId - ID of the agent to retrieve
@@ -516,6 +1009,37 @@ declare class MastraClient extends BaseResource {
516
1009
  getMemoryStatus(agentId: string): Promise<{
517
1010
  result: boolean;
518
1011
  }>;
1012
+ /**
1013
+ * Retrieves memory threads for a resource
1014
+ * @param params - Parameters containing the resource ID
1015
+ * @returns Promise containing array of memory threads
1016
+ */
1017
+ getNetworkMemoryThreads(params: GetNetworkMemoryThreadParams): Promise<GetMemoryThreadResponse>;
1018
+ /**
1019
+ * Creates a new memory thread
1020
+ * @param params - Parameters for creating the memory thread
1021
+ * @returns Promise containing the created memory thread
1022
+ */
1023
+ createNetworkMemoryThread(params: CreateNetworkMemoryThreadParams): Promise<CreateMemoryThreadResponse>;
1024
+ /**
1025
+ * Gets a memory thread instance by ID
1026
+ * @param threadId - ID of the memory thread to retrieve
1027
+ * @returns MemoryThread instance
1028
+ */
1029
+ getNetworkMemoryThread(threadId: string, networkId: string): NetworkMemoryThread;
1030
+ /**
1031
+ * Saves messages to memory
1032
+ * @param params - Parameters containing messages to save
1033
+ * @returns Promise containing the saved messages
1034
+ */
1035
+ saveNetworkMessageToMemory(params: SaveNetworkMessageToMemoryParams): Promise<SaveMessageToMemoryResponse>;
1036
+ /**
1037
+ * Gets the status of the memory system
1038
+ * @returns Promise containing memory system status
1039
+ */
1040
+ getNetworkMemoryStatus(networkId: string): Promise<{
1041
+ result: boolean;
1042
+ }>;
519
1043
  /**
520
1044
  * Retrieves all available tools
521
1045
  * @returns Promise containing map of tool IDs to tool details
@@ -527,6 +1051,17 @@ declare class MastraClient extends BaseResource {
527
1051
  * @returns Tool instance
528
1052
  */
529
1053
  getTool(toolId: string): Tool;
1054
+ /**
1055
+ * Retrieves all available legacy workflows
1056
+ * @returns Promise containing map of legacy workflow IDs to legacy workflow details
1057
+ */
1058
+ getLegacyWorkflows(): Promise<Record<string, GetLegacyWorkflowResponse>>;
1059
+ /**
1060
+ * Gets a legacy workflow instance by ID
1061
+ * @param workflowId - ID of the legacy workflow to retrieve
1062
+ * @returns Legacy Workflow instance
1063
+ */
1064
+ getLegacyWorkflow(workflowId: string): LegacyWorkflow;
530
1065
  /**
531
1066
  * Retrieves all available workflows
532
1067
  * @returns Promise containing map of workflow IDs to workflow details
@@ -573,13 +1108,87 @@ declare class MastraClient extends BaseResource {
573
1108
  * Retrieves all available networks
574
1109
  * @returns Promise containing map of network IDs to network details
575
1110
  */
576
- getNetworks(): Promise<Record<string, GetNetworkResponse>>;
1111
+ getNetworks(): Promise<Array<GetNetworkResponse>>;
1112
+ /**
1113
+ * Retrieves all available vNext networks
1114
+ * @returns Promise containing map of vNext network IDs to vNext network details
1115
+ */
1116
+ getVNextNetworks(): Promise<Array<GetVNextNetworkResponse>>;
577
1117
  /**
578
1118
  * Gets a network instance by ID
579
1119
  * @param networkId - ID of the network to retrieve
580
1120
  * @returns Network instance
581
1121
  */
582
1122
  getNetwork(networkId: string): Network;
1123
+ /**
1124
+ * Gets a vNext network instance by ID
1125
+ * @param networkId - ID of the vNext network to retrieve
1126
+ * @returns vNext Network instance
1127
+ */
1128
+ getVNextNetwork(networkId: string): VNextNetwork;
1129
+ /**
1130
+ * Retrieves a list of available MCP servers.
1131
+ * @param params - Optional parameters for pagination (limit, offset).
1132
+ * @returns Promise containing the list of MCP servers and pagination info.
1133
+ */
1134
+ getMcpServers(params?: {
1135
+ limit?: number;
1136
+ offset?: number;
1137
+ }): Promise<McpServerListResponse>;
1138
+ /**
1139
+ * Retrieves detailed information for a specific MCP server.
1140
+ * @param serverId - The ID of the MCP server to retrieve.
1141
+ * @param params - Optional parameters, e.g., specific version.
1142
+ * @returns Promise containing the detailed MCP server information.
1143
+ */
1144
+ getMcpServerDetails(serverId: string, params?: {
1145
+ version?: string;
1146
+ }): Promise<ServerDetailInfo>;
1147
+ /**
1148
+ * Retrieves a list of tools for a specific MCP server.
1149
+ * @param serverId - The ID of the MCP server.
1150
+ * @returns Promise containing the list of tools.
1151
+ */
1152
+ getMcpServerTools(serverId: string): Promise<McpServerToolListResponse>;
1153
+ /**
1154
+ * Gets an MCPTool resource instance for a specific tool on an MCP server.
1155
+ * This instance can then be used to fetch details or execute the tool.
1156
+ * @param serverId - The ID of the MCP server.
1157
+ * @param toolId - The ID of the tool.
1158
+ * @returns MCPTool instance.
1159
+ */
1160
+ getMcpServerTool(serverId: string, toolId: string): MCPTool;
1161
+ /**
1162
+ * Gets an A2A client for interacting with an agent via the A2A protocol
1163
+ * @param agentId - ID of the agent to interact with
1164
+ * @returns A2A client instance
1165
+ */
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>;
583
1192
  }
584
1193
 
585
- export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult };
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 };