@mastra/core 0.5.0 → 0.6.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.
Files changed (59) hide show
  1. package/dist/agent/index.cjs +2 -2
  2. package/dist/agent/index.d.cts +1 -1
  3. package/dist/agent/index.d.ts +1 -1
  4. package/dist/agent/index.js +1 -1
  5. package/dist/{base-C_Oq53qk.d.ts → base-DA1J3qra.d.ts} +18 -8
  6. package/dist/{base-CIPKleAU.d.cts → base-zjGki2_Z.d.cts} +18 -8
  7. package/dist/{chunk-YPD6BQIM.js → chunk-22HQQDJZ.js} +36 -53
  8. package/dist/chunk-3LURIF6I.cjs +90 -0
  9. package/dist/{chunk-OD7ZMKHY.js → chunk-6ZHR5KIP.js} +93 -42
  10. package/dist/{chunk-KFQ7Z3PO.cjs → chunk-B3KTSEC5.cjs} +2 -2
  11. package/dist/{chunk-XF2FMJYK.js → chunk-DGYFNGOC.js} +1 -1
  12. package/dist/chunk-GMAMAKLH.js +88 -0
  13. package/dist/{chunk-OTFLHXHZ.cjs → chunk-L5BNMAC3.cjs} +2 -2
  14. package/dist/{chunk-KP5UAFLN.js → chunk-LTLNGEL2.js} +3 -1
  15. package/dist/{chunk-MLFXOST6.js → chunk-MLKXBAQG.js} +2 -2
  16. package/dist/{chunk-UZNQG7QO.cjs → chunk-N2G5ZI42.cjs} +93 -42
  17. package/dist/{chunk-3ASEZT7U.cjs → chunk-WX2ECXAE.cjs} +3 -1
  18. package/dist/{chunk-GXQRMKSN.cjs → chunk-XLZRGA3F.cjs} +35 -52
  19. package/dist/eval/index.d.cts +1 -1
  20. package/dist/eval/index.d.ts +1 -1
  21. package/dist/index.cjs +27 -27
  22. package/dist/index.d.cts +2 -2
  23. package/dist/index.d.ts +2 -2
  24. package/dist/index.js +6 -6
  25. package/dist/integration/index.d.cts +1 -1
  26. package/dist/integration/index.d.ts +1 -1
  27. package/dist/llm/index.d.cts +1 -1
  28. package/dist/llm/index.d.ts +1 -1
  29. package/dist/mastra/index.cjs +2 -2
  30. package/dist/mastra/index.d.cts +1 -1
  31. package/dist/mastra/index.d.ts +1 -1
  32. package/dist/mastra/index.js +1 -1
  33. package/dist/memory/index.cjs +2 -2
  34. package/dist/memory/index.d.cts +1 -1
  35. package/dist/memory/index.d.ts +1 -1
  36. package/dist/memory/index.js +1 -1
  37. package/dist/relevance/index.cjs +4 -4
  38. package/dist/relevance/index.d.cts +1 -1
  39. package/dist/relevance/index.d.ts +1 -1
  40. package/dist/relevance/index.js +1 -1
  41. package/dist/storage/index.d.cts +1 -1
  42. package/dist/storage/index.d.ts +1 -1
  43. package/dist/storage/libsql/index.cjs +440 -10
  44. package/dist/storage/libsql/index.d.cts +1 -1
  45. package/dist/storage/libsql/index.d.ts +1 -1
  46. package/dist/storage/libsql/index.js +441 -1
  47. package/dist/telemetry/index.d.cts +1 -1
  48. package/dist/telemetry/index.d.ts +1 -1
  49. package/dist/tools/index.d.cts +2 -2
  50. package/dist/tools/index.d.ts +2 -2
  51. package/dist/utils.d.cts +1 -1
  52. package/dist/utils.d.ts +1 -1
  53. package/dist/workflows/index.cjs +17 -17
  54. package/dist/workflows/index.d.cts +2 -2
  55. package/dist/workflows/index.d.ts +2 -2
  56. package/dist/workflows/index.js +1 -1
  57. package/package.json +5 -5
  58. package/dist/chunk-QAZ2ONKM.js +0 -441
  59. package/dist/chunk-VA4P7QJT.cjs +0 -443
