@mastra/client-js 0.10.12 → 0.10.14-alpha.0

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,1194 @@
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';
5
+ import { JSONSchema7 } from 'json-schema';
6
+ import { ZodSchema } from 'zod';
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';
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
+ /** Abort signal for request */
27
+ abortSignal?: AbortSignal;
28
+ }
29
+ interface RequestOptions {
30
+ method?: string;
31
+ headers?: Record<string, string>;
32
+ body?: any;
33
+ stream?: boolean;
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
+ };
40
+ interface GetAgentResponse {
41
+ name: string;
42
+ instructions: string;
43
+ tools: Record<string, GetToolResponse>;
44
+ workflows: Record<string, GetWorkflowResponse>;
45
+ provider: string;
46
+ modelId: string;
47
+ defaultGenerateOptions: WithoutMethods<AgentGenerateOptions>;
48
+ defaultStreamOptions: WithoutMethods<AgentStreamOptions>;
49
+ }
50
+ type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
51
+ messages: string | string[] | CoreMessage[] | AiMessageType[];
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'>>;
57
+ type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
58
+ messages: string | string[] | CoreMessage[] | AiMessageType[];
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'>>;
64
+ interface GetEvalsByAgentIdResponse extends GetAgentResponse {
65
+ evals: any[];
66
+ instructions: string;
67
+ name: string;
68
+ id: string;
69
+ }
70
+ interface GetToolResponse {
71
+ id: string;
72
+ description: string;
73
+ inputSchema: string;
74
+ outputSchema: string;
75
+ }
76
+ interface GetLegacyWorkflowResponse {
77
+ name: string;
78
+ triggerSchema: string;
79
+ steps: Record<string, StepAction<any, any, any, any>>;
80
+ stepGraph: StepGraph;
81
+ stepSubscriberGraph: Record<string, StepGraph>;
82
+ workflowId?: string;
83
+ }
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 = {
96
+ activePaths: Record<string, {
97
+ status: string;
98
+ suspendPayload?: any;
99
+ stepPath: string[];
100
+ }>;
101
+ results: LegacyWorkflowRunResult$1<any, any, any>['results'];
102
+ timestamp: number;
103
+ runId: string;
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>;
137
+ interface UpsertVectorParams {
138
+ indexName: string;
139
+ vectors: number[][];
140
+ metadata?: Record<string, any>[];
141
+ ids?: string[];
142
+ }
143
+ interface CreateIndexParams {
144
+ indexName: string;
145
+ dimension: number;
146
+ metric?: 'cosine' | 'euclidean' | 'dotproduct';
147
+ }
148
+ interface QueryVectorParams {
149
+ indexName: string;
150
+ queryVector: number[];
151
+ topK?: number;
152
+ filter?: Record<string, any>;
153
+ includeVector?: boolean;
154
+ }
155
+ interface QueryVectorResponse {
156
+ results: QueryResult[];
157
+ }
158
+ interface GetVectorIndexResponse {
159
+ dimension: number;
160
+ metric: 'cosine' | 'euclidean' | 'dotproduct';
161
+ count: number;
162
+ }
163
+ interface SaveMessageToMemoryParams {
164
+ messages: MastraMessageV1[];
165
+ agentId: string;
166
+ }
167
+ interface SaveNetworkMessageToMemoryParams {
168
+ messages: MastraMessageV1[];
169
+ networkId: string;
170
+ }
171
+ type SaveMessageToMemoryResponse = MastraMessageV1[];
172
+ interface CreateMemoryThreadParams {
173
+ title?: string;
174
+ metadata?: Record<string, any>;
175
+ resourceId: string;
176
+ threadId?: string;
177
+ agentId: string;
178
+ }
179
+ interface CreateNetworkMemoryThreadParams {
180
+ title?: string;
181
+ metadata?: Record<string, any>;
182
+ resourceId: string;
183
+ threadId?: string;
184
+ networkId: string;
185
+ }
186
+ type CreateMemoryThreadResponse = StorageThreadType;
187
+ interface GetMemoryThreadParams {
188
+ resourceId: string;
189
+ agentId: string;
190
+ }
191
+ interface GetNetworkMemoryThreadParams {
192
+ resourceId: string;
193
+ networkId: string;
194
+ }
195
+ type GetMemoryThreadResponse = StorageThreadType[];
196
+ interface UpdateMemoryThreadParams {
197
+ title: string;
198
+ metadata: Record<string, any>;
199
+ resourceId: string;
200
+ }
201
+ interface GetMemoryThreadMessagesParams {
202
+ /**
203
+ * Limit the number of messages to retrieve (default: 40)
204
+ */
205
+ limit?: number;
206
+ }
207
+ interface GetMemoryThreadMessagesResponse {
208
+ messages: CoreMessage[];
209
+ uiMessages: AiMessageType[];
210
+ }
211
+ interface GetLogsParams {
212
+ transportId: string;
213
+ fromDate?: Date;
214
+ toDate?: Date;
215
+ logLevel?: LogLevel;
216
+ filters?: Record<string, string>;
217
+ page?: number;
218
+ perPage?: number;
219
+ }
220
+ interface GetLogParams {
221
+ runId: string;
222
+ transportId: string;
223
+ fromDate?: Date;
224
+ toDate?: Date;
225
+ logLevel?: LogLevel;
226
+ filters?: Record<string, string>;
227
+ page?: number;
228
+ perPage?: number;
229
+ }
230
+ type GetLogsResponse = {
231
+ logs: BaseLogMessage[];
232
+ total: number;
233
+ page: number;
234
+ perPage: number;
235
+ hasMore: boolean;
236
+ };
237
+ type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
238
+ type SpanStatus = {
239
+ code: number;
240
+ };
241
+ type SpanOther = {
242
+ droppedAttributesCount: number;
243
+ droppedEventsCount: number;
244
+ droppedLinksCount: number;
245
+ };
246
+ type SpanEventAttributes = {
247
+ key: string;
248
+ value: {
249
+ [key: string]: string | number | boolean | null;
250
+ };
251
+ };
252
+ type SpanEvent = {
253
+ attributes: SpanEventAttributes[];
254
+ name: string;
255
+ timeUnixNano: string;
256
+ droppedAttributesCount: number;
257
+ };
258
+ type Span = {
259
+ id: string;
260
+ parentSpanId: string | null;
261
+ traceId: string;
262
+ name: string;
263
+ scope: string;
264
+ kind: number;
265
+ status: SpanStatus;
266
+ events: SpanEvent[];
267
+ links: any[];
268
+ attributes: Record<string, string | number | boolean | null>;
269
+ startTime: number;
270
+ endTime: number;
271
+ duration: number;
272
+ other: SpanOther;
273
+ createdAt: string;
274
+ };
275
+ interface GetTelemetryResponse {
276
+ traces: Span[];
277
+ }
278
+ interface GetTelemetryParams {
279
+ name?: string;
280
+ scope?: string;
281
+ page?: number;
282
+ perPage?: number;
283
+ attribute?: Record<string, string>;
284
+ fromDate?: Date;
285
+ toDate?: Date;
286
+ }
287
+ interface GetNetworkResponse {
288
+ id: string;
289
+ name: string;
290
+ instructions: string;
291
+ agents: Array<{
292
+ name: string;
293
+ provider: string;
294
+ modelId: string;
295
+ }>;
296
+ routingModel: {
297
+ provider: string;
298
+ modelId: string;
299
+ };
300
+ state?: Record<string, any>;
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
+ }
367
+
368
+ declare class BaseResource {
369
+ readonly options: ClientOptions;
370
+ constructor(options: ClientOptions);
371
+ /**
372
+ * Makes an HTTP request to the API with retries and exponential backoff
373
+ * @param path - The API endpoint path
374
+ * @param options - Optional request configuration
375
+ * @returns Promise containing the response data
376
+ */
377
+ request<T>(path: string, options?: RequestOptions): Promise<T>;
378
+ }
379
+
380
+ declare class AgentVoice extends BaseResource {
381
+ private agentId;
382
+ constructor(options: ClientOptions, agentId: string);
383
+ /**
384
+ * Convert text to speech using the agent's voice provider
385
+ * @param text - Text to convert to speech
386
+ * @param options - Optional provider-specific options for speech generation
387
+ * @returns Promise containing the audio data
388
+ */
389
+ speak(text: string, options?: {
390
+ speaker?: string;
391
+ [key: string]: any;
392
+ }): Promise<Response>;
393
+ /**
394
+ * Convert speech to text using the agent's voice provider
395
+ * @param audio - Audio data to transcribe
396
+ * @param options - Optional provider-specific options
397
+ * @returns Promise containing the transcribed text
398
+ */
399
+ listen(audio: Blob, options?: Record<string, any>): Promise<{
400
+ text: string;
401
+ }>;
402
+ /**
403
+ * Get available speakers for the agent's voice provider
404
+ * @returns Promise containing list of available speakers
405
+ */
406
+ getSpeakers(): Promise<Array<{
407
+ voiceId: string;
408
+ [key: string]: any;
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
+ }>;
417
+ }
418
+ declare class Agent extends BaseResource {
419
+ private agentId;
420
+ readonly voice: AgentVoice;
421
+ constructor(options: ClientOptions, agentId: string);
422
+ /**
423
+ * Retrieves details about the agent
424
+ * @returns Promise containing agent details including model and instructions
425
+ */
426
+ details(): Promise<GetAgentResponse>;
427
+ /**
428
+ * Generates a response from the agent
429
+ * @param params - Generation parameters including prompt
430
+ * @returns Promise containing the generated response
431
+ */
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;
449
+ /**
450
+ * Streams a response from the agent
451
+ * @param params - Stream parameters including prompt
452
+ * @returns Promise containing the enhanced Response object with processDataStream and processTextStream methods
453
+ */
454
+ stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
455
+ processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
456
+ processTextStream: (options?: Omit<Parameters<typeof processTextStream>[0], 'stream'>) => Promise<void>;
457
+ }>;
458
+ /**
459
+ * Gets details about a specific tool available to the agent
460
+ * @param toolId - ID of the tool to retrieve
461
+ * @returns Promise containing tool details
462
+ */
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>;
474
+ /**
475
+ * Retrieves evaluation results for the agent
476
+ * @returns Promise containing agent evaluations
477
+ */
478
+ evals(): Promise<GetEvalsByAgentIdResponse>;
479
+ /**
480
+ * Retrieves live evaluation results for the agent
481
+ * @returns Promise containing live agent evaluations
482
+ */
483
+ liveEvals(): Promise<GetEvalsByAgentIdResponse>;
484
+ }
485
+
486
+ declare class Network extends BaseResource {
487
+ private networkId;
488
+ constructor(options: ClientOptions, networkId: string);
489
+ /**
490
+ * Retrieves details about the network
491
+ * @returns Promise containing network details
492
+ */
493
+ details(): Promise<GetNetworkResponse>;
494
+ /**
495
+ * Generates a response from the agent
496
+ * @param params - Generation parameters including prompt
497
+ * @returns Promise containing the generated response
498
+ */
499
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>): Promise<GenerateReturn<T>>;
500
+ /**
501
+ * Streams a response from the agent
502
+ * @param params - Stream parameters including prompt
503
+ * @returns Promise containing the enhanced Response object with processDataStream method
504
+ */
505
+ stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
506
+ processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
507
+ }>;
508
+ }
509
+
510
+ declare class MemoryThread extends BaseResource {
511
+ private threadId;
512
+ private agentId;
513
+ constructor(options: ClientOptions, threadId: string, agentId: string);
514
+ /**
515
+ * Retrieves the memory thread details
516
+ * @returns Promise containing thread details including title and metadata
517
+ */
518
+ get(): Promise<StorageThreadType>;
519
+ /**
520
+ * Updates the memory thread properties
521
+ * @param params - Update parameters including title and metadata
522
+ * @returns Promise containing updated thread details
523
+ */
524
+ update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
525
+ /**
526
+ * Deletes the memory thread
527
+ * @returns Promise containing deletion result
528
+ */
529
+ delete(): Promise<{
530
+ result: string;
531
+ }>;
532
+ /**
533
+ * Retrieves messages associated with the thread
534
+ * @param params - Optional parameters including limit for number of messages to retrieve
535
+ * @returns Promise containing thread messages and UI messages
536
+ */
537
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
538
+ }
539
+
540
+ declare class Vector extends BaseResource {
541
+ private vectorName;
542
+ constructor(options: ClientOptions, vectorName: string);
543
+ /**
544
+ * Retrieves details about a specific vector index
545
+ * @param indexName - Name of the index to get details for
546
+ * @returns Promise containing vector index details
547
+ */
548
+ details(indexName: string): Promise<GetVectorIndexResponse>;
549
+ /**
550
+ * Deletes a vector index
551
+ * @param indexName - Name of the index to delete
552
+ * @returns Promise indicating deletion success
553
+ */
554
+ delete(indexName: string): Promise<{
555
+ success: boolean;
556
+ }>;
557
+ /**
558
+ * Retrieves a list of all available indexes
559
+ * @returns Promise containing array of index names
560
+ */
561
+ getIndexes(): Promise<{
562
+ indexes: string[];
563
+ }>;
564
+ /**
565
+ * Creates a new vector index
566
+ * @param params - Parameters for index creation including dimension and metric
567
+ * @returns Promise indicating creation success
568
+ */
569
+ createIndex(params: CreateIndexParams): Promise<{
570
+ success: boolean;
571
+ }>;
572
+ /**
573
+ * Upserts vectors into an index
574
+ * @param params - Parameters containing vectors, metadata, and optional IDs
575
+ * @returns Promise containing array of vector IDs
576
+ */
577
+ upsert(params: UpsertVectorParams): Promise<string[]>;
578
+ /**
579
+ * Queries vectors in an index
580
+ * @param params - Query parameters including query vector and search options
581
+ * @returns Promise containing query results
582
+ */
583
+ query(params: QueryVectorParams): Promise<QueryVectorResponse>;
584
+ }
585
+
586
+ declare class LegacyWorkflow extends BaseResource {
587
+ private workflowId;
588
+ constructor(options: ClientOptions, workflowId: string);
589
+ /**
590
+ * Retrieves details about the legacy workflow
591
+ * @returns Promise containing legacy workflow details including steps and graphs
592
+ */
593
+ details(): Promise<GetLegacyWorkflowResponse>;
594
+ /**
595
+ * Retrieves all runs for a legacy workflow
596
+ * @param params - Parameters for filtering runs
597
+ * @returns Promise containing legacy workflow runs array
598
+ */
599
+ runs(params?: GetWorkflowRunsParams): Promise<GetLegacyWorkflowRunsResponse>;
600
+ /**
601
+ * Creates a new legacy workflow run
602
+ * @returns Promise containing the generated run ID
603
+ */
604
+ createRun(params?: {
605
+ runId?: string;
606
+ }): Promise<{
607
+ runId: string;
608
+ }>;
609
+ /**
610
+ * Starts a legacy workflow run synchronously without waiting for the workflow to complete
611
+ * @param params - Object containing the runId and triggerData
612
+ * @returns Promise containing success message
613
+ */
614
+ start(params: {
615
+ runId: string;
616
+ triggerData: Record<string, any>;
617
+ }): Promise<{
618
+ message: string;
619
+ }>;
620
+ /**
621
+ * Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
622
+ * @param stepId - ID of the step to resume
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
626
+ */
627
+ resume({ stepId, runId, context, }: {
628
+ stepId: string;
629
+ runId: string;
630
+ context: Record<string, any>;
631
+ }): Promise<{
632
+ message: string;
633
+ }>;
634
+ /**
635
+ * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
636
+ * @param params - Object containing the optional runId and triggerData
637
+ * @returns Promise containing the workflow execution results
638
+ */
639
+ startAsync(params: {
640
+ runId?: string;
641
+ triggerData: Record<string, any>;
642
+ }): Promise<LegacyWorkflowRunResult>;
643
+ /**
644
+ * Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
645
+ * @param params - Object containing the runId, stepId, and context
646
+ * @returns Promise containing the workflow resume results
647
+ */
648
+ resumeAsync(params: {
649
+ runId: string;
650
+ stepId: string;
651
+ context: Record<string, any>;
652
+ }): Promise<LegacyWorkflowRunResult>;
653
+ /**
654
+ * Creates an async generator that processes a readable stream and yields records
655
+ * separated by the Record Separator character (\x1E)
656
+ *
657
+ * @param stream - The readable stream to process
658
+ * @returns An async generator that yields parsed records
659
+ */
660
+ private streamProcessor;
661
+ /**
662
+ * Watches legacy workflow transitions in real-time
663
+ * @param runId - Optional run ID to filter the watch stream
664
+ * @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
665
+ */
666
+ watch({ runId }: {
667
+ runId?: string;
668
+ }, onRecord: (record: LegacyWorkflowRunResult) => void): Promise<void>;
669
+ }
670
+
671
+ declare class Tool extends BaseResource {
672
+ private toolId;
673
+ constructor(options: ClientOptions, toolId: string);
674
+ /**
675
+ * Retrieves details about the tool
676
+ * @returns Promise containing tool details including description and schemas
677
+ */
678
+ details(): Promise<GetToolResponse>;
679
+ /**
680
+ * Executes the tool with the provided parameters
681
+ * @param params - Parameters required for tool execution
682
+ * @returns Promise containing the tool execution results
683
+ */
684
+ execute(params: {
685
+ data: any;
686
+ runId?: string;
687
+ runtimeContext?: RuntimeContext | Record<string, any>;
688
+ }): Promise<any>;
689
+ }
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
+
965
+ declare class MastraClient extends BaseResource {
966
+ constructor(options: ClientOptions);
967
+ /**
968
+ * Retrieves all available agents
969
+ * @returns Promise containing map of agent IDs to agent details
970
+ */
971
+ getAgents(): Promise<Record<string, GetAgentResponse>>;
972
+ getAGUI({ resourceId }: {
973
+ resourceId: string;
974
+ }): Promise<Record<string, AbstractAgent>>;
975
+ /**
976
+ * Gets an agent instance by ID
977
+ * @param agentId - ID of the agent to retrieve
978
+ * @returns Agent instance
979
+ */
980
+ getAgent(agentId: string): Agent;
981
+ /**
982
+ * Retrieves memory threads for a resource
983
+ * @param params - Parameters containing the resource ID
984
+ * @returns Promise containing array of memory threads
985
+ */
986
+ getMemoryThreads(params: GetMemoryThreadParams): Promise<GetMemoryThreadResponse>;
987
+ /**
988
+ * Creates a new memory thread
989
+ * @param params - Parameters for creating the memory thread
990
+ * @returns Promise containing the created memory thread
991
+ */
992
+ createMemoryThread(params: CreateMemoryThreadParams): Promise<CreateMemoryThreadResponse>;
993
+ /**
994
+ * Gets a memory thread instance by ID
995
+ * @param threadId - ID of the memory thread to retrieve
996
+ * @returns MemoryThread instance
997
+ */
998
+ getMemoryThread(threadId: string, agentId: string): MemoryThread;
999
+ /**
1000
+ * Saves messages to memory
1001
+ * @param params - Parameters containing messages to save
1002
+ * @returns Promise containing the saved messages
1003
+ */
1004
+ saveMessageToMemory(params: SaveMessageToMemoryParams): Promise<SaveMessageToMemoryResponse>;
1005
+ /**
1006
+ * Gets the status of the memory system
1007
+ * @returns Promise containing memory system status
1008
+ */
1009
+ getMemoryStatus(agentId: string): Promise<{
1010
+ result: boolean;
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
+ }>;
1043
+ /**
1044
+ * Retrieves all available tools
1045
+ * @returns Promise containing map of tool IDs to tool details
1046
+ */
1047
+ getTools(): Promise<Record<string, GetToolResponse>>;
1048
+ /**
1049
+ * Gets a tool instance by ID
1050
+ * @param toolId - ID of the tool to retrieve
1051
+ * @returns Tool instance
1052
+ */
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;
1065
+ /**
1066
+ * Retrieves all available workflows
1067
+ * @returns Promise containing map of workflow IDs to workflow details
1068
+ */
1069
+ getWorkflows(): Promise<Record<string, GetWorkflowResponse>>;
1070
+ /**
1071
+ * Gets a workflow instance by ID
1072
+ * @param workflowId - ID of the workflow to retrieve
1073
+ * @returns Workflow instance
1074
+ */
1075
+ getWorkflow(workflowId: string): Workflow;
1076
+ /**
1077
+ * Gets a vector instance by name
1078
+ * @param vectorName - Name of the vector to retrieve
1079
+ * @returns Vector instance
1080
+ */
1081
+ getVector(vectorName: string): Vector;
1082
+ /**
1083
+ * Retrieves logs
1084
+ * @param params - Parameters for filtering logs
1085
+ * @returns Promise containing array of log messages
1086
+ */
1087
+ getLogs(params: GetLogsParams): Promise<GetLogsResponse>;
1088
+ /**
1089
+ * Gets logs for a specific run
1090
+ * @param params - Parameters containing run ID to retrieve
1091
+ * @returns Promise containing array of log messages
1092
+ */
1093
+ getLogForRun(params: GetLogParams): Promise<GetLogsResponse>;
1094
+ /**
1095
+ * List of all log transports
1096
+ * @returns Promise containing list of log transports
1097
+ */
1098
+ getLogTransports(): Promise<{
1099
+ transports: string[];
1100
+ }>;
1101
+ /**
1102
+ * List of all traces (paged)
1103
+ * @param params - Parameters for filtering traces
1104
+ * @returns Promise containing telemetry data
1105
+ */
1106
+ getTelemetry(params?: GetTelemetryParams): Promise<GetTelemetryResponse>;
1107
+ /**
1108
+ * Retrieves all available networks
1109
+ * @returns Promise containing map of network IDs to network details
1110
+ */
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>>;
1117
+ /**
1118
+ * Gets a network instance by ID
1119
+ * @param networkId - ID of the network to retrieve
1120
+ * @returns Network instance
1121
+ */
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>;
1192
+ }
1193
+
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 };