@mastra/core 0.4.2-alpha.1 → 0.4.2

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.
Files changed (58) hide show
  1. package/dist/agent/index.d.ts +4 -4
  2. package/dist/agent/index.js +1 -1
  3. package/dist/{base-eWkcLLSb.d.ts → base-D90KQ4XI.d.ts} +1 -1
  4. package/dist/{base-HowPMmsb.d.ts → base-hk-xmLC1.d.ts} +8 -6
  5. package/dist/base.d.ts +3 -3
  6. package/dist/base.js +1 -1
  7. package/dist/bundler/index.d.ts +3 -3
  8. package/dist/bundler/index.js +1 -1
  9. package/dist/{chunk-LKOVXFLE.js → chunk-33GSTUNK.js} +4 -4
  10. package/dist/{chunk-Z735LDV7.js → chunk-4YRYBCOZ.js} +1 -1
  11. package/dist/chunk-55NFNRKO.js +10 -0
  12. package/dist/chunk-5XPCMNGW.js +215 -0
  13. package/dist/{chunk-T5B2DATI.js → chunk-7TG2Y45H.js} +8 -8
  14. package/dist/{chunk-HPIB5X7E.js → chunk-KM7PRKJ2.js} +5 -5
  15. package/dist/{chunk-XD7K4XPP.js → chunk-M626YCHO.js} +106 -6
  16. package/dist/{chunk-6RDA4JYW.js → chunk-OZ4XVJ6F.js} +1 -1
  17. package/dist/{chunk-KP5SHTKA.js → chunk-PHMSPCTC.js} +2 -2
  18. package/dist/{chunk-VGVST36A.js → chunk-PL6URKH2.js} +1 -1
  19. package/dist/{chunk-NDQR6IPC.js → chunk-QAAJAHDB.js} +2 -2
  20. package/dist/{chunk-YUOADWSP.js → chunk-SVEAENO7.js} +2 -2
  21. package/dist/{chunk-4ZRHVG25.js → chunk-W5HVJX45.js} +5 -5
  22. package/dist/{chunk-TCMOYQ74.js → chunk-XVS6QFTX.js} +20 -4
  23. package/dist/{chunk-JIV6PDIN.js → chunk-YLCBP7MP.js} +7 -217
  24. package/dist/deployer/index.d.ts +3 -3
  25. package/dist/deployer/index.js +1 -1
  26. package/dist/eval/index.d.ts +4 -4
  27. package/dist/{index-C5uPdbs4.d.ts → index-mKY1XrpK.d.ts} +2 -2
  28. package/dist/index.d.ts +11 -19
  29. package/dist/index.js +15 -26
  30. package/dist/integration/index.d.ts +5 -5
  31. package/dist/llm/index.d.ts +4 -4
  32. package/dist/logger/index.d.ts +2 -2
  33. package/dist/logger/index.js +1 -1
  34. package/dist/mastra/index.d.ts +5 -5
  35. package/dist/mastra/index.js +1 -1
  36. package/dist/memory/index.d.ts +4 -4
  37. package/dist/memory/index.js +1 -1
  38. package/dist/relevance/index.js +1 -1
  39. package/dist/storage/index.d.ts +7 -76
  40. package/dist/storage/index.js +1 -2
  41. package/dist/storage/libsql/index.d.ts +81 -0
  42. package/dist/storage/libsql/index.js +1 -0
  43. package/dist/telemetry/index.d.ts +4 -4
  44. package/dist/telemetry/index.js +1 -1
  45. package/dist/tools/index.d.ts +6 -6
  46. package/dist/tts/index.d.ts +3 -3
  47. package/dist/tts/index.js +1 -1
  48. package/dist/vector/index.d.ts +4 -7
  49. package/dist/vector/index.js +1 -1
  50. package/dist/vector/libsql/index.d.ts +5 -6
  51. package/dist/vector/libsql/index.js +1 -1
  52. package/dist/voice/index.d.ts +3 -3
  53. package/dist/voice/index.js +2 -2
  54. package/dist/{workflow-CPz2D0Wz.d.ts → workflow-BxyFP9Wv.d.ts} +3 -3
  55. package/dist/workflows/index.d.ts +6 -6
  56. package/dist/workflows/index.js +1 -1
  57. package/package.json +9 -12
  58. package/dist/chunk-7NPRQT5A.js +0 -111
@@ -1,15 +1,15 @@
1
1
  import 'ai';