@@ -1,10 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunk3ASEZT7U_cjs = require('../chunk-3ASEZT7U.cjs');
3
+ var chunkWX2ECXAE_cjs = require('../chunk-WX2ECXAE.cjs');
4
4
 
5
5
 
6
6
 
7
7
  Object.defineProperty(exports, "Agent", {
8
8
  enumerable: true,
9
- get: function () { return chunk3ASEZT7U_cjs.Agent; }
9
+ get: function () { return chunkWX2ECXAE_cjs.Agent; }
10
10
  });
@@ -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, l as AgentConfig, ay as AgentGenerateOptions, az as AgentStreamOptions, aw as MastraLanguageModel, a as ToolsInput, ax as ToolsetsInput } from '../base-CIPKleAU.cjs';
4
+ export { A as Agent, l as AgentConfig, ay as AgentGenerateOptions, az as AgentStreamOptions, aw as MastraLanguageModel, a as ToolsInput, ax as ToolsetsInput } from '../base-zjGki2_Z.cjs';
5
5
  import '../base-DboIg_Cd.cjs';
6
6
  import '../types-CwTG2XyQ.cjs';
7
7
  import '../voice/index.cjs';
@@ -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, l as AgentConfig, ay as AgentGenerateOptions, az as AgentStreamOptions, aw as MastraLanguageModel, a as ToolsInput, ax as ToolsetsInput } from '../base-C_Oq53qk.js';
4
+ export { A as Agent, l as AgentConfig, ay as AgentGenerateOptions, az as AgentStreamOptions, aw as MastraLanguageModel, a as ToolsInput, ax as ToolsetsInput } from '../base-DA1J3qra.js';
5
5
  import '../base-BZViaFTt.js';
6
6
  import '../types-CwTG2XyQ.js';
7
7
  import '../voice/index.js';
@@ -1 +1 @@
1
- export { Agent } from '../chunk-KP5UAFLN.js';
1
+ export { Agent } from '../chunk-LTLNGEL2.js';
@@ -175,6 +175,9 @@ declare function createStep<TId extends string, TSchemaIn extends z.ZodSchema |
175
175
  interface WorkflowOptions<TTriggerSchema extends z.ZodObject<any> = any> {
176
176
  name: string;
177
177
  triggerSchema?: TTriggerSchema;
178
+ events?: Record<string, {
179
+ schema: z.ZodObject<any>;
180
+ }>;
178
181
  retryConfig?: RetryConfig;
179
182
  mastra?: Mastra;
180
183
  }
@@ -304,7 +307,7 @@ interface WorkflowRunResult<T extends z.ZodType<any>, TSteps extends Step<string
304
307
  [K in keyof StepsRecord<TSteps>]: StepsRecord<TSteps>[K]['outputSchema'] extends undefined ? StepResult<unknown> : StepResult<z.infer<NonNullable<StepsRecord<TSteps>[K]['outputSchema']>>>;
305
308
  };
306
309
  runId: string;
307
- activePaths: Map<string, {
310
+ activePaths: Map<keyof StepsRecord<TSteps>, {
308
311
  status: string;
309
312
  suspendPayload?: any;
310
313
  }>;
@@ -315,7 +318,9 @@ interface WorkflowContext<TTrigger extends z.ZodObject<any> = any, TSteps extend
315
318
  [K in keyof StepsRecord<TSteps>]: StepsRecord<TSteps>[K]['outputSchema'] extends undefined ? StepResult<unknown> : StepResult<z.infer<NonNullable<StepsRecord<TSteps>[K]['outputSchema']>>>;
316
319
  };
317
320
  triggerData: z.infer<TTrigger>;
321
+ resumeData?: any;
318
322
  attempts: Record<string, number>;
