@mastra/client-js 0.0.0-fix-message-embedding-20250506021742 → 0.0.0-fix-generate-title-20250616171351
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 +469 -2
- package/dist/index.cjs +525 -108
- package/dist/index.d.cts +304 -82
- package/dist/index.d.ts +304 -82
- package/dist/index.js +521 -108
- package/package.json +19 -14
- package/src/adapters/agui.test.ts +19 -6
- package/src/adapters/agui.ts +31 -11
- package/src/client.ts +172 -21
- 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 +48 -35
- 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 +218 -96
- package/src/types.ts +99 -22
- package/src/utils/index.ts +11 -0
- package/src/utils/process-client-tools.ts +31 -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,
|
|
4
|
+
import { CoreMessage, AiMessageType, StorageThreadType, MastraMessageV1, LegacyWorkflowRuns, WorkflowRuns, WorkflowRun, QueryResult, GenerateReturn } from '@mastra/core';
|
|
4
5
|
import { JSONSchema7 } from 'json-schema';
|
|
5
6
|
import { ZodSchema } from 'zod';
|
|
6
|
-
import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
|
|
7
|
-
import {
|
|
7
|
+
import { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
|
|
8
|
+
import { LogLevel, BaseLogMessage } from '@mastra/core/logger';
|
|
8
9
|
import { RuntimeContext } from '@mastra/core/runtime-context';
|
|
10
|
+
import { Workflow as Workflow$1, WatchEvent, WorkflowResult } from '@mastra/core/workflows';
|
|
11
|
+
import { StepAction, StepGraph, LegacyWorkflowRunResult as LegacyWorkflowRunResult$1 } from '@mastra/core/workflows/legacy';
|
|
12
|
+
import * as stream_web from 'stream/web';
|
|
13
|
+
import { AgentCard, TaskSendParams, Task, TaskQueryParams, TaskIdParams } from '@mastra/core/a2a';
|
|
9
14
|
|
|
10
15
|
interface ClientOptions {
|
|
11
16
|
/** Base URL for API requests */
|
|
@@ -26,19 +31,35 @@ 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
|
+
clientTools?: ToolsInput;
|
|
55
|
+
} & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
|
|
39
56
|
type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
40
57
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
41
|
-
|
|
58
|
+
output?: T;
|
|
59
|
+
experimental_output?: T;
|
|
60
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
61
|
+
clientTools?: ToolsInput;
|
|
62
|
+
} & WithoutMethods<Omit<AgentStreamOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
|
|
42
63
|
interface GetEvalsByAgentIdResponse extends GetAgentResponse {
|
|
43
64
|
evals: any[];
|
|
44
65
|
instructions: string;
|
|
@@ -51,7 +72,7 @@ interface GetToolResponse {
|
|
|
51
72
|
inputSchema: string;
|
|
52
73
|
outputSchema: string;
|
|
53
74
|
}
|
|
54
|
-
interface
|
|
75
|
+
interface GetLegacyWorkflowResponse {
|
|
55
76
|
name: string;
|
|
56
77
|
triggerSchema: string;
|
|
57
78
|
steps: Record<string, StepAction<any, any, any, any>>;
|
|
@@ -66,19 +87,23 @@ interface GetWorkflowRunsParams {
|
|
|
66
87
|
offset?: number;
|
|
67
88
|
resourceId?: string;
|
|
68
89
|
}
|
|
90
|
+
type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
|
|
69
91
|
type GetWorkflowRunsResponse = WorkflowRuns;
|
|
70
|
-
type
|
|
92
|
+
type GetWorkflowRunByIdResponse = WorkflowRun;
|
|
93
|
+
type GetWorkflowRunExecutionResultResponse = WatchEvent['payload']['workflowState'];
|
|
94
|
+
type LegacyWorkflowRunResult = {
|
|
71
95
|
activePaths: Record<string, {
|
|
72
96
|
status: string;
|
|
73
97
|
suspendPayload?: any;
|
|
74
98
|
stepPath: string[];
|
|
75
99
|
}>;
|
|
76
|
-
results:
|
|
100
|
+
results: LegacyWorkflowRunResult$1<any, any, any>['results'];
|
|
77
101
|
timestamp: number;
|
|
78
102
|
runId: string;
|
|
79
103
|
};
|
|
80
|
-
interface
|
|
104
|
+
interface GetWorkflowResponse {
|
|
81
105
|
name: string;
|
|
106
|
+
description?: string;
|
|
82
107
|
steps: {
|
|
83
108
|
[key: string]: {
|
|
84
109
|
id: string;
|
|
@@ -89,14 +114,14 @@ interface GetVNextWorkflowResponse {
|
|
|
89
114
|
suspendSchema: string;
|
|
90
115
|
};
|
|
91
116
|
};
|
|
92
|
-
stepGraph:
|
|
117
|
+
stepGraph: Workflow$1['serializedStepGraph'];
|
|
93
118
|
inputSchema: string;
|
|
94
119
|
outputSchema: string;
|
|
95
120
|
}
|
|
96
|
-
type
|
|
121
|
+
type WorkflowWatchResult = WatchEvent & {
|
|
97
122
|
runId: string;
|
|
98
123
|
};
|
|
99
|
-
type
|
|
124
|
+
type WorkflowRunResult = WorkflowResult<any, any>;
|
|
100
125
|
interface UpsertVectorParams {
|
|
101
126
|
indexName: string;
|
|
102
127
|
vectors: number[][];
|
|
@@ -124,15 +149,15 @@ interface GetVectorIndexResponse {
|
|
|
124
149
|
count: number;
|
|
125
150
|
}
|
|
126
151
|
interface SaveMessageToMemoryParams {
|
|
127
|
-
messages:
|
|
152
|
+
messages: MastraMessageV1[];
|
|
128
153
|
agentId: string;
|
|
129
154
|
}
|
|
130
|
-
type SaveMessageToMemoryResponse =
|
|
155
|
+
type SaveMessageToMemoryResponse = MastraMessageV1[];
|
|
131
156
|
interface CreateMemoryThreadParams {
|
|
132
|
-
title
|
|
133
|
-
metadata
|
|
157
|
+
title?: string;
|
|
158
|
+
metadata?: Record<string, any>;
|
|
134
159
|
resourceId: string;
|
|
135
|
-
threadId
|
|
160
|
+
threadId?: string;
|
|
136
161
|
agentId: string;
|
|
137
162
|
}
|
|
138
163
|
type CreateMemoryThreadResponse = StorageThreadType;
|
|
@@ -146,18 +171,42 @@ interface UpdateMemoryThreadParams {
|
|
|
146
171
|
metadata: Record<string, any>;
|
|
147
172
|
resourceId: string;
|
|
148
173
|
}
|
|
174
|
+
interface GetMemoryThreadMessagesParams {
|
|
175
|
+
/**
|
|
176
|
+
* Limit the number of messages to retrieve (default: 40)
|
|
177
|
+
*/
|
|
178
|
+
limit?: number;
|
|
179
|
+
}
|
|
149
180
|
interface GetMemoryThreadMessagesResponse {
|
|
150
181
|
messages: CoreMessage[];
|
|
151
182
|
uiMessages: AiMessageType[];
|
|
152
183
|
}
|
|
153
184
|
interface GetLogsParams {
|
|
154
185
|
transportId: string;
|
|
186
|
+
fromDate?: Date;
|
|
187
|
+
toDate?: Date;
|
|
188
|
+
logLevel?: LogLevel;
|
|
189
|
+
filters?: Record<string, string>;
|
|
190
|
+
page?: number;
|
|
191
|
+
perPage?: number;
|
|
155
192
|
}
|
|
156
193
|
interface GetLogParams {
|
|
157
194
|
runId: string;
|
|
158
195
|
transportId: string;
|
|
196
|
+
fromDate?: Date;
|
|
197
|
+
toDate?: Date;
|
|
198
|
+
logLevel?: LogLevel;
|
|
199
|
+
filters?: Record<string, string>;
|
|
200
|
+
page?: number;
|
|
201
|
+
perPage?: number;
|
|
159
202
|
}
|
|
160
|
-
type GetLogsResponse =
|
|
203
|
+
type GetLogsResponse = {
|
|
204
|
+
logs: BaseLogMessage[];
|
|
205
|
+
total: number;
|
|
206
|
+
page: number;
|
|
207
|
+
perPage: number;
|
|
208
|
+
hasMore: boolean;
|
|
209
|
+
};
|
|
161
210
|
type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
|
|
162
211
|
type SpanStatus = {
|
|
163
212
|
code: number;
|
|
@@ -222,6 +271,21 @@ interface GetNetworkResponse {
|
|
|
222
271
|
};
|
|
223
272
|
state?: Record<string, any>;
|
|
224
273
|
}
|
|
274
|
+
interface McpServerListResponse {
|
|
275
|
+
servers: ServerInfo[];
|
|
276
|
+
next: string | null;
|
|
277
|
+
total_count: number;
|
|
278
|
+
}
|
|
279
|
+
interface McpToolInfo {
|
|
280
|
+
id: string;
|
|
281
|
+
name: string;
|
|
282
|
+
description?: string;
|
|
283
|
+
inputSchema: string;
|
|
284
|
+
toolType?: MCPToolType;
|
|
285
|
+
}
|
|
286
|
+
interface McpServerToolListResponse {
|
|
287
|
+
tools: McpToolInfo[];
|
|
288
|
+
}
|
|
225
289
|
|
|
226
290
|
declare class BaseResource {
|
|
227
291
|
readonly options: ClientOptions;
|
|
@@ -254,7 +318,9 @@ declare class AgentVoice extends BaseResource {
|
|
|
254
318
|
* @param options - Optional provider-specific options
|
|
255
319
|
* @returns Promise containing the transcribed text
|
|
256
320
|
*/
|
|
257
|
-
listen(audio: Blob, options?: Record<string, any>): Promise<
|
|
321
|
+
listen(audio: Blob, options?: Record<string, any>): Promise<{
|
|
322
|
+
text: string;
|
|
323
|
+
}>;
|
|
258
324
|
/**
|
|
259
325
|
* Get available speakers for the agent's voice provider
|
|
260
326
|
* @returns Promise containing list of available speakers
|
|
@@ -263,6 +329,13 @@ declare class AgentVoice extends BaseResource {
|
|
|
263
329
|
voiceId: string;
|
|
264
330
|
[key: string]: any;
|
|
265
331
|
}>>;
|
|
332
|
+
/**
|
|
333
|
+
* Get the listener configuration for the agent's voice provider
|
|
334
|
+
* @returns Promise containing a check if the agent has listening capabilities
|
|
335
|
+
*/
|
|
336
|
+
getListener(): Promise<{
|
|
337
|
+
enabled: boolean;
|
|
338
|
+
}>;
|
|
266
339
|
}
|
|
267
340
|
declare class Agent extends BaseResource {
|
|
268
341
|
private agentId;
|
|
@@ -278,7 +351,18 @@ declare class Agent extends BaseResource {
|
|
|
278
351
|
* @param params - Generation parameters including prompt
|
|
279
352
|
* @returns Promise containing the generated response
|
|
280
353
|
*/
|
|
281
|
-
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>
|
|
354
|
+
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
|
|
355
|
+
output?: never;
|
|
356
|
+
experimental_output?: never;
|
|
357
|
+
}): Promise<GenerateReturn<T>>;
|
|
358
|
+
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
|
|
359
|
+
output: T;
|
|
360
|
+
experimental_output?: never;
|
|
361
|
+
}): Promise<GenerateReturn<T>>;
|
|
362
|
+
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
|
|
363
|
+
output?: never;
|
|
364
|
+
experimental_output: T;
|
|
365
|
+
}): Promise<GenerateReturn<T>>;
|
|
282
366
|
/**
|
|
283
367
|
* Streams a response from the agent
|
|
284
368
|
* @param params - Stream parameters including prompt
|
|
@@ -293,6 +377,16 @@ declare class Agent extends BaseResource {
|
|
|
293
377
|
* @returns Promise containing tool details
|
|
294
378
|
*/
|
|
295
379
|
getTool(toolId: string): Promise<GetToolResponse>;
|
|
380
|
+
/**
|
|
381
|
+
* Executes a tool for the agent
|
|
382
|
+
* @param toolId - ID of the tool to execute
|
|
383
|
+
* @param params - Parameters required for tool execution
|
|
384
|
+
* @returns Promise containing the tool execution results
|
|
385
|
+
*/
|
|
386
|
+
executeTool(toolId: string, params: {
|
|
387
|
+
data: any;
|
|
388
|
+
runtimeContext?: RuntimeContext;
|
|
389
|
+
}): Promise<any>;
|
|
296
390
|
/**
|
|
297
391
|
* Retrieves evaluation results for the agent
|
|
298
392
|
* @returns Promise containing agent evaluations
|
|
@@ -353,9 +447,10 @@ declare class MemoryThread extends BaseResource {
|
|
|
353
447
|
}>;
|
|
354
448
|
/**
|
|
355
449
|
* Retrieves messages associated with the thread
|
|
450
|
+
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
356
451
|
* @returns Promise containing thread messages and UI messages
|
|
357
452
|
*/
|
|
358
|
-
getMessages(): Promise<GetMemoryThreadMessagesResponse>;
|
|
453
|
+
getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
|
|
359
454
|
}
|
|
360
455
|
|
|
361
456
|
declare class Vector extends BaseResource {
|
|
@@ -404,29 +499,22 @@ declare class Vector extends BaseResource {
|
|
|
404
499
|
query(params: QueryVectorParams): Promise<QueryVectorResponse>;
|
|
405
500
|
}
|
|
406
501
|
|
|
407
|
-
declare class
|
|
502
|
+
declare class LegacyWorkflow extends BaseResource {
|
|
408
503
|
private workflowId;
|
|
409
504
|
constructor(options: ClientOptions, workflowId: string);
|
|
410
505
|
/**
|
|
411
|
-
* Retrieves details about the workflow
|
|
412
|
-
* @returns Promise containing workflow details including steps and graphs
|
|
506
|
+
* Retrieves details about the legacy workflow
|
|
507
|
+
* @returns Promise containing legacy workflow details including steps and graphs
|
|
413
508
|
*/
|
|
414
|
-
details(): Promise<
|
|
509
|
+
details(): Promise<GetLegacyWorkflowResponse>;
|
|
415
510
|
/**
|
|
416
|
-
* Retrieves all runs for a workflow
|
|
511
|
+
* Retrieves all runs for a legacy workflow
|
|
417
512
|
* @param params - Parameters for filtering runs
|
|
418
|
-
* @returns Promise containing workflow runs array
|
|
513
|
+
* @returns Promise containing legacy workflow runs array
|
|
419
514
|
*/
|
|
420
|
-
runs(params?: GetWorkflowRunsParams): Promise<
|
|
515
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetLegacyWorkflowRunsResponse>;
|
|
421
516
|
/**
|
|
422
|
-
*
|
|
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>;
|
|
428
|
-
/**
|
|
429
|
-
* Creates a new workflow run
|
|
517
|
+
* Creates a new legacy workflow run
|
|
430
518
|
* @returns Promise containing the generated run ID
|
|
431
519
|
*/
|
|
432
520
|
createRun(params?: {
|
|
@@ -435,7 +523,7 @@ declare class Workflow extends BaseResource {
|
|
|
435
523
|
runId: string;
|
|
436
524
|
}>;
|
|
437
525
|
/**
|
|
438
|
-
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
526
|
+
* Starts a legacy workflow run synchronously without waiting for the workflow to complete
|
|
439
527
|
* @param params - Object containing the runId and triggerData
|
|
440
528
|
* @returns Promise containing success message
|
|
441
529
|
*/
|
|
@@ -446,11 +534,11 @@ declare class Workflow extends BaseResource {
|
|
|
446
534
|
message: string;
|
|
447
535
|
}>;
|
|
448
536
|
/**
|
|
449
|
-
* Resumes a suspended workflow step synchronously without waiting for the workflow to complete
|
|
537
|
+
* Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
|
|
450
538
|
* @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
|
|
539
|
+
* @param runId - ID of the legacy workflow run
|
|
540
|
+
* @param context - Context to resume the legacy workflow with
|
|
541
|
+
* @returns Promise containing the legacy workflow resume results
|
|
454
542
|
*/
|
|
455
543
|
resume({ stepId, runId, context, }: {
|
|
456
544
|
stepId: string;
|
|
@@ -467,9 +555,9 @@ declare class Workflow extends BaseResource {
|
|
|
467
555
|
startAsync(params: {
|
|
468
556
|
runId?: string;
|
|
469
557
|
triggerData: Record<string, any>;
|
|
470
|
-
}): Promise<
|
|
558
|
+
}): Promise<LegacyWorkflowRunResult>;
|
|
471
559
|
/**
|
|
472
|
-
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
560
|
+
* Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
473
561
|
* @param params - Object containing the runId, stepId, and context
|
|
474
562
|
* @returns Promise containing the workflow resume results
|
|
475
563
|
*/
|
|
@@ -477,7 +565,7 @@ declare class Workflow extends BaseResource {
|
|
|
477
565
|
runId: string;
|
|
478
566
|
stepId: string;
|
|
479
567
|
context: Record<string, any>;
|
|
480
|
-
}): Promise<
|
|
568
|
+
}): Promise<LegacyWorkflowRunResult>;
|
|
481
569
|
/**
|
|
482
570
|
* Creates an async generator that processes a readable stream and yields records
|
|
483
571
|
* separated by the Record Separator character (\x1E)
|
|
@@ -487,13 +575,13 @@ declare class Workflow extends BaseResource {
|
|
|
487
575
|
*/
|
|
488
576
|
private streamProcessor;
|
|
489
577
|
/**
|
|
490
|
-
* Watches workflow transitions in real-time
|
|
578
|
+
* Watches legacy workflow transitions in real-time
|
|
491
579
|
* @param runId - Optional run ID to filter the watch stream
|
|
492
|
-
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
580
|
+
* @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
|
|
493
581
|
*/
|
|
494
582
|
watch({ runId }: {
|
|
495
583
|
runId?: string;
|
|
496
|
-
}, onRecord: (record:
|
|
584
|
+
}, onRecord: (record: LegacyWorkflowRunResult) => void): Promise<void>;
|
|
497
585
|
}
|
|
498
586
|
|
|
499
587
|
declare class Tool extends BaseResource {
|
|
@@ -512,14 +600,15 @@ declare class Tool extends BaseResource {
|
|
|
512
600
|
execute(params: {
|
|
513
601
|
data: any;
|
|
514
602
|
runId?: string;
|
|
603
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
515
604
|
}): Promise<any>;
|
|
516
605
|
}
|
|
517
606
|
|
|
518
|
-
declare class
|
|
607
|
+
declare class Workflow extends BaseResource {
|
|
519
608
|
private workflowId;
|
|
520
609
|
constructor(options: ClientOptions, workflowId: string);
|
|
521
610
|
/**
|
|
522
|
-
* Creates an async generator that processes a readable stream and yields
|
|
611
|
+
* Creates an async generator that processes a readable stream and yields workflow records
|
|
523
612
|
* separated by the Record Separator character (\x1E)
|
|
524
613
|
*
|
|
525
614
|
* @param stream - The readable stream to process
|
|
@@ -527,18 +616,30 @@ declare class VNextWorkflow extends BaseResource {
|
|
|
527
616
|
*/
|
|
528
617
|
private streamProcessor;
|
|
529
618
|
/**
|
|
530
|
-
* Retrieves details about the
|
|
531
|
-
* @returns Promise containing
|
|
619
|
+
* Retrieves details about the workflow
|
|
620
|
+
* @returns Promise containing workflow details including steps and graphs
|
|
532
621
|
*/
|
|
533
|
-
details(): Promise<
|
|
622
|
+
details(): Promise<GetWorkflowResponse>;
|
|
534
623
|
/**
|
|
535
|
-
* Retrieves all runs for a
|
|
624
|
+
* Retrieves all runs for a workflow
|
|
536
625
|
* @param params - Parameters for filtering runs
|
|
537
|
-
* @returns Promise containing
|
|
626
|
+
* @returns Promise containing workflow runs array
|
|
538
627
|
*/
|
|
539
628
|
runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
|
|
540
629
|
/**
|
|
541
|
-
*
|
|
630
|
+
* Retrieves a specific workflow run by its ID
|
|
631
|
+
* @param runId - The ID of the workflow run to retrieve
|
|
632
|
+
* @returns Promise containing the workflow run details
|
|
633
|
+
*/
|
|
634
|
+
runById(runId: string): Promise<GetWorkflowRunByIdResponse>;
|
|
635
|
+
/**
|
|
636
|
+
* Retrieves the execution result for a specific workflow run by its ID
|
|
637
|
+
* @param runId - The ID of the workflow run to retrieve the execution result for
|
|
638
|
+
* @returns Promise containing the workflow run execution result
|
|
639
|
+
*/
|
|
640
|
+
runExecutionResult(runId: string): Promise<GetWorkflowRunExecutionResultResponse>;
|
|
641
|
+
/**
|
|
642
|
+
* Creates a new workflow run
|
|
542
643
|
* @param params - Optional object containing the optional runId
|
|
543
644
|
* @returns Promise containing the runId of the created run
|
|
544
645
|
*/
|
|
@@ -548,59 +649,142 @@ declare class VNextWorkflow extends BaseResource {
|
|
|
548
649
|
runId: string;
|
|
549
650
|
}>;
|
|
550
651
|
/**
|
|
551
|
-
* Starts a
|
|
652
|
+
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
552
653
|
* @param params - Object containing the runId, inputData and runtimeContext
|
|
553
654
|
* @returns Promise containing success message
|
|
554
655
|
*/
|
|
555
656
|
start(params: {
|
|
556
657
|
runId: string;
|
|
557
658
|
inputData: Record<string, any>;
|
|
558
|
-
runtimeContext?: RuntimeContext
|
|
659
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
559
660
|
}): Promise<{
|
|
560
661
|
message: string;
|
|
561
662
|
}>;
|
|
562
663
|
/**
|
|
563
|
-
* Resumes a suspended
|
|
664
|
+
* Resumes a suspended workflow step synchronously without waiting for the workflow to complete
|
|
564
665
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
565
666
|
* @returns Promise containing success message
|
|
566
667
|
*/
|
|
567
|
-
resume({ step, runId, resumeData,
|
|
668
|
+
resume({ step, runId, resumeData, ...rest }: {
|
|
568
669
|
step: string | string[];
|
|
569
670
|
runId: string;
|
|
570
671
|
resumeData?: Record<string, any>;
|
|
571
|
-
runtimeContext?: RuntimeContext
|
|
672
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
572
673
|
}): Promise<{
|
|
573
674
|
message: string;
|
|
574
675
|
}>;
|
|
575
676
|
/**
|
|
576
|
-
* Starts a
|
|
677
|
+
* Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
|
|
577
678
|
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
578
|
-
* @returns Promise containing the
|
|
679
|
+
* @returns Promise containing the workflow execution results
|
|
579
680
|
*/
|
|
580
681
|
startAsync(params: {
|
|
682
|
+
runId?: string;
|
|
683
|
+
inputData: Record<string, any>;
|
|
684
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
685
|
+
}): Promise<WorkflowRunResult>;
|
|
686
|
+
/**
|
|
687
|
+
* Starts a vNext workflow run and returns a stream
|
|
688
|
+
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
689
|
+
* @returns Promise containing the vNext workflow execution results
|
|
690
|
+
*/
|
|
691
|
+
stream(params: {
|
|
581
692
|
runId?: string;
|
|
582
693
|
inputData: Record<string, any>;
|
|
583
694
|
runtimeContext?: RuntimeContext;
|
|
584
|
-
}): Promise<
|
|
695
|
+
}): Promise<stream_web.ReadableStream<WorkflowWatchResult>>;
|
|
585
696
|
/**
|
|
586
|
-
* Resumes a suspended
|
|
697
|
+
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
587
698
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
588
|
-
* @returns Promise containing the
|
|
699
|
+
* @returns Promise containing the workflow resume results
|
|
589
700
|
*/
|
|
590
701
|
resumeAsync(params: {
|
|
591
702
|
runId: string;
|
|
592
703
|
step: string | string[];
|
|
593
704
|
resumeData?: Record<string, any>;
|
|
594
|
-
runtimeContext?: RuntimeContext
|
|
595
|
-
}): Promise<
|
|
705
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
706
|
+
}): Promise<WorkflowRunResult>;
|
|
596
707
|
/**
|
|
597
|
-
* Watches
|
|
708
|
+
* Watches workflow transitions in real-time
|
|
598
709
|
* @param runId - Optional run ID to filter the watch stream
|
|
599
|
-
* @returns AsyncGenerator that yields parsed records from the
|
|
710
|
+
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
600
711
|
*/
|
|
601
712
|
watch({ runId }: {
|
|
602
713
|
runId?: string;
|
|
603
|
-
}, onRecord: (record:
|
|
714
|
+
}, onRecord: (record: WorkflowWatchResult) => void): Promise<void>;
|
|
715
|
+
/**
|
|
716
|
+
* Creates a new ReadableStream from an iterable or async iterable of objects,
|
|
717
|
+
* serializing each as JSON and separating them with the record separator (\x1E).
|
|
718
|
+
*
|
|
719
|
+
* @param records - An iterable or async iterable of objects to stream
|
|
720
|
+
* @returns A ReadableStream emitting the records as JSON strings separated by the record separator
|
|
721
|
+
*/
|
|
722
|
+
static createRecordStream(records: Iterable<any> | AsyncIterable<any>): ReadableStream;
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/**
|
|
726
|
+
* Class for interacting with an agent via the A2A protocol
|
|
727
|
+
*/
|
|
728
|
+
declare class A2A extends BaseResource {
|
|
729
|
+
private agentId;
|
|
730
|
+
constructor(options: ClientOptions, agentId: string);
|
|
731
|
+
/**
|
|
732
|
+
* Get the agent card with metadata about the agent
|
|
733
|
+
* @returns Promise containing the agent card information
|
|
734
|
+
*/
|
|
735
|
+
getCard(): Promise<AgentCard>;
|
|
736
|
+
/**
|
|
737
|
+
* Send a message to the agent and get a response
|
|
738
|
+
* @param params - Parameters for the task
|
|
739
|
+
* @returns Promise containing the task response
|
|
740
|
+
*/
|
|
741
|
+
sendMessage(params: TaskSendParams): Promise<{
|
|
742
|
+
task: Task;
|
|
743
|
+
}>;
|
|
744
|
+
/**
|
|
745
|
+
* Get the status and result of a task
|
|
746
|
+
* @param params - Parameters for querying the task
|
|
747
|
+
* @returns Promise containing the task response
|
|
748
|
+
*/
|
|
749
|
+
getTask(params: TaskQueryParams): Promise<Task>;
|
|
750
|
+
/**
|
|
751
|
+
* Cancel a running task
|
|
752
|
+
* @param params - Parameters identifying the task to cancel
|
|
753
|
+
* @returns Promise containing the task response
|
|
754
|
+
*/
|
|
755
|
+
cancelTask(params: TaskIdParams): Promise<{
|
|
756
|
+
task: Task;
|
|
757
|
+
}>;
|
|
758
|
+
/**
|
|
759
|
+
* Send a message and subscribe to streaming updates (not fully implemented)
|
|
760
|
+
* @param params - Parameters for the task
|
|
761
|
+
* @returns Promise containing the task response
|
|
762
|
+
*/
|
|
763
|
+
sendAndSubscribe(params: TaskSendParams): Promise<Response>;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Represents a specific tool available on a specific MCP server.
|
|
768
|
+
* Provides methods to get details and execute the tool.
|
|
769
|
+
*/
|
|
770
|
+
declare class MCPTool extends BaseResource {
|
|
771
|
+
private serverId;
|
|
772
|
+
private toolId;
|
|
773
|
+
constructor(options: ClientOptions, serverId: string, toolId: string);
|
|
774
|
+
/**
|
|
775
|
+
* Retrieves details about this specific tool from the MCP server.
|
|
776
|
+
* @returns Promise containing the tool's information (name, description, schema).
|
|
777
|
+
*/
|
|
778
|
+
details(): Promise<McpToolInfo>;
|
|
779
|
+
/**
|
|
780
|
+
* Executes this specific tool on the MCP server.
|
|
781
|
+
* @param params - Parameters for tool execution, including data/args and optional runtimeContext.
|
|
782
|
+
* @returns Promise containing the result of the tool execution.
|
|
783
|
+
*/
|
|
784
|
+
execute(params: {
|
|
785
|
+
data?: any;
|
|
786
|
+
runtimeContext?: RuntimeContext;
|
|
787
|
+
}): Promise<any>;
|
|
604
788
|
}
|
|
605
789
|
|
|
606
790
|
declare class MastraClient extends BaseResource {
|
|
@@ -661,6 +845,17 @@ declare class MastraClient extends BaseResource {
|
|
|
661
845
|
* @returns Tool instance
|
|
662
846
|
*/
|
|
663
847
|
getTool(toolId: string): Tool;
|
|
848
|
+
/**
|
|
849
|
+
* Retrieves all available legacy workflows
|
|
850
|
+
* @returns Promise containing map of legacy workflow IDs to legacy workflow details
|
|
851
|
+
*/
|
|
852
|
+
getLegacyWorkflows(): Promise<Record<string, GetLegacyWorkflowResponse>>;
|
|
853
|
+
/**
|
|
854
|
+
* Gets a legacy workflow instance by ID
|
|
855
|
+
* @param workflowId - ID of the legacy workflow to retrieve
|
|
856
|
+
* @returns Legacy Workflow instance
|
|
857
|
+
*/
|
|
858
|
+
getLegacyWorkflow(workflowId: string): LegacyWorkflow;
|
|
664
859
|
/**
|
|
665
860
|
* Retrieves all available workflows
|
|
666
861
|
* @returns Promise containing map of workflow IDs to workflow details
|
|
@@ -672,17 +867,6 @@ declare class MastraClient extends BaseResource {
|
|
|
672
867
|
* @returns Workflow instance
|
|
673
868
|
*/
|
|
674
869
|
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
870
|
/**
|
|
687
871
|
* Gets a vector instance by name
|
|
688
872
|
* @param vectorName - Name of the vector to retrieve
|
|
@@ -725,6 +909,44 @@ declare class MastraClient extends BaseResource {
|
|
|
725
909
|
* @returns Network instance
|
|
726
910
|
*/
|
|
727
911
|
getNetwork(networkId: string): Network;
|
|
912
|
+
/**
|
|
913
|
+
* Retrieves a list of available MCP servers.
|
|
914
|
+
* @param params - Optional parameters for pagination (limit, offset).
|
|
915
|
+
* @returns Promise containing the list of MCP servers and pagination info.
|
|
916
|
+
*/
|
|
917
|
+
getMcpServers(params?: {
|
|
918
|
+
limit?: number;
|
|
919
|
+
offset?: number;
|
|
920
|
+
}): Promise<McpServerListResponse>;
|
|
921
|
+
/**
|
|
922
|
+
* Retrieves detailed information for a specific MCP server.
|
|
923
|
+
* @param serverId - The ID of the MCP server to retrieve.
|
|
924
|
+
* @param params - Optional parameters, e.g., specific version.
|
|
925
|
+
* @returns Promise containing the detailed MCP server information.
|
|
926
|
+
*/
|
|
927
|
+
getMcpServerDetails(serverId: string, params?: {
|
|
928
|
+
version?: string;
|
|
929
|
+
}): Promise<ServerDetailInfo>;
|
|
930
|
+
/**
|
|
931
|
+
* Retrieves a list of tools for a specific MCP server.
|
|
932
|
+
* @param serverId - The ID of the MCP server.
|
|
933
|
+
* @returns Promise containing the list of tools.
|
|
934
|
+
*/
|
|
935
|
+
getMcpServerTools(serverId: string): Promise<McpServerToolListResponse>;
|
|
936
|
+
/**
|
|
937
|
+
* Gets an MCPTool resource instance for a specific tool on an MCP server.
|
|
938
|
+
* This instance can then be used to fetch details or execute the tool.
|
|
939
|
+
* @param serverId - The ID of the MCP server.
|
|
940
|
+
* @param toolId - The ID of the tool.
|
|
941
|
+
* @returns MCPTool instance.
|
|
942
|
+
*/
|
|
943
|
+
getMcpServerTool(serverId: string, toolId: string): MCPTool;
|
|
944
|
+
/**
|
|
945
|
+
* Gets an A2A client for interacting with an agent via the A2A protocol
|
|
946
|
+
* @param agentId - ID of the agent to interact with
|
|
947
|
+
* @returns A2A client instance
|
|
948
|
+
*/
|
|
949
|
+
getA2A(agentId: string): A2A;
|
|
728
950
|
}
|
|
729
951
|
|
|
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
|
|
952
|
+
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 GetWorkflowRunByIdResponse, type GetWorkflowRunExecutionResultResponse, 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 };
|