@mastra/core 0.7.0 → 0.8.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/dist/agent/index.cjs +2 -2
- package/dist/agent/index.d.cts +3 -1
- package/dist/agent/index.d.ts +3 -1
- package/dist/agent/index.js +1 -1
- package/dist/{base-Cyl73WbV.d.ts → base-B65ZjbJw.d.ts} +100 -29
- package/dist/{base-C0wILuA9.d.cts → base-CYeyHJtc.d.cts} +100 -29
- package/dist/{chunk-ZBKJDQPM.js → chunk-5U7ZB5ID.js} +7 -0
- package/dist/{chunk-43SD5CUE.js → chunk-6IH4PY2A.js} +60 -6
- package/dist/{chunk-SMBKF6K5.js → chunk-APV5PNPE.js} +9 -0
- package/dist/chunk-AZEVFYZU.cjs +4609 -0
- package/dist/{chunk-ASFUEC75.cjs → chunk-BS2HQKYH.cjs} +61 -6
- package/dist/{chunk-YXJQFZOW.cjs → chunk-FKP3IMFA.cjs} +7 -0
- package/dist/{chunk-U7ONOIBO.cjs → chunk-G3GVZCXA.cjs} +9 -0
- package/dist/chunk-HWCOUI5E.js +4582 -0
- package/dist/{chunk-QM6WIIPM.js → chunk-TKOMVZT3.js} +1 -1
- package/dist/{chunk-WESJ2ZY7.cjs → chunk-TKOVKRVO.cjs} +2 -2
- package/dist/eval/index.d.cts +3 -1
- package/dist/eval/index.d.ts +3 -1
- package/dist/index.cjs +53 -42
- package/dist/index.d.cts +7 -5
- package/dist/index.d.ts +7 -5
- package/dist/index.js +6 -6
- package/dist/integration/index.d.cts +3 -1
- package/dist/integration/index.d.ts +3 -1
- package/dist/llm/index.d.cts +3 -1
- package/dist/llm/index.d.ts +3 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.cts +3 -1
- package/dist/mastra/index.d.ts +3 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +6 -2
- package/dist/memory/index.d.cts +3 -1
- package/dist/memory/index.d.ts +3 -1
- package/dist/memory/index.js +1 -1
- package/dist/network/index.cjs +2 -2
- package/dist/network/index.d.cts +3 -1
- package/dist/network/index.d.ts +3 -1
- package/dist/network/index.js +1 -1
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.d.cts +3 -1
- package/dist/relevance/index.d.ts +3 -1
- package/dist/relevance/index.js +1 -1
- package/dist/server/index.cjs +17 -0
- package/dist/server/index.d.cts +37 -0
- package/dist/server/index.d.ts +37 -0
- package/dist/server/index.js +15 -0
- package/dist/storage/index.d.cts +3 -1
- package/dist/storage/index.d.ts +3 -1
- package/dist/storage/libsql/index.d.cts +3 -1
- package/dist/storage/libsql/index.d.ts +3 -1
- package/dist/telemetry/index.d.cts +3 -1
- package/dist/telemetry/index.d.ts +3 -1
- package/dist/tools/index.d.cts +3 -1
- package/dist/tools/index.d.ts +3 -1
- package/dist/utils.d.cts +5 -3
- package/dist/utils.d.ts +5 -3
- package/dist/vector/libsql/index.cjs +3 -3
- package/dist/vector/libsql/index.js +1 -1
- package/dist/voice/index.d.cts +3 -1
- package/dist/voice/index.d.ts +3 -1
- package/dist/workflows/index.cjs +28 -20
- package/dist/workflows/index.d.cts +14 -5
- package/dist/workflows/index.d.ts +14 -5
- package/dist/workflows/index.js +1 -1
- package/package.json +4 -2
- package/dist/chunk-C6BBAS4I.cjs +0 -1715
- package/dist/chunk-GG6TEAMJ.cjs +0 -2289
- package/dist/chunk-R2M5CZ5U.js +0 -2264
- package/dist/chunk-VNQRLYIA.js +0 -1715
package/dist/agent/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkAZEVFYZU_cjs = require('../chunk-AZEVFYZU.cjs');
|
|
4
4
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
Object.defineProperty(exports, "Agent", {
|
|
8
8
|
enumerable: true,
|
|
9
|
-
get: function () { return
|
|
9
|
+
get: function () { return chunkAZEVFYZU_cjs.Agent; }
|
|
10
10
|
});
|
package/dist/agent/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Message as AiMessageType } from 'ai';
|
|
2
2
|
import 'json-schema';
|
|
3
3
|
import 'zod';
|
|
4
|
-
export { A as Agent,
|
|
4
|
+
export { A as Agent, o as AgentConfig, aL as AgentGenerateOptions, aM as AgentStreamOptions, aD as MastraLanguageModel, a as ToolsInput, aK as ToolsetsInput } from '../base-CYeyHJtc.cjs';
|
|
5
5
|
import '../base-ObPJ-w8K.cjs';
|
|
6
6
|
import '../types-CwTG2XyQ.cjs';
|
|
7
7
|
import 'sift';
|
|
@@ -17,3 +17,5 @@ import '@opentelemetry/sdk-trace-base';
|
|
|
17
17
|
import '../tts/index.cjs';
|
|
18
18
|
import '../deployer/index.cjs';
|
|
19
19
|
import '../bundler/index.cjs';
|
|
20
|
+
import 'hono';
|
|
21
|
+
import 'hono-openapi';
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Message as AiMessageType } from 'ai';
|
|
2
2
|
import 'json-schema';
|
|
3
3
|
import 'zod';
|
|
4
|
-
export { A as Agent,
|
|
4
|
+
export { A as Agent, o as AgentConfig, aL as AgentGenerateOptions, aM as AgentStreamOptions, aD as MastraLanguageModel, a as ToolsInput, aK as ToolsetsInput } from '../base-B65ZjbJw.js';
|
|
5
5
|
import '../base-Cmunaaxb.js';
|
|
6
6
|
import '../types-CwTG2XyQ.js';
|
|
7
7
|
import 'sift';
|
|
@@ -17,3 +17,5 @@ import '@opentelemetry/sdk-trace-base';
|
|
|
17
17
|
import '../tts/index.js';
|
|
18
18
|
import '../deployer/index.js';
|
|
19
19
|
import '../bundler/index.js';
|
|
20
|
+
import 'hono';
|
|
21
|
+
import 'hono-openapi';
|
package/dist/agent/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Agent } from '../chunk-
|
|
1
|
+
export { Agent } from '../chunk-HWCOUI5E.js';
|
|
@@ -13,6 +13,8 @@ import EventEmitter from 'node:events';
|
|
|
13
13
|
import { MastraVector } from './vector/index.js';
|
|
14
14
|
import { MastraTTS } from './tts/index.js';
|
|
15
15
|
import { MastraDeployer } from './deployer/index.js';
|
|
16
|
+
import { Handler, MiddlewareHandler } from 'hono';
|
|
17
|
+
import { DescribeRouteOptions } from 'hono-openapi';
|
|
16
18
|
|
|
17
19
|
type VercelTool = Tool$1;
|
|
18
20
|
type CoreTool = {
|
|
@@ -114,6 +116,23 @@ type LLMStreamObjectOptions<T extends ZodSchema | JSONSchema7 | undefined = unde
|
|
|
114
116
|
structuredOutput: JSONSchema7 | z.ZodType<T> | StructuredOutput;
|
|
115
117
|
} & LLMInnerStreamOptions<T> & DefaultLLMStreamObjectOptions;
|
|
116
118
|
|
|
119
|
+
type MemoryProcessorOpts = {
|
|
120
|
+
systemMessage?: string;
|
|
121
|
+
memorySystemMessage?: string;
|
|
122
|
+
newMessages?: CoreMessage$1[];
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Interface for message processors that can filter or transform messages
|
|
126
|
+
* before they're sent to the LLM.
|
|
127
|
+
*/
|
|
128
|
+
declare abstract class MemoryProcessor extends MastraBase {
|
|
129
|
+
/**
|
|
130
|
+
* Process a list of messages and return a filtered or transformed list.
|
|
131
|
+
* @param messages The messages to process
|
|
132
|
+
* @returns The processed messages
|
|
133
|
+
*/
|
|
134
|
+
process(messages: CoreMessage$1[], _opts: MemoryProcessorOpts): CoreMessage$1[];
|
|
135
|
+
}
|
|
117
136
|
/**
|
|
118
137
|
* Abstract Memory class that defines the interface for storing and retrieving
|
|
119
138
|
* conversation threads and messages.
|
|
@@ -123,6 +142,7 @@ declare abstract class MastraMemory extends MastraBase {
|
|
|
123
142
|
storage: MastraStorage;
|
|
124
143
|
vector: MastraVector;
|
|
125
144
|
embedder: EmbeddingModel<string>;
|
|
145
|
+
private processors;
|
|
126
146
|
protected threadConfig: MemoryConfig;
|
|
127
147
|
constructor(config: {
|
|
128
148
|
name: string;
|
|
@@ -149,10 +169,21 @@ declare abstract class MastraMemory extends MastraBase {
|
|
|
149
169
|
indexName: string;
|
|
150
170
|
}>;
|
|
151
171
|
getMergedThreadConfig(config?: MemoryConfig): MemoryConfig;
|
|
152
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Apply all configured message processors to a list of messages.
|
|
174
|
+
* @param messages The messages to process
|
|
175
|
+
* @returns The processed messages
|
|
176
|
+
*/
|
|
177
|
+
private applyProcessors;
|
|
178
|
+
processMessages({ messages, processors, ...opts }: {
|
|
179
|
+
messages: CoreMessage$1[];
|
|
180
|
+
processors?: MemoryProcessor[];
|
|
181
|
+
} & MemoryProcessorOpts): CoreMessage$1[];
|
|
182
|
+
abstract rememberMessages({ threadId, resourceId, vectorMessageSearch, systemMessage, config, }: {
|
|
153
183
|
threadId: string;
|
|
154
184
|
resourceId?: string;
|
|
155
185
|
vectorMessageSearch?: string;
|
|
186
|
+
systemMessage?: CoreMessage$1;
|
|
156
187
|
config?: MemoryConfig;
|
|
157
188
|
}): Promise<{
|
|
158
189
|
threadId: string;
|
|
@@ -229,8 +260,9 @@ declare abstract class MastraMemory extends MastraBase {
|
|
|
229
260
|
* @param toolCallIds - Optional array of tool call ids
|
|
230
261
|
* @returns Promise resolving to the saved message
|
|
231
262
|
*/
|
|
232
|
-
addMessage({ threadId, config, content, role, type, toolNames, toolCallArgs, toolCallIds, }: {
|
|
263
|
+
addMessage({ threadId, resourceId, config, content, role, type, toolNames, toolCallArgs, toolCallIds, }: {
|
|
233
264
|
threadId: string;
|
|
265
|
+
resourceId: string;
|
|
234
266
|
config?: MemoryConfig;
|
|
235
267
|
content: UserContent | AssistantContent;
|
|
236
268
|
role: 'user' | 'assistant';
|
|
@@ -436,8 +468,8 @@ declare class CompositeVoice extends MastraVoice<unknown, unknown, unknown, Tool
|
|
|
436
468
|
type ToolsInput = Record<string, ToolAction<any, any, any> | VercelTool>;
|
|
437
469
|
type ToolsetsInput = Record<string, ToolsInput>;
|
|
438
470
|
type MastraLanguageModel = LanguageModelV1;
|
|
439
|
-
interface AgentConfig<TTools extends ToolsInput = ToolsInput, TMetrics extends Record<string, Metric> = Record<string, Metric>> {
|
|
440
|
-
name:
|
|
471
|
+
interface AgentConfig<TAgentId extends string = string, TTools extends ToolsInput = ToolsInput, TMetrics extends Record<string, Metric> = Record<string, Metric>> {
|
|
472
|
+
name: TAgentId;
|
|
441
473
|
instructions: string;
|
|
442
474
|
model: MastraLanguageModel;
|
|
443
475
|
tools?: TTools;
|
|
@@ -685,9 +717,11 @@ interface WorkflowRunResult<T extends z.ZodObject<any>, TSteps extends Step<stri
|
|
|
685
717
|
[K in keyof StepsRecord<TSteps>]: StepsRecord<TSteps>[K]['outputSchema'] extends undefined ? StepResult<unknown> : StepResult<z.infer<NonNullable<StepsRecord<TSteps>[K]['outputSchema']>>>;
|
|
686
718
|
};
|
|
687
719
|
runId: string;
|
|
720
|
+
timestamp: number;
|
|
688
721
|
activePaths: Map<keyof StepsRecord<TSteps>, {
|
|
689
722
|
status: string;
|
|
690
723
|
suspendPayload?: any;
|
|
724
|
+
stepPath: string[];
|
|
691
725
|
}>;
|
|
692
726
|
}
|
|
693
727
|
interface WorkflowContext<TTrigger extends z.ZodObject<any> = any, TSteps extends Step<string, any, any, any>[] = Step<string, any, any, any>[], TInputData extends Record<string, any> = Record<string, any>> {
|
|
@@ -937,7 +971,7 @@ declare class Machine<TSteps extends Step<any, any, any>[] = any, TTriggerSchema
|
|
|
937
971
|
input?: any;
|
|
938
972
|
snapshot?: Snapshot<any>;
|
|
939
973
|
resumeData?: any;
|
|
940
|
-
}): Promise<Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResultSchema>, 'results' | 'activePaths'>>;
|
|
974
|
+
}): Promise<Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResultSchema>, 'results' | 'activePaths' | 'runId' | 'timestamp'>>;
|
|
941
975
|
private initializeMachine;
|
|
942
976
|
getSnapshot(): xstate.MachineSnapshot<Omit<WorkflowContext<any, Step<string, any, any, any>[], Record<string, any>>, "getStepResult">, {
|
|
943
977
|
type: "RESET_TO_PENDING";
|
|
@@ -1253,6 +1287,7 @@ declare class Machine<TSteps extends Step<any, any, any>[] = any, TTriggerSchema
|
|
|
1253
1287
|
}, xstate.AnyEventObject>;
|
|
1254
1288
|
}) => {
|
|
1255
1289
|
mastra?: MastraUnion | undefined;
|
|
1290
|
+
triggerData: any;
|
|
1256
1291
|
isResume?: {
|
|
1257
1292
|
runId: string;
|
|
1258
1293
|
stepId: string;
|
|
@@ -1281,7 +1316,6 @@ declare class Machine<TSteps extends Step<any, any, any>[] = any, TTriggerSchema
|
|
|
1281
1316
|
output?: any;
|
|
1282
1317
|
};
|
|
1283
1318
|
};
|
|
1284
|
-
triggerData: any;
|
|
1285
1319
|
inputData: Record<string, any>;
|
|
1286
1320
|
attempts: Record<string, number>;
|
|
1287
1321
|
};
|
|
@@ -1294,7 +1328,7 @@ interface WorkflowResultReturn<TResult extends z.ZodObject<any>, T extends z.Zod
|
|
|
1294
1328
|
start: (props?: {
|
|
1295
1329
|
triggerData?: z.infer<T>;
|
|
1296
1330
|
} | undefined) => Promise<WorkflowRunResult<T, TSteps, TResult>>;
|
|
1297
|
-
watch: (onTransition: (state:
|
|
1331
|
+
watch: (onTransition: (state: Pick<WorkflowRunResult<T, TSteps, TResult>, 'results' | 'activePaths' | 'runId'>) => void) => () => void;
|
|
1298
1332
|
resume: (props: {
|
|
1299
1333
|
stepId: string;
|
|
1300
1334
|
context?: Record<string, any>;
|
|
@@ -1318,7 +1352,7 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any>[] = any, TTrig
|
|
|
1318
1352
|
stepGraph: StepGraph;
|
|
1319
1353
|
stepSubscriberGraph: Record<string, StepGraph>;
|
|
1320
1354
|
onFinish?: () => void;
|
|
1321
|
-
onStepTransition?: Set<(state:
|
|
1355
|
+
onStepTransition?: Set<(state: Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, 'results' | 'activePaths' | 'runId' | 'timestamp'>) => void | Promise<void>>;
|
|
1322
1356
|
resultMapping?: Record<string, {
|
|
1323
1357
|
step: StepAction<any, any, any, any>;
|
|
1324
1358
|
path: string;
|
|
@@ -1330,17 +1364,19 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any>[] = any, TTrig
|
|
|
1330
1364
|
setState(state: any): void;
|
|
1331
1365
|
get runId(): string;
|
|
1332
1366
|
get executionSpan(): Span | undefined;
|
|
1333
|
-
watch(onTransition: (state:
|
|
1367
|
+
watch(onTransition: (state: Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, 'results' | 'activePaths' | 'runId' | 'timestamp'>) => void): () => void;
|
|
1334
1368
|
start({ triggerData }?: {
|
|
1335
1369
|
triggerData?: z.infer<TTriggerSchema>;
|
|
1336
1370
|
}): Promise<{
|
|
1337
1371
|
runId: string;
|
|
1372
|
+
timestamp: number;
|
|
1338
1373
|
result?: z.TypeOf<TResult> | undefined;
|
|
1339
1374
|
results: { [K in keyof StepsRecord<TSteps>]: StepsRecord<TSteps>[K]["outputSchema"] extends undefined ? StepResult<unknown> : StepResult<z.TypeOf<NonNullable<StepsRecord<TSteps>[K]["outputSchema"]>>>; };
|
|
1340
1375
|
triggerData?: z.TypeOf<TTriggerSchema> | undefined;
|
|
1341
1376
|
activePaths: Map<TSteps[number]["id"], {
|
|
1342
1377
|
status: string;
|
|
1343
1378
|
suspendPayload?: any;
|
|
1379
|
+
stepPath: string[];
|
|
1344
1380
|
}>;
|
|
1345
1381
|
}>;
|
|
1346
1382
|
private isCompoundDependencyMet;
|
|
@@ -1351,7 +1387,7 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any>[] = any, TTrig
|
|
|
1351
1387
|
resumeData?: any;
|
|
1352
1388
|
}): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, 'runId'>>;
|
|
1353
1389
|
hasSubscribers(stepId: string): boolean;
|
|
1354
|
-
runMachine(parentStepId: string, input: any): Promise<(Pick<WorkflowRunResult<any, any, any>, "results" | "activePaths"> | undefined)[]>;
|
|
1390
|
+
runMachine(parentStepId: string, input: any): Promise<(Pick<WorkflowRunResult<any, any, any>, "runId" | "timestamp" | "results" | "activePaths"> | undefined)[]>;
|
|
1355
1391
|
suspend(stepId: string, machine: Machine<TSteps, TTriggerSchema>): Promise<void>;
|
|
1356
1392
|
/**
|
|
1357
1393
|
* Persists the workflow state to the database
|
|
@@ -1369,6 +1405,7 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any>[] = any, TTrig
|
|
|
1369
1405
|
}): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
|
|
1370
1406
|
}
|
|
1371
1407
|
|
|
1408
|
+
type WorkflowBuilder<T extends Workflow<any, any>> = Pick<T, 'step' | 'then' | 'after' | 'while' | 'until' | 'if' | 'else' | 'afterEvent' | 'commit'>;
|
|
1372
1409
|
declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, any, any>[], TStepId extends string = string, TTriggerSchema extends z.ZodObject<any> = any, TResultSchema extends z.ZodObject<any> = any> extends MastraBase {
|
|
1373
1410
|
#private;
|
|
1374
1411
|
name: TStepId;
|
|
@@ -1387,18 +1424,21 @@ declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, an
|
|
|
1387
1424
|
* @param logger - Optional logger instance
|
|
1388
1425
|
*/
|
|
1389
1426
|
constructor({ name, triggerSchema, result, retryConfig, mastra, events, }: WorkflowOptions<TStepId, TSteps, TTriggerSchema, TResultSchema>);
|
|
1390
|
-
step<TWorkflow extends Workflow<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>): this
|
|
1391
|
-
step<
|
|
1427
|
+
step<TWorkflow extends Workflow<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>;
|
|
1428
|
+
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>;
|
|
1429
|
+
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>;
|
|
1392
1430
|
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;
|
|
1393
1431
|
then<TWorkflow extends Workflow<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;
|
|
1432
|
+
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;
|
|
1394
1433
|
private loop;
|
|
1395
|
-
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>['when'], fallbackStep: FallbackStep): this
|
|
1396
|
-
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): this
|
|
1397
|
-
if<TStep extends StepAction<string, any, any, any>>(condition: StepConfig<TStep, any, any, TTriggerSchema>['when'], ifStep?: TStep | Workflow, elseStep?: TStep | Workflow): this
|
|
1398
|
-
else(): this
|
|
1399
|
-
after<TStep extends StepAction<string, any, any, any>>(steps: TStep | TStep[]): Omit<
|
|
1400
|
-
after<TWorkflow extends Workflow<any, any, any, any>>(steps: TWorkflow | TWorkflow[]): Omit<
|
|
1401
|
-
|
|
1434
|
+
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>['when'], fallbackStep: FallbackStep): Pick<WorkflowBuilder<this>, "then" | "commit">;
|
|
1435
|
+
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): Pick<WorkflowBuilder<this>, "then" | "commit">;
|
|
1436
|
+
if<TStep extends StepAction<string, any, any, any>>(condition: StepConfig<TStep, any, any, TTriggerSchema>['when'], ifStep?: TStep | Workflow, elseStep?: TStep | Workflow): this | WorkflowBuilder<this>;
|
|
1437
|
+
else(): WorkflowBuilder<this>;
|
|
1438
|
+
after<TStep extends StepAction<string, any, any, any>>(steps: TStep | TStep[]): Omit<WorkflowBuilder<this>, 'then' | 'after'>;
|
|
1439
|
+
after<TWorkflow extends Workflow<any, any, any, any>>(steps: TWorkflow | TWorkflow[]): Omit<WorkflowBuilder<this>, 'then' | 'after'>;
|
|
1440
|
+
after<TAgent extends Agent<any, any, any>>(steps: TAgent | TAgent[]): Omit<WorkflowBuilder<this>, 'then' | 'after'>;
|
|
1441
|
+
afterEvent(eventName: string): WorkflowBuilder<this>;
|
|
1402
1442
|
/**
|
|
1403
1443
|
* Executes the workflow with the given trigger data
|
|
1404
1444
|
* @param triggerData - Initial data to start the workflow with
|
|
@@ -1433,7 +1473,7 @@ declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, an
|
|
|
1433
1473
|
stepId: string;
|
|
1434
1474
|
context?: Record<string, any>;
|
|
1435
1475
|
}): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, any>, "runId"> | undefined>;
|
|
1436
|
-
watch(onTransition: (state:
|
|
1476
|
+
watch(onTransition: (state: Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResultSchema>, 'results' | 'activePaths' | 'runId' | 'timestamp'>) => void): () => void;
|
|
1437
1477
|
resumeWithEvent(runId: string, eventName: string, data: any): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, any>, "runId"> | undefined>;
|
|
1438
1478
|
__registerMastra(mastra: Mastra): void;
|
|
1439
1479
|
__registerPrimitives(p: MastraPrimitives): void;
|
|
@@ -1536,8 +1576,8 @@ declare class AgentNetwork extends MastraBase {
|
|
|
1536
1576
|
getAgentInteractionSummary(): string;
|
|
1537
1577
|
executeAgent(agentId: string, input: CoreMessage$1[], includeHistory?: boolean): Promise<string>;
|
|
1538
1578
|
getInstructions(): string;
|
|
1539
|
-
getRoutingAgent(): Agent<ToolsInput, Record<string, Metric>>;
|
|
1540
|
-
getAgents(): Agent<ToolsInput, Record<string, Metric>>[];
|
|
1579
|
+
getRoutingAgent(): Agent<string, ToolsInput, Record<string, Metric>>;
|
|
1580
|
+
getAgents(): Agent<string, ToolsInput, Record<string, Metric>>[];
|
|
1541
1581
|
generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], args?: AgentGenerateOptions<Z> & {
|
|
1542
1582
|
output?: never;
|
|
1543
1583
|
experimental_output?: never;
|
|
@@ -1563,6 +1603,23 @@ declare class AgentNetwork extends MastraBase {
|
|
|
1563
1603
|
__registerMastra(p: Mastra): void;
|
|
1564
1604
|
}
|
|
1565
1605
|
|
|
1606
|
+
type Methods = 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
1607
|
+
type ApiRoute = {
|
|
1608
|
+
path: string;
|
|
1609
|
+
method: Methods;
|
|
1610
|
+
handler: Handler;
|
|
1611
|
+
middleware?: MiddlewareHandler | MiddlewareHandler[];
|
|
1612
|
+
openapi?: DescribeRouteOptions;
|
|
1613
|
+
};
|
|
1614
|
+
type Middleware = MiddlewareHandler | {
|
|
1615
|
+
path: string;
|
|
1616
|
+
handler: MiddlewareHandler;
|
|
1617
|
+
};
|
|
1618
|
+
type ServerConfig = {
|
|
1619
|
+
apiRoutes?: ApiRoute[];
|
|
1620
|
+
middleware?: Middleware | Middleware[];
|
|
1621
|
+
};
|
|
1622
|
+
|
|
1566
1623
|
interface Config<TAgents extends Record<string, Agent<any>> = Record<string, Agent<any>>, 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 Logger = Logger, TNetworks extends Record<string, AgentNetwork> = Record<string, AgentNetwork>> {
|
|
1567
1624
|
agents?: TAgents;
|
|
1568
1625
|
networks?: TNetworks;
|
|
@@ -1573,9 +1630,11 @@ interface Config<TAgents extends Record<string, Agent<any>> = Record<string, Age
|
|
|
1573
1630
|
tts?: TTTS;
|
|
1574
1631
|
telemetry?: OtelConfig;
|
|
1575
1632
|
deployer?: MastraDeployer;
|
|
1633
|
+
server?: ServerConfig;
|
|
1576
1634
|
/**
|
|
1577
1635
|
* Server middleware functions to be applied to API routes
|
|
1578
1636
|
* Each middleware can specify a path pattern (defaults to '/api/*')
|
|
1637
|
+
* @deprecated use server.middleware instead
|
|
1579
1638
|
*/
|
|
1580
1639
|
serverMiddleware?: Array<{
|
|
1581
1640
|
handler: (c: any, next: () => Promise<void>) => Promise<Response | void>;
|
|
@@ -1624,6 +1683,7 @@ declare class Mastra<TAgents extends Record<string, Agent<any>> = Record<string,
|
|
|
1624
1683
|
path: string;
|
|
1625
1684
|
}[];
|
|
1626
1685
|
getNetworks(): AgentNetwork[];
|
|
1686
|
+
getServer(): ServerConfig | undefined;
|
|
1627
1687
|
/**
|
|
1628
1688
|
* Get a specific network by ID
|
|
1629
1689
|
* @param networkId - The ID of the network to retrieve
|
|
@@ -1683,9 +1743,9 @@ declare class MastraLLMBase extends MastraBase {
|
|
|
1683
1743
|
stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options?: LLMStreamOptions<Z>): Promise<StreamReturn<Z>>;
|
|
1684
1744
|
}
|
|
1685
1745
|
|
|
1686
|
-
declare class Agent<TTools extends ToolsInput = ToolsInput, TMetrics extends Record<string, Metric> = Record<string, Metric>> extends MastraBase {
|
|
1746
|
+
declare class Agent<TAgentId extends string = string, TTools extends ToolsInput = ToolsInput, TMetrics extends Record<string, Metric> = Record<string, Metric>> extends MastraBase {
|
|
1687
1747
|
#private;
|
|
1688
|
-
name:
|
|
1748
|
+
name: TAgentId;
|
|
1689
1749
|
readonly llm: MastraLLMBase;
|
|
1690
1750
|
instructions: string;
|
|
1691
1751
|
readonly model?: MastraLanguageModel;
|
|
@@ -1694,7 +1754,7 @@ declare class Agent<TTools extends ToolsInput = ToolsInput, TMetrics extends Rec
|
|
|
1694
1754
|
metrics: TMetrics;
|
|
1695
1755
|
evals: TMetrics;
|
|
1696
1756
|
voice?: CompositeVoice;
|
|
1697
|
-
constructor(config: AgentConfig<TTools, TMetrics>);
|
|
1757
|
+
constructor(config: AgentConfig<TAgentId, TTools, TMetrics>);
|
|
1698
1758
|
hasOwnMemory(): boolean;
|
|
1699
1759
|
getMemory(): MastraMemory | undefined;
|
|
1700
1760
|
__updateInstructions(newInstructions: string): void;
|
|
@@ -1710,11 +1770,12 @@ declare class Agent<TTools extends ToolsInput = ToolsInput, TMetrics extends Rec
|
|
|
1710
1770
|
}): Promise<string>;
|
|
1711
1771
|
getMostRecentUserMessage(messages: Array<CoreMessage$1>): CoreUserMessage$1 | undefined;
|
|
1712
1772
|
genTitle(userMessage: CoreUserMessage$1 | undefined): Promise<string>;
|
|
1713
|
-
fetchMemory({ threadId, memoryConfig, resourceId, userMessages, runId, }: {
|
|
1773
|
+
fetchMemory({ threadId, memoryConfig, resourceId, userMessages, systemMessage, runId, }: {
|
|
1714
1774
|
resourceId: string;
|
|
1715
1775
|
threadId: string;
|
|
1716
1776
|
memoryConfig?: MemoryConfig;
|
|
1717
1777
|
userMessages: CoreMessage$1[];
|
|
1778
|
+
systemMessage: CoreMessage$1;
|
|
1718
1779
|
time?: Date;
|
|
1719
1780
|
keyword?: string;
|
|
1720
1781
|
runId?: string;
|
|
@@ -1736,12 +1797,13 @@ declare class Agent<TTools extends ToolsInput = ToolsInput, TMetrics extends Rec
|
|
|
1736
1797
|
resourceId?: string;
|
|
1737
1798
|
runId?: string;
|
|
1738
1799
|
}): Record<string, CoreTool>;
|
|
1739
|
-
preExecute({ resourceId, runId, threadId, memoryConfig, messages, }: {
|
|
1800
|
+
preExecute({ resourceId, runId, threadId, memoryConfig, messages, systemMessage, }: {
|
|
1740
1801
|
runId?: string;
|
|
1741
1802
|
threadId: string;
|
|
1742
1803
|
memoryConfig?: MemoryConfig;
|
|
1743
1804
|
messages: CoreMessage$1[];
|
|
1744
1805
|
resourceId: string;
|
|
1806
|
+
systemMessage: CoreMessage$1;
|
|
1745
1807
|
}): Promise<{
|
|
1746
1808
|
coreMessages: CoreMessage$1[];
|
|
1747
1809
|
threadIdToUse: string;
|
|
@@ -1760,10 +1822,12 @@ declare class Agent<TTools extends ToolsInput = ToolsInput, TMetrics extends Rec
|
|
|
1760
1822
|
messageObjects: CoreMessage$1[];
|
|
1761
1823
|
convertedTools: Record<string, CoreTool> | undefined;
|
|
1762
1824
|
threadId: string;
|
|
1825
|
+
thread: StorageThreadType | null | undefined;
|
|
1763
1826
|
}>;
|
|
1764
|
-
after: ({ result, threadId, memoryConfig, outputText, runId, }: {
|
|
1827
|
+
after: ({ result, thread: threadAfter, threadId, memoryConfig, outputText, runId, }: {
|
|
1765
1828
|
runId: string;
|
|
1766
1829
|
result: Record<string, any>;
|
|
1830
|
+
thread: StorageThreadType | null | undefined;
|
|
1767
1831
|
threadId: string;
|
|
1768
1832
|
memoryConfig: MemoryConfig | undefined;
|
|
1769
1833
|
outputText: string;
|
|
@@ -1827,6 +1891,11 @@ declare class Agent<TTools extends ToolsInput = ToolsInput, TMetrics extends Rec
|
|
|
1827
1891
|
getSpeakers(): Promise<{
|
|
1828
1892
|
voiceId: string;
|
|
1829
1893
|
}[]>;
|
|
1894
|
+
toStep(): Step<TAgentId, z.ZodObject<{
|
|
1895
|
+
prompt: z.ZodString;
|
|
1896
|
+
}>, z.ZodObject<{
|
|
1897
|
+
text: z.ZodString;
|
|
1898
|
+
}>, any>;
|
|
1830
1899
|
}
|
|
1831
1900
|
|
|
1832
1901
|
interface StorageColumn {
|
|
@@ -1885,6 +1954,7 @@ type MessageType = {
|
|
|
1885
1954
|
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
1886
1955
|
createdAt: Date;
|
|
1887
1956
|
threadId: string;
|
|
1957
|
+
resourceId: string;
|
|
1888
1958
|
toolCallIds?: string[];
|
|
1889
1959
|
toolCallArgs?: Record<string, unknown>[];
|
|
1890
1960
|
toolNames?: string[];
|
|
@@ -1925,6 +1995,7 @@ type SharedMemoryConfig = {
|
|
|
1925
1995
|
options?: MemoryConfig;
|
|
1926
1996
|
vector?: MastraVector;
|
|
1927
1997
|
embedder?: EmbeddingModel<string>;
|
|
1998
|
+
processors?: MemoryProcessor[];
|
|
1928
1999
|
};
|
|
1929
2000
|
|
|
1930
2001
|
declare abstract class MastraStorage extends MastraBase {
|
|
@@ -2035,4 +2106,4 @@ declare abstract class MastraStorage extends MastraBase {
|
|
|
2035
2106
|
__getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
2036
2107
|
}
|
|
2037
2108
|
|
|
2038
|
-
export {
|
|
2109
|
+
export { type MemoryConfig as $, Agent as A, type BaseStructuredOutputType as B, type CoreTool as C, type StructuredOutputType as D, type EvalRow as E, type StructuredOutputArrayItem as F, type StructuredOutput as G, type GenerateReturn as H, type StreamReturn as I, type DefaultLLMTextOptions as J, type DefaultLLMTextObjectOptions as K, type LanguageModel as L, Mastra as M, type DefaultLLMStreamOptions as N, type OutputType as O, type DefaultLLMStreamObjectOptions as P, type LLMTextOptions as Q, type LLMTextObjectOptions as R, Step as S, type ToolAction as T, type LLMStreamOptions as U, type VercelTool as V, Workflow as W, type LLMInnerStreamOptions as X, type LLMStreamObjectOptions as Y, type Config as Z, type MessageResponse as _, type ToolsInput as a, type SharedMemoryConfig as a0, type MemoryProcessorOpts as a1, MemoryProcessor as a2, createTool as a3, type StepAction as a4, type StepVariableType as a5, type StepNode as a6, type StepGraph as a7, type RetryConfig as a8, type VariableReference as a9, type WorkflowRunState as aA, type WorkflowResumeResult as aB, createStep as aC, type MastraLanguageModel as aD, type VoiceEventType as aE, type VoiceEventMap as aF, type VoiceConfig as aG, MastraVoice as aH, CompositeVoice as aI, type AgentNetworkConfig as aJ, type ToolsetsInput as aK, type AgentGenerateOptions as aL, type AgentStreamOptions as aM, TABLE_WORKFLOW_SNAPSHOT as aN, TABLE_EVALS as aO, TABLE_MESSAGES as aP, TABLE_THREADS as aQ, TABLE_TRACES as aR, type BaseCondition as aa, type ActionContext as ab, WhenConditionReturnValue as ac, type StepDef as ad, type StepCondition as ae, type StepConfig as af, type StepResult as ag, type StepsRecord as ah, type WorkflowRunResult as ai, type WorkflowLogMessage as aj, type WorkflowEvent as ak, type ResolverFunctionInput as al, type ResolverFunctionOutput as am, type SubscriberFunctionOutput as an, type DependencyCheckOutput as ao, type StepResolverOutput as ap, type WorkflowActors as aq, type WorkflowActionParams as ar, type WorkflowActions as as, type WorkflowState as at, type StepId as au, type ExtractSchemaFromStep as av, type ExtractStepResult as aw, type StepInputType as ax, type ExtractSchemaType as ay, type PathsToStringProps as az, type MastraPrimitives as b, MastraMemory as c, type StepExecutionContext as d, type WorkflowContext as e, AgentNetwork as f, type Methods as g, type ApiRoute as h, MastraStorage as i, type TABLE_NAMES as j, type StorageColumn as k, type StorageThreadType as l, type MessageType as m, type StorageGetMessagesArg as n, type AgentConfig as o, type ToolExecutionContext as p, Tool as q, type WorkflowOptions as r, type WorkflowRow as s, type CoreMessage as t, type CoreSystemMessage as u, type CoreAssistantMessage as v, type CoreUserMessage as w, type CoreToolMessage as x, type EmbedResult as y, type EmbedManyResult as z };
|