323
+ getStepResult(stepId: 'trigger'): z.infer<TTrigger>;
319
324
  getStepResult<T extends keyof StepsRecord<TSteps> | unknown>(stepId: T extends keyof StepsRecord<TSteps> ? T : string): T extends keyof StepsRecord<TSteps> ? StepsRecord<TSteps>[T]['outputSchema'] extends undefined ? unknown : z.infer<NonNullable<StepsRecord<TSteps>[T]['outputSchema']>> : T;
320
325
  getStepResult<T extends Step<any, any, any, any>>(stepId: T): T['outputSchema'] extends undefined ? unknown : z.infer<NonNullable<T['outputSchema']>>;
321
326
  }
@@ -523,12 +528,15 @@ declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, an
523
528
  #private;
524
529
  name: string;
525
530
  triggerSchema?: TTriggerSchema;
531
+ events?: Record<string, {
532
+ schema: z.ZodObject<any>;
533
+ }>;
526
534
  /**
527
535
  * Creates a new Workflow instance
528
536
  * @param name - Identifier for the workflow (not necessarily unique)
529
537
  * @param logger - Optional logger instance
530
538
  */
531
- constructor({ name, triggerSchema, retryConfig, mastra }: WorkflowOptions<TTriggerSchema>);
539
+ constructor({ name, triggerSchema, retryConfig, mastra, events }: WorkflowOptions<TTriggerSchema>);
532
540
  step<TStep extends StepAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>>(step: TStep, config?: StepConfig<TStep, CondStep, VarStep, TTriggerSchema>): this;
533
541
  then<TStep extends StepAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>>(step: TStep, config?: StepConfig<TStep, CondStep, VarStep, TTriggerSchema>): this;
534
542
  private loop;
@@ -537,6 +545,7 @@ declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, an
537
545
  if<TStep extends StepAction<any, any, any, any>>(condition: StepConfig<TStep, any, any, TTriggerSchema>['when']): this;
538
546
  else(): this;
539
547
  after<TStep extends StepAction<any, any, any, any>>(steps: TStep | TStep[]): Omit<typeof this, "then" | "after">;
548
+ afterEvent(eventName: string): this;
540
549
  /**
541
550
  * Executes the workflow with the given trigger data
542
551
  * @param triggerData - Initial data to start the workflow with
@@ -566,6 +575,7 @@ declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, an
566
575
  stepId: string;
567
576
  context?: Record<string, any>;
568
577
  }): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps>, "runId"> | undefined>;
578
+ resumeWithEvent(runId: string, eventName: string, data: any): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps>, "runId"> | undefined>;
569
579
  __registerMastra(mastra: Mastra): void;
570
580
  __registerPrimitives(p: MastraPrimitives): void;
571
581
  get stepGraph(): StepGraph;
@@ -595,17 +605,17 @@ interface Config<TAgents extends Record<string, Agent<any>> = Record<string, Age
595
605
  declare class Mastra<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> {
596
606
  #private;
597
607
  /**
598
- * @deprecated use getStorage() instead
608
+ * @deprecated use getTelemetry() instead
599
609
  */
600
- storage?: MastraStorage;
610
+ get telemetry(): Telemetry | undefined;
601
611
  /**
602
- * @deprecated use getMemory() instead
612
+ * @deprecated use getStorage() instead
603
613
  */
604
- memory?: MastraMemory;
614
+ get storage(): MastraStorage | undefined;
605
615
  /**
606
- * @deprecated use getTelemetry() instead
616
+ * @deprecated use getMemory() instead
607
617
  */
608
- get telemetry(): Telemetry | undefined;
618
+ get memory(): MastraMemory | undefined;
609
619
  constructor(config?: Config<TAgents, TWorkflows, TVectors, TTTS, TLogger>);
610
620
  getAgent<TAgentName extends keyof TAgents>(name: TAgentName): TAgents[TAgentName];
611
621
  getAgents(): TAgents;
@@ -175,6 +175,9 @@ declare function createStep<TId extends string, TSchemaIn extends z.ZodSchema |
175
175
  interface WorkflowOptions<TTriggerSchema extends z.ZodObject<any> = any> {
176
176
  name: string;
177
177
  triggerSchema?: TTriggerSchema;
178
+ events?: Record<string, {
179
+ schema: z.ZodObject<any>;
180
+ }>;
178
181
  retryConfig?: RetryConfig;
179
182
  mastra?: Mastra;
180
183
  }
