@mastra/client-js 0.0.0-message-ordering-20250415215612 → 0.0.0-pass-headers-for-create-mastra-client-20250529190531
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +19 -0
- package/CHANGELOG.md +573 -3
- package/dist/index.cjs +763 -48
- package/dist/index.d.cts +351 -36
- package/dist/index.d.ts +351 -36
- package/dist/index.js +759 -48
- package/package.json +12 -6
- package/src/adapters/agui.test.ts +180 -0
- package/src/adapters/agui.ts +239 -0
- package/src/client.ts +122 -11
- package/src/example.ts +29 -30
- package/src/index.test.ts +125 -5
- package/src/resources/a2a.ts +88 -0
- package/src/resources/agent.ts +28 -36
- package/src/resources/base.ts +2 -2
- package/src/resources/index.ts +4 -1
- package/src/resources/legacy-workflow.ts +242 -0
- package/src/resources/mcp-tool.ts +48 -0
- package/src/resources/memory-thread.ts +8 -5
- package/src/resources/network.ts +6 -12
- package/src/resources/tool.ts +16 -3
- package/src/resources/workflow.ts +234 -96
- package/src/types.ts +105 -15
- package/src/utils/index.ts +11 -0
- package/src/utils/zod-to-json-schema.ts +10 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import {
|
|
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, MessageType, LegacyWorkflowRuns, WorkflowRuns, QueryResult, GenerateReturn } from '@mastra/core';
|
|
2
5
|
import { JSONSchema7 } from 'json-schema';
|
|
3
6
|
import { ZodSchema } from 'zod';
|
|
4
|
-
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
5
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';
|
|
6
14
|
|
|
7
15
|
interface ClientOptions {
|
|
8
16
|
/** Base URL for API requests */
|
|
@@ -23,21 +31,38 @@ interface RequestOptions {
|
|
|
23
31
|
stream?: boolean;
|
|
24
32
|
signal?: AbortSignal;
|
|
25
33
|
}
|
|
34
|
+
type WithoutMethods<T> = {
|
|
35
|
+
[K in keyof T as T[K] extends (...args: any[]) => any ? never : T[K] extends {
|
|
36
|
+
(): any;
|
|
37
|
+
} ? never : T[K] extends undefined | ((...args: any[]) => any) ? never : K]: T[K];
|
|
38
|
+
};
|
|
26
39
|
interface GetAgentResponse {
|
|
27
40
|
name: string;
|
|
28
41
|
instructions: string;
|
|
29
42
|
tools: Record<string, GetToolResponse>;
|
|
43
|
+
workflows: Record<string, GetWorkflowResponse>;
|
|
30
44
|
provider: string;
|
|
31
45
|
modelId: string;
|
|
46
|
+
defaultGenerateOptions: WithoutMethods<AgentGenerateOptions>;
|
|
47
|
+
defaultStreamOptions: WithoutMethods<AgentStreamOptions>;
|
|
32
48
|
}
|
|
33
49
|
type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
34
50
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
35
|
-
|
|
51
|
+
output?: T;
|
|
52
|
+
experimental_output?: T;
|
|
53
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
54
|
+
} & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
|
|
36
55
|
type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
37
56
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
38
|
-
|
|
57
|
+
output?: T;
|
|
58
|
+
experimental_output?: T;
|
|
59
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
60
|
+
} & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
|
|
39
61
|
interface GetEvalsByAgentIdResponse extends GetAgentResponse {
|
|
40
62
|
evals: any[];
|
|
63
|
+
instructions: string;
|
|
64
|
+
name: string;
|
|
65
|
+
id: string;
|
|
41
66
|
}
|
|
42
67
|
interface GetToolResponse {
|
|
43
68
|
id: string;
|
|
@@ -45,7 +70,7 @@ interface GetToolResponse {
|
|
|
45
70
|
inputSchema: string;
|
|
46
71
|
outputSchema: string;
|
|
47
72
|
}
|
|
48
|
-
interface
|
|
73
|
+
interface GetLegacyWorkflowResponse {
|
|
49
74
|
name: string;
|
|
50
75
|
triggerSchema: string;
|
|
51
76
|
steps: Record<string, StepAction<any, any, any, any>>;
|
|
@@ -53,16 +78,46 @@ interface GetWorkflowResponse {
|
|
|
53
78
|
stepSubscriberGraph: Record<string, StepGraph>;
|
|
54
79
|
workflowId?: string;
|
|
55
80
|
}
|
|
56
|
-
|
|
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 = {
|
|
57
91
|
activePaths: Record<string, {
|
|
58
92
|
status: string;
|
|
59
93
|
suspendPayload?: any;
|
|
60
94
|
stepPath: string[];
|
|
61
95
|
}>;
|
|
62
|
-
results:
|
|
96
|
+
results: LegacyWorkflowRunResult$1<any, any, any>['results'];
|
|
63
97
|
timestamp: number;
|
|
64
98
|
runId: string;
|
|
65
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>;
|
|
66
121
|
interface UpsertVectorParams {
|
|
67
122
|
indexName: string;
|
|
68
123
|
vectors: number[][];
|
|
@@ -95,10 +150,10 @@ interface SaveMessageToMemoryParams {
|
|
|
95
150
|
}
|
|
96
151
|
type SaveMessageToMemoryResponse = MessageType[];
|
|
97
152
|
interface CreateMemoryThreadParams {
|
|
98
|
-
title
|
|
99
|
-
metadata
|
|
100
|
-
|
|
101
|
-
threadId
|
|
153
|
+
title?: string;
|
|
154
|
+
metadata?: Record<string, any>;
|
|
155
|
+
resourceId: string;
|
|
156
|
+
threadId?: string;
|
|
102
157
|
agentId: string;
|
|
103
158
|
}
|
|
104
159
|
type CreateMemoryThreadResponse = StorageThreadType;
|
|
@@ -110,7 +165,13 @@ type GetMemoryThreadResponse = StorageThreadType[];
|
|
|
110
165
|
interface UpdateMemoryThreadParams {
|
|
111
166
|
title: string;
|
|
112
167
|
metadata: Record<string, any>;
|
|
113
|
-
|
|
168
|
+
resourceId: string;
|
|
169
|
+
}
|
|
170
|
+
interface GetMemoryThreadMessagesParams {
|
|
171
|
+
/**
|
|
172
|
+
* Limit the number of messages to retrieve (default: 40)
|
|
173
|
+
*/
|
|
174
|
+
limit?: number;
|
|
114
175
|
}
|
|
115
176
|
interface GetMemoryThreadMessagesResponse {
|
|
116
177
|
messages: CoreMessage[];
|
|
@@ -171,6 +232,8 @@ interface GetTelemetryParams {
|
|
|
171
232
|
page?: number;
|
|
172
233
|
perPage?: number;
|
|
173
234
|
attribute?: Record<string, string>;
|
|
235
|
+
fromDate?: Date;
|
|
236
|
+
toDate?: Date;
|
|
174
237
|
}
|
|
175
238
|
interface GetNetworkResponse {
|
|
176
239
|
name: string;
|
|
@@ -186,6 +249,21 @@ interface GetNetworkResponse {
|
|
|
186
249
|
};
|
|
187
250
|
state?: Record<string, any>;
|
|
188
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
|
+
}
|
|
189
267
|
|
|
190
268
|
declare class BaseResource {
|
|
191
269
|
readonly options: ClientOptions;
|
|
@@ -218,7 +296,9 @@ declare class AgentVoice extends BaseResource {
|
|
|
218
296
|
* @param options - Optional provider-specific options
|
|
219
297
|
* @returns Promise containing the transcribed text
|
|
220
298
|
*/
|
|
221
|
-
listen(audio: Blob, options?: Record<string, any>): Promise<
|
|
299
|
+
listen(audio: Blob, options?: Record<string, any>): Promise<{
|
|
300
|
+
text: string;
|
|
301
|
+
}>;
|
|
222
302
|
/**
|
|
223
303
|
* Get available speakers for the agent's voice provider
|
|
224
304
|
* @returns Promise containing list of available speakers
|
|
@@ -257,6 +337,16 @@ declare class Agent extends BaseResource {
|
|
|
257
337
|
* @returns Promise containing tool details
|
|
258
338
|
*/
|
|
259
339
|
getTool(toolId: string): Promise<GetToolResponse>;
|
|
340
|
+
/**
|
|
341
|
+
* Executes a tool for the agent
|
|
342
|
+
* @param toolId - ID of the tool to execute
|
|
343
|
+
* @param params - Parameters required for tool execution
|
|
344
|
+
* @returns Promise containing the tool execution results
|
|
345
|
+
*/
|
|
346
|
+
executeTool(toolId: string, params: {
|
|
347
|
+
data: any;
|
|
348
|
+
runtimeContext?: RuntimeContext;
|
|
349
|
+
}): Promise<any>;
|
|
260
350
|
/**
|
|
261
351
|
* Retrieves evaluation results for the agent
|
|
262
352
|
* @returns Promise containing agent evaluations
|
|
@@ -317,9 +407,10 @@ declare class MemoryThread extends BaseResource {
|
|
|
317
407
|
}>;
|
|
318
408
|
/**
|
|
319
409
|
* Retrieves messages associated with the thread
|
|
410
|
+
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
320
411
|
* @returns Promise containing thread messages and UI messages
|
|
321
412
|
*/
|
|
322
|
-
getMessages(): Promise<GetMemoryThreadMessagesResponse>;
|
|
413
|
+
getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
|
|
323
414
|
}
|
|
324
415
|
|
|
325
416
|
declare class Vector extends BaseResource {
|
|
@@ -368,23 +459,22 @@ declare class Vector extends BaseResource {
|
|
|
368
459
|
query(params: QueryVectorParams): Promise<QueryVectorResponse>;
|
|
369
460
|
}
|
|
370
461
|
|
|
371
|
-
declare class
|
|
462
|
+
declare class LegacyWorkflow extends BaseResource {
|
|
372
463
|
private workflowId;
|
|
373
464
|
constructor(options: ClientOptions, workflowId: string);
|
|
374
465
|
/**
|
|
375
|
-
* Retrieves details about the workflow
|
|
376
|
-
* @returns Promise containing workflow details including steps and graphs
|
|
466
|
+
* Retrieves details about the legacy workflow
|
|
467
|
+
* @returns Promise containing legacy workflow details including steps and graphs
|
|
377
468
|
*/
|
|
378
|
-
details(): Promise<
|
|
469
|
+
details(): Promise<GetLegacyWorkflowResponse>;
|
|
379
470
|
/**
|
|
380
|
-
*
|
|
381
|
-
*
|
|
382
|
-
* @
|
|
383
|
-
* @returns Promise containing the workflow execution results
|
|
471
|
+
* Retrieves all runs for a legacy workflow
|
|
472
|
+
* @param params - Parameters for filtering runs
|
|
473
|
+
* @returns Promise containing legacy workflow runs array
|
|
384
474
|
*/
|
|
385
|
-
|
|
475
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetLegacyWorkflowRunsResponse>;
|
|
386
476
|
/**
|
|
387
|
-
* Creates a new workflow run
|
|
477
|
+
* Creates a new legacy workflow run
|
|
388
478
|
* @returns Promise containing the generated run ID
|
|
389
479
|
*/
|
|
390
480
|
createRun(params?: {
|
|
@@ -393,7 +483,7 @@ declare class Workflow extends BaseResource {
|
|
|
393
483
|
runId: string;
|
|
394
484
|
}>;
|
|
395
485
|
/**
|
|
396
|
-
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
486
|
+
* Starts a legacy workflow run synchronously without waiting for the workflow to complete
|
|
397
487
|
* @param params - Object containing the runId and triggerData
|
|
398
488
|
* @returns Promise containing success message
|
|
399
489
|
*/
|
|
@@ -404,11 +494,11 @@ declare class Workflow extends BaseResource {
|
|
|
404
494
|
message: string;
|
|
405
495
|
}>;
|
|
406
496
|
/**
|
|
407
|
-
* Resumes a suspended workflow step synchronously without waiting for the workflow to complete
|
|
497
|
+
* Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
|
|
408
498
|
* @param stepId - ID of the step to resume
|
|
409
|
-
* @param runId - ID of the workflow run
|
|
410
|
-
* @param context - Context to resume the workflow with
|
|
411
|
-
* @returns Promise containing the workflow resume results
|
|
499
|
+
* @param runId - ID of the legacy workflow run
|
|
500
|
+
* @param context - Context to resume the legacy workflow with
|
|
501
|
+
* @returns Promise containing the legacy workflow resume results
|
|
412
502
|
*/
|
|
413
503
|
resume({ stepId, runId, context, }: {
|
|
414
504
|
stepId: string;
|
|
@@ -425,9 +515,9 @@ declare class Workflow extends BaseResource {
|
|
|
425
515
|
startAsync(params: {
|
|
426
516
|
runId?: string;
|
|
427
517
|
triggerData: Record<string, any>;
|
|
428
|
-
}): Promise<
|
|
518
|
+
}): Promise<LegacyWorkflowRunResult>;
|
|
429
519
|
/**
|
|
430
|
-
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
520
|
+
* Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
431
521
|
* @param params - Object containing the runId, stepId, and context
|
|
432
522
|
* @returns Promise containing the workflow resume results
|
|
433
523
|
*/
|
|
@@ -435,7 +525,7 @@ declare class Workflow extends BaseResource {
|
|
|
435
525
|
runId: string;
|
|
436
526
|
stepId: string;
|
|
437
527
|
context: Record<string, any>;
|
|
438
|
-
}): Promise<
|
|
528
|
+
}): Promise<LegacyWorkflowRunResult>;
|
|
439
529
|
/**
|
|
440
530
|
* Creates an async generator that processes a readable stream and yields records
|
|
441
531
|
* separated by the Record Separator character (\x1E)
|
|
@@ -445,13 +535,13 @@ declare class Workflow extends BaseResource {
|
|
|
445
535
|
*/
|
|
446
536
|
private streamProcessor;
|
|
447
537
|
/**
|
|
448
|
-
* Watches workflow transitions in real-time
|
|
538
|
+
* Watches legacy workflow transitions in real-time
|
|
449
539
|
* @param runId - Optional run ID to filter the watch stream
|
|
450
|
-
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
540
|
+
* @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
|
|
451
541
|
*/
|
|
452
542
|
watch({ runId }: {
|
|
453
543
|
runId?: string;
|
|
454
|
-
}, onRecord: (record:
|
|
544
|
+
}, onRecord: (record: LegacyWorkflowRunResult) => void): Promise<void>;
|
|
455
545
|
}
|
|
456
546
|
|
|
457
547
|
declare class Tool extends BaseResource {
|
|
@@ -469,6 +559,179 @@ declare class Tool extends BaseResource {
|
|
|
469
559
|
*/
|
|
470
560
|
execute(params: {
|
|
471
561
|
data: any;
|
|
562
|
+
runId?: string;
|
|
563
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
564
|
+
}): Promise<any>;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
declare class Workflow extends BaseResource {
|
|
568
|
+
private workflowId;
|
|
569
|
+
constructor(options: ClientOptions, workflowId: string);
|
|
570
|
+
/**
|
|
571
|
+
* Creates an async generator that processes a readable stream and yields workflow records
|
|
572
|
+
* separated by the Record Separator character (\x1E)
|
|
573
|
+
*
|
|
574
|
+
* @param stream - The readable stream to process
|
|
575
|
+
* @returns An async generator that yields parsed records
|
|
576
|
+
*/
|
|
577
|
+
private streamProcessor;
|
|
578
|
+
/**
|
|
579
|
+
* Retrieves details about the workflow
|
|
580
|
+
* @returns Promise containing workflow details including steps and graphs
|
|
581
|
+
*/
|
|
582
|
+
details(): Promise<GetWorkflowResponse>;
|
|
583
|
+
/**
|
|
584
|
+
* Retrieves all runs for a workflow
|
|
585
|
+
* @param params - Parameters for filtering runs
|
|
586
|
+
* @returns Promise containing workflow runs array
|
|
587
|
+
*/
|
|
588
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
|
|
589
|
+
/**
|
|
590
|
+
* Creates a new workflow run
|
|
591
|
+
* @param params - Optional object containing the optional runId
|
|
592
|
+
* @returns Promise containing the runId of the created run
|
|
593
|
+
*/
|
|
594
|
+
createRun(params?: {
|
|
595
|
+
runId?: string;
|
|
596
|
+
}): Promise<{
|
|
597
|
+
runId: string;
|
|
598
|
+
}>;
|
|
599
|
+
/**
|
|
600
|
+
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
601
|
+
* @param params - Object containing the runId, inputData and runtimeContext
|
|
602
|
+
* @returns Promise containing success message
|
|
603
|
+
*/
|
|
604
|
+
start(params: {
|
|
605
|
+
runId: string;
|
|
606
|
+
inputData: Record<string, any>;
|
|
607
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
608
|
+
}): Promise<{
|
|
609
|
+
message: string;
|
|
610
|
+
}>;
|
|
611
|
+
/**
|
|
612
|
+
* Resumes a suspended workflow step synchronously without waiting for the workflow to complete
|
|
613
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
614
|
+
* @returns Promise containing success message
|
|
615
|
+
*/
|
|
616
|
+
resume({ step, runId, resumeData, ...rest }: {
|
|
617
|
+
step: string | string[];
|
|
618
|
+
runId: string;
|
|
619
|
+
resumeData?: Record<string, any>;
|
|
620
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
621
|
+
}): Promise<{
|
|
622
|
+
message: string;
|
|
623
|
+
}>;
|
|
624
|
+
/**
|
|
625
|
+
* Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
|
|
626
|
+
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
627
|
+
* @returns Promise containing the workflow execution results
|
|
628
|
+
*/
|
|
629
|
+
startAsync(params: {
|
|
630
|
+
runId?: string;
|
|
631
|
+
inputData: Record<string, any>;
|
|
632
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
633
|
+
}): Promise<WorkflowRunResult>;
|
|
634
|
+
/**
|
|
635
|
+
* Starts a vNext workflow run and returns a stream
|
|
636
|
+
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
637
|
+
* @returns Promise containing the vNext workflow execution results
|
|
638
|
+
*/
|
|
639
|
+
stream(params: {
|
|
640
|
+
runId?: string;
|
|
641
|
+
inputData: Record<string, any>;
|
|
642
|
+
runtimeContext?: RuntimeContext;
|
|
643
|
+
}): Promise<stream_web.ReadableStream<WorkflowWatchResult>>;
|
|
644
|
+
/**
|
|
645
|
+
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
646
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
647
|
+
* @returns Promise containing the workflow resume results
|
|
648
|
+
*/
|
|
649
|
+
resumeAsync(params: {
|
|
650
|
+
runId: string;
|
|
651
|
+
step: string | string[];
|
|
652
|
+
resumeData?: Record<string, any>;
|
|
653
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
654
|
+
}): Promise<WorkflowRunResult>;
|
|
655
|
+
/**
|
|
656
|
+
* Watches workflow transitions in real-time
|
|
657
|
+
* @param runId - Optional run ID to filter the watch stream
|
|
658
|
+
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
659
|
+
*/
|
|
660
|
+
watch({ runId }: {
|
|
661
|
+
runId?: string;
|
|
662
|
+
}, onRecord: (record: WorkflowWatchResult) => void): Promise<void>;
|
|
663
|
+
/**
|
|
664
|
+
* Creates a new ReadableStream from an iterable or async iterable of objects,
|
|
665
|
+
* serializing each as JSON and separating them with the record separator (\x1E).
|
|
666
|
+
*
|
|
667
|
+
* @param records - An iterable or async iterable of objects to stream
|
|
668
|
+
* @returns A ReadableStream emitting the records as JSON strings separated by the record separator
|
|
669
|
+
*/
|
|
670
|
+
static createRecordStream(records: Iterable<any> | AsyncIterable<any>): ReadableStream;
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
/**
|
|
674
|
+
* Class for interacting with an agent via the A2A protocol
|
|
675
|
+
*/
|
|
676
|
+
declare class A2A extends BaseResource {
|
|
677
|
+
private agentId;
|
|
678
|
+
constructor(options: ClientOptions, agentId: string);
|
|
679
|
+
/**
|
|
680
|
+
* Get the agent card with metadata about the agent
|
|
681
|
+
* @returns Promise containing the agent card information
|
|
682
|
+
*/
|
|
683
|
+
getCard(): Promise<AgentCard>;
|
|
684
|
+
/**
|
|
685
|
+
* Send a message to the agent and get a response
|
|
686
|
+
* @param params - Parameters for the task
|
|
687
|
+
* @returns Promise containing the task response
|
|
688
|
+
*/
|
|
689
|
+
sendMessage(params: TaskSendParams): Promise<{
|
|
690
|
+
task: Task;
|
|
691
|
+
}>;
|
|
692
|
+
/**
|
|
693
|
+
* Get the status and result of a task
|
|
694
|
+
* @param params - Parameters for querying the task
|
|
695
|
+
* @returns Promise containing the task response
|
|
696
|
+
*/
|
|
697
|
+
getTask(params: TaskQueryParams): Promise<Task>;
|
|
698
|
+
/**
|
|
699
|
+
* Cancel a running task
|
|
700
|
+
* @param params - Parameters identifying the task to cancel
|
|
701
|
+
* @returns Promise containing the task response
|
|
702
|
+
*/
|
|
703
|
+
cancelTask(params: TaskIdParams): Promise<{
|
|
704
|
+
task: Task;
|
|
705
|
+
}>;
|
|
706
|
+
/**
|
|
707
|
+
* Send a message and subscribe to streaming updates (not fully implemented)
|
|
708
|
+
* @param params - Parameters for the task
|
|
709
|
+
* @returns Promise containing the task response
|
|
710
|
+
*/
|
|
711
|
+
sendAndSubscribe(params: TaskSendParams): Promise<Response>;
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* Represents a specific tool available on a specific MCP server.
|
|
716
|
+
* Provides methods to get details and execute the tool.
|
|
717
|
+
*/
|
|
718
|
+
declare class MCPTool extends BaseResource {
|
|
719
|
+
private serverId;
|
|
720
|
+
private toolId;
|
|
721
|
+
constructor(options: ClientOptions, serverId: string, toolId: string);
|
|
722
|
+
/**
|
|
723
|
+
* Retrieves details about this specific tool from the MCP server.
|
|
724
|
+
* @returns Promise containing the tool's information (name, description, schema).
|
|
725
|
+
*/
|
|
726
|
+
details(): Promise<McpToolInfo>;
|
|
727
|
+
/**
|
|
728
|
+
* Executes this specific tool on the MCP server.
|
|
729
|
+
* @param params - Parameters for tool execution, including data/args and optional runtimeContext.
|
|
730
|
+
* @returns Promise containing the result of the tool execution.
|
|
731
|
+
*/
|
|
732
|
+
execute(params: {
|
|
733
|
+
data?: any;
|
|
734
|
+
runtimeContext?: RuntimeContext;
|
|
472
735
|
}): Promise<any>;
|
|
473
736
|
}
|
|
474
737
|
|
|
@@ -479,6 +742,9 @@ declare class MastraClient extends BaseResource {
|
|
|
479
742
|
* @returns Promise containing map of agent IDs to agent details
|
|
480
743
|
*/
|
|
481
744
|
getAgents(): Promise<Record<string, GetAgentResponse>>;
|
|
745
|
+
getAGUI({ resourceId }: {
|
|
746
|
+
resourceId: string;
|
|
747
|
+
}): Promise<Record<string, AbstractAgent>>;
|
|
482
748
|
/**
|
|
483
749
|
* Gets an agent instance by ID
|
|
484
750
|
* @param agentId - ID of the agent to retrieve
|
|
@@ -527,6 +793,17 @@ declare class MastraClient extends BaseResource {
|
|
|
527
793
|
* @returns Tool instance
|
|
528
794
|
*/
|
|
529
795
|
getTool(toolId: string): Tool;
|
|
796
|
+
/**
|
|
797
|
+
* Retrieves all available legacy workflows
|
|
798
|
+
* @returns Promise containing map of legacy workflow IDs to legacy workflow details
|
|
799
|
+
*/
|
|
800
|
+
getLegacyWorkflows(): Promise<Record<string, GetLegacyWorkflowResponse>>;
|
|
801
|
+
/**
|
|
802
|
+
* Gets a legacy workflow instance by ID
|
|
803
|
+
* @param workflowId - ID of the legacy workflow to retrieve
|
|
804
|
+
* @returns Legacy Workflow instance
|
|
805
|
+
*/
|
|
806
|
+
getLegacyWorkflow(workflowId: string): LegacyWorkflow;
|
|
530
807
|
/**
|
|
531
808
|
* Retrieves all available workflows
|
|
532
809
|
* @returns Promise containing map of workflow IDs to workflow details
|
|
@@ -580,6 +857,44 @@ declare class MastraClient extends BaseResource {
|
|
|
580
857
|
* @returns Network instance
|
|
581
858
|
*/
|
|
582
859
|
getNetwork(networkId: string): Network;
|
|
860
|
+
/**
|
|
861
|
+
* Retrieves a list of available MCP servers.
|
|
862
|
+
* @param params - Optional parameters for pagination (limit, offset).
|
|
863
|
+
* @returns Promise containing the list of MCP servers and pagination info.
|
|
864
|
+
*/
|
|
865
|
+
getMcpServers(params?: {
|
|
866
|
+
limit?: number;
|
|
867
|
+
offset?: number;
|
|
868
|
+
}): Promise<McpServerListResponse>;
|
|
869
|
+
/**
|
|
870
|
+
* Retrieves detailed information for a specific MCP server.
|
|
871
|
+
* @param serverId - The ID of the MCP server to retrieve.
|
|
872
|
+
* @param params - Optional parameters, e.g., specific version.
|
|
873
|
+
* @returns Promise containing the detailed MCP server information.
|
|
874
|
+
*/
|
|
875
|
+
getMcpServerDetails(serverId: string, params?: {
|
|
876
|
+
version?: string;
|
|
877
|
+
}): Promise<ServerDetailInfo>;
|
|
878
|
+
/**
|
|
879
|
+
* Retrieves a list of tools for a specific MCP server.
|
|
880
|
+
* @param serverId - The ID of the MCP server.
|
|
881
|
+
* @returns Promise containing the list of tools.
|
|
882
|
+
*/
|
|
883
|
+
getMcpServerTools(serverId: string): Promise<McpServerToolListResponse>;
|
|
884
|
+
/**
|
|
885
|
+
* Gets an MCPTool resource instance for a specific tool on an MCP server.
|
|
886
|
+
* This instance can then be used to fetch details or execute the tool.
|
|
887
|
+
* @param serverId - The ID of the MCP server.
|
|
888
|
+
* @param toolId - The ID of the tool.
|
|
889
|
+
* @returns MCPTool instance.
|
|
890
|
+
*/
|
|
891
|
+
getMcpServerTool(serverId: string, toolId: string): MCPTool;
|
|
892
|
+
/**
|
|
893
|
+
* Gets an A2A client for interacting with an agent via the A2A protocol
|
|
894
|
+
* @param agentId - ID of the agent to interact with
|
|
895
|
+
* @returns A2A client instance
|
|
896
|
+
*/
|
|
897
|
+
getA2A(agentId: string): A2A;
|
|
583
898
|
}
|
|
584
899
|
|
|
585
|
-
export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult };
|
|
900
|
+
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 };
|