2
2
  import 'json-schema';
3
3
  import 'zod';
4
- export { A as Agent } from '../base-HowPMmsb.js';
5
- import '../base-eWkcLLSb.js';
4
+ export { A as Agent } from '../base-hk-xmLC1.js';
5
+ import '../base-D90KQ4XI.js';
6
6
  import '../types-m9RryK9a.js';
7
7
  import '../voice/index.js';
8
8
  import 'sift';
9
9
  import '../vector/index.js';
10
10
  import '@opentelemetry/api';
11
- import '../index-C5uPdbs4.js';
12
- import 'pino';
11
+ import '../index-mKY1XrpK.js';
13
12
  import 'stream';
13
+ import 'pino';
14
14
  import '@opentelemetry/sdk-trace-base';
15
15
  import '../tts/index.js';
@@ -1 +1 @@
1
- export { Agent } from '../chunk-T5B2DATI.js';
1
+ export { Agent } from '../chunk-7TG2Y45H.js';
@@ -1,6 +1,6 @@
1
1
  import * as _opentelemetry_api from '@opentelemetry/api';
2
2
  import { Tracer, Span } from '@opentelemetry/api';
3
- import { R as RegisteredLogger, L as Logger } from './index-C5uPdbs4.js';
3
+ import { R as RegisteredLogger, L as Logger } from './index-mKY1XrpK.js';
4
4
  import { SpanExporter } from '@opentelemetry/sdk-trace-base';
5
5
 
6
6
  /** Sampling strategy configuration for OpenTelemetry */
@@ -1,13 +1,13 @@
1
1
  import * as ai from 'ai';
2
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';
3
+ import { M as MastraBase, T as Telemetry } from './base-D90KQ4XI.js';
4
4
  import { a as Metric, M as MetricResult, T as TestInfo } from './types-m9RryK9a.js';
5
5
  import { Query } from 'sift';
6
6
  import { z, ZodSchema } from 'zod';
7
7
  import { JSONSchema7 } from 'json-schema';
8
8
  import { MastraVector } from './vector/index.js';
9
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';
10
+ import { B as BaseLogMessage, R as RegisteredLogger, L as Logger, d as Run } from './index-mKY1XrpK.js';
11
11
  import { MastraTTS } from './tts/index.js';
12
12
 
