@mastra/client-js 0.0.0-commonjs-20250414101718 → 0.0.0-custom-instrumentation-20250626084921

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,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 } 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 */
@@ -23,21 +31,40 @@ interface RequestOptions {
23
31
  stream?: boolean;
24
32
  signal?: AbortSignal;
25
33
  }
34
+ type WithoutMethods<T> = {
35
+ [K in keyof T as T[K] extends (...args: any[]) => any ? never : T[K] extends {
36
+ (): any;
37
+ } ? never : T[K] extends undefined | ((...args: any[]) => any) ? never : K]: T[K];
38
+ };
26
39
  interface GetAgentResponse {
27
40
  name: string;
28
41
  instructions: string;
29
42
  tools: Record<string, GetToolResponse>;
43
+ workflows: Record<string, GetWorkflowResponse>;
30
44
  provider: string;
31
45
  modelId: string;
46
+ defaultGenerateOptions: WithoutMethods<AgentGenerateOptions>;
47
+ defaultStreamOptions: WithoutMethods<AgentStreamOptions>;
32
48
  }
33
49
  type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
34
50
  messages: string | string[] | CoreMessage[] | AiMessageType[];
35
- } & Partial<AgentGenerateOptions<T>>;
51
+ output?: T;
52
+ experimental_output?: T;
53
+ runtimeContext?: RuntimeContext | Record<string, any>;
54
+ clientTools?: ToolsInput;
55
+ } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
36
56
  type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
37
57
  messages: string | string[] | CoreMessage[] | AiMessageType[];
38
- } & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
58
+ output?: T;
59
+ experimental_output?: T;
60
+ runtimeContext?: RuntimeContext | Record<string, any>;
61
+ clientTools?: ToolsInput;
62
+ } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
39
63
  interface GetEvalsByAgentIdResponse extends GetAgentResponse {
40
64
  evals: any[];
65
+ instructions: string;
66
+ name: string;
67
+ id: string;
41
68
  }
