@mastra/core 0.8.2 → 0.8.3-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/{LICENSE → LICENSE.md} +3 -1
- package/README.md +4 -4
- package/dist/agent/index.cjs +2 -2
- package/dist/agent/index.d.cts +2 -1
- package/dist/agent/index.d.ts +2 -1
- package/dist/agent/index.js +1 -1
- package/dist/{base-CRsNpPj6.d.cts → base-Ca8Hlcj4.d.cts} +34 -16
- package/dist/{base-D0afZZ9D.d.ts → base-Cb5pwtMe.d.ts} +34 -16
- package/dist/chunk-3PBEAM6M.js +69 -0
- package/dist/{chunk-IUU6FRPI.cjs → chunk-B23KFOTM.cjs} +33 -14
- package/dist/{chunk-MP3UIX44.cjs → chunk-EFNSCE3V.cjs} +114 -99
- package/dist/{chunk-4RMSGSQN.js → chunk-EO7KZJF6.js} +1 -1
- package/dist/{chunk-6BT5XRRD.cjs → chunk-FDVSKYK2.cjs} +2 -2
- package/dist/{chunk-26NMSLXS.js → chunk-G2E5PLJV.js} +1 -1
- package/dist/{chunk-7I7AKQH3.cjs → chunk-IPQW4HAT.cjs} +2 -2
- package/dist/{chunk-BC5B4EGI.js → chunk-K5TZKHR7.js} +4 -2
- package/dist/chunk-LZQIMLJV.cjs +71 -0
- package/dist/{chunk-Q5Q3V2SQ.js → chunk-MUM4UGX3.js} +32 -13
- package/dist/{chunk-64VPB7ZD.cjs → chunk-PY3DCT4A.cjs} +4 -2
- package/dist/{chunk-FFOLLSHP.js → chunk-TOA2RYEW.js} +101 -86
- package/dist/di/index.cjs +10 -0
- package/dist/di/index.d.cts +52 -0
- package/dist/di/index.d.ts +52 -0
- package/dist/di/index.js +1 -0
- package/dist/eval/index.d.cts +2 -1
- package/dist/eval/index.d.ts +2 -1
- package/dist/index.cjs +49 -49
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +8 -8
- package/dist/integration/index.cjs +3 -3
- package/dist/integration/index.d.cts +2 -1
- package/dist/integration/index.d.ts +2 -1
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.d.cts +2 -1
- package/dist/llm/index.d.ts +2 -1
- package/dist/mastra/index.d.cts +2 -1
- package/dist/mastra/index.d.ts +2 -1
- package/dist/memory/index.cjs +3 -3
- package/dist/memory/index.d.cts +2 -1
- package/dist/memory/index.d.ts +2 -1
- package/dist/memory/index.js +1 -1
- package/dist/network/index.cjs +4 -4
- package/dist/network/index.d.cts +2 -1
- package/dist/network/index.d.ts +2 -1
- package/dist/network/index.js +2 -2
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.d.cts +2 -1
- package/dist/relevance/index.d.ts +2 -1
- package/dist/relevance/index.js +1 -1
- package/dist/server/index.d.cts +2 -1
- package/dist/server/index.d.ts +2 -1
- package/dist/storage/index.d.cts +2 -1
- package/dist/storage/index.d.ts +2 -1
- package/dist/storage/libsql/index.d.cts +2 -1
- package/dist/storage/libsql/index.d.ts +2 -1
- package/dist/telemetry/index.d.cts +2 -1
- package/dist/telemetry/index.d.ts +2 -1
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.d.cts +2 -1
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.js +1 -1
- package/dist/utils.cjs +13 -13
- package/dist/utils.d.cts +3 -1
- package/dist/utils.d.ts +3 -1
- package/dist/utils.js +1 -1
- package/dist/voice/index.d.cts +3 -2
- package/dist/voice/index.d.ts +3 -2
- package/dist/workflows/index.cjs +23 -23
- package/dist/workflows/index.d.cts +3 -2
- package/dist/workflows/index.d.ts +3 -2
- package/dist/workflows/index.js +1 -1
- package/package.json +3 -3
package/{LICENSE → LICENSE.md}
RENAMED
package/README.md
CHANGED
|
@@ -84,7 +84,7 @@ const agent = new Agent({
|
|
|
84
84
|
});
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
[Memory documentation →](https://mastra.ai/
|
|
87
|
+
[Memory documentation →](https://mastra.ai/reference/memory/Memory)
|
|
88
88
|
|
|
89
89
|
### Tools (`/tools`)
|
|
90
90
|
|
|
@@ -147,7 +147,7 @@ const logger = createLogger({
|
|
|
147
147
|
});
|
|
148
148
|
```
|
|
149
149
|
|
|
150
|
-
[More logging documentation →](https://mastra.ai/
|
|
150
|
+
[More logging documentation →](https://mastra.ai/reference/observability/logging)
|
|
151
151
|
|
|
152
152
|
### Telemetry (`/telemetry`)
|
|
153
153
|
|
|
@@ -172,11 +172,11 @@ const mastra = new Mastra({
|
|
|
172
172
|
});
|
|
173
173
|
```
|
|
174
174
|
|
|
175
|
-
[More Telemetry documentation →](https://mastra.ai/
|
|
175
|
+
[More Telemetry documentation →](https://mastra.ai/reference/observability/telemetry)
|
|
176
176
|
|
|
177
177
|
## Additional Resources
|
|
178
178
|
|
|
179
179
|
- [Getting Started Guide](https://mastra.ai/docs/getting-started/installation)
|
|
180
|
-
- [API Reference](https://mastra.ai/
|
|
180
|
+
- [API Reference](https://mastra.ai/reference)
|
|
181
181
|
- [Examples](https://mastra.ai/docs/examples)
|
|
182
182
|
- [Deployment Guide](https://mastra.ai/docs/deployment/overview)
|
package/dist/agent/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkEFNSCE3V_cjs = require('../chunk-EFNSCE3V.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 chunkEFNSCE3V_cjs.Agent; }
|
|
10
10
|
});
|
package/dist/agent/index.d.cts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { Message as AiMessageType } from 'ai';
|
|
2
2
|
import 'json-schema';
|
|
3
3
|
import 'zod';
|
|
4
|
-
export { j as Agent, k as AgentConfig, aM as AgentGenerateOptions, aN as AgentStreamOptions, aG as MastraLanguageModel, aH as ToolsInput, aL as ToolsetsInput } from '../base-
|
|
4
|
+
export { j as Agent, k as AgentConfig, aM as AgentGenerateOptions, aN as AgentStreamOptions, aG as MastraLanguageModel, aH as ToolsInput, aL as ToolsetsInput } from '../base-Ca8Hlcj4.cjs';
|
|
5
5
|
import '../base-BihKcqDY.cjs';
|
|
6
|
+
import '../di/index.cjs';
|
|
6
7
|
import '../types-BtMyV38I.cjs';
|
|
7
8
|
import 'sift';
|
|
8
9
|
import '../index-CquI0inB.cjs';
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export { Message as AiMessageType } from 'ai';
|
|
2
2
|
import 'json-schema';
|
|
3
3
|
import 'zod';
|
|
4
|
-
export { j as Agent, k as AgentConfig, aM as AgentGenerateOptions, aN as AgentStreamOptions, aG as MastraLanguageModel, aH as ToolsInput, aL as ToolsetsInput } from '../base-
|
|
4
|
+
export { j as Agent, k as AgentConfig, aM as AgentGenerateOptions, aN as AgentStreamOptions, aG as MastraLanguageModel, aH as ToolsInput, aL as ToolsetsInput } from '../base-Cb5pwtMe.js';
|
|
5
5
|
import '../base-DT2poiVK.js';
|
|
6
|
+
import '../di/index.js';
|
|
6
7
|
import '../types-BtMyV38I.js';
|
|
7
8
|
import 'sift';
|
|
8
9
|
import '../index-CquI0inB.js';
|
package/dist/agent/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Agent } from '../chunk-
|
|
1
|
+
export { Agent } from '../chunk-TOA2RYEW.js';
|
|
@@ -5,6 +5,7 @@ import { a as Metric, M as MetricResult, T as TestInfo } from './types-BtMyV38I.
|
|
|
5
5
|
import { Query } from 'sift';
|
|
6
6
|
import { z, ZodSchema } from 'zod';
|
|
7
7
|
import { JSONSchema7 } from 'json-schema';
|
|
8
|
+
import { Container } from './di/index.cjs';
|
|
8
9
|
import { B as BaseLogMessage, R as RegisteredLogger, L as Logger, d as Run } from './index-CquI0inB.cjs';
|
|
9
10
|
import { Span } from '@opentelemetry/api';
|
|
10
11
|
import * as xstate from 'xstate';
|
|
@@ -33,6 +34,7 @@ type CoreTool = {
|
|
|
33
34
|
});
|
|
34
35
|
interface ToolExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefined> extends IExecutionContext<TSchemaIn> {
|
|
35
36
|
mastra?: MastraUnion;
|
|
37
|
+
container: Container;
|
|
36
38
|
}
|
|
37
39
|
interface ToolAction<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>> extends IAction<string, TSchemaIn, TSchemaOut, TContext, ToolExecutionOptions> {
|
|
38
40
|
description: string;
|
|
@@ -191,6 +193,7 @@ interface StepExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undef
|
|
|
191
193
|
runId: string;
|
|
192
194
|
emit: (event: string, data: any) => void;
|
|
193
195
|
mastra?: MastraUnion;
|
|
196
|
+
container: Container;
|
|
194
197
|
}
|
|
195
198
|
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> {
|
|
196
199
|
mastra?: Mastra;
|
|
@@ -565,9 +568,10 @@ declare class Machine<TSteps extends Step<any, any, any, any>[] = Step<any, any,
|
|
|
565
568
|
#private;
|
|
566
569
|
logger: Logger;
|
|
567
570
|
name: string;
|
|
568
|
-
constructor({ logger, mastra, workflowInstance, executionSpan, name, runId, steps, stepGraph, retryConfig, startStepId, }: {
|
|
571
|
+
constructor({ logger, mastra, container, workflowInstance, executionSpan, name, runId, steps, stepGraph, retryConfig, startStepId, }: {
|
|
569
572
|
logger: Logger;
|
|
570
573
|
mastra?: Mastra;
|
|
574
|
+
container: Container;
|
|
571
575
|
workflowInstance: WorkflowInstance;
|
|
572
576
|
executionSpan?: Span;
|
|
573
577
|
name: string;
|
|
@@ -939,13 +943,15 @@ interface WorkflowResultReturn<TResult extends z.ZodObject<any>, T extends z.Zod
|
|
|
939
943
|
runId: string;
|
|
940
944
|
start: (props?: {
|
|
941
945
|
triggerData?: z.infer<T>;
|
|
946
|
+
container?: Container;
|
|
942
947
|
} | undefined) => Promise<WorkflowRunResult<T, TSteps, TResult>>;
|
|
943
948
|
watch: (onTransition: (state: Pick<WorkflowRunResult<T, TSteps, TResult>, 'results' | 'activePaths' | 'runId'>) => void) => () => void;
|
|
944
949
|
resume: (props: {
|
|
945
950
|
stepId: string;
|
|
946
951
|
context?: Record<string, any>;
|
|
952
|
+
container?: Container;
|
|
947
953
|
}) => Promise<Omit<WorkflowRunResult<T, TSteps, TResult>, 'runId'> | undefined>;
|
|
948
|
-
resumeWithEvent: (eventName: string, data: any) => Promise<Omit<WorkflowRunResult<T, TSteps, TResult>, 'runId'> | undefined>;
|
|
954
|
+
resumeWithEvent: (eventName: string, data: any, container?: Container) => Promise<Omit<WorkflowRunResult<T, TSteps, TResult>, 'runId'> | undefined>;
|
|
949
955
|
}
|
|
950
956
|
declare class WorkflowInstance<TSteps extends Step<any, any, any, any>[] = Step<any, any, any, any>[], TTriggerSchema extends z.ZodObject<any> = any, TResult extends z.ZodObject<any> = any> implements WorkflowResultReturn<TResult, TTriggerSchema, TSteps> {
|
|
951
957
|
#private;
|
|
@@ -977,8 +983,9 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any, any>[] = Step<
|
|
|
977
983
|
get runId(): string;
|
|
978
984
|
get executionSpan(): Span | undefined;
|
|
979
985
|
watch(onTransition: (state: Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, 'results' | 'activePaths' | 'runId' | 'timestamp'>) => void): () => void;
|
|
980
|
-
start({ triggerData }?: {
|
|
986
|
+
start({ triggerData, container }?: {
|
|
981
987
|
triggerData?: z.infer<TTriggerSchema>;
|
|
988
|
+
container?: Container;
|
|
982
989
|
}): Promise<{
|
|
983
990
|
runId: string;
|
|
984
991
|
timestamp: number;
|
|
@@ -992,28 +999,31 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any, any>[] = Step<
|
|
|
992
999
|
}>;
|
|
993
1000
|
}>;
|
|
994
1001
|
private isCompoundDependencyMet;
|
|
995
|
-
execute({ triggerData, snapshot, stepId, resumeData, }?: {
|
|
1002
|
+
execute({ triggerData, snapshot, stepId, resumeData, container, }?: {
|
|
996
1003
|
stepId?: string;
|
|
997
1004
|
triggerData?: z.infer<TTriggerSchema>;
|
|
998
1005
|
snapshot?: Snapshot<any>;
|
|
999
1006
|
resumeData?: any;
|
|
1007
|
+
container: Container;
|
|
1000
1008
|
}): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, 'runId'>>;
|
|
1001
1009
|
hasSubscribers(stepId: string): boolean;
|
|
1002
|
-
runMachine(parentStepId: string, input: any): Promise<(Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId" | "timestamp" | "results" | "activePaths"> | undefined)[]>;
|
|
1010
|
+
runMachine(parentStepId: string, input: any, container?: Container): Promise<(Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId" | "timestamp" | "results" | "activePaths"> | undefined)[]>;
|
|
1003
1011
|
suspend(stepId: string, machine: Machine<TSteps, TTriggerSchema>): Promise<void>;
|
|
1004
1012
|
/**
|
|
1005
1013
|
* Persists the workflow state to the database
|
|
1006
1014
|
*/
|
|
1007
1015
|
persistWorkflowSnapshot(): Promise<void>;
|
|
1008
1016
|
getState(): Promise<WorkflowRunState | null>;
|
|
1009
|
-
resumeWithEvent(eventName: string, data: any): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
|
|
1010
|
-
resume({ stepId, context: resumeContext }: {
|
|
1017
|
+
resumeWithEvent(eventName: string, data: any, container?: Container): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
|
|
1018
|
+
resume({ stepId, context: resumeContext, container, }: {
|
|
1011
1019
|
stepId: string;
|
|
1012
1020
|
context?: Record<string, any>;
|
|
1021
|
+
container?: Container;
|
|
1013
1022
|
}): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
|
|
1014
|
-
_resume({ stepId, context: resumeContext }: {
|
|
1023
|
+
_resume({ stepId, context: resumeContext, container, }: {
|
|
1015
1024
|
stepId: string;
|
|
1016
1025
|
context?: Record<string, any>;
|
|
1026
|
+
container: Container;
|
|
1017
1027
|
}): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
|
|
1018
1028
|
}
|
|
1019
1029
|
|
|
@@ -1082,10 +1092,11 @@ declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, an
|
|
|
1082
1092
|
getWorkflowRuns(): Promise<WorkflowRuns>;
|
|
1083
1093
|
getExecutionSpan(runId: string): Span | undefined;
|
|
1084
1094
|
getState(runId: string): Promise<WorkflowRunState | null>;
|
|
1085
|
-
resume({ runId, stepId, context: resumeContext, }: {
|
|
1095
|
+
resume({ runId, stepId, context: resumeContext, container, }: {
|
|
1086
1096
|
runId: string;
|
|
1087
1097
|
stepId: string;
|
|
1088
1098
|
context?: Record<string, any>;
|
|
1099
|
+
container: Container;
|
|
1089
1100
|
}): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, any>, "runId"> | undefined>;
|
|
1090
1101
|
watch(onTransition: (state: Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResultSchema>, 'results' | 'activePaths' | 'runId' | 'timestamp'>) => void): () => void;
|
|
1091
1102
|
resumeWithEvent(runId: string, eventName: string, data: any): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, any>, "runId"> | undefined>;
|
|
@@ -1124,8 +1135,8 @@ declare abstract class MemoryProcessor extends MastraBase {
|
|
|
1124
1135
|
declare abstract class MastraMemory extends MastraBase {
|
|
1125
1136
|
MAX_CONTEXT_TOKENS?: number;
|
|
1126
1137
|
storage: MastraStorage;
|
|
1127
|
-
vector
|
|
1128
|
-
embedder
|
|
1138
|
+
vector?: MastraVector;
|
|
1139
|
+
embedder?: EmbeddingModel<string>;
|
|
1129
1140
|
private processors;
|
|
1130
1141
|
protected threadConfig: MemoryConfig;
|
|
1131
1142
|
constructor(config: {
|
|
@@ -1309,6 +1320,7 @@ type MastraCustomLLMOptions<Z extends ZodSchema | JSONSchema7 | undefined = unde
|
|
|
1309
1320
|
telemetry?: TelemetrySettings;
|
|
1310
1321
|
threadId?: string;
|
|
1311
1322
|
resourceId?: string;
|
|
1323
|
+
container: Container;
|
|
1312
1324
|
} & Run;
|
|
1313
1325
|
type LLMTextOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
1314
1326
|
messages: CoreMessage[];
|
|
@@ -1568,6 +1580,8 @@ type AgentGenerateOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefi
|
|
|
1568
1580
|
};
|
|
1569
1581
|
/** Telemetry settings */
|
|
1570
1582
|
telemetry?: TelemetrySettings;
|
|
1583
|
+
/** Container for dependency injection */
|
|
1584
|
+
container?: Container;
|
|
1571
1585
|
} & ({
|
|
1572
1586
|
resourceId?: undefined;
|
|
1573
1587
|
threadId?: undefined;
|
|
@@ -1609,6 +1623,8 @@ type AgentStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefine
|
|
|
1609
1623
|
experimental_output?: Z;
|
|
1610
1624
|
/** Telemetry settings */
|
|
1611
1625
|
telemetry?: TelemetrySettings;
|
|
1626
|
+
/** Container for dependency injection */
|
|
1627
|
+
container?: Container;
|
|
1612
1628
|
} & ({
|
|
1613
1629
|
resourceId?: undefined;
|
|
1614
1630
|
threadId?: undefined;
|
|
@@ -1758,10 +1774,10 @@ declare class MastraLLMBase extends MastraBase {
|
|
|
1758
1774
|
__registerMastra(p: Mastra): void;
|
|
1759
1775
|
__text<Z extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextOptions<Z>): Promise<GenerateTextResult<any, any>>;
|
|
1760
1776
|
__textObject<T extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextObjectOptions<T>): Promise<GenerateObjectResult<T>>;
|
|
1761
|
-
generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options
|
|
1777
|
+
generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options: LLMStreamOptions<Z>): Promise<GenerateReturn<Z>>;
|
|
1762
1778
|
__stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(input: LLMInnerStreamOptions<Z>): Promise<StreamTextResult<any, any>>;
|
|
1763
1779
|
__streamObject<T extends ZodSchema | JSONSchema7 | undefined>(input: LLMStreamObjectOptions<T>): Promise<StreamObjectResult<DeepPartial<T>, T, never>>;
|
|
1764
|
-
stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options
|
|
1780
|
+
stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options: LLMStreamOptions<Z>): Promise<StreamReturn<Z>>;
|
|
1765
1781
|
}
|
|
1766
1782
|
|
|
1767
1783
|
declare class Agent<TAgentId extends string = string, TTools extends ToolsInput = ToolsInput, TMetrics extends Record<string, Metric> = Record<string, Metric>> extends MastraBase {
|
|
@@ -1807,11 +1823,12 @@ declare class Agent<TAgentId extends string = string, TTools extends ToolsInput
|
|
|
1807
1823
|
}>;
|
|
1808
1824
|
private getResponseMessages;
|
|
1809
1825
|
sanitizeResponseMessages(messages: Array<CoreMessage$1>): Array<CoreMessage$1>;
|
|
1810
|
-
convertTools({ toolsets, threadId, resourceId, runId, }: {
|
|
1826
|
+
convertTools({ toolsets, threadId, resourceId, runId, container, }: {
|
|
1811
1827
|
toolsets?: ToolsetsInput;
|
|
1812
1828
|
threadId?: string;
|
|
1813
1829
|
resourceId?: string;
|
|
1814
1830
|
runId?: string;
|
|
1831
|
+
container: Container;
|
|
1815
1832
|
}): Record<string, CoreTool>;
|
|
1816
1833
|
preExecute({ resourceId, runId, threadId, thread, memoryConfig, messages, systemMessage, }: {
|
|
1817
1834
|
runId?: string;
|
|
@@ -1825,7 +1842,7 @@ declare class Agent<TAgentId extends string = string, TTools extends ToolsInput
|
|
|
1825
1842
|
coreMessages: CoreMessage$1[];
|
|
1826
1843
|
threadIdToUse: string;
|
|
1827
1844
|
}>;
|
|
1828
|
-
__primitive({ instructions, messages, context, threadId, memoryConfig, resourceId, runId, toolsets, }: {
|
|
1845
|
+
__primitive({ instructions, messages, context, threadId, memoryConfig, resourceId, runId, toolsets, container, }: {
|
|
1829
1846
|
instructions?: string;
|
|
1830
1847
|
toolsets?: ToolsetsInput;
|
|
1831
1848
|
resourceId?: string;
|
|
@@ -1834,6 +1851,7 @@ declare class Agent<TAgentId extends string = string, TTools extends ToolsInput
|
|
|
1834
1851
|
context?: CoreMessage$1[];
|
|
1835
1852
|
runId?: string;
|
|
1836
1853
|
messages: CoreMessage$1[];
|
|
1854
|
+
container: Container;
|
|
1837
1855
|
}): {
|
|
1838
1856
|
before: () => Promise<{
|
|
1839
1857
|
messageObjects: CoreMessage$1[];
|
|
@@ -2021,7 +2039,7 @@ type MemoryConfig = {
|
|
|
2021
2039
|
type SharedMemoryConfig = {
|
|
2022
2040
|
storage?: MastraStorage;
|
|
2023
2041
|
options?: MemoryConfig;
|
|
2024
|
-
vector?: MastraVector;
|
|
2042
|
+
vector?: MastraVector | false;
|
|
2025
2043
|
embedder?: EmbeddingModel<string>;
|
|
2026
2044
|
processors?: MemoryProcessor[];
|
|
2027
2045
|
};
|
|
@@ -5,6 +5,7 @@ import { a as Metric, M as MetricResult, T as TestInfo } from './types-BtMyV38I.
|
|
|
5
5
|
import { Query } from 'sift';
|
|
6
6
|
import { z, ZodSchema } from 'zod';
|
|
7
7
|
import { JSONSchema7 } from 'json-schema';
|
|
8
|
+
import { Container } from './di/index.js';
|
|
8
9
|
import { B as BaseLogMessage, R as RegisteredLogger, L as Logger, d as Run } from './index-CquI0inB.js';
|
|
9
10
|
import { Span } from '@opentelemetry/api';
|
|
10
11
|
import * as xstate from 'xstate';
|
|
@@ -33,6 +34,7 @@ type CoreTool = {
|
|
|
33
34
|
});
|
|
34
35
|
interface ToolExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undefined> extends IExecutionContext<TSchemaIn> {
|
|
35
36
|
mastra?: MastraUnion;
|
|
37
|
+
container: Container;
|
|
36
38
|
}
|
|
37
39
|
interface ToolAction<TSchemaIn extends z.ZodSchema | undefined = undefined, TSchemaOut extends z.ZodSchema | undefined = undefined, TContext extends ToolExecutionContext<TSchemaIn> = ToolExecutionContext<TSchemaIn>> extends IAction<string, TSchemaIn, TSchemaOut, TContext, ToolExecutionOptions> {
|
|
38
40
|
description: string;
|
|
@@ -191,6 +193,7 @@ interface StepExecutionContext<TSchemaIn extends z.ZodSchema | undefined = undef
|
|
|
191
193
|
runId: string;
|
|
192
194
|
emit: (event: string, data: any) => void;
|
|
193
195
|
mastra?: MastraUnion;
|
|
196
|
+
container: Container;
|
|
194
197
|
}
|
|
195
198
|
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> {
|
|
196
199
|
mastra?: Mastra;
|
|
@@ -565,9 +568,10 @@ declare class Machine<TSteps extends Step<any, any, any, any>[] = Step<any, any,
|
|
|
565
568
|
#private;
|
|
566
569
|
logger: Logger;
|
|
567
570
|
name: string;
|
|
568
|
-
constructor({ logger, mastra, workflowInstance, executionSpan, name, runId, steps, stepGraph, retryConfig, startStepId, }: {
|
|
571
|
+
constructor({ logger, mastra, container, workflowInstance, executionSpan, name, runId, steps, stepGraph, retryConfig, startStepId, }: {
|
|
569
572
|
logger: Logger;
|
|
570
573
|
mastra?: Mastra;
|
|
574
|
+
container: Container;
|
|
571
575
|
workflowInstance: WorkflowInstance;
|
|
572
576
|
executionSpan?: Span;
|
|
573
577
|
name: string;
|
|
@@ -939,13 +943,15 @@ interface WorkflowResultReturn<TResult extends z.ZodObject<any>, T extends z.Zod
|
|
|
939
943
|
runId: string;
|
|
940
944
|
start: (props?: {
|
|
941
945
|
triggerData?: z.infer<T>;
|
|
946
|
+
container?: Container;
|
|
942
947
|
} | undefined) => Promise<WorkflowRunResult<T, TSteps, TResult>>;
|
|
943
948
|
watch: (onTransition: (state: Pick<WorkflowRunResult<T, TSteps, TResult>, 'results' | 'activePaths' | 'runId'>) => void) => () => void;
|
|
944
949
|
resume: (props: {
|
|
945
950
|
stepId: string;
|
|
946
951
|
context?: Record<string, any>;
|
|
952
|
+
container?: Container;
|
|
947
953
|
}) => Promise<Omit<WorkflowRunResult<T, TSteps, TResult>, 'runId'> | undefined>;
|
|
948
|
-
resumeWithEvent: (eventName: string, data: any) => Promise<Omit<WorkflowRunResult<T, TSteps, TResult>, 'runId'> | undefined>;
|
|
954
|
+
resumeWithEvent: (eventName: string, data: any, container?: Container) => Promise<Omit<WorkflowRunResult<T, TSteps, TResult>, 'runId'> | undefined>;
|
|
949
955
|
}
|
|
950
956
|
declare class WorkflowInstance<TSteps extends Step<any, any, any, any>[] = Step<any, any, any, any>[], TTriggerSchema extends z.ZodObject<any> = any, TResult extends z.ZodObject<any> = any> implements WorkflowResultReturn<TResult, TTriggerSchema, TSteps> {
|
|
951
957
|
#private;
|
|
@@ -977,8 +983,9 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any, any>[] = Step<
|
|
|
977
983
|
get runId(): string;
|
|
978
984
|
get executionSpan(): Span | undefined;
|
|
979
985
|
watch(onTransition: (state: Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, 'results' | 'activePaths' | 'runId' | 'timestamp'>) => void): () => void;
|
|
980
|
-
start({ triggerData }?: {
|
|
986
|
+
start({ triggerData, container }?: {
|
|
981
987
|
triggerData?: z.infer<TTriggerSchema>;
|
|
988
|
+
container?: Container;
|
|
982
989
|
}): Promise<{
|
|
983
990
|
runId: string;
|
|
984
991
|
timestamp: number;
|
|
@@ -992,28 +999,31 @@ declare class WorkflowInstance<TSteps extends Step<any, any, any, any>[] = Step<
|
|
|
992
999
|
}>;
|
|
993
1000
|
}>;
|
|
994
1001
|
private isCompoundDependencyMet;
|
|
995
|
-
execute({ triggerData, snapshot, stepId, resumeData, }?: {
|
|
1002
|
+
execute({ triggerData, snapshot, stepId, resumeData, container, }?: {
|
|
996
1003
|
stepId?: string;
|
|
997
1004
|
triggerData?: z.infer<TTriggerSchema>;
|
|
998
1005
|
snapshot?: Snapshot<any>;
|
|
999
1006
|
resumeData?: any;
|
|
1007
|
+
container: Container;
|
|
1000
1008
|
}): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, 'runId'>>;
|
|
1001
1009
|
hasSubscribers(stepId: string): boolean;
|
|
1002
|
-
runMachine(parentStepId: string, input: any): Promise<(Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId" | "timestamp" | "results" | "activePaths"> | undefined)[]>;
|
|
1010
|
+
runMachine(parentStepId: string, input: any, container?: Container): Promise<(Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId" | "timestamp" | "results" | "activePaths"> | undefined)[]>;
|
|
1003
1011
|
suspend(stepId: string, machine: Machine<TSteps, TTriggerSchema>): Promise<void>;
|
|
1004
1012
|
/**
|
|
1005
1013
|
* Persists the workflow state to the database
|
|
1006
1014
|
*/
|
|
1007
1015
|
persistWorkflowSnapshot(): Promise<void>;
|
|
1008
1016
|
getState(): Promise<WorkflowRunState | null>;
|
|
1009
|
-
resumeWithEvent(eventName: string, data: any): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
|
|
1010
|
-
resume({ stepId, context: resumeContext }: {
|
|
1017
|
+
resumeWithEvent(eventName: string, data: any, container?: Container): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
|
|
1018
|
+
resume({ stepId, context: resumeContext, container, }: {
|
|
1011
1019
|
stepId: string;
|
|
1012
1020
|
context?: Record<string, any>;
|
|
1021
|
+
container?: Container;
|
|
1013
1022
|
}): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
|
|
1014
|
-
_resume({ stepId, context: resumeContext }: {
|
|
1023
|
+
_resume({ stepId, context: resumeContext, container, }: {
|
|
1015
1024
|
stepId: string;
|
|
1016
1025
|
context?: Record<string, any>;
|
|
1026
|
+
container: Container;
|
|
1017
1027
|
}): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, TResult>, "runId"> | undefined>;
|
|
1018
1028
|
}
|
|
1019
1029
|
|
|
@@ -1082,10 +1092,11 @@ declare class Workflow<TSteps extends Step<string, any, any>[] = Step<string, an
|
|
|
1082
1092
|
getWorkflowRuns(): Promise<WorkflowRuns>;
|
|
1083
1093
|
getExecutionSpan(runId: string): Span | undefined;
|
|
1084
1094
|
getState(runId: string): Promise<WorkflowRunState | null>;
|
|
1085
|
-
resume({ runId, stepId, context: resumeContext, }: {
|
|
1095
|
+
resume({ runId, stepId, context: resumeContext, container, }: {
|
|
1086
1096
|
runId: string;
|
|
1087
1097
|
stepId: string;
|
|
1088
1098
|
context?: Record<string, any>;
|
|
1099
|
+
container: Container;
|
|
1089
1100
|
}): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, any>, "runId"> | undefined>;
|
|
1090
1101
|
watch(onTransition: (state: Pick<WorkflowRunResult<TTriggerSchema, TSteps, TResultSchema>, 'results' | 'activePaths' | 'runId' | 'timestamp'>) => void): () => void;
|
|
1091
1102
|
resumeWithEvent(runId: string, eventName: string, data: any): Promise<Omit<WorkflowRunResult<TTriggerSchema, TSteps, any>, "runId"> | undefined>;
|
|
@@ -1124,8 +1135,8 @@ declare abstract class MemoryProcessor extends MastraBase {
|
|
|
1124
1135
|
declare abstract class MastraMemory extends MastraBase {
|
|
1125
1136
|
MAX_CONTEXT_TOKENS?: number;
|
|
1126
1137
|
storage: MastraStorage;
|
|
1127
|
-
vector
|
|
1128
|
-
embedder
|
|
1138
|
+
vector?: MastraVector;
|
|
1139
|
+
embedder?: EmbeddingModel<string>;
|
|
1129
1140
|
private processors;
|
|
1130
1141
|
protected threadConfig: MemoryConfig;
|
|
1131
1142
|
constructor(config: {
|
|
@@ -1309,6 +1320,7 @@ type MastraCustomLLMOptions<Z extends ZodSchema | JSONSchema7 | undefined = unde
|
|
|
1309
1320
|
telemetry?: TelemetrySettings;
|
|
1310
1321
|
threadId?: string;
|
|
1311
1322
|
resourceId?: string;
|
|
1323
|
+
container: Container;
|
|
1312
1324
|
} & Run;
|
|
1313
1325
|
type LLMTextOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefined> = {
|
|
1314
1326
|
messages: CoreMessage[];
|
|
@@ -1568,6 +1580,8 @@ type AgentGenerateOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefi
|
|
|
1568
1580
|
};
|
|
1569
1581
|
/** Telemetry settings */
|
|
1570
1582
|
telemetry?: TelemetrySettings;
|
|
1583
|
+
/** Container for dependency injection */
|
|
1584
|
+
container?: Container;
|
|
1571
1585
|
} & ({
|
|
1572
1586
|
resourceId?: undefined;
|
|
1573
1587
|
threadId?: undefined;
|
|
@@ -1609,6 +1623,8 @@ type AgentStreamOptions<Z extends ZodSchema | JSONSchema7 | undefined = undefine
|
|
|
1609
1623
|
experimental_output?: Z;
|
|
1610
1624
|
/** Telemetry settings */
|
|
1611
1625
|
telemetry?: TelemetrySettings;
|
|
1626
|
+
/** Container for dependency injection */
|
|
1627
|
+
container?: Container;
|
|
1612
1628
|
} & ({
|
|
1613
1629
|
resourceId?: undefined;
|
|
1614
1630
|
threadId?: undefined;
|
|
@@ -1758,10 +1774,10 @@ declare class MastraLLMBase extends MastraBase {
|
|
|
1758
1774
|
__registerMastra(p: Mastra): void;
|
|
1759
1775
|
__text<Z extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextOptions<Z>): Promise<GenerateTextResult<any, any>>;
|
|
1760
1776
|
__textObject<T extends ZodSchema | JSONSchema7 | undefined>(input: LLMTextObjectOptions<T>): Promise<GenerateObjectResult<T>>;
|
|
1761
|
-
generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options
|
|
1777
|
+
generate<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options: LLMStreamOptions<Z>): Promise<GenerateReturn<Z>>;
|
|
1762
1778
|
__stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(input: LLMInnerStreamOptions<Z>): Promise<StreamTextResult<any, any>>;
|
|
1763
1779
|
__streamObject<T extends ZodSchema | JSONSchema7 | undefined>(input: LLMStreamObjectOptions<T>): Promise<StreamObjectResult<DeepPartial<T>, T, never>>;
|
|
1764
|
-
stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options
|
|
1780
|
+
stream<Z extends ZodSchema | JSONSchema7 | undefined = undefined>(messages: string | string[] | CoreMessage$1[], options: LLMStreamOptions<Z>): Promise<StreamReturn<Z>>;
|
|
1765
1781
|
}
|
|
1766
1782
|
|
|
1767
1783
|
declare class Agent<TAgentId extends string = string, TTools extends ToolsInput = ToolsInput, TMetrics extends Record<string, Metric> = Record<string, Metric>> extends MastraBase {
|
|
@@ -1807,11 +1823,12 @@ declare class Agent<TAgentId extends string = string, TTools extends ToolsInput
|
|
|
1807
1823
|
}>;
|
|
1808
1824
|
private getResponseMessages;
|
|
1809
1825
|
sanitizeResponseMessages(messages: Array<CoreMessage$1>): Array<CoreMessage$1>;
|
|
1810
|
-
convertTools({ toolsets, threadId, resourceId, runId, }: {
|
|
1826
|
+
convertTools({ toolsets, threadId, resourceId, runId, container, }: {
|
|
1811
1827
|
toolsets?: ToolsetsInput;
|
|
1812
1828
|
threadId?: string;
|
|
1813
1829
|
resourceId?: string;
|
|
1814
1830
|
runId?: string;
|
|
1831
|
+
container: Container;
|
|
1815
1832
|
}): Record<string, CoreTool>;
|
|
1816
1833
|
preExecute({ resourceId, runId, threadId, thread, memoryConfig, messages, systemMessage, }: {
|
|
1817
1834
|
runId?: string;
|
|
@@ -1825,7 +1842,7 @@ declare class Agent<TAgentId extends string = string, TTools extends ToolsInput
|
|
|
1825
1842
|
coreMessages: CoreMessage$1[];
|
|
1826
1843
|
threadIdToUse: string;
|
|
1827
1844
|
}>;
|
|
1828
|
-
__primitive({ instructions, messages, context, threadId, memoryConfig, resourceId, runId, toolsets, }: {
|
|
1845
|
+
__primitive({ instructions, messages, context, threadId, memoryConfig, resourceId, runId, toolsets, container, }: {
|
|
1829
1846
|
instructions?: string;
|
|
1830
1847
|
toolsets?: ToolsetsInput;
|
|
1831
1848
|
resourceId?: string;
|
|
@@ -1834,6 +1851,7 @@ declare class Agent<TAgentId extends string = string, TTools extends ToolsInput
|
|
|
1834
1851
|
context?: CoreMessage$1[];
|
|
1835
1852
|
runId?: string;
|
|
1836
1853
|
messages: CoreMessage$1[];
|
|
1854
|
+
container: Container;
|
|
1837
1855
|
}): {
|
|
1838
1856
|
before: () => Promise<{
|
|
1839
1857
|
messageObjects: CoreMessage$1[];
|
|
@@ -2021,7 +2039,7 @@ type MemoryConfig = {
|
|
|
2021
2039
|
type SharedMemoryConfig = {
|
|
2022
2040
|
storage?: MastraStorage;
|
|
2023
2041
|
options?: MemoryConfig;
|
|
2024
|
-
vector?: MastraVector;
|
|
2042
|
+
vector?: MastraVector | false;
|
|
2025
2043
|
embedder?: EmbeddingModel<string>;
|
|
2026
2044
|
processors?: MemoryProcessor[];
|
|
2027
2045
|
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// src/di/index.ts
|
|
2
|
+
var Container = class {
|
|
3
|
+
registry = /* @__PURE__ */ new Map();
|
|
4
|
+
constructor(iterable) {
|
|
5
|
+
this.registry = new Map(iterable);
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* set a value with strict typing if `Values` is a Record and the key exists in it.
|
|
9
|
+
*/
|
|
10
|
+
set(key, value) {
|
|
11
|
+
this.registry.set(key, value);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Get a value with its type
|
|
15
|
+
*/
|
|
16
|
+
get(key) {
|
|
17
|
+
return this.registry.get(key);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Check if a key exists in the container
|
|
21
|
+
*/
|
|
22
|
+
has(key) {
|
|
23
|
+
return this.registry.has(key);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Delete a value by key
|
|
27
|
+
*/
|
|
28
|
+
delete(key) {
|
|
29
|
+
return this.registry.delete(key);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Clear all values from the container
|
|
33
|
+
*/
|
|
34
|
+
clear() {
|
|
35
|
+
this.registry.clear();
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Get all keys in the container
|
|
39
|
+
*/
|
|
40
|
+
keys() {
|
|
41
|
+
return this.registry.keys();
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Get all values in the container
|
|
45
|
+
*/
|
|
46
|
+
values() {
|
|
47
|
+
return this.registry.values();
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Get all entries in the container
|
|
51
|
+
*/
|
|
52
|
+
entries() {
|
|
53
|
+
return this.registry.entries();
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Get the size of the container
|
|
57
|
+
*/
|
|
58
|
+
size() {
|
|
59
|
+
return this.registry.size;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Execute a function for each entry in the container
|
|
63
|
+
*/
|
|
64
|
+
forEach(callbackfn) {
|
|
65
|
+
this.registry.forEach(callbackfn);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export { Container };
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var chunkAAMFAGE5_cjs = require('./chunk-AAMFAGE5.cjs');
|
|
4
4
|
var chunk2LIFCMY6_cjs = require('./chunk-2LIFCMY6.cjs');
|
|
5
|
-
var
|
|
5
|
+
var chunkPY3DCT4A_cjs = require('./chunk-PY3DCT4A.cjs');
|
|
6
6
|
var chunkD63P5O4Q_cjs = require('./chunk-D63P5O4Q.cjs');
|
|
7
7
|
var fs = require('fs');
|
|
8
8
|
var path = require('path');
|
|
@@ -139,14 +139,27 @@ var MastraMemory = class extends chunkD63P5O4Q_cjs.MastraBase {
|
|
|
139
139
|
};
|
|
140
140
|
constructor(config) {
|
|
141
141
|
super({ component: "MEMORY", name: config.name });
|
|
142
|
-
|
|
143
|
-
config
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (config.vector) {
|
|
148
|
-
this.vector = config.vector;
|
|
142
|
+
if (config.options) {
|
|
143
|
+
this.threadConfig = this.getMergedThreadConfig(config.options);
|
|
144
|
+
}
|
|
145
|
+
if (config.storage) {
|
|
146
|
+
this.storage = config.storage;
|
|
149
147
|
} else {
|
|
148
|
+
this.storage = new chunk2LIFCMY6_cjs.DefaultProxyStorage({
|
|
149
|
+
config: {
|
|
150
|
+
url: "file:memory.db"
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
const semanticRecallIsEnabled = this.threadConfig.semanticRecall !== false;
|
|
155
|
+
if (config.vector && semanticRecallIsEnabled) {
|
|
156
|
+
this.vector = config.vector;
|
|
157
|
+
} else if (
|
|
158
|
+
// if there's no configured vector store
|
|
159
|
+
// and the vector store hasn't been explicitly disabled with vector: false
|
|
160
|
+
config.vector !== false && // and semanticRecall is enabled
|
|
161
|
+
semanticRecallIsEnabled
|
|
162
|
+
) {
|
|
150
163
|
const oldDb = "memory-vector.db";
|
|
151
164
|
const hasOldDb = fs.existsSync(path.join(process.cwd(), oldDb)) || fs.existsSync(path.join(process.cwd(), ".mastra", oldDb));
|
|
152
165
|
const newDb = "memory.db";
|
|
@@ -161,12 +174,14 @@ var MastraMemory = class extends chunkD63P5O4Q_cjs.MastraBase {
|
|
|
161
174
|
}
|
|
162
175
|
if (config.embedder) {
|
|
163
176
|
this.embedder = config.embedder;
|
|
164
|
-
} else
|
|
177
|
+
} else if (
|
|
178
|
+
// if there's no configured embedder
|
|
179
|
+
// and there's a vector store
|
|
180
|
+
typeof this.vector !== `undefined` && // and semanticRecall is enabled
|
|
181
|
+
semanticRecallIsEnabled
|
|
182
|
+
) {
|
|
165
183
|
this.embedder = defaultEmbedder("bge-small-en-v1.5");
|
|
166
184
|
}
|
|
167
|
-
if (config.options) {
|
|
168
|
-
this.threadConfig = this.getMergedThreadConfig(config.options);
|
|
169
|
-
}
|
|
170
185
|
if (config.processors) {
|
|
171
186
|
this.processors = config.processors;
|
|
172
187
|
}
|
|
@@ -201,6 +216,9 @@ var MastraMemory = class extends chunkD63P5O4Q_cjs.MastraBase {
|
|
|
201
216
|
const isDefault = dimensions === defaultDimensions;
|
|
202
217
|
const usedDimensions = dimensions ?? defaultDimensions;
|
|
203
218
|
const indexName = isDefault ? "memory_messages" : `memory_messages_${usedDimensions}`;
|
|
219
|
+
if (typeof this.vector === `undefined`) {
|
|
220
|
+
throw new Error(`Tried to create embedding index but no vector db is attached to this Memory instance.`);
|
|
221
|
+
}
|
|
204
222
|
await this.vector.createIndex({
|
|
205
223
|
indexName,
|
|
206
224
|
dimension: usedDimensions
|
|
@@ -208,7 +226,7 @@ var MastraMemory = class extends chunkD63P5O4Q_cjs.MastraBase {
|
|
|
208
226
|
return { indexName };
|
|
209
227
|
}
|
|
210
228
|
getMergedThreadConfig(config) {
|
|
211
|
-
return
|
|
229
|
+
return chunkPY3DCT4A_cjs.deepMerge(this.threadConfig, config || {});
|
|
212
230
|
}
|
|
213
231
|
/**
|
|
214
232
|
* Apply all configured message processors to a list of messages.
|
|
@@ -320,7 +338,8 @@ var MastraMemory = class extends chunkD63P5O4Q_cjs.MastraBase {
|
|
|
320
338
|
id: message.id,
|
|
321
339
|
role: message.role,
|
|
322
340
|
content: textContent,
|
|
323
|
-
toolInvocations
|
|
341
|
+
toolInvocations,
|
|
342
|
+
createdAt: message.createdAt
|
|
324
343
|
});
|
|
325
344
|
return obj;
|
|
326
345
|
},
|