13
13
  /**
@@ -196,6 +196,7 @@ type StepDef<TStepId extends TSteps[number]['id'], TSteps extends IAction<any, a
196
196
  snapshotOnTimeout?: boolean;
197
197
  when?: Condition<any, any> | ((args: {
198
198
  context: WorkflowContext;
199
+ mastra?: MastraPrimitives;
199
200
  }) => Promise<boolean>);
200
201
  data: TSchemaIn;
201
202
  handler: (args: ActionContext<TSchemaIn>) => Promise<z.infer<TSchemaOut>>;
@@ -214,6 +215,7 @@ interface StepConfig<TStep extends IAction<any, any, any, any>, CondStep extends
214
215
  snapshotOnTimeout?: boolean;
215
216
  when?: Condition<CondStep, TTriggerSchema> | ((args: {
216
217
  context: WorkflowContext<TTriggerSchema>;
218
+ mastra?: MastraPrimitives;
217
219
  }) => Promise<boolean>);
218
220
  variables?: StepInputType<TStep, 'inputSchema'> extends never ? Record<string, VariableReference<VarStep, TTriggerSchema>> : {
219
221
  [K in keyof StepInputType<TStep, 'inputSchema'>]?: VariableReference<VarStep, TTriggerSchema>;
@@ -238,7 +240,7 @@ interface WorkflowContext<TTrigger extends z.ZodType<any> = any> {
238
240
  steps: Record<string, StepResult<any>>;
239
241
  triggerData: z.infer<TTrigger>;
240
242
  attempts: Record<string, number>;
241
- getStepPayload: <T = unknown>(stepId: string) => T | undefined;
243
+ getStepResult: <T = unknown>(stepId: string) => T | undefined;
242
244
  }
243
245
  interface WorkflowLogMessage extends BaseLogMessage {
244
246
  type: typeof RegisteredLogger.WORKFLOW;
@@ -435,14 +437,14 @@ interface IAction<TId extends string, TSchemaIn extends z.ZodSchema | undefined,
435
437
  outputSchema?: TSchemaOut;
436
438
  mastra?: MastraPrimitives;
437
439
  payload?: TSchemaIn extends z.ZodSchema ? Partial<z.infer<TSchemaIn>> : unknown;
438
- execute: (context: TContext) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
440
+ execute?: (context: TContext) => Promise<TSchemaOut extends z.ZodSchema ? z.infer<TSchemaOut> : unknown>;
439
441
  [key: string]: any;
440
442
  }
441
443
 
442
444
  type CoreTool = {
443
445
  description?: string;
444
446
  parameters: ZodSchema;
445
- execute: (params: any) => Promise<any>;
447
+ execute?: (params: any) => Promise<any>;
446
448
  };
447
449
  interface ToolExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefined, TContext extends WorkflowContext = WorkflowContext> extends IExecutionContext<TSchemaIn, TContext> {
448
450
  }
@@ -896,4 +898,4 @@ declare abstract class MastraStorage extends MastraBase {
896
898
  __getEvalsByAgentName(agentName: string, type?: 'test' | 'live'): Promise<EvalRow[]>;
897
899
  }
898
900
 
899
- export { type WorkflowContext as $, Agent as A, type BaseStructuredOutputType as B, type CoreMessage as C, type LLMInnerStreamOptions as D, type EvalRow as E, type LLMStreamObjectOptions as F, type GenerateReturn as G, type MessageType as H, type IAction as I, type StorageThreadType as J, type MessageResponse as K, type LanguageModel as L, MastraStorage as M, type MemoryConfig as N, type OutputType as O, type SharedMemoryConfig as P, type CoreTool as Q, type RetryConfig as R, type StepExecutionContext as S, type ToolAction as T, type StepNode as U, type VariableReference as V, type WorkflowOptions as W, type BaseCondition as X, type ActionContext as Y, type StepDef as Z, type StepCondition as _, MastraMemory as a, type WorkflowLogMessage as a0, type WorkflowEvent as a1, type ResolverFunctionInput as a2, type ResolverFunctionOutput as a3, type SubscriberFunctionOutput as a4, type DependencyCheckOutput as a5, type WorkflowActors as a6, type WorkflowActionParams as a7, type WorkflowActions as a8, type WorkflowState as a9, type StepId as aa, type ExtractSchemaFromStep as ab, type ExtractStepResult as ac, type StepInputType as ad, type ExtractSchemaType as ae, type PathsToStringProps as af, type TABLE_NAMES as ag, TABLE_WORKFLOW_SNAPSHOT as ah, TABLE_EVALS as ai, TABLE_MESSAGES as aj, TABLE_THREADS as ak, TABLE_TRACES as al, type StepAction as b, type MastraPrimitives as c, type StepVariableType as d, type StepConfig as e, type StepResult as f, type WorkflowRunState as g, type StepGraph as h, type AgentConfig as i, type ToolExecutionContext as j, type StorageColumn as k, type WorkflowRow as l, type StorageGetMessagesArg as m, type CoreSystemMessage as n, type CoreAssistantMessage as o, type CoreUserMessage as p, type CoreToolMessage as q, type EmbedResult as r, type EmbedManyResult as s, type StructuredOutputType as t, type StructuredOutputArrayItem as u, type StructuredOutput as v, type StreamReturn as w, type LLMTextOptions as x, type LLMTextObjectOptions as y, type LLMStreamOptions as z };
901
+ export { type StepCondition as $, Agent as A, type BaseStructuredOutputType as B, type CoreMessage as C, type LLMTextOptions as D, type EvalRow as E, type LLMTextObjectOptions as F, type GenerateReturn as G, type LLMStreamOptions 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 };
package/dist/base.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import '@opentelemetry/api';
2
- import './index-C5uPdbs4.js';
3
- export { M as MastraBase } from './base-eWkcLLSb.js';
4
- import 'pino';
2
+ import './index-mKY1XrpK.js';
3
+ export { M as MastraBase } from './base-D90KQ4XI.js';
5
4
  import 'stream';
5
+ import 'pino';
6
6
  import '@opentelemetry/sdk-trace-base';
package/dist/base.js CHANGED
@@ -1 +1 @@
1
- export { MastraBase } from './chunk-6RDA4JYW.js';
1
+ export { MastraBase } from './chunk-OZ4XVJ6F.js';
@@ -1,8 +1,8 @@
1
- import { M as MastraBase } from '../base-eWkcLLSb.js';
1
+ import { M as MastraBase } from '../base-D90KQ4XI.js';
2
2
  import '@opentelemetry/api';
3
- import '../index-C5uPdbs4.js';
4
- import 'pino';
3
+ import '../index-mKY1XrpK.js';
5
4
  import 'stream';
5
+ import 'pino';
6
6
  import '@opentelemetry/sdk-trace-base';
7
7
 
8
8
  interface IBundler {
@@ -1 +1 @@
1
- export { MastraBundler } from '../chunk-YUOADWSP.js';
1
+ export { MastraBundler } from '../chunk-SVEAENO7.js';
@@ -1,7 +1,7 @@
1
- import { MastraVector } from './chunk-7NPRQT5A.js';
1
+ import { MastraVector } from './chunk-55NFNRKO.js';
2
2
  import { BaseFilterTranslator } from './chunk-SIFBBGY6.js';
3
- import { createClient } from '@libsql/client';
4
3
  import { join } from 'path';
4
+ import { createClient } from '@libsql/client';
5
5
 
6
6
  // src/vector/libsql/filter.ts
7
7
  var LibSQLFilterTranslator = class extends BaseFilterTranslator {
@@ -414,7 +414,7 @@ var processOperator = (key, operator, operatorValue) => {
414
414
  };
415
415
 
416
416
  // src/vector/libsql/index.ts
417
- var DefaultVectorDB = class extends MastraVector {
417
+ var LibSQLVector = class extends MastraVector {
418
418
  turso;
419
419
  constructor({
420
420
  connectionUrl,
@@ -617,4 +617,4 @@ var DefaultVectorDB = class extends MastraVector {
617
617
  }
618
618
  };
619
619
 
620
- export { DefaultVectorDB };
620
+ export { LibSQLVector };
@@ -1,4 +1,4 @@
1
- import { MastraBundler } from './chunk-YUOADWSP.js';
1
+ import { MastraBundler } from './chunk-SVEAENO7.js';
2
2
 
3
3
  // src/deployer/index.ts
4
4
  var MastraDeployer = class extends MastraBundler {
@@ -0,0 +1,10 @@
1
+ import { MastraBase } from './chunk-OZ4XVJ6F.js';
2
+
3
+ // src/vector/index.ts
4
+ var MastraVector = class extends MastraBase {
5
+ constructor() {
6
+ super({ name: "MastraVector", component: "VECTOR" });
7
+ }
8
+ };
9
+
10
+ export { MastraVector };
@@ -0,0 +1,215 @@
1
+ import { TABLE_WORKFLOW_SNAPSHOT, TABLE_EVALS, TABLE_MESSAGES, TABLE_THREADS, TABLE_TRACES } from './chunk-RG66XEJT.js';
2
+ import { MastraBase } from './chunk-OZ4XVJ6F.js';
3
+
4
+ // src/storage/base.ts
5
+ var MastraStorage = class extends MastraBase {
6
+ /** @deprecated import from { TABLE_WORKFLOW_SNAPSHOT } '@mastra/core/storage' instead */
7
+ static TABLE_WORKFLOW_SNAPSHOT = TABLE_WORKFLOW_SNAPSHOT;
8
+ /** @deprecated import from { TABLE_EVALS } '@mastra/core/storage' instead */
9
+ static TABLE_EVALS = TABLE_EVALS;
10
+ /** @deprecated import from { TABLE_MESSAGES } '@mastra/core/storage' instead */
11
+ static TABLE_MESSAGES = TABLE_MESSAGES;
12
+ /** @deprecated import from { TABLE_THREADS } '@mastra/core/storage' instead */
13
+ static TABLE_THREADS = TABLE_THREADS;
14
+ /** @deprecated import { TABLE_TRACES } from '@mastra/core/storage' instead */
15
+ static TABLE_TRACES = TABLE_TRACES;
16
+ hasInitialized = null;
17
+ constructor({ name }) {
18
+ super({
19
+ component: "STORAGE",
20
+ name
21
+ });
22
+ }
23
+ async __batchInsert({
24
+ tableName,
25
+ records
26
+ }) {
27
+ await this.init();
28
+ return this.batchInsert({ tableName, records });
29
+ }
30
+ async __getThreadById({ threadId }) {
31
+ await this.init();
32
+ return this.getThreadById({ threadId });
33
+ }
34
+ async __getThreadsByResourceId({ resourceId }) {
35
+ await this.init();
36
+ return this.getThreadsByResourceId({ resourceId });
37
+ }
38
+ async __saveThread({ thread }) {
39
+ await this.init();
40
+ return this.saveThread({ thread });
41
+ }
42
+ async __updateThread({
43
+ id,
44
+ title,
45
+ metadata
46
+ }) {
47
+ await this.init();
48
+ return this.updateThread({ id, title, metadata });
49
+ }
50
+ async __deleteThread({ threadId }) {
51
+ await this.init();
52
+ return this.deleteThread({ threadId });
53
+ }
54
+ async __getMessages({ threadId, selectBy, threadConfig }) {
55
+ await this.init();
56
+ return this.getMessages({ threadId, selectBy, threadConfig });
57
+ }
58
+ async __saveMessages({ messages }) {
59
+ await this.init();
60
+ return this.saveMessages({ messages });
61
+ }
62
+ async __getTraces({
63
+ scope,
64
+ page,
65
+ perPage,
66
+ attributes
67
+ }) {
68
+ await this.init();
69
+ return this.getTraces({ scope, page, perPage, attributes });
70
+ }
71
+ async init() {
72
+ if (await this.hasInitialized) {
73
+ return;
74
+ }
75
+ this.hasInitialized = Promise.all([
76
+ this.createTable({
77
+ tableName: TABLE_WORKFLOW_SNAPSHOT,
78
+ schema: {
79
+ workflow_name: {
80
+ type: "text"
81
+ },
82
+ run_id: {
83
+ type: "text"
84
+ },
85
+ snapshot: {
86
+ type: "text"
87
+ },
88
+ createdAt: {
89
+ type: "timestamp"
90
+ },
91
+ updatedAt: {
92
+ type: "timestamp"
93
+ }
94
+ }
95
+ }),
96
+ this.createTable({
97
+ tableName: TABLE_EVALS,
98
+ schema: {
99
+ input: {
100
+ type: "text"
101
+ },
102
+ output: {
103
+ type: "text"
104
+ },
105
+ result: {
106
+ type: "jsonb"
107
+ },
108
+ agent_name: {
109
+ type: "text"
110
+ },
111
+ metric_name: {
112
+ type: "text"
113
+ },
114
+ instructions: {
115
+ type: "text"
116
+ },
117
+ test_info: {
118
+ type: "jsonb",
119
+ nullable: true
120
+ },
121
+ global_run_id: {
122
+ type: "text"
123
+ },
124
+ run_id: {
125
+ type: "text"
126
+ },
127
+ created_at: {
128
+ type: "timestamp"
129
+ }
130
+ }
131
+ }),
132
+ this.createTable({
133
+ tableName: TABLE_THREADS,
134
+ schema: {
135
+ id: { type: "text", nullable: false, primaryKey: true },
136
+ resourceId: { type: "text", nullable: false },
137
+ title: { type: "text", nullable: false },
138
+ metadata: { type: "text", nullable: true },
139
+ createdAt: { type: "timestamp", nullable: false },
140
+ updatedAt: { type: "timestamp", nullable: false }
141
+ }
142
+ }),
143
+ this.createTable({
144
+ tableName: TABLE_MESSAGES,
145
+ schema: {
146
+ id: { type: "text", nullable: false, primaryKey: true },
147
+ thread_id: { type: "text", nullable: false },
148
+ content: { type: "text", nullable: false },
149
+ role: { type: "text", nullable: false },
150
+ type: { type: "text", nullable: false },
151
+ createdAt: { type: "timestamp", nullable: false }
152
+ }
153
+ }),
154
+ this.createTable({
155
+ tableName: TABLE_TRACES,
156
+ schema: {
157
+ id: { type: "text", nullable: false, primaryKey: true },
158
+ parentSpanId: { type: "text", nullable: true },
159
+ name: { type: "text", nullable: false },
160
+ traceId: { type: "text", nullable: false },
161
+ scope: { type: "text", nullable: false },
162
+ kind: { type: "integer", nullable: false },
163
+ attributes: { type: "jsonb", nullable: true },
164
+ status: { type: "jsonb", nullable: true },
165
+ events: { type: "jsonb", nullable: true },
166
+ links: { type: "jsonb", nullable: true },
167
+ other: { type: "text", nullable: true },
168
+ startTime: { type: "bigint", nullable: false },
169
+ endTime: { type: "bigint", nullable: false },
170
+ createdAt: { type: "timestamp", nullable: false }
171
+ }
172
+ })
173
+ ]).then(() => true);
174
+ await this.hasInitialized;
175
+ }
176
+ async persistWorkflowSnapshot({
177
+ workflowName,
178
+ runId,
179
+ snapshot
180
+ }) {
181
+ await this.init();
182
+ const data = {
183
+ workflow_name: workflowName,
184
+ run_id: runId,
185
+ snapshot,
186
+ createdAt: /* @__PURE__ */ new Date(),
187
+ updatedAt: /* @__PURE__ */ new Date()
188
+ };
189
+ this.logger.debug("Persisting workflow snapshot", { workflowName, runId, data });
190
+ await this.insert({
191
+ tableName: TABLE_WORKFLOW_SNAPSHOT,
192
+ record: data
193
+ });
194
+ }
195
+ async loadWorkflowSnapshot({
196
+ workflowName,
197
+ runId
198
+ }) {
199
+ if (!this.hasInitialized) {
200
+ await this.init();
201
+ }
202
+ this.logger.debug("Loading workflow snapshot", { workflowName, runId });
203
+ const d = await this.load({
204
+ tableName: TABLE_WORKFLOW_SNAPSHOT,
205
+ keys: { workflow_name: workflowName, run_id: runId }
206
+ });
207
+ return d ? d.snapshot : null;
208
+ }
209
+ async __getEvalsByAgentName(agentName, type) {
210
+ await this.init();
211
+ return this.getEvalsByAgentName(agentName, type);
212
+ }
213
+ };
214
+
215
+ export { MastraStorage };
@@ -1,7 +1,7 @@
1
- import { InstrumentClass } from './chunk-4ZRHVG25.js';
1
+ import { InstrumentClass } from './chunk-W5HVJX45.js';
2
2
  import { delay } from './chunk-WIBGG4X6.js';