42
69
  interface GetToolResponse {
43
70
  id: string;
@@ -45,7 +72,7 @@ interface GetToolResponse {
45
72
  inputSchema: string;
46
73
  outputSchema: string;
47
74
  }
48
- interface GetWorkflowResponse {
75
+ interface GetLegacyWorkflowResponse {
49
76
  name: string;
50
77
  triggerSchema: string;
51
78
  steps: Record<string, StepAction<any, any, any, any>>;
@@ -53,16 +80,48 @@ interface GetWorkflowResponse {
53
80
  stepSubscriberGraph: Record<string, StepGraph>;
54
81
  workflowId?: string;
55
82
  }
56
- type WorkflowRunResult = {
83
+ interface GetWorkflowRunsParams {
84
+ fromDate?: Date;
85
+ toDate?: Date;
86
+ limit?: number;
87
+ offset?: number;
88
+ resourceId?: string;
89
+ }
90
+ type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
91
+ type GetWorkflowRunsResponse = WorkflowRuns;
92
+ type GetWorkflowRunByIdResponse = WorkflowRun;
93
+ type GetWorkflowRunExecutionResultResponse = WatchEvent['payload']['workflowState'];
94
+ type LegacyWorkflowRunResult = {
57
95
  activePaths: Record<string, {
58
96
  status: string;
59
97
  suspendPayload?: any;
60
98
  stepPath: string[];
61
99
  }>;
62
- results: WorkflowRunResult$1<any, any, any>['results'];
100
+ results: LegacyWorkflowRunResult$1<any, any, any>['results'];
63
101
  timestamp: number;
64
102
  runId: string;
65
103
  };
104
+ interface GetWorkflowResponse {
105
+ name: string;
106
+ description?: string;
107
+ steps: {
108
+ [key: string]: {
109
+ id: string;
110
+ description: string;
111
+ inputSchema: string;
112
+ outputSchema: string;
113
+ resumeSchema: string;
114
+ suspendSchema: string;
115
+ };
116
+ };
117
+ stepGraph: Workflow$1['serializedStepGraph'];
118
+ inputSchema: string;
119
+ outputSchema: string;
120
+ }
121
+ type WorkflowWatchResult = WatchEvent & {
122
+ runId: string;
123
+ };
124
+ type WorkflowRunResult = WorkflowResult<any, any>;
66
125
  interface UpsertVectorParams {
67
126
  indexName: string;
68
127
  vectors: number[][];
@@ -90,27 +149,48 @@ interface GetVectorIndexResponse {
90
149
  count: number;
91
150
  }
92
151
  interface SaveMessageToMemoryParams {
93
- messages: MessageType[];
152
+ messages: MastraMessageV1[];
94
153
  agentId: string;
95
154
  }
96
- type SaveMessageToMemoryResponse = MessageType[];
155
+ interface SaveNetworkMessageToMemoryParams {
156
+ messages: MastraMessageV1[];
157
+ networkId: string;
158
+ }
159
+ type SaveMessageToMemoryResponse = MastraMessageV1[];
97
160
  interface CreateMemoryThreadParams {
98
- title: string;
99
- metadata: Record<string, any>;
100
- resourceid: string;
101
- threadId: string;
161
+ title?: string;
162
+ metadata?: Record<string, any>;
163
+ resourceId: string;
164
+ threadId?: string;
102
165
  agentId: string;
103
166
  }
167
+ interface CreateNetworkMemoryThreadParams {
168
+ title?: string;
169
+ metadata?: Record<string, any>;
170
+ resourceId: string;
171
+ threadId?: string;
172
+ networkId: string;
173
+ }
104
174
  type CreateMemoryThreadResponse = StorageThreadType;
105
175
  interface GetMemoryThreadParams {
106
176
  resourceId: string;
107
177
  agentId: string;
108
178
  }
179
+ interface GetNetworkMemoryThreadParams {
180
+ resourceId: string;
181
+ networkId: string;
182
+ }
109
183
  type GetMemoryThreadResponse = StorageThreadType[];
110
184
  interface UpdateMemoryThreadParams {
111
185
  title: string;
112
186
  metadata: Record<string, any>;
113
- resourceid: string;
187
+ resourceId: string;
188
+ }
189
+ interface GetMemoryThreadMessagesParams {
190
+ /**
191
+ * Limit the number of messages to retrieve (default: 40)
192
+ */
193
+ limit?: number;
114
194
  }
115
195
  interface GetMemoryThreadMessagesResponse {
116
196
  messages: CoreMessage[];
@@ -118,12 +198,30 @@ interface GetMemoryThreadMessagesResponse {
118
198
  }
119
199
  interface GetLogsParams {
120
200
  transportId: string;
201
+ fromDate?: Date;
202
+ toDate?: Date;
203
+ logLevel?: LogLevel;
204
+ filters?: Record<string, string>;
205
+ page?: number;
206
+ perPage?: number;
121
207
  }
122
208
  interface GetLogParams {
123
209
  runId: string;
124
210
  transportId: string;
211
+ fromDate?: Date;
212
+ toDate?: Date;
213
+ logLevel?: LogLevel;
214
+ filters?: Record<string, string>;
215
+ page?: number;
216
+ perPage?: number;
125
217
  }
126
- type GetLogsResponse = BaseLogMessage[];
218
+ type GetLogsResponse = {
219
+ logs: BaseLogMessage[];
220
+ total: number;
221
+ page: number;
222
+ perPage: number;
223
+ hasMore: boolean;
224
+ };
127
225
  type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
128
226
  type SpanStatus = {
129
227
  code: number;
@@ -171,8 +269,11 @@ interface GetTelemetryParams {
171
269
  page?: number;
172
270
  perPage?: number;
173
271
  attribute?: Record<string, string>;
272
+ fromDate?: Date;
273
+ toDate?: Date;
174
274
  }
175
275
  interface GetNetworkResponse {
276
+ id: string;
176
277
  name: string;
177
278
  instructions: string;
178
279
  agents: Array<{
@@ -186,6 +287,65 @@ interface GetNetworkResponse {
186
287
  };
187
288
  state?: Record<string, any>;
188
289
  }
290
+ interface GetVNextNetworkResponse {
291
+ id: string;
292
+ name: string;
293
+ instructions: string;
294
+ agents: Array<{
295
+ name: string;
296
+ provider: string;
297
+ modelId: string;
298
+ }>;
299
+ routingModel: {
300
+ provider: string;
301
+ modelId: string;
302
+ };
303
+ workflows: Array<{
304
+ name: string;
305
+ description: string;
306
+ inputSchema: string | undefined;
307
+ outputSchema: string | undefined;
308
+ }>;
309
+ }
310
+ interface GenerateVNextNetworkResponse {
311
+ task: string;
312
+ result: string;
313
+ resourceId: string;
314
+ resourceType: 'none' | 'tool' | 'agent' | 'workflow';
315
+ }
316
+ interface GenerateOrStreamVNextNetworkParams {
317
+ message: string;
318
+ threadId?: string;
319
+ resourceId?: string;
320
+ }
321
+ interface LoopStreamVNextNetworkParams {
322
+ message: string;
323
+ threadId?: string;
324
+ resourceId?: string;
325
+ maxIterations?: number;
326
+ }
327
+ interface LoopVNextNetworkResponse {
328
+ status: 'success';
329
+ result: {
330
+ text: string;
331
+ };
332
+ steps: WorkflowResult<any, any>['steps'];
333
+ }
334
+ interface McpServerListResponse {
335
+ servers: ServerInfo[];
336
+ next: string | null;
337
+ total_count: number;
338
+ }
339
+ interface McpToolInfo {
340
+ id: string;
341
+ name: string;
342
+ description?: string;
343
+ inputSchema: string;
344
+ toolType?: MCPToolType;
345
+ }
346
+ interface McpServerToolListResponse {
347
+ tools: McpToolInfo[];
348
+ }
189
349
 
190
350
  declare class BaseResource {
191
351
  readonly options: ClientOptions;
@@ -218,7 +378,9 @@ declare class AgentVoice extends BaseResource {
218
378
  * @param options - Optional provider-specific options
219
379
  * @returns Promise containing the transcribed text
220
380
  */
221
- listen(audio: Blob, options?: Record<string, any>): Promise<Response>;
381
+ listen(audio: Blob, options?: Record<string, any>): Promise<{
382
+ text: string;
383
+ }>;
222
384
  /**
223
385
  * Get available speakers for the agent's voice provider
224
386
  * @returns Promise containing list of available speakers
@@ -227,6 +389,13 @@ declare class AgentVoice extends BaseResource {
227
389
  voiceId: string;
228
390
  [key: string]: any;
229
391
  }>>;
392
+ /**
393
+ * Get the listener configuration for the agent's voice provider
394
+ * @returns Promise containing a check if the agent has listening capabilities
395
+ */
396
+ getListener(): Promise<{
397
+ enabled: boolean;
398
+ }>;
230
399
  }
231
400
  declare class Agent extends BaseResource {
232
401
  private agentId;
@@ -242,7 +411,19 @@ declare class Agent extends BaseResource {
242
411
  * @param params - Generation parameters including prompt
243
412
  * @returns Promise containing the generated response
244
413
  */
245
- generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>): Promise<GenerateReturn<T>>;
414
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
415
+ output?: never;
416
+ experimental_output?: never;
417
+ }): Promise<GenerateReturn<T>>;
418
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
419
+ output: T;
420
+ experimental_output?: never;
421
+ }): Promise<GenerateReturn<T>>;
422
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
423
+ output?: never;
424
+ experimental_output: T;
425
+ }): Promise<GenerateReturn<T>>;
426
+ private processChatResponse;
246
427
  /**
247
428
  * Streams a response from the agent
248
429
  * @param params - Stream parameters including prompt
@@ -251,12 +432,26 @@ declare class Agent extends BaseResource {
251
432
  stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
252
433
  processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
253
434
  }>;
435
+ /**
436
+ * Processes the stream response and handles tool calls
437
+ */
438
+ private processStreamResponse;
254
439
  /**
255
440
  * Gets details about a specific tool available to the agent
256
441
  * @param toolId - ID of the tool to retrieve
257
442
  * @returns Promise containing tool details
258
443
  */
259
444
  getTool(toolId: string): Promise<GetToolResponse>;
445
+ /**
446
+ * Executes a tool for the agent
447
+ * @param toolId - ID of the tool to execute
448
+ * @param params - Parameters required for tool execution
449
+ * @returns Promise containing the tool execution results
450
+ */
451
+ executeTool(toolId: string, params: {
452
+ data: any;
453
+ runtimeContext?: RuntimeContext;
454
+ }): Promise<any>;
260
455
  /**
261
456
  * Retrieves evaluation results for the agent
262
457
  * @returns Promise containing agent evaluations
@@ -317,9 +512,10 @@ declare class MemoryThread extends BaseResource {
317
512
  }>;
318
513
  /**
319
514
  * Retrieves messages associated with the thread
515
+ * @param params - Optional parameters including limit for number of messages to retrieve
320
516
  * @returns Promise containing thread messages and UI messages
321
517
  */
322
- getMessages(): Promise<GetMemoryThreadMessagesResponse>;
518
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
323
519
  }
324
520
 
325
521
  declare class Vector extends BaseResource {
@@ -368,23 +564,22 @@ declare class Vector extends BaseResource {
368
564
  query(params: QueryVectorParams): Promise<QueryVectorResponse>;
369
565
  }
370
566
 
371
- declare class Workflow extends BaseResource {
567
+ declare class LegacyWorkflow extends BaseResource {
372
568
  private workflowId;
373
569
  constructor(options: ClientOptions, workflowId: string);
374
570
  /**
375
- * Retrieves details about the workflow
376
- * @returns Promise containing workflow details including steps and graphs
571
+ * Retrieves details about the legacy workflow
572
+ * @returns Promise containing legacy workflow details including steps and graphs
377
573
  */
378
- details(): Promise<GetWorkflowResponse>;
574
+ details(): Promise<GetLegacyWorkflowResponse>;
379
575
  /**
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
576
+ * Retrieves all runs for a legacy workflow
577
+ * @param params - Parameters for filtering runs
578
+ * @returns Promise containing legacy workflow runs array
384
579
  */
385
- execute(params: Record<string, any>): Promise<WorkflowRunResult>;
580
+ runs(params?: GetWorkflowRunsParams): Promise<GetLegacyWorkflowRunsResponse>;
386
581
  /**
387
- * Creates a new workflow run
582
+ * Creates a new legacy workflow run
388
583
  * @returns Promise containing the generated run ID
389
584
  */
390
585
  createRun(params?: {
@@ -393,7 +588,7 @@ declare class Workflow extends BaseResource {
393
588
  runId: string;
394
589
  }>;
395
590
  /**
396
- * Starts a workflow run synchronously without waiting for the workflow to complete
591
+ * Starts a legacy workflow run synchronously without waiting for the workflow to complete
397
592
  * @param params - Object containing the runId and triggerData
398
593
  * @returns Promise containing success message
399
594
  */
@@ -404,11 +599,11 @@ declare class Workflow extends BaseResource {
404
599
  message: string;
405
600
  }>;
406
601
  /**
407
- * Resumes a suspended workflow step synchronously without waiting for the workflow to complete
602
+ * Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
408
603
  * @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
604
+ * @param runId - ID of the legacy workflow run
605
+ * @param context - Context to resume the legacy workflow with
606
+ * @returns Promise containing the legacy workflow resume results
412
607
  */
413
608
  resume({ stepId, runId, context, }: {
414
609
  stepId: string;
@@ -425,9 +620,9 @@ declare class Workflow extends BaseResource {
425
620
  startAsync(params: {
426
621
  runId?: string;
427
622
  triggerData: Record<string, any>;
428
- }): Promise<WorkflowRunResult>;
623
+ }): Promise<LegacyWorkflowRunResult>;
429
624
  /**
430
- * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
625
+ * Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
431
626
  * @param params - Object containing the runId, stepId, and context
432
627
  * @returns Promise containing the workflow resume results
433
628
  */
@@ -435,7 +630,7 @@ declare class Workflow extends BaseResource {
435
630
  runId: string;
436
631
  stepId: string;
437
632
  context: Record<string, any>;
438
- }): Promise<WorkflowRunResult>;
633
+ }): Promise<LegacyWorkflowRunResult>;
439
634
  /**
440
635
  * Creates an async generator that processes a readable stream and yields records
441
636
  * separated by the Record Separator character (\x1E)
@@ -445,13 +640,13 @@ declare class Workflow extends BaseResource {
445
640
  */
446
641
  private streamProcessor;
447
642
  /**
448
- * Watches workflow transitions in real-time
643
+ * Watches legacy workflow transitions in real-time
449
644
  * @param runId - Optional run ID to filter the watch stream
450
- * @returns AsyncGenerator that yields parsed records from the workflow watch stream
645
+ * @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
451
646
  */
452
647
  watch({ runId }: {
453
648
  runId?: string;
454
- }, onRecord: (record: WorkflowRunResult) => void): Promise<void>;
649
+ }, onRecord: (record: LegacyWorkflowRunResult) => void): Promise<void>;
455
650
  }
456
651
 
457
652
  declare class Tool extends BaseResource {
@@ -469,9 +664,261 @@ declare class Tool extends BaseResource {
469
664
  */
470
665
  execute(params: {
471
666
  data: any;
667
+ runId?: string;
668
+ runtimeContext?: RuntimeContext | Record<string, any>;
472
669
  }): Promise<any>;
473
670
  }
474
671
 
672
+ declare class Workflow extends BaseResource {
673
+ private workflowId;
674
+ constructor(options: ClientOptions, workflowId: string);
675
+ /**
676
+ * Creates an async generator that processes a readable stream and yields workflow records
677
+ * separated by the Record Separator character (\x1E)
678
+ *
679
+ * @param stream - The readable stream to process
680
+ * @returns An async generator that yields parsed records
681
+ */
682
+ private streamProcessor;
683
+ /**
684
+ * Retrieves details about the workflow
685
+ * @returns Promise containing workflow details including steps and graphs
686
+ */
687
+ details(): Promise<GetWorkflowResponse>;
688
+ /**
689
+ * Retrieves all runs for a workflow
690
+ * @param params - Parameters for filtering runs
691
+ * @returns Promise containing workflow runs array
692
+ */
693
+ runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
694
+ /**
695
+ * Retrieves a specific workflow run by its ID
696
+ * @param runId - The ID of the workflow run to retrieve
697
+ * @returns Promise containing the workflow run details
698
+ */
699
+ runById(runId: string): Promise<GetWorkflowRunByIdResponse>;
700
+ /**
701
+ * Retrieves the execution result for a specific workflow run by its ID
702
+ * @param runId - The ID of the workflow run to retrieve the execution result for
703
+ * @returns Promise containing the workflow run execution result
704
+ */
705
+ runExecutionResult(runId: string): Promise<GetWorkflowRunExecutionResultResponse>;
706
+ /**
707
+ * Creates a new workflow run
708
+ * @param params - Optional object containing the optional runId
709
+ * @returns Promise containing the runId of the created run
710
+ */
711
+ createRun(params?: {
712
+ runId?: string;
713
+ }): Promise<{
714
+ runId: string;
715
+ }>;
716
+ /**
717
+ * Starts a workflow run synchronously without waiting for the workflow to complete
718
+ * @param params - Object containing the runId, inputData and runtimeContext
719
+ * @returns Promise containing success message
720
+ */
721
+ start(params: {
722
+ runId: string;
723
+ inputData: Record<string, any>;
724
+ runtimeContext?: RuntimeContext | Record<string, any>;
725
+ }): Promise<{
726
+ message: string;
727
+ }>;
728
+ /**
729
+ * Resumes a suspended workflow step synchronously without waiting for the workflow to complete
730
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
731
+ * @returns Promise containing success message
732
+ */
733
+ resume({ step, runId, resumeData, ...rest }: {
734
+ step: string | string[];
735
+ runId: string;
736
+ resumeData?: Record<string, any>;
737
+ runtimeContext?: RuntimeContext | Record<string, any>;
738
+ }): Promise<{
739
+ message: string;
740
+ }>;
741
+ /**
742
+ * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
743
+ * @param params - Object containing the optional runId, inputData and runtimeContext
744
+ * @returns Promise containing the workflow execution results
745
+ */
746
+ startAsync(params: {
747
+ runId?: string;
748
+ inputData: Record<string, any>;
749
+ runtimeContext?: RuntimeContext | Record<string, any>;
750
+ }): Promise<WorkflowRunResult>;
751
+ /**
752
+ * Starts a workflow run and returns a stream
753
+ * @param params - Object containing the optional runId, inputData and runtimeContext
754
+ * @returns Promise containing the workflow execution results
755
+ */
756
+ stream(params: {
757
+ runId?: string;
758
+ inputData: Record<string, any>;
759
+ runtimeContext?: RuntimeContext;
760
+ }): Promise<stream_web.ReadableStream<WorkflowWatchResult>>;
761
+ /**
762
+ * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
763
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
764
+ * @returns Promise containing the workflow resume results
765
+ */
766
+ resumeAsync(params: {
767
+ runId: string;
768
+ step: string | string[];
769
+ resumeData?: Record<string, any>;
770
+ runtimeContext?: RuntimeContext | Record<string, any>;
771
+ }): Promise<WorkflowRunResult>;
772
+ /**
773
+ * Watches workflow transitions in real-time
774
+ * @param runId - Optional run ID to filter the watch stream
775
+ * @returns AsyncGenerator that yields parsed records from the workflow watch stream
776
+ */
777
+ watch({ runId }: {
778
+ runId?: string;
779
+ }, onRecord: (record: WorkflowWatchResult) => void): Promise<void>;
780
+ /**
781
+ * Creates a new ReadableStream from an iterable or async iterable of objects,
782
+ * serializing each as JSON and separating them with the record separator (\x1E).
783
+ *
784
+ * @param records - An iterable or async iterable of objects to stream
785
+ * @returns A ReadableStream emitting the records as JSON strings separated by the record separator
786
+ */
787
+ static createRecordStream(records: Iterable<any> | AsyncIterable<any>): ReadableStream;
788
+ }
789
+
790
+ /**
791
+ * Class for interacting with an agent via the A2A protocol
792
+ */
793
+ declare class A2A extends BaseResource {
794
+ private agentId;
795
+ constructor(options: ClientOptions, agentId: string);
796
+ /**
797
+ * Get the agent card with metadata about the agent
798
+ * @returns Promise containing the agent card information
799
+ */
800
+ getCard(): Promise<AgentCard>;
801
+ /**
802
+ * Send a message to the agent and get a response
803
+ * @param params - Parameters for the task
804
+ * @returns Promise containing the task response
805
+ */
806
+ sendMessage(params: TaskSendParams): Promise<{
807
+ task: Task;
808
+ }>;
809
+ /**
810
+ * Get the status and result of a task
811
+ * @param params - Parameters for querying the task
812
+ * @returns Promise containing the task response
813
+ */
814
+ getTask(params: TaskQueryParams): Promise<Task>;
815
+ /**
816
+ * Cancel a running task
817
+ * @param params - Parameters identifying the task to cancel
818
+ * @returns Promise containing the task response
819
+ */
820
+ cancelTask(params: TaskIdParams): Promise<{
821
+ task: Task;
822
+ }>;
823
+ /**
824
+ * Send a message and subscribe to streaming updates (not fully implemented)
825
+ * @param params - Parameters for the task
826
+ * @returns Promise containing the task response
827
+ */
828
+ sendAndSubscribe(params: TaskSendParams): Promise<Response>;
829
+ }
830
+
831
+ /**
832
+ * Represents a specific tool available on a specific MCP server.
833
+ * Provides methods to get details and execute the tool.
834
+ */
835
+ declare class MCPTool extends BaseResource {
836
+ private serverId;
837
+ private toolId;
838
+ constructor(options: ClientOptions, serverId: string, toolId: string);
839
+ /**
840
+ * Retrieves details about this specific tool from the MCP server.
841
+ * @returns Promise containing the tool's information (name, description, schema).
842
+ */
843
+ details(): Promise<McpToolInfo>;
844
+ /**
845
+ * Executes this specific tool on the MCP server.
846
+ * @param params - Parameters for tool execution, including data/args and optional runtimeContext.
847
+ * @returns Promise containing the result of the tool execution.
848
+ */
849
+ execute(params: {
850
+ data?: any;
851
+ runtimeContext?: RuntimeContext;
852
+ }): Promise<any>;
853
+ }
854
+
855
+ declare class VNextNetwork extends BaseResource {
856
+ private networkId;
857
+ constructor(options: ClientOptions, networkId: string);
858
+ /**
859
+ * Retrieves details about the network
860
+ * @returns Promise containing vNext network details
861
+ */
862
+ details(): Promise<GetVNextNetworkResponse>;
863
+ /**
864
+ * Generates a response from the v-next network
865
+ * @param params - Generation parameters including message
866
+ * @returns Promise containing the generated response
867
+ */
868
+ generate(params: GenerateOrStreamVNextNetworkParams): Promise<GenerateVNextNetworkResponse>;
869
+ /**
870
+ * Generates a response from the v-next network using multiple primitives
871
+ * @param params - Generation parameters including message
872
+ * @returns Promise containing the generated response
873
+ */
874
+ loop(params: {
875
+ message: string;
876
+ }): Promise<LoopVNextNetworkResponse>;
877
+ private streamProcessor;
878
+ /**
879
+ * Streams a response from the v-next network
880
+ * @param params - Stream parameters including message
881
+ * @returns Promise containing the results
882
+ */
883
+ stream(params: GenerateOrStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
884
+ /**
885
+ * Streams a response from the v-next network loop
886
+ * @param params - Stream parameters including message
887
+ * @returns Promise containing the results
888
+ */
889
+ loopStream(params: LoopStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
890
+ }
891
+
892
+ declare class NetworkMemoryThread extends BaseResource {
893
+ private threadId;
894
+ private networkId;
895
+ constructor(options: ClientOptions, threadId: string, networkId: string);
896
+ /**
897
+ * Retrieves the memory thread details
898
+ * @returns Promise containing thread details including title and metadata
899
+ */
900
+ get(): Promise<StorageThreadType>;
901
+ /**
902
+ * Updates the memory thread properties
903
+ * @param params - Update parameters including title and metadata
904
+ * @returns Promise containing updated thread details
905
+ */
906
+ update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
907
+ /**
908
+ * Deletes the memory thread
909
+ * @returns Promise containing deletion result
910
+ */
911
+ delete(): Promise<{
912
+ result: string;
913
+ }>;
914
+ /**
915
+ * Retrieves messages associated with the thread
916
+ * @param params - Optional parameters including limit for number of messages to retrieve
917
+ * @returns Promise containing thread messages and UI messages
918
+ */
919
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
920
+ }
921
+
475
922
  declare class MastraClient extends BaseResource {
476
923
  constructor(options: ClientOptions);
477
924
  /**
@@ -479,6 +926,9 @@ declare class MastraClient extends BaseResource {
479
926
  * @returns Promise containing map of agent IDs to agent details
480
927
  */
481
928
  getAgents(): Promise<Record<string, GetAgentResponse>>;
929
+ getAGUI({ resourceId }: {
930
+ resourceId: string;
931
+ }): Promise<Record<string, AbstractAgent>>;
482
932
  /**
483
933
  * Gets an agent instance by ID
484
934
  * @param agentId - ID of the agent to retrieve
@@ -516,6 +966,37 @@ declare class MastraClient extends BaseResource {
516
966
  getMemoryStatus(agentId: string): Promise<{
517
967
  result: boolean;
518
968
  }>;
969
+ /**
970
+ * Retrieves memory threads for a resource
971
+ * @param params - Parameters containing the resource ID
972
+ * @returns Promise containing array of memory threads
973
+ */
974
+ getNetworkMemoryThreads(params: GetNetworkMemoryThreadParams): Promise<GetMemoryThreadResponse>;
975
+ /**
976
+ * Creates a new memory thread
977
+ * @param params - Parameters for creating the memory thread
978
+ * @returns Promise containing the created memory thread
979
+ */
980
+ createNetworkMemoryThread(params: CreateNetworkMemoryThreadParams): Promise<CreateMemoryThreadResponse>;
981
+ /**
982
+ * Gets a memory thread instance by ID
983
+ * @param threadId - ID of the memory thread to retrieve
984
+ * @returns MemoryThread instance
985
+ */
986
+ getNetworkMemoryThread(threadId: string, networkId: string): NetworkMemoryThread;
987
+ /**
988
+ * Saves messages to memory
989
+ * @param params - Parameters containing messages to save
990
+ * @returns Promise containing the saved messages
991
+ */
992
+ saveNetworkMessageToMemory(params: SaveNetworkMessageToMemoryParams): Promise<SaveMessageToMemoryResponse>;
993
+ /**
994
+ * Gets the status of the memory system
995
+ * @returns Promise containing memory system status
996
+ */
997
+ getNetworkMemoryStatus(networkId: string): Promise<{
998
+ result: boolean;
999
+ }>;
519
1000
  /**
520
1001
  * Retrieves all available tools
521
1002
  * @returns Promise containing map of tool IDs to tool details
@@ -527,6 +1008,17 @@ declare class MastraClient extends BaseResource {
527
1008
  * @returns Tool instance
528
1009
  */
529
1010
  getTool(toolId: string): Tool;
1011
+ /**
1012
+ * Retrieves all available legacy workflows
1013
+ * @returns Promise containing map of legacy workflow IDs to legacy workflow details
1014
+ */
1015
+ getLegacyWorkflows(): Promise<Record<string, GetLegacyWorkflowResponse>>;
1016
+ /**
1017
+ * Gets a legacy workflow instance by ID
1018
+ * @param workflowId - ID of the legacy workflow to retrieve
1019
+ * @returns Legacy Workflow instance
1020
+ */
1021
+ getLegacyWorkflow(workflowId: string): LegacyWorkflow;
530
1022
  /**
531
1023
  * Retrieves all available workflows
532
1024
  * @returns Promise containing map of workflow IDs to workflow details
@@ -573,13 +1065,62 @@ declare class MastraClient extends BaseResource {
573
1065
  * Retrieves all available networks
574
1066
  * @returns Promise containing map of network IDs to network details
575
1067
  */
576
- getNetworks(): Promise<Record<string, GetNetworkResponse>>;
1068
+ getNetworks(): Promise<Array<GetNetworkResponse>>;
1069
+ /**
1070
+ * Retrieves all available vNext networks
1071
+ * @returns Promise containing map of vNext network IDs to vNext network details
1072
+ */
1073
+ getVNextNetworks(): Promise<Array<GetVNextNetworkResponse>>;
577
1074
  /**
578
1075
  * Gets a network instance by ID
579
1076
  * @param networkId - ID of the network to retrieve
580
1077
  * @returns Network instance
581
1078
  */
582
1079
  getNetwork(networkId: string): Network;
1080
+ /**
1081
+ * Gets a vNext network instance by ID
1082
+ * @param networkId - ID of the vNext network to retrieve
1083
+ * @returns vNext Network instance
1084
+ */
1085
+ getVNextNetwork(networkId: string): VNextNetwork;
1086
+ /**
1087
+ * Retrieves a list of available MCP servers.
1088
+ * @param params - Optional parameters for pagination (limit, offset).
1089
+ * @returns Promise containing the list of MCP servers and pagination info.
1090
+ */
1091
+ getMcpServers(params?: {
1092
+ limit?: number;
1093
+ offset?: number;
1094
+ }): Promise<McpServerListResponse>;
1095
+ /**
1096
+ * Retrieves detailed information for a specific MCP server.
1097
+ * @param serverId - The ID of the MCP server to retrieve.
1098
+ * @param params - Optional parameters, e.g., specific version.
1099
+ * @returns Promise containing the detailed MCP server information.
1100
+ */
1101
+ getMcpServerDetails(serverId: string, params?: {
1102
+ version?: string;
1103
+ }): Promise<ServerDetailInfo>;
1104
+ /**
1105
+ * Retrieves a list of tools for a specific MCP server.
1106
+ * @param serverId - The ID of the MCP server.
1107
+ * @returns Promise containing the list of tools.
1108
+ */
1109
+ getMcpServerTools(serverId: string): Promise<McpServerToolListResponse>;
1110
+ /**
1111
+ * Gets an MCPTool resource instance for a specific tool on an MCP server.
1112
+ * This instance can then be used to fetch details or execute the tool.
1113
+ * @param serverId - The ID of the MCP server.
1114
+ * @param toolId - The ID of the tool.
1115
+ * @returns MCPTool instance.
1116
+ */
1117
+ getMcpServerTool(serverId: string, toolId: string): MCPTool;
1118
+ /**
1119
+ * Gets an A2A client for interacting with an agent via the A2A protocol
1120
+ * @param agentId - ID of the agent to interact with
1121
+ * @returns A2A client instance
1122
+ */
1123
+ getA2A(agentId: string): A2A;
583
1124
  }
584
1125
 
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 };
1126
+ 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 };