@mastra/client-js 0.0.0-generate-message-id-20250512171942 → 0.0.0-inject-middleware-20250528213451
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/CHANGELOG.md +180 -4
- package/dist/index.cjs +253 -92
- package/dist/index.d.cts +190 -80
- package/dist/index.d.ts +190 -80
- package/dist/index.js +253 -92
- package/package.json +6 -5
- package/src/client.ts +85 -19
- package/src/example.ts +29 -30
- package/src/index.test.ts +121 -1
- package/src/resources/agent.ts +9 -8
- package/src/resources/base.ts +1 -1
- package/src/resources/index.ts +3 -2
- package/src/resources/{vnext-workflow.ts → legacy-workflow.ts} +124 -143
- package/src/resources/mcp-tool.ts +48 -0
- package/src/resources/memory-thread.ts +13 -3
- package/src/resources/tool.ts +4 -3
- package/src/resources/workflow.ts +202 -100
- package/src/types.ts +70 -18
- package/src/utils/index.ts +11 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { AbstractAgent } from '@ag-ui/client';
|
|
2
|
+
import { ServerInfo, MCPToolType, ServerDetailInfo } from '@mastra/core/mcp';
|
|
2
3
|
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
3
|
-
import { CoreMessage, AiMessageType, StorageThreadType, MessageType,
|
|
4
|
+
import { CoreMessage, AiMessageType, StorageThreadType, MessageType, LegacyWorkflowRuns, WorkflowRuns, QueryResult, GenerateReturn } from '@mastra/core';
|
|
4
5
|
import { JSONSchema7 } from 'json-schema';
|
|
5
6
|
import { ZodSchema } from 'zod';
|
|
6
7
|
import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
|
|
7
|
-
import {
|
|
8
|
-
import { RuntimeContext } from '@mastra/core/
|
|
9
|
-
import {
|
|
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';
|
|
10
13
|
import { AgentCard, TaskSendParams, Task, TaskQueryParams, TaskIdParams } from '@mastra/core/a2a';
|
|
11
14
|
|
|
12
15
|
interface ClientOptions {
|
|
@@ -28,19 +31,33 @@ interface RequestOptions {
|
|
|
28
31
|
stream?: boolean;
|
|
29
32
|
signal?: AbortSignal;
|
|
30
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
|
+
};
|
|
31
39
|
interface GetAgentResponse {
|
|
32
40
|
name: string;
|
|
33
41
|
instructions: string;
|
|
34
42
|
tools: Record<string, GetToolResponse>;
|
|
43
|
+
workflows: Record<string, GetWorkflowResponse>;
|
|
35
44
|
provider: string;
|
|
36
45
|
modelId: string;
|
|
46
|
+
defaultGenerateOptions: WithoutMethods<AgentGenerateOptions>;
|
|
47
|
+
defaultStreamOptions: WithoutMethods<AgentStreamOptions>;
|
|
37
48
|
}
|
|
38
49
|
type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
39
50
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
40
|
-
|
|
51
|
+
output?: T;
|
|
52
|
+
experimental_output?: T;
|
|
53
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
54
|
+
} & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
|
|
41
55
|
type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
42
56
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
43
|
-
|
|
57
|
+
output?: T;
|
|
58
|
+
experimental_output?: T;
|
|
59
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
60
|
+
} & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
|
|
44
61
|
interface GetEvalsByAgentIdResponse extends GetAgentResponse {
|
|
45
62
|
evals: any[];
|
|
46
63
|
instructions: string;
|
|
@@ -53,7 +70,7 @@ interface GetToolResponse {
|
|
|
53
70
|
inputSchema: string;
|
|
54
71
|
outputSchema: string;
|
|
55
72
|
}
|
|
56
|
-
interface
|
|
73
|
+
interface GetLegacyWorkflowResponse {
|
|
57
74
|
name: string;
|
|
58
75
|
triggerSchema: string;
|
|
59
76
|
steps: Record<string, StepAction<any, any, any, any>>;
|
|
@@ -68,19 +85,21 @@ interface GetWorkflowRunsParams {
|
|
|
68
85
|
offset?: number;
|
|
69
86
|
resourceId?: string;
|
|
70
87
|
}
|
|
88
|
+
type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
|
|
71
89
|
type GetWorkflowRunsResponse = WorkflowRuns;
|
|
72
|
-
type
|
|
90
|
+
type LegacyWorkflowRunResult = {
|
|
73
91
|
activePaths: Record<string, {
|
|
74
92
|
status: string;
|
|
75
93
|
suspendPayload?: any;
|
|
76
94
|
stepPath: string[];
|
|
77
95
|
}>;
|
|
78
|
-
results:
|
|
96
|
+
results: LegacyWorkflowRunResult$1<any, any, any>['results'];
|
|
79
97
|
timestamp: number;
|
|
80
98
|
runId: string;
|
|
81
99
|
};
|
|
82
|
-
interface
|
|
100
|
+
interface GetWorkflowResponse {
|
|
83
101
|
name: string;
|
|
102
|
+
description?: string;
|
|
84
103
|
steps: {
|
|
85
104
|
[key: string]: {
|
|
86
105
|
id: string;
|
|
@@ -91,14 +110,14 @@ interface GetVNextWorkflowResponse {
|
|
|
91
110
|
suspendSchema: string;
|
|
92
111
|
};
|
|
93
112
|
};
|
|
94
|
-
stepGraph:
|
|
113
|
+
stepGraph: Workflow$1['serializedStepGraph'];
|
|
95
114
|
inputSchema: string;
|
|
96
115
|
outputSchema: string;
|
|
97
116
|
}
|
|
98
|
-
type
|
|
117
|
+
type WorkflowWatchResult = WatchEvent & {
|
|
99
118
|
runId: string;
|
|
100
119
|
};
|
|
101
|
-
type
|
|
120
|
+
type WorkflowRunResult = WorkflowResult<any, any>;
|
|
102
121
|
interface UpsertVectorParams {
|
|
103
122
|
indexName: string;
|
|
104
123
|
vectors: number[][];
|
|
@@ -131,10 +150,10 @@ interface SaveMessageToMemoryParams {
|
|
|
131
150
|
}
|
|
132
151
|
type SaveMessageToMemoryResponse = MessageType[];
|
|
133
152
|
interface CreateMemoryThreadParams {
|
|
134
|
-
title
|
|
135
|
-
metadata
|
|
153
|
+
title?: string;
|
|
154
|
+
metadata?: Record<string, any>;
|
|
136
155
|
resourceId: string;
|
|
137
|
-
threadId
|
|
156
|
+
threadId?: string;
|
|
138
157
|
agentId: string;
|
|
139
158
|
}
|
|
140
159
|
type CreateMemoryThreadResponse = StorageThreadType;
|
|
@@ -148,6 +167,12 @@ interface UpdateMemoryThreadParams {
|
|
|
148
167
|
metadata: Record<string, any>;
|
|
149
168
|
resourceId: string;
|
|
150
169
|
}
|
|
170
|
+
interface GetMemoryThreadMessagesParams {
|
|
171
|
+
/**
|
|
172
|
+
* Limit the number of messages to retrieve (default: 40)
|
|
173
|
+
*/
|
|
174
|
+
limit?: number;
|
|
175
|
+
}
|
|
151
176
|
interface GetMemoryThreadMessagesResponse {
|
|
152
177
|
messages: CoreMessage[];
|
|
153
178
|
uiMessages: AiMessageType[];
|
|
@@ -224,6 +249,21 @@ interface GetNetworkResponse {
|
|
|
224
249
|
};
|
|
225
250
|
state?: Record<string, any>;
|
|
226
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
|
+
}
|
|
227
267
|
|
|
228
268
|
declare class BaseResource {
|
|
229
269
|
readonly options: ClientOptions;
|
|
@@ -256,7 +296,9 @@ declare class AgentVoice extends BaseResource {
|
|
|
256
296
|
* @param options - Optional provider-specific options
|
|
257
297
|
* @returns Promise containing the transcribed text
|
|
258
298
|
*/
|
|
259
|
-
listen(audio: Blob, options?: Record<string, any>): Promise<
|
|
299
|
+
listen(audio: Blob, options?: Record<string, any>): Promise<{
|
|
300
|
+
text: string;
|
|
301
|
+
}>;
|
|
260
302
|
/**
|
|
261
303
|
* Get available speakers for the agent's voice provider
|
|
262
304
|
* @returns Promise containing list of available speakers
|
|
@@ -365,9 +407,10 @@ declare class MemoryThread extends BaseResource {
|
|
|
365
407
|
}>;
|
|
366
408
|
/**
|
|
367
409
|
* Retrieves messages associated with the thread
|
|
410
|
+
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
368
411
|
* @returns Promise containing thread messages and UI messages
|
|
369
412
|
*/
|
|
370
|
-
getMessages(): Promise<GetMemoryThreadMessagesResponse>;
|
|
413
|
+
getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
|
|
371
414
|
}
|
|
372
415
|
|
|
373
416
|
declare class Vector extends BaseResource {
|
|
@@ -416,29 +459,22 @@ declare class Vector extends BaseResource {
|
|
|
416
459
|
query(params: QueryVectorParams): Promise<QueryVectorResponse>;
|
|
417
460
|
}
|
|
418
461
|
|
|
419
|
-
declare class
|
|
462
|
+
declare class LegacyWorkflow extends BaseResource {
|
|
420
463
|
private workflowId;
|
|
421
464
|
constructor(options: ClientOptions, workflowId: string);
|
|
422
465
|
/**
|
|
423
|
-
* Retrieves details about the workflow
|
|
424
|
-
* @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
|
|
425
468
|
*/
|
|
426
|
-
details(): Promise<
|
|
469
|
+
details(): Promise<GetLegacyWorkflowResponse>;
|
|
427
470
|
/**
|
|
428
|
-
* Retrieves all runs for a workflow
|
|
471
|
+
* Retrieves all runs for a legacy workflow
|
|
429
472
|
* @param params - Parameters for filtering runs
|
|
430
|
-
* @returns Promise containing workflow runs array
|
|
431
|
-
*/
|
|
432
|
-
runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
|
|
433
|
-
/**
|
|
434
|
-
* @deprecated Use `startAsync` instead
|
|
435
|
-
* Executes the workflow with the provided parameters
|
|
436
|
-
* @param params - Parameters required for workflow execution
|
|
437
|
-
* @returns Promise containing the workflow execution results
|
|
473
|
+
* @returns Promise containing legacy workflow runs array
|
|
438
474
|
*/
|
|
439
|
-
|
|
475
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetLegacyWorkflowRunsResponse>;
|
|
440
476
|
/**
|
|
441
|
-
* Creates a new workflow run
|
|
477
|
+
* Creates a new legacy workflow run
|
|
442
478
|
* @returns Promise containing the generated run ID
|
|
443
479
|
*/
|
|
444
480
|
createRun(params?: {
|
|
@@ -447,7 +483,7 @@ declare class Workflow extends BaseResource {
|
|
|
447
483
|
runId: string;
|
|
448
484
|
}>;
|
|
449
485
|
/**
|
|
450
|
-
* 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
|
|
451
487
|
* @param params - Object containing the runId and triggerData
|
|
452
488
|
* @returns Promise containing success message
|
|
453
489
|
*/
|
|
@@ -458,11 +494,11 @@ declare class Workflow extends BaseResource {
|
|
|
458
494
|
message: string;
|
|
459
495
|
}>;
|
|
460
496
|
/**
|
|
461
|
-
* 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
|
|
462
498
|
* @param stepId - ID of the step to resume
|
|
463
|
-
* @param runId - ID of the workflow run
|
|
464
|
-
* @param context - Context to resume the workflow with
|
|
465
|
-
* @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
|
|
466
502
|
*/
|
|
467
503
|
resume({ stepId, runId, context, }: {
|
|
468
504
|
stepId: string;
|
|
@@ -479,9 +515,9 @@ declare class Workflow extends BaseResource {
|
|
|
479
515
|
startAsync(params: {
|
|
480
516
|
runId?: string;
|
|
481
517
|
triggerData: Record<string, any>;
|
|
482
|
-
}): Promise<
|
|
518
|
+
}): Promise<LegacyWorkflowRunResult>;
|
|
483
519
|
/**
|
|
484
|
-
* 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
|
|
485
521
|
* @param params - Object containing the runId, stepId, and context
|
|
486
522
|
* @returns Promise containing the workflow resume results
|
|
487
523
|
*/
|
|
@@ -489,7 +525,7 @@ declare class Workflow extends BaseResource {
|
|
|
489
525
|
runId: string;
|
|
490
526
|
stepId: string;
|
|
491
527
|
context: Record<string, any>;
|
|
492
|
-
}): Promise<
|
|
528
|
+
}): Promise<LegacyWorkflowRunResult>;
|
|
493
529
|
/**
|
|
494
530
|
* Creates an async generator that processes a readable stream and yields records
|
|
495
531
|
* separated by the Record Separator character (\x1E)
|
|
@@ -499,13 +535,13 @@ declare class Workflow extends BaseResource {
|
|
|
499
535
|
*/
|
|
500
536
|
private streamProcessor;
|
|
501
537
|
/**
|
|
502
|
-
* Watches workflow transitions in real-time
|
|
538
|
+
* Watches legacy workflow transitions in real-time
|
|
503
539
|
* @param runId - Optional run ID to filter the watch stream
|
|
504
|
-
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
540
|
+
* @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
|
|
505
541
|
*/
|
|
506
542
|
watch({ runId }: {
|
|
507
543
|
runId?: string;
|
|
508
|
-
}, onRecord: (record:
|
|
544
|
+
}, onRecord: (record: LegacyWorkflowRunResult) => void): Promise<void>;
|
|
509
545
|
}
|
|
510
546
|
|
|
511
547
|
declare class Tool extends BaseResource {
|
|
@@ -524,15 +560,15 @@ declare class Tool extends BaseResource {
|
|
|
524
560
|
execute(params: {
|
|
525
561
|
data: any;
|
|
526
562
|
runId?: string;
|
|
527
|
-
runtimeContext?: RuntimeContext
|
|
563
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
528
564
|
}): Promise<any>;
|
|
529
565
|
}
|
|
530
566
|
|
|
531
|
-
declare class
|
|
567
|
+
declare class Workflow extends BaseResource {
|
|
532
568
|
private workflowId;
|
|
533
569
|
constructor(options: ClientOptions, workflowId: string);
|
|
534
570
|
/**
|
|
535
|
-
* Creates an async generator that processes a readable stream and yields
|
|
571
|
+
* Creates an async generator that processes a readable stream and yields workflow records
|
|
536
572
|
* separated by the Record Separator character (\x1E)
|
|
537
573
|
*
|
|
538
574
|
* @param stream - The readable stream to process
|
|
@@ -540,18 +576,18 @@ declare class VNextWorkflow extends BaseResource {
|
|
|
540
576
|
*/
|
|
541
577
|
private streamProcessor;
|
|
542
578
|
/**
|
|
543
|
-
* Retrieves details about the
|
|
544
|
-
* @returns Promise containing
|
|
579
|
+
* Retrieves details about the workflow
|
|
580
|
+
* @returns Promise containing workflow details including steps and graphs
|
|
545
581
|
*/
|
|
546
|
-
details(): Promise<
|
|
582
|
+
details(): Promise<GetWorkflowResponse>;
|
|
547
583
|
/**
|
|
548
|
-
* Retrieves all runs for a
|
|
584
|
+
* Retrieves all runs for a workflow
|
|
549
585
|
* @param params - Parameters for filtering runs
|
|
550
|
-
* @returns Promise containing
|
|
586
|
+
* @returns Promise containing workflow runs array
|
|
551
587
|
*/
|
|
552
588
|
runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
|
|
553
589
|
/**
|
|
554
|
-
* Creates a new
|
|
590
|
+
* Creates a new workflow run
|
|
555
591
|
* @param params - Optional object containing the optional runId
|
|
556
592
|
* @returns Promise containing the runId of the created run
|
|
557
593
|
*/
|
|
@@ -561,19 +597,19 @@ declare class VNextWorkflow extends BaseResource {
|
|
|
561
597
|
runId: string;
|
|
562
598
|
}>;
|
|
563
599
|
/**
|
|
564
|
-
* Starts a
|
|
600
|
+
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
565
601
|
* @param params - Object containing the runId, inputData and runtimeContext
|
|
566
602
|
* @returns Promise containing success message
|
|
567
603
|
*/
|
|
568
604
|
start(params: {
|
|
569
605
|
runId: string;
|
|
570
606
|
inputData: Record<string, any>;
|
|
571
|
-
runtimeContext?: RuntimeContext
|
|
607
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
572
608
|
}): Promise<{
|
|
573
609
|
message: string;
|
|
574
610
|
}>;
|
|
575
611
|
/**
|
|
576
|
-
* Resumes a suspended
|
|
612
|
+
* Resumes a suspended workflow step synchronously without waiting for the workflow to complete
|
|
577
613
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
578
614
|
* @returns Promise containing success message
|
|
579
615
|
*/
|
|
@@ -581,39 +617,57 @@ declare class VNextWorkflow extends BaseResource {
|
|
|
581
617
|
step: string | string[];
|
|
582
618
|
runId: string;
|
|
583
619
|
resumeData?: Record<string, any>;
|
|
584
|
-
runtimeContext?: RuntimeContext
|
|
620
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
585
621
|
}): Promise<{
|
|
586
622
|
message: string;
|
|
587
623
|
}>;
|
|
588
624
|
/**
|
|
589
|
-
* Starts a
|
|
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
|
|
590
636
|
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
591
637
|
* @returns Promise containing the vNext workflow execution results
|
|
592
638
|
*/
|
|
593
|
-
|
|
639
|
+
stream(params: {
|
|
594
640
|
runId?: string;
|
|
595
641
|
inputData: Record<string, any>;
|
|
596
|
-
runtimeContext?: RuntimeContext
|
|
597
|
-
}): Promise<
|
|
642
|
+
runtimeContext?: RuntimeContext;
|
|
643
|
+
}): Promise<stream_web.ReadableStream<WorkflowWatchResult>>;
|
|
598
644
|
/**
|
|
599
|
-
* Resumes a suspended
|
|
645
|
+
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
600
646
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
601
|
-
* @returns Promise containing the
|
|
647
|
+
* @returns Promise containing the workflow resume results
|
|
602
648
|
*/
|
|
603
649
|
resumeAsync(params: {
|
|
604
650
|
runId: string;
|
|
605
651
|
step: string | string[];
|
|
606
652
|
resumeData?: Record<string, any>;
|
|
607
|
-
runtimeContext?: RuntimeContext
|
|
608
|
-
}): Promise<
|
|
653
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
654
|
+
}): Promise<WorkflowRunResult>;
|
|
609
655
|
/**
|
|
610
|
-
* Watches
|
|
656
|
+
* Watches workflow transitions in real-time
|
|
611
657
|
* @param runId - Optional run ID to filter the watch stream
|
|
612
|
-
* @returns AsyncGenerator that yields parsed records from the
|
|
658
|
+
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
613
659
|
*/
|
|
614
660
|
watch({ runId }: {
|
|
615
661
|
runId?: string;
|
|
616
|
-
}, onRecord: (record:
|
|
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;
|
|
617
671
|
}
|
|
618
672
|
|
|
619
673
|
/**
|
|
@@ -657,6 +711,30 @@ declare class A2A extends BaseResource {
|
|
|
657
711
|
sendAndSubscribe(params: TaskSendParams): Promise<Response>;
|
|
658
712
|
}
|
|
659
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;
|
|
735
|
+
}): Promise<any>;
|
|
736
|
+
}
|
|
737
|
+
|
|
660
738
|
declare class MastraClient extends BaseResource {
|
|
661
739
|
constructor(options: ClientOptions);
|
|
662
740
|
/**
|
|
@@ -715,6 +793,17 @@ declare class MastraClient extends BaseResource {
|
|
|
715
793
|
* @returns Tool instance
|
|
716
794
|
*/
|
|
717
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;
|
|
718
807
|
/**
|
|
719
808
|
* Retrieves all available workflows
|
|
720
809
|
* @returns Promise containing map of workflow IDs to workflow details
|
|
@@ -726,17 +815,6 @@ declare class MastraClient extends BaseResource {
|
|
|
726
815
|
* @returns Workflow instance
|
|
727
816
|
*/
|
|
728
817
|
getWorkflow(workflowId: string): Workflow;
|
|
729
|
-
/**
|
|
730
|
-
* Retrieves all available vNext workflows
|
|
731
|
-
* @returns Promise containing map of vNext workflow IDs to vNext workflow details
|
|
732
|
-
*/
|
|
733
|
-
getVNextWorkflows(): Promise<Record<string, GetVNextWorkflowResponse>>;
|
|
734
|
-
/**
|
|
735
|
-
* Gets a vNext workflow instance by ID
|
|
736
|
-
* @param workflowId - ID of the vNext workflow to retrieve
|
|
737
|
-
* @returns vNext Workflow instance
|
|
738
|
-
*/
|
|
739
|
-
getVNextWorkflow(workflowId: string): VNextWorkflow;
|
|
740
818
|
/**
|
|
741
819
|
* Gets a vector instance by name
|
|
742
820
|
* @param vectorName - Name of the vector to retrieve
|
|
@@ -779,6 +857,38 @@ declare class MastraClient extends BaseResource {
|
|
|
779
857
|
* @returns Network instance
|
|
780
858
|
*/
|
|
781
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;
|
|
782
892
|
/**
|
|
783
893
|
* Gets an A2A client for interacting with an agent via the A2A protocol
|
|
784
894
|
* @param agentId - ID of the agent to interact with
|
|
@@ -787,4 +897,4 @@ declare class MastraClient extends BaseResource {
|
|
|
787
897
|
getA2A(agentId: string): A2A;
|
|
788
898
|
}
|
|
789
899
|
|
|
790
|
-
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
|
|
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 };
|