@mastra/client-js 0.0.0-commonjs-20250414101718 → 0.0.0-course-20250527170450
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 +563 -2
- package/dist/index.cjs +759 -48
- package/dist/index.d.cts +350 -36
- package/dist/index.d.ts +350 -36
- package/dist/index.js +755 -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 +229 -95
- package/src/types.ts +103 -14
- 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, 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 {
|
|
7
|
+
import { BaseLogMessage } from '@mastra/core/logger';
|
|
5
8
|
import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
|
|
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,20 @@ 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
|
+
}
|
|
263
|
+
interface McpServerToolListResponse {
|
|
264
|
+
tools: McpToolInfo[];
|
|
265
|
+
}
|
|
189
266
|
|
|
190
267
|
declare class BaseResource {
|
|
191
268
|
readonly options: ClientOptions;
|
|
@@ -218,7 +295,9 @@ declare class AgentVoice extends BaseResource {
|
|
|
218
295
|
* @param options - Optional provider-specific options
|
|
219
296
|
* @returns Promise containing the transcribed text
|
|
220
297
|
*/
|
|
221
|
-
listen(audio: Blob, options?: Record<string, any>): Promise<
|
|
298
|
+
listen(audio: Blob, options?: Record<string, any>): Promise<{
|
|
299
|
+
text: string;
|
|
300
|
+
}>;
|
|
222
301
|
/**
|
|
223
302
|
* Get available speakers for the agent's voice provider
|
|
224
303
|
* @returns Promise containing list of available speakers
|
|
@@ -257,6 +336,16 @@ declare class Agent extends BaseResource {
|
|
|
257
336
|
* @returns Promise containing tool details
|
|
258
337
|
*/
|
|
259
338
|
getTool(toolId: string): Promise<GetToolResponse>;
|
|
339
|
+
/**
|
|
340
|
+
* Executes a tool for the agent
|
|
341
|
+
* @param toolId - ID of the tool to execute
|
|
342
|
+
* @param params - Parameters required for tool execution
|
|
343
|
+
* @returns Promise containing the tool execution results
|
|
344
|
+
*/
|
|
345
|
+
executeTool(toolId: string, params: {
|
|
346
|
+
data: any;
|
|
347
|
+
runtimeContext?: RuntimeContext;
|
|
348
|
+
}): Promise<any>;
|
|
260
349
|
/**
|
|
261
350
|
* Retrieves evaluation results for the agent
|
|
262
351
|
* @returns Promise containing agent evaluations
|
|
@@ -317,9 +406,10 @@ declare class MemoryThread extends BaseResource {
|
|
|
317
406
|
}>;
|
|
318
407
|
/**
|
|
319
408
|
* Retrieves messages associated with the thread
|
|
409
|
+
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
320
410
|
* @returns Promise containing thread messages and UI messages
|
|
321
411
|
*/
|
|
322
|
-
getMessages(): Promise<GetMemoryThreadMessagesResponse>;
|
|
412
|
+
getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
|
|
323
413
|
}
|
|
324
414
|
|
|
325
415
|
declare class Vector extends BaseResource {
|
|
@@ -368,23 +458,22 @@ declare class Vector extends BaseResource {
|
|
|
368
458
|
query(params: QueryVectorParams): Promise<QueryVectorResponse>;
|
|
369
459
|
}
|
|
370
460
|
|
|
371
|
-
declare class
|
|
461
|
+
declare class LegacyWorkflow extends BaseResource {
|
|
372
462
|
private workflowId;
|
|
373
463
|
constructor(options: ClientOptions, workflowId: string);
|
|
374
464
|
/**
|
|
375
|
-
* Retrieves details about the workflow
|
|
376
|
-
* @returns Promise containing workflow details including steps and graphs
|
|
465
|
+
* Retrieves details about the legacy workflow
|
|
466
|
+
* @returns Promise containing legacy workflow details including steps and graphs
|
|
377
467
|
*/
|
|
378
|
-
details(): Promise<
|
|
468
|
+
details(): Promise<GetLegacyWorkflowResponse>;
|
|
379
469
|
/**
|
|
380
|
-
*
|
|
381
|
-
*
|
|
382
|
-
* @
|
|
383
|
-
* @returns Promise containing the workflow execution results
|
|
470
|
+
* Retrieves all runs for a legacy workflow
|
|
471
|
+
* @param params - Parameters for filtering runs
|
|
472
|
+
* @returns Promise containing legacy workflow runs array
|
|
384
473
|
*/
|
|
385
|
-
|
|
474
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetLegacyWorkflowRunsResponse>;
|
|
386
475
|
/**
|
|
387
|
-
* Creates a new workflow run
|
|
476
|
+
* Creates a new legacy workflow run
|
|
388
477
|
* @returns Promise containing the generated run ID
|
|
389
478
|
*/
|
|
390
479
|
createRun(params?: {
|
|
@@ -393,7 +482,7 @@ declare class Workflow extends BaseResource {
|
|
|
393
482
|
runId: string;
|
|
394
483
|
}>;
|
|
395
484
|
/**
|
|
396
|
-
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
485
|
+
* Starts a legacy workflow run synchronously without waiting for the workflow to complete
|
|
397
486
|
* @param params - Object containing the runId and triggerData
|
|
398
487
|
* @returns Promise containing success message
|
|
399
488
|
*/
|
|
@@ -404,11 +493,11 @@ declare class Workflow extends BaseResource {
|
|
|
404
493
|
message: string;
|
|
405
494
|
}>;
|
|
406
495
|
/**
|
|
407
|
-
* Resumes a suspended workflow step synchronously without waiting for the workflow to complete
|
|
496
|
+
* Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
|
|
408
497
|
* @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
|
|
498
|
+
* @param runId - ID of the legacy workflow run
|
|
499
|
+
* @param context - Context to resume the legacy workflow with
|
|
500
|
+
* @returns Promise containing the legacy workflow resume results
|
|
412
501
|
*/
|
|
413
502
|
resume({ stepId, runId, context, }: {
|
|
414
503
|
stepId: string;
|
|
@@ -425,9 +514,9 @@ declare class Workflow extends BaseResource {
|
|
|
425
514
|
startAsync(params: {
|
|
426
515
|
runId?: string;
|
|
427
516
|
triggerData: Record<string, any>;
|
|
428
|
-
}): Promise<
|
|
517
|
+
}): Promise<LegacyWorkflowRunResult>;
|
|
429
518
|
/**
|
|
430
|
-
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
519
|
+
* Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
431
520
|
* @param params - Object containing the runId, stepId, and context
|
|
432
521
|
* @returns Promise containing the workflow resume results
|
|
433
522
|
*/
|
|
@@ -435,7 +524,7 @@ declare class Workflow extends BaseResource {
|
|
|
435
524
|
runId: string;
|
|
436
525
|
stepId: string;
|
|
437
526
|
context: Record<string, any>;
|
|
438
|
-
}): Promise<
|
|
527
|
+
}): Promise<LegacyWorkflowRunResult>;
|
|
439
528
|
/**
|
|
440
529
|
* Creates an async generator that processes a readable stream and yields records
|
|
441
530
|
* separated by the Record Separator character (\x1E)
|
|
@@ -445,13 +534,13 @@ declare class Workflow extends BaseResource {
|
|
|
445
534
|
*/
|
|
446
535
|
private streamProcessor;
|
|
447
536
|
/**
|
|
448
|
-
* Watches workflow transitions in real-time
|
|
537
|
+
* Watches legacy workflow transitions in real-time
|
|
449
538
|
* @param runId - Optional run ID to filter the watch stream
|
|
450
|
-
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
539
|
+
* @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
|
|
451
540
|
*/
|
|
452
541
|
watch({ runId }: {
|
|
453
542
|
runId?: string;
|
|
454
|
-
}, onRecord: (record:
|
|
543
|
+
}, onRecord: (record: LegacyWorkflowRunResult) => void): Promise<void>;
|
|
455
544
|
}
|
|
456
545
|
|
|
457
546
|
declare class Tool extends BaseResource {
|
|
@@ -469,6 +558,179 @@ declare class Tool extends BaseResource {
|
|
|
469
558
|
*/
|
|
470
559
|
execute(params: {
|
|
471
560
|
data: any;
|
|
561
|
+
runId?: string;
|
|
562
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
563
|
+
}): Promise<any>;
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
declare class Workflow extends BaseResource {
|
|
567
|
+
private workflowId;
|
|
568
|
+
constructor(options: ClientOptions, workflowId: string);
|
|
569
|
+
/**
|
|
570
|
+
* Creates an async generator that processes a readable stream and yields workflow records
|
|
571
|
+
* separated by the Record Separator character (\x1E)
|
|
572
|
+
*
|
|
573
|
+
* @param stream - The readable stream to process
|
|
574
|
+
* @returns An async generator that yields parsed records
|
|
575
|
+
*/
|
|
576
|
+
private streamProcessor;
|
|
577
|
+
/**
|
|
578
|
+
* Retrieves details about the workflow
|
|
579
|
+
* @returns Promise containing workflow details including steps and graphs
|
|
580
|
+
*/
|
|
581
|
+
details(): Promise<GetWorkflowResponse>;
|
|
582
|
+
/**
|
|
583
|
+
* Retrieves all runs for a workflow
|
|
584
|
+
* @param params - Parameters for filtering runs
|
|
585
|
+
* @returns Promise containing workflow runs array
|
|
586
|
+
*/
|
|
587
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
|
|
588
|
+
/**
|
|
589
|
+
* Creates a new workflow run
|
|
590
|
+
* @param params - Optional object containing the optional runId
|
|
591
|
+
* @returns Promise containing the runId of the created run
|
|
592
|
+
*/
|
|
593
|
+
createRun(params?: {
|
|
594
|
+
runId?: string;
|
|
595
|
+
}): Promise<{
|
|
596
|
+
runId: string;
|
|
597
|
+
}>;
|
|
598
|
+
/**
|
|
599
|
+
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
600
|
+
* @param params - Object containing the runId, inputData and runtimeContext
|
|
601
|
+
* @returns Promise containing success message
|
|
602
|
+
*/
|
|
603
|
+
start(params: {
|
|
604
|
+
runId: string;
|
|
605
|
+
inputData: Record<string, any>;
|
|
606
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
607
|
+
}): Promise<{
|
|
608
|
+
message: string;
|
|
609
|
+
}>;
|
|
610
|
+
/**
|
|
611
|
+
* Resumes a suspended workflow step synchronously without waiting for the workflow to complete
|
|
612
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
613
|
+
* @returns Promise containing success message
|
|
614
|
+
*/
|
|
615
|
+
resume({ step, runId, resumeData, ...rest }: {
|
|
616
|
+
step: string | string[];
|
|
617
|
+
runId: string;
|
|
618
|
+
resumeData?: Record<string, any>;
|
|
619
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
620
|
+
}): Promise<{
|
|
621
|
+
message: string;
|
|
622
|
+
}>;
|
|
623
|
+
/**
|
|
624
|
+
* Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
|
|
625
|
+
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
626
|
+
* @returns Promise containing the workflow execution results
|
|
627
|
+
*/
|
|
628
|
+
startAsync(params: {
|
|
629
|
+
runId?: string;
|
|
630
|
+
inputData: Record<string, any>;
|
|
631
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
632
|
+
}): Promise<WorkflowRunResult>;
|
|
633
|
+
/**
|
|
634
|
+
* Starts a vNext workflow run and returns a stream
|
|
635
|
+
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
636
|
+
* @returns Promise containing the vNext workflow execution results
|
|
637
|
+
*/
|
|
638
|
+
stream(params: {
|
|
639
|
+
runId?: string;
|
|
640
|
+
inputData: Record<string, any>;
|
|
641
|
+
runtimeContext?: RuntimeContext;
|
|
642
|
+
}): Promise<stream_web.ReadableStream<WorkflowWatchResult>>;
|
|
643
|
+
/**
|
|
644
|
+
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
645
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
646
|
+
* @returns Promise containing the workflow resume results
|
|
647
|
+
*/
|
|
648
|
+
resumeAsync(params: {
|
|
649
|
+
runId: string;
|
|
650
|
+
step: string | string[];
|
|
651
|
+
resumeData?: Record<string, any>;
|
|
652
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
653
|
+
}): Promise<WorkflowRunResult>;
|
|
654
|
+
/**
|
|
655
|
+
* Watches workflow transitions in real-time
|
|
656
|
+
* @param runId - Optional run ID to filter the watch stream
|
|
657
|
+
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
658
|
+
*/
|
|
659
|
+
watch({ runId }: {
|
|
660
|
+
runId?: string;
|
|
661
|
+
}, onRecord: (record: WorkflowWatchResult) => void): Promise<void>;
|
|
662
|
+
/**
|
|
663
|
+
* Creates a new ReadableStream from an iterable or async iterable of objects,
|
|
664
|
+
* serializing each as JSON and separating them with the record separator (\x1E).
|
|
665
|
+
*
|
|
666
|
+
* @param records - An iterable or async iterable of objects to stream
|
|
667
|
+
* @returns A ReadableStream emitting the records as JSON strings separated by the record separator
|
|
668
|
+
*/
|
|
669
|
+
static createRecordStream(records: Iterable<any> | AsyncIterable<any>): ReadableStream;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* Class for interacting with an agent via the A2A protocol
|
|
674
|
+
*/
|
|
675
|
+
declare class A2A extends BaseResource {
|
|
676
|
+
private agentId;
|
|
677
|
+
constructor(options: ClientOptions, agentId: string);
|
|
678
|
+
/**
|
|
679
|
+
* Get the agent card with metadata about the agent
|
|
680
|
+
* @returns Promise containing the agent card information
|
|
681
|
+
*/
|
|
682
|
+
getCard(): Promise<AgentCard>;
|
|
683
|
+
/**
|
|
684
|
+
* Send a message to the agent and get a response
|
|
685
|
+
* @param params - Parameters for the task
|
|
686
|
+
* @returns Promise containing the task response
|
|
687
|
+
*/
|
|
688
|
+
sendMessage(params: TaskSendParams): Promise<{
|
|
689
|
+
task: Task;
|
|
690
|
+
}>;
|
|
691
|
+
/**
|
|
692
|
+
* Get the status and result of a task
|
|
693
|
+
* @param params - Parameters for querying the task
|
|
694
|
+
* @returns Promise containing the task response
|
|
695
|
+
*/
|
|
696
|
+
getTask(params: TaskQueryParams): Promise<Task>;
|
|
697
|
+
/**
|
|
698
|
+
* Cancel a running task
|
|
699
|
+
* @param params - Parameters identifying the task to cancel
|
|
700
|
+
* @returns Promise containing the task response
|
|
701
|
+
*/
|
|
702
|
+
cancelTask(params: TaskIdParams): Promise<{
|
|
703
|
+
task: Task;
|
|
704
|
+
}>;
|
|
705
|
+
/**
|
|
706
|
+
* Send a message and subscribe to streaming updates (not fully implemented)
|
|
707
|
+
* @param params - Parameters for the task
|
|
708
|
+
* @returns Promise containing the task response
|
|
709
|
+
*/
|
|
710
|
+
sendAndSubscribe(params: TaskSendParams): Promise<Response>;
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/**
|
|
714
|
+
* Represents a specific tool available on a specific MCP server.
|
|
715
|
+
* Provides methods to get details and execute the tool.
|
|
716
|
+
*/
|
|
717
|
+
declare class MCPTool extends BaseResource {
|
|
718
|
+
private serverId;
|
|
719
|
+
private toolId;
|
|
720
|
+
constructor(options: ClientOptions, serverId: string, toolId: string);
|
|
721
|
+
/**
|
|
722
|
+
* Retrieves details about this specific tool from the MCP server.
|
|
723
|
+
* @returns Promise containing the tool's information (name, description, schema).
|
|
724
|
+
*/
|
|
725
|
+
details(): Promise<McpToolInfo>;
|
|
726
|
+
/**
|
|
727
|
+
* Executes this specific tool on the MCP server.
|
|
728
|
+
* @param params - Parameters for tool execution, including data/args and optional runtimeContext.
|
|
729
|
+
* @returns Promise containing the result of the tool execution.
|
|
730
|
+
*/
|
|
731
|
+
execute(params: {
|
|
732
|
+
data?: any;
|
|
733
|
+
runtimeContext?: RuntimeContext;
|
|
472
734
|
}): Promise<any>;
|
|
473
735
|
}
|
|
474
736
|
|
|
@@ -479,6 +741,9 @@ declare class MastraClient extends BaseResource {
|
|
|
479
741
|
* @returns Promise containing map of agent IDs to agent details
|
|
480
742
|
*/
|
|
481
743
|
getAgents(): Promise<Record<string, GetAgentResponse>>;
|
|
744
|
+
getAGUI({ resourceId }: {
|
|
745
|
+
resourceId: string;
|
|
746
|
+
}): Promise<Record<string, AbstractAgent>>;
|
|
482
747
|
/**
|
|
483
748
|
* Gets an agent instance by ID
|
|
484
749
|
* @param agentId - ID of the agent to retrieve
|
|
@@ -527,6 +792,17 @@ declare class MastraClient extends BaseResource {
|
|
|
527
792
|
* @returns Tool instance
|
|
528
793
|
*/
|
|
529
794
|
getTool(toolId: string): Tool;
|
|
795
|
+
/**
|
|
796
|
+
* Retrieves all available legacy workflows
|
|
797
|
+
* @returns Promise containing map of legacy workflow IDs to legacy workflow details
|
|
798
|
+
*/
|
|
799
|
+
getLegacyWorkflows(): Promise<Record<string, GetLegacyWorkflowResponse>>;
|
|
800
|
+
/**
|
|
801
|
+
* Gets a legacy workflow instance by ID
|
|
802
|
+
* @param workflowId - ID of the legacy workflow to retrieve
|
|
803
|
+
* @returns Legacy Workflow instance
|
|
804
|
+
*/
|
|
805
|
+
getLegacyWorkflow(workflowId: string): LegacyWorkflow;
|
|
530
806
|
/**
|
|
531
807
|
* Retrieves all available workflows
|
|
532
808
|
* @returns Promise containing map of workflow IDs to workflow details
|
|
@@ -580,6 +856,44 @@ declare class MastraClient extends BaseResource {
|
|
|
580
856
|
* @returns Network instance
|
|
581
857
|
*/
|
|
582
858
|
getNetwork(networkId: string): Network;
|
|
859
|
+
/**
|
|
860
|
+
* Retrieves a list of available MCP servers.
|
|
861
|
+
* @param params - Optional parameters for pagination (limit, offset).
|
|
862
|
+
* @returns Promise containing the list of MCP servers and pagination info.
|
|
863
|
+
*/
|
|
864
|
+
getMcpServers(params?: {
|
|
865
|
+
limit?: number;
|
|
866
|
+
offset?: number;
|
|
867
|
+
}): Promise<McpServerListResponse>;
|
|
868
|
+
/**
|
|
869
|
+
* Retrieves detailed information for a specific MCP server.
|
|
870
|
+
* @param serverId - The ID of the MCP server to retrieve.
|
|
871
|
+
* @param params - Optional parameters, e.g., specific version.
|
|
872
|
+
* @returns Promise containing the detailed MCP server information.
|
|
873
|
+
*/
|
|
874
|
+
getMcpServerDetails(serverId: string, params?: {
|
|
875
|
+
version?: string;
|
|
876
|
+
}): Promise<ServerDetailInfo>;
|
|
877
|
+
/**
|
|
878
|
+
* Retrieves a list of tools for a specific MCP server.
|
|
879
|
+
* @param serverId - The ID of the MCP server.
|
|
880
|
+
* @returns Promise containing the list of tools.
|
|
881
|
+
*/
|
|
882
|
+
getMcpServerTools(serverId: string): Promise<McpServerToolListResponse>;
|
|
883
|
+
/**
|
|
884
|
+
* Gets an MCPTool resource instance for a specific tool on an MCP server.
|
|
885
|
+
* This instance can then be used to fetch details or execute the tool.
|
|
886
|
+
* @param serverId - The ID of the MCP server.
|
|
887
|
+
* @param toolId - The ID of the tool.
|
|
888
|
+
* @returns MCPTool instance.
|
|
889
|
+
*/
|
|
890
|
+
getMcpServerTool(serverId: string, toolId: string): MCPTool;
|
|
891
|
+
/**
|
|
892
|
+
* Gets an A2A client for interacting with an agent via the A2A protocol
|
|
893
|
+
* @param agentId - ID of the agent to interact with
|
|
894
|
+
* @returns A2A client instance
|
|
895
|
+
*/
|
|
896
|
+
getA2A(agentId: string): A2A;
|
|
583
897
|
}
|
|
584
898
|
|
|
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 };
|
|
899
|
+
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 };
|