@mastra/client-js 0.0.0-storage-20250225005900 → 0.0.0-taofeeqInngest-20250603090617

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.
@@ -0,0 +1,907 @@
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, QueryResult, GenerateReturn } from '@mastra/core';
5
+ import { JSONSchema7 } from 'json-schema';
6
+ import { ZodSchema } from 'zod';
7
+ import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
8
+ import { BaseLogMessage } from '@mastra/core/logger';
9
+ import { RuntimeContext } from '@mastra/core/runtime-context';
10
+ import { Workflow as Workflow$1, WorkflowResult, WatchEvent } 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';
14
+
15
+ interface ClientOptions {
16
+ /** Base URL for API requests */
17
+ baseUrl: string;
18
+ /** Number of retry attempts for failed requests */
19
+ retries?: number;
20
+ /** Initial backoff time in milliseconds between retries */
21
+ backoffMs?: number;
22
+ /** Maximum backoff time in milliseconds between retries */
23
+ maxBackoffMs?: number;
24
+ /** Custom headers to include with requests */
25
+ headers?: Record<string, string>;
26
+ }
27
+ interface RequestOptions {
28
+ method?: string;
29
+ headers?: Record<string, string>;
30
+ body?: any;
31
+ stream?: boolean;
32
+ signal?: AbortSignal;
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
+ };
39
+ interface GetAgentResponse {
40
+ name: string;
41
+ instructions: string;
42
+ tools: Record<string, GetToolResponse>;
43
+ workflows: Record<string, GetWorkflowResponse>;
44
+ provider: string;
45
+ modelId: string;
46
+ defaultGenerateOptions: WithoutMethods<AgentGenerateOptions>;
47
+ defaultStreamOptions: WithoutMethods<AgentStreamOptions>;
48
+ }
49
+ type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
50
+ messages: string | string[] | CoreMessage[] | AiMessageType[];
51
+ output?: T;
52
+ experimental_output?: T;
53
+ runtimeContext?: RuntimeContext | Record<string, any>;
54
+ } & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
55
+ type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
56
+ messages: string | string[] | CoreMessage[] | AiMessageType[];
57
+ output?: T;
58
+ experimental_output?: T;
59
+ runtimeContext?: RuntimeContext | Record<string, any>;
60
+ } & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
61
+ interface GetEvalsByAgentIdResponse extends GetAgentResponse {
62
+ evals: any[];
63
+ instructions: string;
64
+ name: string;
65
+ id: string;
66
+ }
67
+ interface GetToolResponse {
68
+ id: string;
69
+ description: string;
70
+ inputSchema: string;
71
+ outputSchema: string;
72
+ }
73
+ interface GetLegacyWorkflowResponse {
74
+ name: string;
75
+ triggerSchema: string;
76
+ steps: Record<string, StepAction<any, any, any, any>>;
77
+ stepGraph: StepGraph;
78
+ stepSubscriberGraph: Record<string, StepGraph>;
79
+ workflowId?: string;
80
+ }
81
+ interface GetWorkflowRunsParams {
82
+ fromDate?: Date;
83
+ toDate?: Date;
84
+ limit?: number;
85
+ offset?: number;
86
+ resourceId?: string;
87
+ }
88
+ type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
89
+ type GetWorkflowRunsResponse = WorkflowRuns;
90
+ type LegacyWorkflowRunResult = {
91
+ activePaths: Record<string, {
92
+ status: string;
93
+ suspendPayload?: any;
94
+ stepPath: string[];
95
+ }>;
96
+ results: LegacyWorkflowRunResult$1<any, any, any>['results'];
97
+ timestamp: number;
98
+ runId: string;
99
+ };
100
+ interface GetWorkflowResponse {
101
+ name: string;
102
+ description?: string;
103
+ steps: {
104
+ [key: string]: {
105
+ id: string;
106
+ description: string;
107
+ inputSchema: string;
108
+ outputSchema: string;
109
+ resumeSchema: string;
110
+ suspendSchema: string;
111
+ };
112
+ };
113
+ stepGraph: Workflow$1['serializedStepGraph'];
114
+ inputSchema: string;
115
+ outputSchema: string;
116
+ }
117
+ type WorkflowWatchResult = WatchEvent & {
118
+ runId: string;
119
+ };
120
+ type WorkflowRunResult = WorkflowResult<any, any>;
121
+ interface UpsertVectorParams {
122
+ indexName: string;
123
+ vectors: number[][];
124
+ metadata?: Record<string, any>[];
125
+ ids?: string[];
126
+ }
127
+ interface CreateIndexParams {
128
+ indexName: string;
129
+ dimension: number;
130
+ metric?: 'cosine' | 'euclidean' | 'dotproduct';
131
+ }
132
+ interface QueryVectorParams {
133
+ indexName: string;
134
+ queryVector: number[];
135
+ topK?: number;
136
+ filter?: Record<string, any>;
137
+ includeVector?: boolean;
138
+ }
139
+ interface QueryVectorResponse {
140
+ results: QueryResult[];
141
+ }
142
+ interface GetVectorIndexResponse {
143
+ dimension: number;
144
+ metric: 'cosine' | 'euclidean' | 'dotproduct';
145
+ count: number;
146
+ }
147
+ interface SaveMessageToMemoryParams {
148
+ messages: MastraMessageV1[];
149
+ agentId: string;
150
+ }
151
+ type SaveMessageToMemoryResponse = MastraMessageV1[];
152
+ interface CreateMemoryThreadParams {
153
+ title?: string;
154
+ metadata?: Record<string, any>;
155
+ resourceId: string;
156
+ threadId?: string;
157
+ agentId: string;
158
+ }
159
+ type CreateMemoryThreadResponse = StorageThreadType;
160
+ interface GetMemoryThreadParams {
161
+ resourceId: string;
162
+ agentId: string;
163
+ }
164
+ type GetMemoryThreadResponse = StorageThreadType[];
165
+ interface UpdateMemoryThreadParams {
166
+ title: string;
167
+ metadata: Record<string, any>;
168
+ resourceId: string;
169
+ }
170
+ interface GetMemoryThreadMessagesParams {
171
+ /**
172
+ * Limit the number of messages to retrieve (default: 40)
173
+ */
174
+ limit?: number;
175
+ }
176
+ interface GetMemoryThreadMessagesResponse {
177
+ messages: CoreMessage[];
178
+ uiMessages: AiMessageType[];
179
+ }
180
+ interface GetLogsParams {
181
+ transportId: string;
182
+ }
183
+ interface GetLogParams {
184
+ runId: string;
185
+ transportId: string;
186
+ }
187
+ type GetLogsResponse = BaseLogMessage[];
188
+ type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
189
+ type SpanStatus = {
190
+ code: number;
191
+ };
192
+ type SpanOther = {
193
+ droppedAttributesCount: number;
194
+ droppedEventsCount: number;
195
+ droppedLinksCount: number;
196
+ };
197
+ type SpanEventAttributes = {
198
+ key: string;
199
+ value: {
200
+ [key: string]: string | number | boolean | null;
201
+ };
202
+ };
203
+ type SpanEvent = {
204
+ attributes: SpanEventAttributes[];
205
+ name: string;
206
+ timeUnixNano: string;
207
+ droppedAttributesCount: number;
208
+ };
209
+ type Span = {
210
+ id: string;
211
+ parentSpanId: string | null;
212
+ traceId: string;
213
+ name: string;
214
+ scope: string;
215
+ kind: number;
216
+ status: SpanStatus;
217
+ events: SpanEvent[];
218
+ links: any[];
219
+ attributes: Record<string, string | number | boolean | null>;
220
+ startTime: number;
221
+ endTime: number;
222
+ duration: number;
223
+ other: SpanOther;
224
+ createdAt: string;
225
+ };
226
+ interface GetTelemetryResponse {
227
+ traces: Span[];
228
+ }
229
+ interface GetTelemetryParams {
230
+ name?: string;
231
+ scope?: string;
232
+ page?: number;
233
+ perPage?: number;
234
+ attribute?: Record<string, string>;
235
+ fromDate?: Date;
236
+ toDate?: Date;
237
+ }
238
+ interface GetNetworkResponse {
239
+ name: string;
240
+ instructions: string;
241
+ agents: Array<{
242
+ name: string;
243
+ provider: string;
244
+ modelId: string;
245
+ }>;
246
+ routingModel: {
247
+ provider: string;
248
+ modelId: string;
249
+ };
250
+ state?: Record<string, any>;
251
+ }
252
+ interface McpServerListResponse {
253
+ servers: ServerInfo[];
254
+ next: string | null;
255
+ total_count: number;
256
+ }
257
+ interface McpToolInfo {
258
+ id: string;
259
+ name: string;
260
+ description?: string;
261
+ inputSchema: string;
262
+ toolType?: MCPToolType;
263
+ }
264
+ interface McpServerToolListResponse {
265
+ tools: McpToolInfo[];
266
+ }
267
+
268
+ declare class BaseResource {
269
+ readonly options: ClientOptions;
270
+ constructor(options: ClientOptions);
271
+ /**
272
+ * Makes an HTTP request to the API with retries and exponential backoff
273
+ * @param path - The API endpoint path
274
+ * @param options - Optional request configuration
275
+ * @returns Promise containing the response data
276
+ */
277
+ request<T>(path: string, options?: RequestOptions): Promise<T>;
278
+ }
279
+
280
+ declare class AgentVoice extends BaseResource {
281
+ private agentId;
282
+ constructor(options: ClientOptions, agentId: string);
283
+ /**
284
+ * Convert text to speech using the agent's voice provider
285
+ * @param text - Text to convert to speech
286
+ * @param options - Optional provider-specific options for speech generation
287
+ * @returns Promise containing the audio data
288
+ */
289
+ speak(text: string, options?: {
290
+ speaker?: string;
291
+ [key: string]: any;
292
+ }): Promise<Response>;
293
+ /**
294
+ * Convert speech to text using the agent's voice provider
295
+ * @param audio - Audio data to transcribe
296
+ * @param options - Optional provider-specific options
297
+ * @returns Promise containing the transcribed text
298
+ */
299
+ listen(audio: Blob, options?: Record<string, any>): Promise<{
300
+ text: string;
301
+ }>;
302
+ /**
303
+ * Get available speakers for the agent's voice provider
304
+ * @returns Promise containing list of available speakers
305
+ */
306
+ getSpeakers(): Promise<Array<{
307
+ voiceId: string;
308
+ [key: string]: any;
309
+ }>>;
310
+ /**
311
+ * Get the listener configuration for the agent's voice provider
312
+ * @returns Promise containing a check if the agent has listening capabilities
313
+ */
314
+ getListener(): Promise<{
315
+ enabled: boolean;
316
+ }>;
317
+ }
318
+ declare class Agent extends BaseResource {
319
+ private agentId;
320
+ readonly voice: AgentVoice;
321
+ constructor(options: ClientOptions, agentId: string);
322
+ /**
323
+ * Retrieves details about the agent
324
+ * @returns Promise containing agent details including model and instructions
325
+ */
326
+ details(): Promise<GetAgentResponse>;
327
+ /**
328
+ * Generates a response from the agent
329
+ * @param params - Generation parameters including prompt
330
+ * @returns Promise containing the generated response
331
+ */
332
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>): Promise<GenerateReturn<T>>;
333
+ /**
334
+ * Streams a response from the agent
335
+ * @param params - Stream parameters including prompt
336
+ * @returns Promise containing the enhanced Response object with processDataStream method
337
+ */
338
+ stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
339
+ processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
340
+ }>;
341
+ /**
342
+ * Gets details about a specific tool available to the agent
343
+ * @param toolId - ID of the tool to retrieve
344
+ * @returns Promise containing tool details
345
+ */
346
+ getTool(toolId: string): Promise<GetToolResponse>;
347
+ /**
348
+ * Executes a tool for the agent
349
+ * @param toolId - ID of the tool to execute
350
+ * @param params - Parameters required for tool execution
351
+ * @returns Promise containing the tool execution results
352
+ */
353
+ executeTool(toolId: string, params: {
354
+ data: any;
355
+ runtimeContext?: RuntimeContext;
356
+ }): Promise<any>;
357
+ /**
358
+ * Retrieves evaluation results for the agent
359
+ * @returns Promise containing agent evaluations
360
+ */
361
+ evals(): Promise<GetEvalsByAgentIdResponse>;
362
+ /**
363
+ * Retrieves live evaluation results for the agent
364
+ * @returns Promise containing live agent evaluations
365
+ */
366
+ liveEvals(): Promise<GetEvalsByAgentIdResponse>;
367
+ }
368
+
369
+ declare class Network extends BaseResource {
370
+ private networkId;
371
+ constructor(options: ClientOptions, networkId: string);
372
+ /**
373
+ * Retrieves details about the network
374
+ * @returns Promise containing network details
375
+ */
376
+ details(): Promise<GetNetworkResponse>;
377
+ /**
378
+ * Generates a response from the agent
379
+ * @param params - Generation parameters including prompt
380
+ * @returns Promise containing the generated response
381
+ */
382
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>): Promise<GenerateReturn<T>>;
383
+ /**
384
+ * Streams a response from the agent
385
+ * @param params - Stream parameters including prompt
386
+ * @returns Promise containing the enhanced Response object with processDataStream method
387
+ */
388
+ stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
389
+ processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
390
+ }>;
391
+ }
392
+
393
+ declare class MemoryThread extends BaseResource {
394
+ private threadId;
395
+ private agentId;
396
+ constructor(options: ClientOptions, threadId: string, agentId: string);
397
+ /**
398
+ * Retrieves the memory thread details
399
+ * @returns Promise containing thread details including title and metadata
400
+ */
401
+ get(): Promise<StorageThreadType>;
402
+ /**
403
+ * Updates the memory thread properties
404
+ * @param params - Update parameters including title and metadata
405
+ * @returns Promise containing updated thread details
406
+ */
407
+ update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
408
+ /**
409
+ * Deletes the memory thread
410
+ * @returns Promise containing deletion result
411
+ */
412
+ delete(): Promise<{
413
+ result: string;
414
+ }>;
415
+ /**
416
+ * Retrieves messages associated with the thread
417
+ * @param params - Optional parameters including limit for number of messages to retrieve
418
+ * @returns Promise containing thread messages and UI messages
419
+ */
420
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
421
+ }
422
+
423
+ declare class Vector extends BaseResource {
424
+ private vectorName;
425
+ constructor(options: ClientOptions, vectorName: string);
426
+ /**
427
+ * Retrieves details about a specific vector index
428
+ * @param indexName - Name of the index to get details for
429
+ * @returns Promise containing vector index details
430
+ */
431
+ details(indexName: string): Promise<GetVectorIndexResponse>;
432
+ /**
433
+ * Deletes a vector index
434
+ * @param indexName - Name of the index to delete
435
+ * @returns Promise indicating deletion success
436
+ */
437
+ delete(indexName: string): Promise<{
438
+ success: boolean;
439
+ }>;
440
+ /**
441
+ * Retrieves a list of all available indexes
442
+ * @returns Promise containing array of index names
443
+ */
444
+ getIndexes(): Promise<{
445
+ indexes: string[];
446
+ }>;
447
+ /**
448
+ * Creates a new vector index
449
+ * @param params - Parameters for index creation including dimension and metric
450
+ * @returns Promise indicating creation success
451
+ */
452
+ createIndex(params: CreateIndexParams): Promise<{
453
+ success: boolean;
454
+ }>;
455
+ /**
456
+ * Upserts vectors into an index
457
+ * @param params - Parameters containing vectors, metadata, and optional IDs
458
+ * @returns Promise containing array of vector IDs
459
+ */
460
+ upsert(params: UpsertVectorParams): Promise<string[]>;
461
+ /**
462
+ * Queries vectors in an index
463
+ * @param params - Query parameters including query vector and search options
464
+ * @returns Promise containing query results
465
+ */
466
+ query(params: QueryVectorParams): Promise<QueryVectorResponse>;
467
+ }
468
+
469
+ declare class LegacyWorkflow extends BaseResource {
470
+ private workflowId;
471
+ constructor(options: ClientOptions, workflowId: string);
472
+ /**
473
+ * Retrieves details about the legacy workflow
474
+ * @returns Promise containing legacy workflow details including steps and graphs
475
+ */
476
+ details(): Promise<GetLegacyWorkflowResponse>;
477
+ /**
478
+ * Retrieves all runs for a legacy workflow
479
+ * @param params - Parameters for filtering runs
480
+ * @returns Promise containing legacy workflow runs array
481
+ */
482
+ runs(params?: GetWorkflowRunsParams): Promise<GetLegacyWorkflowRunsResponse>;
483
+ /**
484
+ * Creates a new legacy workflow run
485
+ * @returns Promise containing the generated run ID
486
+ */
487
+ createRun(params?: {
488
+ runId?: string;
489
+ }): Promise<{
490
+ runId: string;
491
+ }>;
492
+ /**
493
+ * Starts a legacy workflow run synchronously without waiting for the workflow to complete
494
+ * @param params - Object containing the runId and triggerData
495
+ * @returns Promise containing success message
496
+ */
497
+ start(params: {
498
+ runId: string;
499
+ triggerData: Record<string, any>;
500
+ }): Promise<{
501
+ message: string;
502
+ }>;
503
+ /**
504
+ * Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
505
+ * @param stepId - ID of the step to resume
506
+ * @param runId - ID of the legacy workflow run
507
+ * @param context - Context to resume the legacy workflow with
508
+ * @returns Promise containing the legacy workflow resume results
509
+ */
510
+ resume({ stepId, runId, context, }: {
511
+ stepId: string;
512
+ runId: string;
513
+ context: Record<string, any>;
514
+ }): Promise<{
515
+ message: string;
516
+ }>;
517
+ /**
518
+ * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
519
+ * @param params - Object containing the optional runId and triggerData
520
+ * @returns Promise containing the workflow execution results
521
+ */
522
+ startAsync(params: {
523
+ runId?: string;
524
+ triggerData: Record<string, any>;
525
+ }): Promise<LegacyWorkflowRunResult>;
526
+ /**
527
+ * Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
528
+ * @param params - Object containing the runId, stepId, and context
529
+ * @returns Promise containing the workflow resume results
530
+ */
531
+ resumeAsync(params: {
532
+ runId: string;
533
+ stepId: string;
534
+ context: Record<string, any>;
535
+ }): Promise<LegacyWorkflowRunResult>;
536
+ /**
537
+ * Creates an async generator that processes a readable stream and yields records
538
+ * separated by the Record Separator character (\x1E)
539
+ *
540
+ * @param stream - The readable stream to process
541
+ * @returns An async generator that yields parsed records
542
+ */
543
+ private streamProcessor;
544
+ /**
545
+ * Watches legacy workflow transitions in real-time
546
+ * @param runId - Optional run ID to filter the watch stream
547
+ * @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
548
+ */
549
+ watch({ runId }: {
550
+ runId?: string;
551
+ }, onRecord: (record: LegacyWorkflowRunResult) => void): Promise<void>;
552
+ }
553
+
554
+ declare class Tool extends BaseResource {
555
+ private toolId;
556
+ constructor(options: ClientOptions, toolId: string);
557
+ /**
558
+ * Retrieves details about the tool
559
+ * @returns Promise containing tool details including description and schemas
560
+ */
561
+ details(): Promise<GetToolResponse>;
562
+ /**
563
+ * Executes the tool with the provided parameters
564
+ * @param params - Parameters required for tool execution
565
+ * @returns Promise containing the tool execution results
566
+ */
567
+ execute(params: {
568
+ data: any;
569
+ runId?: string;
570
+ runtimeContext?: RuntimeContext | Record<string, any>;
571
+ }): Promise<any>;
572
+ }
573
+
574
+ declare class Workflow extends BaseResource {
575
+ private workflowId;
576
+ constructor(options: ClientOptions, workflowId: string);
577
+ /**
578
+ * Creates an async generator that processes a readable stream and yields workflow records
579
+ * separated by the Record Separator character (\x1E)
580
+ *
581
+ * @param stream - The readable stream to process
582
+ * @returns An async generator that yields parsed records
583
+ */
584
+ private streamProcessor;
585
+ /**
586
+ * Retrieves details about the workflow
587
+ * @returns Promise containing workflow details including steps and graphs
588
+ */
589
+ details(): Promise<GetWorkflowResponse>;
590
+ /**
591
+ * Retrieves all runs for a workflow
592
+ * @param params - Parameters for filtering runs
593
+ * @returns Promise containing workflow runs array
594
+ */
595
+ runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
596
+ /**
597
+ * Creates a new workflow run
598
+ * @param params - Optional object containing the optional runId
599
+ * @returns Promise containing the runId of the created run
600
+ */
601
+ createRun(params?: {
602
+ runId?: string;
603
+ }): Promise<{
604
+ runId: string;
605
+ }>;
606
+ /**
607
+ * Starts a workflow run synchronously without waiting for the workflow to complete
608
+ * @param params - Object containing the runId, inputData and runtimeContext
609
+ * @returns Promise containing success message
610
+ */
611
+ start(params: {
612
+ runId: string;
613
+ inputData: Record<string, any>;
614
+ runtimeContext?: RuntimeContext | Record<string, any>;
615
+ }): Promise<{
616
+ message: string;
617
+ }>;
618
+ /**
619
+ * Resumes a suspended workflow step synchronously without waiting for the workflow to complete
620
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
621
+ * @returns Promise containing success message
622
+ */
623
+ resume({ step, runId, resumeData, ...rest }: {
624
+ step: string | string[];
625
+ runId: string;
626
+ resumeData?: Record<string, any>;
627
+ runtimeContext?: RuntimeContext | Record<string, any>;
628
+ }): Promise<{
629
+ message: string;
630
+ }>;
631
+ /**
632
+ * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
633
+ * @param params - Object containing the optional runId, inputData and runtimeContext
634
+ * @returns Promise containing the workflow execution results
635
+ */
636
+ startAsync(params: {
637
+ runId?: string;
638
+ inputData: Record<string, any>;
639
+ runtimeContext?: RuntimeContext | Record<string, any>;
640
+ }): Promise<WorkflowRunResult>;
641
+ /**
642
+ * Starts a vNext workflow run and returns a stream
643
+ * @param params - Object containing the optional runId, inputData and runtimeContext
644
+ * @returns Promise containing the vNext workflow execution results
645
+ */
646
+ stream(params: {
647
+ runId?: string;
648
+ inputData: Record<string, any>;
649
+ runtimeContext?: RuntimeContext;
650
+ }): Promise<stream_web.ReadableStream<WorkflowWatchResult>>;
651
+ /**
652
+ * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
653
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
654
+ * @returns Promise containing the workflow resume results
655
+ */
656
+ resumeAsync(params: {
657
+ runId: string;
658
+ step: string | string[];
659
+ resumeData?: Record<string, any>;
660
+ runtimeContext?: RuntimeContext | Record<string, any>;
661
+ }): Promise<WorkflowRunResult>;
662
+ /**
663
+ * Watches workflow transitions in real-time
664
+ * @param runId - Optional run ID to filter the watch stream
665
+ * @returns AsyncGenerator that yields parsed records from the workflow watch stream
666
+ */
667
+ watch({ runId }: {
668
+ runId?: string;
669
+ }, onRecord: (record: WorkflowWatchResult) => void): Promise<void>;
670
+ /**
671
+ * Creates a new ReadableStream from an iterable or async iterable of objects,
672
+ * serializing each as JSON and separating them with the record separator (\x1E).
673
+ *
674
+ * @param records - An iterable or async iterable of objects to stream
675
+ * @returns A ReadableStream emitting the records as JSON strings separated by the record separator
676
+ */
677
+ static createRecordStream(records: Iterable<any> | AsyncIterable<any>): ReadableStream;
678
+ }
679
+
680
+ /**
681
+ * Class for interacting with an agent via the A2A protocol
682
+ */
683
+ declare class A2A extends BaseResource {
684
+ private agentId;
685
+ constructor(options: ClientOptions, agentId: string);
686
+ /**
687
+ * Get the agent card with metadata about the agent
688
+ * @returns Promise containing the agent card information
689
+ */
690
+ getCard(): Promise<AgentCard>;
691
+ /**
692
+ * Send a message to the agent and get a response
693
+ * @param params - Parameters for the task
694
+ * @returns Promise containing the task response
695
+ */
696
+ sendMessage(params: TaskSendParams): Promise<{
697
+ task: Task;
698
+ }>;
699
+ /**
700
+ * Get the status and result of a task
701
+ * @param params - Parameters for querying the task
702
+ * @returns Promise containing the task response
703
+ */
704
+ getTask(params: TaskQueryParams): Promise<Task>;
705
+ /**
706
+ * Cancel a running task
707
+ * @param params - Parameters identifying the task to cancel
708
+ * @returns Promise containing the task response
709
+ */
710
+ cancelTask(params: TaskIdParams): Promise<{
711
+ task: Task;
712
+ }>;
713
+ /**
714
+ * Send a message and subscribe to streaming updates (not fully implemented)
715
+ * @param params - Parameters for the task
716
+ * @returns Promise containing the task response
717
+ */
718
+ sendAndSubscribe(params: TaskSendParams): Promise<Response>;
719
+ }
720
+
721
+ /**
722
+ * Represents a specific tool available on a specific MCP server.
723
+ * Provides methods to get details and execute the tool.
724
+ */
725
+ declare class MCPTool extends BaseResource {
726
+ private serverId;
727
+ private toolId;
728
+ constructor(options: ClientOptions, serverId: string, toolId: string);
729
+ /**
730
+ * Retrieves details about this specific tool from the MCP server.
731
+ * @returns Promise containing the tool's information (name, description, schema).
732
+ */
733
+ details(): Promise<McpToolInfo>;
734
+ /**
735
+ * Executes this specific tool on the MCP server.
736
+ * @param params - Parameters for tool execution, including data/args and optional runtimeContext.
737
+ * @returns Promise containing the result of the tool execution.
738
+ */
739
+ execute(params: {
740
+ data?: any;
741
+ runtimeContext?: RuntimeContext;
742
+ }): Promise<any>;
743
+ }
744
+
745
+ declare class MastraClient extends BaseResource {
746
+ constructor(options: ClientOptions);
747
+ /**
748
+ * Retrieves all available agents
749
+ * @returns Promise containing map of agent IDs to agent details
750
+ */
751
+ getAgents(): Promise<Record<string, GetAgentResponse>>;
752
+ getAGUI({ resourceId }: {
753
+ resourceId: string;
754
+ }): Promise<Record<string, AbstractAgent>>;
755
+ /**
756
+ * Gets an agent instance by ID
757
+ * @param agentId - ID of the agent to retrieve
758
+ * @returns Agent instance
759
+ */
760
+ getAgent(agentId: string): Agent;
761
+ /**
762
+ * Retrieves memory threads for a resource
763
+ * @param params - Parameters containing the resource ID
764
+ * @returns Promise containing array of memory threads
765
+ */
766
+ getMemoryThreads(params: GetMemoryThreadParams): Promise<GetMemoryThreadResponse>;
767
+ /**
768
+ * Creates a new memory thread
769
+ * @param params - Parameters for creating the memory thread
770
+ * @returns Promise containing the created memory thread
771
+ */
772
+ createMemoryThread(params: CreateMemoryThreadParams): Promise<CreateMemoryThreadResponse>;
773
+ /**
774
+ * Gets a memory thread instance by ID
775
+ * @param threadId - ID of the memory thread to retrieve
776
+ * @returns MemoryThread instance
777
+ */
778
+ getMemoryThread(threadId: string, agentId: string): MemoryThread;
779
+ /**
780
+ * Saves messages to memory
781
+ * @param params - Parameters containing messages to save
782
+ * @returns Promise containing the saved messages
783
+ */
784
+ saveMessageToMemory(params: SaveMessageToMemoryParams): Promise<SaveMessageToMemoryResponse>;
785
+ /**
786
+ * Gets the status of the memory system
787
+ * @returns Promise containing memory system status
788
+ */
789
+ getMemoryStatus(agentId: string): Promise<{
790
+ result: boolean;
791
+ }>;
792
+ /**
793
+ * Retrieves all available tools
794
+ * @returns Promise containing map of tool IDs to tool details
795
+ */
796
+ getTools(): Promise<Record<string, GetToolResponse>>;
797
+ /**
798
+ * Gets a tool instance by ID
799
+ * @param toolId - ID of the tool to retrieve
800
+ * @returns Tool instance
801
+ */
802
+ getTool(toolId: string): Tool;
803
+ /**
804
+ * Retrieves all available legacy workflows
805
+ * @returns Promise containing map of legacy workflow IDs to legacy workflow details
806
+ */
807
+ getLegacyWorkflows(): Promise<Record<string, GetLegacyWorkflowResponse>>;
808
+ /**
809
+ * Gets a legacy workflow instance by ID
810
+ * @param workflowId - ID of the legacy workflow to retrieve
811
+ * @returns Legacy Workflow instance
812
+ */
813
+ getLegacyWorkflow(workflowId: string): LegacyWorkflow;
814
+ /**
815
+ * Retrieves all available workflows
816
+ * @returns Promise containing map of workflow IDs to workflow details
817
+ */
818
+ getWorkflows(): Promise<Record<string, GetWorkflowResponse>>;
819
+ /**
820
+ * Gets a workflow instance by ID
821
+ * @param workflowId - ID of the workflow to retrieve
822
+ * @returns Workflow instance
823
+ */
824
+ getWorkflow(workflowId: string): Workflow;
825
+ /**
826
+ * Gets a vector instance by name
827
+ * @param vectorName - Name of the vector to retrieve
828
+ * @returns Vector instance
829
+ */
830
+ getVector(vectorName: string): Vector;
831
+ /**
832
+ * Retrieves logs
833
+ * @param params - Parameters for filtering logs
834
+ * @returns Promise containing array of log messages
835
+ */
836
+ getLogs(params: GetLogsParams): Promise<GetLogsResponse>;
837
+ /**
838
+ * Gets logs for a specific run
839
+ * @param params - Parameters containing run ID to retrieve
840
+ * @returns Promise containing array of log messages
841
+ */
842
+ getLogForRun(params: GetLogParams): Promise<GetLogsResponse>;
843
+ /**
844
+ * List of all log transports
845
+ * @returns Promise containing list of log transports
846
+ */
847
+ getLogTransports(): Promise<{
848
+ transports: string[];
849
+ }>;
850
+ /**
851
+ * List of all traces (paged)
852
+ * @param params - Parameters for filtering traces
853
+ * @returns Promise containing telemetry data
854
+ */
855
+ getTelemetry(params?: GetTelemetryParams): Promise<GetTelemetryResponse>;
856
+ /**
857
+ * Retrieves all available networks
858
+ * @returns Promise containing map of network IDs to network details
859
+ */
860
+ getNetworks(): Promise<Record<string, GetNetworkResponse>>;
861
+ /**
862
+ * Gets a network instance by ID
863
+ * @param networkId - ID of the network to retrieve
864
+ * @returns Network instance
865
+ */
866
+ getNetwork(networkId: string): Network;
867
+ /**
868
+ * Retrieves a list of available MCP servers.
869
+ * @param params - Optional parameters for pagination (limit, offset).
870
+ * @returns Promise containing the list of MCP servers and pagination info.
871
+ */
872
+ getMcpServers(params?: {
873
+ limit?: number;
874
+ offset?: number;
875
+ }): Promise<McpServerListResponse>;
876
+ /**
877
+ * Retrieves detailed information for a specific MCP server.
878
+ * @param serverId - The ID of the MCP server to retrieve.
879
+ * @param params - Optional parameters, e.g., specific version.
880
+ * @returns Promise containing the detailed MCP server information.
881
+ */
882
+ getMcpServerDetails(serverId: string, params?: {
883
+ version?: string;
884
+ }): Promise<ServerDetailInfo>;
885
+ /**
886
+ * Retrieves a list of tools for a specific MCP server.
887
+ * @param serverId - The ID of the MCP server.
888
+ * @returns Promise containing the list of tools.
889
+ */
890
+ getMcpServerTools(serverId: string): Promise<McpServerToolListResponse>;
891
+ /**
892
+ * Gets an MCPTool resource instance for a specific tool on an MCP server.
893
+ * This instance can then be used to fetch details or execute the tool.
894
+ * @param serverId - The ID of the MCP server.
895
+ * @param toolId - The ID of the tool.
896
+ * @returns MCPTool instance.
897
+ */
898
+ getMcpServerTool(serverId: string, toolId: string): MCPTool;
899
+ /**
900
+ * Gets an A2A client for interacting with an agent via the A2A protocol
901
+ * @param agentId - ID of the agent to interact with
902
+ * @returns A2A client instance
903
+ */
904
+ getA2A(agentId: string): A2A;
905
+ }
906
+
907
+ 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 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 };