@mastra/client-js 0.0.0-agui-20250501191909 → 0.0.0-cli-debug-20250611094457
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 +465 -2
- package/dist/index.cjs +558 -109
- package/dist/index.d.cts +304 -98
- package/dist/index.d.ts +304 -98
- package/dist/index.js +554 -109
- package/package.json +9 -9
- package/src/adapters/agui.test.ts +19 -6
- package/src/adapters/agui.ts +31 -11
- package/src/client.ts +182 -24
- 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} +140 -132
- 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 +230 -100
- package/src/types.ts +104 -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,12 +1,16 @@
|
|
|
1
|
-
import { AbstractAgent
|
|
2
|
-
import {
|
|
1
|
+
import { AbstractAgent } from '@ag-ui/client';
|
|
2
|
+
import { ServerInfo, MCPToolType, ServerDetailInfo } from '@mastra/core/mcp';
|
|
3
3
|
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
4
|
-
import { CoreMessage, AiMessageType, StorageThreadType,
|
|
4
|
+
import { CoreMessage, AiMessageType, StorageThreadType, MastraMessageV1, LegacyWorkflowRuns, WorkflowRuns, QueryResult, GenerateReturn } from '@mastra/core';
|
|
5
5
|
import { JSONSchema7 } from 'json-schema';
|
|
6
6
|
import { ZodSchema } from 'zod';
|
|
7
|
-
import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
|
|
8
|
-
import {
|
|
7
|
+
import { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
|
|
8
|
+
import { LogLevel, BaseLogMessage } from '@mastra/core/logger';
|
|
9
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';
|
|
10
14
|
|
|
11
15
|
interface ClientOptions {
|
|
12
16
|
/** Base URL for API requests */
|
|
@@ -27,19 +31,35 @@ interface RequestOptions {
|
|
|
27
31
|
stream?: boolean;
|
|
28
32
|
signal?: AbortSignal;
|
|
29
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
|
+
};
|
|
30
39
|
interface GetAgentResponse {
|
|
31
40
|
name: string;
|
|
32
41
|
instructions: string;
|
|
33
42
|
tools: Record<string, GetToolResponse>;
|
|
43
|
+
workflows: Record<string, GetWorkflowResponse>;
|
|
34
44
|
provider: string;
|
|
35
45
|
modelId: string;
|
|
46
|
+
defaultGenerateOptions: WithoutMethods<AgentGenerateOptions>;
|
|
47
|
+
defaultStreamOptions: WithoutMethods<AgentStreamOptions>;
|
|
36
48
|
}
|
|
37
49
|
type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
38
50
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
39
|
-
|
|
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'>>;
|
|
40
56
|
type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
41
57
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
42
|
-
|
|
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'>>;
|
|
43
63
|
interface GetEvalsByAgentIdResponse extends GetAgentResponse {
|
|
44
64
|
evals: any[];
|
|
45
65
|
instructions: string;
|
|
@@ -52,7 +72,7 @@ interface GetToolResponse {
|
|
|
52
72
|
inputSchema: string;
|
|
53
73
|
outputSchema: string;
|
|
54
74
|
}
|
|
55
|
-
interface
|
|
75
|
+
interface GetLegacyWorkflowResponse {
|
|
56
76
|
name: string;
|
|
57
77
|
triggerSchema: string;
|
|
58
78
|
steps: Record<string, StepAction<any, any, any, any>>;
|
|
@@ -60,19 +80,28 @@ interface GetWorkflowResponse {
|
|
|
60
80
|
stepSubscriberGraph: Record<string, StepGraph>;
|
|
61
81
|
workflowId?: string;
|
|
62
82
|
}
|
|
83
|
+
interface GetWorkflowRunsParams {
|
|
84
|
+
fromDate?: Date;
|
|
85
|
+
toDate?: Date;
|
|
86
|
+
limit?: number;
|
|
87
|
+
offset?: number;
|
|
88
|
+
resourceId?: string;
|
|
89
|
+
}
|
|
90
|
+
type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
|
|
63
91
|
type GetWorkflowRunsResponse = WorkflowRuns;
|
|
64
|
-
type
|
|
92
|
+
type LegacyWorkflowRunResult = {
|
|
65
93
|
activePaths: Record<string, {
|
|
66
94
|
status: string;
|
|
67
95
|
suspendPayload?: any;
|
|
68
96
|
stepPath: string[];
|
|
69
97
|
}>;
|
|
70
|
-
results:
|
|
98
|
+
results: LegacyWorkflowRunResult$1<any, any, any>['results'];
|
|
71
99
|
timestamp: number;
|
|
72
100
|
runId: string;
|
|
73
101
|
};
|
|
74
|
-
interface
|
|
102
|
+
interface GetWorkflowResponse {
|
|
75
103
|
name: string;
|
|
104
|
+
description?: string;
|
|
76
105
|
steps: {
|
|
77
106
|
[key: string]: {
|
|
78
107
|
id: string;
|
|
@@ -83,14 +112,14 @@ interface GetVNextWorkflowResponse {
|
|
|
83
112
|
suspendSchema: string;
|
|
84
113
|
};
|
|
85
114
|
};
|
|
86
|
-
stepGraph:
|
|
115
|
+
stepGraph: Workflow$1['serializedStepGraph'];
|
|
87
116
|
inputSchema: string;
|
|
88
117
|
outputSchema: string;
|
|
89
118
|
}
|
|
90
|
-
type
|
|
119
|
+
type WorkflowWatchResult = WatchEvent & {
|
|
91
120
|
runId: string;
|
|
92
121
|
};
|
|
93
|
-
type
|
|
122
|
+
type WorkflowRunResult = WorkflowResult<any, any>;
|
|
94
123
|
interface UpsertVectorParams {
|
|
95
124
|
indexName: string;
|
|
96
125
|
vectors: number[][];
|
|
@@ -118,15 +147,15 @@ interface GetVectorIndexResponse {
|
|
|
118
147
|
count: number;
|
|
119
148
|
}
|
|
120
149
|
interface SaveMessageToMemoryParams {
|
|
121
|
-
messages:
|
|
150
|
+
messages: MastraMessageV1[];
|
|
122
151
|
agentId: string;
|
|
123
152
|
}
|
|
124
|
-
type SaveMessageToMemoryResponse =
|
|
153
|
+
type SaveMessageToMemoryResponse = MastraMessageV1[];
|
|
125
154
|
interface CreateMemoryThreadParams {
|
|
126
|
-
title
|
|
127
|
-
metadata
|
|
155
|
+
title?: string;
|
|
156
|
+
metadata?: Record<string, any>;
|
|
128
157
|
resourceId: string;
|
|
129
|
-
threadId
|
|
158
|
+
threadId?: string;
|
|
130
159
|
agentId: string;
|
|
131
160
|
}
|
|
132
161
|
type CreateMemoryThreadResponse = StorageThreadType;
|
|
@@ -140,18 +169,42 @@ interface UpdateMemoryThreadParams {
|
|
|
140
169
|
metadata: Record<string, any>;
|
|
141
170
|
resourceId: string;
|
|
142
171
|
}
|
|
172
|
+
interface GetMemoryThreadMessagesParams {
|
|
173
|
+
/**
|
|
174
|
+
* Limit the number of messages to retrieve (default: 40)
|
|
175
|
+
*/
|
|
176
|
+
limit?: number;
|
|
177
|
+
}
|
|
143
178
|
interface GetMemoryThreadMessagesResponse {
|
|
144
179
|
messages: CoreMessage[];
|
|
145
180
|
uiMessages: AiMessageType[];
|
|
146
181
|
}
|
|
147
182
|
interface GetLogsParams {
|
|
148
183
|
transportId: string;
|
|
184
|
+
fromDate?: Date;
|
|
185
|
+
toDate?: Date;
|
|
186
|
+
logLevel?: LogLevel;
|
|
187
|
+
filters?: Record<string, string>;
|
|
188
|
+
page?: number;
|
|
189
|
+
perPage?: number;
|
|
149
190
|
}
|
|
150
191
|
interface GetLogParams {
|
|
151
192
|
runId: string;
|
|
152
193
|
transportId: string;
|
|
194
|
+
fromDate?: Date;
|
|
195
|
+
toDate?: Date;
|
|
196
|
+
logLevel?: LogLevel;
|
|
197
|
+
filters?: Record<string, string>;
|
|
198
|
+
page?: number;
|
|
199
|
+
perPage?: number;
|
|
153
200
|
}
|
|
154
|
-
type GetLogsResponse =
|
|
201
|
+
type GetLogsResponse = {
|
|
202
|
+
logs: BaseLogMessage[];
|
|
203
|
+
total: number;
|
|
204
|
+
page: number;
|
|
205
|
+
perPage: number;
|
|
206
|
+
hasMore: boolean;
|
|
207
|
+
};
|
|
155
208
|
type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
|
|
156
209
|
type SpanStatus = {
|
|
157
210
|
code: number;
|
|
@@ -199,6 +252,8 @@ interface GetTelemetryParams {
|
|
|
199
252
|
page?: number;
|
|
200
253
|
perPage?: number;
|
|
201
254
|
attribute?: Record<string, string>;
|
|
255
|
+
fromDate?: Date;
|
|
256
|
+
toDate?: Date;
|
|
202
257
|
}
|
|
203
258
|
interface GetNetworkResponse {
|
|
204
259
|
name: string;
|
|
@@ -214,6 +269,21 @@ interface GetNetworkResponse {
|
|
|
214
269
|
};
|
|
215
270
|
state?: Record<string, any>;
|
|
216
271
|
}
|
|
272
|
+
interface McpServerListResponse {
|
|
273
|
+
servers: ServerInfo[];
|
|
274
|
+
next: string | null;
|
|
275
|
+
total_count: number;
|
|
276
|
+
}
|
|
277
|
+
interface McpToolInfo {
|
|
278
|
+
id: string;
|
|
279
|
+
name: string;
|
|
280
|
+
description?: string;
|
|
281
|
+
inputSchema: string;
|
|
282
|
+
toolType?: MCPToolType;
|
|
283
|
+
}
|
|
284
|
+
interface McpServerToolListResponse {
|
|
285
|
+
tools: McpToolInfo[];
|
|
286
|
+
}
|
|
217
287
|
|
|
218
288
|
declare class BaseResource {
|
|
219
289
|
readonly options: ClientOptions;
|
|
@@ -246,7 +316,9 @@ declare class AgentVoice extends BaseResource {
|
|
|
246
316
|
* @param options - Optional provider-specific options
|
|
247
317
|
* @returns Promise containing the transcribed text
|
|
248
318
|
*/
|
|
249
|
-
listen(audio: Blob, options?: Record<string, any>): Promise<
|
|
319
|
+
listen(audio: Blob, options?: Record<string, any>): Promise<{
|
|
320
|
+
text: string;
|
|
321
|
+
}>;
|
|
250
322
|
/**
|
|
251
323
|
* Get available speakers for the agent's voice provider
|
|
252
324
|
* @returns Promise containing list of available speakers
|
|
@@ -255,6 +327,13 @@ declare class AgentVoice extends BaseResource {
|
|
|
255
327
|
voiceId: string;
|
|
256
328
|
[key: string]: any;
|
|
257
329
|
}>>;
|
|
330
|
+
/**
|
|
331
|
+
* Get the listener configuration for the agent's voice provider
|
|
332
|
+
* @returns Promise containing a check if the agent has listening capabilities
|
|
333
|
+
*/
|
|
334
|
+
getListener(): Promise<{
|
|
335
|
+
enabled: boolean;
|
|
336
|
+
}>;
|
|
258
337
|
}
|
|
259
338
|
declare class Agent extends BaseResource {
|
|
260
339
|
private agentId;
|
|
@@ -270,7 +349,18 @@ declare class Agent extends BaseResource {
|
|
|
270
349
|
* @param params - Generation parameters including prompt
|
|
271
350
|
* @returns Promise containing the generated response
|
|
272
351
|
*/
|
|
273
|
-
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T>
|
|
352
|
+
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
|
|
353
|
+
output?: never;
|
|
354
|
+
experimental_output?: never;
|
|
355
|
+
}): Promise<GenerateReturn<T>>;
|
|
356
|
+
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
|
|
357
|
+
output: T;
|
|
358
|
+
experimental_output?: never;
|
|
359
|
+
}): Promise<GenerateReturn<T>>;
|
|
360
|
+
generate<T extends JSONSchema7 | ZodSchema | undefined = undefined>(params: GenerateParams<T> & {
|
|
361
|
+
output?: never;
|
|
362
|
+
experimental_output: T;
|
|
363
|
+
}): Promise<GenerateReturn<T>>;
|
|
274
364
|
/**
|
|
275
365
|
* Streams a response from the agent
|
|
276
366
|
* @param params - Stream parameters including prompt
|
|
@@ -285,6 +375,16 @@ declare class Agent extends BaseResource {
|
|
|
285
375
|
* @returns Promise containing tool details
|
|
286
376
|
*/
|
|
287
377
|
getTool(toolId: string): Promise<GetToolResponse>;
|
|
378
|
+
/**
|
|
379
|
+
* Executes a tool for the agent
|
|
380
|
+
* @param toolId - ID of the tool to execute
|
|
381
|
+
* @param params - Parameters required for tool execution
|
|
382
|
+
* @returns Promise containing the tool execution results
|
|
383
|
+
*/
|
|
384
|
+
executeTool(toolId: string, params: {
|
|
385
|
+
data: any;
|
|
386
|
+
runtimeContext?: RuntimeContext;
|
|
387
|
+
}): Promise<any>;
|
|
288
388
|
/**
|
|
289
389
|
* Retrieves evaluation results for the agent
|
|
290
390
|
* @returns Promise containing agent evaluations
|
|
@@ -297,18 +397,6 @@ declare class Agent extends BaseResource {
|
|
|
297
397
|
liveEvals(): Promise<GetEvalsByAgentIdResponse>;
|
|
298
398
|
}
|
|
299
399
|
|
|
300
|
-
interface MastraAgentConfig extends AgentConfig {
|
|
301
|
-
agent: Agent;
|
|
302
|
-
agentId: string;
|
|
303
|
-
resourceId?: string;
|
|
304
|
-
}
|
|
305
|
-
declare class AGUIAdapter extends AbstractAgent {
|
|
306
|
-
agent: Agent;
|
|
307
|
-
resourceId?: string;
|
|
308
|
-
constructor({ agent, agentId, resourceId, ...rest }: MastraAgentConfig);
|
|
309
|
-
protected run(input: RunAgentInput): Observable<BaseEvent>;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
400
|
declare class Network extends BaseResource {
|
|
313
401
|
private networkId;
|
|
314
402
|
constructor(options: ClientOptions, networkId: string);
|
|
@@ -357,9 +445,10 @@ declare class MemoryThread extends BaseResource {
|
|
|
357
445
|
}>;
|
|
358
446
|
/**
|
|
359
447
|
* Retrieves messages associated with the thread
|
|
448
|
+
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
360
449
|
* @returns Promise containing thread messages and UI messages
|
|
361
450
|
*/
|
|
362
|
-
getMessages(): Promise<GetMemoryThreadMessagesResponse>;
|
|
451
|
+
getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
|
|
363
452
|
}
|
|
364
453
|
|
|
365
454
|
declare class Vector extends BaseResource {
|
|
@@ -408,28 +497,22 @@ declare class Vector extends BaseResource {
|
|
|
408
497
|
query(params: QueryVectorParams): Promise<QueryVectorResponse>;
|
|
409
498
|
}
|
|
410
499
|
|
|
411
|
-
declare class
|
|
500
|
+
declare class LegacyWorkflow extends BaseResource {
|
|
412
501
|
private workflowId;
|
|
413
502
|
constructor(options: ClientOptions, workflowId: string);
|
|
414
503
|
/**
|
|
415
|
-
* Retrieves details about the workflow
|
|
416
|
-
* @returns Promise containing workflow details including steps and graphs
|
|
504
|
+
* Retrieves details about the legacy workflow
|
|
505
|
+
* @returns Promise containing legacy workflow details including steps and graphs
|
|
417
506
|
*/
|
|
418
|
-
details(): Promise<
|
|
419
|
-
/**
|
|
420
|
-
* Retrieves all runs for a workflow
|
|
421
|
-
* @returns Promise containing workflow runs array
|
|
422
|
-
*/
|
|
423
|
-
runs(): Promise<GetWorkflowRunsResponse>;
|
|
507
|
+
details(): Promise<GetLegacyWorkflowResponse>;
|
|
424
508
|
/**
|
|
425
|
-
*
|
|
426
|
-
*
|
|
427
|
-
* @
|
|
428
|
-
* @returns Promise containing the workflow execution results
|
|
509
|
+
* Retrieves all runs for a legacy workflow
|
|
510
|
+
* @param params - Parameters for filtering runs
|
|
511
|
+
* @returns Promise containing legacy workflow runs array
|
|
429
512
|
*/
|
|
430
|
-
|
|
513
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetLegacyWorkflowRunsResponse>;
|
|
431
514
|
/**
|
|
432
|
-
* Creates a new workflow run
|
|
515
|
+
* Creates a new legacy workflow run
|
|
433
516
|
* @returns Promise containing the generated run ID
|
|
434
517
|
*/
|
|
435
518
|
createRun(params?: {
|
|
@@ -438,7 +521,7 @@ declare class Workflow extends BaseResource {
|
|
|
438
521
|
runId: string;
|
|
439
522
|
}>;
|
|
440
523
|
/**
|
|
441
|
-
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
524
|
+
* Starts a legacy workflow run synchronously without waiting for the workflow to complete
|
|
442
525
|
* @param params - Object containing the runId and triggerData
|
|
443
526
|
* @returns Promise containing success message
|
|
444
527
|
*/
|
|
@@ -449,11 +532,11 @@ declare class Workflow extends BaseResource {
|
|
|
449
532
|
message: string;
|
|
450
533
|
}>;
|
|
451
534
|
/**
|
|
452
|
-
* Resumes a suspended workflow step synchronously without waiting for the workflow to complete
|
|
535
|
+
* Resumes a suspended legacy workflow step synchronously without waiting for the workflow to complete
|
|
453
536
|
* @param stepId - ID of the step to resume
|
|
454
|
-
* @param runId - ID of the workflow run
|
|
455
|
-
* @param context - Context to resume the workflow with
|
|
456
|
-
* @returns Promise containing the workflow resume results
|
|
537
|
+
* @param runId - ID of the legacy workflow run
|
|
538
|
+
* @param context - Context to resume the legacy workflow with
|
|
539
|
+
* @returns Promise containing the legacy workflow resume results
|
|
457
540
|
*/
|
|
458
541
|
resume({ stepId, runId, context, }: {
|
|
459
542
|
stepId: string;
|
|
@@ -470,9 +553,9 @@ declare class Workflow extends BaseResource {
|
|
|
470
553
|
startAsync(params: {
|
|
471
554
|
runId?: string;
|
|
472
555
|
triggerData: Record<string, any>;
|
|
473
|
-
}): Promise<
|
|
556
|
+
}): Promise<LegacyWorkflowRunResult>;
|
|
474
557
|
/**
|
|
475
|
-
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
558
|
+
* Resumes a suspended legacy workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
476
559
|
* @param params - Object containing the runId, stepId, and context
|
|
477
560
|
* @returns Promise containing the workflow resume results
|
|
478
561
|
*/
|
|
@@ -480,7 +563,7 @@ declare class Workflow extends BaseResource {
|
|
|
480
563
|
runId: string;
|
|
481
564
|
stepId: string;
|
|
482
565
|
context: Record<string, any>;
|
|
483
|
-
}): Promise<
|
|
566
|
+
}): Promise<LegacyWorkflowRunResult>;
|
|
484
567
|
/**
|
|
485
568
|
* Creates an async generator that processes a readable stream and yields records
|
|
486
569
|
* separated by the Record Separator character (\x1E)
|
|
@@ -490,13 +573,13 @@ declare class Workflow extends BaseResource {
|
|
|
490
573
|
*/
|
|
491
574
|
private streamProcessor;
|
|
492
575
|
/**
|
|
493
|
-
* Watches workflow transitions in real-time
|
|
576
|
+
* Watches legacy workflow transitions in real-time
|
|
494
577
|
* @param runId - Optional run ID to filter the watch stream
|
|
495
|
-
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
578
|
+
* @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
|
|
496
579
|
*/
|
|
497
580
|
watch({ runId }: {
|
|
498
581
|
runId?: string;
|
|
499
|
-
}, onRecord: (record:
|
|
582
|
+
}, onRecord: (record: LegacyWorkflowRunResult) => void): Promise<void>;
|
|
500
583
|
}
|
|
501
584
|
|
|
502
585
|
declare class Tool extends BaseResource {
|
|
@@ -515,14 +598,15 @@ declare class Tool extends BaseResource {
|
|
|
515
598
|
execute(params: {
|
|
516
599
|
data: any;
|
|
517
600
|
runId?: string;
|
|
601
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
518
602
|
}): Promise<any>;
|
|
519
603
|
}
|
|
520
604
|
|
|
521
|
-
declare class
|
|
605
|
+
declare class Workflow extends BaseResource {
|
|
522
606
|
private workflowId;
|
|
523
607
|
constructor(options: ClientOptions, workflowId: string);
|
|
524
608
|
/**
|
|
525
|
-
* Creates an async generator that processes a readable stream and yields
|
|
609
|
+
* Creates an async generator that processes a readable stream and yields workflow records
|
|
526
610
|
* separated by the Record Separator character (\x1E)
|
|
527
611
|
*
|
|
528
612
|
* @param stream - The readable stream to process
|
|
@@ -530,17 +614,18 @@ declare class VNextWorkflow extends BaseResource {
|
|
|
530
614
|
*/
|
|
531
615
|
private streamProcessor;
|
|
532
616
|
/**
|
|
533
|
-
* Retrieves details about the
|
|
534
|
-
* @returns Promise containing
|
|
617
|
+
* Retrieves details about the workflow
|
|
618
|
+
* @returns Promise containing workflow details including steps and graphs
|
|
535
619
|
*/
|
|
536
|
-
details(): Promise<
|
|
620
|
+
details(): Promise<GetWorkflowResponse>;
|
|
537
621
|
/**
|
|
538
|
-
* Retrieves all runs for a
|
|
539
|
-
* @
|
|
622
|
+
* Retrieves all runs for a workflow
|
|
623
|
+
* @param params - Parameters for filtering runs
|
|
624
|
+
* @returns Promise containing workflow runs array
|
|
540
625
|
*/
|
|
541
|
-
runs(): Promise<GetWorkflowRunsResponse>;
|
|
626
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
|
|
542
627
|
/**
|
|
543
|
-
* Creates a new
|
|
628
|
+
* Creates a new workflow run
|
|
544
629
|
* @param params - Optional object containing the optional runId
|
|
545
630
|
* @returns Promise containing the runId of the created run
|
|
546
631
|
*/
|
|
@@ -550,59 +635,142 @@ declare class VNextWorkflow extends BaseResource {
|
|
|
550
635
|
runId: string;
|
|
551
636
|
}>;
|
|
552
637
|
/**
|
|
553
|
-
* Starts a
|
|
638
|
+
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
554
639
|
* @param params - Object containing the runId, inputData and runtimeContext
|
|
555
640
|
* @returns Promise containing success message
|
|
556
641
|
*/
|
|
557
642
|
start(params: {
|
|
558
643
|
runId: string;
|
|
559
644
|
inputData: Record<string, any>;
|
|
560
|
-
runtimeContext?: RuntimeContext
|
|
645
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
561
646
|
}): Promise<{
|
|
562
647
|
message: string;
|
|
563
648
|
}>;
|
|
564
649
|
/**
|
|
565
|
-
* Resumes a suspended
|
|
650
|
+
* Resumes a suspended workflow step synchronously without waiting for the workflow to complete
|
|
566
651
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
567
652
|
* @returns Promise containing success message
|
|
568
653
|
*/
|
|
569
|
-
resume({ step, runId, resumeData,
|
|
654
|
+
resume({ step, runId, resumeData, ...rest }: {
|
|
570
655
|
step: string | string[];
|
|
571
656
|
runId: string;
|
|
572
657
|
resumeData?: Record<string, any>;
|
|
573
|
-
runtimeContext?: RuntimeContext
|
|
658
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
574
659
|
}): Promise<{
|
|
575
660
|
message: string;
|
|
576
661
|
}>;
|
|
577
662
|
/**
|
|
578
|
-
* Starts a
|
|
663
|
+
* Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
|
|
579
664
|
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
580
|
-
* @returns Promise containing the
|
|
665
|
+
* @returns Promise containing the workflow execution results
|
|
581
666
|
*/
|
|
582
667
|
startAsync(params: {
|
|
668
|
+
runId?: string;
|
|
669
|
+
inputData: Record<string, any>;
|
|
670
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
671
|
+
}): Promise<WorkflowRunResult>;
|
|
672
|
+
/**
|
|
673
|
+
* Starts a vNext workflow run and returns a stream
|
|
674
|
+
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
675
|
+
* @returns Promise containing the vNext workflow execution results
|
|
676
|
+
*/
|
|
677
|
+
stream(params: {
|
|
583
678
|
runId?: string;
|
|
584
679
|
inputData: Record<string, any>;
|
|
585
680
|
runtimeContext?: RuntimeContext;
|
|
586
|
-
}): Promise<
|
|
681
|
+
}): Promise<stream_web.ReadableStream<WorkflowWatchResult>>;
|
|
587
682
|
/**
|
|
588
|
-
* Resumes a suspended
|
|
683
|
+
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
589
684
|
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
590
|
-
* @returns Promise containing the
|
|
685
|
+
* @returns Promise containing the workflow resume results
|
|
591
686
|
*/
|
|
592
687
|
resumeAsync(params: {
|
|
593
688
|
runId: string;
|
|
594
689
|
step: string | string[];
|
|
595
690
|
resumeData?: Record<string, any>;
|
|
596
|
-
runtimeContext?: RuntimeContext
|
|
597
|
-
}): Promise<
|
|
691
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
692
|
+
}): Promise<WorkflowRunResult>;
|
|
598
693
|
/**
|
|
599
|
-
* Watches
|
|
694
|
+
* Watches workflow transitions in real-time
|
|
600
695
|
* @param runId - Optional run ID to filter the watch stream
|
|
601
|
-
* @returns AsyncGenerator that yields parsed records from the
|
|
696
|
+
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
602
697
|
*/
|
|
603
698
|
watch({ runId }: {
|
|
604
699
|
runId?: string;
|
|
605
|
-
}, onRecord: (record:
|
|
700
|
+
}, onRecord: (record: WorkflowWatchResult) => void): Promise<void>;
|
|
701
|
+
/**
|
|
702
|
+
* Creates a new ReadableStream from an iterable or async iterable of objects,
|
|
703
|
+
* serializing each as JSON and separating them with the record separator (\x1E).
|
|
704
|
+
*
|
|
705
|
+
* @param records - An iterable or async iterable of objects to stream
|
|
706
|
+
* @returns A ReadableStream emitting the records as JSON strings separated by the record separator
|
|
707
|
+
*/
|
|
708
|
+
static createRecordStream(records: Iterable<any> | AsyncIterable<any>): ReadableStream;
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
/**
|
|
712
|
+
* Class for interacting with an agent via the A2A protocol
|
|
713
|
+
*/
|
|
714
|
+
declare class A2A extends BaseResource {
|
|
715
|
+
private agentId;
|
|
716
|
+
constructor(options: ClientOptions, agentId: string);
|
|
717
|
+
/**
|
|
718
|
+
* Get the agent card with metadata about the agent
|
|
719
|
+
* @returns Promise containing the agent card information
|
|
720
|
+
*/
|
|
721
|
+
getCard(): Promise<AgentCard>;
|
|
722
|
+
/**
|
|
723
|
+
* Send a message to the agent and get a response
|
|
724
|
+
* @param params - Parameters for the task
|
|
725
|
+
* @returns Promise containing the task response
|
|
726
|
+
*/
|
|
727
|
+
sendMessage(params: TaskSendParams): Promise<{
|
|
728
|
+
task: Task;
|
|
729
|
+
}>;
|
|
730
|
+
/**
|
|
731
|
+
* Get the status and result of a task
|
|
732
|
+
* @param params - Parameters for querying the task
|
|
733
|
+
* @returns Promise containing the task response
|
|
734
|
+
*/
|
|
735
|
+
getTask(params: TaskQueryParams): Promise<Task>;
|
|
736
|
+
/**
|
|
737
|
+
* Cancel a running task
|
|
738
|
+
* @param params - Parameters identifying the task to cancel
|
|
739
|
+
* @returns Promise containing the task response
|
|
740
|
+
*/
|
|
741
|
+
cancelTask(params: TaskIdParams): Promise<{
|
|
742
|
+
task: Task;
|
|
743
|
+
}>;
|
|
744
|
+
/**
|
|
745
|
+
* Send a message and subscribe to streaming updates (not fully implemented)
|
|
746
|
+
* @param params - Parameters for the task
|
|
747
|
+
* @returns Promise containing the task response
|
|
748
|
+
*/
|
|
749
|
+
sendAndSubscribe(params: TaskSendParams): Promise<Response>;
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/**
|
|
753
|
+
* Represents a specific tool available on a specific MCP server.
|
|
754
|
+
* Provides methods to get details and execute the tool.
|
|
755
|
+
*/
|
|
756
|
+
declare class MCPTool extends BaseResource {
|
|
757
|
+
private serverId;
|
|
758
|
+
private toolId;
|
|
759
|
+
constructor(options: ClientOptions, serverId: string, toolId: string);
|
|
760
|
+
/**
|
|
761
|
+
* Retrieves details about this specific tool from the MCP server.
|
|
762
|
+
* @returns Promise containing the tool's information (name, description, schema).
|
|
763
|
+
*/
|
|
764
|
+
details(): Promise<McpToolInfo>;
|
|
765
|
+
/**
|
|
766
|
+
* Executes this specific tool on the MCP server.
|
|
767
|
+
* @param params - Parameters for tool execution, including data/args and optional runtimeContext.
|
|
768
|
+
* @returns Promise containing the result of the tool execution.
|
|
769
|
+
*/
|
|
770
|
+
execute(params: {
|
|
771
|
+
data?: any;
|
|
772
|
+
runtimeContext?: RuntimeContext;
|
|
773
|
+
}): Promise<any>;
|
|
606
774
|
}
|
|
607
775
|
|
|
608
776
|
declare class MastraClient extends BaseResource {
|
|
@@ -614,7 +782,7 @@ declare class MastraClient extends BaseResource {
|
|
|
614
782
|
getAgents(): Promise<Record<string, GetAgentResponse>>;
|
|
615
783
|
getAGUI({ resourceId }: {
|
|
616
784
|
resourceId: string;
|
|
617
|
-
}): Promise<Record<string,
|
|
785
|
+
}): Promise<Record<string, AbstractAgent>>;
|
|
618
786
|
/**
|
|
619
787
|
* Gets an agent instance by ID
|
|
620
788
|
* @param agentId - ID of the agent to retrieve
|
|
@@ -663,6 +831,17 @@ declare class MastraClient extends BaseResource {
|
|
|
663
831
|
* @returns Tool instance
|
|
664
832
|
*/
|
|
665
833
|
getTool(toolId: string): Tool;
|
|
834
|
+
/**
|
|
835
|
+
* Retrieves all available legacy workflows
|
|
836
|
+
* @returns Promise containing map of legacy workflow IDs to legacy workflow details
|
|
837
|
+
*/
|
|
838
|
+
getLegacyWorkflows(): Promise<Record<string, GetLegacyWorkflowResponse>>;
|
|
839
|
+
/**
|
|
840
|
+
* Gets a legacy workflow instance by ID
|
|
841
|
+
* @param workflowId - ID of the legacy workflow to retrieve
|
|
842
|
+
* @returns Legacy Workflow instance
|
|
843
|
+
*/
|
|
844
|
+
getLegacyWorkflow(workflowId: string): LegacyWorkflow;
|
|
666
845
|
/**
|
|
667
846
|
* Retrieves all available workflows
|
|
668
847
|
* @returns Promise containing map of workflow IDs to workflow details
|
|
@@ -674,17 +853,6 @@ declare class MastraClient extends BaseResource {
|
|
|
674
853
|
* @returns Workflow instance
|
|
675
854
|
*/
|
|
676
855
|
getWorkflow(workflowId: string): Workflow;
|
|
677
|
-
/**
|
|
678
|
-
* Retrieves all available vNext workflows
|
|
679
|
-
* @returns Promise containing map of vNext workflow IDs to vNext workflow details
|
|
680
|
-
*/
|
|
681
|
-
getVNextWorkflows(): Promise<Record<string, GetVNextWorkflowResponse>>;
|
|
682
|
-
/**
|
|
683
|
-
* Gets a vNext workflow instance by ID
|
|
684
|
-
* @param workflowId - ID of the vNext workflow to retrieve
|
|
685
|
-
* @returns vNext Workflow instance
|
|
686
|
-
*/
|
|
687
|
-
getVNextWorkflow(workflowId: string): VNextWorkflow;
|
|
688
856
|
/**
|
|
689
857
|
* Gets a vector instance by name
|
|
690
858
|
* @param vectorName - Name of the vector to retrieve
|
|
@@ -727,6 +895,44 @@ declare class MastraClient extends BaseResource {
|
|
|
727
895
|
* @returns Network instance
|
|
728
896
|
*/
|
|
729
897
|
getNetwork(networkId: string): Network;
|
|
898
|
+
/**
|
|
899
|
+
* Retrieves a list of available MCP servers.
|
|
900
|
+
* @param params - Optional parameters for pagination (limit, offset).
|
|
901
|
+
* @returns Promise containing the list of MCP servers and pagination info.
|
|
902
|
+
*/
|
|
903
|
+
getMcpServers(params?: {
|
|
904
|
+
limit?: number;
|
|
905
|
+
offset?: number;
|
|
906
|
+
}): Promise<McpServerListResponse>;
|
|
907
|
+
/**
|
|
908
|
+
* Retrieves detailed information for a specific MCP server.
|
|
909
|
+
* @param serverId - The ID of the MCP server to retrieve.
|
|
910
|
+
* @param params - Optional parameters, e.g., specific version.
|
|
911
|
+
* @returns Promise containing the detailed MCP server information.
|
|
912
|
+
*/
|
|
913
|
+
getMcpServerDetails(serverId: string, params?: {
|
|
914
|
+
version?: string;
|
|
915
|
+
}): Promise<ServerDetailInfo>;
|
|
916
|
+
/**
|
|
917
|
+
* Retrieves a list of tools for a specific MCP server.
|
|
918
|
+
* @param serverId - The ID of the MCP server.
|
|
919
|
+
* @returns Promise containing the list of tools.
|
|
920
|
+
*/
|
|
921
|
+
getMcpServerTools(serverId: string): Promise<McpServerToolListResponse>;
|
|
922
|
+
/**
|
|
923
|
+
* Gets an MCPTool resource instance for a specific tool on an MCP server.
|
|
924
|
+
* This instance can then be used to fetch details or execute the tool.
|
|
925
|
+
* @param serverId - The ID of the MCP server.
|
|
926
|
+
* @param toolId - The ID of the tool.
|
|
927
|
+
* @returns MCPTool instance.
|
|
928
|
+
*/
|
|
929
|
+
getMcpServerTool(serverId: string, toolId: string): MCPTool;
|
|
930
|
+
/**
|
|
931
|
+
* Gets an A2A client for interacting with an agent via the A2A protocol
|
|
932
|
+
* @param agentId - ID of the agent to interact with
|
|
933
|
+
* @returns A2A client instance
|
|
934
|
+
*/
|
|
935
|
+
getA2A(agentId: string): A2A;
|
|
730
936
|
}
|
|
731
937
|
|
|
732
|
-
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
|
|
938
|
+
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 };
|