@mastra/core 0.9.0 → 0.9.1-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 +4 -2
- package/dist/agent/index.d.ts +4 -2
- package/dist/agent/index.js +1 -1
- package/dist/{base-oP3DoUrm.d.cts → base-CZmT-p10.d.cts} +524 -53
- package/dist/{base-Bk5V1doj.d.ts → base-DDoWFpFc.d.ts} +524 -53
- package/dist/{chunk-NTHHPNOW.js → chunk-34622N67.js} +1 -1
- package/dist/{chunk-ATXF6TIO.cjs → chunk-422BXQRT.cjs} +24 -677
- package/dist/{chunk-HARYMLZH.js → chunk-4K4DHXRF.js} +6 -658
- package/dist/{chunk-N2ONCUUS.js → chunk-6AHC67YY.js} +132 -12
- package/dist/chunk-7AGAXO6B.cjs +588 -0
- package/dist/{chunk-GEIPVIW4.js → chunk-BFF2O6RO.js} +1 -1
- package/dist/{chunk-RASVJ3TR.js → chunk-BU45BMXY.js} +55 -1
- package/dist/{chunk-DIZZQ3E5.cjs → chunk-CEXM6WP5.cjs} +2 -2
- package/dist/chunk-HNEE7IF4.js +60 -0
- package/dist/{chunk-NZDXKMDP.cjs → chunk-LABUWBKX.cjs} +1 -1
- package/dist/chunk-MUNFCOMB.cjs +62 -0
- package/dist/{chunk-GJWCFDFN.js → chunk-PS2ZF6MA.js} +1 -1
- package/dist/{chunk-M472GIT6.js → chunk-SGGPJWRQ.js} +1 -1
- package/dist/{chunk-7CSNWYGJ.cjs → chunk-U5DGGGS2.cjs} +2 -2
- package/dist/{chunk-W5IA5OGL.cjs → chunk-V7IE36YV.cjs} +58 -4
- package/dist/chunk-VMVXIPGW.js +586 -0
- package/dist/{chunk-53P5ZBJE.cjs → chunk-YTTBFAQJ.cjs} +2 -2
- package/dist/{chunk-KZWBYRXW.cjs → chunk-YZFNMXY4.cjs} +135 -14
- package/dist/di/index.cjs +2 -2
- package/dist/di/index.d.cts +1 -52
- package/dist/di/index.d.ts +1 -52
- package/dist/di/index.js +1 -1
- package/dist/eval/index.d.cts +4 -2
- package/dist/eval/index.d.ts +4 -2
- package/dist/index.cjs +60 -55
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +10 -9
- package/dist/integration/index.cjs +3 -3
- package/dist/integration/index.d.cts +4 -2
- package/dist/integration/index.d.ts +4 -2
- package/dist/integration/index.js +1 -1
- package/dist/llm/index.cjs +8 -0
- package/dist/llm/index.d.cts +4 -2
- package/dist/llm/index.d.ts +4 -2
- package/dist/llm/index.js +1 -1
- package/dist/mastra/index.cjs +2 -2
- package/dist/mastra/index.d.cts +4 -2
- package/dist/mastra/index.d.ts +4 -2
- package/dist/mastra/index.js +1 -1
- package/dist/memory/index.cjs +7 -3
- package/dist/memory/index.d.cts +4 -2
- package/dist/memory/index.d.ts +4 -2
- package/dist/memory/index.js +1 -1
- package/dist/network/index.cjs +4 -4
- package/dist/network/index.d.cts +4 -2
- package/dist/network/index.d.ts +4 -2
- package/dist/network/index.js +2 -2
- package/dist/relevance/index.cjs +4 -4
- package/dist/relevance/index.d.cts +4 -2
- package/dist/relevance/index.d.ts +4 -2
- package/dist/relevance/index.js +1 -1
- package/dist/runtime-context/index.cjs +7 -68
- package/dist/runtime-context/index.js +1 -69
- package/dist/server/index.d.cts +4 -2
- package/dist/server/index.d.ts +4 -2
- package/dist/storage/index.d.cts +4 -2
- package/dist/storage/index.d.ts +4 -2
- package/dist/storage/libsql/index.cjs +19 -0
- package/dist/storage/libsql/index.d.cts +7 -8
- package/dist/storage/libsql/index.d.ts +7 -8
- package/dist/storage/libsql/index.js +19 -0
- package/dist/telemetry/index.d.cts +4 -2
- package/dist/telemetry/index.d.ts +4 -2
- package/dist/tools/index.cjs +4 -4
- package/dist/tools/index.d.cts +4 -2
- package/dist/tools/index.d.ts +4 -2
- package/dist/tools/index.js +1 -1
- package/dist/utils.cjs +14 -14
- package/dist/utils.d.cts +6 -4
- package/dist/utils.d.ts +6 -4
- package/dist/utils.js +1 -1
- package/dist/voice/index.d.cts +5 -3
- package/dist/voice/index.d.ts +5 -3
- package/dist/workflows/index.cjs +22 -26
- package/dist/workflows/index.d.cts +5 -3
- package/dist/workflows/index.d.ts +5 -3
- package/dist/workflows/index.js +1 -1
- package/dist/workflows/vNext/index.cjs +1058 -0
- package/dist/workflows/vNext/index.d.cts +180 -0
- package/dist/workflows/vNext/index.d.ts +180 -0
- package/dist/workflows/vNext/index.js +1046 -0
- package/package.json +11 -1
- package/workflows/vNext.d.ts +1 -0
- /package/dist/{chunk-WEYWYKLG.cjs → chunk-27PAET7X.cjs} +0 -0
- /package/dist/{chunk-FRQFWZDN.cjs → chunk-HSVOEWAM.cjs} +0 -0
- /package/dist/{chunk-ZDWFBE5L.js → chunk-NH5WJNNS.js} +0 -0
- /package/dist/{chunk-LANFNMEE.js → chunk-SGTFVHOZ.js} +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { simulateReadableStream } from 'ai';
|
|
2
|
+
import { MockLanguageModelV1 } from 'ai/test';
|
|
3
|
+
|
|
4
|
+
// src/llm/model/mock.ts
|
|
5
|
+
function createMockModel({
|
|
6
|
+
objectGenerationMode,
|
|
7
|
+
mockText,
|
|
8
|
+
spyGenerate,
|
|
9
|
+
spyStream
|
|
10
|
+
}) {
|
|
11
|
+
const mockModel = new MockLanguageModelV1({
|
|
12
|
+
defaultObjectGenerationMode: objectGenerationMode,
|
|
13
|
+
doGenerate: async (props) => {
|
|
14
|
+
if (spyGenerate) {
|
|
15
|
+
spyGenerate(props);
|
|
16
|
+
}
|
|
17
|
+
if (objectGenerationMode === "json") {
|
|
18
|
+
return {
|
|
19
|
+
rawCall: { rawPrompt: null, rawSettings: {} },
|
|
20
|
+
finishReason: "stop",
|
|
21
|
+
usage: { promptTokens: 10, completionTokens: 20 },
|
|
22
|
+
text: JSON.stringify(mockText)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
rawCall: { rawPrompt: null, rawSettings: {} },
|
|
27
|
+
finishReason: "stop",
|
|
28
|
+
usage: { promptTokens: 10, completionTokens: 20 },
|
|
29
|
+
text: typeof mockText === "string" ? mockText : JSON.stringify(mockText)
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
doStream: async (props) => {
|
|
33
|
+
if (spyStream) {
|
|
34
|
+
spyStream(props);
|
|
35
|
+
}
|
|
36
|
+
const text = typeof mockText === "string" ? mockText : JSON.stringify(mockText);
|
|
37
|
+
const chunks = text.split(" ").map((word) => ({
|
|
38
|
+
type: "text-delta",
|
|
39
|
+
textDelta: word + " "
|
|
40
|
+
}));
|
|
41
|
+
return {
|
|
42
|
+
stream: simulateReadableStream({
|
|
43
|
+
chunks: [
|
|
44
|
+
...chunks,
|
|
45
|
+
{
|
|
46
|
+
type: "finish",
|
|
47
|
+
finishReason: "stop",
|
|
48
|
+
logprobs: void 0,
|
|
49
|
+
usage: { completionTokens: 10, promptTokens: 3 }
|
|
50
|
+
}
|
|
51
|
+
]
|
|
52
|
+
}),
|
|
53
|
+
rawCall: { rawPrompt: null, rawSettings: {} }
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return mockModel;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { createMockModel };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var ai = require('ai');
|
|
4
|
+
var test = require('ai/test');
|
|
5
|
+
|
|
6
|
+
// src/llm/model/mock.ts
|
|
7
|
+
function createMockModel({
|
|
8
|
+
objectGenerationMode,
|
|
9
|
+
mockText,
|
|
10
|
+
spyGenerate,
|
|
11
|
+
spyStream
|
|
12
|
+
}) {
|
|
13
|
+
const mockModel = new test.MockLanguageModelV1({
|
|
14
|
+
defaultObjectGenerationMode: objectGenerationMode,
|
|
15
|
+
doGenerate: async (props) => {
|
|
16
|
+
if (spyGenerate) {
|
|
17
|
+
spyGenerate(props);
|
|
18
|
+
}
|
|
19
|
+
if (objectGenerationMode === "json") {
|
|
20
|
+
return {
|
|
21
|
+
rawCall: { rawPrompt: null, rawSettings: {} },
|
|
22
|
+
finishReason: "stop",
|
|
23
|
+
usage: { promptTokens: 10, completionTokens: 20 },
|
|
24
|
+
text: JSON.stringify(mockText)
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
rawCall: { rawPrompt: null, rawSettings: {} },
|
|
29
|
+
finishReason: "stop",
|
|
30
|
+
usage: { promptTokens: 10, completionTokens: 20 },
|
|
31
|
+
text: typeof mockText === "string" ? mockText : JSON.stringify(mockText)
|
|
32
|
+
};
|
|
33
|
+
},
|
|
34
|
+
doStream: async (props) => {
|
|
35
|
+
if (spyStream) {
|
|
36
|
+
spyStream(props);
|
|
37
|
+
}
|
|
38
|
+
const text = typeof mockText === "string" ? mockText : JSON.stringify(mockText);
|
|
39
|
+
const chunks = text.split(" ").map((word) => ({
|
|
40
|
+
type: "text-delta",
|
|
41
|
+
textDelta: word + " "
|
|
42
|
+
}));
|
|
43
|
+
return {
|
|
44
|
+
stream: ai.simulateReadableStream({
|
|
45
|
+
chunks: [
|
|
46
|
+
...chunks,
|
|
47
|
+
{
|
|
48
|
+
type: "finish",
|
|
49
|
+
finishReason: "stop",
|
|
50
|
+
logprobs: void 0,
|
|
51
|
+
usage: { completionTokens: 10, promptTokens: 3 }
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}),
|
|
55
|
+
rawCall: { rawPrompt: null, rawSettings: {} }
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return mockModel;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
exports.createMockModel = createMockModel;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkYTTBFAQJ_cjs = require('./chunk-YTTBFAQJ.cjs');
|
|
4
4
|
var zod = require('zod');
|
|
5
5
|
|
|
6
6
|
// src/integration/integration.ts
|
|
@@ -68,7 +68,7 @@ var OpenAPIToolset = class {
|
|
|
68
68
|
const tools = Object.keys(clientMethods).reduce((acc, key) => {
|
|
69
69
|
const comment = documentations[key]?.comment;
|
|
70
70
|
const fallbackComment = `Execute ${key}`;
|
|
71
|
-
const tool =
|
|
71
|
+
const tool = chunkYTTBFAQJ_cjs.createTool({
|
|
72
72
|
id: key,
|
|
73
73
|
inputSchema: schemas[key] || zod.z.object({}),
|
|
74
74
|
description: comment || fallbackComment,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunk27PAET7X_cjs = require('./chunk-27PAET7X.cjs');
|
|
4
4
|
var chunkRIBNDTA6_cjs = require('./chunk-RIBNDTA6.cjs');
|
|
5
5
|
var chunkO7IW545H_cjs = require('./chunk-O7IW545H.cjs');
|
|
6
6
|
var chunkRWTSGWWL_cjs = require('./chunk-RWTSGWWL.cjs');
|
|
@@ -16,6 +16,7 @@ exports.Mastra = class Mastra {
|
|
|
16
16
|
#agents;
|
|
17
17
|
#logger;
|
|
18
18
|
#workflows;
|
|
19
|
+
#vnext_workflows;
|
|
19
20
|
#tts;
|
|
20
21
|
#deployer;
|
|
21
22
|
#serverMiddleware = [];
|
|
@@ -66,13 +67,13 @@ exports.Mastra = class Mastra {
|
|
|
66
67
|
this.#logger = logger;
|
|
67
68
|
let storage = config?.storage;
|
|
68
69
|
if (!storage) {
|
|
69
|
-
storage = new
|
|
70
|
+
storage = new chunk27PAET7X_cjs.DefaultProxyStorage({
|
|
70
71
|
config: {
|
|
71
72
|
url: process.env.MASTRA_DEFAULT_STORAGE_URL || `:memory:`
|
|
72
73
|
}
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
|
-
storage =
|
|
76
|
+
storage = chunk27PAET7X_cjs.augmentWithInit(storage);
|
|
76
77
|
this.#telemetry = chunkRIBNDTA6_cjs.Telemetry.init(config?.telemetry);
|
|
77
78
|
if (this.#telemetry) {
|
|
78
79
|
this.#storage = this.#telemetry.traceClass(storage, {
|
|
@@ -183,6 +184,22 @@ This is a warning for now, but will throw an error in the future
|
|
|
183
184
|
}
|
|
184
185
|
});
|
|
185
186
|
}
|
|
187
|
+
this.#vnext_workflows = {};
|
|
188
|
+
if (config?.vnext_workflows) {
|
|
189
|
+
Object.entries(config.vnext_workflows).forEach(([key, workflow]) => {
|
|
190
|
+
workflow.__registerMastra(this);
|
|
191
|
+
workflow.__registerPrimitives({
|
|
192
|
+
logger: this.getLogger(),
|
|
193
|
+
telemetry: this.#telemetry,
|
|
194
|
+
storage: this.storage,
|
|
195
|
+
memory: this.memory,
|
|
196
|
+
agents,
|
|
197
|
+
tts: this.#tts,
|
|
198
|
+
vectors: this.#vectors
|
|
199
|
+
});
|
|
200
|
+
this.#vnext_workflows[key] = workflow;
|
|
201
|
+
});
|
|
202
|
+
}
|
|
186
203
|
if (config?.server) {
|
|
187
204
|
this.#server = config.server;
|
|
188
205
|
}
|
|
@@ -227,6 +244,20 @@ This is a warning for now, but will throw an error in the future
|
|
|
227
244
|
}
|
|
228
245
|
return workflow;
|
|
229
246
|
}
|
|
247
|
+
vnext_getWorkflow(id, {
|
|
248
|
+
serialized
|
|
249
|
+
} = {}) {
|
|
250
|
+
const workflow = this.#vnext_workflows?.[id];
|
|
251
|
+
if (!workflow) {
|
|
252
|
+
throw new Error(`Workflow with ID ${String(id)} not found`);
|
|
253
|
+
}
|
|
254
|
+
if (serialized) {
|
|
255
|
+
return {
|
|
256
|
+
name: workflow.name
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
return workflow;
|
|
260
|
+
}
|
|
230
261
|
getWorkflows(props = {}) {
|
|
231
262
|
if (props.serialized) {
|
|
232
263
|
return Object.entries(this.#workflows).reduce((acc, [k, v]) => {
|
|
@@ -240,8 +271,31 @@ This is a warning for now, but will throw an error in the future
|
|
|
240
271
|
}
|
|
241
272
|
return this.#workflows;
|
|
242
273
|
}
|
|
274
|
+
vnext_getWorkflows(props = {}) {
|
|
275
|
+
if (props.serialized) {
|
|
276
|
+
return Object.entries(this.#vnext_workflows).reduce((acc, [k, v]) => {
|
|
277
|
+
return {
|
|
278
|
+
...acc,
|
|
279
|
+
[k]: {
|
|
280
|
+
name: v.name
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
}, {});
|
|
284
|
+
}
|
|
285
|
+
return this.#vnext_workflows;
|
|
286
|
+
}
|
|
243
287
|
setStorage(storage) {
|
|
244
|
-
|
|
288
|
+
if (storage instanceof chunk27PAET7X_cjs.DefaultProxyStorage) {
|
|
289
|
+
this.#logger.warn(`Importing "DefaultStorage" from '@mastra/core/storage/libsql' is deprecated.
|
|
290
|
+
|
|
291
|
+
Instead of:
|
|
292
|
+
import { DefaultStorage } from '@mastra/core/storage/libsql';
|
|
293
|
+
|
|
294
|
+
Do:
|
|
295
|
+
import { LibSQLStore } from '@mastra/libsql';
|
|
296
|
+
`);
|
|
297
|
+
}
|
|
298
|
+
this.#storage = chunk27PAET7X_cjs.augmentWithInit(storage);
|
|
245
299
|
}
|
|
246
300
|
setLogger({
|
|
247
301
|
logger
|