@mastra/core 0.2.0-alpha.89 → 0.2.0-alpha.92
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/README.md +1 -2
- package/dist/action/index.d.ts +3 -3
- package/dist/agent/index.d.ts +4 -4
- package/dist/agent/index.js +4 -4
- package/dist/base.d.ts +1 -1
- package/dist/base.js +2 -2
- package/dist/bundler/index.d.ts +12 -4
- package/dist/bundler/index.js +3 -3
- package/dist/{chunk-D6SEHWUL.js → chunk-4LJFWC2Q.js} +1 -1
- package/dist/chunk-5DYJZVB7.js +66 -0
- package/dist/chunk-AD6IIOCI.js +11 -0
- package/dist/{chunk-5NQ3MEZM.js → chunk-BOS3IA23.js} +0 -1
- package/dist/chunk-CQU72KBX.js +54 -0
- package/dist/{chunk-SKEBFXFK.js → chunk-DINPURQT.js} +5 -10
- package/dist/{chunk-FFZKACHZ.js → chunk-E3TBVBIO.js} +12 -84
- package/dist/{chunk-ADU6ZLCT.js → chunk-ECUVL2G5.js} +1 -1
- package/dist/{chunk-WLG2YHOZ.js → chunk-G4MCO7XF.js} +1 -1
- package/dist/{chunk-IO3KMCXV.js → chunk-ICMEXHKD.js} +0 -1
- package/dist/{chunk-HILJW64N.js → chunk-IE37CBXB.js} +20 -9
- package/dist/chunk-IEFQZ3IL.js +78 -0
- package/dist/{chunk-GTJIVA2D.js → chunk-IJ55HGH4.js} +1 -1
- package/dist/{chunk-BCNHUSA6.js → chunk-JJ57BXQR.js} +1 -1
- package/dist/{chunk-RIATJJC3.js → chunk-MCB4M5W4.js} +3 -3
- package/dist/chunk-NNNAWW2H.js +66 -0
- package/dist/{chunk-T5ZUXYWC.js → chunk-NYBGZL6Z.js} +1 -1
- package/dist/{chunk-654VMNVR.js → chunk-QX2CHXA7.js} +12 -5
- package/dist/chunk-RAR7V3E3.js +66 -0
- package/dist/{chunk-Y7YCQUOD.js → chunk-RI3ECMVF.js} +2 -3
- package/dist/{chunk-SMVXLIV7.js → chunk-U7WDR4WO.js} +1 -1
- package/dist/{chunk-J556NL2S.js → chunk-UCOTMN3J.js} +2 -2
- package/dist/chunk-VPSYTVWP.js +66 -0
- package/dist/{chunk-KHPTZCPA.js → chunk-WBPDZBUT.js} +5 -33
- package/dist/{chunk-Z2KRB7Z4.js → chunk-XDXRDRTQ.js} +1 -1
- package/dist/chunk-ZA7MIXNW.js +66 -0
- package/dist/deployer/index.d.ts +7 -4
- package/dist/deployer/index.js +4 -4
- package/dist/embeddings/index.js +1 -1
- package/dist/embeddings/model/providers/bedrock.d.ts +42 -0
- package/dist/embeddings/model/providers/bedrock.js +3 -0
- package/dist/embeddings/model/providers/bedrock.test.d.ts +2 -0
- package/dist/embeddings/model/providers/bedrock.test.js +37 -0
- package/dist/embeddings/model/providers/cohere.d.ts +34 -0
- package/dist/embeddings/model/providers/cohere.js +3 -0
- package/dist/embeddings/model/providers/cohere.test.d.ts +2 -0
- package/dist/embeddings/model/providers/cohere.test.js +37 -0
- package/dist/embeddings/model/providers/embedder.d.ts +28 -0
- package/dist/embeddings/model/providers/embedder.js +2 -0
- package/dist/embeddings/model/providers/google.d.ts +34 -0
- package/dist/embeddings/model/providers/google.js +3 -0
- package/dist/embeddings/model/providers/google.test.d.ts +2 -0
- package/dist/embeddings/model/providers/google.test.js +37 -0
- package/dist/embeddings/model/providers/mistral.d.ts +34 -0
- package/dist/embeddings/model/providers/mistral.js +3 -0
- package/dist/embeddings/model/providers/mistral.test.d.ts +2 -0
- package/dist/embeddings/model/providers/mistral.test.js +37 -0
- package/dist/embeddings/model/providers/mock.d.ts +20 -0
- package/dist/embeddings/model/providers/mock.js +3 -0
- package/dist/embeddings/model/providers/mock.test.d.ts +2 -0
- package/dist/embeddings/model/providers/mock.test.js +29 -0
- package/dist/embeddings/model/providers/openai.d.ts +34 -0
- package/dist/embeddings/model/providers/openai.js +3 -0
- package/dist/embeddings/model/providers/openai.test.d.ts +2 -0
- package/dist/embeddings/model/providers/openai.test.js +37 -0
- package/dist/embeddings/model/providers/voyage.d.ts +34 -0
- package/dist/embeddings/model/providers/voyage.js +3 -0
- package/dist/embeddings/model/providers/voyage.test.d.ts +2 -0
- package/dist/embeddings/model/providers/voyage.test.js +37 -0
- package/dist/eval/index.d.ts +4 -4
- package/dist/filter/index.d.ts +1 -1
- package/dist/filter/index.js +1 -1
- package/dist/{index-D-mqcYwN.d.ts → index-B48181D5.d.ts} +6 -13
- package/dist/{index-Cktbxvxx.d.ts → index-CBZ2mk2H.d.ts} +0 -1
- package/dist/index.d.ts +7 -8
- package/dist/index.js +17 -18
- package/dist/integration/index.d.ts +5 -5
- package/dist/llm/index.d.ts +4 -4
- package/dist/llm/index.js +3 -3
- package/dist/{model-CD0nIpJn.d.ts → llm/model/index.d.ts} +17 -3
- package/dist/llm/model/index.js +5 -0
- package/dist/llm/model/providers/anthropic-vertex.d.ts +5 -5
- package/dist/llm/model/providers/anthropic-vertex.js +3 -3
- package/dist/llm/model/providers/anthropic.d.ts +5 -5
- package/dist/llm/model/providers/anthropic.js +3 -3
- package/dist/llm/model/providers/azure.d.ts +5 -5
- package/dist/llm/model/providers/azure.js +3 -3
- package/dist/llm/model/providers/baseten.d.ts +5 -5
- package/dist/llm/model/providers/baseten.js +4 -4
- package/dist/llm/model/providers/bedrock.d.ts +5 -5
- package/dist/llm/model/providers/bedrock.js +3 -3
- package/dist/llm/model/providers/cerebras.d.ts +5 -5
- package/dist/llm/model/providers/cerebras.js +3 -3
- package/dist/llm/model/providers/cohere.d.ts +5 -5
- package/dist/llm/model/providers/cohere.js +3 -3
- package/dist/llm/model/providers/deepinfra.d.ts +5 -5
- package/dist/llm/model/providers/deepinfra.js +3 -3
- package/dist/llm/model/providers/deepseek.d.ts +5 -5
- package/dist/llm/model/providers/deepseek.js +3 -3
- package/dist/llm/model/providers/fireworks.d.ts +5 -5
- package/dist/llm/model/providers/fireworks.js +3 -3
- package/dist/llm/model/providers/google-vertex.d.ts +5 -5
- package/dist/llm/model/providers/google-vertex.js +3 -3
- package/dist/llm/model/providers/google.d.ts +5 -5
- package/dist/llm/model/providers/google.js +3 -3
- package/dist/llm/model/providers/grok.d.ts +5 -5
- package/dist/llm/model/providers/grok.js +3 -3
- package/dist/llm/model/providers/groq.d.ts +5 -5
- package/dist/llm/model/providers/groq.js +3 -3
- package/dist/llm/model/providers/lmstudio.d.ts +5 -5
- package/dist/llm/model/providers/lmstudio.js +4 -4
- package/dist/llm/model/providers/mistral.d.ts +5 -5
- package/dist/llm/model/providers/mistral.js +3 -3
- package/dist/llm/model/providers/mock.d.ts +5 -5
- package/dist/llm/model/providers/mock.js +3 -3
- package/dist/llm/model/providers/ollama.d.ts +5 -5
- package/dist/llm/model/providers/ollama.js +3 -3
- package/dist/llm/model/providers/openai-compat.d.ts +5 -5
- package/dist/llm/model/providers/openai-compat.js +4 -4
- package/dist/llm/model/providers/openai.d.ts +5 -5
- package/dist/llm/model/providers/openai.js +4 -4
- package/dist/llm/model/providers/openai.test.js +4 -4
- package/dist/llm/model/providers/perplexity.d.ts +5 -5
- package/dist/llm/model/providers/perplexity.js +3 -3
- package/dist/llm/model/providers/portkey.d.ts +5 -5
- package/dist/llm/model/providers/portkey.js +3 -3
- package/dist/llm/model/providers/togetherai.d.ts +5 -5
- package/dist/llm/model/providers/togetherai.js +3 -3
- package/dist/logger/index.d.ts +1 -1
- package/dist/logger/index.js +1 -1
- package/dist/mastra/index.d.ts +5 -7
- package/dist/mastra/index.js +4 -4
- package/dist/memory/index.d.ts +4 -4
- package/dist/memory/index.js +3 -3
- package/dist/relevance/index.d.ts +4 -4
- package/dist/relevance/index.js +5 -5
- package/dist/storage/index.d.ts +5 -5
- package/dist/storage/index.js +3 -3
- package/dist/tools/index.d.ts +5 -5
- package/dist/tts/index.d.ts +1 -1
- package/dist/tts/index.js +3 -3
- package/dist/vector/index.d.ts +1 -1
- package/dist/vector/index.js +4 -4
- package/dist/vector/libsql/index.d.ts +31 -0
- package/dist/vector/libsql/index.js +662 -0
- package/dist/{workflow-4u4hE9mG.d.ts → workflow-CSwxE-4q.d.ts} +1 -19
- package/dist/workflows/index.d.ts +6 -6
- package/dist/workflows/index.js +3 -3
- package/package.json +14 -8
- package/dist/chunk-NIYVERVP.js +0 -199
- package/dist/engine/index.d.ts +0 -59
- package/dist/engine/index.js +0 -4
- package/dist/engine-EwEG-4Iv.d.ts +0 -127
package/README.md
CHANGED
|
@@ -49,10 +49,9 @@ const agent = new Agent({
|
|
|
49
49
|
The embeddings module provides a unified interface for converting text into vector representations across multiple AI providers. These vectors are essential for semantic search, similarity comparisons, and other NLP tasks.
|
|
50
50
|
|
|
51
51
|
```typescript
|
|
52
|
-
import { embed
|
|
52
|
+
import { embed } from '@mastra/core/embeddings/openai';
|
|
53
53
|
|
|
54
54
|
const embeddings = await embed('text to embed', {
|
|
55
|
-
provider: 'OPEN_AI',
|
|
56
55
|
model: 'text-embedding-3-small',
|
|
57
56
|
});
|
|
58
57
|
```
|
package/dist/action/index.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import 'zod';
|
|
2
|
-
export { I as IAction, aT as IExecutionContext, d as MastraPrimitives } from '../index-
|
|
3
|
-
import '../
|
|
4
|
-
import '../index-Cktbxvxx.js';
|
|
2
|
+
export { I as IAction, aT as IExecutionContext, d as MastraPrimitives } from '../index-B48181D5.js';
|
|
3
|
+
import '../index-CBZ2mk2H.js';
|
|
5
4
|
import '../telemetry-oCUM52DG.js';
|
|
6
5
|
import '../tts/index.js';
|
|
7
6
|
import '../vector/index.js';
|
|
@@ -15,4 +14,5 @@ import '@opentelemetry/sdk-node';
|
|
|
15
14
|
import '@opentelemetry/sdk-trace-base';
|
|
16
15
|
import '../metric-D2V4CR8D.js';
|
|
17
16
|
import 'sift';
|
|
17
|
+
import '../embeddings/model/providers/embedder.js';
|
|
18
18
|
import '../types-M16hSruO.js';
|
package/dist/agent/index.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import 'ai';
|
|
2
2
|
import 'json-schema';
|
|
3
3
|
import 'zod';
|
|
4
|
-
export { A as Agent } from '../index-
|
|
4
|
+
export { A as Agent } from '../index-B48181D5.js';
|
|
5
5
|
import '../base.js';
|
|
6
6
|
import '../metric-D2V4CR8D.js';
|
|
7
7
|
import '../telemetry-oCUM52DG.js';
|
|
8
|
-
import '../index-
|
|
8
|
+
import '../index-CBZ2mk2H.js';
|
|
9
9
|
import 'pino';
|
|
10
10
|
import 'stream';
|
|
11
11
|
import 'sift';
|
|
12
|
-
import '../
|
|
12
|
+
import '../embeddings/model/providers/embedder.js';
|
|
13
13
|
import '../vector/index.js';
|
|
14
|
+
import '../types-M16hSruO.js';
|
|
14
15
|
import '@opentelemetry/api';
|
|
15
16
|
import '@opentelemetry/sdk-node';
|
|
16
17
|
import '@opentelemetry/sdk-trace-base';
|
|
17
|
-
import '../engine-EwEG-4Iv.js';
|
|
18
18
|
import '../tts/index.js';
|
package/dist/agent/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { Agent } from '../chunk-
|
|
1
|
+
export { Agent } from '../chunk-DINPURQT.js';
|
|
2
2
|
import '../chunk-HBTQNIAX.js';
|
|
3
3
|
import '../chunk-SDKEPBBH.js';
|
|
4
|
-
import '../chunk-
|
|
4
|
+
import '../chunk-RI3ECMVF.js';
|
|
5
5
|
import '../chunk-6ZVFVYLE.js';
|
|
6
6
|
import '../chunk-KNPBNSJ7.js';
|
|
7
|
-
import '../chunk-
|
|
8
|
-
import '../chunk-
|
|
7
|
+
import '../chunk-G4MCO7XF.js';
|
|
8
|
+
import '../chunk-ICMEXHKD.js';
|
|
9
9
|
import '../chunk-AJJZUHB4.js';
|
package/dist/base.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _opentelemetry_api from '@opentelemetry/api';
|
|
2
|
-
import { R as RegisteredLogger, L as Logger, a as LogLevel } from './index-
|
|
2
|
+
import { R as RegisteredLogger, L as Logger, a as LogLevel } from './index-CBZ2mk2H.js';
|
|
3
3
|
import { T as Telemetry } from './telemetry-oCUM52DG.js';
|
|
4
4
|
import 'pino';
|
|
5
5
|
import 'stream';
|
package/dist/base.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { MastraBase } from './chunk-
|
|
2
|
-
import './chunk-
|
|
1
|
+
export { MastraBase } from './chunk-G4MCO7XF.js';
|
|
2
|
+
import './chunk-ICMEXHKD.js';
|
|
3
3
|
import './chunk-AJJZUHB4.js';
|
package/dist/bundler/index.d.ts
CHANGED
|
@@ -1,21 +1,29 @@
|
|
|
1
1
|
import { MastraBase } from '../base.js';
|
|
2
2
|
import '@opentelemetry/api';
|
|
3
|
-
import '../index-
|
|
3
|
+
import '../index-CBZ2mk2H.js';
|
|
4
4
|
import 'pino';
|
|
5
5
|
import 'stream';
|
|
6
6
|
import '../telemetry-oCUM52DG.js';
|
|
7
7
|
import '@opentelemetry/sdk-node';
|
|
8
8
|
import '@opentelemetry/sdk-trace-base';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
interface IBundler {
|
|
11
|
+
loadEnvVars(): Promise<Map<string, string>>;
|
|
12
|
+
getEnvFiles(): Promise<string[]>;
|
|
13
|
+
bundle(entryFile: string, outputDirectory: string): Promise<void>;
|
|
14
|
+
prepare(outputDirectory: string): Promise<void>;
|
|
15
|
+
writePackageJson(outputDirectory: string, dependencies: Map<string, string>): Promise<void>;
|
|
16
|
+
}
|
|
17
|
+
declare abstract class MastraBundler extends MastraBase implements IBundler {
|
|
11
18
|
constructor({ name, component }: {
|
|
12
19
|
name: string;
|
|
13
20
|
component?: 'BUNDLER' | 'DEPLOYER';
|
|
14
21
|
});
|
|
15
22
|
loadEnvVars(): Promise<Map<string, string>>;
|
|
16
23
|
abstract prepare(outputDirectory: string): Promise<void>;
|
|
24
|
+
abstract writePackageJson(outputDirectory: string, dependencies: Map<string, string>): Promise<void>;
|
|
17
25
|
abstract getEnvFiles(): Promise<string[]>;
|
|
18
|
-
abstract bundle(
|
|
26
|
+
abstract bundle(entryFile: string, outputDirectory: string): Promise<void>;
|
|
19
27
|
}
|
|
20
28
|
|
|
21
|
-
export { MastraBundler };
|
|
29
|
+
export { type IBundler, MastraBundler };
|
package/dist/bundler/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { MastraBundler } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { MastraBundler } from '../chunk-MCB4M5W4.js';
|
|
2
|
+
import '../chunk-G4MCO7XF.js';
|
|
3
|
+
import '../chunk-ICMEXHKD.js';
|
|
4
4
|
import '../chunk-AJJZUHB4.js';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { MastraEmbedder } from './chunk-AD6IIOCI.js';
|
|
2
|
+
import { __name, __publicField } from './chunk-AJJZUHB4.js';
|
|
3
|
+
import { createMistral } from '@ai-sdk/mistral';
|
|
4
|
+
import { embed as embed$1, embedMany as embedMany$1 } from 'ai';
|
|
5
|
+
|
|
6
|
+
async function embed(value, { apiKey = process.env.MISTRAL_API_KEY || "", model = "mistral-embed", baseURL, maxRetries = 3 }) {
|
|
7
|
+
const mistral = createMistral({
|
|
8
|
+
baseURL,
|
|
9
|
+
apiKey
|
|
10
|
+
});
|
|
11
|
+
const eModel = mistral.textEmbeddingModel(model);
|
|
12
|
+
return await embed$1({
|
|
13
|
+
model: eModel,
|
|
14
|
+
value,
|
|
15
|
+
maxRetries
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
__name(embed, "embed");
|
|
19
|
+
async function embedMany(values, { apiKey = process.env.MISTRAL_API_KEY || "", model = "mistral-embed", baseURL, maxRetries = 3 }) {
|
|
20
|
+
const mistral = createMistral({
|
|
21
|
+
baseURL,
|
|
22
|
+
apiKey
|
|
23
|
+
});
|
|
24
|
+
const eModel = mistral.textEmbeddingModel(model);
|
|
25
|
+
return await embedMany$1({
|
|
26
|
+
model: eModel,
|
|
27
|
+
values,
|
|
28
|
+
maxRetries
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
__name(embedMany, "embedMany");
|
|
32
|
+
var _MistralEmbedder = class _MistralEmbedder extends MastraEmbedder {
|
|
33
|
+
constructor({ apiKey = process.env.MISTRAL_API_KEY || "", model = "mistral-embed", baseURL }) {
|
|
34
|
+
super();
|
|
35
|
+
__publicField(this, "apiKey");
|
|
36
|
+
__publicField(this, "model");
|
|
37
|
+
__publicField(this, "baseURL");
|
|
38
|
+
this.apiKey = apiKey;
|
|
39
|
+
this.model = model;
|
|
40
|
+
this.baseURL = baseURL;
|
|
41
|
+
}
|
|
42
|
+
async embed(value, { maxRetries } = {
|
|
43
|
+
maxRetries: 3
|
|
44
|
+
}) {
|
|
45
|
+
return embed(value, {
|
|
46
|
+
apiKey: this.apiKey,
|
|
47
|
+
model: this.model,
|
|
48
|
+
baseURL: this.baseURL,
|
|
49
|
+
maxRetries
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
async embedMany(values, { maxRetries } = {
|
|
53
|
+
maxRetries: 3
|
|
54
|
+
}) {
|
|
55
|
+
return embedMany(values, {
|
|
56
|
+
apiKey: this.apiKey,
|
|
57
|
+
model: this.model,
|
|
58
|
+
baseURL: this.baseURL,
|
|
59
|
+
maxRetries
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
__name(_MistralEmbedder, "MistralEmbedder");
|
|
64
|
+
var MistralEmbedder = _MistralEmbedder;
|
|
65
|
+
|
|
66
|
+
export { MistralEmbedder, embed, embedMany };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { __name } from './chunk-AJJZUHB4.js';
|
|
2
|
+
|
|
3
|
+
// src/embeddings/model/providers/embedder.ts
|
|
4
|
+
var _MastraEmbedder = class _MastraEmbedder {
|
|
5
|
+
constructor() {
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
__name(_MastraEmbedder, "MastraEmbedder");
|
|
9
|
+
var MastraEmbedder = _MastraEmbedder;
|
|
10
|
+
|
|
11
|
+
export { MastraEmbedder };
|
|
@@ -6,7 +6,6 @@ import { createMistral } from '@ai-sdk/mistral';
|
|
|
6
6
|
import { createOpenAI } from '@ai-sdk/openai';
|
|
7
7
|
import { embed as embed$1, embedMany as embedMany$1 } from 'ai';
|
|
8
8
|
import { createVoyage } from 'voyage-ai-provider';
|
|
9
|
-
import 'dotenv/config';
|
|
10
9
|
|
|
11
10
|
function getEmbeddingModel(embedding) {
|
|
12
11
|
let embeddingModel;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { MastraEmbedder } from './chunk-AD6IIOCI.js';
|
|
2
|
+
import { __name } from './chunk-AJJZUHB4.js';
|
|
3
|
+
import { embed as embed$1, embedMany as embedMany$1 } from 'ai';
|
|
4
|
+
import { MockEmbeddingModelV1 } from 'ai/test';
|
|
5
|
+
|
|
6
|
+
var model = new MockEmbeddingModelV1({
|
|
7
|
+
doEmbed: /* @__PURE__ */ __name(() => Promise.resolve({
|
|
8
|
+
embeddings: [
|
|
9
|
+
[
|
|
10
|
+
1,
|
|
11
|
+
0
|
|
12
|
+
]
|
|
13
|
+
]
|
|
14
|
+
}), "doEmbed")
|
|
15
|
+
});
|
|
16
|
+
async function embed(value, { maxRetries = 3 } = {}) {
|
|
17
|
+
return await embed$1({
|
|
18
|
+
model,
|
|
19
|
+
value,
|
|
20
|
+
maxRetries
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
__name(embed, "embed");
|
|
24
|
+
async function embedMany(values, { maxRetries = 3 } = {}) {
|
|
25
|
+
return await embedMany$1({
|
|
26
|
+
model,
|
|
27
|
+
values,
|
|
28
|
+
maxRetries
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
__name(embedMany, "embedMany");
|
|
32
|
+
var _MockEmbedder = class _MockEmbedder extends MastraEmbedder {
|
|
33
|
+
constructor() {
|
|
34
|
+
super();
|
|
35
|
+
}
|
|
36
|
+
async embed(value, { maxRetries } = {
|
|
37
|
+
maxRetries: 3
|
|
38
|
+
}) {
|
|
39
|
+
return embed(value, {
|
|
40
|
+
maxRetries
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async embedMany(values, { maxRetries } = {
|
|
44
|
+
maxRetries: 3
|
|
45
|
+
}) {
|
|
46
|
+
return embedMany(values, {
|
|
47
|
+
maxRetries
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
__name(_MockEmbedder, "MockEmbedder");
|
|
52
|
+
var MockEmbedder = _MockEmbedder;
|
|
53
|
+
|
|
54
|
+
export { MockEmbedder, embed, embedMany };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { executeHook, AvailableHooks } from './chunk-HBTQNIAX.js';
|
|
2
|
-
import { LLM } from './chunk-
|
|
2
|
+
import { LLM } from './chunk-RI3ECMVF.js';
|
|
3
3
|
import { InstrumentClass } from './chunk-6ZVFVYLE.js';
|
|
4
|
-
import { MastraBase } from './chunk-
|
|
5
|
-
import { RegisteredLogger, LogLevel } from './chunk-
|
|
4
|
+
import { MastraBase } from './chunk-G4MCO7XF.js';
|
|
5
|
+
import { RegisteredLogger, LogLevel } from './chunk-ICMEXHKD.js';
|
|
6
6
|
import { __name, __publicField, __privateAdd, __privateSet, __privateGet } from './chunk-AJJZUHB4.js';
|
|
7
7
|
import { randomUUID } from 'crypto';
|
|
8
8
|
import { z } from 'zod';
|
|
9
|
-
import 'dotenv/config';
|
|
10
9
|
|
|
11
10
|
function _ts_decorate(decorators, target, key, desc) {
|
|
12
11
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -492,7 +491,7 @@ ${memorySystemMessage}` : ""}`
|
|
|
492
491
|
threadIdToUse = preExecuteResult.threadIdToUse;
|
|
493
492
|
}
|
|
494
493
|
let convertedTools;
|
|
495
|
-
if (toolsets && Object.keys(toolsets || {}).length > 0 || this.getMemory() && resourceId
|
|
494
|
+
if (toolsets && Object.keys(toolsets || {}).length > 0 || this.getMemory() && resourceId) {
|
|
496
495
|
const reasons = [];
|
|
497
496
|
if (toolsets && Object.keys(toolsets || {}).length > 0) {
|
|
498
497
|
reasons.push(`toolsets present (${Object.keys(toolsets || {}).length} tools)`);
|
|
@@ -500,15 +499,11 @@ ${memorySystemMessage}` : ""}`
|
|
|
500
499
|
if (this.getMemory() && resourceId) {
|
|
501
500
|
reasons.push("memory and resourceId available");
|
|
502
501
|
}
|
|
503
|
-
if (__privateGet(this, _mastra)?.engine) {
|
|
504
|
-
reasons.push("mastra engine enabled");
|
|
505
|
-
}
|
|
506
502
|
this.logger.debug(`[Agent:${this.name}] - Enhancing tools: ${reasons.join(", ")}`, {
|
|
507
503
|
runId,
|
|
508
504
|
toolsets: toolsets ? Object.keys(toolsets) : undefined,
|
|
509
505
|
hasMemory: !!this.getMemory(),
|
|
510
|
-
hasResourceId: !!resourceId
|
|
511
|
-
hasEngine: !!__privateGet(this, _mastra)?.engine
|
|
506
|
+
hasResourceId: !!resourceId
|
|
512
507
|
});
|
|
513
508
|
convertedTools = this.convertTools({
|
|
514
509
|
toolsets,
|
|
@@ -1,41 +1,9 @@
|
|
|
1
|
-
import { MastraBase } from './chunk-
|
|
2
|
-
import { __name,
|
|
1
|
+
import { MastraBase } from './chunk-G4MCO7XF.js';
|
|
2
|
+
import { __name, __privateAdd, __publicField, __privateSet, __privateMethod, __privateGet } from './chunk-AJJZUHB4.js';
|
|
3
3
|
import { get } from 'radash';
|
|
4
4
|
import sift from 'sift';
|
|
5
5
|
import { setup, createActor, assign, fromPromise } from 'xstate';
|
|
6
6
|
|
|
7
|
-
// src/workflows/snapshot.ts
|
|
8
|
-
var _WorkflowSnapshot = class _WorkflowSnapshot {
|
|
9
|
-
constructor(engine) {
|
|
10
|
-
__publicField(this, "engine");
|
|
11
|
-
this.engine = engine;
|
|
12
|
-
}
|
|
13
|
-
async persist({ entityName, connectionId, runId, snapshot }) {
|
|
14
|
-
await this.engine.syncRecords({
|
|
15
|
-
name: entityName,
|
|
16
|
-
connectionId,
|
|
17
|
-
records: [
|
|
18
|
-
{
|
|
19
|
-
externalId: runId,
|
|
20
|
-
data: {
|
|
21
|
-
snapshot: JSON.stringify(snapshot)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
]
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
async load({ runId, connectionId, entityName }) {
|
|
28
|
-
const state = await this.engine.getRecordsByEntityNameAndExternalId({
|
|
29
|
-
entityName,
|
|
30
|
-
connectionId,
|
|
31
|
-
externalId: runId
|
|
32
|
-
});
|
|
33
|
-
return state?.[0]?.data?.snapshot;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
__name(_WorkflowSnapshot, "WorkflowSnapshot");
|
|
37
|
-
var WorkflowSnapshot = _WorkflowSnapshot;
|
|
38
|
-
|
|
39
7
|
// src/workflows/utils.ts
|
|
40
8
|
function isErrorEvent(stateEvent) {
|
|
41
9
|
return stateEvent.type.startsWith("xstate.error.actor.");
|
|
@@ -56,7 +24,7 @@ function getStepResult(result) {
|
|
|
56
24
|
__name(getStepResult, "getStepResult");
|
|
57
25
|
|
|
58
26
|
// src/workflows/workflow.ts
|
|
59
|
-
var _machine, _actor, _runId, _retryConfig, _mastra,
|
|
27
|
+
var _machine, _actor, _runId, _retryConfig, _mastra, _afterStepStack, _lastStepStack, _stepGraph, _stepSubscriberGraph, _steps, _Workflow_instances, getSuspendedPaths_fn, isFinalState_fn, recursivelyCheckForFinalState_fn, buildBaseState_fn, makeStepKey_fn, buildStateHierarchy_fn, getDefaultActions_fn, getInjectables_fn, getDefaultActors_fn, persistWorkflowSnapshot_fn, loadWorkflowSnapshot_fn, resolveVariables_fn, evaluateCondition_fn, makeStepDef_fn, makeDelayMap_fn, cleanup_fn, getActivePathsAndStatus_fn, hasStateChanged_fn, getDeepestState_fn;
|
|
60
28
|
var _Workflow = class _Workflow extends MastraBase {
|
|
61
29
|
/**
|
|
62
30
|
* Creates a new Workflow instance
|
|
@@ -70,7 +38,6 @@ var _Workflow = class _Workflow extends MastraBase {
|
|
|
70
38
|
});
|
|
71
39
|
__privateAdd(this, _Workflow_instances);
|
|
72
40
|
__publicField(this, "name");
|
|
73
|
-
__publicField(this, "snapshot");
|
|
74
41
|
__publicField(this, "triggerSchema");
|
|
75
42
|
/** XState machine instance that orchestrates the workflow execution */
|
|
76
43
|
__privateAdd(this, _machine);
|
|
@@ -79,8 +46,6 @@ var _Workflow = class _Workflow extends MastraBase {
|
|
|
79
46
|
__privateAdd(this, _runId);
|
|
80
47
|
__privateAdd(this, _retryConfig);
|
|
81
48
|
__privateAdd(this, _mastra);
|
|
82
|
-
__privateAdd(this, _connectionId, `WORKFLOWS`);
|
|
83
|
-
__privateAdd(this, _entityName, `__workflows__`);
|
|
84
49
|
// registers stepIds on `after` calls
|
|
85
50
|
__privateAdd(this, _afterStepStack, []);
|
|
86
51
|
__privateAdd(this, _lastStepStack, []);
|
|
@@ -94,9 +59,6 @@ var _Workflow = class _Workflow extends MastraBase {
|
|
|
94
59
|
this.triggerSchema = triggerSchema;
|
|
95
60
|
__privateSet(this, _runId, crypto.randomUUID());
|
|
96
61
|
__privateSet(this, _mastra, mastra);
|
|
97
|
-
if (__privateGet(this, _mastra)?.engine) {
|
|
98
|
-
this.snapshot = new WorkflowSnapshot(__privateGet(this, _mastra).engine);
|
|
99
|
-
}
|
|
100
62
|
if (mastra?.logger) {
|
|
101
63
|
this.logger = mastra?.logger;
|
|
102
64
|
}
|
|
@@ -335,13 +297,12 @@ var _Workflow = class _Workflow extends MastraBase {
|
|
|
335
297
|
timestamp: Date.now()
|
|
336
298
|
};
|
|
337
299
|
}
|
|
338
|
-
const storedSnapshot = await this
|
|
300
|
+
const storedSnapshot = await __privateGet(this, _mastra)?.storage?.loadWorkflowSnapshot({
|
|
339
301
|
runId,
|
|
340
|
-
|
|
341
|
-
connectionId: __privateGet(this, _connectionId)
|
|
302
|
+
workflowName: this.name
|
|
342
303
|
});
|
|
343
304
|
if (storedSnapshot) {
|
|
344
|
-
const parsed =
|
|
305
|
+
const parsed = storedSnapshot;
|
|
345
306
|
const m = __privateMethod(this, _Workflow_instances, getActivePathsAndStatus_fn).call(this, parsed.value);
|
|
346
307
|
return {
|
|
347
308
|
runId,
|
|
@@ -459,9 +420,6 @@ var _Workflow = class _Workflow extends MastraBase {
|
|
|
459
420
|
if (p.logger) {
|
|
460
421
|
this.__setLogger(p.logger);
|
|
461
422
|
}
|
|
462
|
-
if (p?.engine) {
|
|
463
|
-
this.snapshot = new WorkflowSnapshot(p.engine);
|
|
464
|
-
}
|
|
465
423
|
__privateSet(this, _mastra, p);
|
|
466
424
|
}
|
|
467
425
|
get stepGraph() {
|
|
@@ -479,8 +437,6 @@ _actor = new WeakMap();
|
|
|
479
437
|
_runId = new WeakMap();
|
|
480
438
|
_retryConfig = new WeakMap();
|
|
481
439
|
_mastra = new WeakMap();
|
|
482
|
-
_connectionId = new WeakMap();
|
|
483
|
-
_entityName = new WeakMap();
|
|
484
440
|
_afterStepStack = new WeakMap();
|
|
485
441
|
_lastStepStack = new WeakMap();
|
|
486
442
|
_stepGraph = new WeakMap();
|
|
@@ -1047,7 +1003,7 @@ getDefaultActors_fn = /* @__PURE__ */ __name(function() {
|
|
|
1047
1003
|
}, "#getDefaultActors");
|
|
1048
1004
|
persistWorkflowSnapshot_fn = /* @__PURE__ */ __name(async function() {
|
|
1049
1005
|
const snapshotFromActor = __privateGet(this, _actor)?.getPersistedSnapshot();
|
|
1050
|
-
if (!this
|
|
1006
|
+
if (!__privateGet(this, _mastra)?.storage) {
|
|
1051
1007
|
this.logger.debug("Snapshot cannot be persisted. Mastra engine is not initialized", {
|
|
1052
1008
|
runId: __privateGet(this, _runId)
|
|
1053
1009
|
});
|
|
@@ -1065,48 +1021,20 @@ persistWorkflowSnapshot_fn = /* @__PURE__ */ __name(async function() {
|
|
|
1065
1021
|
runId: __privateGet(this, _runId),
|
|
1066
1022
|
snapshot: snapshotFromActor
|
|
1067
1023
|
});
|
|
1068
|
-
} else {
|
|
1069
|
-
await this.snapshot.persist({
|
|
1070
|
-
runId: __privateGet(this, _runId),
|
|
1071
|
-
snapshot: snapshotFromActor,
|
|
1072
|
-
entityName: __privateGet(this, _entityName),
|
|
1073
|
-
connectionId: __privateGet(this, _connectionId)
|
|
1074
|
-
});
|
|
1075
|
-
this.logger.debug("Successfully persisted workflow snapshot", {
|
|
1076
|
-
runId: __privateGet(this, _runId)
|
|
1077
|
-
});
|
|
1078
1024
|
}
|
|
1079
1025
|
return __privateGet(this, _runId);
|
|
1080
1026
|
}, "#persistWorkflowSnapshot");
|
|
1081
1027
|
loadWorkflowSnapshot_fn = /* @__PURE__ */ __name(async function(runId) {
|
|
1082
|
-
if (!this
|
|
1028
|
+
if (!__privateGet(this, _mastra)?.storage) {
|
|
1083
1029
|
this.logger.debug("Snapshot cannot be loaded. Mastra engine is not initialized", {
|
|
1084
1030
|
runId
|
|
1085
1031
|
});
|
|
1086
1032
|
return;
|
|
1087
1033
|
}
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
});
|
|
1093
|
-
} else {
|
|
1094
|
-
this.logger.debug("Loading workflow snapshot", {
|
|
1095
|
-
runId,
|
|
1096
|
-
entityName: __privateGet(this, _entityName),
|
|
1097
|
-
connectionId: __privateGet(this, _connectionId)
|
|
1098
|
-
});
|
|
1099
|
-
const snapshotData = await this.snapshot.load({
|
|
1100
|
-
runId,
|
|
1101
|
-
entityName: __privateGet(this, _entityName),
|
|
1102
|
-
connectionId: __privateGet(this, _connectionId)
|
|
1103
|
-
});
|
|
1104
|
-
this.logger.debug("Retrieved workflow state from storage", {
|
|
1105
|
-
snapshot: snapshotData,
|
|
1106
|
-
runId
|
|
1107
|
-
});
|
|
1108
|
-
return snapshotData;
|
|
1109
|
-
}
|
|
1034
|
+
return __privateGet(this, _mastra).storage.loadWorkflowSnapshot({
|
|
1035
|
+
runId,
|
|
1036
|
+
workflowName: this.name
|
|
1037
|
+
});
|
|
1110
1038
|
}, "#loadWorkflowSnapshot");
|
|
1111
1039
|
/**
|
|
1112
1040
|
* Resolves variables for a step from trigger data or previous step results
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { deepMerge } from './chunk-KNPBNSJ7.js';
|
|
2
|
-
import { MastraBase } from './chunk-
|
|
2
|
+
import { MastraBase } from './chunk-G4MCO7XF.js';
|
|
3
3
|
import { __name, __publicField } from './chunk-AJJZUHB4.js';
|
|
4
4
|
|
|
5
5
|
// src/memory/index.ts
|
|
@@ -12,7 +12,7 @@ var _MastraMemory = class _MastraMemory extends MastraBase {
|
|
|
12
12
|
__publicField(this, "MAX_CONTEXT_TOKENS");
|
|
13
13
|
__publicField(this, "storage");
|
|
14
14
|
__publicField(this, "vector");
|
|
15
|
-
__publicField(this, "
|
|
15
|
+
__publicField(this, "embedder");
|
|
16
16
|
__publicField(this, "threadConfig", {
|
|
17
17
|
lastMessages: 40,
|
|
18
18
|
semanticRecall: false
|
|
@@ -22,8 +22,8 @@ var _MastraMemory = class _MastraMemory extends MastraBase {
|
|
|
22
22
|
this.vector = config.vector;
|
|
23
23
|
this.threadConfig.semanticRecall = true;
|
|
24
24
|
}
|
|
25
|
-
if (
|
|
26
|
-
this.
|
|
25
|
+
if (config.embedder) {
|
|
26
|
+
this.embedder = config.embedder;
|
|
27
27
|
}
|
|
28
28
|
if (config.options) {
|
|
29
29
|
this.threadConfig = this.getMergedThreadConfig(config.options);
|
|
@@ -37,11 +37,22 @@ var _MastraMemory = class _MastraMemory extends MastraBase {
|
|
|
37
37
|
async getSystemMessage(_input) {
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
40
|
-
|
|
41
|
-
if (!this.
|
|
42
|
-
throw new Error(`Cannot use vector features without setting new Memory({
|
|
40
|
+
getEmbedder() {
|
|
41
|
+
if (!this.embedder) {
|
|
42
|
+
throw new Error(`Cannot use vector features without setting new Memory({ embedder: embedderInstance })
|
|
43
|
+
|
|
44
|
+
For example:
|
|
45
|
+
|
|
46
|
+
new Memory({
|
|
47
|
+
storage,
|
|
48
|
+
vector,
|
|
49
|
+
embedder: new OpenAIEmbedder({ // <- this is required
|
|
50
|
+
model: "text-embedding-3-small",
|
|
51
|
+
})
|
|
52
|
+
});
|
|
53
|
+
`);
|
|
43
54
|
}
|
|
44
|
-
return this.
|
|
55
|
+
return this.embedder;
|
|
45
56
|
}
|
|
46
57
|
getMergedThreadConfig(config) {
|
|
47
58
|
return deepMerge(this.threadConfig, config || {});
|
|
@@ -136,7 +147,7 @@ var _MastraMemory = class _MastraMemory extends MastraBase {
|
|
|
136
147
|
async createThread({ threadId, resourceId, title, metadata, memoryConfig }) {
|
|
137
148
|
const thread = {
|
|
138
149
|
id: threadId || this.generateId(),
|
|
139
|
-
title,
|
|
150
|
+
title: title || "New Thread",
|
|
140
151
|
resourceId,
|
|
141
152
|
createdAt: /* @__PURE__ */ new Date(),
|
|
142
153
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { MastraEmbedder } from './chunk-AD6IIOCI.js';
|
|
2
|
+
import { __name, __publicField } from './chunk-AJJZUHB4.js';
|
|
3
|
+
import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock';
|
|
4
|
+
import { embed as embed$1, embedMany as embedMany$1 } from 'ai';
|
|
5
|
+
|
|
6
|
+
async function embed(value, { region = process.env.AWS_REGION || "us-east-1", accessKeyId = process.env.AWS_ACCESS_KEY_ID || "", secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY || "", sessionToken = process.env.AWS_SESSION_TOKEN || "", model = "amazon.titan-embed-text-v1", maxRetries = 3 }) {
|
|
7
|
+
const bedrock = createAmazonBedrock({
|
|
8
|
+
region,
|
|
9
|
+
accessKeyId,
|
|
10
|
+
secretAccessKey,
|
|
11
|
+
sessionToken
|
|
12
|
+
});
|
|
13
|
+
const eModel = bedrock.embedding(model);
|
|
14
|
+
return await embed$1({
|
|
15
|
+
model: eModel,
|
|
16
|
+
value,
|
|
17
|
+
maxRetries
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
__name(embed, "embed");
|
|
21
|
+
async function embedMany(values, { region = process.env.AWS_REGION || "us-east-1", accessKeyId = process.env.AWS_ACCESS_KEY_ID || "", secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY || "", sessionToken = process.env.AWS_SESSION_TOKEN || "", model = "amazon.titan-embed-text-v1", maxRetries = 3 }) {
|
|
22
|
+
const bedrock = createAmazonBedrock({
|
|
23
|
+
region,
|
|
24
|
+
accessKeyId,
|
|
25
|
+
secretAccessKey,
|
|
26
|
+
sessionToken
|
|
27
|
+
});
|
|
28
|
+
const eModel = bedrock.embedding(model);
|
|
29
|
+
return await embedMany$1({
|
|
30
|
+
model: eModel,
|
|
31
|
+
values,
|
|
32
|
+
maxRetries
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
__name(embedMany, "embedMany");
|
|
36
|
+
var _BedrockEmbedder = class _BedrockEmbedder extends MastraEmbedder {
|
|
37
|
+
constructor({ region = process.env.AWS_REGION || "us-east-1", accessKeyId = process.env.AWS_ACCESS_KEY_ID || "", secretAccessKey = process.env.AWS_SECRET_ACCESS_KEY || "", sessionToken = process.env.AWS_SESSION_TOKEN || "", model = "amazon.titan-embed-text-v1" } = {}) {
|
|
38
|
+
super();
|
|
39
|
+
__publicField(this, "region");
|
|
40
|
+
__publicField(this, "accessKeyId");
|
|
41
|
+
__publicField(this, "secretAccessKey");
|
|
42
|
+
__publicField(this, "sessionToken");
|
|
43
|
+
__publicField(this, "model");
|
|
44
|
+
this.region = region;
|
|
45
|
+
this.accessKeyId = accessKeyId;
|
|
46
|
+
this.secretAccessKey = secretAccessKey;
|
|
47
|
+
this.sessionToken = sessionToken;
|
|
48
|
+
this.model = model;
|
|
49
|
+
}
|
|
50
|
+
async embed(value, { maxRetries } = {
|
|
51
|
+
maxRetries: 3
|
|
52
|
+
}) {
|
|
53
|
+
return embed(value, {
|
|
54
|
+
region: this.region,
|
|
55
|
+
accessKeyId: this.accessKeyId,
|
|
56
|
+
secretAccessKey: this.secretAccessKey,
|
|
57
|
+
sessionToken: this.sessionToken,
|
|
58
|
+
model: this.model,
|
|
59
|
+
maxRetries
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async embedMany(values, { maxRetries } = {
|
|
63
|
+
maxRetries: 3
|
|
64
|
+
}) {
|
|
65
|
+
return embedMany(values, {
|
|
66
|
+
region: this.region,
|
|
67
|
+
accessKeyId: this.accessKeyId,
|
|
68
|
+
secretAccessKey: this.secretAccessKey,
|
|
69
|
+
sessionToken: this.sessionToken,
|
|
70
|
+
model: this.model,
|
|
71
|
+
maxRetries
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
__name(_BedrockEmbedder, "BedrockEmbedder");
|
|
76
|
+
var BedrockEmbedder = _BedrockEmbedder;
|
|
77
|
+
|
|
78
|
+
export { BedrockEmbedder, embed, embedMany };
|