3
- import { MastraBase } from './chunk-6RDA4JYW.js';
4
- import { RegisteredLogger } from './chunk-KP5SHTKA.js';
3
+ import { MastraBase } from './chunk-OZ4XVJ6F.js';
4
+ import { RegisteredLogger } from './chunk-PHMSPCTC.js';
5
5
  import { executeHook } from './chunk-BB4KXGBU.js';
6
6
  import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-C6A6W6XS.js';
7
7
  import { randomUUID } from 'crypto';
@@ -152,11 +152,11 @@ var MastraLLM = class extends MastraLLMBase {
152
152
  tool: k,
153
153
  props
154
154
  });
155
- return tool.execute({
155
+ return tool?.execute?.({
156
156
  context: props,
157
157
  mastra: this.#mastra,
158
158
  runId
159
- });
159
+ }) ?? void 0;
160
160
  } catch (error) {
161
161
  this.logger.error("Error executing tool", {
162
162
  tool: k,
@@ -563,7 +563,7 @@ var Agent = class extends (_a = MastraBase) {
563
563
  this.name = config.name;
564
564
  this.instructions = config.instructions;
565
565
  if (!config.model) {
566
- throw new Error(`LanugageModel is required to create an Agent. Please provider the 'model'.`);
566
+ throw new Error(`LanguageModel is required to create an Agent. Please provide the 'model'.`);
567
567
  }
568
568
  this.llm = new MastraLLM({
569
569
  model: config.model
@@ -918,11 +918,11 @@ var Agent = class extends (_a = MastraBase) {
918
918
  args,
919
919
  runId
920
920
  });
921
- return tool.execute({
921
+ return tool?.execute?.({
922
922
  context: args,
923
923
  mastra: this.#mastra,
924
924
  runId
925
- });
925
+ }) ?? void 0;
926
926
  } catch (err) {
927
927
  this.logger.error(`[Agent:${this.name}] - Failed execution`, {
928
928
  error: err,
@@ -1,6 +1,6 @@
1
- import { DefaultStorage } from './chunk-JIV6PDIN.js';
2
- import { InstrumentClass, OTLPTraceExporter, Telemetry } from './chunk-4ZRHVG25.js';
3
- import { createLogger, LogLevel, noopLogger } from './chunk-KP5SHTKA.js';
1
+ import { LibSQLStore } from './chunk-YLCBP7MP.js';
2
+ import { InstrumentClass, OTLPTraceExporter, Telemetry } from './chunk-W5HVJX45.js';
3
+ import { createLogger, LogLevel, noopLogger } from './chunk-PHMSPCTC.js';
4
4
  import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-C6A6W6XS.js';
5
5
 
6
6
  // src/mastra/index.ts
@@ -37,13 +37,13 @@ var Mastra = class {
37
37
  this.logger = logger;
38
38
  let storage = config?.storage;
39
39
  if (!storage) {
40
- storage = new DefaultStorage({
40
+ storage = new LibSQLStore({
41
41
  config: {
42
42
  url: process.env.MASTRA_DEFAULT_STORAGE_URL || `:memory:`
43
43
  }
44
44
  });
45
45
  }
46
- if (storage instanceof DefaultStorage && config?.telemetry?.export?.type !== "custom") {
46
+ if (storage instanceof LibSQLStore && config?.telemetry?.export?.type !== "custom") {
47
47
  const newTelemetry = {
48
48
  ...(config?.telemetry || {}),
49
49
  export: {
@@ -1,8 +1,108 @@
1
- import { DefaultStorage } from './chunk-JIV6PDIN.js';
2
- import { DefaultVectorDB } from './chunk-LKOVXFLE.js';
3
- import { defaultEmbedder } from './chunk-7NPRQT5A.js';
1
+ import { LibSQLVector } from './chunk-33GSTUNK.js';
2
+ import { LibSQLStore } from './chunk-YLCBP7MP.js';
4
3
  import { deepMerge } from './chunk-WIBGG4X6.js';
5
- import { MastraBase } from './chunk-6RDA4JYW.js';
4
+ import { MastraBase } from './chunk-OZ4XVJ6F.js';
5
+ import path from 'path';
6
+ import { experimental_customProvider } from 'ai';
7
+ import node_modulesPath from 'node_modules-path';
8
+
9
+ var cachedPath = false;
10
+ function getModelCachePath() {
11
+ if (cachedPath) return cachedPath;
12
+ const firstNodeModules = node_modulesPath().split("node_modules")[0];
13
+ cachedPath = path.join(firstNodeModules, "node_modules", ".fastembed-model-cache");
14
+ return cachedPath;
15
+ }
16
+ function unbundleableImport(name) {
17
+ const nonStaticallyAnalyzableName = `${name}?d=${Date.now()}`;
18
+ return import(nonStaticallyAnalyzableName.split(`?`)[0]);
19
+ }
20
+ async function generateEmbeddings(values, modelType) {
21
+ try {
22
+ let mod;
23
+ const importErrors = [];
24
+ {
25
+ try {
26
+ mod = await unbundleableImport("fastembed");
27
+ } catch (e) {
28
+ if (e instanceof Error) {
29
+ importErrors.push(e);
30
+ } else {
31
+ throw e;
32
+ }
33
+ }
34
+ }
35
+ if (!mod) {
36
+ throw new Error(`${importErrors.map((e) => e.message).join(`
37
+ `)}
38
+
39
+ This runtime does not support fastembed-js, which is the default embedder in Mastra.
40
+ Scroll up to read import errors. These errors mean you can't use the default Mastra embedder on this hosting platform.
41
+ You can either use Mastra Cloud which supports the default embedder, or you can configure an alternate provider.
42
+
43
+ For example if you're using Memory:
44
+
45
+ import { openai } from "@ai-sdk/openai";
46
+
47
+ const memory = new Memory({
48
+ embedder: openai.embedding("text-embedding-3-small"), // <- doesn't have to be openai
49
+ })
50
+
51
+ Visit https://sdk.vercel.ai/docs/foundations/overview#embedding-models to find an alternate embedding provider
52
+
53
+ If you do not want to use the Memory semantic recall feature, you can disable it entirely and this error will go away.
54
+
55
+ const memory = new Memory({
56
+ options: {
57
+ semanticRecall: false // <- an embedder will not be required with this set to false
58
+ }
59
+ })
60
+ `);
61
+ }
62
+ const { FlagEmbedding, EmbeddingModel } = mod;
63
+ const model = await FlagEmbedding.init({
64
+ model: EmbeddingModel[modelType],
65
+ cacheDir: getModelCachePath()
66
+ });
67
+ const embeddings = await model.embed(values);
68
+ const allResults = [];
69
+ for await (const result of embeddings) {
70
+ allResults.push(...result.map((embedding) => Array.from(embedding)));
71
+ }
72
+ if (allResults.length === 0) throw new Error("No embeddings generated");
73
+ return {
74
+ embeddings: allResults
75
+ };
76
+ } catch (error) {
77
+ console.error("Error generating embeddings:", error);
78
+ throw error;
79
+ }
80
+ }
81
+ var fastEmbedProvider = experimental_customProvider({
82
+ textEmbeddingModels: {
83
+ "bge-small-en-v1.5": {
84
+ specificationVersion: "v1",
85
+ provider: "fastembed",
86
+ modelId: "bge-small-en-v1.5",
87
+ maxEmbeddingsPerCall: 256,
88
+ supportsParallelCalls: true,
89
+ async doEmbed({ values }) {
90
+ return generateEmbeddings(values, "BGESmallENV15");
91
+ }
92
+ },
93
+ "bge-base-en-v1.5": {
94
+ specificationVersion: "v1",
95
+ provider: "fastembed",
96
+ modelId: "bge-base-en-v1.5",
97
+ maxEmbeddingsPerCall: 256,
98
+ supportsParallelCalls: true,
99
+ async doEmbed({ values }) {
100
+ return generateEmbeddings(values, "BGEBaseENV15");
101
+ }
102
+ }
103
+ }
104
+ });
105
+ var defaultEmbedder = fastEmbedProvider.textEmbeddingModel;
6
106
 
7
107
  // src/memory/memory.ts
8
108
  var MastraMemory = class extends MastraBase {
@@ -16,7 +116,7 @@ var MastraMemory = class extends MastraBase {
16
116
  };
17
117
  constructor(config) {
18
118
  super({ component: "MEMORY", name: config.name });
19
- this.storage = config.storage || new DefaultStorage({
119
+ this.storage = config.storage || new LibSQLStore({
20
120
  config: {
21
121
  url: "file:memory.db"
22
122
  }
@@ -24,7 +124,7 @@ var MastraMemory = class extends MastraBase {
24
124
  if (config.vector) {
25
125
  this.vector = config.vector;
26
126
  } else {
27
- this.vector = new DefaultVectorDB({
127
+ this.vector = new LibSQLVector({
28
128
  connectionUrl: "file:memory-vector.db"
29
129
  // file name needs to be different than default storage or it wont work properly
30
130
  });
@@ -1,4 +1,4 @@
1
- import { RegisteredLogger, createLogger } from './chunk-KP5SHTKA.js';
1
+ import { RegisteredLogger, createLogger } from './chunk-PHMSPCTC.js';
2
2
 
3
3
  // src/base.ts
4
4
  var MastraBase = class {
@@ -1,6 +1,6 @@
1
+ import { Transform } from 'stream';
1
2
  import pino from 'pino';
2
3
  import pretty from 'pino-pretty';
3
- import { Transform } from 'stream';
4
4
 
5
5
  // src/logger/index.ts
6
6
  var RegisteredLogger = {
@@ -27,7 +27,7 @@ var LoggerTransport = class extends Transform {
27
27
  constructor(opts = {}) {
28
28
  super({ ...opts, objectMode: true });
29
29
  }
30
- async getLogsByRunId({ runId }) {
30
+ async getLogsByRunId(_args) {
31
31
  return [];
32
32
  }
33
33
  async getLogs() {
@@ -1,4 +1,4 @@
1
- import { Agent } from './chunk-T5B2DATI.js';
1
+ import { Agent } from './chunk-7TG2Y45H.js';
2
2
  import { CohereClient } from 'cohere-ai';
3
3
 
4
4
  var CohereRelevanceScorer = class {
@@ -1,5 +1,5 @@
1
- import { InstrumentClass } from './chunk-4ZRHVG25.js';
2
- import { MastraBase } from './chunk-6RDA4JYW.js';
1
+ import { InstrumentClass } from './chunk-W5HVJX45.js';
2
+ import { MastraBase } from './chunk-OZ4XVJ6F.js';
3
3
  import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-C6A6W6XS.js';
4
4
 
5
5
  // src/tts/index.ts
@@ -1,6 +1,6 @@
1
- import { MastraBase } from './chunk-6RDA4JYW.js';
2
- import { parse } from 'dotenv';
1
+ import { MastraBase } from './chunk-OZ4XVJ6F.js';
3
2
  import { readFile } from 'fs/promises';
3
+ import { parse } from 'dotenv';
4
4
 
5
5
  var MastraBundler = class extends MastraBase {
6
6
  constructor({ name, component = "BUNDLER" }) {