@@ -304,7 +307,7 @@ interface WorkflowRunResult<T extends z.ZodType<any>, TSteps extends Step<string
304
307
  [K in keyof StepsRecord<TSteps>]: StepsRecord<TSteps>[K]['outputSchema'] extends undefined ? StepResult<unknown> : StepResult<z.infer<NonNullable<StepsRecord<TSteps>[K]['outputSchema']>>>;
305
308
  };
306
309
  runId: string;
307
- activePaths: Map<string, {
310
+ activePaths: Map<keyof StepsRecord<TSteps>, {
308
311
  status: string;
309
312
  suspendPayload?: any;
310
313
  }>;
@@ -315,7 +318,9 @@ interface WorkflowContext<TTrigger extends z.ZodObject<any> = any, TSteps extend
315
318
  [K in keyof StepsRecord<TSteps>]: StepsRecord<TSteps>[K]['outputSchema'] extends undefined ? StepResult<unknown> : StepResult<z.infer<NonNullable<StepsRecord<TSteps>[K]['outputSchema']>>>;
316
319
  };
317
320
  triggerData: z.infer<TTrigger>;
321
+ resumeData?: any;
318
322
  attempts: Record<string, number>;
323
+ getStepResult(stepId: 'trigger'): z.infer<TTrigger>;
319
324
  getStepResult<T extends keyof StepsRecord<TSteps> | unknown>(stepId: T extends keyof StepsRecord<TSteps> ? T : string): T extends keyof StepsRecord<TSteps> ? StepsRecord<TSteps>[T]['outputSchema'] extends undefined ? unknown : z.infer<NonNullable<StepsRecord<TSteps>[T]['outputSchema']>> : T;
320
325
  getStepResult<T extends Step<any, any, any, any>>(stepId: T): T['outputSchema'] extends undefined ? unknown : z.infer<NonNullable<T['outputSchema']>>;
321
326
  }
@@ -523,12 +528,15 @@ declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, an
523
528
  #private;
524
529
  name: string;
525
530
  triggerSchema?: TTriggerSchema;
531
+ events?: Record<string, {
532
+ schema: z.ZodObject<any>;
533
+ }>;
526
534
  /**
527
535
  * Creates a new Workflow instance
528
536
  * @param name - Identifier for the workflow (not necessarily unique)
529
537
  * @param logger - Optional logger instance
530
538
  */
531
- constructor({ name, triggerSchema, retryConfig, mastra }: WorkflowOptions<TTriggerSchema>);
539
+ constructor({ name, triggerSchema, retryConfig, mastra, events }: WorkflowOptions<TTriggerSchema>);
532
540
  step<TStep extends StepAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>>(step: TStep, config?: StepConfig<TStep, CondStep, VarStep, TTriggerSchema>): this;
533
541
  then<TStep extends StepAction<any, any, any, any>, CondStep extends StepVariableType<any, any, any, any>, VarStep extends StepVariableType<any, any, any, any>>(step: TStep, config?: StepConfig<TStep, CondStep, VarStep, TTriggerSchema>): this;
534
542
  private loop;
@@ -537,6 +545,7 @@ declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, an
537
545
  if<TStep extends StepAction<any, any, any, any>>(condition: StepConfig<TStep, any, any, TTriggerSchema>['when']): this;
538
546
  else(): this;
539
547
  after<TStep extends StepAction<any, any, any, any>>(steps: TStep | TStep[]): Omit<typeof this, "then" | "after">;
548
+ afterEvent(eventName: string): this;
540
549
  /**
541
550
  * Executes the workflow with the given trigger data
542
551
  * @param triggerData - Initial data to start the workflow with
@@ -566,6 +575,7 @@ declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, an
566
575
  stepId: string;
567
576
  context?: Record<string, any>;
568
577
  }): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps>, "runId"> | undefined>;
578
+ resumeWithEvent(runId: string, eventName: string, data: any): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps>, "runId"> | undefined>;
569
579
  __registerMastra(mastra: Mastra): void;
570
580
  __registerPrimitives(p: MastraPrimitives): void;
571
581
  get stepGraph(): StepGraph;
@@ -595,17 +605,17 @@ interface Config<TAgents extends Record<string, Agent<any>> = Record<string, Age
595
605
  declare class Mastra<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> {
596
606
  #private;
597
607
  /**
598
- * @deprecated use getStorage() instead
608
+ * @deprecated use getTelemetry() instead
599
609
  */
