@mastra/core 0.0.0-storage-20250225005900
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/LICENSE +21 -0
- package/README.md +180 -0
- package/dist/agent/index.d.ts +15 -0
- package/dist/agent/index.js +1 -0
- package/dist/base-CHNzbTDj.d.ts +894 -0
- package/dist/base-eWkcLLSb.d.ts +139 -0
- package/dist/base.d.ts +6 -0
- package/dist/base.js +1 -0
- package/dist/bundler/index.d.ts +28 -0
- package/dist/bundler/index.js +1 -0
- package/dist/chunk-4IIE6KIC.js +10 -0
- package/dist/chunk-4ZNSY7J7.js +215 -0
- package/dist/chunk-4ZRHVG25.js +402 -0
- package/dist/chunk-5275WBGX.js +318 -0
- package/dist/chunk-6RDA4JYW.js +49 -0
- package/dist/chunk-BB4KXGBU.js +83 -0
- package/dist/chunk-C6A6W6XS.js +77 -0
- package/dist/chunk-FEBWYMJQ.js +416 -0
- package/dist/chunk-KP5SHTKA.js +145 -0
- package/dist/chunk-N7KZVQDK.js +61 -0
- package/dist/chunk-NDQR6IPC.js +37 -0
- package/dist/chunk-NUDAZEOG.js +35 -0
- package/dist/chunk-ORM3OCHX.js +1367 -0
- package/dist/chunk-PNZK456O.js +88 -0
- package/dist/chunk-QXPUH6PK.js +620 -0
- package/dist/chunk-RG66XEJT.js +8 -0
- package/dist/chunk-SIFBBGY6.js +190 -0
- package/dist/chunk-TCMOYQ74.js +1204 -0
- package/dist/chunk-WIBGG4X6.js +173 -0
- package/dist/chunk-YKDBP67T.js +346 -0
- package/dist/chunk-YUOADWSP.js +22 -0
- package/dist/chunk-Z735LDV7.js +10 -0
- package/dist/chunk-ZDWFBE5L.js +1 -0
- package/dist/chunk-ZINPRHAN.js +22 -0
- package/dist/deployer/index.d.ts +19 -0
- package/dist/deployer/index.js +1 -0
- package/dist/eval/index.d.ts +28 -0
- package/dist/eval/index.js +1 -0
- package/dist/filter/index.d.ts +90 -0
- package/dist/filter/index.js +1 -0
- package/dist/hooks/index.d.ts +33 -0
- package/dist/hooks/index.js +1 -0
- package/dist/index-C5uPdbs4.d.ts +90 -0
- package/dist/index.d.ts +98 -0
- package/dist/index.js +119 -0
- package/dist/integration/index.d.ts +53 -0
- package/dist/integration/index.js +1 -0
- package/dist/llm/index.d.ts +15 -0
- package/dist/llm/index.js +1 -0
- package/dist/logger/index.d.ts +3 -0
- package/dist/logger/index.js +1 -0
- package/dist/mastra/index.d.ts +68 -0
- package/dist/mastra/index.js +1 -0
- package/dist/memory/index.d.ts +15 -0
- package/dist/memory/index.js +1 -0
- package/dist/relevance/index.d.ts +21 -0
- package/dist/relevance/index.js +1 -0
- package/dist/storage/index.d.ts +15 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage/libsql/index.d.ts +81 -0
- package/dist/storage/libsql/index.js +1 -0
- package/dist/telemetry/index.d.ts +51 -0
- package/dist/telemetry/index.js +1 -0
- package/dist/telemetry/otel-vendor.d.ts +7 -0
- package/dist/telemetry/otel-vendor.js +7 -0
- package/dist/tools/index.d.ts +29 -0
- package/dist/tools/index.js +1 -0
- package/dist/tts/index.d.ts +28 -0
- package/dist/tts/index.js +1 -0
- package/dist/types-m9RryK9a.d.ts +14 -0
- package/dist/utils.d.ts +26 -0
- package/dist/utils.js +1 -0
- package/dist/vector/index.d.ts +29 -0
- package/dist/vector/index.js +1 -0
- package/dist/vector/libsql/index.d.ts +29 -0
- package/dist/vector/libsql/index.js +1 -0
- package/dist/voice/index.d.ts +67 -0
- package/dist/voice/index.js +76 -0
- package/dist/workflow-CddifUps.d.ts +92 -0
- package/dist/workflows/index.d.ts +31 -0
- package/dist/workflows/index.js +1 -0
- package/package.json +134 -0
|
@@ -0,0 +1,894 @@
|
|
|
1
|
+
import * as ai from 'ai';
|
|
2
|
+
import { EmbeddingModel, CoreMessage as CoreMessage$1, Message, UserContent, AssistantContent, LanguageModelV1, GenerateTextResult, GenerateObjectResult, StreamTextResult, StreamObjectResult, CoreSystemMessage as CoreSystemMessage$1, CoreAssistantMessage as CoreAssistantMessage$1, CoreUserMessage as CoreUserMessage$1, CoreToolMessage as CoreToolMessage$1, EmbedResult as EmbedResult$1, EmbedManyResult as EmbedManyResult$1, LanguageModel as LanguageModel$1, DeepPartial, ToolContent } from 'ai';
|
|
3
|
+
import { M as MastraBase, T as Telemetry } from './base-eWkcLLSb.js';
|
|
4
|
+
import { a as Metric, M as MetricResult, T as TestInfo } from './types-m9RryK9a.js';
|
|
5
|
+
import { Query } from 'sift';
|
|
6
|
+
import { z, ZodSchema } from 'zod';
|
|
7
|
+
import { JSONSchema7 } from 'json-schema';
|
|
8
|
+
import { MastraVector } from './vector/index.js';
|
|
9
|
+
import { CompositeVoice } from './voice/index.js';
|
|
10
|
+
import { B as BaseLogMessage, R as RegisteredLogger, L as Logger, d as Run } from './index-C5uPdbs4.js';
|
|
11
|
+
import { MastraTTS } from './tts/index.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Abstract Memory class that defines the interface for storing and retrieving
|
|
15
|
+
* conversation threads and messages.
|
|
16
|
+
*/
|
|
17
|
+
declare abstract class MastraMemory extends MastraBase {
|
|
18
|
+
MAX_CONTEXT_TOKENS?: number;
|
|
19
|
+
storage: MastraStorage;
|
|
20
|
+
vector: MastraVector;
|
|
21
|
+
embedder: EmbeddingModel<string>;
|
|
22
|
+
protected threadConfig: MemoryConfig;
|
|
23
|
+
constructor(config: {
|
|
24
|
+
name: string;
|
|
25
|
+
} & SharedMemoryConfig);
|
|
26
|
+
setStorage(storage: MastraStorage): void;
|
|
27
|
+
setVector(vector: MastraVector): void;
|
|
28
|
+
setEmbedder(embedder: EmbeddingModel<string>): void;
|
|
29
|
+
/**
|
|
30
|
+
* Get a system message to inject into the conversation.
|
|
31
|
+
* This will be called before each conversation turn.
|
|
32
|
+
* Implementations can override this to inject custom system messages.
|
|
33
|
+
*/
|
|
34
|
+
getSystemMessage(_input: {
|
|
35
|
+
threadId: string;
|
|
36
|
+
memoryConfig?: MemoryConfig;
|
|
37
|
+
}): Promise<string | null>;
|
|
38
|
+
protected createEmbeddingIndex(): Promise<{
|
|
39
|
+
indexName: string;
|
|
40
|
+
}>;
|
|
41
|
+
protected getMergedThreadConfig(config?: MemoryConfig): MemoryConfig;
|
|
42
|
+
abstract rememberMessages({ threadId, vectorMessageSearch, config, }: {
|
|
43
|
+
threadId: string;
|
|
44
|
+
vectorMessageSearch?: string;
|
|
45
|
+
config?: MemoryConfig;
|
|
46
|
+
}): Promise<{
|
|
47
|
+
messages: CoreMessage$1[];
|
|
48
|
+
uiMessages: Message[];
|
|
49
|
+
}>;
|
|
50
|
+
estimateTokens(text: string): number;
|
|
51
|
+
protected parseMessages(messages: MessageType[]): CoreMessage$1[];
|
|
52
|
+
protected convertToUIMessages(messages: MessageType[]): Message[];
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves a specific thread by its ID
|
|
55
|
+
* @param threadId - The unique identifier of the thread
|
|
56
|
+
* @returns Promise resolving to the thread or null if not found
|
|
57
|
+
*/
|
|
58
|
+
abstract getThreadById({ threadId }: {
|
|
59
|
+
threadId: string;
|
|
60
|
+
}): Promise<StorageThreadType | null>;
|
|
61
|
+
abstract getThreadsByResourceId({ resourceId }: {
|
|
62
|
+
resourceId: string;
|
|
63
|
+
}): Promise<StorageThreadType[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Saves or updates a thread
|
|
66
|
+
* @param thread - The thread data to save
|
|
67
|
+
* @returns Promise resolving to the saved thread
|
|
68
|
+
*/
|
|
69
|
+
abstract saveThread({ thread, memoryConfig, }: {
|
|
70
|
+
thread: StorageThreadType;
|
|
71
|
+
memoryConfig?: MemoryConfig;
|
|
72
|
+
}): Promise<StorageThreadType>;
|
|
73
|
+
/**
|
|
74
|
+
* Saves messages to a thread
|
|
75
|
+
* @param messages - Array of messages to save
|
|
76
|
+
* @returns Promise resolving to the saved messages
|
|
77
|
+
*/
|
|
78
|
+
abstract saveMessages({ messages, memoryConfig, }: {
|
|
79
|
+
messages: MessageType[];
|
|
80
|
+
memoryConfig: MemoryConfig | undefined;
|
|
81
|
+
}): Promise<MessageType[]>;
|
|
82
|
+
/**
|
|
83
|
+
* Retrieves all messages for a specific thread
|
|
84
|
+
* @param threadId - The unique identifier of the thread
|
|
85
|
+
* @returns Promise resolving to array of messages and uiMessages
|
|
86
|
+
*/
|
|
87
|
+
abstract query({ threadId, selectBy, }: StorageGetMessagesArg): Promise<{
|
|
88
|
+
messages: CoreMessage$1[];
|
|
89
|
+
uiMessages: Message[];
|
|
90
|
+
}>;
|
|
91
|
+
/**
|
|
92
|
+
* Helper method to create a new thread
|
|
93
|
+
* @param title - Optional title for the thread
|
|
94
|
+
* @param metadata - Optional metadata for the thread
|
|
95
|
+
* @returns Promise resolving to the created thread
|
|
96
|
+
*/
|
|
97
|
+
createThread({ threadId, resourceId, title, metadata, memoryConfig, }: {
|
|
98
|
+
resourceId: string;
|
|
99
|
+
threadId?: string;
|
|
100
|
+
title?: string;
|
|
101
|
+
metadata?: Record<string, unknown>;
|
|
102
|
+
memoryConfig?: MemoryConfig;
|
|
103
|
+
}): Promise<StorageThreadType>;
|
|
104
|
+
/**
|
|
105
|
+
* Helper method to delete a thread
|
|
106
|
+
* @param threadId - the id of the thread to delete
|
|
107
|
+
*/
|
|
108
|
+
abstract deleteThread(threadId: string): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Helper method to add a single message to a thread
|
|
111
|
+
* @param threadId - The thread to add the message to
|
|
112
|
+
* @param content - The message content
|
|
113
|
+
* @param role - The role of the message sender
|
|
114
|
+
* @param type - The type of the message
|
|
115
|
+
* @param toolNames - Optional array of tool names that were called
|
|
116
|
+
* @param toolCallArgs - Optional array of tool call arguments
|
|
117
|
+
* @param toolCallIds - Optional array of tool call ids
|
|
118
|
+
* @returns Promise resolving to the saved message
|
|
119
|
+
*/
|
|
120
|
+
addMessage({ threadId, config, content, role, type, toolNames, toolCallArgs, toolCallIds, }: {
|
|
121
|
+
threadId: string;
|
|
122
|
+
config?: MemoryConfig;
|
|
123
|
+
content: UserContent | AssistantContent;
|
|
124
|
+
role: 'user' | 'assistant';
|
|
125
|
+
type: 'text' | 'tool-call' | 'tool-result';
|
|
126
|
+
toolNames?: string[];
|
|
127
|
+
toolCallArgs?: Record<string, unknown>[];
|
|
128
|
+
toolCallIds?: string[];
|
|
129
|
+
}): Promise<MessageType>;
|
|
130
|
+
/**
|
|
131
|
+
* Generates a unique identifier
|
|
132
|
+
* @returns A unique string ID
|
|
133
|
+
*/
|
|
134
|
+
generateId(): string;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
interface WorkflowOptions<TTriggerSchema extends z.ZodType<any> = any> {
|
|
138
|
+
name: string;
|
|
139
|
+
triggerSchema?: TTriggerSchema;
|
|
140
|
+
retryConfig?: RetryConfig;
|
|
141
|
+
mastra?: MastraPrimitives;
|
|
142
|
+
}
|
|
143
|
+
interface StepExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefined, TContext extends WorkflowContext = WorkflowContext> extends IExecutionContext<TSchemaIn, TContext> {
|
|
144
|
+
runId: string;
|
|
145
|
+
}
|
|
146
|
+
interface StepAction<TId extends string, TSchemaIn extends z.ZodSchema | undefined, TSchemaOut extends z.ZodSchema | undefined, TContext extends StepExecutionContext<TSchemaIn>> extends IAction<TId, TSchemaIn, TSchemaOut, TContext> {
|
|
147
|
+
retryConfig?: RetryConfig;
|
|
148
|
+
}
|
|
149
|
+
interface SimpleConditionalType {
|
|
150
|
+
[key: `${string}.${string}`]: string | Query<any>;
|
|
151
|
+
}
|
|
152
|
+
type StepVariableType<TId extends string, TSchemaIn extends z.ZodSchema | undefined, TSchemaOut extends z.ZodSchema | undefined, TContext extends IExecutionContext<TSchemaIn>> = IAction<TId, TSchemaIn, TSchemaOut, TContext> | 'trigger' | {
|
|
153
|
+
id: string;
|
|
154
|
+
};
|
|
155
|
+
type StepNode = {
|
|
156
|
+
step: IAction<any, any, any, any>;
|
|
157
|
+
config: StepDef<any, any, any, any>[any];
|
|
158
|
+
};
|
|
159
|
+
type StepGraph = {
|
|
160
|
+
initial: StepNode[];
|
|
161
|
+
[key: string]: StepNode[];
|
|
162
|
+
};
|
|
163
|
+
type RetryConfig = {
|
|
164
|
+
attempts?: number;
|
|
165
|
+
delay?: number;
|
|
166
|
+
};
|
|
167
|
+
type VariableReference<TStep extends StepVariableType<any, any, any, any>, TTriggerSchema extends z.ZodType<any>> = TStep extends IAction<any, any, any, any> ? {
|
|
168
|
+
step: TStep;
|
|
169
|
+
path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TStep, 'outputSchema'>>> | '' | '.';
|
|
170
|
+
} : TStep extends 'trigger' ? {
|
|
171
|
+
step: 'trigger';
|
|
172
|
+
path: PathsToStringProps<ExtractSchemaType<TTriggerSchema>> | '.' | '';
|
|
173
|
+
} : {
|
|
174
|
+
step: {
|
|
175
|
+
id: string;
|
|
176
|
+
};
|
|
177
|
+
path: string;
|
|
178
|
+
};
|
|
179
|
+
interface BaseCondition<TStep extends StepVariableType<any, any, any, any>, TTriggerSchema extends z.ZodType<any>> {
|
|
180
|
+
ref: TStep extends IAction<any, any, any, any> ? {
|
|
181
|
+
step: TStep;
|
|
182
|
+
path: PathsToStringProps<ExtractSchemaType<ExtractSchemaFromStep<TStep, 'outputSchema'>>> | '' | '.' | 'status';
|
|
183
|
+
} : TStep extends 'trigger' ? {
|
|
184
|
+
step: 'trigger';
|
|
185
|
+
path: PathsToStringProps<ExtractSchemaType<TTriggerSchema>> | '.' | '';
|
|
186
|
+
} : {
|
|
187
|
+
step: {
|
|
188
|
+
id: string;
|
|
189
|
+
};
|
|
190
|
+
path: string;
|
|
191
|
+
};
|
|
192
|
+
query: Query<any>;
|
|
193
|
+
}
|
|
194
|
+
type ActionContext<TSchemaIn extends z.ZodType<any>> = IExecutionContext<z.infer<TSchemaIn>, WorkflowContext>;
|
|
195
|
+
type StepDef<TStepId extends TSteps[number]['id'], TSteps extends IAction<any, any, any, any>[], TSchemaIn extends z.ZodType<any>, TSchemaOut extends z.ZodType<any>> = Record<TStepId, {
|
|
196
|
+
snapshotOnTimeout?: boolean;
|
|
197
|
+
when?: Condition<any, any> | ((args: {
|
|
198
|
+
context: WorkflowContext;
|
|
199
|
+
}) => Promise<boolean>);
|
|
200
|
+
data: TSchemaIn;
|
|
201
|
+
handler: (args: ActionContext<TSchemaIn>) => Promise<z.infer<TSchemaOut>>;
|
|
202
|
+
}>;
|
|
203
|
+
type StepCondition<TStep extends StepVariableType<any, any, any, any>, TTriggerSchema extends z.ZodType<any>> = BaseCondition<TStep, TTriggerSchema> | SimpleConditionalType | {
|
|
204
|
+
and: StepCondition<TStep, TTriggerSchema>[];
|
|
205
|
+
} | {
|
|
206
|
+
or: StepCondition<TStep, TTriggerSchema>[];
|
|
207
|
+
};
|
|
208
|
+
type Condition<TStep extends StepVariableType<any, any, any, any>, TTriggerSchema extends z.ZodType<any>> = BaseCondition<TStep, TTriggerSchema> | SimpleConditionalType | {
|
|
209
|
+
and: Condition<TStep, TTriggerSchema>[];
|
|
210
|
+
} | {
|
|
211
|
+
or: Condition<TStep, TTriggerSchema>[];
|
|
212
|
+
};
|
|
213
|
+
interface StepConfig<TStep extends IAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>, TTriggerSchema extends z.ZodType<any>> {
|
|
214
|
+
snapshotOnTimeout?: boolean;
|
|
215
|
+
when?: Condition<CondStep, TTriggerSchema> | ((args: {
|
|
216
|
+
context: WorkflowContext<TTriggerSchema>;
|
|
217
|
+
}) => Promise<boolean>);
|
|
218
|
+
variables?: StepInputType<TStep, 'inputSchema'> extends never ? Record<string, VariableReference<VarStep, TTriggerSchema>> : {
|
|
219
|
+
[K in keyof StepInputType<TStep, 'inputSchema'>]?: VariableReference<VarStep, TTriggerSchema>;
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
type StepSuccess<T> = {
|
|
223
|
+
status: 'success';
|
|
224
|
+
output: T;
|
|
225
|
+
};
|
|
226
|
+
type StepSuspended = {
|
|
227
|
+
status: 'suspended';
|
|
228
|
+
};
|
|
229
|
+
type StepWaiting = {
|
|
230
|
+
status: 'waiting';
|
|
231
|
+
};
|
|
232
|
+
type StepFailure = {
|
|
233
|
+
status: 'failed';
|
|
234
|
+
error: string;
|
|
235
|
+
};
|
|
236
|
+
type StepResult<T> = StepSuccess<T> | StepFailure | StepSuspended | StepWaiting;
|
|
237
|
+
interface WorkflowContext<TTrigger extends z.ZodType<any> = any> {
|
|
238
|
+
steps: Record<string, StepResult<any>>;
|
|
239
|
+
triggerData: z.infer<TTrigger>;
|
|
240
|
+
attempts: Record<string, number>;
|
|
241
|
+
getStepPayload: <T = unknown>(stepId: string) => T | undefined;
|
|
242
|
+
}
|
|
243
|
+
interface WorkflowLogMessage extends BaseLogMessage {
|
|
244
|
+
type: typeof RegisteredLogger.WORKFLOW;
|
|
245
|
+
workflowName: string;
|
|
246
|
+
stepId?: StepId;
|
|
247
|
+
data?: unknown;
|
|
248
|
+
runId?: string;
|
|
249
|
+
}
|
|
250
|
+
type WorkflowEvent = {
|
|
251
|
+
type: 'RESET_TO_PENDING';
|
|
252
|
+
stepId: string;
|
|
253
|
+
} | {
|
|
254
|
+
type: 'CONDITIONS_MET';
|
|
255
|
+
stepId: string;
|
|
256
|
+
} | {
|
|
257
|
+
type: 'CONDITION_FAILED';
|
|
258
|
+
stepId: string;
|
|
259
|
+
error: string;
|
|
260
|
+
} | {
|
|
261
|
+
type: 'SUSPENDED';
|
|
262
|
+
stepId: string;
|
|
263
|
+
} | {
|
|
264
|
+
type: 'WAITING';
|
|
265
|
+
stepId: string;
|
|
266
|
+
} | {
|
|
267
|
+
type: `xstate.error.actor.${string}`;
|
|
268
|
+
error: Error;
|
|
269
|
+
} | {
|
|
270
|
+
type: `xstate.done.actor.${string}`;
|
|
271
|
+
output: ResolverFunctionOutput;
|
|
272
|
+
};
|
|
273
|
+
type ResolverFunctionInput = {
|
|
274
|
+
stepNode: StepNode;
|
|
275
|
+
context: WorkflowContext;
|
|
276
|
+
};
|
|
277
|
+
type ResolverFunctionOutput = {
|
|
278
|
+
stepId: StepId;
|
|
279
|
+
result: unknown;
|
|
280
|
+
};
|
|
281
|
+
type SubscriberFunctionOutput = {
|
|
282
|
+
stepId: StepId;
|
|
283
|
+
result: unknown;
|
|
284
|
+
};
|
|
285
|
+
type DependencyCheckOutput = {
|
|
286
|
+
type: 'CONDITIONS_MET';
|
|
287
|
+
} | {
|
|
288
|
+
type: 'CONDITION_FAILED';
|
|
289
|
+
error: string;
|
|
290
|
+
} | {
|
|
291
|
+
type: 'SUSPENDED';
|
|
292
|
+
} | {
|
|
293
|
+
type: 'WAITING';
|
|
294
|
+
};
|
|
295
|
+
type WorkflowActors = {
|
|
296
|
+
resolverFunction: {
|
|
297
|
+
input: ResolverFunctionInput;
|
|
298
|
+
output: ResolverFunctionOutput;
|
|
299
|
+
};
|
|
300
|
+
conditionCheck: {
|
|
301
|
+
input: {
|
|
302
|
+
context: WorkflowContext;
|
|
303
|
+
stepId: string;
|
|
304
|
+
};
|
|
305
|
+
output: DependencyCheckOutput;
|
|
306
|
+
};
|
|
307
|
+
spawnSubscriberFunction: {
|
|
308
|
+
input: {
|
|
309
|
+
context: WorkflowContext;
|
|
310
|
+
stepId: string;
|
|
311
|
+
};
|
|
312
|
+
output: SubscriberFunctionOutput;
|
|
313
|
+
};
|
|
314
|
+
};
|
|
315
|
+
type WorkflowActionParams = {
|
|
316
|
+
stepId: string;
|
|
317
|
+
};
|
|
318
|
+
type WorkflowActions = {
|
|
319
|
+
type: 'updateStepResult' | 'setStepError' | 'notifyStepCompletion' | 'decrementAttemptCount';
|
|
320
|
+
params: WorkflowActionParams;
|
|
321
|
+
};
|
|
322
|
+
type WorkflowState = {
|
|
323
|
+
[key: string]: {
|
|
324
|
+
initial: 'pending';
|
|
325
|
+
states: {
|
|
326
|
+
pending: {
|
|
327
|
+
invoke: {
|
|
328
|
+
src: 'conditionCheck';
|
|
329
|
+
input: ({ context }: {
|
|
330
|
+
context: WorkflowContext;
|
|
331
|
+
}) => {
|
|
332
|
+
context: WorkflowContext;
|
|
333
|
+
stepId: string;
|
|
334
|
+
};
|
|
335
|
+
onDone: [
|
|
336
|
+
{
|
|
337
|
+
guard: (_: any, event: {
|
|
338
|
+
output: DependencyCheckOutput;
|
|
339
|
+
}) => boolean;
|
|
340
|
+
target: 'executing';
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
guard: (_: any, event: {
|
|
344
|
+
output: DependencyCheckOutput;
|
|
345
|
+
}) => boolean;
|
|
346
|
+
target: 'waiting';
|
|
347
|
+
}
|
|
348
|
+
];
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
waiting: {
|
|
352
|
+
after: {
|
|
353
|
+
CHECK_INTERVAL: {
|
|
354
|
+
target: 'pending';
|
|
355
|
+
};
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
executing: {
|
|
359
|
+
invoke: {
|
|
360
|
+
src: 'resolverFunction';
|
|
361
|
+
input: ({ context }: {
|
|
362
|
+
context: WorkflowContext;
|
|
363
|
+
}) => ResolverFunctionInput;
|
|
364
|
+
onDone: {
|
|
365
|
+
target: 'completed';
|
|
366
|
+
actions: ['updateStepResult'];
|
|
367
|
+
};
|
|
368
|
+
onError: {
|
|
369
|
+
target: 'failed';
|
|
370
|
+
actions: ['setStepError'];
|
|
371
|
+
};
|
|
372
|
+
};
|
|
373
|
+
};
|
|
374
|
+
completed: {
|
|
375
|
+
type: 'final';
|
|
376
|
+
entry: ['notifyStepCompletion'];
|
|
377
|
+
};
|
|
378
|
+
failed: {
|
|
379
|
+
type: 'final';
|
|
380
|
+
entry: ['notifyStepCompletion'];
|
|
381
|
+
};
|
|
382
|
+
};
|
|
383
|
+
};
|
|
384
|
+
};
|
|
385
|
+
declare const StepIdBrand: unique symbol;
|
|
386
|
+
type StepId = string & {
|
|
387
|
+
readonly [StepIdBrand]: typeof StepIdBrand;
|
|
388
|
+
};
|
|
389
|
+
type ExtractSchemaFromStep<TStep extends IAction<any, any, any, any>, TKey extends 'inputSchema' | 'outputSchema'> = TStep[TKey];
|
|
390
|
+
type ExtractStepResult<T> = T extends (data: any) => Promise<infer R> ? R : never;
|
|
391
|
+
type StepInputType<TStep extends IAction<any, any, any, any>, TKey extends 'inputSchema' | 'outputSchema'> = ExtractSchemaFromStep<TStep, TKey> extends infer Schema ? Schema extends z.ZodType<any> ? z.infer<Schema> : never : never;
|
|
392
|
+
type ExtractSchemaType<T extends z.ZodSchema> = T extends z.ZodSchema<infer V> ? V : never;
|
|
393
|
+
type PathsToStringProps<T> = T extends object ? {
|
|
394
|
+
[K in keyof T]: T[K] extends object ? K extends string ? K | `${K}.${PathsToStringProps<T[K]>}` : never : K extends string ? K : never;
|
|
395
|
+
}[keyof T] : never;
|
|
396
|
+
interface WorkflowRunState {
|
|
397
|
+
value: Record<string, string>;
|
|
398
|
+
context: {
|
|
399
|
+
steps: Record<string, {
|
|
400
|
+
status: 'success' | 'failed' | 'suspended' | 'waiting';
|
|
401
|
+
payload?: any;
|
|
402
|
+
error?: string;
|
|
403
|
+
}>;
|
|
404
|
+
triggerData: Record<string, any>;
|
|
405
|
+
attempts: Record<string, number>;
|
|
406
|
+
};
|
|
407
|
+
activePaths: Array<{
|
|
408
|
+
stepPath: string[];
|
|
409
|
+
stepId: string;
|
|
410
|
+
status: string;
|
|
411
|
+
}>;
|
|
412
|
+
runId: string;
|
|
413
|
+
timestamp: number;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
type MastraPrimitives = {
|
|
417
|
+
logger?: Logger;
|
|
418
|
+
telemetry?: Telemetry;
|
|
419
|
+
storage?: MastraStorage;
|
|
420
|
+
agents?: Record<string, Agent>;
|
|
421
|
+
tts?: Record<string, MastraTTS>;
|
|
422
|
+
vectors?: Record<string, MastraVector>;
|
|
423
|
+
memory?: MastraMemory;
|
|
424
|
+
};
|
|
425
|
+
interface IExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefined, TContext extends WorkflowContext = WorkflowContext> {
|
|
426
|
+
context: TSchemaIn extends z.ZodSchema ? z.infer<TSchemaIn> & TContext : TContext;
|
|
427
|
+
runId?: string;
|
|
428
|
+
mastra?: MastraPrimitives;
|
|
429
|
+
suspend: () => Promise<void>;
|
|
430
|
+
}
|
|
431
|
+
interface IAction<TId extends string, TSchemaIn extends z.ZodSchema | undefined, TSchemaOut extends z.ZodSchema | undefined, TContext extends IExecutionContext<TSchemaIn>> {
|
|
432
|
+
id: TId;
|
|
433
|
+
description?: string;
|
|
434
|
+
inputSchema?: TSchemaIn;
|
|
435
|
+
outputSchema?: TSchemaOut;
|
|
436
|
+
mastra?: MastraPrimitives;
|
|
437
|
+
payload?: TSchemaIn extends z.ZodSchema ? Partial<z.infer<TSchemaIn>> : unknown;
|
|
438
|
+
execute: (context: TContext) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
|
|
439
|
+
[key: string]: any;
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
type CoreTool = {
|
|
443
|
+
description?: string;
|
|
444
|
+
parameters: ZodSchema;
|
|
445
|
+
execute: (params: any) => Promise<any>;
|
|
446
|
+
};
|
|
447
|
+
interface ToolExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefined, TContext extends WorkflowContext = WorkflowContext> extends IExecutionContext<TSchemaIn, TContext> {
|
|
448
|
+
}
|
|
449
|
+
interface ToolAction<TId extends string, TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>> extends IAction<TId, TSchemaIn, TSchemaOut, TContext> {
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
type ToolsetsInput = Record<string, Record<string, ToolAction<any, any, any, any>>>;
|
|
453
|
+
type ToolsInput = Record<string, ToolAction<any, any, any, any>>;
|
|
454
|
+
interface AgentConfig<TTools extends Record<string, ToolAction<any, any, any, any>> = Record<string, ToolAction<any, any, any, any>>, TMetrics extends Record<string, Metric> = Record<string, Metric>> {
|
|
455
|
+
name: string;
|
|
456
|
+
instructions: string;
|
|
457
|
+
model: LanguageModelV1;
|
|
458
|
+
tools?: TTools;
|
|
459
|
+
mastra?: MastraPrimitives;
|
|
460
|
+
/** @deprecated This property is deprecated. Use evals instead to add evaluation metrics. */
|
|
461
|
+
metrics?: TMetrics;
|
|
462
|
+
evals?: TMetrics;
|
|
463
|
+
memory?: MastraMemory;
|
|
464
|
+
voice?: CompositeVoice;
|
|
465
|
+
}
|
|
466
|
+
interface AgentGenerateOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> {
|
|
467
|
+
toolsets?: ToolsetsInput;
|
|
468
|
+
resourceId?: string;
|
|
469
|
+
context?: CoreMessage[];
|
|
470
|
+
threadId?: string;
|
|
471
|
+
memoryOptions?: MemoryConfig;
|
|
472
|
+
runId?: string;
|
|
473
|
+
onStepFinish?: (step: string) => void;
|
|
474
|
+
maxSteps?: number;
|
|
475
|
+
output?: OutputType | Z;
|
|
476
|
+
temperature?: number;
|
|
477
|
+
toolChoice?: 'auto' | 'required';
|
|
478
|
+
}
|
|
479
|
+
interface AgentStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> {
|
|
480
|
+
toolsets?: ToolsetsInput;
|
|
481
|
+
resourceId?: string;
|
|
482
|
+
context?: CoreMessage[];
|
|
483
|
+
threadId?: string;
|
|
484
|
+
memoryOptions?: MemoryConfig;
|
|
485
|
+
runId?: string;
|
|
486
|
+
onFinish?: (result: string) => unknown;
|
|
487
|
+
onStepFinish?: (step: string) => unknown;
|
|
488
|
+
maxSteps?: number;
|
|
489
|
+
output?: OutputType | Z;
|
|
490
|
+
temperature?: number;
|
|
491
|
+
toolChoice?: 'auto' | 'required';
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
type LanguageModel = LanguageModelV1;
|
|
495
|
+
type CoreMessage = CoreMessage$1;
|
|
496
|
+
type CoreSystemMessage = CoreSystemMessage$1;
|
|
497
|
+
type CoreAssistantMessage = CoreAssistantMessage$1;
|
|
498
|
+
type CoreUserMessage = CoreUserMessage$1;
|
|
499
|
+
type CoreToolMessage = CoreToolMessage$1;
|
|
500
|
+
type EmbedResult<T> = EmbedResult$1<T>;
|
|
501
|
+
type EmbedManyResult<T> = EmbedManyResult$1<T>;
|
|
502
|
+
type BaseStructuredOutputType = 'string' | 'number' | 'boolean' | 'date';
|
|
503
|
+
type StructuredOutputType = 'array' | 'string' | 'number' | 'object' | 'boolean' | 'date';
|
|
504
|
+
type StructuredOutputArrayItem = {
|
|
505
|
+
type: BaseStructuredOutputType;
|
|
506
|
+
} | {
|
|
507
|
+
type: 'object';
|
|
508
|
+
items: StructuredOutput;
|
|
509
|
+
};
|
|
510
|
+
type StructuredOutput = {
|
|
511
|
+
[key: string]: {
|
|
512
|
+
type: BaseStructuredOutputType;
|
|
513
|
+
} | {
|
|
514
|
+
type: 'object';
|
|
515
|
+
items: StructuredOutput;
|
|
516
|
+
} | {
|
|
517
|
+
type: 'array';
|
|
518
|
+
items: StructuredOutputArrayItem;
|
|
519
|
+
};
|
|
520
|
+
};
|
|
521
|
+
type GenerateReturn<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = Z extends undefined ? GenerateTextResult<any, any> : GenerateObjectResult<any>;
|
|
522
|
+
type StreamReturn<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = Z extends undefined ? StreamTextResult<any, any> : StreamObjectResult<any, any, any>;
|
|
523
|
+
type OutputType = 'text' | StructuredOutput;
|
|
524
|
+
type LLMStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
525
|
+
runId?: string;
|
|
526
|
+
onFinish?: (result: string) => Promise<void> | void;
|
|
527
|
+
onStepFinish?: (step: string) => void;
|
|
528
|
+
maxSteps?: number;
|
|
529
|
+
tools?: ToolsInput;
|
|
530
|
+
convertedTools?: Record<string, CoreTool>;
|
|
531
|
+
output?: OutputType | Z;
|
|
532
|
+
temperature?: number;
|
|
533
|
+
};
|
|
534
|
+
type LLMTextOptions = {
|
|
535
|
+
tools?: ToolsInput;
|
|
536
|
+
convertedTools?: Record<string, CoreTool>;
|
|
537
|
+
messages: CoreMessage[];
|
|
538
|
+
onStepFinish?: (step: string) => void;
|
|
539
|
+
toolChoice?: 'auto' | 'required';
|
|
540
|
+
maxSteps?: number;
|
|
541
|
+
temperature?: number;
|
|
542
|
+
} & Run;
|
|
543
|
+
type LLMTextObjectOptions<T> = LLMTextOptions & {
|
|
544
|
+
structuredOutput: JSONSchema7 | z.ZodType<T> | StructuredOutput;
|
|
545
|
+
};
|
|
546
|
+
type LLMInnerStreamOptions = {
|
|
547
|
+
tools?: ToolsInput;
|
|
548
|
+
convertedTools?: Record<string, CoreTool>;
|
|
549
|
+
messages: CoreMessage[];
|
|
550
|
+
onStepFinish?: (step: string) => unknown;
|
|
551
|
+
onFinish?: (result: string) => unknown;
|
|
552
|
+
maxSteps?: number;
|
|
553
|
+
temperature?: number;
|
|
554
|
+
toolChoice?: 'auto' | 'required';
|
|
555
|
+
} & Run;
|
|
556
|
+
type LLMStreamObjectOptions<T> = LLMInnerStreamOptions & {
|
|
557
|
+
structuredOutput: JSONSchema7 | z.ZodType<T> | StructuredOutput;
|
|
558
|
+
};
|
|
559
|
+
|
|
560
|
+
declare class MastraLLMBase extends MastraBase {
|
|
561
|
+
#private;
|
|
562
|
+
constructor({ name, model }: {
|
|
563
|
+
name: string;
|
|
564
|
+
model: LanguageModel$1;
|
|
565
|
+
});
|
|
566
|
+
getProvider(): string;
|
|
567
|
+
getModelId(): string;
|
|
568
|
+
getModel(): ai.LanguageModelV1;
|
|
569
|
+
convertToMessages(messages: string | string[] | CoreMessage$1[]): CoreMessage$1[];
|
|
570
|
+
__registerPrimitives(p: MastraPrimitives): void;
|
|
571
|
+
__text(input: LLMTextOptions): Promise<GenerateTextResult<any, any>>;
|
|
572
|
+
__textObject<T>(input: LLMTextObjectOptions<T>): Promise<GenerateObjectResult<T>>;
|
|
573
|
+
generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options?: LLMStreamOptions<Z>): Promise<GenerateReturn<Z>>;
|
|
574
|
+
__stream(input: LLMInnerStreamOptions): Promise<StreamTextResult<any, any>>;
|
|
575
|
+
__streamObject<T>(input: LLMStreamObjectOptions<T>): Promise<StreamObjectResult<DeepPartial<T>, T, never>>;
|
|
576
|
+
stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options?: LLMStreamOptions<Z>): Promise<StreamReturn<Z>>;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
declare class Agent<TTools extends Record<string, ToolAction<any, any, any, any>> = Record<string, ToolAction<any, any, any, any>>, TMetrics extends Record<string, Metric> = Record<string, Metric>> extends MastraBase {
|
|
580
|
+
#private;
|
|
581
|
+
name: string;
|
|
582
|
+
readonly llm: MastraLLMBase;
|
|
583
|
+
instructions: string;
|
|
584
|
+
readonly model?: LanguageModelV1;
|
|
585
|
+
tools: TTools;
|
|
586
|
+
/** @deprecated This property is deprecated. Use evals instead. */
|
|
587
|
+
metrics: TMetrics;
|
|
588
|
+
evals: TMetrics;
|
|
589
|
+
voice?: CompositeVoice;
|
|
590
|
+
constructor(config: AgentConfig<TTools, TMetrics>);
|
|
591
|
+
hasOwnMemory(): boolean;
|
|
592
|
+
getMemory(): MastraMemory | undefined;
|
|
593
|
+
__updateInstructions(newInstructions: string): void;
|
|
594
|
+
__registerPrimitives(p: MastraPrimitives): void;
|
|
595
|
+
/**
|
|
596
|
+
* Set the concrete tools for the agent
|
|
597
|
+
* @param tools
|
|
598
|
+
*/
|
|
599
|
+
__setTools(tools: TTools): void;
|
|
600
|
+
generateTitleFromUserMessage({ message }: {
|
|
601
|
+
message: CoreUserMessage$1;
|
|
602
|
+
}): Promise<string>;
|
|
603
|
+
getMostRecentUserMessage(messages: Array<CoreMessage$1>): CoreUserMessage$1 | undefined;
|
|
604
|
+
genTitle(userMessage: CoreUserMessage$1 | undefined): Promise<string>;
|
|
605
|
+
saveMemory({ threadId, memoryConfig, resourceId, userMessages, runId, }: {
|
|
606
|
+
resourceId: string;
|
|
607
|
+
threadId?: string;
|
|
608
|
+
memoryConfig?: MemoryConfig;
|
|
609
|
+
userMessages: CoreMessage$1[];
|
|
610
|
+
time?: Date;
|
|
611
|
+
keyword?: string;
|
|
612
|
+
runId?: string;
|
|
613
|
+
}): Promise<{
|
|
614
|
+
threadId: string;
|
|
615
|
+
messages: NonNullable<CoreMessage$1 | null>[];
|
|
616
|
+
}>;
|
|
617
|
+
saveResponse({ result, threadId, resourceId, runId, memoryConfig, }: {
|
|
618
|
+
runId: string;
|
|
619
|
+
resourceId: string;
|
|
620
|
+
result: Record<string, any>;
|
|
621
|
+
threadId: string;
|
|
622
|
+
memoryConfig: MemoryConfig | undefined;
|
|
623
|
+
}): Promise<void>;
|
|
624
|
+
sanitizeResponseMessages(messages: Array<CoreMessage$1>): Array<CoreMessage$1>;
|
|
625
|
+
convertTools({ toolsets, runId, }: {
|
|
626
|
+
toolsets?: ToolsetsInput;
|
|
627
|
+
threadId?: string;
|
|
628
|
+
runId?: string;
|
|
629
|
+
}): Record<string, CoreTool>;
|
|
630
|
+
preExecute({ resourceId, runId, threadId, memoryConfig, messages, }: {
|
|
631
|
+
runId?: string;
|
|
632
|
+
threadId?: string;
|
|
633
|
+
memoryConfig?: MemoryConfig;
|
|
634
|
+
messages: CoreMessage$1[];
|
|
635
|
+
resourceId: string;
|
|
636
|
+
}): Promise<{
|
|
637
|
+
coreMessages: CoreMessage$1[];
|
|
638
|
+
threadIdToUse: string;
|
|
639
|
+
}>;
|
|
640
|
+
__primitive({ messages, context, threadId, memoryConfig, resourceId, runId, toolsets, }: {
|
|
641
|
+
toolsets?: ToolsetsInput;
|
|
642
|
+
resourceId?: string;
|
|
643
|
+
threadId?: string;
|
|
644
|
+
memoryConfig?: MemoryConfig;
|
|
645
|
+
context?: CoreMessage$1[];
|
|
646
|
+
runId?: string;
|
|
647
|
+
messages: CoreMessage$1[];
|
|
648
|
+
}): {
|
|
649
|
+
before: () => Promise<{
|
|
650
|
+
messageObjects: CoreMessage$1[];
|
|
651
|
+
convertedTools: Record<string, CoreTool> | undefined;
|
|
652
|
+
threadId: string;
|
|
653
|
+
}>;
|
|
654
|
+
after: ({ result, threadId, memoryConfig, outputText, runId, }: {
|
|
655
|
+
runId: string;
|
|
656
|
+
result: Record<string, any>;
|
|
657
|
+
threadId: string;
|
|
658
|
+
memoryConfig: MemoryConfig | undefined;
|
|
659
|
+
outputText: string;
|
|
660
|
+
}) => Promise<void>;
|
|
661
|
+
};
|
|
662
|
+
generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], { context, threadId: threadIdInFn, memoryOptions, resourceId, maxSteps, onStepFinish, runId, toolsets, output, temperature, toolChoice, }?: AgentGenerateOptions<Z>): Promise<GenerateReturn<Z>>;
|
|
663
|
+
stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], { context, threadId: threadIdInFn, memoryOptions, resourceId, maxSteps, onFinish, onStepFinish, runId, toolsets, output, temperature, toolChoice, }?: AgentStreamOptions<Z>): Promise<StreamReturn<Z>>;
|
|
664
|
+
/**
|
|
665
|
+
* Convert text to speech using the configured voice provider
|
|
666
|
+
* @param input Text or text stream to convert to speech
|
|
667
|
+
* @param options Speech options including speaker and provider-specific options
|
|
668
|
+
* @returns Audio stream
|
|
669
|
+
*/
|
|
670
|
+
speak(input: string | NodeJS.ReadableStream, options?: {
|
|
671
|
+
speaker?: string;
|
|
672
|
+
[key: string]: any;
|
|
673
|
+
}): Promise<NodeJS.ReadableStream>;
|
|
674
|
+
/**
|
|
675
|
+
* Convert speech to text using the configured voice provider
|
|
676
|
+
* @param audioStream Audio stream to transcribe
|
|
677
|
+
* @param options Provider-specific transcription options
|
|
678
|
+
* @returns Text or text stream
|
|
679
|
+
*/
|
|
680
|
+
listen(audioStream: NodeJS.ReadableStream, options?: {
|
|
681
|
+
[key: string]: any;
|
|
682
|
+
}): Promise<string | NodeJS.ReadableStream>;
|
|
683
|
+
/**
|
|
684
|
+
* Get a list of available speakers from the configured voice provider
|
|
685
|
+
* @throws {Error} If no voice provider is configured
|
|
686
|
+
* @returns {Promise<Array<{voiceId: string}>>} List of available speakers
|
|
687
|
+
*/
|
|
688
|
+
getSpeakers(): Promise<{
|
|
689
|
+
[key: string]: any;
|
|
690
|
+
voiceId: string;
|
|
691
|
+
}[]>;
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
interface StorageColumn {
|
|
695
|
+
type: 'text' | 'timestamp' | 'uuid' | 'jsonb' | 'integer' | 'bigint';
|
|
696
|
+
primaryKey?: boolean;
|
|
697
|
+
nullable?: boolean;
|
|
698
|
+
references?: {
|
|
699
|
+
table: string;
|
|
700
|
+
column: string;
|
|
701
|
+
};
|
|
702
|
+
}
|
|
703
|
+
interface WorkflowRow {
|
|
704
|
+
workflow_name: string;
|
|
705
|
+
run_id: string;
|
|
706
|
+
snapshot: WorkflowRunState;
|
|
707
|
+
created_at: Date;
|
|
708
|
+
updated_at: Date;
|
|
709
|
+
}
|
|
710
|
+
type StorageGetMessagesArg = {
|
|
711
|
+
threadId: string;
|
|
712
|
+
selectBy?: {
|
|
713
|
+
vectorSearchString?: string;
|
|
714
|
+
last?: number | false;
|
|
715
|
+
include?: {
|
|
716
|
+
id: string;
|
|
717
|
+
withPreviousMessages?: number;
|
|
718
|
+
withNextMessages?: number;
|
|
719
|
+
}[];
|
|
720
|
+
};
|
|
721
|
+
threadConfig?: MemoryConfig;
|
|
722
|
+
};
|
|
723
|
+
type EvalRow = {
|
|
724
|
+
input: string;
|
|
725
|
+
output: string;
|
|
726
|
+
result: MetricResult;
|
|
727
|
+
agentName: string;
|
|
728
|
+
createdAt: string;
|
|
729
|
+
metricName: string;
|
|
730
|
+
instructions: string;
|
|
731
|
+
runId: string;
|
|
732
|
+
globalRunId: string;
|
|
733
|
+
testInfo?: TestInfo;
|
|
734
|
+
};
|
|
735
|
+
|
|
736
|
+
declare const TABLE_WORKFLOW_SNAPSHOT = "mastra_workflow_snapshot";
|
|
737
|
+
declare const TABLE_EVALS = "mastra_evals";
|
|
738
|
+
declare const TABLE_MESSAGES = "mastra_messages";
|
|
739
|
+
declare const TABLE_THREADS = "mastra_threads";
|
|
740
|
+
declare const TABLE_TRACES = "mastra_traces";
|
|
741
|
+
type TABLE_NAMES = typeof TABLE_WORKFLOW_SNAPSHOT | typeof TABLE_EVALS | typeof TABLE_MESSAGES | typeof TABLE_THREADS | typeof TABLE_TRACES;
|
|
742
|
+
|
|
743
|
+
type MessageType = {
|
|
744
|
+
id: string;
|
|
745
|
+
content: UserContent | AssistantContent | ToolContent;
|
|
746
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
747
|
+
createdAt: Date;
|
|
748
|
+
threadId: string;
|
|
749
|
+
toolCallIds?: string[];
|
|
750
|
+
toolCallArgs?: Record<string, unknown>[];
|
|
751
|
+
toolNames?: string[];
|
|
752
|
+
type: 'text' | 'tool-call' | 'tool-result';
|
|
753
|
+
};
|
|
754
|
+
type StorageThreadType = {
|
|
755
|
+
id: string;
|
|
756
|
+
title?: string;
|
|
757
|
+
resourceId: string;
|
|
758
|
+
createdAt: Date;
|
|
759
|
+
updatedAt: Date;
|
|
760
|
+
metadata?: Record<string, unknown>;
|
|
761
|
+
};
|
|
762
|
+
type MessageResponse<T extends 'raw' | 'core_message'> = {
|
|
763
|
+
raw: MessageType[];
|
|
764
|
+
core_message: CoreMessage$1[];
|
|
765
|
+
}[T];
|
|
766
|
+
type MemoryConfig = {
|
|
767
|
+
lastMessages?: number | false;
|
|
768
|
+
semanticRecall?: boolean | {
|
|
769
|
+
topK: number;
|
|
770
|
+
messageRange: number | {
|
|
771
|
+
before: number;
|
|
772
|
+
after: number;
|
|
773
|
+
};
|
|
774
|
+
};
|
|
775
|
+
workingMemory?: {
|
|
776
|
+
enabled: boolean;
|
|
777
|
+
template?: string;
|
|
778
|
+
};
|
|
779
|
+
};
|
|
780
|
+
type SharedMemoryConfig = {
|
|
781
|
+
storage?: MastraStorage;
|
|
782
|
+
options?: MemoryConfig;
|
|
783
|
+
vector?: MastraVector;
|
|
784
|
+
embedder?: EmbeddingModel<string>;
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
declare abstract class MastraStorage extends MastraBase {
|
|
788
|
+
/** @deprecated import from { TABLE_WORKFLOW_SNAPSHOT } '@mastra/core/storage' instead */
|
|
789
|
+
static readonly TABLE_WORKFLOW_SNAPSHOT = "mastra_workflow_snapshot";
|
|
790
|
+
/** @deprecated import from { TABLE_EVALS } '@mastra/core/storage' instead */
|
|
791
|
+
static readonly TABLE_EVALS = "mastra_evals";
|
|
792
|
+
/** @deprecated import from { TABLE_MESSAGES } '@mastra/core/storage' instead */
|
|
793
|
+
static readonly TABLE_MESSAGES = "mastra_messages";
|
|
794
|
+
/** @deprecated import from { TABLE_THREADS } '@mastra/core/storage' instead */
|
|
795
|
+
static readonly TABLE_THREADS = "mastra_threads";
|
|
796
|
+
/** @deprecated import { TABLE_TRACES } from '@mastra/core/storage' instead */
|
|
797
|
+
static readonly TABLE_TRACES = "mastra_traces";
|
|
798
|
+
protected hasInitialized: null | Promise<boolean>;
|
|
799
|
+
constructor({ name }: {
|
|
800
|
+
name: string;
|
|
801
|
+
});
|
|
802
|
+
abstract createTable({ tableName }: {
|
|
803
|
+
tableName: TABLE_NAMES;
|
|
804
|
+
schema: Record<string, StorageColumn>;
|
|
805
|
+
}): Promise<void>;
|
|
806
|
+
abstract clearTable({ tableName }: {
|
|
807
|
+
tableName: TABLE_NAMES;
|
|
808
|
+
}): Promise<void>;
|
|
809
|
+
abstract insert({ tableName, record }: {
|
|
810
|
+
tableName: TABLE_NAMES;
|
|
811
|
+
record: Record<string, any>;
|
|
812
|
+
}): Promise<void>;
|
|
813
|
+
abstract batchInsert({ tableName, records, }: {
|
|
814
|
+
tableName: TABLE_NAMES;
|
|
815
|
+
records: Record<string, any>[];
|
|
816
|
+
}): Promise<void>;
|
|
817
|
+
__batchInsert({ tableName, records, }: {
|
|
818
|
+
tableName: TABLE_NAMES;
|
|
819
|
+
records: Record<string, any>[];
|
|
820
|
+
}): Promise<void>;
|
|
821
|
+
abstract load<R>({ tableName, keys }: {
|
|
822
|
+
tableName: TABLE_NAMES;
|
|
823
|
+
keys: Record<string, string>;
|
|
824
|
+
}): Promise<R | null>;
|
|
825
|
+
abstract getThreadById({ threadId }: {
|
|
826
|
+
threadId: string;
|
|
827
|
+
}): Promise<StorageThreadType | null>;
|
|
828
|
+
__getThreadById({ threadId }: {
|
|
829
|
+
threadId: string;
|
|
830
|
+
}): Promise<StorageThreadType | null>;
|
|
831
|
+
abstract getThreadsByResourceId({ resourceId }: {
|
|
832
|
+
resourceId: string;
|
|
833
|
+
}): Promise<StorageThreadType[]>;
|
|
834
|
+
__getThreadsByResourceId({ resourceId }: {
|
|
835
|
+
resourceId: string;
|
|
836
|
+
}): Promise<StorageThreadType[]>;
|
|
837
|
+
abstract saveThread({ thread }: {
|
|
838
|
+
thread: StorageThreadType;
|
|
839
|
+
}): Promise<StorageThreadType>;
|
|
840
|
+
__saveThread({ thread }: {
|
|
841
|
+
thread: StorageThreadType;
|
|
842
|
+
}): Promise<StorageThreadType>;
|
|
843
|
+
abstract updateThread({ id, title, metadata, }: {
|
|
844
|
+
id: string;
|
|
845
|
+
title: string;
|
|
846
|
+
metadata: Record<string, unknown>;
|
|
847
|
+
}): Promise<StorageThreadType>;
|
|
848
|
+
__updateThread({ id, title, metadata, }: {
|
|
849
|
+
id: string;
|
|
850
|
+
title: string;
|
|
851
|
+
metadata: Record<string, unknown>;
|
|
852
|
+
}): Promise<StorageThreadType>;
|
|
853
|
+
abstract deleteThread({ threadId }: {
|
|
854
|
+
threadId: string;
|
|
855
|
+
}): Promise<void>;
|
|
856
|
+
__deleteThread({ threadId }: {
|
|
857
|
+
threadId: string;
|
|
858
|
+
}): Promise<void>;
|
|
859
|
+
abstract getMessages({ threadId, selectBy, threadConfig }: StorageGetMessagesArg): Promise<MessageType[]>;
|
|
860
|
+
__getMessages({ threadId, selectBy, threadConfig }: StorageGetMessagesArg): Promise<MessageType[]>;
|
|
861
|
+
abstract saveMessages({ messages }: {
|
|
862
|
+
messages: MessageType[];
|
|
863
|
+
}): Promise<MessageType[]>;
|
|
864
|
+
__saveMessages({ messages }: {
|
|
865
|
+
messages: MessageType[];
|
|
866
|
+
}): Promise<MessageType[]>;
|
|
867
|
+
abstract getTraces({ name, scope, page, perPage, attributes, }: {
|
|
868
|
+
name?: string;
|
|
869
|
+
scope?: string;
|
|
870
|
+
page: number;
|
|
871
|
+
perPage: number;
|
|
872
|
+
attributes?: Record<string, string>;
|
|
873
|
+
}): Promise<any[]>;
|
|
874
|
+
__getTraces({ scope, page, perPage, attributes, }: {
|
|
875
|
+
scope?: string;
|
|
876
|
+
page: number;
|
|
877
|
+
perPage: number;
|
|
878
|
+
attributes?: Record<string, string>;
|
|
879
|
+
}): Promise<any[]>;
|
|
880
|
+
init(): Promise<void>;
|
|
881
|
+
persistWorkflowSnapshot({ workflowName, runId, snapshot, }: {
|
|
882
|
+
workflowName: string;
|
|
883
|
+
runId: string;
|
|
884
|
+
snapshot: WorkflowRunState;
|
|
885
|
+
}): Promise<void>;
|
|
886
|
+
loadWorkflowSnapshot({ workflowName, runId, }: {
|
|
887
|
+
workflowName: string;
|
|
888
|
+
runId: string;
|
|
889
|
+
}): Promise<WorkflowRunState | null>;
|
|
890
|
+
abstract getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
891
|
+
__getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
export { type StepCondition as $, Agent as A, type BaseStructuredOutputType as B, type CoreMessage as C, type LLMStreamOptions as D, type EvalRow as E, type LLMTextOptions as F, type GenerateReturn as G, type LLMTextObjectOptions as H, type IAction as I, type LLMInnerStreamOptions as J, type LLMStreamObjectOptions as K, type LanguageModel as L, MastraStorage as M, type MessageResponse as N, type OutputType as O, type MemoryConfig as P, type SharedMemoryConfig as Q, type RetryConfig as R, type StorageColumn as S, type TABLE_NAMES as T, type CoreTool as U, type StepNode as V, type WorkflowOptions as W, type VariableReference as X, type BaseCondition as Y, type ActionContext as Z, type StepDef as _, MastraMemory as a, type WorkflowContext as a0, type WorkflowLogMessage as a1, type WorkflowEvent as a2, type ResolverFunctionInput as a3, type ResolverFunctionOutput as a4, type SubscriberFunctionOutput as a5, type DependencyCheckOutput as a6, type WorkflowActors as a7, type WorkflowActionParams as a8, type WorkflowActions as a9, type WorkflowState as aa, type StepId as ab, type ExtractSchemaFromStep as ac, type ExtractStepResult as ad, type StepInputType as ae, type ExtractSchemaType as af, type PathsToStringProps as ag, TABLE_WORKFLOW_SNAPSHOT as ah, TABLE_EVALS as ai, TABLE_MESSAGES as aj, TABLE_THREADS as ak, TABLE_TRACES as al, type StorageThreadType as b, type MessageType as c, type StorageGetMessagesArg as d, type StepExecutionContext as e, type StepAction as f, type MastraPrimitives as g, type StepVariableType as h, type StepConfig as i, type StepResult as j, type WorkflowRunState as k, type StepGraph as l, type ToolAction as m, type AgentConfig as n, type ToolExecutionContext as o, type WorkflowRow as p, type CoreSystemMessage as q, type CoreAssistantMessage as r, type CoreUserMessage as s, type CoreToolMessage as t, type EmbedResult as u, type EmbedManyResult as v, type StructuredOutputType as w, type StructuredOutputArrayItem as x, type StructuredOutput as y, type StreamReturn as z };
|