@mastra/client-js 0.0.0-fix-message-embedding-20250506021742 → 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 +289 -2
- package/dist/index.cjs +399 -101
- package/dist/index.d.cts +247 -77
- package/dist/index.d.ts +247 -77
- package/dist/index.js +395 -101
- package/package.json +7 -6
- package/src/adapters/agui.test.ts +19 -6
- package/src/adapters/agui.ts +31 -11
- package/src/client.ts +94 -19
- package/src/example.ts +29 -30
- package/src/index.test.ts +121 -1
- package/src/resources/a2a.ts +88 -0
- package/src/resources/agent.ts +27 -34
- package/src/resources/base.ts +1 -1
- package/src/resources/index.ts +4 -2
- package/src/resources/{vnext-workflow.ts → legacy-workflow.ts} +124 -139
- package/src/resources/mcp-tool.ts +48 -0
- package/src/resources/memory-thread.ts +13 -3
- package/src/resources/network.ts +5 -11
- package/src/resources/tool.ts +9 -2
- package/src/resources/workflow.ts +202 -100
- package/src/types.ts +70 -18
- package/src/utils/index.ts +11 -0
- package/src/utils/zod-to-json-schema.ts +10 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
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 { BaseLogMessage } from '@mastra/core/logger';
|
|
8
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';
|
|
9
14
|
|
|
10
15
|
interface ClientOptions {
|
|
11
16
|
/** Base URL for API requests */
|
|
@@ -26,19 +31,33 @@ interface RequestOptions {
|
|
|
26
31
|
stream?: boolean;
|
|
27
32
|
signal?: AbortSignal;
|
|
28
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
|
+
};
|
|
29
39
|
interface GetAgentResponse {
|
|
30
40
|
name: string;
|
|
31
41
|
instructions: string;
|
|
32
42
|
tools: Record<string, GetToolResponse>;
|
|
43
|
+
workflows: Record<string, GetWorkflowResponse>;
|
|
33
44
|
provider: string;
|
|
34
45
|
modelId: string;
|
|
46
|
+
defaultGenerateOptions: WithoutMethods<AgentGenerateOptions>;
|
|
47
|
+
defaultStreamOptions: WithoutMethods<AgentStreamOptions>;
|
|
35
48
|
}
|
|
36
49
|
type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
37
50
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
38
|
-
|
|
51
|
+
output?: T;
|
|
52
|
+
experimental_output?: T;
|
|
53
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
54
|
+
} & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
|
|
39
55
|
type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
40
56
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
41
|
-
|
|
57
|
+
output?: T;
|
|
58
|
+
experimental_output?: T;
|
|
59
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
60
|
+
} & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext'>>;
|
|
42
61
|
interface GetEvalsByAgentIdResponse extends GetAgentResponse {
|
|
43
62
|
evals: any[];
|
|
44
63
|
instructions: string;
|
|
@@ -51,7 +70,7 @@ interface GetToolResponse {
|
|
|
51
70
|
inputSchema: string;
|
|
52
71
|
outputSchema: string;
|
|
53
72
|
}
|
|
54
|
-
interface
|
|
73
|
+
interface GetLegacyWorkflowResponse {
|
|
55
74
|
name: string;
|
|
56
75
|
triggerSchema: string;
|
|
57
76
|
steps: Record<string, StepAction<any, any, any, any>>;
|
|
@@ -66,19 +85,21 @@ interface GetWorkflowRunsParams {
|
|
|
66
85
|
offset?: number;
|
|
67
86
|
resourceId?: string;
|
|
68
87
|
}
|
|
88
|
+
type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
|
|
69
89
|
type GetWorkflowRunsResponse = WorkflowRuns;
|
|
70
|
-
type
|
|
90
|
+
type LegacyWorkflowRunResult = {
|
|
71
91
|
activePaths: Record<string, {
|
|
72
92
|
status: string;
|
|
73
93
|
suspendPayload?: any;
|
|
74
94
|
stepPath: string[];
|
|
75
95
|
}>;
|
|
76
|
-
results:
|
|
96
|
+
results: LegacyWorkflowRunResult$1<any, any, any>['results'];
|
|
77
97
|
timestamp: number;
|
|
78
98
|
runId: string;
|
|
79
99
|
};
|
|
80
|
-
interface
|
|
100
|
+
interface GetWorkflowResponse {
|
|
81
101
|
name: string;
|
|
102
|
+
description?: string;
|
|
82
103
|
steps: {
|
|
83
104
|
[key: string]: {
|
|
84
105
|
id: string;
|
|
@@ -89,14 +110,14 @@ interface GetVNextWorkflowResponse {
|
|
|
89
110
|
suspendSchema: string;
|
|
90
111
|
};
|
|
91
112
|
};
|
|
92
|
-
stepGraph:
|
|
113
|
+
stepGraph: Workflow$1['serializedStepGraph'];
|
|
93
114
|
inputSchema: string;
|
|
94
115
|
outputSchema: string;
|
|
95
116
|
}
|
|
96
|
-
type
|
|
117
|
+
type WorkflowWatchResult = WatchEvent & {
|
|
97
118
|
runId: string;
|
|
98
119
|
};
|
|
99
|
-
type
|
|
120
|
+
type WorkflowRunResult = WorkflowResult<any, any>;
|
|
100
121
|
interface UpsertVectorParams {
|
|
101
122
|
indexName: string;
|
|
102
123
|
vectors: number[][];
|
|
@@ -129,10 +150,10 @@ interface SaveMessageToMemoryParams {
|
|
|
129
150
|
}
|
|
130
151
|
type SaveMessageToMemoryResponse = MessageType[];
|
|
131
152
|
interface CreateMemoryThreadParams {
|
|
132
|
-
title
|
|
133
|
-
metadata
|
|
153
|
+
title?: string;
|
|
154
|
+
metadata?: Record<string, any>;
|
|
134
155
|
resourceId: string;
|
|
135
|
-
threadId
|
|
156
|
+
threadId?: string;
|
|
136
157
|
agentId: string;
|
|
137
158
|
}
|
|
138
159
|
type CreateMemoryThreadResponse = StorageThreadType;
|
|
@@ -146,6 +167,12 @@ interface UpdateMemoryThreadParams {
|
|
|
146
167
|
metadata: Record<string, any>;
|
|
147
168
|
resourceId: string;
|
|
148
169
|
}
|
|
170
|
+
interface GetMemoryThreadMessagesParams {
|
|
171
|
+
/**
|
|
172
|
+
* Limit the number of messages to retrieve (default: 40)
|
|
173
|
+
*/
|
|
174
|
+
limit?: number;
|
|
175
|
+
}
|
|
149
176
|
interface GetMemoryThreadMessagesResponse {
|
|
150
177
|
messages: CoreMessage[];
|
|
151
178
|
uiMessages: AiMessageType[];
|
|
@@ -222,6 +249,21 @@ interface GetNetworkResponse {
|
|
|
222
249
|
};
|
|
223
250
|
state?: Record<string, any>;
|
|
224
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
|
+
}
|
|
225
267
|
|
|
226
268
|
declare class BaseResource {
|
|
227
269
|
readonly options: ClientOptions;
|
|
@@ -254,7 +296,9 @@ declare class AgentVoice extends BaseResource {
|
|
|
254
296
|
* @param options - Optional provider-specific options
|
|
255
297
|
* @returns Promise containing the transcribed text
|
|
256
298
|
*/
|
|
257
|
-
listen(audio: Blob, options?: Record<string, any>): Promise<
|
|
299
|
+
listen(audio: Blob, options?: Record<string, any>): Promise<{
|
|
300
|
+
text: string;
|
|
301
|
+
}>;
|
|
258
302
|
/**
|
|
259
303
|
* Get available speakers for the agent's voice provider
|
|
260
304
|
* @returns Promise containing list of available speakers
|
|
@@ -293,6 +337,16 @@ declare class Agent extends BaseResource {
|
|
|
293
337
|
* @returns Promise containing tool details
|
|
294
338
|
*/
|
|
295
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>;
|
|
296
350
|
/**
|
|
297
351
|
* Retrieves evaluation results for the agent
|
|
298
352
|
* @returns Promise containing agent evaluations
|
|
@@ -353,9 +407,10 @@ declare class MemoryThread extends BaseResource {
|
|
|
353
407
|
}>;
|
|
354
408
|
/**
|
|
355
409
|
* Retrieves messages associated with the thread
|
|
410
|
+
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
356
411
|
* @returns Promise containing thread messages and UI messages
|
|
357
412
|
*/
|
|
358
|
-
getMessages(): Promise<GetMemoryThreadMessagesResponse>;
|
|
413
|
+
getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
|
|
359
414
|
}
|
|
360
415
|
|
|
361
416
|
declare class Vector extends BaseResource {
|
|
@@ -404,29 +459,22 @@ declare class Vector extends BaseResource {
|
|
|
404
459
|
query(params: QueryVectorParams): Promise<QueryVectorResponse>;
|
|
405
460
|
}
|
|
406
461
|
|
|
407
|
-
declare class
|
|
462
|
+
declare class LegacyWorkflow extends BaseResource {
|
|
408
463
|
private workflowId;
|
|
409
464
|
constructor(options: ClientOptions, workflowId: string);
|
|
410
465
|
/**
|
|
411
|
-
* Retrieves details about the workflow
|
|
412
|
-
* @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
|
|
413
468
|
*/
|
|
414
|
-
details(): Promise<
|
|
469
|
+
details(): Promise<GetLegacyWorkflowResponse>;
|
|
415
470
|
/**
|
|
416
|
-
* Retrieves all runs for a workflow
|
|
471
|
+
* Retrieves all runs for a legacy workflow
|
|
417
472
|
* @param params - Parameters for filtering runs
|
|
418
|
-
* @returns Promise containing workflow runs array
|
|
473
|
+
* @returns Promise containing legacy workflow runs array
|
|
419
474
|
*/
|
|
420
|
-
runs(params?: GetWorkflowRunsParams): Promise<
|
|
421
|
-
/**
|
|
422
|
-
* @deprecated Use `startAsync` instead
|
|
423
|
-
* Executes the workflow with the provided parameters
|
|
424
|
-
* @param params - Parameters required for workflow execution
|
|
425
|
-
* @returns Promise containing the workflow execution results
|
|
426
|
-
*/
|
|
427
|
-
execute(params: Record<string, any>): Promise<WorkflowRunResult>;
|
|
475
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetLegacyWorkflowRunsResponse>;
|
|
428
476
|
/**
|
|
429
|
-
* Creates a new workflow run
|
|
477
|
+
* Creates a new legacy workflow run
|
|
430
478
|
* @returns Promise containing the generated run ID
|
|
431
479
|
*/
|
|
432
480
|
createRun(params?: {
|
|
@@ -435,7 +483,7 @@ declare class Workflow extends BaseResource {
|
|
|
435
483
|
runId: string;
|
|
436
484
|
}>;
|
|
437
485
|
/**
|
|
438
|
-
* 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
|
|
439
487
|
* @param params - Object containing the runId and triggerData
|
|
440
488
|
* @returns Promise containing success message
|
|
441
489
|
*/
|
|
@@ -446,11 +494,11 @@ declare class Workflow extends BaseResource {
|
|
|
446
494
|
message: string;
|
|
447
495
|
}>;
|
|
448
496
|
/**
|
|
449
|
-
* 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
|
|
450
498
|
* @param stepId - ID of the step to resume
|
|
451
|
-
* @param runId - ID of the workflow run
|
|
452
|
-
* @param context - Context to resume the workflow with
|
|
453
|
-
* @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
|
|
454
502
|
*/
|
|
455
503
|
resume({ stepId, runId, context, }: {
|
|
456
504
|
stepId: string;
|
|
@@ -467,9 +515,9 @@ declare class Workflow extends BaseResource {
|
|
|
467
515
|
startAsync(params: {
|
|
468
516
|
runId?: string;
|
|
469
517
|
triggerData: Record<string, any>;
|
|
470
|
-
}): Promise<
|
|
518
|
+
}): Promise<LegacyWorkflowRunResult>;
|
|
471
519
|
/**
|
|
472
|
-
* 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
|
|
473
521
|
* @param params - Object containing the runId, stepId, and context
|
|
474
522
|
* @returns Promise containing the workflow resume results
|
|
475
523
|
*/
|
|
@@ -477,7 +525,7 @@ declare class Workflow extends BaseResource {
|
|
|
477
525
|
runId: string;
|
|
478
526
|
stepId: string;
|
|
479
527
|
context: Record<string, any>;
|
|
480
|
-
}): Promise<
|
|
528
|
+
}): Promise<LegacyWorkflowRunResult>;
|
|
481
529
|
/**
|
|
482
530
|
* Creates an async generator that processes a readable stream and yields records
|
|
483
531
|
* separated by the Record Separator character (\x1E)
|
|
@@ -487,13 +535,13 @@ declare class Workflow extends BaseResource {
|
|
|
487
535
|
*/
|
|
488
536
|
private streamProcessor;
|
|
489
537
|
/**
|
|
490
|
-
* Watches workflow transitions in real-time
|
|
538
|
+
* Watches legacy workflow transitions in real-time
|
|
491
539
|
* @param runId - Optional run ID to filter the watch stream
|
|
492
|
-
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
540
|
+
* @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
|
|
493
541
|
*/
|
|
494
542
|
watch({ runId }: {
|
|
495
543
|
runId?: string;
|
|
496
|
-
}, onRecord: (record:
|
|
544
|
+
}, onRecord: (record: LegacyWorkflowRunResult) => void): Promise<void>;
|
|
497
545
|
}
|
|
498
546
|
|
|
499
547
|
declare class Tool extends BaseResource {
|
|
@@ -512,14 +560,15 @@ declare class Tool extends BaseResource {
|
|
|
512
560
|
execute(params: {
|
|
513
561
|
data: any;
|
|
514
562
|
runId?: string;
|
|
563
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
515
564
|
}): Promise<any>;
|
|
516
565
|
}
|
|
517
566
|
|
|
518
|
-
declare class
|
|
567
|
+
declare class Workflow extends BaseResource {
|
|
519
568
|
private workflowId;
|
|
520
569
|
constructor(options: ClientOptions, workflowId: string);
|
|
521
570
|
/**
|
|
522
|
-
* 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
|
|
523
572
|
* separated by the Record Separator character (\x1E)
|
|
524
573
|
*
|
|
525
574
|
* @param stream - The readable stream to process
|
|
@@ -527,18 +576,18 @@ declare class VNextWorkflow extends BaseResource {
|
|
|
527
576
|
*/
|
|
528
577
|
private streamProcessor;
|
|
529
578
|
/**
|
|
530
|
-
* Retrieves details about the
|
|
531
|
-
* @returns Promise containing
|
|
579
|
+
* Retrieves details about the workflow
|
|
580
|
+
* @returns Promise containing workflow details including steps and graphs
|
|
532
581
|
*/
|
|
533
|
-
details(): Promise<
|
|
582
|
+
details(): Promise<GetWorkflowResponse>;
|
|
534
583
|
/**
|
|
535
|
-
* Retrieves all runs for a
|
|
584
|
+
* Retrieves all runs for a workflow
|
|
536
585
|
* @param params - Parameters for filtering runs
|
|
537
|
-
* @returns Promise containing
|
|
586
|
+
* @returns Promise containing workflow runs array
|
|
538
587
|
*/
|
|
539
588
|
runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
|
|
540
589
|
/**
|
|
541
|
-
* Creates a new
|
|
590
|
+
* Creates a new workflow run
|
|
542
591
|
* @param params - Optional object containing the optional runId
|
|
543
592
|
* @returns Promise containing the runId of the created run
|
|
544
593
|
*/
|
|
@@ -548,59 +597,142 @@ declare class VNextWorkflow extends BaseResource {
|
|
|
548
597
|
runId: string;
|
|
549
598
|
}>;
|
|
550
599
|
/**
|
|
551
|
-
* Starts a
|
|
600
|
+
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
552
601
|
* @param params - Object containing the runId, inputData and runtimeContext
|
|
553
602
|
* @returns Promise containing success message
|
|
554
603
|
*/
|
|
555
604
|
start(params: {
|
|
556
605
|
runId: string;
|
|
557
606
|
inputData: Record<string, any>;
|
|
558
|
-
runtimeContext?: RuntimeContext
|
|
607
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
559
608
|
}): Promise<{
|
|
560
609
|
message: string;
|
|
561
610
|
}>;
|
|
562
611
|
/**
|
|
563
|
-
* Resumes a suspended
|
|
612
|
+
* Resumes a suspended workflow step synchronously without waiting for the workflow to complete
|
|
564
613
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
565
614
|
* @returns Promise containing success message
|
|
566
615
|
*/
|
|
567
|
-
resume({ step, runId, resumeData,
|
|
616
|
+
resume({ step, runId, resumeData, ...rest }: {
|
|
568
617
|
step: string | string[];
|
|
569
618
|
runId: string;
|
|
570
619
|
resumeData?: Record<string, any>;
|
|
571
|
-
runtimeContext?: RuntimeContext
|
|
620
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
572
621
|
}): Promise<{
|
|
573
622
|
message: string;
|
|
574
623
|
}>;
|
|
575
624
|
/**
|
|
576
|
-
* Starts a
|
|
625
|
+
* Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
|
|
577
626
|
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
578
|
-
* @returns Promise containing the
|
|
627
|
+
* @returns Promise containing the workflow execution results
|
|
579
628
|
*/
|
|
580
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: {
|
|
581
640
|
runId?: string;
|
|
582
641
|
inputData: Record<string, any>;
|
|
583
642
|
runtimeContext?: RuntimeContext;
|
|
584
|
-
}): Promise<
|
|
643
|
+
}): Promise<stream_web.ReadableStream<WorkflowWatchResult>>;
|
|
585
644
|
/**
|
|
586
|
-
* Resumes a suspended
|
|
645
|
+
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
587
646
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
588
|
-
* @returns Promise containing the
|
|
647
|
+
* @returns Promise containing the workflow resume results
|
|
589
648
|
*/
|
|
590
649
|
resumeAsync(params: {
|
|
591
650
|
runId: string;
|
|
592
651
|
step: string | string[];
|
|
593
652
|
resumeData?: Record<string, any>;
|
|
594
|
-
runtimeContext?: RuntimeContext
|
|
595
|
-
}): Promise<
|
|
653
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
654
|
+
}): Promise<WorkflowRunResult>;
|
|
596
655
|
/**
|
|
597
|
-
* Watches
|
|
656
|
+
* Watches workflow transitions in real-time
|
|
598
657
|
* @param runId - Optional run ID to filter the watch stream
|
|
599
|
-
* @returns AsyncGenerator that yields parsed records from the
|
|
658
|
+
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
600
659
|
*/
|
|
601
660
|
watch({ runId }: {
|
|
602
661
|
runId?: string;
|
|
603
|
-
}, 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;
|
|
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;
|
|
735
|
+
}): Promise<any>;
|
|
604
736
|
}
|
|
605
737
|
|
|
606
738
|
declare class MastraClient extends BaseResource {
|
|
@@ -661,6 +793,17 @@ declare class MastraClient extends BaseResource {
|
|
|
661
793
|
* @returns Tool instance
|
|
662
794
|
*/
|
|
663
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;
|
|
664
807
|
/**
|
|
665
808
|
* Retrieves all available workflows
|
|
666
809
|
* @returns Promise containing map of workflow IDs to workflow details
|
|
@@ -672,17 +815,6 @@ declare class MastraClient extends BaseResource {
|
|
|
672
815
|
* @returns Workflow instance
|
|
673
816
|
*/
|
|
674
817
|
getWorkflow(workflowId: string): Workflow;
|
|
675
|
-
/**
|
|
676
|
-
* Retrieves all available vNext workflows
|
|
677
|
-
* @returns Promise containing map of vNext workflow IDs to vNext workflow details
|
|
678
|
-
*/
|
|
679
|
-
getVNextWorkflows(): Promise<Record<string, GetVNextWorkflowResponse>>;
|
|
680
|
-
/**
|
|
681
|
-
* Gets a vNext workflow instance by ID
|
|
682
|
-
* @param workflowId - ID of the vNext workflow to retrieve
|
|
683
|
-
* @returns vNext Workflow instance
|
|
684
|
-
*/
|
|
685
|
-
getVNextWorkflow(workflowId: string): VNextWorkflow;
|
|
686
818
|
/**
|
|
687
819
|
* Gets a vector instance by name
|
|
688
820
|
* @param vectorName - Name of the vector to retrieve
|
|
@@ -725,6 +857,44 @@ declare class MastraClient extends BaseResource {
|
|
|
725
857
|
* @returns Network instance
|
|
726
858
|
*/
|
|
727
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;
|
|
728
898
|
}
|
|
729
899
|
|
|
730
|
-
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 };
|