@mastra/client-js 0.0.0-vnextWorkflows-20250422142014 → 0.0.0-workflow-deno-20250616130925
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 +662 -2
- package/dist/index.cjs +889 -55
- package/dist/index.d.cts +408 -41
- package/dist/index.d.ts +408 -41
- package/dist/index.js +885 -55
- package/package.json +23 -13
- package/src/adapters/agui.test.ts +180 -0
- package/src/adapters/agui.ts +239 -0
- package/src/client.ts +200 -13
- package/src/example.ts +30 -31
- package/src/index.test.ts +125 -5
- package/src/resources/a2a.ts +88 -0
- package/src/resources/agent.ts +49 -37
- package/src/resources/base.ts +2 -2
- package/src/resources/index.ts +4 -1
- package/src/resources/legacy-workflow.ts +242 -0
- package/src/resources/mcp-tool.ts +48 -0
- package/src/resources/memory-thread.ts +8 -5
- package/src/resources/network.ts +6 -12
- package/src/resources/tool.ts +16 -3
- package/src/resources/workflow.ts +254 -96
- package/src/types.ts +134 -19
- 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.cts
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AbstractAgent } from '@ag-ui/client';
|
|
2
|
+
import { ServerInfo, MCPToolType, ServerDetailInfo } from '@mastra/core/mcp';
|
|
3
|
+
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
4
|
+
import { CoreMessage, AiMessageType, StorageThreadType, MastraMessageV1, LegacyWorkflowRuns, WorkflowRuns, WorkflowRun, QueryResult, GenerateReturn } from '@mastra/core';
|
|
2
5
|
import { JSONSchema7 } from 'json-schema';
|
|
3
6
|
import { ZodSchema } from 'zod';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
7
|
+
import { AgentGenerateOptions, AgentStreamOptions, ToolsInput } from '@mastra/core/agent';
|
|
8
|
+
import { LogLevel, BaseLogMessage } from '@mastra/core/logger';
|
|
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';
|
|
6
14
|
|
|
7
15
|
interface ClientOptions {
|
|
8
16
|
/** Base URL for API requests */
|
|
@@ -23,21 +31,40 @@ interface RequestOptions {
|
|
|
23
31
|
stream?: boolean;
|
|
24
32
|
signal?: AbortSignal;
|
|
25
33
|
}
|
|
34
|
+
type WithoutMethods<T> = {
|
|
35
|
+
[K in keyof T as T[K] extends (...args: any[]) => any ? never : T[K] extends {
|
|
36
|
+
(): any;
|
|
37
|
+
} ? never : T[K] extends undefined | ((...args: any[]) => any) ? never : K]: T[K];
|
|
38
|
+
};
|
|
26
39
|
interface GetAgentResponse {
|
|
27
40
|
name: string;
|
|
28
41
|
instructions: string;
|
|
29
42
|
tools: Record<string, GetToolResponse>;
|
|
43
|
+
workflows: Record<string, GetWorkflowResponse>;
|
|
30
44
|
provider: string;
|
|
31
45
|
modelId: string;
|
|
46
|
+
defaultGenerateOptions: WithoutMethods<AgentGenerateOptions>;
|
|
47
|
+
defaultStreamOptions: WithoutMethods<AgentStreamOptions>;
|
|
32
48
|
}
|
|
33
49
|
type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
34
50
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
35
|
-
|
|
51
|
+
output?: T;
|
|
52
|
+
experimental_output?: T;
|
|
53
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
54
|
+
clientTools?: ToolsInput;
|
|
55
|
+
} & WithoutMethods<Omit<AgentGenerateOptions<T>, 'output' | 'experimental_output' | 'runtimeContext' | 'clientTools'>>;
|
|
36
56
|
type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
37
57
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
38
|
-
|
|
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'>>;
|
|
39
63
|
interface GetEvalsByAgentIdResponse extends GetAgentResponse {
|
|
40
64
|
evals: any[];
|
|
65
|
+
instructions: string;
|
|
66
|
+
name: string;
|
|
67
|
+
id: string;
|
|
41
68
|
}
|
|
42
69
|
interface GetToolResponse {
|
|
43
70
|
id: string;
|
|
@@ -45,7 +72,7 @@ interface GetToolResponse {
|
|
|
45
72
|
inputSchema: string;
|
|
46
73
|
outputSchema: string;
|
|
47
74
|
}
|
|
48
|
-
interface
|
|
75
|
+
interface GetLegacyWorkflowResponse {
|
|
49
76
|
name: string;
|
|
50
77
|
triggerSchema: string;
|
|
51
78
|
steps: Record<string, StepAction<any, any, any, any>>;
|
|
@@ -53,16 +80,48 @@ interface GetWorkflowResponse {
|
|
|
53
80
|
stepSubscriberGraph: Record<string, StepGraph>;
|
|
54
81
|
workflowId?: string;
|
|
55
82
|
}
|
|
56
|
-
|
|
83
|
+
interface GetWorkflowRunsParams {
|
|
84
|
+
fromDate?: Date;
|
|
85
|
+
toDate?: Date;
|
|
86
|
+
limit?: number;
|
|
87
|
+
offset?: number;
|
|
88
|
+
resourceId?: string;
|
|
89
|
+
}
|
|
90
|
+
type GetLegacyWorkflowRunsResponse = LegacyWorkflowRuns;
|
|
91
|
+
type GetWorkflowRunsResponse = WorkflowRuns;
|
|
92
|
+
type GetWorkflowRunByIdResponse = WorkflowRun;
|
|
93
|
+
type GetWorkflowRunExecutionResultResponse = WatchEvent['payload']['workflowState'];
|
|
94
|
+
type LegacyWorkflowRunResult = {
|
|
57
95
|
activePaths: Record<string, {
|
|
58
96
|
status: string;
|
|
59
97
|
suspendPayload?: any;
|
|
60
98
|
stepPath: string[];
|
|
61
99
|
}>;
|
|
62
|
-
results:
|
|
100
|
+
results: LegacyWorkflowRunResult$1<any, any, any>['results'];
|
|
63
101
|
timestamp: number;
|
|
64
102
|
runId: string;
|
|
65
103
|
};
|
|
104
|
+
interface GetWorkflowResponse {
|
|
105
|
+
name: string;
|
|
106
|
+
description?: string;
|
|
107
|
+
steps: {
|
|
108
|
+
[key: string]: {
|
|
109
|
+
id: string;
|
|
110
|
+
description: string;
|
|
111
|
+
inputSchema: string;
|
|
112
|
+
outputSchema: string;
|
|
113
|
+
resumeSchema: string;
|
|
114
|
+
suspendSchema: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
stepGraph: Workflow$1['serializedStepGraph'];
|
|
118
|
+
inputSchema: string;
|
|
119
|
+
outputSchema: string;
|
|
120
|
+
}
|
|
121
|
+
type WorkflowWatchResult = WatchEvent & {
|
|
122
|
+
runId: string;
|
|
123
|
+
};
|
|
124
|
+
type WorkflowRunResult = WorkflowResult<any, any>;
|
|
66
125
|
interface UpsertVectorParams {
|
|
67
126
|
indexName: string;
|
|
68
127
|
vectors: number[][];
|
|
@@ -90,15 +149,15 @@ interface GetVectorIndexResponse {
|
|
|
90
149
|
count: number;
|
|
91
150
|
}
|
|
92
151
|
interface SaveMessageToMemoryParams {
|
|
93
|
-
messages:
|
|
152
|
+
messages: MastraMessageV1[];
|
|
94
153
|
agentId: string;
|
|
95
154
|
}
|
|
96
|
-
type SaveMessageToMemoryResponse =
|
|
155
|
+
type SaveMessageToMemoryResponse = MastraMessageV1[];
|
|
97
156
|
interface CreateMemoryThreadParams {
|
|
98
|
-
title
|
|
99
|
-
metadata
|
|
100
|
-
|
|
101
|
-
threadId
|
|
157
|
+
title?: string;
|
|
158
|
+
metadata?: Record<string, any>;
|
|
159
|
+
resourceId: string;
|
|
160
|
+
threadId?: string;
|
|
102
161
|
agentId: string;
|
|
103
162
|
}
|
|
104
163
|
type CreateMemoryThreadResponse = StorageThreadType;
|
|
@@ -110,7 +169,13 @@ type GetMemoryThreadResponse = StorageThreadType[];
|
|
|
110
169
|
interface UpdateMemoryThreadParams {
|
|
111
170
|
title: string;
|
|
112
171
|
metadata: Record<string, any>;
|
|
113
|
-
|
|
172
|
+
resourceId: string;
|
|
173
|
+
}
|
|
174
|
+
interface GetMemoryThreadMessagesParams {
|
|
175
|
+
/**
|
|
176
|
+
* Limit the number of messages to retrieve (default: 40)
|
|
177
|
+
*/
|
|
178
|
+
limit?: number;
|
|
114
179
|
}
|
|
115
180
|
interface GetMemoryThreadMessagesResponse {
|
|
116
181
|
messages: CoreMessage[];
|
|
@@ -118,12 +183,30 @@ interface GetMemoryThreadMessagesResponse {
|
|
|
118
183
|
}
|
|
119
184
|
interface GetLogsParams {
|
|
120
185
|
transportId: string;
|
|
186
|
+
fromDate?: Date;
|
|
187
|
+
toDate?: Date;
|
|
188
|
+
logLevel?: LogLevel;
|
|
189
|
+
filters?: Record<string, string>;
|
|
190
|
+
page?: number;
|
|
191
|
+
perPage?: number;
|
|
121
192
|
}
|
|
122
193
|
interface GetLogParams {
|
|
123
194
|
runId: string;
|
|
124
195
|
transportId: string;
|
|
196
|
+
fromDate?: Date;
|
|
197
|
+
toDate?: Date;
|
|
198
|
+
logLevel?: LogLevel;
|
|
199
|
+
filters?: Record<string, string>;
|
|
200
|
+
page?: number;
|
|
201
|
+
perPage?: number;
|
|
125
202
|
}
|
|
126
|
-
type GetLogsResponse =
|
|
203
|
+
type GetLogsResponse = {
|
|
204
|
+
logs: BaseLogMessage[];
|
|
205
|
+
total: number;
|
|
206
|
+
page: number;
|
|
207
|
+
perPage: number;
|
|
208
|
+
hasMore: boolean;
|
|
209
|
+
};
|
|
127
210
|
type RequestFunction = (path: string, options?: RequestOptions) => Promise<any>;
|
|
128
211
|
type SpanStatus = {
|
|
129
212
|
code: number;
|
|
@@ -171,6 +254,8 @@ interface GetTelemetryParams {
|
|
|
171
254
|
page?: number;
|
|
172
255
|
perPage?: number;
|
|
173
256
|
attribute?: Record<string, string>;
|
|
257
|
+
fromDate?: Date;
|
|
258
|
+
toDate?: Date;
|
|
174
259
|
}
|
|
175
260
|
interface GetNetworkResponse {
|
|
176
261
|
name: string;
|
|
@@ -186,6 +271,21 @@ interface GetNetworkResponse {
|
|
|
186
271
|
};
|
|
187
272
|
state?: Record<string, any>;
|
|
188
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
|
+
}
|
|
189
289
|
|
|
190
290
|
declare class BaseResource {
|
|
191
291
|
readonly options: ClientOptions;
|
|
@@ -218,7 +318,9 @@ declare class AgentVoice extends BaseResource {
|
|
|
218
318
|
* @param options - Optional provider-specific options
|
|
219
319
|
* @returns Promise containing the transcribed text
|
|
220
320
|
*/
|
|
221
|
-
listen(audio: Blob, options?: Record<string, any>): Promise<
|
|
321
|
+
listen(audio: Blob, options?: Record<string, any>): Promise<{
|
|
322
|
+
text: string;
|
|
323
|
+
}>;
|
|
222
324
|
/**
|
|
223
325
|
* Get available speakers for the agent's voice provider
|
|
224
326
|
* @returns Promise containing list of available speakers
|
|
@@ -227,6 +329,13 @@ declare class AgentVoice extends BaseResource {
|
|
|
227
329
|
voiceId: string;
|
|
228
330
|
[key: string]: any;
|
|
229
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
|
+
}>;
|
|
230
339
|
}
|
|
231
340
|
declare class Agent extends BaseResource {
|
|
232
341
|
private agentId;
|
|
@@ -242,7 +351,18 @@ declare class Agent extends BaseResource {
|
|
|
242
351
|
* @param params - Generation parameters including prompt
|
|
243
352
|
* @returns Promise containing the generated response
|
|
244
353
|
*/
|
|
245
|
-
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>>;
|
|
246
366
|
/**
|
|
247
367
|
* Streams a response from the agent
|
|
248
368
|
* @param params - Stream parameters including prompt
|
|
@@ -257,6 +377,16 @@ declare class Agent extends BaseResource {
|
|
|
257
377
|
* @returns Promise containing tool details
|
|
258
378
|
*/
|
|
259
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>;
|
|
260
390
|
/**
|
|
261
391
|
* Retrieves evaluation results for the agent
|
|
262
392
|
* @returns Promise containing agent evaluations
|
|
@@ -317,9 +447,10 @@ declare class MemoryThread extends BaseResource {
|
|
|
317
447
|
}>;
|
|
318
448
|
/**
|
|
319
449
|
* Retrieves messages associated with the thread
|
|
450
|
+
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
320
451
|
* @returns Promise containing thread messages and UI messages
|
|
321
452
|
*/
|
|
322
|
-
getMessages(): Promise<GetMemoryThreadMessagesResponse>;
|
|
453
|
+
getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
|
|
323
454
|
}
|
|
324
455
|
|
|
325
456
|
declare class Vector extends BaseResource {
|
|
@@ -368,23 +499,22 @@ declare class Vector extends BaseResource {
|
|
|
368
499
|
query(params: QueryVectorParams): Promise<QueryVectorResponse>;
|
|
369
500
|
}
|
|
370
501
|
|
|
371
|
-
declare class
|
|
502
|
+
declare class LegacyWorkflow extends BaseResource {
|
|
372
503
|
private workflowId;
|
|
373
504
|
constructor(options: ClientOptions, workflowId: string);
|
|
374
505
|
/**
|
|
375
|
-
* Retrieves details about the workflow
|
|
376
|
-
* @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
|
|
377
508
|
*/
|
|
378
|
-
details(): Promise<
|
|
509
|
+
details(): Promise<GetLegacyWorkflowResponse>;
|
|
379
510
|
/**
|
|
380
|
-
*
|
|
381
|
-
*
|
|
382
|
-
* @
|
|
383
|
-
* @returns Promise containing the workflow execution results
|
|
511
|
+
* Retrieves all runs for a legacy workflow
|
|
512
|
+
* @param params - Parameters for filtering runs
|
|
513
|
+
* @returns Promise containing legacy workflow runs array
|
|
384
514
|
*/
|
|
385
|
-
|
|
515
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetLegacyWorkflowRunsResponse>;
|
|
386
516
|
/**
|
|
387
|
-
* Creates a new workflow run
|
|
517
|
+
* Creates a new legacy workflow run
|
|
388
518
|
* @returns Promise containing the generated run ID
|
|
389
519
|
*/
|
|
390
520
|
createRun(params?: {
|
|
@@ -393,7 +523,7 @@ declare class Workflow extends BaseResource {
|
|
|
393
523
|
runId: string;
|
|
394
524
|
}>;
|
|
395
525
|
/**
|
|
396
|
-
* 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
|
|
397
527
|
* @param params - Object containing the runId and triggerData
|
|
398
528
|
* @returns Promise containing success message
|
|
399
529
|
*/
|
|
@@ -404,11 +534,11 @@ declare class Workflow extends BaseResource {
|
|
|
404
534
|
message: string;
|
|
405
535
|
}>;
|
|
406
536
|
/**
|
|
407
|
-
* 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
|
|
408
538
|
* @param stepId - ID of the step to resume
|
|
409
|
-
* @param runId - ID of the workflow run
|
|
410
|
-
* @param context - Context to resume the workflow with
|
|
411
|
-
* @returns Promise containing the workflow resume results
|
|
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
|
|
412
542
|
*/
|
|
413
543
|
resume({ stepId, runId, context, }: {
|
|
414
544
|
stepId: string;
|
|
@@ -425,9 +555,9 @@ declare class Workflow extends BaseResource {
|
|
|
425
555
|
startAsync(params: {
|
|
426
556
|
runId?: string;
|
|
427
557
|
triggerData: Record<string, any>;
|
|
428
|
-
}): Promise<
|
|
558
|
+
}): Promise<LegacyWorkflowRunResult>;
|
|
429
559
|
/**
|
|
430
|
-
* 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
|
|
431
561
|
* @param params - Object containing the runId, stepId, and context
|
|
432
562
|
* @returns Promise containing the workflow resume results
|
|
433
563
|
*/
|
|
@@ -435,7 +565,7 @@ declare class Workflow extends BaseResource {
|
|
|
435
565
|
runId: string;
|
|
436
566
|
stepId: string;
|
|
437
567
|
context: Record<string, any>;
|
|
438
|
-
}): Promise<
|
|
568
|
+
}): Promise<LegacyWorkflowRunResult>;
|
|
439
569
|
/**
|
|
440
570
|
* Creates an async generator that processes a readable stream and yields records
|
|
441
571
|
* separated by the Record Separator character (\x1E)
|
|
@@ -445,13 +575,13 @@ declare class Workflow extends BaseResource {
|
|
|
445
575
|
*/
|
|
446
576
|
private streamProcessor;
|
|
447
577
|
/**
|
|
448
|
-
* Watches workflow transitions in real-time
|
|
578
|
+
* Watches legacy workflow transitions in real-time
|
|
449
579
|
* @param runId - Optional run ID to filter the watch stream
|
|
450
|
-
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
580
|
+
* @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
|
|
451
581
|
*/
|
|
452
582
|
watch({ runId }: {
|
|
453
583
|
runId?: string;
|
|
454
|
-
}, onRecord: (record:
|
|
584
|
+
}, onRecord: (record: LegacyWorkflowRunResult) => void): Promise<void>;
|
|
455
585
|
}
|
|
456
586
|
|
|
457
587
|
declare class Tool extends BaseResource {
|
|
@@ -469,6 +599,191 @@ declare class Tool extends BaseResource {
|
|
|
469
599
|
*/
|
|
470
600
|
execute(params: {
|
|
471
601
|
data: any;
|
|
602
|
+
runId?: string;
|
|
603
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
604
|
+
}): Promise<any>;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
declare class Workflow extends BaseResource {
|
|
608
|
+
private workflowId;
|
|
609
|
+
constructor(options: ClientOptions, workflowId: string);
|
|
610
|
+
/**
|
|
611
|
+
* Creates an async generator that processes a readable stream and yields workflow records
|
|
612
|
+
* separated by the Record Separator character (\x1E)
|
|
613
|
+
*
|
|
614
|
+
* @param stream - The readable stream to process
|
|
615
|
+
* @returns An async generator that yields parsed records
|
|
616
|
+
*/
|
|
617
|
+
private streamProcessor;
|
|
618
|
+
/**
|
|
619
|
+
* Retrieves details about the workflow
|
|
620
|
+
* @returns Promise containing workflow details including steps and graphs
|
|
621
|
+
*/
|
|
622
|
+
details(): Promise<GetWorkflowResponse>;
|
|
623
|
+
/**
|
|
624
|
+
* Retrieves all runs for a workflow
|
|
625
|
+
* @param params - Parameters for filtering runs
|
|
626
|
+
* @returns Promise containing workflow runs array
|
|
627
|
+
*/
|
|
628
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
|
|
629
|
+
/**
|
|
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
|
|
643
|
+
* @param params - Optional object containing the optional runId
|
|
644
|
+
* @returns Promise containing the runId of the created run
|
|
645
|
+
*/
|
|
646
|
+
createRun(params?: {
|
|
647
|
+
runId?: string;
|
|
648
|
+
}): Promise<{
|
|
649
|
+
runId: string;
|
|
650
|
+
}>;
|
|
651
|
+
/**
|
|
652
|
+
* Starts a workflow run synchronously without waiting for the workflow to complete
|
|
653
|
+
* @param params - Object containing the runId, inputData and runtimeContext
|
|
654
|
+
* @returns Promise containing success message
|
|
655
|
+
*/
|
|
656
|
+
start(params: {
|
|
657
|
+
runId: string;
|
|
658
|
+
inputData: Record<string, any>;
|
|
659
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
660
|
+
}): Promise<{
|
|
661
|
+
message: string;
|
|
662
|
+
}>;
|
|
663
|
+
/**
|
|
664
|
+
* Resumes a suspended workflow step synchronously without waiting for the workflow to complete
|
|
665
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
666
|
+
* @returns Promise containing success message
|
|
667
|
+
*/
|
|
668
|
+
resume({ step, runId, resumeData, ...rest }: {
|
|
669
|
+
step: string | string[];
|
|
670
|
+
runId: string;
|
|
671
|
+
resumeData?: Record<string, any>;
|
|
672
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
673
|
+
}): Promise<{
|
|
674
|
+
message: string;
|
|
675
|
+
}>;
|
|
676
|
+
/**
|
|
677
|
+
* Starts a workflow run asynchronously and returns a promise that resolves when the workflow is complete
|
|
678
|
+
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
679
|
+
* @returns Promise containing the workflow execution results
|
|
680
|
+
*/
|
|
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: {
|
|
692
|
+
runId?: string;
|
|
693
|
+
inputData: Record<string, any>;
|
|
694
|
+
runtimeContext?: RuntimeContext;
|
|
695
|
+
}): Promise<stream_web.ReadableStream<WorkflowWatchResult>>;
|
|
696
|
+
/**
|
|
697
|
+
* Resumes a suspended workflow step asynchronously and returns a promise that resolves when the workflow is complete
|
|
698
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
699
|
+
* @returns Promise containing the workflow resume results
|
|
700
|
+
*/
|
|
701
|
+
resumeAsync(params: {
|
|
702
|
+
runId: string;
|
|
703
|
+
step: string | string[];
|
|
704
|
+
resumeData?: Record<string, any>;
|
|
705
|
+
runtimeContext?: RuntimeContext | Record<string, any>;
|
|
706
|
+
}): Promise<WorkflowRunResult>;
|
|
707
|
+
/**
|
|
708
|
+
* Watches workflow transitions in real-time
|
|
709
|
+
* @param runId - Optional run ID to filter the watch stream
|
|
710
|
+
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
711
|
+
*/
|
|
712
|
+
watch({ runId }: {
|
|
713
|
+
runId?: string;
|
|
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;
|
|
472
787
|
}): Promise<any>;
|
|
473
788
|
}
|
|
474
789
|
|
|
@@ -479,6 +794,9 @@ declare class MastraClient extends BaseResource {
|
|
|
479
794
|
* @returns Promise containing map of agent IDs to agent details
|
|
480
795
|
*/
|
|
481
796
|
getAgents(): Promise<Record<string, GetAgentResponse>>;
|
|
797
|
+
getAGUI({ resourceId }: {
|
|
798
|
+
resourceId: string;
|
|
799
|
+
}): Promise<Record<string, AbstractAgent>>;
|
|
482
800
|
/**
|
|
483
801
|
* Gets an agent instance by ID
|
|
484
802
|
* @param agentId - ID of the agent to retrieve
|
|
@@ -527,6 +845,17 @@ declare class MastraClient extends BaseResource {
|
|
|
527
845
|
* @returns Tool instance
|
|
528
846
|
*/
|
|
529
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;
|
|
530
859
|
/**
|
|
531
860
|
* Retrieves all available workflows
|
|
532
861
|
* @returns Promise containing map of workflow IDs to workflow details
|
|
@@ -580,6 +909,44 @@ declare class MastraClient extends BaseResource {
|
|
|
580
909
|
* @returns Network instance
|
|
581
910
|
*/
|
|
582
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;
|
|
583
950
|
}
|
|
584
951
|
|
|
585
|
-
export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVectorIndexResponse, type GetWorkflowResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type WorkflowRunResult };
|
|
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 };
|