600
- storage?: MastraStorage;
610
+ get telemetry(): Telemetry | undefined;
601
611
  /**
602
- * @deprecated use getMemory() instead
612
+ * @deprecated use getStorage() instead
603
613
  */
604
- memory?: MastraMemory;
614
+ get storage(): MastraStorage | undefined;
605
615
  /**
606
- * @deprecated use getTelemetry() instead
616
+ * @deprecated use getMemory() instead
607
617
  */
608
- get telemetry(): Telemetry | undefined;
618
+ get memory(): MastraMemory | undefined;
609
619
  constructor(config?: Config<TAgents, TWorkflows, TVectors, TTTS, TLogger>);
610
620
  getAgent<TAgentName extends keyof TAgents>(name: TAgentName): TAgents[TAgentName];
611
621
  getAgents(): TAgents;
@@ -1,5 +1,5 @@
1
- import { LibSQLStore } from './chunk-QAZ2ONKM.js';
2
- import { InstrumentClass, OTLPTraceExporter, Telemetry } from './chunk-W5HVJX45.js';
1
+ import { DefaultProxyStorage } from './chunk-GMAMAKLH.js';
2
+ import { InstrumentClass, Telemetry } from './chunk-W5HVJX45.js';
3
3
  import { createLogger, LogLevel, noopLogger } from './chunk-3JSTLSIP.js';
4
4
  import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-C6A6W6XS.js';
5
5
 
