@mastra/client-js 0.10.12 → 0.10.13

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,1166 @@
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
+ }
337
+ interface LoopStreamVNextNetworkParams {
338
+ message: string;
339
+ threadId?: string;
340
+ resourceId?: string;
341
+ maxIterations?: number;
342
+ }
343
+ interface LoopVNextNetworkResponse {
344
+ status: 'success';
345
+ result: {
346
+ text: string;
347
+ };
348
+ steps: WorkflowResult<any, any>['steps'];
349
+ }
350
+ interface McpServerListResponse {
351
+ servers: ServerInfo[];
352
+ next: string | null;
353
+ total_count: number;
354
+ }
355
+ interface McpToolInfo {
356
+ id: string;
357
+ name: string;
358
+ description?: string;
359
+ inputSchema: string;
360
+ toolType?: MCPToolType;
361
+ }
362
+ interface McpServerToolListResponse {
363
+ tools: McpToolInfo[];
364
+ }
365
+
366
+ declare class BaseResource {
367
+ readonly options: ClientOptions;
368
+ constructor(options: ClientOptions);
369
+ /**
370
+ * Makes an HTTP request to the API with retries and exponential backoff
371
+ * @param path - The API endpoint path
372
+ * @param options - Optional request configuration
373
+ * @returns Promise containing the response data
374
+ */
375
+ request<T>(path: string, options?: RequestOptions): Promise<T>;
376
+ }
377
+
378
+ declare class AgentVoice extends BaseResource {
379
+ private agentId;
380
+ constructor(options: ClientOptions, agentId: string);
381
+ /**
382
+ * Convert text to speech using the agent's voice provider
383
+ * @param text - Text to convert to speech
384
+ * @param options - Optional provider-specific options for speech generation
385
+ * @returns Promise containing the audio data
386
+ */
387
+ speak(text: string, options?: {
388
+ speaker?: string;
389
+ [key: string]: any;
390
+ }): Promise<Response>;
391
+ /**
392
+ * Convert speech to text using the agent's voice provider
393
+ * @param audio - Audio data to transcribe
394
+ * @param options - Optional provider-specific options
395
+ * @returns Promise containing the transcribed text
396
+ */
397
+ listen(audio: Blob, options?: Record<string, any>): Promise<{
398
+ text: string;
399
+ }>;
400
+ /**
401
+ * Get available speakers for the agent's voice provider
402
+ * @returns Promise containing list of available speakers
403
+ */
404
+ getSpeakers(): Promise<Array<{
405
+ voiceId: string;
406
+ [key: string]: any;
407
+ }>>;
408
+ /**
409
+ * Get the listener configuration for the agent's voice provider
410
+ * @returns Promise containing a check if the agent has listening capabilities
411
+ */
412
+ getListener(): Promise<{
413
+ enabled: boolean;
414
+ }>;
415
+ }
416
+ declare class Agent extends BaseResource {
417
+ private agentId;
418
+ readonly voice: AgentVoice;
419
+ constructor(options: ClientOptions, agentId: string);
420
+ /**
421
+ * Retrieves details about the agent
422
+ * @returns Promise containing agent details including model and instructions
423
+ */
424
+ details(): Promise<GetAgentResponse>;
425
+ /**
426
+ * Generates a response from the agent
427
+ * @param params - Generation parameters including prompt
428
+ * @returns Promise containing the generated response
429
+ */
430
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
431
+ output?: never;
432
+ experimental_output?: never;
433
+ }): Promise<GenerateReturn<T>>;
434
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
435
+ output: T;
436
+ experimental_output?: never;
437
+ }): Promise<GenerateReturn<T>>;
438
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
439
+ output?: never;
440
+ experimental_output: T;
441
+ }): Promise<GenerateReturn<T>>;
442
+ private processChatResponse;
443
+ /**
444
+ * Processes the stream response and handles tool calls
445
+ */
446
+ private processStreamResponse;
447
+ /**
448
+ * Streams a response from the agent
449
+ * @param params - Stream parameters including prompt
450
+ * @returns Promise containing the enhanced Response object with processDataStream and processTextStream methods
451
+ */
452
+ stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
453
+ processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
454
+ processTextStream: (options?: Omit<Parameters<typeof processTextStream>[0], 'stream'>) => Promise<void>;
455
+ }>;
456
+ /**
457
+ * Gets details about a specific tool available to the agent
458
+ * @param toolId - ID of the tool to retrieve
459
+ * @returns Promise containing tool details
460
+ */
461
+ getTool(toolId: string): Promise<GetToolResponse>;
462
+ /**
463
+ * Executes a tool for the agent
464
+ * @param toolId - ID of the tool to execute
465
+ * @param params - Parameters required for tool execution
466
+ * @returns Promise containing the tool execution results
467
+ */
468
+ executeTool(toolId: string, params: {
469
+ data: any;
470
+ runtimeContext?: RuntimeContext;
471
+ }): Promise<any>;
472
+ /**
473
+ * Retrieves evaluation results for the agent
474
+ * @returns Promise containing agent evaluations
475
+ */
476
+ evals(): Promise<GetEvalsByAgentIdResponse>;
477
+ /**
478
+ * Retrieves live evaluation results for the agent
479
+ * @returns Promise containing live agent evaluations
480
+ */
481
+ liveEvals(): Promise<GetEvalsByAgentIdResponse>;
482
+ }
483
+
484
+ declare class Network extends BaseResource {
485
+ private networkId;
486
+ constructor(options: ClientOptions, networkId: string);
487
+ /**
488
+ * Retrieves details about the network
489
+ * @returns Promise containing network details
490
+ */
491
+ details(): Promise<GetNetworkResponse>;
492
+ /**
493
+ * Generates a response from the agent
494
+ * @param params - Generation parameters including prompt
495
+ * @returns Promise containing the generated response
496
+ */
497
+ generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>): Promise<GenerateReturn<T>>;
498
+ /**
499
+ * Streams a response from the agent
500
+ * @param params - Stream parameters including prompt
501
+ * @returns Promise containing the enhanced Response object with processDataStream method
502
+ */
503
+ stream<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: StreamParams<T>): Promise<Response & {
504
+ processDataStream: (options?: Omit<Parameters<typeof processDataStream>[0], 'stream'>) => Promise<void>;
505
+ }>;
506
+ }
507
+
508
+ declare class MemoryThread extends BaseResource {
509
+ private threadId;
510
+ private agentId;
511
+ constructor(options: ClientOptions, threadId: string, agentId: string);
512
+ /**
513
+ * Retrieves the memory thread details
514
+ * @returns Promise containing thread details including title and metadata
515
+ */
516
+ get(): Promise<StorageThreadType>;
517
+ /**
518
+ * Updates the memory thread properties
519
+ * @param params - Update parameters including title and metadata
520
+ * @returns Promise containing updated thread details
521
+ */
522
+ update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
523
+ /**
524
+ * Deletes the memory thread
525
+ * @returns Promise containing deletion result
526
+ */
527
+ delete(): Promise<{
528
+ result: string;
529
+ }>;
530
+ /**
531
+ * Retrieves messages associated with the thread
532
+ * @param params - Optional parameters including limit for number of messages to retrieve
533
+ * @returns Promise containing thread messages and UI messages
534
+ */
535
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
536
+ }
537
+
538
+ declare class Vector extends BaseResource {
539
+ private vectorName;
540
+ constructor(options: ClientOptions, vectorName: string);
541
+ /**
542
+ * Retrieves details about a specific vector index
543
+ * @param indexName - Name of the index to get details for
544
+ * @returns Promise containing vector index details
545
+ */
546
+ details(indexName: string): Promise<GetVectorIndexResponse>;
547
+ /**
548
+ * Deletes a vector index
549
+ * @param indexName - Name of the index to delete
550
+ * @returns Promise indicating deletion success
551
+ */
552
+ delete(indexName: string): Promise<{
553
+ success: boolean;
554
+ }>;
555
+ /**
556
+ * Retrieves a list of all available indexes
557
+ * @returns Promise containing array of index names
558
+ */
559
+ getIndexes(): Promise<{
560
+ indexes: string[];
561
+ }>;
562
+ /**
563
+ * Creates a new vector index
564
+ * @param params - Parameters for index creation including dimension and metric
565
+ * @returns Promise indicating creation success
566
+ */
567
+ createIndex(params: CreateIndexParams): Promise<{
568
+ success: boolean;
569
+ }>;
570
+ /**
571
+ * Upserts vectors into an index
572
+ * @param params - Parameters containing vectors, metadata, and optional IDs
573
+ * @returns Promise containing array of vector IDs
574
+ */
575
+ upsert(params: UpsertVectorParams): Promise<string[]>;
576
+ /**
577
+ * Queries vectors in an index
578
+ * @param params - Query parameters including query vector and search options
579
+ * @returns Promise containing query results
580
+ */
581
+ query(params: QueryVectorParams): Promise<QueryVectorResponse>;
582
+ }
583
+
584
+ declare class LegacyWorkflow extends BaseResource {
585
+ private workflowId;
586
+ constructor(options: ClientOptions, workflowId: string);
587
+ /**
588
+ * Retrieves details about the legacy workflow
589
+ * @returns Promise containing legacy workflow details including steps and graphs
590
+ */
591
+ details(): Promise<GetLegacyWorkflowResponse>;
592
+ /**
593
+ * Retrieves all runs for a legacy workflow
594
+ * @param params - Parameters for filtering runs
595
+ * @returns Promise containing legacy workflow runs array
596
+ */
597
+ runs(params?: GetWorkflowRunsParams): Promise<GetLegacyWorkflowRunsResponse>;
598
+ /**
599
+ * Creates a new legacy workflow run
600
+ * @returns Promise containing the generated run ID
601
+ */
602
+ createRun(params?: {
603
+ runId?: string;
604
+ }): Promise<{
605
+ runId: string;
606
+ }>;
607
+ /**
608
+ * Starts a legacy workflow run synchronously without waiting for the workflow to complete
609
+ * @param params - Object containing the runId and triggerData
610
+ * @returns Promise containing success message
611
+ */
612
+ start(params: {
613
+ runId: string;
614
+ triggerData: Record<string, any>;
615
+ }): Promise<{
616
+ message: string;
617
+ }>;
618
+ /**
619
+ * Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
620
+ * @param stepId - ID of the step to resume
621
+ * @param runId - ID of the legacy workflow run
622
+ * @param context - Context to resume the legacy workflow with
623
+ * @returns Promise containing the legacy workflow resume results
624
+ */
625
+ resume({ stepId, runId, context, }: {
626
+ stepId: string;
627
+ runId: string;
628
+ context: Record<string, any>;
629
+ }): Promise<{
630
+ message: string;
631
+ }>;
632
+ /**
633
+ * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
634
+ * @param params - Object containing the optional runId and triggerData
635
+ * @returns Promise containing the workflow execution results
636
+ */
637
+ startAsync(params: {
638
+ runId?: string;
639
+ triggerData: Record<string, any>;
640
+ }): Promise<LegacyWorkflowRunResult>;
641
+ /**
642
+ * Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
643
+ * @param params - Object containing the runId, stepId, and context
644
+ * @returns Promise containing the workflow resume results
645
+ */
646
+ resumeAsync(params: {
647
+ runId: string;
648
+ stepId: string;
649
+ context: Record<string, any>;
650
+ }): Promise<LegacyWorkflowRunResult>;
651
+ /**
652
+ * Creates an async generator that processes a readable stream and yields records
653
+ * separated by the Record Separator character (\x1E)
654
+ *
655
+ * @param stream - The readable stream to process
656
+ * @returns An async generator that yields parsed records
657
+ */
658
+ private streamProcessor;
659
+ /**
660
+ * Watches legacy workflow transitions in real-time
661
+ * @param runId - Optional run ID to filter the watch stream
662
+ * @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
663
+ */
664
+ watch({ runId }: {
665
+ runId?: string;
666
+ }, onRecord: (record: LegacyWorkflowRunResult) => void): Promise<void>;
667
+ }
668
+
669
+ declare class Tool extends BaseResource {
670
+ private toolId;
671
+ constructor(options: ClientOptions, toolId: string);
672
+ /**
673
+ * Retrieves details about the tool
674
+ * @returns Promise containing tool details including description and schemas
675
+ */
676
+ details(): Promise<GetToolResponse>;
677
+ /**
678
+ * Executes the tool with the provided parameters
679
+ * @param params - Parameters required for tool execution
680
+ * @returns Promise containing the tool execution results
681
+ */
682
+ execute(params: {
683
+ data: any;
684
+ runId?: string;
685
+ runtimeContext?: RuntimeContext | Record<string, any>;
686
+ }): Promise<any>;
687
+ }
688
+
689
+ declare class Workflow extends BaseResource {
690
+ private workflowId;
691
+ constructor(options: ClientOptions, workflowId: string);
692
+ /**
693
+ * Creates an async generator that processes a readable stream and yields workflow records
694
+ * separated by the Record Separator character (\x1E)
695
+ *
696
+ * @param stream - The readable stream to process
697
+ * @returns An async generator that yields parsed records
698
+ */
699
+ private streamProcessor;
700
+ /**
701
+ * Retrieves details about the workflow
702
+ * @returns Promise containing workflow details including steps and graphs
703
+ */
704
+ details(): Promise<GetWorkflowResponse>;
705
+ /**
706
+ * Retrieves all runs for a workflow
707
+ * @param params - Parameters for filtering runs
708
+ * @returns Promise containing workflow runs array
709
+ */
710
+ runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
711
+ /**
712
+ * Retrieves a specific workflow run by its ID
713
+ * @param runId - The ID of the workflow run to retrieve
714
+ * @returns Promise containing the workflow run details
715
+ */
716
+ runById(runId: string): Promise<GetWorkflowRunByIdResponse>;
717
+ /**
718
+ * Retrieves the execution result for a specific workflow run by its ID
719
+ * @param runId - The ID of the workflow run to retrieve the execution result for
720
+ * @returns Promise containing the workflow run execution result
721
+ */
722
+ runExecutionResult(runId: string): Promise<GetWorkflowRunExecutionResultResponse>;
723
+ /**
724
+ * Cancels a specific workflow run by its ID
725
+ * @param runId - The ID of the workflow run to cancel
726
+ * @returns Promise containing a success message
727
+ */
728
+ cancelRun(runId: string): Promise<{
729
+ message: string;
730
+ }>;
731
+ /**
732
+ * Sends an event to a specific workflow run by its ID
733
+ * @param params - Object containing the runId, event and data
734
+ * @returns Promise containing a success message
735
+ */
736
+ sendRunEvent(params: {
737
+ runId: string;
738
+ event: string;
739
+ data: unknown;
740
+ }): Promise<{
741
+ message: string;
742
+ }>;
743
+ /**
744
+ * Creates a new workflow run
745
+ * @param params - Optional object containing the optional runId
746
+ * @returns Promise containing the runId of the created run
747
+ */
748
+ createRun(params?: {
749
+ runId?: string;
750
+ }): Promise<{
751
+ runId: string;
752
+ }>;
753
+ /**
754
+ * Starts a workflow run synchronously without waiting for the workflow to complete
755
+ * @param params - Object containing the runId, inputData and runtimeContext
756
+ * @returns Promise containing success message
757
+ */
758
+ start(params: {
759
+ runId: string;
760
+ inputData: Record<string, any>;
761
+ runtimeContext?: RuntimeContext | Record<string, any>;
762
+ }): Promise<{
763
+ message: string;
764
+ }>;
765
+ /**
766
+ * Resumes a suspended workflow step synchronously without waiting for the workflow to complete
767
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
768
+ * @returns Promise containing success message
769
+ */
770
+ resume({ step, runId, resumeData, ...rest }: {
771
+ step: string | string[];
772
+ runId: string;
773
+ resumeData?: Record<string, any>;
774
+ runtimeContext?: RuntimeContext | Record<string, any>;
775
+ }): Promise<{
776
+ message: string;
777
+ }>;
778
+ /**
779
+ * Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
780
+ * @param params - Object containing the optional runId, inputData and runtimeContext
781
+ * @returns Promise containing the workflow execution results
782
+ */
783
+ startAsync(params: {
784
+ runId?: string;
785
+ inputData: Record<string, any>;
786
+ runtimeContext?: RuntimeContext | Record<string, any>;
787
+ }): Promise<WorkflowRunResult>;
788
+ /**
789
+ * Starts a workflow run and returns a stream
790
+ * @param params - Object containing the optional runId, inputData and runtimeContext
791
+ * @returns Promise containing the workflow execution results
792
+ */
793
+ stream(params: {
794
+ runId?: string;
795
+ inputData: Record<string, any>;
796
+ runtimeContext?: RuntimeContext;
797
+ }): Promise<stream_web.ReadableStream<{
798
+ type: string;
799
+ payload: any;
800
+ }>>;
801
+ /**
802
+ * Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
803
+ * @param params - Object containing the runId, step, resumeData and runtimeContext
804
+ * @returns Promise containing the workflow resume results
805
+ */
806
+ resumeAsync(params: {
807
+ runId: string;
808
+ step: string | string[];
809
+ resumeData?: Record<string, any>;
810
+ runtimeContext?: RuntimeContext | Record<string, any>;
811
+ }): Promise<WorkflowRunResult>;
812
+ /**
813
+ * Watches workflow transitions in real-time
814
+ * @param runId - Optional run ID to filter the watch stream
815
+ * @returns AsyncGenerator that yields parsed records from the workflow watch stream
816
+ */
817
+ watch({ runId }: {
818
+ runId?: string;
819
+ }, onRecord: (record: WorkflowWatchResult) => void): Promise<void>;
820
+ /**
821
+ * Creates a new ReadableStream from an iterable or async iterable of objects,
822
+ * serializing each as JSON and separating them with the record separator (\x1E).
823
+ *
824
+ * @param records - An iterable or async iterable of objects to stream
825
+ * @returns A ReadableStream emitting the records as JSON strings separated by the record separator
826
+ */
827
+ static createRecordStream(records: Iterable<any> | AsyncIterable<any>): ReadableStream;
828
+ }
829
+
830
+ /**
831
+ * Class for interacting with an agent via the A2A protocol
832
+ */
833
+ declare class A2A extends BaseResource {
834
+ private agentId;
835
+ constructor(options: ClientOptions, agentId: string);
836
+ /**
837
+ * Get the agent card with metadata about the agent
838
+ * @returns Promise containing the agent card information
839
+ */
840
+ getCard(): Promise<AgentCard>;
841
+ /**
842
+ * Send a message to the agent and get a response
843
+ * @param params - Parameters for the task
844
+ * @returns Promise containing the task response
845
+ */
846
+ sendMessage(params: TaskSendParams): Promise<{
847
+ task: Task;
848
+ }>;
849
+ /**
850
+ * Get the status and result of a task
851
+ * @param params - Parameters for querying the task
852
+ * @returns Promise containing the task response
853
+ */
854
+ getTask(params: TaskQueryParams): Promise<Task>;
855
+ /**
856
+ * Cancel a running task
857
+ * @param params - Parameters identifying the task to cancel
858
+ * @returns Promise containing the task response
859
+ */
860
+ cancelTask(params: TaskIdParams): Promise<{
861
+ task: Task;
862
+ }>;
863
+ /**
864
+ * Send a message and subscribe to streaming updates (not fully implemented)
865
+ * @param params - Parameters for the task
866
+ * @returns Promise containing the task response
867
+ */
868
+ sendAndSubscribe(params: TaskSendParams): Promise<Response>;
869
+ }
870
+
871
+ /**
872
+ * Represents a specific tool available on a specific MCP server.
873
+ * Provides methods to get details and execute the tool.
874
+ */
875
+ declare class MCPTool extends BaseResource {
876
+ private serverId;
877
+ private toolId;
878
+ constructor(options: ClientOptions, serverId: string, toolId: string);
879
+ /**
880
+ * Retrieves details about this specific tool from the MCP server.
881
+ * @returns Promise containing the tool's information (name, description, schema).
882
+ */
883
+ details(): Promise<McpToolInfo>;
884
+ /**
885
+ * Executes this specific tool on the MCP server.
886
+ * @param params - Parameters for tool execution, including data/args and optional runtimeContext.
887
+ * @returns Promise containing the result of the tool execution.
888
+ */
889
+ execute(params: {
890
+ data?: any;
891
+ runtimeContext?: RuntimeContext;
892
+ }): Promise<any>;
893
+ }
894
+
895
+ declare class VNextNetwork extends BaseResource {
896
+ private networkId;
897
+ constructor(options: ClientOptions, networkId: string);
898
+ /**
899
+ * Retrieves details about the network
900
+ * @returns Promise containing vNext network details
901
+ */
902
+ details(): Promise<GetVNextNetworkResponse>;
903
+ /**
904
+ * Generates a response from the v-next network
905
+ * @param params - Generation parameters including message
906
+ * @returns Promise containing the generated response
907
+ */
908
+ generate(params: GenerateOrStreamVNextNetworkParams): Promise<GenerateVNextNetworkResponse>;
909
+ /**
910
+ * Generates a response from the v-next network using multiple primitives
911
+ * @param params - Generation parameters including message
912
+ * @returns Promise containing the generated response
913
+ */
914
+ loop(params: {
915
+ message: string;
916
+ }): Promise<LoopVNextNetworkResponse>;
917
+ private streamProcessor;
918
+ /**
919
+ * Streams a response from the v-next network
920
+ * @param params - Stream parameters including message
921
+ * @returns Promise containing the results
922
+ */
923
+ stream(params: GenerateOrStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
924
+ /**
925
+ * Streams a response from the v-next network loop
926
+ * @param params - Stream parameters including message
927
+ * @returns Promise containing the results
928
+ */
929
+ loopStream(params: LoopStreamVNextNetworkParams, onRecord: (record: WatchEvent) => void): Promise<void>;
930
+ }
931
+
932
+ declare class NetworkMemoryThread extends BaseResource {
933
+ private threadId;
934
+ private networkId;
935
+ constructor(options: ClientOptions, threadId: string, networkId: string);
936
+ /**
937
+ * Retrieves the memory thread details
938
+ * @returns Promise containing thread details including title and metadata
939
+ */
940
+ get(): Promise<StorageThreadType>;
941
+ /**
942
+ * Updates the memory thread properties
943
+ * @param params - Update parameters including title and metadata
944
+ * @returns Promise containing updated thread details
945
+ */
946
+ update(params: UpdateMemoryThreadParams): Promise<StorageThreadType>;
947
+ /**
948
+ * Deletes the memory thread
949
+ * @returns Promise containing deletion result
950
+ */
951
+ delete(): Promise<{
952
+ result: string;
953
+ }>;
954
+ /**
955
+ * Retrieves messages associated with the thread
956
+ * @param params - Optional parameters including limit for number of messages to retrieve
957
+ * @returns Promise containing thread messages and UI messages
958
+ */
959
+ getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
960
+ }
961
+
962
+ declare class MastraClient extends BaseResource {
963
+ constructor(options: ClientOptions);
964
+ /**
965
+ * Retrieves all available agents
966
+ * @returns Promise containing map of agent IDs to agent details
967
+ */
968
+ getAgents(): Promise<Record<string, GetAgentResponse>>;
969
+ getAGUI({ resourceId }: {
970
+ resourceId: string;
971
+ }): Promise<Record<string, AbstractAgent>>;
972
+ /**
973
+ * Gets an agent instance by ID
974
+ * @param agentId - ID of the agent to retrieve
975
+ * @returns Agent instance
976
+ */
977
+ getAgent(agentId: string): Agent;
978
+ /**
979
+ * Retrieves memory threads for a resource
980
+ * @param params - Parameters containing the resource ID
981
+ * @returns Promise containing array of memory threads
982
+ */
983
+ getMemoryThreads(params: GetMemoryThreadParams): Promise<GetMemoryThreadResponse>;
984
+ /**
985
+ * Creates a new memory thread
986
+ * @param params - Parameters for creating the memory thread
987
+ * @returns Promise containing the created memory thread
988
+ */
989
+ createMemoryThread(params: CreateMemoryThreadParams): Promise<CreateMemoryThreadResponse>;
990
+ /**
991
+ * Gets a memory thread instance by ID
992
+ * @param threadId - ID of the memory thread to retrieve
993
+ * @returns MemoryThread instance
994
+ */
995
+ getMemoryThread(threadId: string, agentId: string): MemoryThread;
996
+ /**
997
+ * Saves messages to memory
998
+ * @param params - Parameters containing messages to save
999
+ * @returns Promise containing the saved messages
1000
+ */
1001
+ saveMessageToMemory(params: SaveMessageToMemoryParams): Promise<SaveMessageToMemoryResponse>;
1002
+ /**
1003
+ * Gets the status of the memory system
1004
+ * @returns Promise containing memory system status
1005
+ */
1006
+ getMemoryStatus(agentId: string): Promise<{
1007
+ result: boolean;
1008
+ }>;
1009
+ /**
1010
+ * Retrieves memory threads for a resource
1011
+ * @param params - Parameters containing the resource ID
1012
+ * @returns Promise containing array of memory threads
1013
+ */
1014
+ getNetworkMemoryThreads(params: GetNetworkMemoryThreadParams): Promise<GetMemoryThreadResponse>;
1015
+ /**
1016
+ * Creates a new memory thread
1017
+ * @param params - Parameters for creating the memory thread
1018
+ * @returns Promise containing the created memory thread
1019
+ */
1020
+ createNetworkMemoryThread(params: CreateNetworkMemoryThreadParams): Promise<CreateMemoryThreadResponse>;
1021
+ /**
1022
+ * Gets a memory thread instance by ID
1023
+ * @param threadId - ID of the memory thread to retrieve
1024
+ * @returns MemoryThread instance
1025
+ */
1026
+ getNetworkMemoryThread(threadId: string, networkId: string): NetworkMemoryThread;
1027
+ /**
1028
+ * Saves messages to memory
1029
+ * @param params - Parameters containing messages to save
1030
+ * @returns Promise containing the saved messages
1031
+ */
1032
+ saveNetworkMessageToMemory(params: SaveNetworkMessageToMemoryParams): Promise<SaveMessageToMemoryResponse>;
1033
+ /**
1034
+ * Gets the status of the memory system
1035
+ * @returns Promise containing memory system status
1036
+ */
1037
+ getNetworkMemoryStatus(networkId: string): Promise<{
1038
+ result: boolean;
1039
+ }>;
1040
+ /**
1041
+ * Retrieves all available tools
1042
+ * @returns Promise containing map of tool IDs to tool details
1043
+ */
1044
+ getTools(): Promise<Record<string, GetToolResponse>>;
1045
+ /**
1046
+ * Gets a tool instance by ID
1047
+ * @param toolId - ID of the tool to retrieve
1048
+ * @returns Tool instance
1049
+ */
1050
+ getTool(toolId: string): Tool;
1051
+ /**
1052
+ * Retrieves all available legacy workflows
1053
+ * @returns Promise containing map of legacy workflow IDs to legacy workflow details
1054
+ */
1055
+ getLegacyWorkflows(): Promise<Record<string, GetLegacyWorkflowResponse>>;
1056
+ /**
1057
+ * Gets a legacy workflow instance by ID
1058
+ * @param workflowId - ID of the legacy workflow to retrieve
1059
+ * @returns Legacy Workflow instance
1060
+ */
1061
+ getLegacyWorkflow(workflowId: string): LegacyWorkflow;
1062
+ /**
1063
+ * Retrieves all available workflows
1064
+ * @returns Promise containing map of workflow IDs to workflow details
1065
+ */
1066
+ getWorkflows(): Promise<Record<string, GetWorkflowResponse>>;
1067
+ /**
1068
+ * Gets a workflow instance by ID
1069
+ * @param workflowId - ID of the workflow to retrieve
1070
+ * @returns Workflow instance
1071
+ */
1072
+ getWorkflow(workflowId: string): Workflow;
1073
+ /**
1074
+ * Gets a vector instance by name
1075
+ * @param vectorName - Name of the vector to retrieve
1076
+ * @returns Vector instance
1077
+ */
1078
+ getVector(vectorName: string): Vector;
1079
+ /**
1080
+ * Retrieves logs
1081
+ * @param params - Parameters for filtering logs
1082
+ * @returns Promise containing array of log messages
1083
+ */
1084
+ getLogs(params: GetLogsParams): Promise<GetLogsResponse>;
1085
+ /**
1086
+ * Gets logs for a specific run
1087
+ * @param params - Parameters containing run ID to retrieve
1088
+ * @returns Promise containing array of log messages
1089
+ */
1090
+ getLogForRun(params: GetLogParams): Promise<GetLogsResponse>;
1091
+ /**
1092
+ * List of all log transports
1093
+ * @returns Promise containing list of log transports
1094
+ */
1095
+ getLogTransports(): Promise<{
1096
+ transports: string[];
1097
+ }>;
1098
+ /**
1099
+ * List of all traces (paged)
1100
+ * @param params - Parameters for filtering traces
1101
+ * @returns Promise containing telemetry data
1102
+ */
1103
+ getTelemetry(params?: GetTelemetryParams): Promise<GetTelemetryResponse>;
1104
+ /**
1105
+ * Retrieves all available networks
1106
+ * @returns Promise containing map of network IDs to network details
1107
+ */
1108
+ getNetworks(): Promise<Array<GetNetworkResponse>>;
1109
+ /**
1110
+ * Retrieves all available vNext networks
1111
+ * @returns Promise containing map of vNext network IDs to vNext network details
1112
+ */
1113
+ getVNextNetworks(): Promise<Array<GetVNextNetworkResponse>>;
1114
+ /**
1115
+ * Gets a network instance by ID
1116
+ * @param networkId - ID of the network to retrieve
1117
+ * @returns Network instance
1118
+ */
1119
+ getNetwork(networkId: string): Network;
1120
+ /**
1121
+ * Gets a vNext network instance by ID
1122
+ * @param networkId - ID of the vNext network to retrieve
1123
+ * @returns vNext Network instance
1124
+ */
1125
+ getVNextNetwork(networkId: string): VNextNetwork;
1126
+ /**
1127
+ * Retrieves a list of available MCP servers.
1128
+ * @param params - Optional parameters for pagination (limit, offset).
1129
+ * @returns Promise containing the list of MCP servers and pagination info.
1130
+ */
1131
+ getMcpServers(params?: {
1132
+ limit?: number;
1133
+ offset?: number;
1134
+ }): Promise<McpServerListResponse>;
1135
+ /**
1136
+ * Retrieves detailed information for a specific MCP server.
1137
+ * @param serverId - The ID of the MCP server to retrieve.
1138
+ * @param params - Optional parameters, e.g., specific version.
1139
+ * @returns Promise containing the detailed MCP server information.
1140
+ */
1141
+ getMcpServerDetails(serverId: string, params?: {
1142
+ version?: string;
1143
+ }): Promise<ServerDetailInfo>;
1144
+ /**
1145
+ * Retrieves a list of tools for a specific MCP server.
1146
+ * @param serverId - The ID of the MCP server.
1147
+ * @returns Promise containing the list of tools.
1148
+ */
1149
+ getMcpServerTools(serverId: string): Promise<McpServerToolListResponse>;
1150
+ /**
1151
+ * Gets an MCPTool resource instance for a specific tool on an MCP server.
1152
+ * This instance can then be used to fetch details or execute the tool.
1153
+ * @param serverId - The ID of the MCP server.
1154
+ * @param toolId - The ID of the tool.
1155
+ * @returns MCPTool instance.
1156
+ */
1157
+ getMcpServerTool(serverId: string, toolId: string): MCPTool;
1158
+ /**
1159
+ * Gets an A2A client for interacting with an agent via the A2A protocol
1160
+ * @param agentId - ID of the agent to interact with
1161
+ * @returns A2A client instance
1162
+ */
1163
+ getA2A(agentId: string): A2A;
1164
+ }
1165
+
1166
+ 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 };