@mastra/client-js 0.0.0-bundle-dynamic-imports-20250424001248 → 0.0.0-cloud-transporter-20250513033346
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +285 -2
- package/dist/index.cjs +576 -17
- package/dist/index.d.cts +222 -7
- package/dist/index.d.ts +222 -7
- package/dist/index.js +572 -17
- package/package.json +9 -7
- package/src/adapters/agui.test.ts +180 -0
- package/src/adapters/agui.ts +239 -0
- package/src/client.ts +56 -2
- package/src/index.test.ts +34 -4
- package/src/resources/a2a.ts +88 -0
- package/src/resources/agent.ts +27 -36
- package/src/resources/base.ts +1 -1
- package/src/resources/index.ts +2 -0
- package/src/resources/memory-thread.ts +13 -3
- package/src/resources/network.ts +6 -12
- package/src/resources/tool.ts +15 -3
- package/src/resources/vnext-workflow.ts +261 -0
- package/src/resources/workflow.ts +38 -2
- package/src/types.ts +48 -2
- package/src/utils/zod-to-json-schema.ts +10 -0
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AbstractAgent } from '@ag-ui/client';
|
|
2
|
+
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
3
|
+
import { StepAction, StepGraph, CoreMessage, AiMessageType, StorageThreadType, MessageType, WorkflowRuns, WorkflowRunResult as WorkflowRunResult$1, QueryResult, BaseLogMessage, GenerateReturn } from '@mastra/core';
|
|
2
4
|
import { JSONSchema7 } from 'json-schema';
|
|
3
5
|
import { ZodSchema } from 'zod';
|
|
4
|
-
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
5
6
|
import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
|
|
7
|
+
import { NewWorkflow, WorkflowResult, WatchEvent } from '@mastra/core/workflows/vNext';
|
|
8
|
+
import { RuntimeContext } from '@mastra/core/di';
|
|
9
|
+
import { RuntimeContext as RuntimeContext$1 } from '@mastra/core/runtime-context';
|
|
10
|
+
import { AgentCard, TaskSendParams, Task, TaskQueryParams, TaskIdParams } from '@mastra/core/a2a';
|
|
6
11
|
|
|
7
12
|
interface ClientOptions {
|
|
8
13
|
/** Base URL for API requests */
|
|
@@ -27,17 +32,21 @@ interface GetAgentResponse {
|
|
|
27
32
|
name: string;
|
|
28
33
|
instructions: string;
|
|
29
34
|
tools: Record<string, GetToolResponse>;
|
|
35
|
+
workflows: Record<string, GetWorkflowResponse>;
|
|
30
36
|
provider: string;
|
|
31
37
|
modelId: string;
|
|
32
38
|
}
|
|
33
39
|
type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
34
40
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
35
|
-
} & Partial<AgentGenerateOptions<T>>;
|
|
41
|
+
} & Partial<Omit<AgentGenerateOptions<T>, 'experimental_generateMessageId'>>;
|
|
36
42
|
type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
37
43
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
38
|
-
} & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
|
|
44
|
+
} & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry' | 'experimental_generateMessageId'>;
|
|
39
45
|
interface GetEvalsByAgentIdResponse extends GetAgentResponse {
|
|
40
46
|
evals: any[];
|
|
47
|
+
instructions: string;
|
|
48
|
+
name: string;
|
|
49
|
+
id: string;
|
|
41
50
|
}
|
|
42
51
|
interface GetToolResponse {
|
|
43
52
|
id: string;
|
|
@@ -53,6 +62,14 @@ interface GetWorkflowResponse {
|
|
|
53
62
|
stepSubscriberGraph: Record<string, StepGraph>;
|
|
54
63
|
workflowId?: string;
|
|
55
64
|
}
|
|
65
|
+
interface GetWorkflowRunsParams {
|
|
66
|
+
fromDate?: Date;
|
|
67
|
+
toDate?: Date;
|
|
68
|
+
limit?: number;
|
|
69
|
+
offset?: number;
|
|
70
|
+
resourceId?: string;
|
|
71
|
+
}
|
|
72
|
+
type GetWorkflowRunsResponse = WorkflowRuns;
|
|
56
73
|
type WorkflowRunResult = {
|
|
57
74
|
activePaths: Record<string, {
|
|
58
75
|
status: string;
|
|
@@ -63,6 +80,26 @@ type WorkflowRunResult = {
|
|
|
63
80
|
timestamp: number;
|
|
64
81
|
runId: string;
|
|
65
82
|
};
|
|
83
|
+
interface GetVNextWorkflowResponse {
|
|
84
|
+
name: string;
|
|
85
|
+
steps: {
|
|
86
|
+
[key: string]: {
|
|
87
|
+
id: string;
|
|
88
|
+
description: string;
|
|
89
|
+
inputSchema: string;
|
|
90
|
+
outputSchema: string;
|
|
91
|
+
resumeSchema: string;
|
|
92
|
+
suspendSchema: string;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
stepGraph: NewWorkflow['serializedStepGraph'];
|
|
96
|
+
inputSchema: string;
|
|
97
|
+
outputSchema: string;
|
|
98
|
+
}
|
|
99
|
+
type VNextWorkflowWatchResult = WatchEvent & {
|
|
100
|
+
runId: string;
|
|
101
|
+
};
|
|
102
|
+
type VNextWorkflowRunResult = WorkflowResult<any, any>;
|
|
66
103
|
interface UpsertVectorParams {
|
|
67
104
|
indexName: string;
|
|
68
105
|
vectors: number[][];
|
|
@@ -112,6 +149,12 @@ interface UpdateMemoryThreadParams {
|
|
|
112
149
|
metadata: Record<string, any>;
|
|
113
150
|
resourceId: string;
|
|
114
151
|
}
|
|
152
|
+
interface GetMemoryThreadMessagesParams {
|
|
153
|
+
/**
|
|
154
|
+
* Limit the number of messages to retrieve (default: 40)
|
|
155
|
+
*/
|
|
156
|
+
limit?: number;
|
|
157
|
+
}
|
|
115
158
|
interface GetMemoryThreadMessagesResponse {
|
|
116
159
|
messages: CoreMessage[];
|
|
117
160
|
uiMessages: AiMessageType[];
|
|
@@ -171,6 +214,8 @@ interface GetTelemetryParams {
|
|
|
171
214
|
page?: number;
|
|
172
215
|
perPage?: number;
|
|
173
216
|
attribute?: Record<string, string>;
|
|
217
|
+
fromDate?: Date;
|
|
218
|
+
toDate?: Date;
|
|
174
219
|
}
|
|
175
220
|
interface GetNetworkResponse {
|
|
176
221
|
name: string;
|
|
@@ -218,7 +263,9 @@ declare class AgentVoice extends BaseResource {
|
|
|
218
263
|
* @param options - Optional provider-specific options
|
|
219
264
|
* @returns Promise containing the transcribed text
|
|
220
265
|
*/
|
|
221
|
-
listen(audio: Blob, options?: Record<string, any>): Promise<
|
|
266
|
+
listen(audio: Blob, options?: Record<string, any>): Promise<{
|
|
267
|
+
text: string;
|
|
268
|
+
}>;
|
|
222
269
|
/**
|
|
223
270
|
* Get available speakers for the agent's voice provider
|
|
224
271
|
* @returns Promise containing list of available speakers
|
|
@@ -257,6 +304,16 @@ declare class Agent extends BaseResource {
|
|
|
257
304
|
* @returns Promise containing tool details
|
|
258
305
|
*/
|
|
259
306
|
getTool(toolId: string): Promise<GetToolResponse>;
|
|
307
|
+
/**
|
|
308
|
+
* Executes a tool for the agent
|
|
309
|
+
* @param toolId - ID of the tool to execute
|
|
310
|
+
* @param params - Parameters required for tool execution
|
|
311
|
+
* @returns Promise containing the tool execution results
|
|
312
|
+
*/
|
|
313
|
+
executeTool(toolId: string, params: {
|
|
314
|
+
data: any;
|
|
315
|
+
runtimeContext?: RuntimeContext;
|
|
316
|
+
}): Promise<any>;
|
|
260
317
|
/**
|
|
261
318
|
* Retrieves evaluation results for the agent
|
|
262
319
|
* @returns Promise containing agent evaluations
|
|
@@ -317,9 +374,10 @@ declare class MemoryThread extends BaseResource {
|
|
|
317
374
|
}>;
|
|
318
375
|
/**
|
|
319
376
|
* Retrieves messages associated with the thread
|
|
377
|
+
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
320
378
|
* @returns Promise containing thread messages and UI messages
|
|
321
379
|
*/
|
|
322
|
-
getMessages(): Promise<GetMemoryThreadMessagesResponse>;
|
|
380
|
+
getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
|
|
323
381
|
}
|
|
324
382
|
|
|
325
383
|
declare class Vector extends BaseResource {
|
|
@@ -376,6 +434,12 @@ declare class Workflow extends BaseResource {
|
|
|
376
434
|
* @returns Promise containing workflow details including steps and graphs
|
|
377
435
|
*/
|
|
378
436
|
details(): Promise<GetWorkflowResponse>;
|
|
437
|
+
/**
|
|
438
|
+
* Retrieves all runs for a workflow
|
|
439
|
+
* @param params - Parameters for filtering runs
|
|
440
|
+
* @returns Promise containing workflow runs array
|
|
441
|
+
*/
|
|
442
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
|
|
379
443
|
/**
|
|
380
444
|
* @deprecated Use `startAsync` instead
|
|
381
445
|
* Executes the workflow with the provided parameters
|
|
@@ -469,9 +533,140 @@ declare class Tool extends BaseResource {
|
|
|
469
533
|
*/
|
|
470
534
|
execute(params: {
|
|
471
535
|
data: any;
|
|
536
|
+
runId?: string;
|
|
537
|
+
runtimeContext?: RuntimeContext;
|
|
472
538
|
}): Promise<any>;
|
|
473
539
|
}
|
|
474
540
|
|
|
541
|
+
declare class VNextWorkflow extends BaseResource {
|
|
542
|
+
private workflowId;
|
|
543
|
+
constructor(options: ClientOptions, workflowId: string);
|
|
544
|
+
/**
|
|
545
|
+
* Creates an async generator that processes a readable stream and yields vNext workflow records
|
|
546
|
+
* separated by the Record Separator character (\x1E)
|
|
547
|
+
*
|
|
548
|
+
* @param stream - The readable stream to process
|
|
549
|
+
* @returns An async generator that yields parsed records
|
|
550
|
+
*/
|
|
551
|
+
private streamProcessor;
|
|
552
|
+
/**
|
|
553
|
+
* Retrieves details about the vNext workflow
|
|
554
|
+
* @returns Promise containing vNext workflow details including steps and graphs
|
|
555
|
+
*/
|
|
556
|
+
details(): Promise<GetVNextWorkflowResponse>;
|
|
557
|
+
/**
|
|
558
|
+
* Retrieves all runs for a vNext workflow
|
|
559
|
+
* @param params - Parameters for filtering runs
|
|
560
|
+
* @returns Promise containing vNext workflow runs array
|
|
561
|
+
*/
|
|
562
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
|
|
563
|
+
/**
|
|
564
|
+
* Creates a new vNext workflow run
|
|
565
|
+
* @param params - Optional object containing the optional runId
|
|
566
|
+
* @returns Promise containing the runId of the created run
|
|
567
|
+
*/
|
|
568
|
+
createRun(params?: {
|
|
569
|
+
runId?: string;
|
|
570
|
+
}): Promise<{
|
|
571
|
+
runId: string;
|
|
572
|
+
}>;
|
|
573
|
+
/**
|
|
574
|
+
* Starts a vNext workflow run synchronously without waiting for the workflow to complete
|
|
575
|
+
* @param params - Object containing the runId, inputData and runtimeContext
|
|
576
|
+
* @returns Promise containing success message
|
|
577
|
+
*/
|
|
578
|
+
start(params: {
|
|
579
|
+
runId: string;
|
|
580
|
+
inputData: Record<string, any>;
|
|
581
|
+
runtimeContext?: RuntimeContext$1;
|
|
582
|
+
}): Promise<{
|
|
583
|
+
message: string;
|
|
584
|
+
}>;
|
|
585
|
+
/**
|
|
586
|
+
* Resumes a suspended vNext workflow step synchronously without waiting for the vNext workflow to complete
|
|
587
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
588
|
+
* @returns Promise containing success message
|
|
589
|
+
*/
|
|
590
|
+
resume({ step, runId, resumeData, ...rest }: {
|
|
591
|
+
step: string | string[];
|
|
592
|
+
runId: string;
|
|
593
|
+
resumeData?: Record<string, any>;
|
|
594
|
+
runtimeContext?: RuntimeContext$1;
|
|
595
|
+
}): Promise<{
|
|
596
|
+
message: string;
|
|
597
|
+
}>;
|
|
598
|
+
/**
|
|
599
|
+
* Starts a vNext workflow run asynchronously and returns a promise that resolves when the vNext workflow is complete
|
|
600
|
+
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
601
|
+
* @returns Promise containing the vNext workflow execution results
|
|
602
|
+
*/
|
|
603
|
+
startAsync(params: {
|
|
604
|
+
runId?: string;
|
|
605
|
+
inputData: Record<string, any>;
|
|
606
|
+
runtimeContext?: RuntimeContext$1;
|
|
607
|
+
}): Promise<VNextWorkflowRunResult>;
|
|
608
|
+
/**
|
|
609
|
+
* Resumes a suspended vNext workflow step asynchronously and returns a promise that resolves when the vNext workflow is complete
|
|
610
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
611
|
+
* @returns Promise containing the vNext workflow resume results
|
|
612
|
+
*/
|
|
613
|
+
resumeAsync(params: {
|
|
614
|
+
runId: string;
|
|
615
|
+
step: string | string[];
|
|
616
|
+
resumeData?: Record<string, any>;
|
|
617
|
+
runtimeContext?: RuntimeContext$1;
|
|
618
|
+
}): Promise<VNextWorkflowRunResult>;
|
|
619
|
+
/**
|
|
620
|
+
* Watches vNext workflow transitions in real-time
|
|
621
|
+
* @param runId - Optional run ID to filter the watch stream
|
|
622
|
+
* @returns AsyncGenerator that yields parsed records from the vNext workflow watch stream
|
|
623
|
+
*/
|
|
624
|
+
watch({ runId }: {
|
|
625
|
+
runId?: string;
|
|
626
|
+
}, onRecord: (record: VNextWorkflowWatchResult) => void): Promise<void>;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Class for interacting with an agent via the A2A protocol
|
|
631
|
+
*/
|
|
632
|
+
declare class A2A extends BaseResource {
|
|
633
|
+
private agentId;
|
|
634
|
+
constructor(options: ClientOptions, agentId: string);
|
|
635
|
+
/**
|
|
636
|
+
* Get the agent card with metadata about the agent
|
|
637
|
+
* @returns Promise containing the agent card information
|
|
638
|
+
*/
|
|
639
|
+
getCard(): Promise<AgentCard>;
|
|
640
|
+
/**
|
|
641
|
+
* Send a message to the agent and get a response
|
|
642
|
+
* @param params - Parameters for the task
|
|
643
|
+
* @returns Promise containing the task response
|
|
644
|
+
*/
|
|
645
|
+
sendMessage(params: TaskSendParams): Promise<{
|
|
646
|
+
task: Task;
|
|
647
|
+
}>;
|
|
648
|
+
/**
|
|
649
|
+
* Get the status and result of a task
|
|
650
|
+
* @param params - Parameters for querying the task
|
|
651
|
+
* @returns Promise containing the task response
|
|
652
|
+
*/
|
|
653
|
+
getTask(params: TaskQueryParams): Promise<Task>;
|
|
654
|
+
/**
|
|
655
|
+
* Cancel a running task
|
|
656
|
+
* @param params - Parameters identifying the task to cancel
|
|
657
|
+
* @returns Promise containing the task response
|
|
658
|
+
*/
|
|
659
|
+
cancelTask(params: TaskIdParams): Promise<{
|
|
660
|
+
task: Task;
|
|
661
|
+
}>;
|
|
662
|
+
/**
|
|
663
|
+
* Send a message and subscribe to streaming updates (not fully implemented)
|
|
664
|
+
* @param params - Parameters for the task
|
|
665
|
+
* @returns Promise containing the task response
|
|
666
|
+
*/
|
|
667
|
+
sendAndSubscribe(params: TaskSendParams): Promise<Response>;
|
|
668
|
+
}
|
|
669
|
+
|
|
475
670
|
declare class MastraClient extends BaseResource {
|
|
476
671
|
constructor(options: ClientOptions);
|
|
477
672
|
/**
|
|
@@ -479,6 +674,9 @@ declare class MastraClient extends BaseResource {
|
|
|
479
674
|
* @returns Promise containing map of agent IDs to agent details
|
|
480
675
|
*/
|
|
481
676
|
getAgents(): Promise<Record<string, GetAgentResponse>>;
|
|
677
|
+
getAGUI({ resourceId }: {
|
|
678
|
+
resourceId: string;
|
|
679
|
+
}): Promise<Record<string, AbstractAgent>>;
|
|
482
680
|
/**
|
|
483
681
|
* Gets an agent instance by ID
|
|
484
682
|
* @param agentId - ID of the agent to retrieve
|
|
@@ -538,6 +736,17 @@ declare class MastraClient extends BaseResource {
|
|
|
538
736
|
* @returns Workflow instance
|
|
539
737
|
*/
|
|
540
738
|
getWorkflow(workflowId: string): Workflow;
|
|
739
|
+
/**
|
|
740
|
+
* Retrieves all available vNext workflows
|
|
741
|
+
* @returns Promise containing map of vNext workflow IDs to vNext workflow details
|
|
742
|
+
*/
|
|
743
|
+
getVNextWorkflows(): Promise<Record<string, GetVNextWorkflowResponse>>;
|
|
744
|
+
/**
|
|
745
|
+
* Gets a vNext workflow instance by ID
|
|
746
|
+
* @param workflowId - ID of the vNext workflow to retrieve
|
|
747
|
+
* @returns vNext Workflow instance
|
|
748
|
+
*/
|
|
749
|
+
getVNextWorkflow(workflowId: string): VNextWorkflow;
|
|
541
750
|
/**
|
|
542
751
|
* Gets a vector instance by name
|
|
543
752
|
* @param vectorName - Name of the vector to retrieve
|
|
@@ -580,6 +789,12 @@ declare class MastraClient extends BaseResource {
|
|
|
580
789
|
* @returns Network instance
|
|
581
790
|
*/
|
|
582
791
|
getNetwork(networkId: string): Network;
|
|
792
|
+
/**
|
|
793
|
+
* Gets an A2A client for interacting with an agent via the A2A protocol
|
|
794
|
+
* @param agentId - ID of the agent to interact with
|
|
795
|
+
* @returns A2A client instance
|
|
796
|
+
*/
|
|
797
|
+
getA2A(agentId: string): A2A;
|
|
583
798
|
}
|
|
584
799
|
|
|
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 };
|
|
800
|
+
export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextWorkflowResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type VNextWorkflowRunResult, type VNextWorkflowWatchResult, type WorkflowRunResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AbstractAgent } from '@ag-ui/client';
|
|
2
|
+
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
3
|
+
import { StepAction, StepGraph, CoreMessage, AiMessageType, StorageThreadType, MessageType, WorkflowRuns, WorkflowRunResult as WorkflowRunResult$1, QueryResult, BaseLogMessage, GenerateReturn } from '@mastra/core';
|
|
2
4
|
import { JSONSchema7 } from 'json-schema';
|
|
3
5
|
import { ZodSchema } from 'zod';
|
|
4
|
-
import { processDataStream } from '@ai-sdk/ui-utils';
|
|
5
6
|
import { AgentGenerateOptions, AgentStreamOptions } from '@mastra/core/agent';
|
|
7
|
+
import { NewWorkflow, WorkflowResult, WatchEvent } from '@mastra/core/workflows/vNext';
|
|
8
|
+
import { RuntimeContext } from '@mastra/core/di';
|
|
9
|
+
import { RuntimeContext as RuntimeContext$1 } from '@mastra/core/runtime-context';
|
|
10
|
+
import { AgentCard, TaskSendParams, Task, TaskQueryParams, TaskIdParams } from '@mastra/core/a2a';
|
|
6
11
|
|
|
7
12
|
interface ClientOptions {
|
|
8
13
|
/** Base URL for API requests */
|
|
@@ -27,17 +32,21 @@ interface GetAgentResponse {
|
|
|
27
32
|
name: string;
|
|
28
33
|
instructions: string;
|
|
29
34
|
tools: Record<string, GetToolResponse>;
|
|
35
|
+
workflows: Record<string, GetWorkflowResponse>;
|
|
30
36
|
provider: string;
|
|
31
37
|
modelId: string;
|
|
32
38
|
}
|
|
33
39
|
type GenerateParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
34
40
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
35
|
-
} & Partial<AgentGenerateOptions<T>>;
|
|
41
|
+
} & Partial<Omit<AgentGenerateOptions<T>, 'experimental_generateMessageId'>>;
|
|
36
42
|
type StreamParams<T extends JSONSchema7 | ZodSchema | undefined = undefined> = {
|
|
37
43
|
messages: string | string[] | CoreMessage[] | AiMessageType[];
|
|
38
|
-
} & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry'>;
|
|
44
|
+
} & Omit<AgentStreamOptions<T>, 'onFinish' | 'onStepFinish' | 'telemetry' | 'experimental_generateMessageId'>;
|
|
39
45
|
interface GetEvalsByAgentIdResponse extends GetAgentResponse {
|
|
40
46
|
evals: any[];
|
|
47
|
+
instructions: string;
|
|
48
|
+
name: string;
|
|
49
|
+
id: string;
|
|
41
50
|
}
|
|
42
51
|
interface GetToolResponse {
|
|
43
52
|
id: string;
|
|
@@ -53,6 +62,14 @@ interface GetWorkflowResponse {
|
|
|
53
62
|
stepSubscriberGraph: Record<string, StepGraph>;
|
|
54
63
|
workflowId?: string;
|
|
55
64
|
}
|
|
65
|
+
interface GetWorkflowRunsParams {
|
|
66
|
+
fromDate?: Date;
|
|
67
|
+
toDate?: Date;
|
|
68
|
+
limit?: number;
|
|
69
|
+
offset?: number;
|
|
70
|
+
resourceId?: string;
|
|
71
|
+
}
|
|
72
|
+
type GetWorkflowRunsResponse = WorkflowRuns;
|
|
56
73
|
type WorkflowRunResult = {
|
|
57
74
|
activePaths: Record<string, {
|
|
58
75
|
status: string;
|
|
@@ -63,6 +80,26 @@ type WorkflowRunResult = {
|
|
|
63
80
|
timestamp: number;
|
|
64
81
|
runId: string;
|
|
65
82
|
};
|
|
83
|
+
interface GetVNextWorkflowResponse {
|
|
84
|
+
name: string;
|
|
85
|
+
steps: {
|
|
86
|
+
[key: string]: {
|
|
87
|
+
id: string;
|
|
88
|
+
description: string;
|
|
89
|
+
inputSchema: string;
|
|
90
|
+
outputSchema: string;
|
|
91
|
+
resumeSchema: string;
|
|
92
|
+
suspendSchema: string;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
stepGraph: NewWorkflow['serializedStepGraph'];
|
|
96
|
+
inputSchema: string;
|
|
97
|
+
outputSchema: string;
|
|
98
|
+
}
|
|
99
|
+
type VNextWorkflowWatchResult = WatchEvent & {
|
|
100
|
+
runId: string;
|
|
101
|
+
};
|
|
102
|
+
type VNextWorkflowRunResult = WorkflowResult<any, any>;
|
|
66
103
|
interface UpsertVectorParams {
|
|
67
104
|
indexName: string;
|
|
68
105
|
vectors: number[][];
|
|
@@ -112,6 +149,12 @@ interface UpdateMemoryThreadParams {
|
|
|
112
149
|
metadata: Record<string, any>;
|
|
113
150
|
resourceId: string;
|
|
114
151
|
}
|
|
152
|
+
interface GetMemoryThreadMessagesParams {
|
|
153
|
+
/**
|
|
154
|
+
* Limit the number of messages to retrieve (default: 40)
|
|
155
|
+
*/
|
|
156
|
+
limit?: number;
|
|
157
|
+
}
|
|
115
158
|
interface GetMemoryThreadMessagesResponse {
|
|
116
159
|
messages: CoreMessage[];
|
|
117
160
|
uiMessages: AiMessageType[];
|
|
@@ -171,6 +214,8 @@ interface GetTelemetryParams {
|
|
|
171
214
|
page?: number;
|
|
172
215
|
perPage?: number;
|
|
173
216
|
attribute?: Record<string, string>;
|
|
217
|
+
fromDate?: Date;
|
|
218
|
+
toDate?: Date;
|
|
174
219
|
}
|
|
175
220
|
interface GetNetworkResponse {
|
|
176
221
|
name: string;
|
|
@@ -218,7 +263,9 @@ declare class AgentVoice extends BaseResource {
|
|
|
218
263
|
* @param options - Optional provider-specific options
|
|
219
264
|
* @returns Promise containing the transcribed text
|
|
220
265
|
*/
|
|
221
|
-
listen(audio: Blob, options?: Record<string, any>): Promise<
|
|
266
|
+
listen(audio: Blob, options?: Record<string, any>): Promise<{
|
|
267
|
+
text: string;
|
|
268
|
+
}>;
|
|
222
269
|
/**
|
|
223
270
|
* Get available speakers for the agent's voice provider
|
|
224
271
|
* @returns Promise containing list of available speakers
|
|
@@ -257,6 +304,16 @@ declare class Agent extends BaseResource {
|
|
|
257
304
|
* @returns Promise containing tool details
|
|
258
305
|
*/
|
|
259
306
|
getTool(toolId: string): Promise<GetToolResponse>;
|
|
307
|
+
/**
|
|
308
|
+
* Executes a tool for the agent
|
|
309
|
+
* @param toolId - ID of the tool to execute
|
|
310
|
+
* @param params - Parameters required for tool execution
|
|
311
|
+
* @returns Promise containing the tool execution results
|
|
312
|
+
*/
|
|
313
|
+
executeTool(toolId: string, params: {
|
|
314
|
+
data: any;
|
|
315
|
+
runtimeContext?: RuntimeContext;
|
|
316
|
+
}): Promise<any>;
|
|
260
317
|
/**
|
|
261
318
|
* Retrieves evaluation results for the agent
|
|
262
319
|
* @returns Promise containing agent evaluations
|
|
@@ -317,9 +374,10 @@ declare class MemoryThread extends BaseResource {
|
|
|
317
374
|
}>;
|
|
318
375
|
/**
|
|
319
376
|
* Retrieves messages associated with the thread
|
|
377
|
+
* @param params - Optional parameters including limit for number of messages to retrieve
|
|
320
378
|
* @returns Promise containing thread messages and UI messages
|
|
321
379
|
*/
|
|
322
|
-
getMessages(): Promise<GetMemoryThreadMessagesResponse>;
|
|
380
|
+
getMessages(params?: GetMemoryThreadMessagesParams): Promise<GetMemoryThreadMessagesResponse>;
|
|
323
381
|
}
|
|
324
382
|
|
|
325
383
|
declare class Vector extends BaseResource {
|
|
@@ -376,6 +434,12 @@ declare class Workflow extends BaseResource {
|
|
|
376
434
|
* @returns Promise containing workflow details including steps and graphs
|
|
377
435
|
*/
|
|
378
436
|
details(): Promise<GetWorkflowResponse>;
|
|
437
|
+
/**
|
|
438
|
+
* Retrieves all runs for a workflow
|
|
439
|
+
* @param params - Parameters for filtering runs
|
|
440
|
+
* @returns Promise containing workflow runs array
|
|
441
|
+
*/
|
|
442
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
|
|
379
443
|
/**
|
|
380
444
|
* @deprecated Use `startAsync` instead
|
|
381
445
|
* Executes the workflow with the provided parameters
|
|
@@ -469,9 +533,140 @@ declare class Tool extends BaseResource {
|
|
|
469
533
|
*/
|
|
470
534
|
execute(params: {
|
|
471
535
|
data: any;
|
|
536
|
+
runId?: string;
|
|
537
|
+
runtimeContext?: RuntimeContext;
|
|
472
538
|
}): Promise<any>;
|
|
473
539
|
}
|
|
474
540
|
|
|
541
|
+
declare class VNextWorkflow extends BaseResource {
|
|
542
|
+
private workflowId;
|
|
543
|
+
constructor(options: ClientOptions, workflowId: string);
|
|
544
|
+
/**
|
|
545
|
+
* Creates an async generator that processes a readable stream and yields vNext workflow records
|
|
546
|
+
* separated by the Record Separator character (\x1E)
|
|
547
|
+
*
|
|
548
|
+
* @param stream - The readable stream to process
|
|
549
|
+
* @returns An async generator that yields parsed records
|
|
550
|
+
*/
|
|
551
|
+
private streamProcessor;
|
|
552
|
+
/**
|
|
553
|
+
* Retrieves details about the vNext workflow
|
|
554
|
+
* @returns Promise containing vNext workflow details including steps and graphs
|
|
555
|
+
*/
|
|
556
|
+
details(): Promise<GetVNextWorkflowResponse>;
|
|
557
|
+
/**
|
|
558
|
+
* Retrieves all runs for a vNext workflow
|
|
559
|
+
* @param params - Parameters for filtering runs
|
|
560
|
+
* @returns Promise containing vNext workflow runs array
|
|
561
|
+
*/
|
|
562
|
+
runs(params?: GetWorkflowRunsParams): Promise<GetWorkflowRunsResponse>;
|
|
563
|
+
/**
|
|
564
|
+
* Creates a new vNext workflow run
|
|
565
|
+
* @param params - Optional object containing the optional runId
|
|
566
|
+
* @returns Promise containing the runId of the created run
|
|
567
|
+
*/
|
|
568
|
+
createRun(params?: {
|
|
569
|
+
runId?: string;
|
|
570
|
+
}): Promise<{
|
|
571
|
+
runId: string;
|
|
572
|
+
}>;
|
|
573
|
+
/**
|
|
574
|
+
* Starts a vNext workflow run synchronously without waiting for the workflow to complete
|
|
575
|
+
* @param params - Object containing the runId, inputData and runtimeContext
|
|
576
|
+
* @returns Promise containing success message
|
|
577
|
+
*/
|
|
578
|
+
start(params: {
|
|
579
|
+
runId: string;
|
|
580
|
+
inputData: Record<string, any>;
|
|
581
|
+
runtimeContext?: RuntimeContext$1;
|
|
582
|
+
}): Promise<{
|
|
583
|
+
message: string;
|
|
584
|
+
}>;
|
|
585
|
+
/**
|
|
586
|
+
* Resumes a suspended vNext workflow step synchronously without waiting for the vNext workflow to complete
|
|
587
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
588
|
+
* @returns Promise containing success message
|
|
589
|
+
*/
|
|
590
|
+
resume({ step, runId, resumeData, ...rest }: {
|
|
591
|
+
step: string | string[];
|
|
592
|
+
runId: string;
|
|
593
|
+
resumeData?: Record<string, any>;
|
|
594
|
+
runtimeContext?: RuntimeContext$1;
|
|
595
|
+
}): Promise<{
|
|
596
|
+
message: string;
|
|
597
|
+
}>;
|
|
598
|
+
/**
|
|
599
|
+
* Starts a vNext workflow run asynchronously and returns a promise that resolves when the vNext workflow is complete
|
|
600
|
+
* @param params - Object containing the optional runId, inputData and runtimeContext
|
|
601
|
+
* @returns Promise containing the vNext workflow execution results
|
|
602
|
+
*/
|
|
603
|
+
startAsync(params: {
|
|
604
|
+
runId?: string;
|
|
605
|
+
inputData: Record<string, any>;
|
|
606
|
+
runtimeContext?: RuntimeContext$1;
|
|
607
|
+
}): Promise<VNextWorkflowRunResult>;
|
|
608
|
+
/**
|
|
609
|
+
* Resumes a suspended vNext workflow step asynchronously and returns a promise that resolves when the vNext workflow is complete
|
|
610
|
+
* @param params - Object containing the runId, step, resumeData and runtimeContext
|
|
611
|
+
* @returns Promise containing the vNext workflow resume results
|
|
612
|
+
*/
|
|
613
|
+
resumeAsync(params: {
|
|
614
|
+
runId: string;
|
|
615
|
+
step: string | string[];
|
|
616
|
+
resumeData?: Record<string, any>;
|
|
617
|
+
runtimeContext?: RuntimeContext$1;
|
|
618
|
+
}): Promise<VNextWorkflowRunResult>;
|
|
619
|
+
/**
|
|
620
|
+
* Watches vNext workflow transitions in real-time
|
|
621
|
+
* @param runId - Optional run ID to filter the watch stream
|
|
622
|
+
* @returns AsyncGenerator that yields parsed records from the vNext workflow watch stream
|
|
623
|
+
*/
|
|
624
|
+
watch({ runId }: {
|
|
625
|
+
runId?: string;
|
|
626
|
+
}, onRecord: (record: VNextWorkflowWatchResult) => void): Promise<void>;
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
/**
|
|
630
|
+
* Class for interacting with an agent via the A2A protocol
|
|
631
|
+
*/
|
|
632
|
+
declare class A2A extends BaseResource {
|
|
633
|
+
private agentId;
|
|
634
|
+
constructor(options: ClientOptions, agentId: string);
|
|
635
|
+
/**
|
|
636
|
+
* Get the agent card with metadata about the agent
|
|
637
|
+
* @returns Promise containing the agent card information
|
|
638
|
+
*/
|
|
639
|
+
getCard(): Promise<AgentCard>;
|
|
640
|
+
/**
|
|
641
|
+
* Send a message to the agent and get a response
|
|
642
|
+
* @param params - Parameters for the task
|
|
643
|
+
* @returns Promise containing the task response
|
|
644
|
+
*/
|
|
645
|
+
sendMessage(params: TaskSendParams): Promise<{
|
|
646
|
+
task: Task;
|
|
647
|
+
}>;
|
|
648
|
+
/**
|
|
649
|
+
* Get the status and result of a task
|
|
650
|
+
* @param params - Parameters for querying the task
|
|
651
|
+
* @returns Promise containing the task response
|
|
652
|
+
*/
|
|
653
|
+
getTask(params: TaskQueryParams): Promise<Task>;
|
|
654
|
+
/**
|
|
655
|
+
* Cancel a running task
|
|
656
|
+
* @param params - Parameters identifying the task to cancel
|
|
657
|
+
* @returns Promise containing the task response
|
|
658
|
+
*/
|
|
659
|
+
cancelTask(params: TaskIdParams): Promise<{
|
|
660
|
+
task: Task;
|
|
661
|
+
}>;
|
|
662
|
+
/**
|
|
663
|
+
* Send a message and subscribe to streaming updates (not fully implemented)
|
|
664
|
+
* @param params - Parameters for the task
|
|
665
|
+
* @returns Promise containing the task response
|
|
666
|
+
*/
|
|
667
|
+
sendAndSubscribe(params: TaskSendParams): Promise<Response>;
|
|
668
|
+
}
|
|
669
|
+
|
|
475
670
|
declare class MastraClient extends BaseResource {
|
|
476
671
|
constructor(options: ClientOptions);
|
|
477
672
|
/**
|
|
@@ -479,6 +674,9 @@ declare class MastraClient extends BaseResource {
|
|
|
479
674
|
* @returns Promise containing map of agent IDs to agent details
|
|
480
675
|
*/
|
|
481
676
|
getAgents(): Promise<Record<string, GetAgentResponse>>;
|
|
677
|
+
getAGUI({ resourceId }: {
|
|
678
|
+
resourceId: string;
|
|
679
|
+
}): Promise<Record<string, AbstractAgent>>;
|
|
482
680
|
/**
|
|
483
681
|
* Gets an agent instance by ID
|
|
484
682
|
* @param agentId - ID of the agent to retrieve
|
|
@@ -538,6 +736,17 @@ declare class MastraClient extends BaseResource {
|
|
|
538
736
|
* @returns Workflow instance
|
|
539
737
|
*/
|
|
540
738
|
getWorkflow(workflowId: string): Workflow;
|
|
739
|
+
/**
|
|
740
|
+
* Retrieves all available vNext workflows
|
|
741
|
+
* @returns Promise containing map of vNext workflow IDs to vNext workflow details
|
|
742
|
+
*/
|
|
743
|
+
getVNextWorkflows(): Promise<Record<string, GetVNextWorkflowResponse>>;
|
|
744
|
+
/**
|
|
745
|
+
* Gets a vNext workflow instance by ID
|
|
746
|
+
* @param workflowId - ID of the vNext workflow to retrieve
|
|
747
|
+
* @returns vNext Workflow instance
|
|
748
|
+
*/
|
|
749
|
+
getVNextWorkflow(workflowId: string): VNextWorkflow;
|
|
541
750
|
/**
|
|
542
751
|
* Gets a vector instance by name
|
|
543
752
|
* @param vectorName - Name of the vector to retrieve
|
|
@@ -580,6 +789,12 @@ declare class MastraClient extends BaseResource {
|
|
|
580
789
|
* @returns Network instance
|
|
581
790
|
*/
|
|
582
791
|
getNetwork(networkId: string): Network;
|
|
792
|
+
/**
|
|
793
|
+
* Gets an A2A client for interacting with an agent via the A2A protocol
|
|
794
|
+
* @param agentId - ID of the agent to interact with
|
|
795
|
+
* @returns A2A client instance
|
|
796
|
+
*/
|
|
797
|
+
getA2A(agentId: string): A2A;
|
|
583
798
|
}
|
|
584
799
|
|
|
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 };
|
|
800
|
+
export { type ClientOptions, type CreateIndexParams, type CreateMemoryThreadParams, type CreateMemoryThreadResponse, type GenerateParams, type GetAgentResponse, type GetEvalsByAgentIdResponse, type GetLogParams, type GetLogsParams, type GetLogsResponse, type GetMemoryThreadMessagesParams, type GetMemoryThreadMessagesResponse, type GetMemoryThreadParams, type GetMemoryThreadResponse, type GetNetworkResponse, type GetTelemetryParams, type GetTelemetryResponse, type GetToolResponse, type GetVNextWorkflowResponse, type GetVectorIndexResponse, type GetWorkflowResponse, type GetWorkflowRunsParams, type GetWorkflowRunsResponse, MastraClient, type QueryVectorParams, type QueryVectorResponse, type RequestFunction, type RequestOptions, type SaveMessageToMemoryParams, type SaveMessageToMemoryResponse, type StreamParams, type UpdateMemoryThreadParams, type UpsertVectorParams, type VNextWorkflowRunResult, type VNextWorkflowWatchResult, type WorkflowRunResult };
|