@@ -18,19 +18,25 @@ var Mastra = class {
18
18
  #deployer;
19
19
  #serverMiddleware = [];
20
20
  #telemetry;
21
+ #storage;
22
+ #memory;
21
23
  /**
22
- * @deprecated use getStorage() instead
24
+ * @deprecated use getTelemetry() instead
23
25
  */
24
- storage;
26
+ get telemetry() {
27
+ return this.#telemetry;
28
+ }
25
29
  /**
26
- * @deprecated use getMemory() instead
30
+ * @deprecated use getStorage() instead
27
31
  */
28
- memory;
32
+ get storage() {
33
+ return this.#storage;
34
+ }
29
35
  /**
30
- * @deprecated use getTelemetry() instead
36
+ * @deprecated use getMemory() instead
31
37
  */
32
- get telemetry() {
33
- return this.#telemetry;
38
+ get memory() {
39
+ return this.#memory;
34
40
  }
35
41
  constructor(config) {
36
42
  if (config?.serverMiddleware) {
@@ -56,43 +62,20 @@ var Mastra = class {
56
62
  this.#logger = logger;
57
63
  let storage = config?.storage;
58
64
  if (!storage) {
59
- storage = new LibSQLStore({
65
+ storage = new DefaultProxyStorage({
60
66
  config: {
61
67
  url: process.env.MASTRA_DEFAULT_STORAGE_URL || `:memory:`
62
68
  }
63
69
  });
64
70
  }
65
- if (storage instanceof LibSQLStore && config?.telemetry?.export?.type !== "custom") {
66
- const newTelemetry = {
67
- ...(config?.telemetry || {}),
68
- export: {
69
- type: "custom",
70
- exporter: new OTLPTraceExporter({
71
- logger: this.getLogger(),
72
- storage
73
- })
74
- }
75
- };
76
- this.#telemetry = Telemetry.init(newTelemetry);
77
- } else if (config?.telemetry) {
78
- this.#telemetry = Telemetry.init(config?.telemetry);
79
- }
80
- if (config?.deployer) {
81
- this.#deployer = config.deployer;
82
- if (this.#telemetry) {
83
- this.#deployer = this.#telemetry.traceClass(config.deployer, {
84
- excludeMethods: ["__setTelemetry", "__getTelemetry"]
85
- });
86
- this.#deployer.__setTelemetry(this.#telemetry);
87
- }
88
- }
71
+ this.#telemetry = Telemetry.init(config?.telemetry);
89
72
  if (this.#telemetry) {
90
- this.storage = this.#telemetry.traceClass(storage, {
73
+ this.#storage = this.#telemetry.traceClass(storage, {
91
74
  excludeMethods: ["__setTelemetry", "__getTelemetry"]
92
75
  });
93
- this.storage.__setTelemetry(this.#telemetry);
76
+ this.#storage.__setTelemetry(this.#telemetry);
94
77
  } else {
95
- this.storage = storage;
78
+ this.#storage = storage;
96
79
  }
97
80
  if (config?.vectors) {
98
81
  let vectors = {};
@@ -112,12 +95,12 @@ var Mastra = class {
112
95
  this.#vectors = config.vectors;
113
96
  }
114
97
  if (config?.memory) {
115
- this.memory = config.memory;
98
+ this.#memory = config.memory;
116
99
  if (this.#telemetry) {
117
- this.memory = this.#telemetry.traceClass(config.memory, {
100
+ this.#memory = this.#telemetry.traceClass(config.memory, {
118
101
  excludeMethods: ["__setTelemetry", "__getTelemetry"]
119
102
  });
120
- this.memory.__setTelemetry(this.#telemetry);
103
+ this.#memory.__setTelemetry(this.#telemetry);
121
104
  }
122
105
  }
123
106
  if (config && `memory` in config) {
@@ -237,7 +220,7 @@ This is a warning for now, but will throw an error in the future
237
220
  return this.#workflows;
238
221
  }
239
222
  setStorage(storage) {
240
- this.storage = storage;
223
+ this.#storage = storage;
241
224
  }
242
225
  setLogger({
243
226
  logger
@@ -248,8 +231,8 @@ This is a warning for now, but will throw an error in the future
248
231
  this.#agents?.[key]?.__setLogger(this.#logger);
249
232
  });
250
233
  }
251
- if (this.memory) {
252
- this.memory.__setLogger(this.#logger);
234
+ if (this.#memory) {
235
+ this.#memory.__setLogger(this.#logger);
253
236
  }
254
237
  if (this.#deployer) {
255
238
  this.#deployer.__setLogger(this.#logger);
@@ -259,8 +242,8 @@ This is a warning for now, but will throw an error in the future
259
242
  this.#tts?.[key]?.__setLogger(this.#logger);
260
243
  });
261
244
  }
262
- if (this.storage) {
263
- this.storage.__setLogger(this.#logger);
245
+ if (this.#storage) {
246
+ this.#storage.__setLogger(this.#logger);
264
247
  }
265
248
  if (this.#vectors) {
266
249
  Object.keys(this.#vectors).forEach(key => {
@@ -277,11 +260,11 @@ This is a warning for now, but will throw an error in the future
277
260
  }
278
261
  });
279
262
  }
280
- if (this.memory) {
281
- this.memory = this.#telemetry.traceClass(this.memory, {
263
+ if (this.#memory) {
264
+ this.#memory = this.#telemetry.traceClass(this.#memory, {
282
265
  excludeMethods: ["__setTelemetry", "__getTelemetry"]
283
266
  });
284
- this.memory.__setTelemetry(this.#telemetry);
267
+ this.#memory.__setTelemetry(this.#telemetry);
285
268
  }
286
269
  if (this.#deployer) {
287
270
  this.#deployer = this.#telemetry.traceClass(this.#deployer, {
@@ -301,11 +284,11 @@ This is a warning for now, but will throw an error in the future
301
284
  });
302
285
  this.#tts = tts;
303
286
  }
304
- if (this.storage) {
305
- this.storage = this.#telemetry.traceClass(this.storage, {
287
+ if (this.#storage) {
288
+ this.#storage = this.#telemetry.traceClass(this.#storage, {
306
289
  excludeMethods: ["__setTelemetry", "__getTelemetry"]
307
290
  });
308
- this.storage.__setTelemetry(this.#telemetry);
291
+ this.#storage.__setTelemetry(this.#telemetry);
309
292
  }
310
293
  if (this.#vectors) {
311
294
  let vectors = {};
@@ -330,10 +313,10 @@ This is a warning for now, but will throw an error in the future
330
313
  return this.#telemetry;
331
314
  }
332
315
  getMemory() {
333
- return this.memory;
316
+ return this.#memory;
334
317
  }
335
318
  getStorage() {
336
- return this.storage;
319
+ return this.#storage;
337
320
  }
338
321
  getServerMiddleware() {
339
322
  return this.#serverMiddleware;
@@ -0,0 +1,90 @@
1
+ 'use strict';
2
+
3
+ var chunkFL3GQXQ2_cjs = require('./chunk-FL3GQXQ2.cjs');
4
+
5
+ // src/storage/default-proxy-storage.ts
6
+ var DefaultProxyStorage = class extends chunkFL3GQXQ2_cjs.MastraStorage {
7
+ storage = null;
8
+ storageConfig;
9
+ isInitializingPromise = null;
10
+ constructor({ config }) {
11
+ super({ name: "DefaultStorage" });
12
+ this.storageConfig = config;
13
+ }
14
+ setupStorage() {
15
+ if (!this.isInitializingPromise) {
16
+ this.isInitializingPromise = new Promise((resolve, reject) => {
17
+ import('./storage/libsql/index.cjs').then(({ DefaultStorage }) => {
18
+ this.storage = new DefaultStorage({ config: this.storageConfig });
19
+ resolve();
20
+ }).catch(reject);
21
+ });
22
+ }
23
+ return this.isInitializingPromise;
24
+ }
25
+ async createTable({
26
+ tableName,
27
+ schema
28
+ }) {
29
+ await this.setupStorage();
30
+ return this.storage.createTable({ tableName, schema });
31
+ }
32
+ async clearTable({ tableName }) {
33
+ await this.setupStorage();
34
+ return this.storage.clearTable({ tableName });
35
+ }
36
+ async insert({ tableName, record }) {
37
+ await this.setupStorage();
38
+ return this.storage.insert({ tableName, record });
39
+ }
40
+ async batchInsert({ tableName, records }) {
41
+ await this.setupStorage();
42
+ return this.storage.batchInsert({ tableName, records });
43
+ }
44
+ async load({ tableName, keys }) {
45
+ await this.setupStorage();
46
+ return this.storage.load({ tableName, keys });
47
+ }
48
+ async getThreadById({ threadId }) {
49
+ await this.setupStorage();
50
+ return this.storage.getThreadById({ threadId });
51
+ }
52
+ async getThreadsByResourceId({ resourceId }) {
53
+ await this.setupStorage();
54
+ return this.storage.getThreadsByResourceId({ resourceId });
55
+ }
56
+ async saveThread({ thread }) {
57
+ await this.setupStorage();
58
+ return this.storage.saveThread({ thread });
59
+ }
60
+ async updateThread({
61
+ id,
62
+ title,
63
+ metadata
64
+ }) {
65
+ await this.setupStorage();
66
+ return this.storage.updateThread({ id, title, metadata });
67
+ }
68
+ async deleteThread({ threadId }) {
69
+ await this.setupStorage();
70
+ return this.storage.deleteThread({ threadId });
71
+ }
72
+ async getMessages({ threadId, selectBy }) {
73
+ await this.setupStorage();
74
+ return this.storage.getMessages({ threadId, selectBy });
75
+ }
76
+ async saveMessages({ messages }) {
77
+ await this.setupStorage();
78
+ return this.storage.saveMessages({ messages });
79
+ }
80
+ async getEvalsByAgentName(agentName, type) {
81
+ await this.setupStorage();
82
+ return this.storage.getEvalsByAgentName(agentName, type);
83
+ }
84
+ async getTraces(options) {
85
+ await this.setupStorage();
86
+ return this.storage.getTraces(options);
87
+ }
88
+ };
89
+
90
+ exports.DefaultProxyStorage = DefaultProxyStorage;