@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.
- package/dist/agent/index.cjs +2 -2
- package/dist/agent/index.d.cts +1 -1
- package/dist/agent/index.d.ts +1 -1
- package/dist/agent/index.js +1 -1
- package/dist/{base-C_Oq53qk.d.ts → base-DA1J3qra.d.ts} +18 -8
- package/dist/{base-CIPKleAU.d.cts → base-zjGki2_Z.d.cts} +18 -8
- package/dist/{chunk-YPD6BQIM.js → chunk-22HQQDJZ.js} +36 -53
- package/dist/chunk-3LURIF6I.cjs +90 -0
- package/dist/{chunk-OD7ZMKHY.js → chunk-6ZHR5KIP.js} +93 -42
- package/dist/{chunk-KFQ7Z3PO.cjs → chunk-B3KTSEC5.cjs} +2 -2
- package/dist/{chunk-XF2FMJYK.js → chunk-DGYFNGOC.js} +1 -1
- package/dist/chunk-GMAMAKLH.js +88 -0
- package/dist/{chunk-OTFLHXHZ.cjs → chunk-L5BNMAC3.cjs} +2 -2
- package/dist/{chunk-KP5UAFLN.js → chunk-LTLNGEL2.js} +3 -1
- package/dist/{chunk-MLFXOST6.js → chunk-MLKXBAQG.js} +2 -2
- package/dist/{chunk-UZNQG7QO.cjs → chunk-N2G5ZI42.cjs} +93 -42
- package/dist/{chunk-3ASEZT7U.cjs → chunk-WX2ECXAE.cjs} +3 -1
- package/dist/{chunk-GXQRMKSN.cjs → chunk-XLZRGA3F.cjs} +35 -52
- package/dist/eval/index.d.cts +1 -1
- package/dist/eval/index.d.ts +1 -1
- package/dist/index.cjs +27 -27
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -6
- package/dist/integration/index.d.cts +1 -1
- package/dist/integration/index.d.ts +1 -1
- package/dist/llm/index.d.cts +1 -1
- package/dist/llm/index.d.ts +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.cts +1 -1
- package/dist/mastra/index.d.ts +1 -1
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +2 -2
- package/dist/memory/index.d.cts +1 -1
- package/dist/memory/index.d.ts +1 -1
- package/dist/memory/index.js +1 -1
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.d.cts +1 -1
- package/dist/relevance/index.d.ts +1 -1
- package/dist/relevance/index.js +1 -1
- package/dist/storage/index.d.cts +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/libsql/index.cjs +440 -10
- package/dist/storage/libsql/index.d.cts +1 -1
- package/dist/storage/libsql/index.d.ts +1 -1
- package/dist/storage/libsql/index.js +441 -1
- package/dist/telemetry/index.d.cts +1 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/tools/index.d.cts +2 -2
- package/dist/tools/index.d.ts +2 -2
- package/dist/utils.d.cts +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/workflows/index.cjs +17 -17
- package/dist/workflows/index.d.cts +2 -2
- package/dist/workflows/index.d.ts +2 -2
- package/dist/workflows/index.js +1 -1
- package/package.json +5 -5
- package/dist/chunk-QAZ2ONKM.js +0 -441
- package/dist/chunk-VA4P7QJT.cjs +0 -443
package/dist/agent/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
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
|
|
9
|
+
get: function () { return chunkWX2ECXAE_cjs.Agent; }
|
|
10
10
|
});
|
package/dist/agent/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Message as AiMessageType } from 'ai';
|
|
2
2
|
import 'json-schema';
|
|
3
3
|
import 'zod';
|
|
4
|
-
export { A as Agent, l as AgentConfig, ay as AgentGenerateOptions, az as AgentStreamOptions, aw as MastraLanguageModel, a as ToolsInput, ax as ToolsetsInput } from '../base-
|
|
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';
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { Message as AiMessageType } from 'ai';
|
|
2
2
|
import 'json-schema';
|
|
3
3
|
import 'zod';
|
|
4
|
-
export { A as Agent, l as AgentConfig, ay as AgentGenerateOptions, az as AgentStreamOptions, aw as MastraLanguageModel, a as ToolsInput, ax as ToolsetsInput } from '../base-
|
|
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';
|
package/dist/agent/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Agent } from '../chunk-
|
|
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<
|
|
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
|
|
608
|
+
* @deprecated use getTelemetry() instead
|
|
599
609
|
*/
|
|
600
|
-
|
|
610
|
+
get telemetry(): Telemetry | undefined;
|
|
601
611
|
/**
|
|
602
|
-
* @deprecated use
|
|
612
|
+
* @deprecated use getStorage() instead
|
|
603
613
|
*/
|
|
604
|
-
|
|
614
|
+
get storage(): MastraStorage | undefined;
|
|
605
615
|
/**
|
|
606
|
-
* @deprecated use
|
|
616
|
+
* @deprecated use getMemory() instead
|
|
607
617
|
*/
|
|
608
|
-
get
|
|
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<
|
|
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
|
|
608
|
+
* @deprecated use getTelemetry() instead
|
|
599
609
|
*/
|
|
600
|
-
|
|
610
|
+
get telemetry(): Telemetry | undefined;
|
|
601
611
|
/**
|
|
602
|
-
* @deprecated use
|
|
612
|
+
* @deprecated use getStorage() instead
|
|
603
613
|
*/
|
|
604
|
-
|
|
614
|
+
get storage(): MastraStorage | undefined;
|
|
605
615
|
/**
|
|
606
|
-
* @deprecated use
|
|
616
|
+
* @deprecated use getMemory() instead
|
|
607
617
|
*/
|
|
608
|
-
get
|
|
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 {
|
|
2
|
-
import { InstrumentClass,
|
|
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
|
|
24
|
+
* @deprecated use getTelemetry() instead
|
|
23
25
|
*/
|
|
24
|
-
|
|
26
|
+
get telemetry() {
|
|
27
|
+
return this.#telemetry;
|
|
28
|
+
}
|
|
25
29
|
/**
|
|
26
|
-
* @deprecated use
|
|
30
|
+
* @deprecated use getStorage() instead
|
|
27
31
|
*/
|
|
28
|
-
|
|
32
|
+
get storage() {
|
|
33
|
+
return this.#storage;
|
|
34
|
+
}
|
|
29
35
|
/**
|
|
30
|
-
* @deprecated use
|
|
36
|
+
* @deprecated use getMemory() instead
|
|
31
37
|
*/
|
|
32
|
-
get
|
|
33
|
-
return this.#
|
|
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
|
|
65
|
+
storage = new DefaultProxyStorage({
|
|
60
66
|
config: {
|
|
61
67
|
url: process.env.MASTRA_DEFAULT_STORAGE_URL || `:memory:`
|
|
62
68
|
}
|
|
63
69
|
});
|
|
64
70
|
}
|
|
65
|
-
|
|
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
|
|
73
|
+
this.#storage = this.#telemetry.traceClass(storage, {
|
|
91
74
|
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
92
75
|
});
|
|
93
|
-
this
|
|
76
|
+
this.#storage.__setTelemetry(this.#telemetry);
|
|
94
77
|
} else {
|
|
95
|
-
this
|
|
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
|
|
98
|
+
this.#memory = config.memory;
|
|
116
99
|
if (this.#telemetry) {
|
|
117
|
-
this
|
|
100
|
+
this.#memory = this.#telemetry.traceClass(config.memory, {
|
|
118
101
|
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
119
102
|
});
|
|
120
|
-
this
|
|
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
|
|
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
|
|
252
|
-
this
|
|
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
|
|
263
|
-
this
|
|
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
|
|
281
|
-
this
|
|
263
|
+
if (this.#memory) {
|
|
264
|
+
this.#memory = this.#telemetry.traceClass(this.#memory, {
|
|
282
265
|
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
283
266
|
});
|
|
284
|
-
this
|
|
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
|
|
305
|
-
this
|
|
287
|
+
if (this.#storage) {
|
|
288
|
+
this.#storage = this.#telemetry.traceClass(this.#storage, {
|
|
306
289
|
excludeMethods: ["__setTelemetry", "__getTelemetry"]
|
|
307
290
|
});
|
|
308
|
-
this
|
|
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
|
|
316
|
+
return this.#memory;
|
|
334
317
|
}
|
|
335
318
|
getStorage() {
|
|
336
|
-
return this
|
|
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;
|