@mastra/client-js 0.0.0-fix-memory-xxhash-20250409202110 → 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 +801 -2
- package/{LICENSE → LICENSE.md} +3 -1
- package/dist/index.cjs +889 -55
- package/dist/index.d.cts +409 -44
- package/dist/index.d.ts +409 -44
- package/dist/index.js +885 -55
- package/package.json +24 -14
- 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 +29 -30
- 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 +135 -20
- 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,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;
|
|
@@ -163,9 +246,7 @@ type Span = {
|
|
|
163
246
|
createdAt: string;
|
|
164
247
|
};
|
|
165
248
|
interface GetTelemetryResponse {
|
|
166
|
-
traces:
|
|
167
|
-
traces: Span[];
|
|
168
|
-
};
|
|
249
|
+
traces: Span[];
|
|
169
250
|
}
|
|
170
251
|
interface GetTelemetryParams {
|
|
171
252
|
name?: string;
|
|
@@ -173,6 +254,8 @@ interface GetTelemetryParams {
|
|
|
173
254
|
page?: number;
|
|
174
255
|
perPage?: number;
|
|
175
256
|
attribute?: Record<string, string>;
|
|
257
|
+
fromDate?: Date;
|
|
258
|
+
toDate?: Date;
|
|
176
259
|
}
|
|
177
260
|
interface GetNetworkResponse {
|
|
178
261
|
name: string;
|
|
@@ -188,6 +271,21 @@ interface GetNetworkResponse {
|
|
|
188
271
|
};
|
|
189
272
|
state?: Record<string, any>;
|
|
190
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
|
+
}
|
|
191
289
|
|
|
192
290
|
declare class BaseResource {
|
|
193
291
|
readonly options: ClientOptions;
|
|
@@ -220,7 +318,9 @@ declare class AgentVoice extends BaseResource {
|
|
|
220
318
|
* @param options - Optional provider-specific options
|
|
221
319
|
* @returns Promise containing the transcribed text
|
|
222
320
|
*/
|
|
223
|
-
listen(audio: Blob, options?: Record<string, any>): Promise<
|
|
321
|
+
listen(audio: Blob, options?: Record<string, any>): Promise<{
|
|
322
|
+
text: string;
|
|
323
|
+
}>;
|
|
224
324
|
/**
|
|
225
325
|
* Get available speakers for the agent's voice provider
|
|
226
326
|
* @returns Promise containing list of available speakers
|
|
@@ -229,6 +329,13 @@ declare class AgentVoice extends BaseResource {
|
|
|
229
329
|
voiceId: string;
|
|
230
330
|
[key: string]: any;
|
|
231
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
|
+
}>;
|
|
232
339
|
}
|
|
233
340
|
declare class Agent extends BaseResource {
|
|
234
341
|
private agentId;
|
|
@@ -244,7 +351,18 @@ declare class Agent extends BaseResource {
|
|
|
244
351
|
* @param params - Generation parameters including prompt
|
|
245
352
|
* @returns Promise containing the generated response
|
|
246
353
|
*/
|
|
247
|
-
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>>;
|
|
248
366
|
/**
|
|
249
367
|
* Streams a response from the agent
|
|
250
368
|
* @param params - Stream parameters including prompt
|
|
@@ -259,6 +377,16 @@ declare class Agent extends BaseResource {
|
|
|
259
377
|
* @returns Promise containing tool details
|
|
260
378
|
*/
|
|
261
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>;
|
|
262
390
|
/**
|
|
263
391
|
* Retrieves evaluation results for the agent
|
|
264
392
|
* @returns Promise containing agent evaluations
|
|
@@ -319,9 +447,10 @@ declare class MemoryThread extends BaseResource {
|
|
|
319
447
|
}>;
|
|
320
448
|
/**
|
|
321
449
|
* Retrieves messages associated with the thread
|
|
450
|
+
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
322
451
|
* @returns Promise containing thread messages and UI messages
|
|
323
452
|
*/
|
|
324
|
-
getMessages(): Promise<GetMemoryThreadMessagesResponse>;
|
|
453
|
+
getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
|
|
325
454
|
}
|
|
326
455
|
|
|
327
456
|
declare class Vector extends BaseResource {
|
|
@@ -370,23 +499,22 @@ declare class Vector extends BaseResource {
|
|
|
370
499
|
query(params: QueryVectorParams): Promise<QueryVectorResponse>;
|
|
371
500
|
}
|
|
372
501
|
|
|
373
|
-
declare class
|
|
502
|
+
declare class LegacyWorkflow extends BaseResource {
|
|
374
503
|
private workflowId;
|
|
375
504
|
constructor(options: ClientOptions, workflowId: string);
|
|
376
505
|
/**
|
|
377
|
-
* Retrieves details about the workflow
|
|
378
|
-
* @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
|
|
379
508
|
*/
|
|
380
|
-
details(): Promise<
|
|
509
|
+
details(): Promise<GetLegacyWorkflowResponse>;
|
|
381
510
|
/**
|
|
382
|
-
*
|
|
383
|
-
*
|
|
384
|
-
* @
|
|
385
|
-
* @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
|
|
386
514
|
*/
|
|
387
|
-
|
|
515
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetLegacyWorkflowRunsResponse>;
|
|
388
516
|
/**
|
|
389
|
-
* Creates a new workflow run
|
|
517
|
+
* Creates a new legacy workflow run
|
|
390
518
|
* @returns Promise containing the generated run ID
|
|
391
519
|
*/
|
|
392
520
|
createRun(params?: {
|
|
@@ -395,7 +523,7 @@ declare class Workflow extends BaseResource {
|
|
|
395
523
|
runId: string;
|
|
396
524
|
}>;
|
|
397
525
|
/**
|
|
398
|
-
* 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
|
|
399
527
|
* @param params - Object containing the runId and triggerData
|
|
400
528
|
* @returns Promise containing success message
|
|
401
529
|
*/
|
|
@@ -406,11 +534,11 @@ declare class Workflow extends BaseResource {
|
|
|
406
534
|
message: string;
|
|
407
535
|
}>;
|
|
408
536
|
/**
|
|
409
|
-
* 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
|
|
410
538
|
* @param stepId - ID of the step to resume
|
|
411
|
-
* @param runId - ID of the workflow run
|
|
412
|
-
* @param context - Context to resume the workflow with
|
|
413
|
-
* @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
|
|
414
542
|
*/
|
|
415
543
|
resume({ stepId, runId, context, }: {
|
|
416
544
|
stepId: string;
|
|
@@ -427,9 +555,9 @@ declare class Workflow extends BaseResource {
|
|
|
427
555
|
startAsync(params: {
|
|
428
556
|
runId?: string;
|
|
429
557
|
triggerData: Record<string, any>;
|
|
430
|
-
}): Promise<
|
|
558
|
+
}): Promise<LegacyWorkflowRunResult>;
|
|
431
559
|
/**
|
|
432
|
-
* 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
|
|
433
561
|
* @param params - Object containing the runId, stepId, and context
|
|
434
562
|
* @returns Promise containing the workflow resume results
|
|
435
563
|
*/
|
|
@@ -437,7 +565,7 @@ declare class Workflow extends BaseResource {
|
|
|
437
565
|
runId: string;
|
|
438
566
|
stepId: string;
|
|
439
567
|
context: Record<string, any>;
|
|
440
|
-
}): Promise<
|
|
568
|
+
}): Promise<LegacyWorkflowRunResult>;
|
|
441
569
|
/**
|
|
442
570
|
* Creates an async generator that processes a readable stream and yields records
|
|
443
571
|
* separated by the Record Separator character (\x1E)
|
|
@@ -447,13 +575,13 @@ declare class Workflow extends BaseResource {
|
|
|
447
575
|
*/
|
|
448
576
|
private streamProcessor;
|
|
449
577
|
/**
|
|
450
|
-
* Watches workflow transitions in real-time
|
|
578
|
+
* Watches legacy workflow transitions in real-time
|
|
451
579
|
* @param runId - Optional run ID to filter the watch stream
|
|
452
|
-
* @returns AsyncGenerator that yields parsed records from the workflow watch stream
|
|
580
|
+
* @returns AsyncGenerator that yields parsed records from the legacy workflow watch stream
|
|
453
581
|
*/
|
|
454
582
|
watch({ runId }: {
|
|
455
583
|
runId?: string;
|
|
456
|
-
}, onRecord: (record:
|
|
584
|
+
}, onRecord: (record: LegacyWorkflowRunResult) => void): Promise<void>;
|
|
457
585
|
}
|
|
458
586
|
|
|
459
587
|
declare class Tool extends BaseResource {
|
|
@@ -471,6 +599,191 @@ declare class Tool extends BaseResource {
|
|
|
471
599
|
*/
|
|
472
600
|
execute(params: {
|
|
473
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;
|
|
474
787
|
}): Promise<any>;
|
|
475
788
|
}
|
|
476
789
|
|
|
@@ -481,6 +794,9 @@ declare class MastraClient extends BaseResource {
|
|
|
481
794
|
* @returns Promise containing map of agent IDs to agent details
|
|
482
795
|
*/
|
|
483
796
|
getAgents(): Promise<Record<string, GetAgentResponse>>;
|
|
797
|
+
getAGUI({ resourceId }: {
|
|
798
|
+
resourceId: string;
|
|
799
|
+
}): Promise<Record<string, AbstractAgent>>;
|
|
484
800
|
/**
|
|
485
801
|
* Gets an agent instance by ID
|
|
486
802
|
* @param agentId - ID of the agent to retrieve
|
|
@@ -529,6 +845,17 @@ declare class MastraClient extends BaseResource {
|
|
|
529
845
|
* @returns Tool instance
|
|
530
846
|
*/
|
|
531
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;
|
|
532
859
|
/**
|
|
533
860
|
* Retrieves all available workflows
|
|
534
861
|
* @returns Promise containing map of workflow IDs to workflow details
|
|
@@ -582,6 +909,44 @@ declare class MastraClient extends BaseResource {
|
|
|
582
909
|
* @returns Network instance
|
|
583
910
|
*/
|
|
584
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;
|
|
585
950
|
}
|
|
586
951
|
|
|
587
|
-
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 };
|