@mastra/core 0.9.4 → 0.10.0-alpha.1
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/README.md +3 -2
- package/dist/agent/index.cjs +2 -2
- package/dist/agent/index.d.cts +13 -14
- package/dist/agent/index.d.ts +13 -14
- package/dist/agent/index.js +1 -1
- package/dist/{base-BCfssGt6.d.ts → base-DttB7sJD.d.ts} +1187 -886
- package/dist/{base-CAEcd6q2.d.cts → base-aJ3etsh5.d.cts} +1187 -886
- package/dist/{base-H7siSAfu.d.cts → base-aPYtPBT2.d.cts} +3 -3
- package/dist/{base-4Z34GQL8.d.ts → base-tc5kgDTD.d.ts} +3 -3
- package/dist/base.cjs +2 -2
- package/dist/base.d.cts +2 -3
- package/dist/base.d.ts +2 -3
- package/dist/base.js +1 -1
- package/dist/bundler/index.cjs +2 -2
- package/dist/bundler/index.d.cts +2 -3
- package/dist/bundler/index.d.ts +2 -3
- package/dist/bundler/index.js +1 -1
- package/dist/{chunk-W4BSLENO.js → chunk-2NTUAUGH.js} +1 -1
- package/dist/{chunk-S34QVMKE.js → chunk-2PW6UJMW.js} +77 -10
- package/dist/{chunk-WE36CRQV.cjs → chunk-2U7ZZUFO.cjs} +2 -2
- package/dist/{workflows/vNext/index.js → chunk-3SQ3G2EJ.js} +19 -16
- package/dist/chunk-5HULBQ2W.cjs +38 -0
- package/dist/{chunk-XRGDVLM4.cjs → chunk-5JRD3NDP.cjs} +15 -15
- package/dist/{chunk-GXKODTLA.cjs → chunk-5W2G7S44.cjs} +83 -68
- package/dist/chunk-75Z4BZEE.js +36 -0
- package/dist/{chunk-66GQROSI.cjs → chunk-AOGUTJUO.cjs} +58 -51
- package/dist/{chunk-WIKOYZ63.js → chunk-BPTSLJHA.js} +9 -9
- package/dist/{chunk-JBJ7KXN5.js → chunk-C3ICEF6E.js} +1 -1
- package/dist/{chunk-E4FAXBUV.cjs → chunk-CWSFP2HS.cjs} +2 -2
- package/dist/{chunk-FW5RS6WV.js → chunk-E7CLY6SK.js} +42 -35
- package/dist/{chunk-235X76GC.js → chunk-FI7R232B.js} +2 -2
- package/dist/chunk-GQ2XQ4UN.js +321 -0
- package/dist/{chunk-H4CEZSRM.js → chunk-J7GDGV6F.js} +1 -1
- package/dist/{chunk-NLBJOFNG.js → chunk-JW5TMK2L.js} +1 -1
- package/dist/{chunk-NOPY74PV.js → chunk-KJQFFEEQ.js} +1 -1
- package/dist/{chunk-V2Q2FEVO.cjs → chunk-KSPHQSZX.cjs} +2 -2
- package/dist/{chunk-NZV4OA6P.js → chunk-LHRZV5VG.js} +2 -23
- package/dist/chunk-NMDM4IZN.cjs +78 -0
- package/dist/chunk-OBEALYTK.js +74 -0
- package/dist/{chunk-PEK4TY3P.js → chunk-OCT2762Q.js} +1 -1
- package/dist/{chunk-5DUFC7TV.cjs → chunk-P7BGXOQV.cjs} +2 -2
- package/dist/{chunk-WQKOM7XM.cjs → chunk-PIZM25KI.cjs} +3 -24
- package/dist/{chunk-S7J63JOG.cjs → chunk-RVS6OUJN.cjs} +2 -2
- package/dist/{chunk-5JUWUTPJ.cjs → chunk-SKG2NIZW.cjs} +2 -2
- package/dist/chunk-SWW4EBUZ.cjs +96 -0
- package/dist/{chunk-RGE4UF6A.cjs → chunk-TMPFLJLG.cjs} +2 -2
- package/dist/{workflows/vNext/index.cjs → chunk-TTKQ37ZZ.cjs} +24 -21
- package/dist/{chunk-EJITEVAB.cjs → chunk-U3L3NEOM.cjs} +81 -10
- package/dist/chunk-VHLL4AZK.js +90 -0
- package/dist/{chunk-EG74VBSP.cjs → chunk-YEULQPUY.cjs} +6 -6
- package/dist/{chunk-SOLXHDNQ.js → chunk-ZB3LEHL2.js} +81 -66
- package/dist/{chunk-TAFOICHR.js → chunk-ZKN6HYYQ.js} +1 -1
- package/dist/chunk-ZZDAC5KD.cjs +325 -0
- package/dist/deployer/index.cjs +2 -2
- package/dist/deployer/index.d.cts +2 -3
- package/dist/deployer/index.d.ts +2 -3
- package/dist/deployer/index.js +1 -1
- package/dist/eval/index.d.cts +13 -14
- package/dist/eval/index.d.ts +13 -14
- package/dist/hooks/index.d.cts +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/index.cjs +88 -159
- package/dist/index.d.cts +17 -25
- package/dist/index.d.ts +17 -25
- package/dist/index.js +18 -25
- package/dist/integration/index.cjs +3 -3
- package/dist/integration/index.d.cts +12 -13
- package/dist/integration/index.d.ts +12 -13
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.d.cts +13 -14
- package/dist/llm/index.d.ts +13 -14
- package/dist/logger/index.cjs +18 -17
- package/dist/logger/index.d.cts +42 -2
- package/dist/logger/index.d.ts +42 -2
- package/dist/logger/index.js +2 -1
- package/dist/{index-QV27jkxQ.d.ts → logger-EhZkzZOr.d.cts} +38 -52
- package/dist/{index-QV27jkxQ.d.cts → logger-EhZkzZOr.d.ts} +38 -52
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.cts +11 -12
- package/dist/mastra/index.d.ts +11 -12
- package/dist/mastra/index.js +1 -1
- package/dist/mcp/index.cjs +75 -17
- package/dist/mcp/index.d.cts +14 -15
- package/dist/mcp/index.d.ts +14 -15
- package/dist/mcp/index.js +69 -15
- package/dist/memory/index.cjs +4 -4
- package/dist/memory/index.d.cts +12 -13
- package/dist/memory/index.d.ts +12 -13
- package/dist/memory/index.js +1 -1
- package/dist/network/index.cjs +8 -8
- package/dist/network/index.d.cts +12 -13
- package/dist/network/index.d.ts +12 -13
- package/dist/network/index.js +5 -5
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.d.cts +15 -16
- package/dist/relevance/index.d.ts +15 -16
- package/dist/relevance/index.js +1 -1
- package/dist/server/index.cjs +4 -0
- package/dist/server/index.d.cts +13 -12
- package/dist/server/index.d.ts +13 -12
- package/dist/server/index.js +4 -1
- package/dist/storage/index.cjs +184 -3
- package/dist/storage/index.d.cts +83 -13
- package/dist/storage/index.d.ts +83 -13
- package/dist/storage/index.js +186 -1
- package/dist/telemetry/index.d.cts +14 -15
- package/dist/telemetry/index.d.ts +14 -15
- package/dist/telemetry/otel-vendor.cjs +2 -2
- package/dist/telemetry/otel-vendor.d.cts +1 -1
- package/dist/telemetry/otel-vendor.d.ts +1 -1
- package/dist/telemetry/otel-vendor.js +1 -1
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.d.cts +12 -13
- package/dist/tools/index.d.ts +12 -13
- package/dist/tools/index.js +1 -1
- package/dist/tts/index.cjs +2 -2
- package/dist/tts/index.d.cts +2 -3
- package/dist/tts/index.d.ts +2 -3
- package/dist/tts/index.js +1 -1
- package/dist/{types-BtMyV38I.d.ts → types-Bo1uigWx.d.cts} +1 -1
- package/dist/{types-BtMyV38I.d.cts → types-Bo1uigWx.d.ts} +1 -1
- package/dist/utils.cjs +28 -12
- package/dist/utils.d.cts +59 -16
- package/dist/utils.d.ts +59 -16
- package/dist/utils.js +1 -1
- package/dist/vector/filter/index.cjs +189 -7
- package/dist/vector/filter/index.js +190 -1
- package/dist/vector/index.cjs +2 -2
- package/dist/vector/index.d.cts +28 -20
- package/dist/vector/index.d.ts +28 -20
- package/dist/vector/index.js +1 -1
- package/dist/voice/index.cjs +4 -4
- package/dist/voice/index.d.cts +12 -13
- package/dist/voice/index.d.ts +12 -13
- package/dist/voice/index.js +1 -1
- package/dist/workflows/index.cjs +17 -69
- package/dist/workflows/index.d.cts +197 -77
- package/dist/workflows/index.d.ts +197 -77
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/legacy/index.cjs +90 -0
- package/dist/workflows/legacy/index.d.cts +87 -0
- package/dist/workflows/legacy/index.d.ts +87 -0
- package/dist/workflows/legacy/index.js +1 -0
- package/package.json +19 -40
- package/workflows/legacy.d.ts +1 -0
- package/dist/chunk-4WABQORE.js +0 -781
- package/dist/chunk-CIEPFV6B.js +0 -658
- package/dist/chunk-CMPPXW4U.js +0 -154
- package/dist/chunk-CTKNWYK2.js +0 -131
- package/dist/chunk-LGERQTJM.js +0 -190
- package/dist/chunk-O44MSFMZ.cjs +0 -168
- package/dist/chunk-QDAMIZY3.cjs +0 -783
- package/dist/chunk-QHDPLMHB.cjs +0 -667
- package/dist/chunk-RAQBTCIR.cjs +0 -134
- package/dist/chunk-YK3XJ52U.cjs +0 -192
- package/dist/storage/libsql/index.cjs +0 -581
- package/dist/storage/libsql/index.d.cts +0 -104
- package/dist/storage/libsql/index.d.ts +0 -104
- package/dist/storage/libsql/index.js +0 -578
- package/dist/vector/libsql/index.cjs +0 -14
- package/dist/vector/libsql/index.d.cts +0 -82
- package/dist/vector/libsql/index.d.ts +0 -82
- package/dist/vector/libsql/index.js +0 -1
- package/dist/workflows/vNext/index.d.cts +0 -209
- package/dist/workflows/vNext/index.d.ts +0 -209
- package/storage/libsql.d.ts +0 -1
- package/vector/libsql.d.ts +0 -1
- package/workflows/vNext.d.ts +0 -1
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
|
-
import { Tool as Tool$1, Schema, ToolExecutionOptions,
|
|
3
|
-
import { M as MastraBase, T as Telemetry, O as OtelConfig } from './base-
|
|
4
|
-
import {
|
|
2
|
+
import { Tool as Tool$1, Schema, ToolExecutionOptions, EmbeddingModel, CoreMessage as CoreMessage$1, Message, UserContent, AssistantContent, LanguageModel as LanguageModel$1, GenerateTextResult, GenerateObjectResult, StreamTextResult, StreamObjectResult, DeepPartial, generateText, generateObject, streamText, streamObject, TelemetrySettings, CoreSystemMessage as CoreSystemMessage$1, CoreAssistantMessage as CoreAssistantMessage$1, CoreUserMessage as CoreUserMessage$1, CoreToolMessage as CoreToolMessage$1, EmbedResult as EmbedResult$1, EmbedManyResult as EmbedManyResult$1, LanguageModelV1, GenerateTextOnStepFinishCallback, StreamTextOnFinishCallback, StreamObjectOnFinishCallback, StreamTextOnStepFinishCallback, ToolContent } from 'ai';
|
|
3
|
+
import { M as MastraBase, T as Telemetry, O as OtelConfig } from './base-tc5kgDTD.js';
|
|
4
|
+
import { M as Metric, a as MetricResult, T as TestInfo } from './types-Bo1uigWx.js';
|
|
5
5
|
import { Query } from 'sift';
|
|
6
6
|
import { z, ZodSchema } from 'zod';
|
|
7
7
|
import { JSONSchema7Type, JSONSchema7 } from 'json-schema';
|
|
8
|
-
import {
|
|
8
|
+
import { MastraDeployer } from './deployer/index.js';
|
|
9
|
+
import { B as BaseLogMessage, R as RegisteredLogger, I as IMastraLogger } from './logger-EhZkzZOr.js';
|
|
10
|
+
import * as http from 'node:http';
|
|
11
|
+
import { Context, Handler, MiddlewareHandler, HonoRequest } from 'hono';
|
|
9
12
|
import { RuntimeContext } from './runtime-context/index.js';
|
|
13
|
+
import { MastraVector } from './vector/index.js';
|
|
14
|
+
import { cors } from 'hono/cors';
|
|
15
|
+
import { DescribeRouteOptions } from 'hono-openapi';
|
|
16
|
+
import { MastraTTS } from './tts/index.js';
|
|
10
17
|
import { Span } from '@opentelemetry/api';
|
|
11
18
|
import * as xstate from 'xstate';
|
|
12
19
|
import { Snapshot } from 'xstate';
|
|
13
20
|
import EventEmitter from 'node:events';
|
|
14
|
-
import { MastraVector } from './vector/index.js';
|
|
15
|
-
import { MastraTTS } from './tts/index.js';
|
|
16
|
-
import * as http from 'node:http';
|
|
17
|
-
import { Context, Handler, MiddlewareHandler } from 'hono';
|
|
18
21
|
import EventEmitter$1 from 'events';
|
|
19
|
-
import { MastraDeployer } from './deployer/index.js';
|
|
20
|
-
import { cors } from 'hono/cors';
|
|
21
|
-
import { DescribeRouteOptions } from 'hono-openapi';
|
|
22
22
|
import { MockLanguageModelV1 } from 'ai/test';
|
|
23
23
|
|
|
24
24
|
type VercelTool = Tool$1;
|
|
@@ -75,262 +75,484 @@ declare function createTool<TSchemaIn extends z.ZodSchema | undefined = undefine
|
|
|
75
75
|
execute: (context: TContext) => Promise<any>;
|
|
76
76
|
} : Tool<TSchemaIn, TSchemaOut, TContext>;
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
*/
|
|
89
|
-
version: string;
|
|
90
|
-
/**
|
|
91
|
-
* Tools to register with the MCP server
|
|
92
|
-
*/
|
|
93
|
-
tools: ToolsInput;
|
|
94
|
-
}
|
|
95
|
-
type ConvertedTool = {
|
|
96
|
-
name: string;
|
|
97
|
-
description?: string;
|
|
98
|
-
parameters: InternalCoreTool['parameters'];
|
|
99
|
-
execute: InternalCoreTool['execute'];
|
|
78
|
+
type RunStatus = 'created' | 'running' | 'completed' | 'failed';
|
|
79
|
+
type Run$1 = {
|
|
80
|
+
runId?: string;
|
|
81
|
+
runStatus?: RunStatus;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
type MemoryProcessorOpts = {
|
|
85
|
+
systemMessage?: string;
|
|
86
|
+
memorySystemMessage?: string;
|
|
87
|
+
newMessages?: CoreMessage$1[];
|
|
100
88
|
};
|
|
101
|
-
interface MCPServerSSEOptionsBase {
|
|
102
|
-
/**
|
|
103
|
-
* Parsed URL of the incoming request
|
|
104
|
-
*/
|
|
105
|
-
url: URL;
|
|
106
|
-
/**
|
|
107
|
-
* Path for establishing the SSE connection (e.g. '/sse')
|
|
108
|
-
*/
|
|
109
|
-
ssePath: string;
|
|
110
|
-
/**
|
|
111
|
-
* Path for POSTing client messages (e.g. '/message')
|
|
112
|
-
*/
|
|
113
|
-
messagePath: string;
|
|
114
|
-
}
|
|
115
89
|
/**
|
|
116
|
-
*
|
|
90
|
+
* Interface for message processors that can filter or transform messages
|
|
91
|
+
* before they're sent to the LLM.
|
|
117
92
|
*/
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Incoming HTTP request
|
|
121
|
-
*/
|
|
122
|
-
req: http.IncomingMessage;
|
|
93
|
+
declare abstract class MemoryProcessor extends MastraBase {
|
|
123
94
|
/**
|
|
124
|
-
*
|
|
95
|
+
* Process a list of messages and return a filtered or transformed list.
|
|
96
|
+
* @param messages The messages to process
|
|
97
|
+
* @returns The processed messages
|
|
125
98
|
*/
|
|
126
|
-
|
|
99
|
+
process(messages: CoreMessage$1[], _opts: MemoryProcessorOpts): CoreMessage$1[];
|
|
127
100
|
}
|
|
101
|
+
declare const memoryDefaultOptions: {
|
|
102
|
+
lastMessages: number;
|
|
103
|
+
semanticRecall: false;
|
|
104
|
+
threads: {
|
|
105
|
+
generateTitle: false;
|
|
106
|
+
};
|
|
107
|
+
workingMemory: {
|
|
108
|
+
enabled: false;
|
|
109
|
+
template: string;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
128
112
|
/**
|
|
129
|
-
*
|
|
113
|
+
* Abstract Memory class that defines the interface for storing and retrieving
|
|
114
|
+
* conversation threads and messages.
|
|
130
115
|
*/
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
* Incoming HTTP request
|
|
148
|
-
*/
|
|
149
|
-
req: http.IncomingMessage;
|
|
150
|
-
/**
|
|
151
|
-
* HTTP response (must support .write/.end)
|
|
152
|
-
*/
|
|
153
|
-
res: http.ServerResponse<http.IncomingMessage>;
|
|
116
|
+
declare abstract class MastraMemory extends MastraBase {
|
|
117
|
+
MAX_CONTEXT_TOKENS?: number;
|
|
118
|
+
_storage?: MastraStorage;
|
|
119
|
+
vector?: MastraVector;
|
|
120
|
+
embedder?: EmbeddingModel<string>;
|
|
121
|
+
private processors;
|
|
122
|
+
protected threadConfig: MemoryConfig;
|
|
123
|
+
constructor(config: {
|
|
124
|
+
name: string;
|
|
125
|
+
} & SharedMemoryConfig);
|
|
126
|
+
protected _hasOwnStorage: boolean;
|
|
127
|
+
get hasOwnStorage(): boolean;
|
|
128
|
+
get storage(): MastraStorage;
|
|
129
|
+
setStorage(storage: MastraStorage): void;
|
|
130
|
+
setVector(vector: MastraVector): void;
|
|
131
|
+
setEmbedder(embedder: EmbeddingModel<string>): void;
|
|
154
132
|
/**
|
|
155
|
-
*
|
|
133
|
+
* Get a system message to inject into the conversation.
|
|
134
|
+
* This will be called before each conversation turn.
|
|
135
|
+
* Implementations can override this to inject custom system messages.
|
|
156
136
|
*/
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
* Abstract base class for MCP server implementations
|
|
162
|
-
* This provides a common interface for all MCP servers that can be registered with Mastra
|
|
163
|
-
*/
|
|
164
|
-
declare abstract class MCPServerBase extends MastraBase {
|
|
137
|
+
getSystemMessage(_input: {
|
|
138
|
+
threadId: string;
|
|
139
|
+
memoryConfig?: MemoryConfig;
|
|
140
|
+
}): Promise<string | null>;
|
|
165
141
|
/**
|
|
166
|
-
*
|
|
142
|
+
* Get tools that should be available to the agent.
|
|
143
|
+
* This will be called when converting tools for the agent.
|
|
144
|
+
* Implementations can override this to provide additional tools.
|
|
167
145
|
*/
|
|
168
|
-
|
|
146
|
+
getTools(_config?: MemoryConfig): Record<string, CoreTool>;
|
|
147
|
+
protected createEmbeddingIndex(dimensions?: number): Promise<{
|
|
148
|
+
indexName: string;
|
|
149
|
+
}>;
|
|
150
|
+
getMergedThreadConfig(config?: MemoryConfig): MemoryConfig;
|
|
169
151
|
/**
|
|
170
|
-
*
|
|
152
|
+
* Apply all configured message processors to a list of messages.
|
|
153
|
+
* @param messages The messages to process
|
|
154
|
+
* @returns The processed messages
|
|
171
155
|
*/
|
|
172
|
-
|
|
156
|
+
private applyProcessors;
|
|
157
|
+
processMessages({ messages, processors, ...opts }: {
|
|
158
|
+
messages: CoreMessage$1[];
|
|
159
|
+
processors?: MemoryProcessor[];
|
|
160
|
+
} & MemoryProcessorOpts): CoreMessage$1[];
|
|
161
|
+
abstract rememberMessages({ threadId, resourceId, vectorMessageSearch, systemMessage, config, }: {
|
|
162
|
+
threadId: string;
|
|
163
|
+
resourceId?: string;
|
|
164
|
+
vectorMessageSearch?: string;
|
|
165
|
+
systemMessage?: CoreMessage$1;
|
|
166
|
+
config?: MemoryConfig;
|
|
167
|
+
}): Promise<{
|
|
168
|
+
threadId: string;
|
|
169
|
+
messages: CoreMessage$1[];
|
|
170
|
+
uiMessages: Message[];
|
|
171
|
+
}>;
|
|
172
|
+
estimateTokens(text: string): number;
|
|
173
|
+
protected parseMessages(messages: MessageType[]): CoreMessage$1[];
|
|
174
|
+
protected convertToUIMessages(messages: MessageType[]): Message[];
|
|
173
175
|
/**
|
|
174
|
-
*
|
|
176
|
+
* Retrieves a specific thread by its ID
|
|
177
|
+
* @param threadId - The unique identifier of the thread
|
|
178
|
+
* @returns Promise resolving to the thread or null if not found
|
|
175
179
|
*/
|
|
176
|
-
|
|
177
|
-
|
|
180
|
+
abstract getThreadById({ threadId }: {
|
|
181
|
+
threadId: string;
|
|
182
|
+
}): Promise<StorageThreadType | null>;
|
|
183
|
+
abstract getThreadsByResourceId({ resourceId }: {
|
|
184
|
+
resourceId: string;
|
|
185
|
+
}): Promise<StorageThreadType[]>;
|
|
178
186
|
/**
|
|
179
|
-
*
|
|
187
|
+
* Saves or updates a thread
|
|
188
|
+
* @param thread - The thread data to save
|
|
189
|
+
* @returns Promise resolving to the saved thread
|
|
180
190
|
*/
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
191
|
+
abstract saveThread({ thread, memoryConfig, }: {
|
|
192
|
+
thread: StorageThreadType;
|
|
193
|
+
memoryConfig?: MemoryConfig;
|
|
194
|
+
}): Promise<StorageThreadType>;
|
|
184
195
|
/**
|
|
185
|
-
*
|
|
186
|
-
* @param
|
|
196
|
+
* Saves messages to a thread
|
|
197
|
+
* @param messages - Array of messages to save
|
|
198
|
+
* @returns Promise resolving to the saved messages
|
|
187
199
|
*/
|
|
188
|
-
|
|
200
|
+
abstract saveMessages({ messages, memoryConfig, }: {
|
|
201
|
+
messages: MessageType[];
|
|
202
|
+
memoryConfig: MemoryConfig | undefined;
|
|
203
|
+
}): Promise<MessageType[]>;
|
|
189
204
|
/**
|
|
190
|
-
*
|
|
191
|
-
*
|
|
205
|
+
* Retrieves all messages for a specific thread
|
|
206
|
+
* @param threadId - The unique identifier of the thread
|
|
207
|
+
* @returns Promise resolving to array of messages and uiMessages
|
|
192
208
|
*/
|
|
193
|
-
abstract
|
|
209
|
+
abstract query({ threadId, resourceId, selectBy, }: StorageGetMessagesArg): Promise<{
|
|
210
|
+
messages: CoreMessage$1[];
|
|
211
|
+
uiMessages: Message[];
|
|
212
|
+
}>;
|
|
194
213
|
/**
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
* @param
|
|
214
|
+
* Helper method to create a new thread
|
|
215
|
+
* @param title - Optional title for the thread
|
|
216
|
+
* @param metadata - Optional metadata for the thread
|
|
217
|
+
* @returns Promise resolving to the created thread
|
|
198
218
|
*/
|
|
199
|
-
|
|
219
|
+
createThread({ threadId, resourceId, title, metadata, memoryConfig, }: {
|
|
220
|
+
resourceId: string;
|
|
221
|
+
threadId?: string;
|
|
222
|
+
title?: string;
|
|
223
|
+
metadata?: Record<string, unknown>;
|
|
224
|
+
memoryConfig?: MemoryConfig;
|
|
225
|
+
}): Promise<StorageThreadType>;
|
|
200
226
|
/**
|
|
201
|
-
*
|
|
202
|
-
*
|
|
203
|
-
* @param options Options for the SSE transport
|
|
227
|
+
* Helper method to delete a thread
|
|
228
|
+
* @param threadId - the id of the thread to delete
|
|
204
229
|
*/
|
|
205
|
-
abstract
|
|
230
|
+
abstract deleteThread(threadId: string): Promise<void>;
|
|
206
231
|
/**
|
|
207
|
-
*
|
|
208
|
-
* @param
|
|
232
|
+
* Helper method to add a single message to a thread
|
|
233
|
+
* @param threadId - The thread to add the message to
|
|
234
|
+
* @param content - The message content
|
|
235
|
+
* @param role - The role of the message sender
|
|
236
|
+
* @param type - The type of the message
|
|
237
|
+
* @param toolNames - Optional array of tool names that were called
|
|
238
|
+
* @param toolCallArgs - Optional array of tool call arguments
|
|
239
|
+
* @param toolCallIds - Optional array of tool call ids
|
|
240
|
+
* @returns Promise resolving to the saved message
|
|
209
241
|
*/
|
|
210
|
-
|
|
242
|
+
addMessage({ threadId, resourceId, config, content, role, type, toolNames, toolCallArgs, toolCallIds, }: {
|
|
243
|
+
threadId: string;
|
|
244
|
+
resourceId: string;
|
|
245
|
+
config?: MemoryConfig;
|
|
246
|
+
content: UserContent | AssistantContent;
|
|
247
|
+
role: 'user' | 'assistant';
|
|
248
|
+
type: 'text' | 'tool-call' | 'tool-result';
|
|
249
|
+
toolNames?: string[];
|
|
250
|
+
toolCallArgs?: Record<string, unknown>[];
|
|
251
|
+
toolCallIds?: string[];
|
|
252
|
+
}): Promise<MessageType>;
|
|
211
253
|
/**
|
|
212
|
-
*
|
|
254
|
+
* Generates a unique identifier
|
|
255
|
+
* @returns A unique string ID
|
|
213
256
|
*/
|
|
214
|
-
|
|
257
|
+
generateId(): string;
|
|
215
258
|
}
|
|
216
259
|
|
|
217
|
-
|
|
218
|
-
name: string;
|
|
219
|
-
agents: Agent[];
|
|
220
|
-
model: LanguageModelV1;
|
|
221
|
-
instructions: string;
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
declare class AgentNetwork extends MastraBase {
|
|
260
|
+
declare class MastraLLMBase extends MastraBase {
|
|
225
261
|
#private;
|
|
226
|
-
constructor(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
actions: {
|
|
277
|
-
input: string;
|
|
278
|
-
agent: string;
|
|
279
|
-
includeHistory?: boolean | undefined;
|
|
280
|
-
}[];
|
|
281
|
-
}>>>;
|
|
262
|
+
constructor({ name, model }: {
|
|
263
|
+
name: string;
|
|
264
|
+
model: LanguageModel$1;
|
|
265
|
+
});
|
|
266
|
+
getProvider(): string;
|
|
267
|
+
getModelId(): string;
|
|
268
|
+
getModel(): ai.LanguageModelV1;
|
|
269
|
+
convertToMessages(messages: string | string[] | CoreMessage$1[]): CoreMessage$1[];
|
|
270
|
+
__registerPrimitives(p: MastraPrimitives): void;
|
|
271
|
+
__registerMastra(p: Mastra): void;
|
|
272
|
+
__text<Z extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextOptions<Z>): Promise<GenerateTextResult<any, any>>;
|
|
273
|
+
__textObject<T extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextObjectOptions<T>): Promise<GenerateObjectResult<T>>;
|
|
274
|
+
generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options: LLMStreamOptions<Z>): Promise<GenerateReturn<Z>>;
|
|
275
|
+
__stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(input: LLMInnerStreamOptions<Z>): Promise<StreamTextResult<any, any>>;
|
|
276
|
+
__streamObject<T extends ZodSchema | JSONSchema7 | undefined>(input: LLMStreamObjectOptions<T>): Promise<StreamObjectResult<DeepPartial<T>, T, never>>;
|
|
277
|
+
stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options: LLMStreamOptions<Z>): Promise<StreamReturn<Z>>;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
declare function createMockModel({ objectGenerationMode, mockText, spyGenerate, spyStream, }: {
|
|
281
|
+
objectGenerationMode?: 'json';
|
|
282
|
+
mockText: string | Record<string, any>;
|
|
283
|
+
spyGenerate?: (props: any) => void;
|
|
284
|
+
spyStream?: (props: any) => void;
|
|
285
|
+
}): MockLanguageModelV1;
|
|
286
|
+
|
|
287
|
+
type LanguageModel = MastraLanguageModel;
|
|
288
|
+
type CoreMessage = CoreMessage$1;
|
|
289
|
+
type CoreSystemMessage = CoreSystemMessage$1;
|
|
290
|
+
type CoreAssistantMessage = CoreAssistantMessage$1;
|
|
291
|
+
type CoreUserMessage = CoreUserMessage$1;
|
|
292
|
+
type CoreToolMessage = CoreToolMessage$1;
|
|
293
|
+
type EmbedResult<T> = EmbedResult$1<T>;
|
|
294
|
+
type EmbedManyResult<T> = EmbedManyResult$1<T>;
|
|
295
|
+
type BaseStructuredOutputType = 'string' | 'number' | 'boolean' | 'date';
|
|
296
|
+
type StructuredOutputType = 'array' | 'string' | 'number' | 'object' | 'boolean' | 'date';
|
|
297
|
+
type StructuredOutputArrayItem = {
|
|
298
|
+
type: BaseStructuredOutputType;
|
|
299
|
+
} | {
|
|
300
|
+
type: 'object';
|
|
301
|
+
items: StructuredOutput;
|
|
302
|
+
};
|
|
303
|
+
type StructuredOutput = {
|
|
304
|
+
[key: string]: {
|
|
305
|
+
type: BaseStructuredOutputType;
|
|
306
|
+
} | {
|
|
307
|
+
type: 'object';
|
|
308
|
+
items: StructuredOutput;
|
|
309
|
+
} | {
|
|
310
|
+
type: 'array';
|
|
311
|
+
items: StructuredOutputArrayItem;
|
|
282
312
|
};
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
313
|
+
};
|
|
314
|
+
type GenerateReturn<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = Z extends undefined ? GenerateTextResult<any, Z extends ZodSchema ? z.infer<Z> : unknown> : GenerateObjectResult<Z extends ZodSchema ? z.infer<Z> : unknown>;
|
|
315
|
+
type StreamReturn<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = Z extends undefined ? StreamTextResult<any, Z extends ZodSchema ? z.infer<Z> : unknown> : StreamObjectResult<any, Z extends ZodSchema ? z.infer<Z> : unknown, any>;
|
|
316
|
+
type OutputType = StructuredOutput | ZodSchema | JSONSchema7 | undefined;
|
|
317
|
+
type GenerateTextOptions = Parameters<typeof generateText>[0];
|
|
318
|
+
type StreamTextOptions = Parameters<typeof streamText>[0];
|
|
319
|
+
type GenerateObjectOptions = Parameters<typeof generateObject>[0];
|
|
320
|
+
type StreamObjectOptions = Parameters<typeof streamObject>[0];
|
|
321
|
+
type MastraCustomLLMOptionsKeys = 'messages' | 'tools' | 'model' | 'onStepFinish' | 'experimental_output' | 'experimental_telemetry' | 'messages' | 'onFinish' | 'output';
|
|
322
|
+
type DefaultLLMTextOptions = Omit<GenerateTextOptions, MastraCustomLLMOptionsKeys>;
|
|
323
|
+
type DefaultLLMTextObjectOptions = Omit<GenerateObjectOptions, MastraCustomLLMOptionsKeys>;
|
|
324
|
+
type DefaultLLMStreamOptions = Omit<StreamTextOptions, MastraCustomLLMOptionsKeys>;
|
|
325
|
+
type DefaultLLMStreamObjectOptions = Omit<StreamObjectOptions, MastraCustomLLMOptionsKeys>;
|
|
326
|
+
type MastraCustomLLMOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
327
|
+
tools?: Record<string, CoreTool>;
|
|
328
|
+
onStepFinish?: (step: unknown) => Promise<void> | void;
|
|
329
|
+
experimental_output?: Z;
|
|
330
|
+
telemetry?: TelemetrySettings;
|
|
331
|
+
threadId?: string;
|
|
332
|
+
resourceId?: string;
|
|
333
|
+
runtimeContext: RuntimeContext;
|
|
334
|
+
} & Run$1;
|
|
335
|
+
type LLMTextOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
336
|
+
messages: CoreMessage[];
|
|
337
|
+
} & MastraCustomLLMOptions<Z> & DefaultLLMTextOptions;
|
|
338
|
+
type LLMTextObjectOptions<T extends ZodSchema | JSONSchema7 | undefined = undefined> = LLMTextOptions<T> & DefaultLLMTextObjectOptions & {
|
|
339
|
+
structuredOutput: JSONSchema7 | z.ZodType<T> | StructuredOutput;
|
|
340
|
+
};
|
|
341
|
+
type LLMStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
342
|
+
output?: OutputType | Z;
|
|
343
|
+
onFinish?: (result: string) => Promise<void> | void;
|
|
344
|
+
} & MastraCustomLLMOptions<Z> & DefaultLLMStreamOptions;
|
|
345
|
+
type LLMInnerStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
346
|
+
messages: CoreMessage[];
|
|
347
|
+
onFinish?: (result: string) => Promise<void> | void;
|
|
348
|
+
} & MastraCustomLLMOptions<Z> & DefaultLLMStreamOptions;
|
|
349
|
+
type LLMStreamObjectOptions<T extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
350
|
+
structuredOutput: JSONSchema7 | z.ZodType<T> | StructuredOutput;
|
|
351
|
+
} & LLMInnerStreamOptions<T> & DefaultLLMStreamObjectOptions;
|
|
352
|
+
|
|
353
|
+
type VoiceEventType = 'speaking' | 'writing' | 'error' | string;
|
|
354
|
+
interface VoiceEventMap {
|
|
355
|
+
speaker: NodeJS.ReadableStream;
|
|
356
|
+
speaking: {
|
|
357
|
+
audio?: string;
|
|
358
|
+
};
|
|
359
|
+
writing: {
|
|
360
|
+
text: string;
|
|
361
|
+
role: 'assistant' | 'user';
|
|
362
|
+
};
|
|
363
|
+
error: {
|
|
364
|
+
message: string;
|
|
365
|
+
code?: string;
|
|
366
|
+
details?: unknown;
|
|
367
|
+
};
|
|
368
|
+
[key: string]: unknown;
|
|
369
|
+
}
|
|
370
|
+
interface BuiltInModelConfig {
|
|
371
|
+
name: string;
|
|
372
|
+
apiKey?: string;
|
|
373
|
+
}
|
|
374
|
+
interface VoiceConfig<T = unknown> {
|
|
375
|
+
listeningModel?: BuiltInModelConfig;
|
|
376
|
+
speechModel?: BuiltInModelConfig;
|
|
377
|
+
speaker?: string;
|
|
378
|
+
name?: string;
|
|
379
|
+
realtimeConfig?: {
|
|
380
|
+
model?: string;
|
|
381
|
+
apiKey?: string;
|
|
382
|
+
options?: T;
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
declare abstract class MastraVoice<TOptions = unknown, TSpeakOptions = unknown, TListenOptions = unknown, TTools extends ToolsInput = ToolsInput, TEventArgs extends VoiceEventMap = VoiceEventMap, TSpeakerMetadata = unknown> extends MastraBase {
|
|
386
|
+
protected listeningModel?: BuiltInModelConfig;
|
|
387
|
+
protected speechModel?: BuiltInModelConfig;
|
|
388
|
+
protected speaker?: string;
|
|
389
|
+
protected realtimeConfig?: {
|
|
390
|
+
model?: string;
|
|
391
|
+
apiKey?: string;
|
|
392
|
+
options?: TOptions;
|
|
393
|
+
};
|
|
394
|
+
constructor({ listeningModel, speechModel, speaker, realtimeConfig, name }?: VoiceConfig<TOptions>);
|
|
395
|
+
traced<T extends Function>(method: T, methodName: string): T;
|
|
396
|
+
/**
|
|
397
|
+
* Convert text to speech
|
|
398
|
+
* @param input Text or text stream to convert to speech
|
|
399
|
+
* @param options Speech options including speaker and provider-specific options
|
|
400
|
+
* @returns Audio stream
|
|
401
|
+
*/
|
|
402
|
+
/**
|
|
403
|
+
* Convert text to speech
|
|
404
|
+
* @param input Text or text stream to convert to speech
|
|
405
|
+
* @param options Speech options including speaker and provider-specific options
|
|
406
|
+
* @returns Audio stream or void if in chat mode
|
|
407
|
+
*/
|
|
408
|
+
abstract speak(input: string | NodeJS.ReadableStream, options?: {
|
|
409
|
+
speaker?: string;
|
|
410
|
+
} & TSpeakOptions): Promise<NodeJS.ReadableStream | void>;
|
|
411
|
+
/**
|
|
412
|
+
* Convert speech to text
|
|
413
|
+
* @param audioStream Audio stream to transcribe
|
|
414
|
+
* @param options Provider-specific transcription options
|
|
415
|
+
* @returns Text or text stream
|
|
416
|
+
*/
|
|
417
|
+
/**
|
|
418
|
+
* Convert speech to text
|
|
419
|
+
* @param audioStream Audio stream to transcribe
|
|
420
|
+
* @param options Provider-specific transcription options
|
|
421
|
+
* @returns Text, text stream, or void if in chat mode
|
|
422
|
+
*/
|
|
423
|
+
abstract listen(audioStream: NodeJS.ReadableStream | unknown, // Allow other audio input types for OpenAI realtime API
|
|
424
|
+
options?: TListenOptions): Promise<string | NodeJS.ReadableStream | void>;
|
|
425
|
+
updateConfig(_options: Record<string, unknown>): void;
|
|
426
|
+
/**
|
|
427
|
+
* Initializes a WebSocket or WebRTC connection for real-time communication
|
|
428
|
+
* @returns Promise that resolves when the connection is established
|
|
429
|
+
*/
|
|
430
|
+
connect(_options?: Record<string, unknown>): Promise<void>;
|
|
431
|
+
/**
|
|
432
|
+
* Relay audio data to the voice provider for real-time processing
|
|
433
|
+
* @param audioData Audio data to relay
|
|
434
|
+
*/
|
|
435
|
+
send(_audioData: NodeJS.ReadableStream | Int16Array): Promise<void>;
|
|
436
|
+
/**
|
|
437
|
+
* Trigger voice providers to respond
|
|
438
|
+
*/
|
|
439
|
+
answer(_options?: Record<string, unknown>): Promise<void>;
|
|
440
|
+
/**
|
|
441
|
+
* Equip the voice provider with instructions
|
|
442
|
+
* @param instructions Instructions to add
|
|
443
|
+
*/
|
|
444
|
+
addInstructions(_instructions?: string): void;
|
|
445
|
+
/**
|
|
446
|
+
* Equip the voice provider with tools
|
|
447
|
+
* @param tools Array of tools to add
|
|
448
|
+
*/
|
|
449
|
+
addTools(_tools: TTools): void;
|
|
450
|
+
/**
|
|
451
|
+
* Disconnect from the WebSocket or WebRTC connection
|
|
452
|
+
*/
|
|
453
|
+
close(): void;
|
|
454
|
+
/**
|
|
455
|
+
* Register an event listener
|
|
456
|
+
* @param event Event name (e.g., 'speaking', 'writing', 'error')
|
|
457
|
+
* @param callback Callback function that receives event data
|
|
458
|
+
*/
|
|
459
|
+
on<E extends VoiceEventType>(_event: E, _callback: (data: E extends keyof TEventArgs ? TEventArgs[E] : unknown) => void): void;
|
|
460
|
+
/**
|
|
461
|
+
* Remove an event listener
|
|
462
|
+
* @param event Event name (e.g., 'speaking', 'writing', 'error')
|
|
463
|
+
* @param callback Callback function to remove
|
|
464
|
+
*/
|
|
465
|
+
off<E extends VoiceEventType>(_event: E, _callback: (data: E extends keyof TEventArgs ? TEventArgs[E] : unknown) => void): void;
|
|
466
|
+
/**
|
|
467
|
+
* Get available speakers/voices
|
|
468
|
+
* @returns Array of available voice IDs and their metadata
|
|
469
|
+
*/
|
|
470
|
+
getSpeakers(): Promise<Array<{
|
|
471
|
+
voiceId: string;
|
|
472
|
+
} & TSpeakerMetadata>>;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
declare class CompositeVoice extends MastraVoice<unknown, unknown, unknown, ToolsInput, VoiceEventMap> {
|
|
476
|
+
protected speakProvider?: MastraVoice;
|
|
477
|
+
protected listenProvider?: MastraVoice;
|
|
478
|
+
protected realtimeProvider?: MastraVoice;
|
|
479
|
+
constructor({ input, output, realtime, speakProvider, listenProvider, realtimeProvider, }: {
|
|
480
|
+
/** @deprecated use output instead */
|
|
481
|
+
speakProvider?: MastraVoice;
|
|
482
|
+
/** @deprecated use input instead */
|
|
483
|
+
listenProvider?: MastraVoice;
|
|
484
|
+
/** @deprecated use realtime instead */
|
|
485
|
+
realtimeProvider?: MastraVoice;
|
|
486
|
+
input?: MastraVoice;
|
|
487
|
+
output?: MastraVoice;
|
|
488
|
+
realtime?: MastraVoice;
|
|
489
|
+
});
|
|
490
|
+
/**
|
|
491
|
+
* Convert text to speech using the configured provider
|
|
492
|
+
* @param input Text or text stream to convert to speech
|
|
493
|
+
* @param options Speech options including speaker and provider-specific options
|
|
494
|
+
* @returns Audio stream or void if in realtime mode
|
|
495
|
+
*/
|
|
496
|
+
speak(input: string | NodeJS.ReadableStream, options?: {
|
|
497
|
+
speaker?: string;
|
|
498
|
+
} & any): Promise<NodeJS.ReadableStream | void>;
|
|
499
|
+
listen(audioStream: NodeJS.ReadableStream, options?: any): Promise<string | void | NodeJS.ReadableStream>;
|
|
500
|
+
getSpeakers(): Promise<{
|
|
501
|
+
voiceId: string;
|
|
502
|
+
}[]>;
|
|
503
|
+
updateConfig(options: Record<string, unknown>): void;
|
|
288
504
|
/**
|
|
289
|
-
*
|
|
290
|
-
* @returns
|
|
505
|
+
* Initializes a WebSocket or WebRTC connection for real-time communication
|
|
506
|
+
* @returns Promise that resolves when the connection is established
|
|
291
507
|
*/
|
|
292
|
-
|
|
293
|
-
[x: string]: {
|
|
294
|
-
input: string;
|
|
295
|
-
output: string;
|
|
296
|
-
timestamp: string;
|
|
297
|
-
}[];
|
|
298
|
-
};
|
|
508
|
+
connect(options?: Record<string, unknown>): Promise<void>;
|
|
299
509
|
/**
|
|
300
|
-
*
|
|
301
|
-
* @
|
|
510
|
+
* Relay audio data to the voice provider for real-time processing
|
|
511
|
+
* @param audioData Audio data to send
|
|
302
512
|
*/
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
513
|
+
send(audioData: NodeJS.ReadableStream | Int16Array): Promise<void>;
|
|
514
|
+
/**
|
|
515
|
+
* Trigger voice providers to respond
|
|
516
|
+
*/
|
|
517
|
+
answer(options?: Record<string, unknown>): Promise<void>;
|
|
518
|
+
/**
|
|
519
|
+
* Equip the voice provider with instructions
|
|
520
|
+
* @param instructions Instructions to add
|
|
521
|
+
*/
|
|
522
|
+
addInstructions(instructions: string): void;
|
|
523
|
+
/**
|
|
524
|
+
* Equip the voice provider with tools
|
|
525
|
+
* @param tools Array of tools to add
|
|
526
|
+
*/
|
|
527
|
+
addTools(tools: ToolsInput): void;
|
|
528
|
+
/**
|
|
529
|
+
* Disconnect from the WebSocket or WebRTC connection
|
|
530
|
+
*/
|
|
531
|
+
close(): void;
|
|
532
|
+
/**
|
|
533
|
+
* Register an event listener
|
|
534
|
+
* @param event Event name (e.g., 'speaking', 'writing', 'error')
|
|
535
|
+
* @param callback Callback function that receives event data
|
|
536
|
+
*/
|
|
537
|
+
on<E extends VoiceEventType>(event: E, callback: (data: E extends keyof VoiceEventMap ? VoiceEventMap[E] : unknown) => void): void;
|
|
538
|
+
/**
|
|
539
|
+
* Remove an event listener
|
|
540
|
+
* @param event Event name (e.g., 'speaking', 'writing', 'error')
|
|
541
|
+
* @param callback Callback function to remove
|
|
542
|
+
*/
|
|
543
|
+
off<E extends VoiceEventType>(event: E, callback: (data: E extends keyof VoiceEventMap ? VoiceEventMap[E] : unknown) => void): void;
|
|
331
544
|
}
|
|
332
545
|
|
|
333
|
-
|
|
546
|
+
declare class DefaultVoice extends MastraVoice {
|
|
547
|
+
constructor();
|
|
548
|
+
speak(_input: string | NodeJS.ReadableStream): Promise<NodeJS.ReadableStream>;
|
|
549
|
+
listen(_input: string | NodeJS.ReadableStream): Promise<string>;
|
|
550
|
+
getSpeakers(): Promise<{
|
|
551
|
+
voiceId: string;
|
|
552
|
+
}[]>;
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
interface WorkflowOptions<TWorkflowName extends string = string, TSteps extends LegacyStep<string, any, any, any>[] = LegacyStep<string, any, any, any>[], TTriggerSchema extends z.ZodObject<any> = any, TResultSchema extends z.ZodObject<any> = any> {
|
|
334
556
|
steps?: TSteps;
|
|
335
557
|
name: TWorkflowName;
|
|
336
558
|
triggerSchema?: TTriggerSchema;
|
|
@@ -361,7 +583,7 @@ interface StepAction<TId extends string, TSchemaIn extends z.ZodSchema | undefin
|
|
|
361
583
|
payload?: TSchemaIn extends z.ZodSchema ? Partial<z.infer<TSchemaIn>> : unknown;
|
|
362
584
|
execute: (context: TContext) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
|
|
363
585
|
retryConfig?: RetryConfig;
|
|
364
|
-
workflow?:
|
|
586
|
+
workflow?: LegacyWorkflow;
|
|
365
587
|
workflowId?: string;
|
|
366
588
|
}
|
|
367
589
|
interface SimpleConditionalType {
|
|
@@ -443,7 +665,7 @@ type Condition<TStep extends StepVariableType<any, any, any, any>, TTriggerSchem
|
|
|
443
665
|
} | {
|
|
444
666
|
not: Condition<TStep, TTriggerSchema>;
|
|
445
667
|
};
|
|
446
|
-
interface StepConfig<TStep extends StepAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>, TTriggerSchema extends z.ZodObject<any>, TSteps extends
|
|
668
|
+
interface StepConfig<TStep extends StepAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>, TTriggerSchema extends z.ZodObject<any>, TSteps extends LegacyStep<string, any, any, any>[] = LegacyStep<string, any, any, any>[]> {
|
|
447
669
|
when?: Condition<CondStep, TTriggerSchema> | ((args: {
|
|
448
670
|
context: WorkflowContext<TTriggerSchema, TSteps>;
|
|
449
671
|
mastra?: Mastra;
|
|
@@ -481,12 +703,12 @@ type StepSkipped = {
|
|
|
481
703
|
status: 'skipped';
|
|
482
704
|
};
|
|
483
705
|
type StepResult$1<T> = StepSuccess$1<T> | StepFailure$1 | StepSuspended$1<T> | StepWaiting | StepSkipped;
|
|
484
|
-
type StepsRecord$1<T extends readonly
|
|
706
|
+
type StepsRecord$1<T extends readonly LegacyStep<any, any, z.ZodType<any> | undefined>[]> = {
|
|
485
707
|
[K in T[number]['id']]: Extract<T[number], {
|
|
486
708
|
id: K;
|
|
487
709
|
}>;
|
|
488
710
|
};
|
|
489
|
-
interface
|
|
711
|
+
interface LegacyWorkflowRunResult<T extends z.ZodObject<any>, TSteps extends LegacyStep<string, any, z.ZodType<any> | undefined>[], TResult extends z.ZodObject<any>> {
|
|
490
712
|
triggerData?: z.infer<T>;
|
|
491
713
|
result?: z.infer<TResult>;
|
|
492
714
|
results: {
|
|
@@ -500,7 +722,7 @@ interface WorkflowRunResult<T extends z.ZodObject<any>, TSteps extends Step<stri
|
|
|
500
722
|
stepPath: string[];
|
|
501
723
|
}>;
|
|
502
724
|
}
|
|
503
|
-
interface WorkflowContext<TTrigger extends z.ZodObject<any> = any, TSteps extends
|
|
725
|
+
interface WorkflowContext<TTrigger extends z.ZodObject<any> = any, TSteps extends LegacyStep<string, any, any, any>[] = LegacyStep<string, any, any, any>[], TInputData extends Record<string, any> = Record<string, any>> {
|
|
504
726
|
isResume?: {
|
|
505
727
|
runId: string;
|
|
506
728
|
stepId: string;
|
|
@@ -514,7 +736,7 @@ interface WorkflowContext<TTrigger extends z.ZodObject<any> = any, TSteps extend
|
|
|
514
736
|
attempts: Record<string, number>;
|
|
515
737
|
getStepResult(stepId: 'trigger'): z.infer<TTrigger>;
|
|
516
738
|
getStepResult<T extends keyof StepsRecord$1<TSteps> | unknown>(stepId: T extends keyof StepsRecord$1<TSteps> ? T : string): T extends keyof StepsRecord$1<TSteps> ? StepsRecord$1<TSteps>[T]['outputSchema'] extends undefined ? unknown : z.infer<NonNullable<StepsRecord$1<TSteps>[T]['outputSchema']>> : T;
|
|
517
|
-
getStepResult<T extends
|
|
739
|
+
getStepResult<T extends LegacyStep<any, any, any, any>>(stepId: T): T['outputSchema'] extends undefined ? unknown : z.infer<NonNullable<T['outputSchema']>>;
|
|
518
740
|
}
|
|
519
741
|
interface WorkflowLogMessage extends BaseLogMessage {
|
|
520
742
|
type: typeof RegisteredLogger.WORKFLOW;
|
|
@@ -612,7 +834,7 @@ type WorkflowActions = {
|
|
|
612
834
|
type: 'updateStepResult' | 'setStepError' | 'notifyStepCompletion' | 'decrementAttemptCount';
|
|
613
835
|
params: WorkflowActionParams;
|
|
614
836
|
};
|
|
615
|
-
type
|
|
837
|
+
type LegacyWorkflowState = {
|
|
616
838
|
[key: string]: {
|
|
617
839
|
initial: 'pending';
|
|
618
840
|
states: {
|
|
@@ -686,7 +908,7 @@ type ExtractSchemaType$1<T extends z.ZodSchema> = T extends z.ZodSchema<infer V>
|
|
|
686
908
|
type PathsToStringProps$1<T> = T extends object ? {
|
|
687
909
|
[K in keyof T]: T[K] extends object ? K extends string ? K | `${K}.${PathsToStringProps$1<T[K]>}` : never : K extends string ? K : never;
|
|
688
910
|
}[keyof T] : never;
|
|
689
|
-
interface
|
|
911
|
+
interface LegacyWorkflowRunState {
|
|
690
912
|
value: Record<string, string>;
|
|
691
913
|
context: {
|
|
692
914
|
steps: Record<string, {
|
|
@@ -705,7 +927,7 @@ interface WorkflowRunState {
|
|
|
705
927
|
suspendedPaths: Record<string, number[]>;
|
|
706
928
|
runId: string;
|
|
707
929
|
timestamp: number;
|
|
708
|
-
childStates?: Record<string,
|
|
930
|
+
childStates?: Record<string, LegacyWorkflowRunState>;
|
|
709
931
|
suspendedSteps?: Record<string, string>;
|
|
710
932
|
}
|
|
711
933
|
type WorkflowResumeResult<TTriggerSchema extends z.ZodObject<any>> = {
|
|
@@ -713,7 +935,7 @@ type WorkflowResumeResult<TTriggerSchema extends z.ZodObject<any>> = {
|
|
|
713
935
|
results: Record<string, StepResult$1<any>>;
|
|
714
936
|
};
|
|
715
937
|
|
|
716
|
-
declare class
|
|
938
|
+
declare class LegacyStep<TStepId extends string = any, TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends StepExecutionContext<TSchemaIn> = StepExecutionContext<TSchemaIn>> implements StepAction<TStepId, TSchemaIn, TSchemaOut, TContext> {
|
|
717
939
|
id: TStepId;
|
|
718
940
|
description?: string;
|
|
719
941
|
inputSchema?: TSchemaIn;
|
|
@@ -725,12 +947,12 @@ declare class Step<TStepId extends string = any, TSchemaIn extends z.ZodSchema |
|
|
|
725
947
|
constructor({ id, description, execute, payload, outputSchema, inputSchema, retryConfig, }: StepAction<TStepId, TSchemaIn, TSchemaOut, TContext>);
|
|
726
948
|
}
|
|
727
949
|
|
|
728
|
-
declare class Machine<TSteps extends
|
|
950
|
+
declare class Machine<TSteps extends LegacyStep<any, any, any, any>[] = LegacyStep<any, any, any, any>[], TTriggerSchema extends z.ZodObject<any> = any, TResultSchema extends z.ZodObject<any> = any> extends EventEmitter {
|
|
729
951
|
#private;
|
|
730
|
-
logger:
|
|
952
|
+
logger: IMastraLogger;
|
|
731
953
|
name: string;
|
|
732
954
|
constructor({ logger, mastra, runtimeContext, workflowInstance, executionSpan, name, runId, steps, stepGraph, retryConfig, startStepId, }: {
|
|
733
|
-
logger:
|
|
955
|
+
logger: IMastraLogger;
|
|
734
956
|
mastra?: Mastra;
|
|
735
957
|
runtimeContext: RuntimeContext;
|
|
736
958
|
workflowInstance: WorkflowInstance;
|
|
@@ -748,9 +970,9 @@ declare class Machine<TSteps extends Step<any, any, any, any>[] = Step<any, any,
|
|
|
748
970
|
input?: any;
|
|
749
971
|
snapshot?: Snapshot<any>;
|
|
750
972
|
resumeData?: any;
|
|
751
|
-
}): Promise<Pick<
|
|
973
|
+
}): Promise<Pick<LegacyWorkflowRunResult<TTriggerSchema, TSteps, TResultSchema>, 'results' | 'activePaths' | 'runId' | 'timestamp'>>;
|
|
752
974
|
private initializeMachine;
|
|
753
|
-
getSnapshot(): xstate.MachineSnapshot<Omit<WorkflowContext<any,
|
|
975
|
+
getSnapshot(): xstate.MachineSnapshot<Omit<WorkflowContext<any, LegacyStep<string, any, any, any>[], Record<string, any>>, "getStepResult">, {
|
|
754
976
|
type: "RESET_TO_PENDING";
|
|
755
977
|
stepId: string;
|
|
756
978
|
} | {
|
|
@@ -1012,8 +1234,8 @@ declare class Machine<TSteps extends Step<any, any, any, any>[] = Step<any, any,
|
|
|
1012
1234
|
syncSnapshot?: boolean;
|
|
1013
1235
|
} & { [K in xstate.RequiredLogicInput<TLogic>]: unknown; }) | undefined], xstate.IsNotNever<xstate.RequiredLogicInput<TLogic>>>): xstate.ActorRefFromLogic<TLogic>;
|
|
1014
1236
|
};
|
|
1015
|
-
input: Omit<WorkflowContext<any,
|
|
1016
|
-
self: xstate.ActorRef<xstate.MachineSnapshot<Omit<WorkflowContext<any,
|
|
1237
|
+
input: Omit<WorkflowContext<any, LegacyStep<string, any, any, any>[], Record<string, any>>, "getStepResult">;
|
|
1238
|
+
self: xstate.ActorRef<xstate.MachineSnapshot<Omit<WorkflowContext<any, LegacyStep<string, any, any, any>[], Record<string, any>>, "getStepResult">, {
|
|
1017
1239
|
type: "RESET_TO_PENDING";
|
|
1018
1240
|
stepId: string;
|
|
1019
1241
|
} | {
|
|
@@ -1100,30 +1322,30 @@ declare class Machine<TSteps extends Step<any, any, any, any>[] = Step<any, any,
|
|
|
1100
1322
|
}> | undefined;
|
|
1101
1323
|
}
|
|
1102
1324
|
|
|
1103
|
-
interface WorkflowResultReturn<TResult extends z.ZodObject<any>, T extends z.ZodObject<any>, TSteps extends
|
|
1325
|
+
interface WorkflowResultReturn<TResult extends z.ZodObject<any>, T extends z.ZodObject<any>, TSteps extends LegacyStep<any, any, any>[]> {
|
|
1104
1326
|
runId: string;
|
|
1105
1327
|
start: (props?: {
|
|
1106
1328
|
triggerData?: z.infer<T>;
|
|
1107
1329
|
runtimeContext?: RuntimeContext;
|
|
1108
|
-
} | undefined) => Promise<
|
|
1109
|
-
watch: (onTransition: (state: Pick<
|
|
1330
|
+
} | undefined) => Promise<LegacyWorkflowRunResult<T, TSteps, TResult>>;
|
|
1331
|
+
watch: (onTransition: (state: Pick<LegacyWorkflowRunResult<T, TSteps, TResult>, 'results' | 'activePaths' | 'runId' | 'timestamp'>) => void) => () => void;
|
|
1110
1332
|
resume: (props: {
|
|
1111
1333
|
stepId: string;
|
|
1112
1334
|
context?: Record<string, any>;
|
|
1113
1335
|
runtimeContext?: RuntimeContext;
|
|
1114
|
-
}) => Promise<Omit<
|
|
1115
|
-
resumeWithEvent: (eventName: string, data: any, runtimeContext?: RuntimeContext) => Promise<Omit<
|
|
1336
|
+
}) => Promise<Omit<LegacyWorkflowRunResult<T, TSteps, TResult>, 'runId'> | undefined>;
|
|
1337
|
+
resumeWithEvent: (eventName: string, data: any, runtimeContext?: RuntimeContext) => Promise<Omit<LegacyWorkflowRunResult<T, TSteps, TResult>, 'runId'> | undefined>;
|
|
1116
1338
|
}
|
|
1117
|
-
declare class WorkflowInstance<TSteps extends
|
|
1339
|
+
declare class WorkflowInstance<TSteps extends LegacyStep<any, any, any, any>[] = LegacyStep<any, any, any, any>[], TTriggerSchema extends z.ZodObject<any> = any, TResult extends z.ZodObject<any> = any> implements WorkflowResultReturn<TResult, TTriggerSchema, TSteps> {
|
|
1118
1340
|
#private;
|
|
1119
1341
|
name: string;
|
|
1120
|
-
logger:
|
|
1342
|
+
logger: IMastraLogger;
|
|
1121
1343
|
events?: Record<string, {
|
|
1122
1344
|
schema: z.ZodObject<any>;
|
|
1123
1345
|
}>;
|
|
1124
1346
|
constructor({ name, logger, steps, runId, retryConfig, mastra, stepGraph, stepSubscriberGraph, onFinish, onStepTransition, resultMapping, events, }: {
|
|
1125
1347
|
name: string;
|
|
1126
|
-
logger:
|
|
1348
|
+
logger: IMastraLogger;
|
|
1127
1349
|
steps: Record<string, StepNode>;
|
|
1128
1350
|
mastra?: Mastra;
|
|
1129
1351
|
retryConfig?: RetryConfig;
|
|
@@ -1131,7 +1353,7 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any, any>[] = Step<
|
|
|
1131
1353
|
stepGraph: StepGraph;
|
|
1132
1354
|
stepSubscriberGraph: Record<string, StepGraph>;
|
|
1133
1355
|
onFinish?: () => void;
|
|
1134
|
-
onStepTransition?: Set<(state: Pick<
|
|
1356
|
+
onStepTransition?: Set<(state: Pick<LegacyWorkflowRunResult<TTriggerSchema, TSteps, TResult>, 'results' | 'activePaths' | 'runId' | 'timestamp'>) => void | Promise<void>>;
|
|
1135
1357
|
resultMapping?: Record<string, {
|
|
1136
1358
|
step: StepAction<any, any, any, any>;
|
|
1137
1359
|
path: string;
|
|
@@ -1143,16 +1365,16 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any, any>[] = Step<
|
|
|
1143
1365
|
setState(state: any): void;
|
|
1144
1366
|
get runId(): string;
|
|
1145
1367
|
get executionSpan(): Span | undefined;
|
|
1146
|
-
watch(onTransition: (state: Pick<
|
|
1368
|
+
watch(onTransition: (state: Pick<LegacyWorkflowRunResult<TTriggerSchema, TSteps, TResult>, 'results' | 'activePaths' | 'runId' | 'timestamp'>) => void): () => void;
|
|
1147
1369
|
start({ triggerData, runtimeContext, }?: {
|
|
1148
1370
|
triggerData?: z.infer<TTriggerSchema>;
|
|
1149
1371
|
runtimeContext?: RuntimeContext;
|
|
1150
1372
|
}): Promise<{
|
|
1151
1373
|
runId: string;
|
|
1152
1374
|
result?: z.TypeOf<TResult> | undefined;
|
|
1153
|
-
timestamp: number;
|
|
1154
1375
|
triggerData?: z.TypeOf<TTriggerSchema> | undefined;
|
|
1155
1376
|
results: { [K in keyof StepsRecord$1<TSteps>]: StepsRecord$1<TSteps>[K]["outputSchema"] extends undefined ? StepResult$1<unknown> : StepResult$1<z.TypeOf<NonNullable<StepsRecord$1<TSteps>[K]["outputSchema"]>>>; };
|
|
1377
|
+
timestamp: number;
|
|
1156
1378
|
activePaths: Map<TSteps[number]["id"], {
|
|
1157
1379
|
status: string;
|
|
1158
1380
|
suspendPayload?: any;
|
|
@@ -1166,30 +1388,30 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any, any>[] = Step<
|
|
|
1166
1388
|
snapshot?: Snapshot<any>;
|
|
1167
1389
|
resumeData?: any;
|
|
1168
1390
|
runtimeContext: RuntimeContext;
|
|
1169
|
-
}): Promise<Omit<
|
|
1391
|
+
}): Promise<Omit<LegacyWorkflowRunResult<TTriggerSchema, TSteps, TResult>, 'runId'>>;
|
|
1170
1392
|
hasSubscribers(stepId: string): boolean;
|
|
1171
|
-
runMachine(parentStepId: string, input: any, runtimeContext?: RuntimeContext): Promise<(Pick<
|
|
1393
|
+
runMachine(parentStepId: string, input: any, runtimeContext?: RuntimeContext): Promise<(Pick<LegacyWorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId" | "results" | "timestamp" | "activePaths"> | undefined)[]>;
|
|
1172
1394
|
suspend(stepId: string, machine: Machine<TSteps, TTriggerSchema>): Promise<void>;
|
|
1173
1395
|
/**
|
|
1174
1396
|
* Persists the workflow state to the database
|
|
1175
1397
|
*/
|
|
1176
1398
|
persistWorkflowSnapshot(): Promise<void>;
|
|
1177
|
-
getState(): Promise<
|
|
1178
|
-
resumeWithEvent(eventName: string, data: any, runtimeContext?: RuntimeContext): Promise<Omit<
|
|
1399
|
+
getState(): Promise<LegacyWorkflowRunState | null>;
|
|
1400
|
+
resumeWithEvent(eventName: string, data: any, runtimeContext?: RuntimeContext): Promise<Omit<LegacyWorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
|
|
1179
1401
|
resume({ stepId, context: resumeContext, runtimeContext, }: {
|
|
1180
1402
|
stepId: string;
|
|
1181
1403
|
context?: Record<string, any>;
|
|
1182
1404
|
runtimeContext?: RuntimeContext;
|
|
1183
|
-
}): Promise<Omit<
|
|
1405
|
+
}): Promise<Omit<LegacyWorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
|
|
1184
1406
|
_resume({ stepId, context: resumeContext, runtimeContext, }: {
|
|
1185
1407
|
stepId: string;
|
|
1186
1408
|
context?: Record<string, any>;
|
|
1187
1409
|
runtimeContext: RuntimeContext;
|
|
1188
|
-
}): Promise<Omit<
|
|
1410
|
+
}): Promise<Omit<LegacyWorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
|
|
1189
1411
|
}
|
|
1190
1412
|
|
|
1191
|
-
type WorkflowBuilder<T extends
|
|
1192
|
-
declare class
|
|
1413
|
+
type WorkflowBuilder<T extends LegacyWorkflow<any, any>> = Pick<T, 'step' | 'then' | 'after' | 'while' | 'until' | 'if' | 'else' | 'afterEvent' | 'commit'>;
|
|
1414
|
+
declare class LegacyWorkflow<TSteps extends LegacyStep<string, any, any>[] = LegacyStep<string, any, any>[], TStepId extends string = string, TTriggerSchema extends z.ZodObject<any> = any, TResultSchema extends z.ZodObject<any> = any> extends MastraBase {
|
|
1193
1415
|
#private;
|
|
1194
1416
|
name: TStepId;
|
|
1195
1417
|
triggerSchema?: TTriggerSchema;
|
|
@@ -1203,24 +1425,24 @@ declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, an
|
|
|
1203
1425
|
}>;
|
|
1204
1426
|
isNested: boolean;
|
|
1205
1427
|
/**
|
|
1206
|
-
* Creates a new
|
|
1428
|
+
* Creates a new LegacyWorkflow instance
|
|
1207
1429
|
* @param name - Identifier for the workflow (not necessarily unique)
|
|
1208
1430
|
* @param logger - Optional logger instance
|
|
1209
1431
|
*/
|
|
1210
1432
|
constructor({ name, triggerSchema, result, retryConfig, mastra, events, }: WorkflowOptions<TStepId, TSteps, TTriggerSchema, TResultSchema>);
|
|
1211
|
-
step<TWorkflow extends
|
|
1433
|
+
step<TWorkflow extends LegacyWorkflow<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>, Steps extends StepAction<any, any, any, any>[] = TSteps>(next: TWorkflow, config?: StepConfig<ReturnType<TWorkflow['toStep']>, CondStep, VarStep, TTriggerSchema, Steps>): WorkflowBuilder<this>;
|
|
1212
1434
|
step<TAgent extends Agent<any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>, Steps extends StepAction<any, any, any, any>[] = TSteps>(next: TAgent, config?: StepConfig<ReturnType<TAgent['toStep']>, CondStep, VarStep, TTriggerSchema, Steps>): WorkflowBuilder<this>;
|
|
1213
1435
|
step<TStep extends StepAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>, Steps extends StepAction<any, any, any, any>[] = TSteps>(step: TStep, config?: StepConfig<TStep, CondStep, VarStep, TTriggerSchema, Steps>): WorkflowBuilder<this>;
|
|
1214
1436
|
then<TStep extends StepAction<string, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>>(next: TStep | TStep[], config?: StepConfig<TStep, CondStep, VarStep, TTriggerSchema>): this;
|
|
1215
|
-
then<TWorkflow extends
|
|
1437
|
+
then<TWorkflow extends LegacyWorkflow<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>>(next: TWorkflow | TWorkflow[], config?: StepConfig<StepAction<string, any, any, any>, CondStep, VarStep, TTriggerSchema>): this;
|
|
1216
1438
|
then<TAgent extends Agent<any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>>(next: TAgent | TAgent[], config?: StepConfig<StepAction<string, any, any, any>, CondStep, VarStep, TTriggerSchema>): this;
|
|
1217
1439
|
private loop;
|
|
1218
1440
|
while<FallbackStep extends StepAction<string, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>>(condition: StepConfig<FallbackStep, CondStep, VarStep, TTriggerSchema, TSteps>['when'], fallbackStep: FallbackStep, variables?: StepConfig<FallbackStep, CondStep, VarStep, TTriggerSchema, TSteps>['variables']): Pick<WorkflowBuilder<this>, "then" | "commit">;
|
|
1219
1441
|
until<FallbackStep extends StepAction<string, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>>(condition: StepConfig<FallbackStep, CondStep, VarStep, TTriggerSchema, TSteps>['when'], fallbackStep: FallbackStep, variables?: StepConfig<FallbackStep, CondStep, VarStep, TTriggerSchema, TSteps>['variables']): Pick<WorkflowBuilder<this>, "then" | "commit">;
|
|
1220
|
-
if<TStep extends StepAction<string, any, any, any>>(condition: StepConfig<TStep, any, any, TTriggerSchema>['when'], ifStep?: TStep |
|
|
1442
|
+
if<TStep extends StepAction<string, any, any, any>>(condition: StepConfig<TStep, any, any, TTriggerSchema>['when'], ifStep?: TStep | LegacyWorkflow, elseStep?: TStep | LegacyWorkflow): this | WorkflowBuilder<this>;
|
|
1221
1443
|
else(): WorkflowBuilder<this>;
|
|
1222
1444
|
after<TStep extends StepAction<string, any, any, any>>(steps: string | TStep | TStep[] | (TStep | string)[]): Omit<WorkflowBuilder<this>, 'then' | 'after'>;
|
|
1223
|
-
after<TWorkflow extends
|
|
1445
|
+
after<TWorkflow extends LegacyWorkflow<any, any, any, any>>(steps: TWorkflow | TWorkflow[]): Omit<WorkflowBuilder<this>, 'then' | 'after'>;
|
|
1224
1446
|
after<TAgent extends Agent<any, any, any>>(steps: TAgent | TAgent[]): Omit<WorkflowBuilder<this>, 'then' | 'after'>;
|
|
1225
1447
|
afterEvent(eventName: string): WorkflowBuilder<this>;
|
|
1226
1448
|
/**
|
|
@@ -1262,17 +1484,17 @@ declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, an
|
|
|
1262
1484
|
limit?: number;
|
|
1263
1485
|
offset?: number;
|
|
1264
1486
|
resourceId?: string;
|
|
1265
|
-
}): Promise<
|
|
1487
|
+
}): Promise<LegacyWorkflowRuns>;
|
|
1266
1488
|
getExecutionSpan(runId: string): Span | undefined;
|
|
1267
|
-
getState(runId: string): Promise<
|
|
1489
|
+
getState(runId: string): Promise<LegacyWorkflowRunState | null>;
|
|
1268
1490
|
resume({ runId, stepId, context: resumeContext, runtimeContext, }: {
|
|
1269
1491
|
runId: string;
|
|
1270
1492
|
stepId: string;
|
|
1271
1493
|
context?: Record<string, any>;
|
|
1272
1494
|
runtimeContext: RuntimeContext;
|
|
1273
|
-
}): Promise<Omit<
|
|
1274
|
-
watch(onTransition: (state: Pick<
|
|
1275
|
-
resumeWithEvent(runId: string, eventName: string, data: any): Promise<Omit<
|
|
1495
|
+
}): Promise<Omit<LegacyWorkflowRunResult<TTriggerSchema, TSteps, any>, "runId"> | undefined>;
|
|
1496
|
+
watch(onTransition: (state: Pick<LegacyWorkflowRunResult<TTriggerSchema, TSteps, TResultSchema>, 'results' | 'activePaths' | 'runId' | 'timestamp'>) => void): () => void;
|
|
1497
|
+
resumeWithEvent(runId: string, eventName: string, data: any): Promise<Omit<LegacyWorkflowRunResult<TTriggerSchema, TSteps, any>, "runId"> | undefined>;
|
|
1276
1498
|
__registerMastra(mastra: Mastra): void;
|
|
1277
1499
|
__registerPrimitives(p: MastraPrimitives): void;
|
|
1278
1500
|
get stepGraph(): StepGraph;
|
|
@@ -1281,7 +1503,7 @@ declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, an
|
|
|
1281
1503
|
get serializedStepSubscriberGraph(): Record<string, StepGraph>;
|
|
1282
1504
|
get steps(): Record<string, StepAction<string, any, any, any>>;
|
|
1283
1505
|
setNested(isNested: boolean): void;
|
|
1284
|
-
toStep():
|
|
1506
|
+
toStep(): LegacyStep<TStepId, TTriggerSchema, z.ZodType<LegacyWorkflowRunResult<TTriggerSchema, TSteps, TResultSchema>>, any>;
|
|
1285
1507
|
}
|
|
1286
1508
|
|
|
1287
1509
|
type ExecuteFunction<TStepInput, TStepOutput, TResumeSchema, TSuspendSchema> = (params: {
|
|
@@ -1289,8 +1511,9 @@ type ExecuteFunction<TStepInput, TStepOutput, TResumeSchema, TSuspendSchema> = (
|
|
|
1289
1511
|
runtimeContext: RuntimeContext;
|
|
1290
1512
|
inputData: TStepInput;
|
|
1291
1513
|
resumeData?: TResumeSchema;
|
|
1292
|
-
getInitData<T extends
|
|
1293
|
-
|
|
1514
|
+
getInitData<T extends z.ZodType<any>>(): z.infer<T>;
|
|
1515
|
+
getInitData<T extends Workflow<any, any, any, any, any>>(): T extends undefined ? unknown : z.infer<NonNullable<T['inputSchema']>>;
|
|
1516
|
+
getStepResult<T extends Step<any, any, any>>(stepId: T): T['outputSchema'] extends undefined ? unknown : z.infer<NonNullable<T['outputSchema']>>;
|
|
1294
1517
|
suspend(suspendPayload: TSuspendSchema): Promise<void>;
|
|
1295
1518
|
resume?: {
|
|
1296
1519
|
steps: string[];
|
|
@@ -1300,7 +1523,7 @@ type ExecuteFunction<TStepInput, TStepOutput, TResumeSchema, TSuspendSchema> = (
|
|
|
1300
1523
|
emit: (event: string, data: any) => Promise<void>;
|
|
1301
1524
|
};
|
|
1302
1525
|
}) => Promise<TStepOutput>;
|
|
1303
|
-
interface
|
|
1526
|
+
interface Step<TStepId extends string = string, TSchemaIn extends z.ZodType<any> = z.ZodType<any>, TSchemaOut extends z.ZodType<any> = z.ZodType<any>, TResumeSchema extends z.ZodType<any> = z.ZodType<any>, TSuspendSchema extends z.ZodType<any> = z.ZodType<any>> {
|
|
1304
1527
|
id: TStepId;
|
|
1305
1528
|
description?: string;
|
|
1306
1529
|
inputSchema: TSchemaIn;
|
|
@@ -1324,7 +1547,7 @@ type StepSuspended<T> = {
|
|
|
1324
1547
|
payload: T;
|
|
1325
1548
|
};
|
|
1326
1549
|
type StepResult<T> = StepSuccess<T> | StepFailure | StepSuspended<T>;
|
|
1327
|
-
type StepsRecord<T extends readonly
|
|
1550
|
+
type StepsRecord<T extends readonly Step<any, any, any>[]> = {
|
|
1328
1551
|
[K in T[number]['id']]: Extract<T[number], {
|
|
1329
1552
|
id: K;
|
|
1330
1553
|
}>;
|
|
@@ -1337,8 +1560,8 @@ type PathsToStringProps<T> = T extends object ? {
|
|
|
1337
1560
|
[K in keyof T]: T[K] extends object ? K extends string ? K | `${K}.${PathsToStringProps<T[K]>}` : never : K extends string ? K : never;
|
|
1338
1561
|
}[keyof T] : never;
|
|
1339
1562
|
type ExtractSchemaType<T extends z.ZodType<any>> = T extends z.ZodObject<infer V> ? V : never;
|
|
1340
|
-
type ExtractSchemaFromStep<TStep extends
|
|
1341
|
-
type VariableReference<TStep extends
|
|
1563
|
+
type ExtractSchemaFromStep<TStep extends Step<any, any, any>, TKey extends 'inputSchema' | 'outputSchema'> = TStep[TKey];
|
|
1564
|
+
type VariableReference<TStep extends Step<string, any, any> = Step<string, any, any>, TVarPath extends PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TStep, 'outputSchema'>>> | '' | '.' = PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TStep, 'outputSchema'>>> | '' | '.'> = {
|
|
1342
1565
|
step: TStep;
|
|
1343
1566
|
path: TVarPath;
|
|
1344
1567
|
} | {
|
|
@@ -1368,6 +1591,16 @@ type WatchEvent = {
|
|
|
1368
1591
|
eventTimestamp: Date;
|
|
1369
1592
|
};
|
|
1370
1593
|
type ZodPathType<T extends z.ZodTypeAny, P extends string> = T extends z.ZodObject<infer Shape> ? P extends `${infer Key}.${infer Rest}` ? Key extends keyof Shape ? Shape[Key] extends z.ZodTypeAny ? ZodPathType<Shape[Key], Rest> : never : never : P extends keyof Shape ? Shape[P] : never : never;
|
|
1594
|
+
interface WorkflowRunState {
|
|
1595
|
+
runId: string;
|
|
1596
|
+
value: Record<string, string>;
|
|
1597
|
+
context: {
|
|
1598
|
+
input?: Record<string, any>;
|
|
1599
|
+
} & Record<string, StepResult<any>>;
|
|
1600
|
+
activePaths: Array<unknown>;
|
|
1601
|
+
suspendedPaths: Record<string, number[]>;
|
|
1602
|
+
timestamp: number;
|
|
1603
|
+
}
|
|
1371
1604
|
|
|
1372
1605
|
/**
|
|
1373
1606
|
* Represents an execution graph for a workflow
|
|
@@ -1416,7 +1649,7 @@ declare abstract class ExecutionEngine extends MastraBase {
|
|
|
1416
1649
|
|
|
1417
1650
|
type StepFlowEntry = {
|
|
1418
1651
|
type: 'step';
|
|
1419
|
-
step:
|
|
1652
|
+
step: Step;
|
|
1420
1653
|
} | {
|
|
1421
1654
|
type: 'parallel';
|
|
1422
1655
|
steps: StepFlowEntry[];
|
|
@@ -1430,7 +1663,7 @@ type StepFlowEntry = {
|
|
|
1430
1663
|
}[];
|
|
1431
1664
|
} | {
|
|
1432
1665
|
type: 'loop';
|
|
1433
|
-
step:
|
|
1666
|
+
step: Step;
|
|
1434
1667
|
condition: ExecuteFunction<any, any, any, any>;
|
|
1435
1668
|
serializedCondition: {
|
|
1436
1669
|
id: string;
|
|
@@ -1439,12 +1672,12 @@ type StepFlowEntry = {
|
|
|
1439
1672
|
loopType: 'dowhile' | 'dountil';
|
|
1440
1673
|
} | {
|
|
1441
1674
|
type: 'foreach';
|
|
1442
|
-
step:
|
|
1675
|
+
step: Step;
|
|
1443
1676
|
opts: {
|
|
1444
1677
|
concurrency: number;
|
|
1445
1678
|
};
|
|
1446
1679
|
};
|
|
1447
|
-
type SerializedStep = Pick<
|
|
1680
|
+
type SerializedStep = Pick<Step, 'id' | 'description'> & {
|
|
1448
1681
|
component?: string;
|
|
1449
1682
|
serializedStepFlow?: SerializedStepFlowEntry[];
|
|
1450
1683
|
};
|
|
@@ -1494,25 +1727,25 @@ declare function createStep<TStepId extends string, TStepInput extends z.ZodType
|
|
|
1494
1727
|
resumeSchema?: TResumeSchema;
|
|
1495
1728
|
suspendSchema?: TSuspendSchema;
|
|
1496
1729
|
execute: ExecuteFunction<z.infer<TStepInput>, z.infer<TStepOutput>, z.infer<TResumeSchema>, z.infer<TSuspendSchema>>;
|
|
1497
|
-
}):
|
|
1730
|
+
}): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema>;
|
|
1498
1731
|
declare function createStep<TStepId extends string, TStepInput extends z.ZodObject<{
|
|
1499
1732
|
prompt: z.ZodString;
|
|
1500
1733
|
}>, TStepOutput extends z.ZodObject<{
|
|
1501
1734
|
text: z.ZodString;
|
|
1502
|
-
}>, TResumeSchema extends z.ZodType<any>, TSuspendSchema extends z.ZodType<any>>(agent: Agent<TStepId, any, any>):
|
|
1735
|
+
}>, TResumeSchema extends z.ZodType<any>, TSuspendSchema extends z.ZodType<any>>(agent: Agent<TStepId, any, any>): Step<TStepId, TStepInput, TStepOutput, TResumeSchema, TSuspendSchema>;
|
|
1503
1736
|
declare function createStep<TSchemaIn extends z.ZodType<any>, TSchemaOut extends z.ZodType<any>, TContext extends ToolExecutionContext<TSchemaIn>>(tool: Tool<TSchemaIn, TSchemaOut, TContext> & {
|
|
1504
1737
|
inputSchema: TSchemaIn;
|
|
1505
1738
|
outputSchema: TSchemaOut;
|
|
1506
1739
|
execute: (context: TContext) => Promise<any>;
|
|
1507
|
-
}):
|
|
1508
|
-
declare function cloneStep<TStepId extends string>(step:
|
|
1740
|
+
}): Step<string, TSchemaIn, TSchemaOut, z.ZodType<any>, z.ZodType<any>>;
|
|
1741
|
+
declare function cloneStep<TStepId extends string>(step: Step<string, any, any>, opts: {
|
|
1509
1742
|
id: TStepId;
|
|
1510
|
-
}):
|
|
1511
|
-
declare function createWorkflow<TWorkflowId extends string = string, TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>, TSteps extends
|
|
1512
|
-
declare function cloneWorkflow<TWorkflowId extends string = string, TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>, TSteps extends
|
|
1743
|
+
}): Step<TStepId, any, any>;
|
|
1744
|
+
declare function createWorkflow<TWorkflowId extends string = string, TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>, TSteps extends Step<string, any, any, any, any>[] = Step<string, any, any, any, any>[]>(params: WorkflowConfig<TWorkflowId, TInput, TOutput, TSteps>): Workflow<TSteps, TWorkflowId, TInput, TOutput, TInput>;
|
|
1745
|
+
declare function cloneWorkflow<TWorkflowId extends string = string, TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>, TSteps extends Step<string, any, any, any, any>[] = Step<string, any, any, any, any>[]>(workflow: Workflow<TSteps, string, TInput, TOutput>, opts: {
|
|
1513
1746
|
id: TWorkflowId;
|
|
1514
|
-
}):
|
|
1515
|
-
type WorkflowResult<TOutput extends z.ZodType<any>, TSteps extends
|
|
1747
|
+
}): Workflow<TSteps, TWorkflowId, TInput, TOutput>;
|
|
1748
|
+
type WorkflowResult<TOutput extends z.ZodType<any>, TSteps extends Step<string, any, any>[]> = {
|
|
1516
1749
|
status: 'success';
|
|
1517
1750
|
result: z.infer<TOutput>;
|
|
1518
1751
|
steps: {
|
|
@@ -1531,7 +1764,7 @@ type WorkflowResult<TOutput extends z.ZodType<any>, TSteps extends NewStep<strin
|
|
|
1531
1764
|
};
|
|
1532
1765
|
suspended: [string[], ...string[][]];
|
|
1533
1766
|
};
|
|
1534
|
-
type
|
|
1767
|
+
type WorkflowConfig<TWorkflowId extends string = string, TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>, TSteps extends Step<string, any, any, any, any>[] = Step<string, any, any, any, any>[]> = {
|
|
1535
1768
|
mastra?: Mastra;
|
|
1536
1769
|
id: TWorkflowId;
|
|
1537
1770
|
description?: string | undefined;
|
|
@@ -1544,13 +1777,13 @@ type NewWorkflowConfig<TWorkflowId extends string = string, TInput extends z.Zod
|
|
|
1544
1777
|
delay?: number;
|
|
1545
1778
|
};
|
|
1546
1779
|
};
|
|
1547
|
-
declare class
|
|
1780
|
+
declare class Workflow<TSteps extends Step<string, any, any, any, any>[] = Step<string, any, any, any, any>[], TWorkflowId extends string = string, TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>, TPrevSchema extends z.ZodType<any> = TInput> extends MastraBase implements Step<TWorkflowId, TInput, TOutput> {
|
|
1548
1781
|
#private;
|
|
1549
1782
|
id: TWorkflowId;
|
|
1550
1783
|
description?: string | undefined;
|
|
1551
1784
|
inputSchema: TInput;
|
|
1552
1785
|
outputSchema: TOutput;
|
|
1553
|
-
steps: Record<string,
|
|
1786
|
+
steps: Record<string, Step<string, any, any, any, any>>;
|
|
1554
1787
|
stepDefs?: TSteps;
|
|
1555
1788
|
protected stepFlow: StepFlowEntry[];
|
|
1556
1789
|
protected serializedStepFlow: SerializedStepFlowEntry[];
|
|
@@ -1560,9 +1793,9 @@ declare class NewWorkflow<TSteps extends NewStep<string, any, any, any, any>[] =
|
|
|
1560
1793
|
attempts?: number;
|
|
1561
1794
|
delay?: number;
|
|
1562
1795
|
};
|
|
1563
|
-
constructor({ mastra, id, inputSchema, outputSchema, description, executionEngine, retryConfig, steps, }:
|
|
1796
|
+
constructor({ mastra, id, inputSchema, outputSchema, description, executionEngine, retryConfig, steps, }: WorkflowConfig<TWorkflowId, TInput, TOutput, TSteps>);
|
|
1564
1797
|
get runs(): Map<string, Run<TSteps, TInput, TOutput>>;
|
|
1565
|
-
get mastra(): Mastra<Record<string, Agent<any, ToolsInput, Record<string, Metric>>>, Record<string,
|
|
1798
|
+
get mastra(): Mastra<Record<string, Agent<any, ToolsInput, Record<string, Metric>>>, Record<string, LegacyWorkflow<LegacyStep<string, any, any, StepExecutionContext<any, WorkflowContext<any, LegacyStep<string, any, any, any>[], Record<string, any>>>>[], string, any, any>>, Record<string, Workflow<Step<string, any, any, any, any>[], string, z.ZodType<any, z.ZodTypeDef, any>, z.ZodType<any, z.ZodTypeDef, any>, z.ZodType<any, z.ZodTypeDef, any>>>, Record<string, MastraVector>, Record<string, MastraTTS>, IMastraLogger, Record<string, AgentNetwork>, Record<string, MCPServerBase>> | undefined;
|
|
1566
1799
|
__registerMastra(mastra: Mastra): void;
|
|
1567
1800
|
__registerPrimitives(p: MastraPrimitives): void;
|
|
1568
1801
|
setStepFlow(stepFlow: StepFlowEntry[]): void;
|
|
@@ -1571,8 +1804,8 @@ declare class NewWorkflow<TSteps extends NewStep<string, any, any, any, any>[] =
|
|
|
1571
1804
|
* @param step The step to add to the workflow
|
|
1572
1805
|
* @returns The workflow instance for chaining
|
|
1573
1806
|
*/
|
|
1574
|
-
then<TStepInputSchema extends TPrevSchema, TStepId extends string, TSchemaOut extends z.ZodType<any>>(step:
|
|
1575
|
-
map<TSteps extends
|
|
1807
|
+
then<TStepInputSchema extends TPrevSchema, TStepId extends string, TSchemaOut extends z.ZodType<any>>(step: Step<TStepId, TStepInputSchema, TSchemaOut, any, any>): Workflow<TSteps, TWorkflowId, TInput, TOutput, TSchemaOut>;
|
|
1808
|
+
map<TSteps extends Step<string, any, any>[], TMapping extends {
|
|
1576
1809
|
[K in keyof TMapping]: {
|
|
1577
1810
|
step: TSteps[number] | TSteps[number][];
|
|
1578
1811
|
path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TSteps[number], 'outputSchema'>>> | '.';
|
|
@@ -1586,17 +1819,17 @@ declare class NewWorkflow<TSteps extends NewStep<string, any, any, any, any>[] =
|
|
|
1586
1819
|
runtimeContextPath: string;
|
|
1587
1820
|
schema: z.ZodTypeAny;
|
|
1588
1821
|
} | DynamicMapping<TPrevSchema, z.ZodTypeAny>;
|
|
1589
|
-
}>(mappingConfig: TMapping | ExecuteFunction<z.infer<TPrevSchema>, any, any, any>):
|
|
1590
|
-
parallel<TParallelSteps extends
|
|
1822
|
+
}>(mappingConfig: TMapping | ExecuteFunction<z.infer<TPrevSchema>, any, any, any>): Workflow<TSteps, TWorkflowId, TInput, TOutput, any>;
|
|
1823
|
+
parallel<TParallelSteps extends Step<string, TPrevSchema, any, any, any>[]>(steps: TParallelSteps): Workflow<TSteps, TWorkflowId, TInput, TOutput, z.ZodObject<{ [K in keyof StepsRecord<TParallelSteps>]: StepsRecord<TParallelSteps>[K]["outputSchema"]["path"]; }, any, z.ZodTypeAny>>;
|
|
1591
1824
|
branch<TBranchSteps extends Array<[
|
|
1592
1825
|
ExecuteFunction<z.infer<TPrevSchema>, any, any, any>,
|
|
1593
|
-
|
|
1594
|
-
]>>(steps: TBranchSteps):
|
|
1595
|
-
dowhile<TStepInputSchema extends TPrevSchema, TStepId extends string, TSchemaOut extends z.ZodType<any>>(step:
|
|
1596
|
-
dountil<TStepInputSchema extends TPrevSchema, TStepId extends string, TSchemaOut extends z.ZodType<any>>(step:
|
|
1597
|
-
foreach<TPrevIsArray extends TPrevSchema extends z.ZodArray<any> ? true : false, TStepInputSchema extends TPrevSchema extends z.ZodArray<infer TElement> ? TElement : never, TStepId extends string, TSchemaOut extends z.ZodType<any>>(step: TPrevIsArray extends true ?
|
|
1826
|
+
Step<string, TPrevSchema, any, any, any>
|
|
1827
|
+
]>>(steps: TBranchSteps): Workflow<TSteps, TWorkflowId, TInput, TOutput, z.ZodObject<{ [K in keyof StepsRecord<{ [K_1 in keyof TBranchSteps]: TBranchSteps[K_1][1]; }[number][]>]: StepsRecord<{ [K_1 in keyof TBranchSteps]: TBranchSteps[K_1][1]; }[number][]>[K]["outputSchema"]; }, any, z.ZodTypeAny>>;
|
|
1828
|
+
dowhile<TStepInputSchema extends TPrevSchema, TStepId extends string, TSchemaOut extends z.ZodType<any>>(step: Step<TStepId, TStepInputSchema, TSchemaOut, any, any>, condition: ExecuteFunction<z.infer<TSchemaOut>, any, any, any>): Workflow<TSteps, TWorkflowId, TInput, TOutput, TSchemaOut>;
|
|
1829
|
+
dountil<TStepInputSchema extends TPrevSchema, TStepId extends string, TSchemaOut extends z.ZodType<any>>(step: Step<TStepId, TStepInputSchema, TSchemaOut, any, any>, condition: ExecuteFunction<z.infer<TSchemaOut>, any, any, any>): Workflow<TSteps, TWorkflowId, TInput, TOutput, TSchemaOut>;
|
|
1830
|
+
foreach<TPrevIsArray extends TPrevSchema extends z.ZodArray<any> ? true : false, TStepInputSchema extends TPrevSchema extends z.ZodArray<infer TElement> ? TElement : never, TStepId extends string, TSchemaOut extends z.ZodType<any>>(step: TPrevIsArray extends true ? Step<TStepId, TStepInputSchema, TSchemaOut, any, any> : 'Previous step must return an array type', opts?: {
|
|
1598
1831
|
concurrency: number;
|
|
1599
|
-
}):
|
|
1832
|
+
}): Workflow<TSteps, TWorkflowId, TInput, TOutput, z.ZodArray<TSchemaOut>>;
|
|
1600
1833
|
/**
|
|
1601
1834
|
* Builds the execution graph for this workflow
|
|
1602
1835
|
* @returns The execution graph that can be used to execute the workflow
|
|
@@ -1607,7 +1840,7 @@ declare class NewWorkflow<TSteps extends NewStep<string, any, any, any, any>[] =
|
|
|
1607
1840
|
* This method should be called after all steps have been added to the workflow
|
|
1608
1841
|
* @returns A built workflow instance ready for execution
|
|
1609
1842
|
*/
|
|
1610
|
-
commit():
|
|
1843
|
+
commit(): Workflow<TSteps, TWorkflowId, TInput, TOutput, TOutput>;
|
|
1611
1844
|
get stepGraph(): StepFlowEntry[];
|
|
1612
1845
|
get serializedStepGraph(): SerializedStepFlowEntry[];
|
|
1613
1846
|
/**
|
|
@@ -1618,10 +1851,10 @@ declare class NewWorkflow<TSteps extends NewStep<string, any, any, any, any>[] =
|
|
|
1618
1851
|
createRun(options?: {
|
|
1619
1852
|
runId?: string;
|
|
1620
1853
|
}): Run<TSteps, TInput, TOutput>;
|
|
1621
|
-
execute({ inputData, resumeData, suspend, resume, emitter, mastra, }: {
|
|
1854
|
+
execute({ inputData, resumeData, suspend, resume, emitter, mastra, runtimeContext, }: {
|
|
1622
1855
|
inputData: z.infer<TInput>;
|
|
1623
1856
|
resumeData?: any;
|
|
1624
|
-
getStepResult<T extends
|
|
1857
|
+
getStepResult<T extends Step<any, any, any>>(stepId: T): T['outputSchema'] extends undefined ? unknown : z.infer<NonNullable<T['outputSchema']>>;
|
|
1625
1858
|
suspend: (suspendPayload: any) => Promise<void>;
|
|
1626
1859
|
resume?: {
|
|
1627
1860
|
steps: string[];
|
|
@@ -1632,6 +1865,7 @@ declare class NewWorkflow<TSteps extends NewStep<string, any, any, any, any>[] =
|
|
|
1632
1865
|
emit: (event: string, data: any) => void;
|
|
1633
1866
|
};
|
|
1634
1867
|
mastra: Mastra;
|
|
1868
|
+
runtimeContext?: RuntimeContext;
|
|
1635
1869
|
}): Promise<z.infer<TOutput>>;
|
|
1636
1870
|
getWorkflowRuns(args?: {
|
|
1637
1871
|
fromDate?: Date;
|
|
@@ -1645,7 +1879,7 @@ declare class NewWorkflow<TSteps extends NewStep<string, any, any, any, any>[] =
|
|
|
1645
1879
|
/**
|
|
1646
1880
|
* Represents a workflow run that can be executed
|
|
1647
1881
|
*/
|
|
1648
|
-
declare class Run<TSteps extends
|
|
1882
|
+
declare class Run<TSteps extends Step<string, any, any>[] = Step<string, any, any>[], TInput extends z.ZodType<any> = z.ZodType<any>, TOutput extends z.ZodType<any> = z.ZodType<any>> {
|
|
1649
1883
|
#private;
|
|
1650
1884
|
protected emitter: EventEmitter$1;
|
|
1651
1885
|
/**
|
|
@@ -1673,623 +1907,633 @@ declare class Run<TSteps extends NewStep<string, any, any>[] = NewStep<string, a
|
|
|
1673
1907
|
attempts?: number;
|
|
1674
1908
|
delay?: number;
|
|
1675
1909
|
};
|
|
1676
|
-
constructor(params: {
|
|
1677
|
-
workflowId: string;
|
|
1678
|
-
runId: string;
|
|
1679
|
-
executionEngine: ExecutionEngine;
|
|
1680
|
-
executionGraph: ExecutionGraph;
|
|
1681
|
-
mastra?: Mastra;
|
|
1682
|
-
retryConfig?: {
|
|
1683
|
-
attempts?: number;
|
|
1684
|
-
delay?: number;
|
|
1685
|
-
};
|
|
1686
|
-
cleanup?: () => void;
|
|
1687
|
-
});
|
|
1910
|
+
constructor(params: {
|
|
1911
|
+
workflowId: string;
|
|
1912
|
+
runId: string;
|
|
1913
|
+
executionEngine: ExecutionEngine;
|
|
1914
|
+
executionGraph: ExecutionGraph;
|
|
1915
|
+
mastra?: Mastra;
|
|
1916
|
+
retryConfig?: {
|
|
1917
|
+
attempts?: number;
|
|
1918
|
+
delay?: number;
|
|
1919
|
+
};
|
|
1920
|
+
cleanup?: () => void;
|
|
1921
|
+
});
|
|
1922
|
+
/**
|
|
1923
|
+
* Starts the workflow execution with the provided input
|
|
1924
|
+
* @param input The input data for the workflow
|
|
1925
|
+
* @returns A promise that resolves to the workflow output
|
|
1926
|
+
*/
|
|
1927
|
+
start({ inputData, runtimeContext, }: {
|
|
1928
|
+
inputData?: z.infer<TInput>;
|
|
1929
|
+
runtimeContext?: RuntimeContext;
|
|
1930
|
+
}): Promise<WorkflowResult<TOutput, TSteps>>;
|
|
1931
|
+
watch(cb: (event: WatchEvent) => void): () => void;
|
|
1932
|
+
resume<TResumeSchema extends z.ZodType<any>>(params: {
|
|
1933
|
+
resumeData?: z.infer<TResumeSchema>;
|
|
1934
|
+
step: Step<string, any, any, TResumeSchema, any> | [...Step<string, any, any, any, any>[], Step<string, any, any, TResumeSchema, any>] | string | string[];
|
|
1935
|
+
runtimeContext?: RuntimeContext;
|
|
1936
|
+
}): Promise<WorkflowResult<TOutput, TSteps>>;
|
|
1937
|
+
/**
|
|
1938
|
+
* Returns the current state of the workflow run
|
|
1939
|
+
* @returns The current state of the workflow run
|
|
1940
|
+
*/
|
|
1941
|
+
getState(): Record<string, any>;
|
|
1942
|
+
updateState(state: Record<string, any>): void;
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
type ToolsInput = Record<string, ToolAction<any, any, any> | VercelTool>;
|
|
1946
|
+
type ToolsetsInput = Record<string, ToolsInput>;
|
|
1947
|
+
type MastraLanguageModel = LanguageModelV1;
|
|
1948
|
+
type DynamicArgument<T> = T | (({ runtimeContext }: {
|
|
1949
|
+
runtimeContext: RuntimeContext;
|
|
1950
|
+
}) => Promise<T> | T);
|
|
1951
|
+
interface AgentConfig<TAgentId extends string = string, TTools extends ToolsInput = ToolsInput, TMetrics extends Record<string, Metric> = Record<string, Metric>> {
|
|
1952
|
+
name: TAgentId;
|
|
1953
|
+
instructions: DynamicArgument<string>;
|
|
1954
|
+
model: DynamicArgument<MastraLanguageModel>;
|
|
1955
|
+
tools?: DynamicArgument<TTools>;
|
|
1956
|
+
workflows?: DynamicArgument<Record<string, Workflow>>;
|
|
1957
|
+
defaultGenerateOptions?: AgentGenerateOptions;
|
|
1958
|
+
defaultStreamOptions?: AgentStreamOptions;
|
|
1959
|
+
mastra?: Mastra;
|
|
1960
|
+
evals?: TMetrics;
|
|
1961
|
+
memory?: MastraMemory;
|
|
1962
|
+
voice?: CompositeVoice;
|
|
1963
|
+
/** @deprecated This property is deprecated. Use evals instead to add evaluation metrics. */
|
|
1964
|
+
metrics?: TMetrics;
|
|
1965
|
+
}
|
|
1966
|
+
/**
|
|
1967
|
+
* Options for generating responses with an agent
|
|
1968
|
+
* @template Z - The schema type for structured output (Zod schema or JSON schema)
|
|
1969
|
+
*/
|
|
1970
|
+
type AgentGenerateOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
1971
|
+
/** Optional instructions to override the agent's default instructions */
|
|
1972
|
+
instructions?: string;
|
|
1973
|
+
/** Additional tool sets that can be used for this generation */
|
|
1974
|
+
toolsets?: ToolsetsInput;
|
|
1975
|
+
clientTools?: ToolsInput;
|
|
1976
|
+
/** Additional context messages to include */
|
|
1977
|
+
context?: CoreMessage[];
|
|
1978
|
+
/** Memory configuration options */
|
|
1979
|
+
memoryOptions?: MemoryConfig;
|
|
1980
|
+
/** Unique ID for this generation run */
|
|
1981
|
+
runId?: string;
|
|
1982
|
+
/** Callback fired after each generation step completes */
|
|
1983
|
+
onStepFinish?: Z extends undefined ? GenerateTextOnStepFinishCallback<any> : never;
|
|
1984
|
+
/** Maximum number of steps allowed for generation */
|
|
1985
|
+
maxSteps?: number;
|
|
1986
|
+
/** Schema for structured output, does not work with tools, use experimental_output instead */
|
|
1987
|
+
output?: OutputType | Z;
|
|
1988
|
+
/** Schema for structured output generation alongside tool calls. */
|
|
1989
|
+
experimental_output?: Z;
|
|
1990
|
+
/** Controls how tools are selected during generation */
|
|
1991
|
+
toolChoice?: 'auto' | 'none' | 'required' | {
|
|
1992
|
+
type: 'tool';
|
|
1993
|
+
toolName: string;
|
|
1994
|
+
};
|
|
1995
|
+
/** Telemetry settings */
|
|
1996
|
+
telemetry?: TelemetrySettings;
|
|
1997
|
+
/** RuntimeContext for dependency injection */
|
|
1998
|
+
runtimeContext?: RuntimeContext;
|
|
1999
|
+
} & ({
|
|
2000
|
+
resourceId?: undefined;
|
|
2001
|
+
threadId?: undefined;
|
|
2002
|
+
} | {
|
|
2003
|
+
resourceId: string;
|
|
2004
|
+
threadId: string;
|
|
2005
|
+
}) & (Z extends undefined ? DefaultLLMTextOptions : DefaultLLMTextObjectOptions);
|
|
2006
|
+
/**
|
|
2007
|
+
* Options for streaming responses with an agent
|
|
2008
|
+
* @template Z - The schema type for structured output (Zod schema or JSON schema)
|
|
2009
|
+
*/
|
|
2010
|
+
type AgentStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
2011
|
+
/** Optional instructions to override the agent's default instructions */
|
|
2012
|
+
instructions?: string;
|
|
2013
|
+
/** Additional tool sets that can be used for this generation */
|
|
2014
|
+
toolsets?: ToolsetsInput;
|
|
2015
|
+
clientTools?: ToolsInput;
|
|
2016
|
+
/** Additional context messages to include */
|
|
2017
|
+
context?: CoreMessage[];
|
|
2018
|
+
/** Memory configuration options */
|
|
2019
|
+
memoryOptions?: MemoryConfig;
|
|
2020
|
+
/** Unique ID for this generation run */
|
|
2021
|
+
runId?: string;
|
|
2022
|
+
/** Callback fired when streaming completes */
|
|
2023
|
+
onFinish?: Z extends undefined ? StreamTextOnFinishCallback<any> : Z extends ZodSchema ? StreamObjectOnFinishCallback<z.infer<Z>> : StreamObjectOnFinishCallback<any>;
|
|
2024
|
+
/** Callback fired after each generation step completes */
|
|
2025
|
+
onStepFinish?: Z extends undefined ? StreamTextOnStepFinishCallback<any> : never;
|
|
2026
|
+
/** Maximum number of steps allowed for generation */
|
|
2027
|
+
maxSteps?: number;
|
|
2028
|
+
/** Schema for structured output */
|
|
2029
|
+
output?: OutputType | Z;
|
|
2030
|
+
/** Temperature parameter for controlling randomness */
|
|
2031
|
+
temperature?: number;
|
|
2032
|
+
/** Controls how tools are selected during generation */
|
|
2033
|
+
toolChoice?: 'auto' | 'none' | 'required' | {
|
|
2034
|
+
type: 'tool';
|
|
2035
|
+
toolName: string;
|
|
2036
|
+
};
|
|
2037
|
+
/** Experimental schema for structured output */
|
|
2038
|
+
experimental_output?: Z;
|
|
2039
|
+
/** Telemetry settings */
|
|
2040
|
+
telemetry?: TelemetrySettings;
|
|
2041
|
+
/** RuntimeContext for dependency injection */
|
|
2042
|
+
runtimeContext?: RuntimeContext;
|
|
2043
|
+
} & ({
|
|
2044
|
+
resourceId?: undefined;
|
|
2045
|
+
threadId?: undefined;
|
|
2046
|
+
} | {
|
|
2047
|
+
resourceId: string;
|
|
2048
|
+
threadId: string;
|
|
2049
|
+
}) & (Z extends undefined ? DefaultLLMStreamOptions : DefaultLLMStreamObjectOptions);
|
|
2050
|
+
|
|
2051
|
+
type AgentNetworkConfig = {
|
|
2052
|
+
name: string;
|
|
2053
|
+
agents: Agent[];
|
|
2054
|
+
model: LanguageModelV1;
|
|
2055
|
+
instructions: string;
|
|
2056
|
+
};
|
|
2057
|
+
|
|
2058
|
+
declare class AgentNetwork extends MastraBase {
|
|
2059
|
+
#private;
|
|
2060
|
+
constructor(config: AgentNetworkConfig);
|
|
2061
|
+
formatAgentId(name: string): string;
|
|
2062
|
+
getTools(): {
|
|
2063
|
+
readonly transmit: Tool<z.ZodObject<{
|
|
2064
|
+
actions: z.ZodArray<z.ZodObject<{
|
|
2065
|
+
agent: z.ZodString;
|
|
2066
|
+
input: z.ZodString;
|
|
2067
|
+
includeHistory: z.ZodOptional<z.ZodBoolean>;
|
|
2068
|
+
}, "strip", z.ZodTypeAny, {
|
|
2069
|
+
input: string;
|
|
2070
|
+
agent: string;
|
|
2071
|
+
includeHistory?: boolean | undefined;
|
|
2072
|
+
}, {
|
|
2073
|
+
input: string;
|
|
2074
|
+
agent: string;
|
|
2075
|
+
includeHistory?: boolean | undefined;
|
|
2076
|
+
}>, "many">;
|
|
2077
|
+
}, "strip", z.ZodTypeAny, {
|
|
2078
|
+
actions: {
|
|
2079
|
+
input: string;
|
|
2080
|
+
agent: string;
|
|
2081
|
+
includeHistory?: boolean | undefined;
|
|
2082
|
+
}[];
|
|
2083
|
+
}, {
|
|
2084
|
+
actions: {
|
|
2085
|
+
input: string;
|
|
2086
|
+
agent: string;
|
|
2087
|
+
includeHistory?: boolean | undefined;
|
|
2088
|
+
}[];
|
|
2089
|
+
}>, undefined, ToolExecutionContext<z.ZodObject<{
|
|
2090
|
+
actions: z.ZodArray<z.ZodObject<{
|
|
2091
|
+
agent: z.ZodString;
|
|
2092
|
+
input: z.ZodString;
|
|
2093
|
+
includeHistory: z.ZodOptional<z.ZodBoolean>;
|
|
2094
|
+
}, "strip", z.ZodTypeAny, {
|
|
2095
|
+
input: string;
|
|
2096
|
+
agent: string;
|
|
2097
|
+
includeHistory?: boolean | undefined;
|
|
2098
|
+
}, {
|
|
2099
|
+
input: string;
|
|
2100
|
+
agent: string;
|
|
2101
|
+
includeHistory?: boolean | undefined;
|
|
2102
|
+
}>, "many">;
|
|
2103
|
+
}, "strip", z.ZodTypeAny, {
|
|
2104
|
+
actions: {
|
|
2105
|
+
input: string;
|
|
2106
|
+
agent: string;
|
|
2107
|
+
includeHistory?: boolean | undefined;
|
|
2108
|
+
}[];
|
|
2109
|
+
}, {
|
|
2110
|
+
actions: {
|
|
2111
|
+
input: string;
|
|
2112
|
+
agent: string;
|
|
2113
|
+
includeHistory?: boolean | undefined;
|
|
2114
|
+
}[];
|
|
2115
|
+
}>>>;
|
|
2116
|
+
};
|
|
2117
|
+
getAgentHistory(agentId: string): {
|
|
2118
|
+
input: string;
|
|
2119
|
+
output: string;
|
|
2120
|
+
timestamp: string;
|
|
2121
|
+
}[];
|
|
1688
2122
|
/**
|
|
1689
|
-
*
|
|
1690
|
-
* @
|
|
1691
|
-
* @returns A promise that resolves to the workflow output
|
|
2123
|
+
* Get the history of all agent interactions that have occurred in this network
|
|
2124
|
+
* @returns A record of agent interactions, keyed by agent ID
|
|
1692
2125
|
*/
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
step: NewStep<string, any, any, TResumeSchema, any> | [...NewStep<string, any, any, any, any>[], NewStep<string, any, any, TResumeSchema, any>] | string | string[];
|
|
1701
|
-
runtimeContext?: RuntimeContext;
|
|
1702
|
-
}): Promise<WorkflowResult<TOutput, TSteps>>;
|
|
2126
|
+
getAgentInteractionHistory(): {
|
|
2127
|
+
[x: string]: {
|
|
2128
|
+
input: string;
|
|
2129
|
+
output: string;
|
|
2130
|
+
timestamp: string;
|
|
2131
|
+
}[];
|
|
2132
|
+
};
|
|
1703
2133
|
/**
|
|
1704
|
-
*
|
|
1705
|
-
* @returns
|
|
2134
|
+
* Get a summary of agent interactions in a more readable format, displayed chronologically
|
|
2135
|
+
* @returns A formatted string with all agent interactions in chronological order
|
|
1706
2136
|
*/
|
|
1707
|
-
|
|
1708
|
-
|
|
2137
|
+
getAgentInteractionSummary(): string;
|
|
2138
|
+
executeAgent(agentId: string, input: CoreMessage$1[], includeHistory?: boolean, runtimeContext?: RuntimeContext): Promise<string>;
|
|
2139
|
+
getInstructions(): string;
|
|
2140
|
+
getRoutingAgent(): Agent<string, ToolsInput, Record<string, Metric>>;
|
|
2141
|
+
getAgents(): Agent<string, ToolsInput, Record<string, Metric>>[];
|
|
2142
|
+
generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], args?: AgentGenerateOptions<Z> & {
|
|
2143
|
+
output?: never;
|
|
2144
|
+
experimental_output?: never;
|
|
2145
|
+
}): Promise<GenerateTextResult<any, Z extends ZodSchema ? z.infer<Z> : unknown>>;
|
|
2146
|
+
generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], args?: AgentGenerateOptions<Z> & ({
|
|
2147
|
+
output: Z;
|
|
2148
|
+
experimental_output?: never;
|
|
2149
|
+
} | {
|
|
2150
|
+
experimental_output: Z;
|
|
2151
|
+
output?: never;
|
|
2152
|
+
})): Promise<GenerateObjectResult<Z extends ZodSchema ? z.infer<Z> : unknown>>;
|
|
2153
|
+
stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], args?: AgentStreamOptions<Z> & {
|
|
2154
|
+
output?: never;
|
|
2155
|
+
experimental_output?: never;
|
|
2156
|
+
}): Promise<StreamTextResult<any, Z extends ZodSchema ? z.infer<Z> : unknown>>;
|
|
2157
|
+
stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], args?: AgentStreamOptions<Z> & ({
|
|
2158
|
+
output: Z;
|
|
2159
|
+
experimental_output?: never;
|
|
2160
|
+
} | {
|
|
2161
|
+
experimental_output: Z;
|
|
2162
|
+
output?: never;
|
|
2163
|
+
})): Promise<StreamObjectResult<any, Z extends ZodSchema ? z.infer<Z> : unknown, any>>;
|
|
2164
|
+
__registerMastra(p: Mastra): void;
|
|
1709
2165
|
}
|
|
1710
2166
|
|
|
1711
|
-
type
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
/**
|
|
1717
|
-
* Interface for message processors that can filter or transform messages
|
|
1718
|
-
* before they're sent to the LLM.
|
|
1719
|
-
*/
|
|
1720
|
-
declare abstract class MemoryProcessor extends MastraBase {
|
|
1721
|
-
/**
|
|
1722
|
-
* Process a list of messages and return a filtered or transformed list.
|
|
1723
|
-
* @param messages The messages to process
|
|
1724
|
-
* @returns The processed messages
|
|
1725
|
-
*/
|
|
1726
|
-
process(messages: CoreMessage$1[], _opts: MemoryProcessorOpts): CoreMessage$1[];
|
|
1727
|
-
}
|
|
1728
|
-
declare const memoryDefaultOptions: {
|
|
1729
|
-
lastMessages: number;
|
|
1730
|
-
semanticRecall: {
|
|
1731
|
-
topK: number;
|
|
1732
|
-
messageRange: {
|
|
1733
|
-
before: number;
|
|
1734
|
-
after: number;
|
|
1735
|
-
};
|
|
1736
|
-
};
|
|
1737
|
-
threads: {
|
|
1738
|
-
generateTitle: true;
|
|
1739
|
-
};
|
|
1740
|
-
workingMemory: {
|
|
1741
|
-
use: "text-stream";
|
|
1742
|
-
enabled: false;
|
|
1743
|
-
template: string;
|
|
1744
|
-
};
|
|
2167
|
+
type ConvertedTool = {
|
|
2168
|
+
name: string;
|
|
2169
|
+
description?: string;
|
|
2170
|
+
parameters: InternalCoreTool['parameters'];
|
|
2171
|
+
execute: InternalCoreTool['execute'];
|
|
1745
2172
|
};
|
|
1746
|
-
|
|
1747
|
-
* Abstract Memory class that defines the interface for storing and retrieving
|
|
1748
|
-
* conversation threads and messages.
|
|
1749
|
-
*/
|
|
1750
|
-
declare abstract class MastraMemory extends MastraBase {
|
|
1751
|
-
MAX_CONTEXT_TOKENS?: number;
|
|
1752
|
-
storage: MastraStorage;
|
|
1753
|
-
vector?: MastraVector;
|
|
1754
|
-
embedder?: EmbeddingModel<string>;
|
|
1755
|
-
private processors;
|
|
1756
|
-
private deprecationWarnings;
|
|
1757
|
-
protected threadConfig: MemoryConfig;
|
|
1758
|
-
constructor(config: {
|
|
1759
|
-
name: string;
|
|
1760
|
-
} & SharedMemoryConfig);
|
|
1761
|
-
private addImplicitDefaultsWarning;
|
|
1762
|
-
setStorage(storage: MastraStorage): void;
|
|
1763
|
-
setVector(vector: MastraVector): void;
|
|
1764
|
-
setEmbedder(embedder: EmbeddingModel<string>): void;
|
|
1765
|
-
/**
|
|
1766
|
-
* Get a system message to inject into the conversation.
|
|
1767
|
-
* This will be called before each conversation turn.
|
|
1768
|
-
* Implementations can override this to inject custom system messages.
|
|
1769
|
-
*/
|
|
1770
|
-
getSystemMessage(_input: {
|
|
1771
|
-
threadId: string;
|
|
1772
|
-
memoryConfig?: MemoryConfig;
|
|
1773
|
-
}): Promise<string | null>;
|
|
2173
|
+
interface MCPServerSSEOptionsBase {
|
|
1774
2174
|
/**
|
|
1775
|
-
*
|
|
1776
|
-
* This will be called when converting tools for the agent.
|
|
1777
|
-
* Implementations can override this to provide additional tools.
|
|
2175
|
+
* Parsed URL of the incoming request
|
|
1778
2176
|
*/
|
|
1779
|
-
|
|
1780
|
-
protected createEmbeddingIndex(dimensions?: number): Promise<{
|
|
1781
|
-
indexName: string;
|
|
1782
|
-
}>;
|
|
1783
|
-
getMergedThreadConfig(config?: MemoryConfig): MemoryConfig;
|
|
2177
|
+
url: URL;
|
|
1784
2178
|
/**
|
|
1785
|
-
*
|
|
1786
|
-
* @param messages The messages to process
|
|
1787
|
-
* @returns The processed messages
|
|
2179
|
+
* Path for establishing the SSE connection (e.g. '/sse')
|
|
1788
2180
|
*/
|
|
1789
|
-
|
|
1790
|
-
processMessages({ messages, processors, ...opts }: {
|
|
1791
|
-
messages: CoreMessage$1[];
|
|
1792
|
-
processors?: MemoryProcessor[];
|
|
1793
|
-
} & MemoryProcessorOpts): CoreMessage$1[];
|
|
1794
|
-
abstract rememberMessages({ threadId, resourceId, vectorMessageSearch, systemMessage, config, }: {
|
|
1795
|
-
threadId: string;
|
|
1796
|
-
resourceId?: string;
|
|
1797
|
-
vectorMessageSearch?: string;
|
|
1798
|
-
systemMessage?: CoreMessage$1;
|
|
1799
|
-
config?: MemoryConfig;
|
|
1800
|
-
}): Promise<{
|
|
1801
|
-
threadId: string;
|
|
1802
|
-
messages: CoreMessage$1[];
|
|
1803
|
-
uiMessages: Message[];
|
|
1804
|
-
}>;
|
|
1805
|
-
estimateTokens(text: string): number;
|
|
1806
|
-
protected parseMessages(messages: MessageType[]): CoreMessage$1[];
|
|
1807
|
-
protected convertToUIMessages(messages: MessageType[]): Message[];
|
|
2181
|
+
ssePath: string;
|
|
1808
2182
|
/**
|
|
1809
|
-
*
|
|
1810
|
-
* @param threadId - The unique identifier of the thread
|
|
1811
|
-
* @returns Promise resolving to the thread or null if not found
|
|
2183
|
+
* Path for POSTing client messages (e.g. '/message')
|
|
1812
2184
|
*/
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
2185
|
+
messagePath: string;
|
|
2186
|
+
}
|
|
2187
|
+
/**
|
|
2188
|
+
* Options for starting an MCP server with SSE transport
|
|
2189
|
+
*/
|
|
2190
|
+
interface MCPServerSSEOptions extends MCPServerSSEOptionsBase {
|
|
1819
2191
|
/**
|
|
1820
|
-
*
|
|
1821
|
-
* @param thread - The thread data to save
|
|
1822
|
-
* @returns Promise resolving to the saved thread
|
|
2192
|
+
* Incoming HTTP request
|
|
1823
2193
|
*/
|
|
1824
|
-
|
|
1825
|
-
thread: StorageThreadType;
|
|
1826
|
-
memoryConfig?: MemoryConfig;
|
|
1827
|
-
}): Promise<StorageThreadType>;
|
|
2194
|
+
req: http.IncomingMessage;
|
|
1828
2195
|
/**
|
|
1829
|
-
*
|
|
1830
|
-
* @param messages - Array of messages to save
|
|
1831
|
-
* @returns Promise resolving to the saved messages
|
|
2196
|
+
* HTTP response (must support .write/.end)
|
|
1832
2197
|
*/
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
2198
|
+
res: http.ServerResponse<http.IncomingMessage>;
|
|
2199
|
+
}
|
|
2200
|
+
/**
|
|
2201
|
+
* Options for starting an MCP server with Hono SSE transport
|
|
2202
|
+
*/
|
|
2203
|
+
interface MCPServerHonoSSEOptions extends MCPServerSSEOptionsBase {
|
|
1837
2204
|
/**
|
|
1838
|
-
*
|
|
1839
|
-
* @param threadId - The unique identifier of the thread
|
|
1840
|
-
* @returns Promise resolving to array of messages and uiMessages
|
|
2205
|
+
* Incoming Hono context
|
|
1841
2206
|
*/
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
}>;
|
|
2207
|
+
context: Context;
|
|
2208
|
+
}
|
|
2209
|
+
interface MCPServerHTTPOptions {
|
|
1846
2210
|
/**
|
|
1847
|
-
*
|
|
1848
|
-
* @param title - Optional title for the thread
|
|
1849
|
-
* @param metadata - Optional metadata for the thread
|
|
1850
|
-
* @returns Promise resolving to the created thread
|
|
2211
|
+
* Parsed URL of the incoming request
|
|
1851
2212
|
*/
|
|
1852
|
-
|
|
1853
|
-
resourceId: string;
|
|
1854
|
-
threadId?: string;
|
|
1855
|
-
title?: string;
|
|
1856
|
-
metadata?: Record<string, unknown>;
|
|
1857
|
-
memoryConfig?: MemoryConfig;
|
|
1858
|
-
}): Promise<StorageThreadType>;
|
|
2213
|
+
url: URL;
|
|
1859
2214
|
/**
|
|
1860
|
-
*
|
|
1861
|
-
* @param threadId - the id of the thread to delete
|
|
2215
|
+
* Path for establishing the HTTP connection (e.g. '/mcp')
|
|
1862
2216
|
*/
|
|
1863
|
-
|
|
2217
|
+
httpPath: string;
|
|
1864
2218
|
/**
|
|
1865
|
-
*
|
|
1866
|
-
* @param threadId - The thread to add the message to
|
|
1867
|
-
* @param content - The message content
|
|
1868
|
-
* @param role - The role of the message sender
|
|
1869
|
-
* @param type - The type of the message
|
|
1870
|
-
* @param toolNames - Optional array of tool names that were called
|
|
1871
|
-
* @param toolCallArgs - Optional array of tool call arguments
|
|
1872
|
-
* @param toolCallIds - Optional array of tool call ids
|
|
1873
|
-
* @returns Promise resolving to the saved message
|
|
2219
|
+
* Incoming HTTP request
|
|
1874
2220
|
*/
|
|
1875
|
-
|
|
1876
|
-
threadId: string;
|
|
1877
|
-
resourceId: string;
|
|
1878
|
-
config?: MemoryConfig;
|
|
1879
|
-
content: UserContent | AssistantContent;
|
|
1880
|
-
role: 'user' | 'assistant';
|
|
1881
|
-
type: 'text' | 'tool-call' | 'tool-result';
|
|
1882
|
-
toolNames?: string[];
|
|
1883
|
-
toolCallArgs?: Record<string, unknown>[];
|
|
1884
|
-
toolCallIds?: string[];
|
|
1885
|
-
}): Promise<MessageType>;
|
|
2221
|
+
req: http.IncomingMessage;
|
|
1886
2222
|
/**
|
|
1887
|
-
*
|
|
1888
|
-
* @returns A unique string ID
|
|
2223
|
+
* HTTP response (must support .write/.end)
|
|
1889
2224
|
*/
|
|
1890
|
-
|
|
2225
|
+
res: http.ServerResponse<http.IncomingMessage>;
|
|
2226
|
+
/**
|
|
2227
|
+
* Optional options to pass to the transport (e.g. sessionIdGenerator)
|
|
2228
|
+
*/
|
|
2229
|
+
options?: any;
|
|
1891
2230
|
}
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
getModelId(): string;
|
|
1901
|
-
getModel(): ai.LanguageModelV1;
|
|
1902
|
-
convertToMessages(messages: string | string[] | CoreMessage$1[]): CoreMessage$1[];
|
|
1903
|
-
__registerPrimitives(p: MastraPrimitives): void;
|
|
1904
|
-
__registerMastra(p: Mastra): void;
|
|
1905
|
-
__text<Z extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextOptions<Z>): Promise<GenerateTextResult<any, any>>;
|
|
1906
|
-
__textObject<T extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextObjectOptions<T>): Promise<GenerateObjectResult<T>>;
|
|
1907
|
-
generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options: LLMStreamOptions<Z>): Promise<GenerateReturn<Z>>;
|
|
1908
|
-
__stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(input: LLMInnerStreamOptions<Z>): Promise<StreamTextResult<any, any>>;
|
|
1909
|
-
__streamObject<T extends ZodSchema | JSONSchema7 | undefined>(input: LLMStreamObjectOptions<T>): Promise<StreamObjectResult<DeepPartial<T>, T, never>>;
|
|
1910
|
-
stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options: LLMStreamOptions<Z>): Promise<StreamReturn<Z>>;
|
|
2231
|
+
/** Describes a source code repository. */
|
|
2232
|
+
interface Repository {
|
|
2233
|
+
/** The URL of the repository (e.g., a GitHub URL). */
|
|
2234
|
+
url: string;
|
|
2235
|
+
/** The source control platform (e.g., 'github', 'gitlab'). */
|
|
2236
|
+
source: 'github' | 'gitlab' | string;
|
|
2237
|
+
/** A unique identifier for the repository at the source. */
|
|
2238
|
+
id: string;
|
|
1911
2239
|
}
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
type LanguageModel = MastraLanguageModel;
|
|
1921
|
-
type CoreMessage = CoreMessage$1;
|
|
1922
|
-
type CoreSystemMessage = CoreSystemMessage$1;
|
|
1923
|
-
type CoreAssistantMessage = CoreAssistantMessage$1;
|
|
1924
|
-
type CoreUserMessage = CoreUserMessage$1;
|
|
1925
|
-
type CoreToolMessage = CoreToolMessage$1;
|
|
1926
|
-
type EmbedResult<T> = EmbedResult$1<T>;
|
|
1927
|
-
type EmbedManyResult<T> = EmbedManyResult$1<T>;
|
|
1928
|
-
type BaseStructuredOutputType = 'string' | 'number' | 'boolean' | 'date';
|
|
1929
|
-
type StructuredOutputType = 'array' | 'string' | 'number' | 'object' | 'boolean' | 'date';
|
|
1930
|
-
type StructuredOutputArrayItem = {
|
|
1931
|
-
type: BaseStructuredOutputType;
|
|
1932
|
-
} | {
|
|
1933
|
-
type: 'object';
|
|
1934
|
-
items: StructuredOutput;
|
|
1935
|
-
};
|
|
1936
|
-
type StructuredOutput = {
|
|
1937
|
-
[key: string]: {
|
|
1938
|
-
type: BaseStructuredOutputType;
|
|
1939
|
-
} | {
|
|
1940
|
-
type: 'object';
|
|
1941
|
-
items: StructuredOutput;
|
|
1942
|
-
} | {
|
|
1943
|
-
type: 'array';
|
|
1944
|
-
items: StructuredOutputArrayItem;
|
|
1945
|
-
};
|
|
1946
|
-
};
|
|
1947
|
-
type GenerateReturn<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = Z extends undefined ? GenerateTextResult<any, Z extends ZodSchema ? z.infer<Z> : unknown> : GenerateObjectResult<Z extends ZodSchema ? z.infer<Z> : unknown>;
|
|
1948
|
-
type StreamReturn<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = Z extends undefined ? StreamTextResult<any, Z extends ZodSchema ? z.infer<Z> : unknown> : StreamObjectResult<any, Z extends ZodSchema ? z.infer<Z> : unknown, any>;
|
|
1949
|
-
type OutputType = StructuredOutput | ZodSchema | JSONSchema7 | undefined;
|
|
1950
|
-
type GenerateTextOptions = Parameters<typeof generateText>[0];
|
|
1951
|
-
type StreamTextOptions = Parameters<typeof streamText>[0];
|
|
1952
|
-
type GenerateObjectOptions = Parameters<typeof generateObject>[0];
|
|
1953
|
-
type StreamObjectOptions = Parameters<typeof streamObject>[0];
|
|
1954
|
-
type MastraCustomLLMOptionsKeys = 'messages' | 'tools' | 'model' | 'onStepFinish' | 'experimental_output' | 'experimental_telemetry' | 'messages' | 'onFinish' | 'output';
|
|
1955
|
-
type DefaultLLMTextOptions = Omit<GenerateTextOptions, MastraCustomLLMOptionsKeys>;
|
|
1956
|
-
type DefaultLLMTextObjectOptions = Omit<GenerateObjectOptions, MastraCustomLLMOptionsKeys>;
|
|
1957
|
-
type DefaultLLMStreamOptions = Omit<StreamTextOptions, MastraCustomLLMOptionsKeys>;
|
|
1958
|
-
type DefaultLLMStreamObjectOptions = Omit<StreamObjectOptions, MastraCustomLLMOptionsKeys>;
|
|
1959
|
-
type MastraCustomLLMOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
1960
|
-
tools?: Record<string, CoreTool>;
|
|
1961
|
-
onStepFinish?: (step: unknown) => void;
|
|
1962
|
-
experimental_output?: Z;
|
|
1963
|
-
telemetry?: TelemetrySettings;
|
|
1964
|
-
threadId?: string;
|
|
1965
|
-
resourceId?: string;
|
|
1966
|
-
runtimeContext: RuntimeContext;
|
|
1967
|
-
} & Run$1;
|
|
1968
|
-
type LLMTextOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
1969
|
-
messages: CoreMessage[];
|
|
1970
|
-
} & MastraCustomLLMOptions<Z> & DefaultLLMTextOptions;
|
|
1971
|
-
type LLMTextObjectOptions<T extends ZodSchema | JSONSchema7 | undefined = undefined> = LLMTextOptions<T> & DefaultLLMTextObjectOptions & {
|
|
1972
|
-
structuredOutput: JSONSchema7 | z.ZodType<T> | StructuredOutput;
|
|
1973
|
-
};
|
|
1974
|
-
type LLMStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
1975
|
-
output?: OutputType | Z;
|
|
1976
|
-
onFinish?: (result: string) => Promise<void> | void;
|
|
1977
|
-
} & MastraCustomLLMOptions<Z> & DefaultLLMStreamOptions;
|
|
1978
|
-
type LLMInnerStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
1979
|
-
messages: CoreMessage[];
|
|
1980
|
-
onFinish?: (result: string) => Promise<void> | void;
|
|
1981
|
-
} & MastraCustomLLMOptions<Z> & DefaultLLMStreamOptions;
|
|
1982
|
-
type LLMStreamObjectOptions<T extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
1983
|
-
structuredOutput: JSONSchema7 | z.ZodType<T> | StructuredOutput;
|
|
1984
|
-
} & LLMInnerStreamOptions<T> & DefaultLLMStreamObjectOptions;
|
|
1985
|
-
|
|
1986
|
-
type VoiceEventType = 'speaking' | 'writing' | 'error' | string;
|
|
1987
|
-
interface VoiceEventMap {
|
|
1988
|
-
speaker: NodeJS.ReadableStream;
|
|
1989
|
-
speaking: {
|
|
1990
|
-
audio?: string;
|
|
1991
|
-
};
|
|
1992
|
-
writing: {
|
|
1993
|
-
text: string;
|
|
1994
|
-
role: 'assistant' | 'user';
|
|
1995
|
-
};
|
|
1996
|
-
error: {
|
|
1997
|
-
message: string;
|
|
1998
|
-
code?: string;
|
|
1999
|
-
details?: unknown;
|
|
2000
|
-
};
|
|
2001
|
-
[key: string]: unknown;
|
|
2240
|
+
/** Provides details about a specific version of an MCP server. */
|
|
2241
|
+
interface VersionDetail {
|
|
2242
|
+
/** The semantic version string (e.g., "1.0.2"). */
|
|
2243
|
+
version: string;
|
|
2244
|
+
/** The ISO 8601 date-time string when this version was released or registered. */
|
|
2245
|
+
release_date: string;
|
|
2246
|
+
/** Indicates if this version is the latest available. */
|
|
2247
|
+
is_latest: boolean;
|
|
2002
2248
|
}
|
|
2003
|
-
interface
|
|
2249
|
+
/** Base interface for command-line arguments. */
|
|
2250
|
+
interface ArgumentInfo {
|
|
2251
|
+
/** The name of the argument. */
|
|
2004
2252
|
name: string;
|
|
2005
|
-
|
|
2253
|
+
/** A description of what the argument is for. */
|
|
2254
|
+
description: string;
|
|
2255
|
+
/** Whether the argument is required. */
|
|
2256
|
+
is_required: boolean;
|
|
2257
|
+
/** Whether the argument can be specified multiple times. */
|
|
2258
|
+
is_repeatable?: boolean;
|
|
2259
|
+
/** Whether the argument's value can be edited by the user (e.g., in a UI). */
|
|
2260
|
+
is_editable?: boolean;
|
|
2261
|
+
/** A list of predefined choices for the argument's value. */
|
|
2262
|
+
choices?: string[];
|
|
2263
|
+
/** The default value for the argument if not specified. */
|
|
2264
|
+
default_value?: string | number | boolean;
|
|
2006
2265
|
}
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
name?: string;
|
|
2012
|
-
realtimeConfig?: {
|
|
2013
|
-
model?: string;
|
|
2014
|
-
apiKey?: string;
|
|
2015
|
-
options?: T;
|
|
2016
|
-
};
|
|
2266
|
+
/** Describes a positional argument for a command. */
|
|
2267
|
+
interface PositionalArgumentInfo extends ArgumentInfo {
|
|
2268
|
+
/** The 0-indexed position of the argument. */
|
|
2269
|
+
position: number;
|
|
2017
2270
|
}
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
/**
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
/**
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
/**
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2271
|
+
/** Describes a named argument (flag) for a command. */
|
|
2272
|
+
interface NamedArgumentInfo extends ArgumentInfo {
|
|
2273
|
+
/** The short flag for the argument (e.g., "-y"). */
|
|
2274
|
+
short_flag?: string;
|
|
2275
|
+
/** The long flag for the argument (e.g., "--yes"). */
|
|
2276
|
+
long_flag?: string;
|
|
2277
|
+
/** Whether the flag requires a value (e.g., `--config <value>`) or is a boolean flag. */
|
|
2278
|
+
requires_value?: boolean;
|
|
2279
|
+
}
|
|
2280
|
+
/** Describes a subcommand for a command-line tool. */
|
|
2281
|
+
interface SubcommandInfo {
|
|
2282
|
+
/** The name of the subcommand (e.g., "run", "list"). */
|
|
2283
|
+
name: string;
|
|
2284
|
+
/** A description of what the subcommand does. */
|
|
2285
|
+
description: string;
|
|
2286
|
+
/** Whether this subcommand is required if its parent command is used. */
|
|
2287
|
+
is_required?: boolean;
|
|
2288
|
+
/** Nested subcommands. */
|
|
2289
|
+
subcommands?: SubcommandInfo[];
|
|
2290
|
+
/** Positional arguments for this subcommand. */
|
|
2291
|
+
positional_arguments?: PositionalArgumentInfo[];
|
|
2292
|
+
/** Named arguments (flags) for this subcommand. */
|
|
2293
|
+
named_arguments?: NamedArgumentInfo[];
|
|
2294
|
+
}
|
|
2295
|
+
/** Describes a command to run an MCP server package. */
|
|
2296
|
+
interface CommandInfo {
|
|
2297
|
+
/** The primary command executable (e.g., "npx", "docker"). */
|
|
2298
|
+
name: 'npx' | 'docker' | 'pypi' | 'uvx' | string;
|
|
2299
|
+
/** Subcommands to append to the primary command. */
|
|
2300
|
+
subcommands?: SubcommandInfo[];
|
|
2301
|
+
/** Positional arguments for the command. */
|
|
2302
|
+
positional_arguments?: PositionalArgumentInfo[];
|
|
2303
|
+
/** Named arguments (flags) for the command. */
|
|
2304
|
+
named_arguments?: NamedArgumentInfo[];
|
|
2305
|
+
}
|
|
2306
|
+
/** Describes an environment variable required or used by an MCP server package. */
|
|
2307
|
+
interface EnvironmentVariableInfo {
|
|
2308
|
+
/** The name of the environment variable (e.g., "API_KEY"). */
|
|
2309
|
+
name: string;
|
|
2310
|
+
/** A description of what the environment variable is for. */
|
|
2311
|
+
description: string;
|
|
2312
|
+
/** Whether the environment variable is required. */
|
|
2313
|
+
required?: boolean;
|
|
2314
|
+
/** The default value for the environment variable if not set. */
|
|
2315
|
+
default_value?: string;
|
|
2316
|
+
}
|
|
2317
|
+
/** Describes an installable package for an MCP server. */
|
|
2318
|
+
interface PackageInfo {
|
|
2319
|
+
/** The name of the package registry (e.g., "npm", "docker"). */
|
|
2320
|
+
registry_name: 'npm' | 'docker' | 'pypi' | 'homebrew' | string;
|
|
2321
|
+
/** The name of the package. */
|
|
2322
|
+
name: string;
|
|
2323
|
+
/** The version of the package. */
|
|
2324
|
+
version: string;
|
|
2325
|
+
/** The command structure to run this package as an MCP server. */
|
|
2326
|
+
command?: CommandInfo;
|
|
2327
|
+
/** Environment variables relevant to this package. */
|
|
2328
|
+
environment_variables?: EnvironmentVariableInfo[];
|
|
2329
|
+
}
|
|
2330
|
+
/** Describes a remote endpoint for accessing an MCP server. */
|
|
2331
|
+
interface RemoteInfo {
|
|
2332
|
+
/** The transport type for the remote connection (e.g., "sse", "streamable"). */
|
|
2333
|
+
transport_type: 'streamable' | 'sse' | string;
|
|
2334
|
+
/** The URL of the remote endpoint. */
|
|
2335
|
+
url: string;
|
|
2336
|
+
}
|
|
2337
|
+
/** Configuration options for creating an MCPServer instance. */
|
|
2338
|
+
interface MCPServerConfig {
|
|
2339
|
+
/** The display name of the MCP server. */
|
|
2340
|
+
name: string;
|
|
2341
|
+
/** The semantic version of the MCP server. */
|
|
2342
|
+
version: string;
|
|
2343
|
+
/** The tools that this MCP server will expose. */
|
|
2344
|
+
tools: ToolsInput;
|
|
2050
2345
|
/**
|
|
2051
|
-
*
|
|
2052
|
-
*
|
|
2053
|
-
*
|
|
2054
|
-
* @returns Text, text stream, or void if in chat mode
|
|
2346
|
+
* Optional unique identifier for the server.
|
|
2347
|
+
* If not provided, a UUID will be generated.
|
|
2348
|
+
* If provided, this ID is considered final and cannot be changed by Mastra.
|
|
2055
2349
|
*/
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2350
|
+
id?: string;
|
|
2351
|
+
/** Optional description of the MCP server. */
|
|
2352
|
+
description?: string;
|
|
2353
|
+
/** Optional repository information for the server's source code. */
|
|
2354
|
+
repository?: Repository;
|
|
2059
2355
|
/**
|
|
2060
|
-
*
|
|
2061
|
-
*
|
|
2356
|
+
* Optional release date of this server version (ISO 8601 string).
|
|
2357
|
+
* Defaults to the time of instantiation if not provided.
|
|
2062
2358
|
*/
|
|
2063
|
-
|
|
2359
|
+
releaseDate?: string;
|
|
2064
2360
|
/**
|
|
2065
|
-
*
|
|
2066
|
-
*
|
|
2361
|
+
* Optional flag indicating if this is the latest version.
|
|
2362
|
+
* Defaults to true if not provided.
|
|
2067
2363
|
*/
|
|
2068
|
-
|
|
2364
|
+
isLatest?: boolean;
|
|
2069
2365
|
/**
|
|
2070
|
-
*
|
|
2366
|
+
* Optional canonical packaging format if the server is distributed as a package
|
|
2367
|
+
* (e.g., "npm", "docker").
|
|
2071
2368
|
*/
|
|
2072
|
-
|
|
2369
|
+
packageCanonical?: 'npm' | 'docker' | 'pypi' | 'crates' | string;
|
|
2370
|
+
/** Optional list of installable packages for this server. */
|
|
2371
|
+
packages?: PackageInfo[];
|
|
2372
|
+
/** Optional list of remote access points for this server. */
|
|
2373
|
+
remotes?: RemoteInfo[];
|
|
2374
|
+
}
|
|
2375
|
+
/** Basic information about an MCP server, conforming to the MCP Registry 'Server' schema. */
|
|
2376
|
+
interface ServerInfo {
|
|
2377
|
+
/** The unique ID of the server. */
|
|
2378
|
+
id: string;
|
|
2379
|
+
/** The name of the server. */
|
|
2380
|
+
name: string;
|
|
2381
|
+
/** A description of the server. */
|
|
2382
|
+
description?: string;
|
|
2383
|
+
/** Repository information for the server. */
|
|
2384
|
+
repository?: Repository;
|
|
2385
|
+
/** Detailed version information. */
|
|
2386
|
+
version_detail: VersionDetail;
|
|
2387
|
+
}
|
|
2388
|
+
/** Detailed information about an MCP server, conforming to the MCP Registry 'ServerDetail' schema. */
|
|
2389
|
+
interface ServerDetailInfo extends ServerInfo {
|
|
2390
|
+
/** The canonical packaging format, if applicable. */
|
|
2391
|
+
package_canonical?: MCPServerConfig['packageCanonical'];
|
|
2392
|
+
/** Information about installable packages for this server. */
|
|
2393
|
+
packages?: PackageInfo[];
|
|
2394
|
+
/** Information about remote access points for this server. */
|
|
2395
|
+
remotes?: RemoteInfo[];
|
|
2396
|
+
}
|
|
2397
|
+
|
|
2398
|
+
/**
|
|
2399
|
+
* Abstract base class for MCP server implementations.
|
|
2400
|
+
* This provides a common interface and shared functionality for all MCP servers
|
|
2401
|
+
* that can be registered with Mastra, including handling of server metadata.
|
|
2402
|
+
*/
|
|
2403
|
+
declare abstract class MCPServerBase extends MastraBase {
|
|
2404
|
+
/** Tracks if the server ID has been definitively set. */
|
|
2405
|
+
private idWasSet;
|
|
2406
|
+
/** The display name of the MCP server. */
|
|
2407
|
+
readonly name: string;
|
|
2408
|
+
/** The semantic version of the MCP server. */
|
|
2409
|
+
readonly version: string;
|
|
2410
|
+
/** Internal storage for the server's unique ID. */
|
|
2411
|
+
private _id;
|
|
2412
|
+
/** A description of what the MCP server does. */
|
|
2413
|
+
readonly description?: string;
|
|
2414
|
+
/** Repository information for the server's source code. */
|
|
2415
|
+
readonly repository?: Repository;
|
|
2416
|
+
/** The release date of this server version (ISO 8601 string). */
|
|
2417
|
+
readonly releaseDate: string;
|
|
2418
|
+
/** Indicates if this version is the latest available. */
|
|
2419
|
+
readonly isLatest: boolean;
|
|
2420
|
+
/** The canonical packaging format (e.g., "npm", "docker"), if applicable. */
|
|
2421
|
+
readonly packageCanonical?: MCPServerConfig['packageCanonical'];
|
|
2422
|
+
/** Information about installable packages for this server. */
|
|
2423
|
+
readonly packages?: PackageInfo[];
|
|
2424
|
+
/** Information about remote access points for this server. */
|
|
2425
|
+
readonly remotes?: RemoteInfo[];
|
|
2426
|
+
/** The tools registered with and converted by this MCP server. */
|
|
2427
|
+
readonly convertedTools: Record<string, ConvertedTool>;
|
|
2428
|
+
/** Reference to the Mastra instance if this server is registered with one. */
|
|
2429
|
+
mastra: Mastra | undefined;
|
|
2073
2430
|
/**
|
|
2074
|
-
*
|
|
2075
|
-
*
|
|
2431
|
+
* Public getter for the server's unique ID.
|
|
2432
|
+
* The ID is set at construction or by Mastra and is read-only afterwards.
|
|
2076
2433
|
*/
|
|
2077
|
-
|
|
2434
|
+
get id(): string;
|
|
2078
2435
|
/**
|
|
2079
|
-
*
|
|
2080
|
-
* @
|
|
2436
|
+
* Gets a read-only view of the registered tools.
|
|
2437
|
+
* @returns A readonly record of converted tools.
|
|
2081
2438
|
*/
|
|
2082
|
-
|
|
2439
|
+
tools(): Readonly<Record<string, ConvertedTool>>;
|
|
2083
2440
|
/**
|
|
2084
|
-
*
|
|
2441
|
+
* Sets the server's unique ID. This method is typically called by Mastra when
|
|
2442
|
+
* registering the server, using the key provided in the Mastra configuration.
|
|
2443
|
+
* It ensures the ID is set only once.
|
|
2444
|
+
* If an ID was already provided in the MCPServerConfig, this method will be a no-op.
|
|
2445
|
+
* @param id The unique ID to assign to the server.
|
|
2085
2446
|
*/
|
|
2086
|
-
|
|
2447
|
+
setId(id: string): void;
|
|
2087
2448
|
/**
|
|
2088
|
-
*
|
|
2089
|
-
* @param
|
|
2090
|
-
* @
|
|
2449
|
+
* Abstract method to convert and validate tool definitions provided to the server.
|
|
2450
|
+
* @param tools Tool definitions to convert.
|
|
2451
|
+
* @returns A record of converted and validated tools.
|
|
2091
2452
|
*/
|
|
2092
|
-
|
|
2453
|
+
abstract convertTools(tools: ToolsInput): Record<string, ConvertedTool>;
|
|
2093
2454
|
/**
|
|
2094
|
-
*
|
|
2095
|
-
* @param
|
|
2096
|
-
* @
|
|
2455
|
+
* Internal method used by Mastra to register itself with the server.
|
|
2456
|
+
* @param mastra The Mastra instance.
|
|
2457
|
+
* @internal
|
|
2097
2458
|
*/
|
|
2098
|
-
|
|
2459
|
+
__registerMastra(mastra: Mastra): void;
|
|
2099
2460
|
/**
|
|
2100
|
-
*
|
|
2101
|
-
* @
|
|
2461
|
+
* Constructor for the MCPServerBase.
|
|
2462
|
+
* @param config Configuration options for the MCP server, including metadata.
|
|
2102
2463
|
*/
|
|
2103
|
-
|
|
2104
|
-
voiceId: string;
|
|
2105
|
-
} & TSpeakerMetadata>>;
|
|
2106
|
-
}
|
|
2107
|
-
|
|
2108
|
-
declare class CompositeVoice extends MastraVoice<unknown, unknown, unknown, ToolsInput, VoiceEventMap> {
|
|
2109
|
-
protected speakProvider?: MastraVoice;
|
|
2110
|
-
protected listenProvider?: MastraVoice;
|
|
2111
|
-
protected realtimeProvider?: MastraVoice;
|
|
2112
|
-
constructor({ input, output, realtime, speakProvider, listenProvider, realtimeProvider, }: {
|
|
2113
|
-
/** @deprecated use output instead */
|
|
2114
|
-
speakProvider?: MastraVoice;
|
|
2115
|
-
/** @deprecated use input instead */
|
|
2116
|
-
listenProvider?: MastraVoice;
|
|
2117
|
-
/** @deprecated use realtime instead */
|
|
2118
|
-
realtimeProvider?: MastraVoice;
|
|
2119
|
-
input?: MastraVoice;
|
|
2120
|
-
output?: MastraVoice;
|
|
2121
|
-
realtime?: MastraVoice;
|
|
2122
|
-
});
|
|
2464
|
+
constructor(config: MCPServerConfig);
|
|
2123
2465
|
/**
|
|
2124
|
-
*
|
|
2125
|
-
*
|
|
2126
|
-
* @param options Speech options including speaker and provider-specific options
|
|
2127
|
-
* @returns Audio stream or void if in realtime mode
|
|
2466
|
+
* Start the MCP server using stdio transport
|
|
2467
|
+
* This is typically used for Windsurf integration
|
|
2128
2468
|
*/
|
|
2129
|
-
|
|
2130
|
-
speaker?: string;
|
|
2131
|
-
} & any): Promise<NodeJS.ReadableStream | void>;
|
|
2132
|
-
listen(audioStream: NodeJS.ReadableStream, options?: any): Promise<string | void | NodeJS.ReadableStream>;
|
|
2133
|
-
getSpeakers(): Promise<{
|
|
2134
|
-
voiceId: string;
|
|
2135
|
-
}[]>;
|
|
2136
|
-
updateConfig(options: Record<string, unknown>): void;
|
|
2469
|
+
abstract startStdio(): Promise<void>;
|
|
2137
2470
|
/**
|
|
2138
|
-
*
|
|
2139
|
-
*
|
|
2471
|
+
* Start the MCP server using SSE transport
|
|
2472
|
+
* This is typically used for web integration
|
|
2473
|
+
* @param options Options for the SSE transport
|
|
2140
2474
|
*/
|
|
2141
|
-
|
|
2475
|
+
abstract startSSE(options: MCPServerSSEOptions): Promise<void>;
|
|
2142
2476
|
/**
|
|
2143
|
-
*
|
|
2144
|
-
*
|
|
2477
|
+
* Start the MCP server using Hono SSE transport
|
|
2478
|
+
* Used for Hono servers
|
|
2479
|
+
* @param options Options for the SSE transport
|
|
2145
2480
|
*/
|
|
2146
|
-
|
|
2481
|
+
abstract startHonoSSE(options: MCPServerHonoSSEOptions): Promise<Response | undefined>;
|
|
2147
2482
|
/**
|
|
2148
|
-
*
|
|
2483
|
+
* Start the MCP server using HTTP transport
|
|
2484
|
+
* @param options Options for the HTTP transport
|
|
2149
2485
|
*/
|
|
2150
|
-
|
|
2486
|
+
abstract startHTTP(options: MCPServerHTTPOptions): Promise<void>;
|
|
2151
2487
|
/**
|
|
2152
|
-
*
|
|
2153
|
-
* @param instructions Instructions to add
|
|
2488
|
+
* Close the MCP server and all its connections
|
|
2154
2489
|
*/
|
|
2155
|
-
|
|
2490
|
+
abstract close(): Promise<void>;
|
|
2156
2491
|
/**
|
|
2157
|
-
*
|
|
2158
|
-
*
|
|
2492
|
+
* Gets the basic information about the server, conforming to the MCP Registry 'Server' schema.
|
|
2493
|
+
* This information is suitable for listing multiple servers.
|
|
2494
|
+
* @returns ServerInfo object containing basic server metadata.
|
|
2159
2495
|
*/
|
|
2160
|
-
|
|
2496
|
+
abstract getServerInfo(): ServerInfo;
|
|
2161
2497
|
/**
|
|
2162
|
-
*
|
|
2498
|
+
* Gets detailed information about the server, conforming to the MCP Registry 'ServerDetail' schema.
|
|
2499
|
+
* This includes all information from `getServerInfo` plus package and remote details.
|
|
2500
|
+
* @returns ServerDetailInfo object containing comprehensive server metadata.
|
|
2163
2501
|
*/
|
|
2164
|
-
|
|
2502
|
+
abstract getServerDetail(): ServerDetailInfo;
|
|
2165
2503
|
/**
|
|
2166
|
-
*
|
|
2167
|
-
* @
|
|
2168
|
-
* @param callback Callback function that receives event data
|
|
2504
|
+
* Gets a list of tools provided by this MCP server, including their schemas.
|
|
2505
|
+
* @returns An object containing an array of tool information.
|
|
2169
2506
|
*/
|
|
2170
|
-
|
|
2507
|
+
abstract getToolListInfo(): {
|
|
2508
|
+
tools: Array<{
|
|
2509
|
+
name: string;
|
|
2510
|
+
description?: string;
|
|
2511
|
+
inputSchema: string;
|
|
2512
|
+
}>;
|
|
2513
|
+
};
|
|
2171
2514
|
/**
|
|
2172
|
-
*
|
|
2173
|
-
* @param
|
|
2174
|
-
* @
|
|
2515
|
+
* Gets information for a specific tool provided by this MCP server.
|
|
2516
|
+
* @param toolId The ID/name of the tool to retrieve.
|
|
2517
|
+
* @returns Tool information (name, description, inputSchema) or undefined if not found.
|
|
2175
2518
|
*/
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
}) => Promise<T> | T);
|
|
2194
|
-
interface AgentConfig<TAgentId extends string = string, TTools extends ToolsInput = ToolsInput, TMetrics extends Record<string, Metric> = Record<string, Metric>> {
|
|
2195
|
-
name: TAgentId;
|
|
2196
|
-
instructions: DynamicArgument<string>;
|
|
2197
|
-
model: DynamicArgument<MastraLanguageModel>;
|
|
2198
|
-
tools?: DynamicArgument<TTools>;
|
|
2199
|
-
workflows?: DynamicArgument<Record<string, NewWorkflow>>;
|
|
2200
|
-
defaultGenerateOptions?: AgentGenerateOptions;
|
|
2201
|
-
defaultStreamOptions?: AgentStreamOptions;
|
|
2202
|
-
mastra?: Mastra;
|
|
2203
|
-
evals?: TMetrics;
|
|
2204
|
-
memory?: MastraMemory;
|
|
2205
|
-
voice?: CompositeVoice;
|
|
2206
|
-
/** @deprecated This property is deprecated. Use evals instead to add evaluation metrics. */
|
|
2207
|
-
metrics?: TMetrics;
|
|
2519
|
+
abstract getToolInfo(toolId: string): {
|
|
2520
|
+
name: string;
|
|
2521
|
+
description?: string;
|
|
2522
|
+
inputSchema: string;
|
|
2523
|
+
} | undefined;
|
|
2524
|
+
/**
|
|
2525
|
+
* Executes a specific tool provided by this MCP server.
|
|
2526
|
+
* @param toolId The ID/name of the tool to execute.
|
|
2527
|
+
* @param args The arguments to pass to the tool's execute function.
|
|
2528
|
+
* @param executionContext Optional context for the tool execution (e.g., messages, toolCallId).
|
|
2529
|
+
* @returns A promise that resolves to the result of the tool execution.
|
|
2530
|
+
* @throws Error if the tool is not found, or if execution fails.
|
|
2531
|
+
*/
|
|
2532
|
+
abstract executeTool(toolId: string, args: any, executionContext?: {
|
|
2533
|
+
messages?: any[];
|
|
2534
|
+
toolCallId?: string;
|
|
2535
|
+
}): Promise<any>;
|
|
2208
2536
|
}
|
|
2209
|
-
/**
|
|
2210
|
-
* Options for generating responses with an agent
|
|
2211
|
-
* @template Z - The schema type for structured output (Zod schema or JSON schema)
|
|
2212
|
-
*/
|
|
2213
|
-
type AgentGenerateOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
2214
|
-
/** Optional instructions to override the agent's default instructions */
|
|
2215
|
-
instructions?: string;
|
|
2216
|
-
/** Additional tool sets that can be used for this generation */
|
|
2217
|
-
toolsets?: ToolsetsInput;
|
|
2218
|
-
clientTools?: ToolsInput;
|
|
2219
|
-
/** Additional context messages to include */
|
|
2220
|
-
context?: CoreMessage[];
|
|
2221
|
-
/** Memory configuration options */
|
|
2222
|
-
memoryOptions?: MemoryConfig;
|
|
2223
|
-
/** Unique ID for this generation run */
|
|
2224
|
-
runId?: string;
|
|
2225
|
-
/** Callback fired after each generation step completes */
|
|
2226
|
-
onStepFinish?: Z extends undefined ? GenerateTextOnStepFinishCallback<any> : never;
|
|
2227
|
-
/** Maximum number of steps allowed for generation */
|
|
2228
|
-
maxSteps?: number;
|
|
2229
|
-
/** Schema for structured output, does not work with tools, use experimental_output instead */
|
|
2230
|
-
output?: OutputType | Z;
|
|
2231
|
-
/** Schema for structured output generation alongside tool calls. */
|
|
2232
|
-
experimental_output?: Z;
|
|
2233
|
-
/** Controls how tools are selected during generation */
|
|
2234
|
-
toolChoice?: 'auto' | 'none' | 'required' | {
|
|
2235
|
-
type: 'tool';
|
|
2236
|
-
toolName: string;
|
|
2237
|
-
};
|
|
2238
|
-
/** Telemetry settings */
|
|
2239
|
-
telemetry?: TelemetrySettings;
|
|
2240
|
-
/** RuntimeContext for dependency injection */
|
|
2241
|
-
runtimeContext?: RuntimeContext;
|
|
2242
|
-
} & ({
|
|
2243
|
-
resourceId?: undefined;
|
|
2244
|
-
threadId?: undefined;
|
|
2245
|
-
} | {
|
|
2246
|
-
resourceId: string;
|
|
2247
|
-
threadId: string;
|
|
2248
|
-
}) & (Z extends undefined ? DefaultLLMTextOptions : DefaultLLMTextObjectOptions);
|
|
2249
|
-
/**
|
|
2250
|
-
* Options for streaming responses with an agent
|
|
2251
|
-
* @template Z - The schema type for structured output (Zod schema or JSON schema)
|
|
2252
|
-
*/
|
|
2253
|
-
type AgentStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
2254
|
-
/** Optional instructions to override the agent's default instructions */
|
|
2255
|
-
instructions?: string;
|
|
2256
|
-
/** Additional tool sets that can be used for this generation */
|
|
2257
|
-
toolsets?: ToolsetsInput;
|
|
2258
|
-
clientTools?: ToolsInput;
|
|
2259
|
-
/** Additional context messages to include */
|
|
2260
|
-
context?: CoreMessage[];
|
|
2261
|
-
/** Memory configuration options */
|
|
2262
|
-
memoryOptions?: MemoryConfig;
|
|
2263
|
-
/** Unique ID for this generation run */
|
|
2264
|
-
runId?: string;
|
|
2265
|
-
/** Callback fired when streaming completes */
|
|
2266
|
-
onFinish?: Z extends undefined ? StreamTextOnFinishCallback<any> : Z extends ZodSchema ? StreamObjectOnFinishCallback<z.infer<Z>> : StreamObjectOnFinishCallback<any>;
|
|
2267
|
-
/** Callback fired after each generation step completes */
|
|
2268
|
-
onStepFinish?: Z extends undefined ? StreamTextOnStepFinishCallback<any> : never;
|
|
2269
|
-
/** Maximum number of steps allowed for generation */
|
|
2270
|
-
maxSteps?: number;
|
|
2271
|
-
/** Schema for structured output */
|
|
2272
|
-
output?: OutputType | Z;
|
|
2273
|
-
/** Temperature parameter for controlling randomness */
|
|
2274
|
-
temperature?: number;
|
|
2275
|
-
/** Controls how tools are selected during generation */
|
|
2276
|
-
toolChoice?: 'auto' | 'none' | 'required' | {
|
|
2277
|
-
type: 'tool';
|
|
2278
|
-
toolName: string;
|
|
2279
|
-
};
|
|
2280
|
-
/** Experimental schema for structured output */
|
|
2281
|
-
experimental_output?: Z;
|
|
2282
|
-
/** Telemetry settings */
|
|
2283
|
-
telemetry?: TelemetrySettings;
|
|
2284
|
-
/** RuntimeContext for dependency injection */
|
|
2285
|
-
runtimeContext?: RuntimeContext;
|
|
2286
|
-
} & ({
|
|
2287
|
-
resourceId?: undefined;
|
|
2288
|
-
threadId?: undefined;
|
|
2289
|
-
} | {
|
|
2290
|
-
resourceId: string;
|
|
2291
|
-
threadId: string;
|
|
2292
|
-
}) & (Z extends undefined ? DefaultLLMStreamOptions : DefaultLLMStreamObjectOptions);
|
|
2293
2537
|
|
|
2294
2538
|
type Methods = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'ALL';
|
|
2295
2539
|
type ApiRoute = {
|
|
@@ -2311,6 +2555,47 @@ type Middleware = MiddlewareHandler | {
|
|
|
2311
2555
|
path: string;
|
|
2312
2556
|
handler: MiddlewareHandler;
|
|
2313
2557
|
};
|
|
2558
|
+
type ContextWithMastra = Context<{
|
|
2559
|
+
Variables: {
|
|
2560
|
+
mastra: Mastra;
|
|
2561
|
+
runtimeContext: RuntimeContext;
|
|
2562
|
+
};
|
|
2563
|
+
}>;
|
|
2564
|
+
type MastraAuthConfig<TUser = unknown> = {
|
|
2565
|
+
/**
|
|
2566
|
+
* Public paths for the server
|
|
2567
|
+
*/
|
|
2568
|
+
public?: (RegExp | string | [string, Methods | Methods[]])[];
|
|
2569
|
+
/**
|
|
2570
|
+
* Public paths for the server
|
|
2571
|
+
*/
|
|
2572
|
+
authenticateToken?: (token: string, request: HonoRequest) => Promise<TUser>;
|
|
2573
|
+
/**
|
|
2574
|
+
* Authorization function for the server
|
|
2575
|
+
*/
|
|
2576
|
+
authorize?: (path: string, method: string, user: TUser, context: ContextWithMastra) => Promise<boolean>;
|
|
2577
|
+
/**
|
|
2578
|
+
* Rules for the server
|
|
2579
|
+
*/
|
|
2580
|
+
rules?: {
|
|
2581
|
+
/**
|
|
2582
|
+
* Path for the rule
|
|
2583
|
+
*/
|
|
2584
|
+
path?: RegExp | string | string[];
|
|
2585
|
+
/**
|
|
2586
|
+
* Method for the rule
|
|
2587
|
+
*/
|
|
2588
|
+
methods?: Methods | Methods[];
|
|
2589
|
+
/**
|
|
2590
|
+
* Condition for the rule
|
|
2591
|
+
*/
|
|
2592
|
+
condition?: (user: TUser) => Promise<boolean> | boolean;
|
|
2593
|
+
/**
|
|
2594
|
+
* Allow the rule
|
|
2595
|
+
*/
|
|
2596
|
+
allow?: boolean;
|
|
2597
|
+
}[];
|
|
2598
|
+
};
|
|
2314
2599
|
type ServerConfig = {
|
|
2315
2600
|
/**
|
|
2316
2601
|
* Port for the server
|
|
@@ -2364,16 +2649,20 @@ type ServerConfig = {
|
|
|
2364
2649
|
* @default 4.5mb
|
|
2365
2650
|
*/
|
|
2366
2651
|
bodySizeLimit?: number;
|
|
2652
|
+
/**
|
|
2653
|
+
* Authentication configuration for the server
|
|
2654
|
+
*/
|
|
2655
|
+
experimental_auth?: MastraAuthConfig<any>;
|
|
2367
2656
|
};
|
|
2368
2657
|
|
|
2369
|
-
interface Config<TAgents extends Record<string, Agent<any>> = Record<string, Agent<any>>,
|
|
2658
|
+
interface Config<TAgents extends Record<string, Agent<any>> = Record<string, Agent<any>>, TLegacyWorkflows extends Record<string, LegacyWorkflow> = Record<string, LegacyWorkflow>, TWorkflows extends Record<string, Workflow> = Record<string, Workflow>, TVectors extends Record<string, MastraVector> = Record<string, MastraVector>, TTTS extends Record<string, MastraTTS> = Record<string, MastraTTS>, TLogger extends IMastraLogger = IMastraLogger, TNetworks extends Record<string, AgentNetwork> = Record<string, AgentNetwork>, TMCPServers extends Record<string, MCPServerBase> = Record<string, MCPServerBase>> {
|
|
2370
2659
|
agents?: TAgents;
|
|
2371
2660
|
networks?: TNetworks;
|
|
2372
2661
|
storage?: MastraStorage;
|
|
2373
2662
|
vectors?: TVectors;
|
|
2374
2663
|
logger?: TLogger | false;
|
|
2664
|
+
legacy_workflows?: TLegacyWorkflows;
|
|
2375
2665
|
workflows?: TWorkflows;
|
|
2376
|
-
vnext_workflows?: TNewWorkflows;
|
|
2377
2666
|
tts?: TTTS;
|
|
2378
2667
|
telemetry?: OtelConfig;
|
|
2379
2668
|
deployer?: MastraDeployer;
|
|
@@ -2388,9 +2677,9 @@ interface Config<TAgents extends Record<string, Agent<any>> = Record<string, Age
|
|
|
2388
2677
|
handler: (c: any, next: () => Promise<void>) => Promise<Response | void>;
|
|
2389
2678
|
path?: string;
|
|
2390
2679
|
}>;
|
|
2391
|
-
memory?:
|
|
2680
|
+
memory?: never;
|
|
2392
2681
|
}
|
|
2393
|
-
declare class Mastra<TAgents extends Record<string, Agent<any>> = Record<string, Agent<any>>,
|
|
2682
|
+
declare class Mastra<TAgents extends Record<string, Agent<any>> = Record<string, Agent<any>>, TLegacyWorkflows extends Record<string, LegacyWorkflow> = Record<string, LegacyWorkflow>, TWorkflows extends Record<string, Workflow> = Record<string, Workflow>, TVectors extends Record<string, MastraVector> = Record<string, MastraVector>, TTTS extends Record<string, MastraTTS> = Record<string, MastraTTS>, TLogger extends IMastraLogger = IMastraLogger, TNetworks extends Record<string, AgentNetwork> = Record<string, AgentNetwork>, TMCPServers extends Record<string, MCPServerBase> = Record<string, MCPServerBase>> {
|
|
2394
2683
|
#private;
|
|
2395
2684
|
/**
|
|
2396
2685
|
* @deprecated use getTelemetry() instead
|
|
@@ -2404,24 +2693,24 @@ declare class Mastra<TAgents extends Record<string, Agent<any>> = Record<string,
|
|
|
2404
2693
|
* @deprecated use getMemory() instead
|
|
2405
2694
|
*/
|
|
2406
2695
|
get memory(): MastraMemory | undefined;
|
|
2407
|
-
constructor(config?: Config<TAgents,
|
|
2696
|
+
constructor(config?: Config<TAgents, TLegacyWorkflows, TWorkflows, TVectors, TTTS, TLogger, TNetworks, TMCPServers>);
|
|
2408
2697
|
getAgent<TAgentName extends keyof TAgents>(name: TAgentName): TAgents[TAgentName];
|
|
2409
2698
|
getAgents(): TAgents;
|
|
2410
2699
|
getVector<TVectorName extends keyof TVectors>(name: TVectorName): TVectors[TVectorName];
|
|
2411
2700
|
getVectors(): TVectors | undefined;
|
|
2412
2701
|
getDeployer(): MastraDeployer | undefined;
|
|
2702
|
+
legacy_getWorkflow<TWorkflowId extends keyof TLegacyWorkflows>(id: TWorkflowId, { serialized }?: {
|
|
2703
|
+
serialized?: boolean;
|
|
2704
|
+
}): TLegacyWorkflows[TWorkflowId];
|
|
2413
2705
|
getWorkflow<TWorkflowId extends keyof TWorkflows>(id: TWorkflowId, { serialized }?: {
|
|
2414
2706
|
serialized?: boolean;
|
|
2415
2707
|
}): TWorkflows[TWorkflowId];
|
|
2416
|
-
|
|
2708
|
+
legacy_getWorkflows(props?: {
|
|
2417
2709
|
serialized?: boolean;
|
|
2418
|
-
}):
|
|
2710
|
+
}): Record<string, LegacyWorkflow>;
|
|
2419
2711
|
getWorkflows(props?: {
|
|
2420
2712
|
serialized?: boolean;
|
|
2421
2713
|
}): Record<string, Workflow>;
|
|
2422
|
-
vnext_getWorkflows(props?: {
|
|
2423
|
-
serialized?: boolean;
|
|
2424
|
-
}): Record<string, NewWorkflow>;
|
|
2425
2714
|
setStorage(storage: MastraStorage): void;
|
|
2426
2715
|
setLogger({ logger }: {
|
|
2427
2716
|
logger: TLogger;
|
|
@@ -2447,23 +2736,27 @@ declare class Mastra<TAgents extends Record<string, Agent<any>> = Record<string,
|
|
|
2447
2736
|
getLogsByRunId({ runId, transportId }: {
|
|
2448
2737
|
runId: string;
|
|
2449
2738
|
transportId: string;
|
|
2450
|
-
}): Promise<
|
|
2451
|
-
getLogs(transportId: string): Promise<
|
|
2739
|
+
}): Promise<any[]>;
|
|
2740
|
+
getLogs(transportId: string): Promise<any[]>;
|
|
2452
2741
|
/**
|
|
2453
|
-
* Get
|
|
2454
|
-
* @
|
|
2455
|
-
* @returns The MCP server with the specified ID, or undefined if not found
|
|
2742
|
+
* Get all registered MCP server instances.
|
|
2743
|
+
* @returns A record of MCP server ID to MCPServerBase instance, or undefined if none are registered.
|
|
2456
2744
|
*/
|
|
2457
|
-
|
|
2745
|
+
getMCPServers(): Record<string, MCPServerBase> | undefined;
|
|
2458
2746
|
/**
|
|
2459
|
-
* Get
|
|
2460
|
-
*
|
|
2747
|
+
* Get a specific MCP server instance.
|
|
2748
|
+
* If a version is provided, it attempts to find the server with that exact logical ID and version.
|
|
2749
|
+
* If no version is provided, it returns the server with the specified logical ID that has the most recent releaseDate.
|
|
2750
|
+
* The logical ID should match the `id` property of the MCPServer instance (typically set via MCPServerConfig.id).
|
|
2751
|
+
* @param serverId - The logical ID of the MCP server to retrieve.
|
|
2752
|
+
* @param version - Optional specific version of the MCP server to retrieve.
|
|
2753
|
+
* @returns The MCP server instance, or undefined if not found or if the specific version is not found.
|
|
2461
2754
|
*/
|
|
2462
|
-
|
|
2755
|
+
getMCPServer(serverId: string, version?: string): MCPServerBase | undefined;
|
|
2463
2756
|
}
|
|
2464
2757
|
|
|
2465
2758
|
type MastraPrimitives = {
|
|
2466
|
-
logger?:
|
|
2759
|
+
logger?: IMastraLogger;
|
|
2467
2760
|
telemetry?: Telemetry;
|
|
2468
2761
|
storage?: MastraStorage;
|
|
2469
2762
|
agents?: Record<string, Agent>;
|
|
@@ -2502,7 +2795,7 @@ declare class Agent<TAgentId extends string = string, TTools extends ToolsInput
|
|
|
2502
2795
|
get voice(): CompositeVoice;
|
|
2503
2796
|
getWorkflows({ runtimeContext, }?: {
|
|
2504
2797
|
runtimeContext?: RuntimeContext;
|
|
2505
|
-
}): Promise<Record<string,
|
|
2798
|
+
}): Promise<Record<string, Workflow>>;
|
|
2506
2799
|
getVoice({ runtimeContext }?: {
|
|
2507
2800
|
runtimeContext?: RuntimeContext;
|
|
2508
2801
|
}): Promise<CompositeVoice | DefaultVoice>;
|
|
@@ -2665,7 +2958,7 @@ declare class Agent<TAgentId extends string = string, TTools extends ToolsInput
|
|
|
2665
2958
|
getSpeakers(): Promise<{
|
|
2666
2959
|
voiceId: string;
|
|
2667
2960
|
}[]>;
|
|
2668
|
-
toStep():
|
|
2961
|
+
toStep(): LegacyStep<TAgentId, z.ZodObject<{
|
|
2669
2962
|
prompt: z.ZodString;
|
|
2670
2963
|
}>, z.ZodObject<{
|
|
2671
2964
|
text: z.ZodString;
|
|
@@ -2681,6 +2974,18 @@ interface StorageColumn {
|
|
|
2681
2974
|
column: string;
|
|
2682
2975
|
};
|
|
2683
2976
|
}
|
|
2977
|
+
interface LegacyWorkflowRuns {
|
|
2978
|
+
runs: LegacyWorkflowRun[];
|
|
2979
|
+
total: number;
|
|
2980
|
+
}
|
|
2981
|
+
interface LegacyWorkflowRun {
|
|
2982
|
+
workflowName: string;
|
|
2983
|
+
runId: string;
|
|
2984
|
+
snapshot: LegacyWorkflowRunState | string;
|
|
2985
|
+
createdAt: Date;
|
|
2986
|
+
updatedAt: Date;
|
|
2987
|
+
resourceId?: string;
|
|
2988
|
+
}
|
|
2684
2989
|
interface WorkflowRuns {
|
|
2685
2990
|
runs: WorkflowRun[];
|
|
2686
2991
|
total: number;
|
|
@@ -2764,12 +3069,8 @@ type MemoryConfig = {
|
|
|
2764
3069
|
workingMemory?: {
|
|
2765
3070
|
enabled: boolean;
|
|
2766
3071
|
template?: string;
|
|
2767
|
-
use
|
|
2768
|
-
|
|
2769
|
-
enabled: boolean;
|
|
2770
|
-
template?: string;
|
|
2771
|
-
/** @deprecated the 'text-stream' working memory option (which is the current default) will be full removed in favor of the 'tool-call' option in a future breaking change. */
|
|
2772
|
-
use?: 'text-stream';
|
|
3072
|
+
/** @deprecated The `use` option has been removed. Working memory always uses tool-call mode. */
|
|
3073
|
+
use?: never;
|
|
2773
3074
|
};
|
|
2774
3075
|
threads?: {
|
|
2775
3076
|
generateTitle?: boolean;
|
|
@@ -2877,4 +3178,4 @@ declare abstract class MastraStorage extends MastraBase {
|
|
|
2877
3178
|
}): Promise<WorkflowRun | null>;
|
|
2878
3179
|
}
|
|
2879
3180
|
|
|
2880
|
-
export { type
|
|
3181
|
+
export { type WorkflowActions as $, type ApiRoute as A, type StepGraph as B, type ContextWithMastra as C, type BaseCondition as D, type EvalRow as E, type ActionContext as F, WhenConditionReturnValue as G, type StepDef as H, type StepCondition as I, type StepConfig as J, type StepsRecord$1 as K, type LegacyWorkflowRuns as L, type Methods as M, type WorkflowLogMessage as N, type WorkflowEvent as O, type ResolverFunctionInput as P, type ResolverFunctionOutput as Q, type RetryConfig as R, type StorageColumn as S, type TABLE_NAMES as T, type SubscriberFunctionOutput as U, type VariableReference$1 as V, type WorkflowRuns as W, type DependencyCheckOutput as X, type StepResolverOutput as Y, type WorkflowActors as Z, type WorkflowActionParams as _, Mastra as a, ExecutionEngine as a$, type LegacyWorkflowState as a0, type StepId as a1, type ExtractSchemaFromStep$1 as a2, type ExtractStepResult as a3, type StepInputType as a4, type ExtractSchemaType$1 as a5, type PathsToStringProps$1 as a6, type LegacyWorkflowRunState as a7, type WorkflowResumeResult as a8, type ToolAction as a9, type LLMTextOptions as aA, type LLMTextObjectOptions as aB, type LLMStreamOptions as aC, type LLMInnerStreamOptions as aD, type LLMStreamObjectOptions as aE, createMockModel as aF, type Config as aG, type MessageResponse as aH, type MemoryConfig as aI, type SharedMemoryConfig as aJ, type MemoryProcessorOpts as aK, MemoryProcessor as aL, memoryDefaultOptions as aM, createTool as aN, type VercelTool as aO, type CoreTool as aP, type InternalCoreTool as aQ, type StepFlowEntry as aR, type SerializedStep as aS, type SerializedStepFlowEntry as aT, createStep as aU, cloneStep as aV, createWorkflow as aW, cloneWorkflow as aX, type WorkflowResult as aY, Run as aZ, type ExecutionGraph as a_, type AgentConfig as aa, MastraMemory as ab, type ToolExecutionContext as ac, Tool as ad, type Step as ae, Workflow as af, type WorkflowConfig as ag, type LanguageModel as ah, type CoreMessage as ai, type CoreSystemMessage as aj, type CoreAssistantMessage as ak, type CoreUserMessage as al, type CoreToolMessage as am, type EmbedResult as an, type EmbedManyResult as ao, type BaseStructuredOutputType as ap, type StructuredOutputType as aq, type StructuredOutputArrayItem as ar, type StructuredOutput as as, type GenerateReturn as at, type StreamReturn as au, type OutputType as av, type DefaultLLMTextOptions as aw, type DefaultLLMTextObjectOptions as ax, type DefaultLLMStreamOptions as ay, type DefaultLLMStreamObjectOptions as az, type MastraAuthConfig as b, type ExecuteFunction as b0, type StepSuccess as b1, type StepFailure as b2, type StepSuspended as b3, type StepResult as b4, type StepsRecord as b5, type DynamicMapping as b6, type PathsToStringProps as b7, type ExtractSchemaType as b8, type ExtractSchemaFromStep as b9, type EnvironmentVariableInfo as bA, type PackageInfo as bB, type RemoteInfo as bC, type MCPServerConfig as bD, type ServerInfo as bE, type ServerDetailInfo as bF, type ToolsetsInput as bG, type DynamicArgument as bH, type AgentGenerateOptions as bI, type AgentStreamOptions as bJ, type VariableReference as ba, type WatchEvent as bb, type ZodPathType as bc, type WorkflowRunState as bd, type MastraLanguageModel as be, type MastraPrimitives as bf, AgentNetwork as bg, MCPServerBase as bh, type VoiceEventType as bi, type VoiceEventMap as bj, type VoiceConfig as bk, MastraVoice as bl, CompositeVoice as bm, DefaultVoice as bn, type AgentNetworkConfig as bo, type ConvertedTool as bp, type MCPServerSSEOptions as bq, type MCPServerHonoSSEOptions as br, type MCPServerHTTPOptions as bs, type Repository as bt, type VersionDetail as bu, type ArgumentInfo as bv, type PositionalArgumentInfo as bw, type NamedArgumentInfo as bx, type SubcommandInfo as by, type CommandInfo as bz, MastraStorage as c, type StorageThreadType as d, type MessageType as e, type StorageGetMessagesArg as f, type WorkflowRun as g, type LegacyWorkflowRun as h, TABLE_WORKFLOW_SNAPSHOT as i, TABLE_EVALS as j, TABLE_MESSAGES as k, TABLE_THREADS as l, TABLE_TRACES as m, TABLE_SCHEMAS as n, type StepResult$1 as o, LegacyStep as p, LegacyWorkflow as q, Agent as r, type WorkflowContext as s, type ToolsInput as t, type StepAction as u, type LegacyWorkflowRunResult as v, type WorkflowOptions as w, type StepExecutionContext as x, type StepVariableType as y, type StepNode as z };
|