@mastra/core 0.10.13 → 0.10.14
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/a2a.d.ts +1 -0
- package/agent.d.ts +1 -0
- package/base.d.ts +1 -0
- package/bundler.d.ts +1 -0
- package/deployer.d.ts +1 -0
- package/di.d.ts +1 -0
- package/dist/a2a/index.cjs +79 -0
- package/dist/a2a/index.d.cts +780 -0
- package/dist/a2a/index.d.ts +780 -0
- package/dist/a2a/index.js +68 -0
- package/dist/agent/index.cjs +15 -0
- package/dist/agent/index.d.cts +29 -0
- package/dist/agent/index.d.ts +29 -0
- package/dist/agent/index.js +2 -0
- package/dist/base-B_y9sMg0.d.cts +162 -0
- package/dist/base-CS5eSXbL.d.cts +4117 -0
- package/dist/base-ClrXcCRx.d.ts +162 -0
- package/dist/base-DBhKcre4.d.ts +4117 -0
- package/dist/base.cjs +10 -0
- package/dist/base.d.cts +6 -0
- package/dist/base.d.ts +6 -0
- package/dist/base.js +1 -0
- package/dist/bundler/index.cjs +10 -0
- package/dist/bundler/index.d.cts +30 -0
- package/dist/bundler/index.d.ts +30 -0
- package/dist/bundler/index.js +1 -0
- package/dist/chunk-2GRYVZ2O.cjs +244 -0
- package/dist/chunk-2HDFKWFU.js +2249 -0
- package/dist/chunk-32C7JDIZ.js +1 -0
- package/dist/chunk-4UBOJFSL.js +989 -0
- package/dist/chunk-4UWPFBC6.js +88 -0
- package/dist/chunk-4Z3OU5RY.cjs +31 -0
- package/dist/chunk-5HTMDAXP.js +359 -0
- package/dist/chunk-5IEKR756.js +53 -0
- package/dist/chunk-5YDTZN2X.js +114 -0
- package/dist/chunk-6UNGH46J.js +75 -0
- package/dist/chunk-6Y4UL5Z6.cjs +94 -0
- package/dist/chunk-7F6BQXE2.cjs +425 -0
- package/dist/chunk-7H2GET5Z.cjs +668 -0
- package/dist/chunk-7HZ6NIAF.cjs +2 -0
- package/dist/chunk-7MZNOW6W.cjs +2263 -0
- package/dist/chunk-7XQIPES3.js +668 -0
- package/dist/chunk-AKYTYALY.js +70 -0
- package/dist/chunk-ATXBSEFT.js +22 -0
- package/dist/chunk-B6TOBUS6.cjs +80 -0
- package/dist/chunk-B7SQOKEC.cjs +91 -0
- package/dist/chunk-BB4KXGBU.js +83 -0
- package/dist/chunk-BB6DPGIV.cjs +6 -0
- package/dist/chunk-C4LMN2IR.js +27 -0
- package/dist/chunk-DFFVEKIG.js +407 -0
- package/dist/chunk-E7AX3U6M.cjs +659 -0
- package/dist/chunk-EWCOOO3H.js +5007 -0
- package/dist/chunk-F2WMR75C.cjs +183 -0
- package/dist/chunk-FBKJ3652.cjs +5034 -0
- package/dist/chunk-FEYYOBBG.cjs +24 -0
- package/dist/chunk-FL5SZ2XU.js +181 -0
- package/dist/chunk-GH2KM66J.js +37 -0
- package/dist/chunk-GWFS5DAR.cjs +37 -0
- package/dist/chunk-HNEE7IF4.js +60 -0
- package/dist/chunk-HSVOEWAM.cjs +2 -0
- package/dist/chunk-J52TXHZV.cjs +73 -0
- package/dist/chunk-JNMQKJH4.js +10 -0
- package/dist/chunk-JQOMTERC.js +89 -0
- package/dist/chunk-LABUWBKX.cjs +71 -0
- package/dist/chunk-LXFZUKP3.cjs +34 -0
- package/dist/chunk-MP2QBLUJ.cjs +70 -0
- package/dist/chunk-MUNFCOMB.cjs +62 -0
- package/dist/chunk-NH5WJNNS.js +1 -0
- package/dist/chunk-P3Q73CAW.cjs +55 -0
- package/dist/chunk-PA2YIVIT.js +61 -0
- package/dist/chunk-QFTBW7ZZ.cjs +2 -0
- package/dist/chunk-QQ5K5TZE.cjs +619 -0
- package/dist/chunk-QUSEDVYI.cjs +991 -0
- package/dist/chunk-R4V75T7J.js +1 -0
- package/dist/chunk-SGGPJWRQ.js +69 -0
- package/dist/chunk-ST5RMVLG.cjs +87 -0
- package/dist/chunk-TC2SCOTE.js +605 -0
- package/dist/chunk-U64IJDC5.cjs +109 -0
- package/dist/chunk-UX3B6S2I.cjs +65 -0
- package/dist/chunk-V5D2LIF5.js +68 -0
- package/dist/chunk-VG4OPO2R.js +240 -0
- package/dist/chunk-WQNOATKB.js +103 -0
- package/dist/chunk-Y7D2JLKS.js +4 -0
- package/dist/chunk-YJEHXYK5.js +657 -0
- package/dist/chunk-YOQP5T77.js +32 -0
- package/dist/chunk-ZIZ3CVHN.cjs +120 -0
- package/dist/chunk-ZPOUMTTH.cjs +362 -0
- package/dist/chunk-ZZLBNB3U.cjs +12 -0
- package/dist/deployer/index.cjs +10 -0
- package/dist/deployer/index.d.cts +19 -0
- package/dist/deployer/index.d.ts +19 -0
- package/dist/deployer/index.js +1 -0
- package/dist/di/index.cjs +10 -0
- package/dist/di/index.d.cts +1 -0
- package/dist/di/index.d.ts +1 -0
- package/dist/di/index.js +1 -0
- package/dist/error/index.cjs +22 -0
- package/dist/error/index.d.cts +86 -0
- package/dist/error/index.d.ts +86 -0
- package/dist/error/index.js +1 -0
- package/dist/eval/index.cjs +14 -0
- package/dist/eval/index.d.cts +43 -0
- package/dist/eval/index.d.ts +43 -0
- package/dist/eval/index.js +1 -0
- package/dist/hooks/index.cjs +18 -0
- package/dist/hooks/index.d.cts +33 -0
- package/dist/hooks/index.d.ts +33 -0
- package/dist/hooks/index.js +1 -0
- package/dist/index.cjs +281 -0
- package/dist/index.d.cts +92 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.js +112 -0
- package/dist/integration/index.cjs +14 -0
- package/dist/integration/index.d.cts +65 -0
- package/dist/integration/index.d.ts +65 -0
- package/dist/integration/index.js +1 -0
- package/dist/llm/index.cjs +10 -0
- package/dist/llm/index.d.cts +29 -0
- package/dist/llm/index.d.ts +29 -0
- package/dist/llm/index.js +1 -0
- package/dist/logger/index.cjs +43 -0
- package/dist/logger/index.d.cts +96 -0
- package/dist/logger/index.d.ts +96 -0
- package/dist/logger/index.js +2 -0
- package/dist/logger-B8XXh6ya.d.cts +159 -0
- package/dist/logger-Bpa2oLL4.d.ts +159 -0
- package/dist/mastra/index.cjs +10 -0
- package/dist/mastra/index.d.cts +29 -0
- package/dist/mastra/index.d.ts +29 -0
- package/dist/mastra/index.js +1 -0
- package/dist/mcp/index.cjs +106 -0
- package/dist/mcp/index.d.cts +29 -0
- package/dist/mcp/index.d.ts +29 -0
- package/dist/mcp/index.js +100 -0
- package/dist/memory/index.cjs +18 -0
- package/dist/memory/index.d.cts +29 -0
- package/dist/memory/index.d.ts +29 -0
- package/dist/memory/index.js +1 -0
- package/dist/network/index.cjs +311 -0
- package/dist/network/index.d.cts +29 -0
- package/dist/network/index.d.ts +29 -0
- package/dist/network/index.js +309 -0
- package/dist/network/vNext/index.cjs +873 -0
- package/dist/network/vNext/index.d.cts +29 -0
- package/dist/network/vNext/index.d.ts +29 -0
- package/dist/network/vNext/index.js +871 -0
- package/dist/relevance/index.cjs +18 -0
- package/dist/relevance/index.d.cts +49 -0
- package/dist/relevance/index.d.ts +49 -0
- package/dist/relevance/index.js +1 -0
- package/dist/runtime-context/index.cjs +10 -0
- package/dist/runtime-context/index.d.cts +52 -0
- package/dist/runtime-context/index.d.ts +52 -0
- package/dist/runtime-context/index.js +1 -0
- package/dist/server/index.cjs +62 -0
- package/dist/server/index.d.cts +52 -0
- package/dist/server/index.d.ts +52 -0
- package/dist/server/index.js +59 -0
- package/dist/storage/index.cjs +336 -0
- package/dist/storage/index.d.cts +149 -0
- package/dist/storage/index.d.ts +149 -0
- package/dist/storage/index.js +303 -0
- package/dist/telemetry/index.cjs +30 -0
- package/dist/telemetry/index.d.cts +75 -0
- package/dist/telemetry/index.d.ts +75 -0
- package/dist/telemetry/index.js +1 -0
- package/dist/telemetry/otel-vendor.cjs +103 -0
- package/dist/telemetry/otel-vendor.d.cts +20 -0
- package/dist/telemetry/otel-vendor.d.ts +20 -0
- package/dist/telemetry/otel-vendor.js +57 -0
- package/dist/tools/index.cjs +18 -0
- package/dist/tools/index.d.cts +41 -0
- package/dist/tools/index.d.ts +41 -0
- package/dist/tools/index.js +1 -0
- package/dist/tts/index.cjs +10 -0
- package/dist/tts/index.d.cts +28 -0
- package/dist/tts/index.d.ts +28 -0
- package/dist/tts/index.js +1 -0
- package/dist/types-Bo1uigWx.d.cts +17 -0
- package/dist/types-Bo1uigWx.d.ts +17 -0
- package/dist/utils.cjs +58 -0
- package/dist/utils.d.cts +149 -0
- package/dist/utils.d.ts +149 -0
- package/dist/utils.js +1 -0
- package/dist/vector/filter/index.cjs +192 -0
- package/dist/vector/filter/index.d.cts +128 -0
- package/dist/vector/filter/index.d.ts +128 -0
- package/dist/vector/filter/index.js +190 -0
- package/dist/vector/index.cjs +10 -0
- package/dist/vector/index.d.cts +77 -0
- package/dist/vector/index.d.ts +77 -0
- package/dist/vector/index.js +1 -0
- package/dist/voice/index.cjs +18 -0
- package/dist/voice/index.d.cts +29 -0
- package/dist/voice/index.d.ts +29 -0
- package/dist/voice/index.js +1 -0
- package/dist/workflows/constants.cjs +10 -0
- package/dist/workflows/constants.d.cts +3 -0
- package/dist/workflows/constants.d.ts +3 -0
- package/dist/workflows/constants.js +1 -0
- package/dist/workflows/index.cjs +42 -0
- package/dist/workflows/index.d.cts +282 -0
- package/dist/workflows/index.d.ts +282 -0
- package/dist/workflows/index.js +1 -0
- package/dist/workflows/legacy/index.cjs +90 -0
- package/dist/workflows/legacy/index.d.cts +91 -0
- package/dist/workflows/legacy/index.d.ts +91 -0
- package/dist/workflows/legacy/index.js +1 -0
- package/error.d.ts +1 -0
- package/eval.d.ts +1 -0
- package/hooks.d.ts +1 -0
- package/integration.d.ts +1 -0
- package/llm.d.ts +1 -0
- package/logger.d.ts +1 -0
- package/mastra.d.ts +1 -0
- package/mcp.d.ts +1 -0
- package/memory.d.ts +1 -0
- package/network/vNext.d.ts +1 -0
- package/network.d.ts +1 -0
- package/package.json +1 -1
- package/relevance.d.ts +1 -0
- package/runtime-context.d.ts +1 -0
- package/server.d.ts +1 -0
- package/storage.d.ts +1 -0
- package/telemetry/otel-vendor.d.ts +1 -0
- package/telemetry.d.ts +1 -0
- package/tools.d.ts +1 -0
- package/tts.d.ts +1 -0
- package/utils.d.ts +1 -0
- package/vector/filter.d.ts +1 -0
- package/vector.d.ts +1 -0
- package/voice.d.ts +1 -0
- package/workflows/_constants.d.ts +1 -0
- package/workflows/legacy.d.ts +1 -0
- package/workflows.d.ts +1 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkP3Q73CAW_cjs = require('./chunk-P3Q73CAW.cjs');
|
|
4
|
+
var promises = require('fs/promises');
|
|
5
|
+
var dotenv = require('dotenv');
|
|
6
|
+
|
|
7
|
+
var MastraBundler = class extends chunkP3Q73CAW_cjs.MastraBase {
|
|
8
|
+
constructor({ name, component = "BUNDLER" }) {
|
|
9
|
+
super({ component, name });
|
|
10
|
+
}
|
|
11
|
+
async loadEnvVars() {
|
|
12
|
+
const envVars = /* @__PURE__ */ new Map();
|
|
13
|
+
for (const file of await this.getEnvFiles()) {
|
|
14
|
+
const content = await promises.readFile(file, "utf-8");
|
|
15
|
+
const config = dotenv.parse(content);
|
|
16
|
+
Object.entries(config).forEach(([key, value]) => {
|
|
17
|
+
envVars.set(key, value);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return envVars;
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.MastraBundler = MastraBundler;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { TABLE_WORKFLOW_SNAPSHOT, TABLE_EVALS, TABLE_MESSAGES, TABLE_THREADS, TABLE_TRACES, TABLE_SCHEMAS, TABLE_RESOURCES } from './chunk-TC2SCOTE.js';
|
|
2
|
+
import { MastraBase } from './chunk-5IEKR756.js';
|
|
3
|
+
|
|
4
|
+
// src/storage/base.ts
|
|
5
|
+
var MastraStorage = class extends MastraBase {
|
|
6
|
+
/** @deprecated import from { TABLE_WORKFLOW_SNAPSHOT } '@mastra/core/storage' instead */
|
|
7
|
+
static TABLE_WORKFLOW_SNAPSHOT = TABLE_WORKFLOW_SNAPSHOT;
|
|
8
|
+
/** @deprecated import from { TABLE_EVALS } '@mastra/core/storage' instead */
|
|
9
|
+
static TABLE_EVALS = TABLE_EVALS;
|
|
10
|
+
/** @deprecated import from { TABLE_MESSAGES } '@mastra/core/storage' instead */
|
|
11
|
+
static TABLE_MESSAGES = TABLE_MESSAGES;
|
|
12
|
+
/** @deprecated import from { TABLE_THREADS } '@mastra/core/storage' instead */
|
|
13
|
+
static TABLE_THREADS = TABLE_THREADS;
|
|
14
|
+
/** @deprecated import { TABLE_TRACES } from '@mastra/core/storage' instead */
|
|
15
|
+
static TABLE_TRACES = TABLE_TRACES;
|
|
16
|
+
hasInitialized = null;
|
|
17
|
+
shouldCacheInit = true;
|
|
18
|
+
constructor({ name }) {
|
|
19
|
+
super({
|
|
20
|
+
component: "STORAGE",
|
|
21
|
+
name
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
get supports() {
|
|
25
|
+
return {
|
|
26
|
+
selectByIncludeResourceScope: false,
|
|
27
|
+
resourceWorkingMemory: false
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
ensureDate(date) {
|
|
31
|
+
if (!date) return void 0;
|
|
32
|
+
return date instanceof Date ? date : new Date(date);
|
|
33
|
+
}
|
|
34
|
+
serializeDate(date) {
|
|
35
|
+
if (!date) return void 0;
|
|
36
|
+
const dateObj = this.ensureDate(date);
|
|
37
|
+
return dateObj?.toISOString();
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Resolves limit for how many messages to fetch
|
|
41
|
+
*
|
|
42
|
+
* @param last The number of messages to fetch
|
|
43
|
+
* @param defaultLimit The default limit to use if last is not provided
|
|
44
|
+
* @returns The resolved limit
|
|
45
|
+
*/
|
|
46
|
+
resolveMessageLimit({
|
|
47
|
+
last,
|
|
48
|
+
defaultLimit
|
|
49
|
+
}) {
|
|
50
|
+
if (typeof last === "number") return Math.max(0, last);
|
|
51
|
+
if (last === false) return 0;
|
|
52
|
+
return defaultLimit;
|
|
53
|
+
}
|
|
54
|
+
getSqlType(type) {
|
|
55
|
+
switch (type) {
|
|
56
|
+
case "text":
|
|
57
|
+
return "TEXT";
|
|
58
|
+
case "timestamp":
|
|
59
|
+
return "TIMESTAMP";
|
|
60
|
+
case "integer":
|
|
61
|
+
return "INTEGER";
|
|
62
|
+
case "bigint":
|
|
63
|
+
return "BIGINT";
|
|
64
|
+
case "jsonb":
|
|
65
|
+
return "JSONB";
|
|
66
|
+
default:
|
|
67
|
+
return "TEXT";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
getDefaultValue(type) {
|
|
71
|
+
switch (type) {
|
|
72
|
+
case "text":
|
|
73
|
+
case "uuid":
|
|
74
|
+
return "DEFAULT ''";
|
|
75
|
+
case "timestamp":
|
|
76
|
+
return "DEFAULT '1970-01-01 00:00:00'";
|
|
77
|
+
case "integer":
|
|
78
|
+
case "bigint":
|
|
79
|
+
return "DEFAULT 0";
|
|
80
|
+
case "jsonb":
|
|
81
|
+
return "DEFAULT '{}'";
|
|
82
|
+
default:
|
|
83
|
+
return "DEFAULT ''";
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
batchTraceInsert({ records }) {
|
|
87
|
+
return this.batchInsert({ tableName: TABLE_TRACES, records });
|
|
88
|
+
}
|
|
89
|
+
async getResourceById(_) {
|
|
90
|
+
throw new Error(
|
|
91
|
+
`Resource working memory is not supported by this storage adapter (${this.constructor.name}). Supported storage adapters: LibSQL (@mastra/libsql), PostgreSQL (@mastra/pg), Upstash (@mastra/upstash). To use per-resource working memory, switch to one of these supported storage adapters.`
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
async saveResource(_) {
|
|
95
|
+
throw new Error(
|
|
96
|
+
`Resource working memory is not supported by this storage adapter (${this.constructor.name}). Supported storage adapters: LibSQL (@mastra/libsql), PostgreSQL (@mastra/pg), Upstash (@mastra/upstash). To use per-resource working memory, switch to one of these supported storage adapters.`
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
async updateResource(_) {
|
|
100
|
+
throw new Error(
|
|
101
|
+
`Resource working memory is not supported by this storage adapter (${this.constructor.name}). Supported storage adapters: LibSQL (@mastra/libsql), PostgreSQL (@mastra/pg), Upstash (@mastra/upstash). To use per-resource working memory, switch to one of these supported storage adapters.`
|
|
102
|
+
);
|
|
103
|
+
}
|
|
104
|
+
async init() {
|
|
105
|
+
if (this.shouldCacheInit && await this.hasInitialized) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
const tableCreationTasks = [
|
|
109
|
+
this.createTable({
|
|
110
|
+
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
111
|
+
schema: TABLE_SCHEMAS[TABLE_WORKFLOW_SNAPSHOT]
|
|
112
|
+
}),
|
|
113
|
+
this.createTable({
|
|
114
|
+
tableName: TABLE_EVALS,
|
|
115
|
+
schema: TABLE_SCHEMAS[TABLE_EVALS]
|
|
116
|
+
}),
|
|
117
|
+
this.createTable({
|
|
118
|
+
tableName: TABLE_THREADS,
|
|
119
|
+
schema: TABLE_SCHEMAS[TABLE_THREADS]
|
|
120
|
+
}),
|
|
121
|
+
this.createTable({
|
|
122
|
+
tableName: TABLE_MESSAGES,
|
|
123
|
+
schema: TABLE_SCHEMAS[TABLE_MESSAGES]
|
|
124
|
+
}),
|
|
125
|
+
this.createTable({
|
|
126
|
+
tableName: TABLE_TRACES,
|
|
127
|
+
schema: TABLE_SCHEMAS[TABLE_TRACES]
|
|
128
|
+
})
|
|
129
|
+
];
|
|
130
|
+
if (this.supports.resourceWorkingMemory) {
|
|
131
|
+
tableCreationTasks.push(
|
|
132
|
+
this.createTable({
|
|
133
|
+
tableName: TABLE_RESOURCES,
|
|
134
|
+
schema: TABLE_SCHEMAS[TABLE_RESOURCES]
|
|
135
|
+
})
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
this.hasInitialized = Promise.all(tableCreationTasks).then(() => true);
|
|
139
|
+
await this.hasInitialized;
|
|
140
|
+
await this?.alterTable?.({
|
|
141
|
+
tableName: TABLE_MESSAGES,
|
|
142
|
+
schema: TABLE_SCHEMAS[TABLE_MESSAGES],
|
|
143
|
+
ifNotExists: ["resourceId"]
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
async persistWorkflowSnapshot({
|
|
147
|
+
workflowName,
|
|
148
|
+
runId,
|
|
149
|
+
snapshot
|
|
150
|
+
}) {
|
|
151
|
+
await this.init();
|
|
152
|
+
const data = {
|
|
153
|
+
workflow_name: workflowName,
|
|
154
|
+
run_id: runId,
|
|
155
|
+
snapshot,
|
|
156
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
157
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
158
|
+
};
|
|
159
|
+
this.logger.debug("Persisting workflow snapshot", { workflowName, runId, data });
|
|
160
|
+
await this.insert({
|
|
161
|
+
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
162
|
+
record: data
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
async loadWorkflowSnapshot({
|
|
166
|
+
workflowName,
|
|
167
|
+
runId
|
|
168
|
+
}) {
|
|
169
|
+
if (!this.hasInitialized) {
|
|
170
|
+
await this.init();
|
|
171
|
+
}
|
|
172
|
+
this.logger.debug("Loading workflow snapshot", { workflowName, runId });
|
|
173
|
+
const d = await this.load({
|
|
174
|
+
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
175
|
+
keys: { workflow_name: workflowName, run_id: runId }
|
|
176
|
+
});
|
|
177
|
+
return d ? d.snapshot : null;
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export { MastraStorage };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { InstrumentClass } from './chunk-TC2SCOTE.js';
|
|
2
|
+
import { MastraBase } from './chunk-5IEKR756.js';
|
|
3
|
+
import { __decoratorStart, __decorateElement, __runInitializers } from './chunk-WQNOATKB.js';
|
|
4
|
+
|
|
5
|
+
// src/tts/index.ts
|
|
6
|
+
var _MastraTTS_decorators, _init, _a;
|
|
7
|
+
_MastraTTS_decorators = [InstrumentClass({
|
|
8
|
+
prefix: "tts",
|
|
9
|
+
excludeMethods: ["__setTools", "__setLogger", "__setTelemetry", "#log"]
|
|
10
|
+
})];
|
|
11
|
+
var MastraTTS = class extends (_a = MastraBase) {
|
|
12
|
+
model;
|
|
13
|
+
constructor({
|
|
14
|
+
model
|
|
15
|
+
}) {
|
|
16
|
+
super({
|
|
17
|
+
component: "TTS"
|
|
18
|
+
});
|
|
19
|
+
this.model = model;
|
|
20
|
+
}
|
|
21
|
+
traced(method, methodName) {
|
|
22
|
+
return this.telemetry?.traceMethod(method, {
|
|
23
|
+
spanName: `${this.model.name}-tts.${methodName}`,
|
|
24
|
+
attributes: {
|
|
25
|
+
"tts.type": `${this.model.name}`
|
|
26
|
+
}
|
|
27
|
+
}) ?? method;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
MastraTTS = /*@__PURE__*/(_ => {
|
|
31
|
+
_init = __decoratorStart(_a);
|
|
32
|
+
MastraTTS = __decorateElement(_init, 0, "MastraTTS", _MastraTTS_decorators, MastraTTS);
|
|
33
|
+
__runInitializers(_init, 1, MastraTTS);
|
|
34
|
+
return MastraTTS;
|
|
35
|
+
})();
|
|
36
|
+
|
|
37
|
+
export { MastraTTS };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkQQ5K5TZE_cjs = require('./chunk-QQ5K5TZE.cjs');
|
|
4
|
+
var chunkP3Q73CAW_cjs = require('./chunk-P3Q73CAW.cjs');
|
|
5
|
+
var chunkU64IJDC5_cjs = require('./chunk-U64IJDC5.cjs');
|
|
6
|
+
|
|
7
|
+
// src/tts/index.ts
|
|
8
|
+
var _MastraTTS_decorators, _init, _a;
|
|
9
|
+
_MastraTTS_decorators = [chunkQQ5K5TZE_cjs.InstrumentClass({
|
|
10
|
+
prefix: "tts",
|
|
11
|
+
excludeMethods: ["__setTools", "__setLogger", "__setTelemetry", "#log"]
|
|
12
|
+
})];
|
|
13
|
+
exports.MastraTTS = class MastraTTS extends (_a = chunkP3Q73CAW_cjs.MastraBase) {
|
|
14
|
+
model;
|
|
15
|
+
constructor({
|
|
16
|
+
model
|
|
17
|
+
}) {
|
|
18
|
+
super({
|
|
19
|
+
component: "TTS"
|
|
20
|
+
});
|
|
21
|
+
this.model = model;
|
|
22
|
+
}
|
|
23
|
+
traced(method, methodName) {
|
|
24
|
+
return this.telemetry?.traceMethod(method, {
|
|
25
|
+
spanName: `${this.model.name}-tts.${methodName}`,
|
|
26
|
+
attributes: {
|
|
27
|
+
"tts.type": `${this.model.name}`
|
|
28
|
+
}
|
|
29
|
+
}) ?? method;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.MastraTTS = /*@__PURE__*/(_ => {
|
|
33
|
+
_init = chunkU64IJDC5_cjs.__decoratorStart(_a);
|
|
34
|
+
exports.MastraTTS = chunkU64IJDC5_cjs.__decorateElement(_init, 0, "MastraTTS", _MastraTTS_decorators, exports.MastraTTS);
|
|
35
|
+
chunkU64IJDC5_cjs.__runInitializers(_init, 1, exports.MastraTTS);
|
|
36
|
+
return exports.MastraTTS;
|
|
37
|
+
})();
|
|
@@ -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,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkST5RMVLG_cjs = require('./chunk-ST5RMVLG.cjs');
|
|
4
|
+
var chunkB6TOBUS6_cjs = require('./chunk-B6TOBUS6.cjs');
|
|
5
|
+
|
|
6
|
+
// src/eval/metric.ts
|
|
7
|
+
var Metric = class {
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// src/eval/evaluation.ts
|
|
11
|
+
async function evaluate({
|
|
12
|
+
agentName,
|
|
13
|
+
input,
|
|
14
|
+
metric,
|
|
15
|
+
output,
|
|
16
|
+
runId,
|
|
17
|
+
globalRunId,
|
|
18
|
+
testInfo,
|
|
19
|
+
instructions
|
|
20
|
+
}) {
|
|
21
|
+
const runIdToUse = runId || crypto.randomUUID();
|
|
22
|
+
let metricResult;
|
|
23
|
+
let metricName = metric.constructor.name;
|
|
24
|
+
try {
|
|
25
|
+
metricResult = await metric.measure(input.toString(), output);
|
|
26
|
+
} catch (e) {
|
|
27
|
+
throw new chunkB6TOBUS6_cjs.MastraError(
|
|
28
|
+
{
|
|
29
|
+
id: "EVAL_METRIC_MEASURE_EXECUTION_FAILED",
|
|
30
|
+
domain: "EVAL" /* EVAL */,
|
|
31
|
+
category: "USER" /* USER */,
|
|
32
|
+
details: {
|
|
33
|
+
agentName,
|
|
34
|
+
metricName,
|
|
35
|
+
globalRunId
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
e
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
const traceObject = {
|
|
42
|
+
input: input.toString(),
|
|
43
|
+
output,
|
|
44
|
+
result: metricResult,
|
|
45
|
+
agentName,
|
|
46
|
+
metricName,
|
|
47
|
+
instructions,
|
|
48
|
+
globalRunId,
|
|
49
|
+
runId: runIdToUse,
|
|
50
|
+
testInfo
|
|
51
|
+
};
|
|
52
|
+
try {
|
|
53
|
+
chunkST5RMVLG_cjs.executeHook("onEvaluation" /* ON_EVALUATION */, traceObject);
|
|
54
|
+
} catch (e) {
|
|
55
|
+
throw new chunkB6TOBUS6_cjs.MastraError(
|
|
56
|
+
{
|
|
57
|
+
id: "EVAL_HOOK_EXECUTION_FAILED",
|
|
58
|
+
domain: "EVAL" /* EVAL */,
|
|
59
|
+
category: "USER" /* USER */,
|
|
60
|
+
details: {
|
|
61
|
+
agentName,
|
|
62
|
+
metricName,
|
|
63
|
+
globalRunId
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
e
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
return { ...metricResult, output };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
exports.Metric = Metric;
|
|
73
|
+
exports.evaluate = evaluate;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { Transform } from 'stream';
|
|
2
|
+
|
|
3
|
+
// src/logger/multi-logger.ts
|
|
4
|
+
var MultiLogger = class {
|
|
5
|
+
loggers;
|
|
6
|
+
constructor(loggers) {
|
|
7
|
+
this.loggers = loggers;
|
|
8
|
+
}
|
|
9
|
+
debug(message, ...args) {
|
|
10
|
+
this.loggers.forEach((logger) => logger.debug(message, ...args));
|
|
11
|
+
}
|
|
12
|
+
info(message, ...args) {
|
|
13
|
+
this.loggers.forEach((logger) => logger.info(message, ...args));
|
|
14
|
+
}
|
|
15
|
+
warn(message, ...args) {
|
|
16
|
+
this.loggers.forEach((logger) => logger.warn(message, ...args));
|
|
17
|
+
}
|
|
18
|
+
error(message, ...args) {
|
|
19
|
+
this.loggers.forEach((logger) => logger.error(message, ...args));
|
|
20
|
+
}
|
|
21
|
+
trackException(error) {
|
|
22
|
+
this.loggers.forEach((logger) => logger.trackException(error));
|
|
23
|
+
}
|
|
24
|
+
getTransports() {
|
|
25
|
+
const transports = [];
|
|
26
|
+
this.loggers.forEach((logger) => transports.push(...logger.getTransports().entries()));
|
|
27
|
+
return new Map(transports);
|
|
28
|
+
}
|
|
29
|
+
async getLogs(transportId, params) {
|
|
30
|
+
for (const logger of this.loggers) {
|
|
31
|
+
const logs = await logger.getLogs(transportId, params);
|
|
32
|
+
if (logs.total > 0) {
|
|
33
|
+
return logs;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return { logs: [], total: 0, page: params?.page ?? 1, perPage: params?.perPage ?? 100, hasMore: false };
|
|
37
|
+
}
|
|
38
|
+
async getLogsByRunId(args) {
|
|
39
|
+
for (const logger of this.loggers) {
|
|
40
|
+
const logs = await logger.getLogsByRunId(args);
|
|
41
|
+
if (logs.total > 0) {
|
|
42
|
+
return logs;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return { logs: [], total: 0, page: args.page ?? 1, perPage: args.perPage ?? 100, hasMore: false };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// src/logger/noop-logger.ts
|
|
50
|
+
var noopLogger = {
|
|
51
|
+
debug: () => {
|
|
52
|
+
},
|
|
53
|
+
info: () => {
|
|
54
|
+
},
|
|
55
|
+
warn: () => {
|
|
56
|
+
},
|
|
57
|
+
error: () => {
|
|
58
|
+
},
|
|
59
|
+
cleanup: async () => {
|
|
60
|
+
},
|
|
61
|
+
getTransports: () => /* @__PURE__ */ new Map(),
|
|
62
|
+
trackException: () => {
|
|
63
|
+
},
|
|
64
|
+
getLogs: async () => ({ logs: [], total: 0, page: 1, perPage: 100, hasMore: false }),
|
|
65
|
+
getLogsByRunId: async () => ({ logs: [], total: 0, page: 1, perPage: 100, hasMore: false })
|
|
66
|
+
};
|
|
67
|
+
var LoggerTransport = class extends Transform {
|
|
68
|
+
constructor(opts = {}) {
|
|
69
|
+
super({ ...opts, objectMode: true });
|
|
70
|
+
}
|
|
71
|
+
async getLogsByRunId(_args) {
|
|
72
|
+
return { logs: [], total: 0, page: _args?.page ?? 1, perPage: _args?.perPage ?? 100, hasMore: false };
|
|
73
|
+
}
|
|
74
|
+
async getLogs(_args) {
|
|
75
|
+
return { logs: [], total: 0, page: _args?.page ?? 1, perPage: _args?.perPage ?? 100, hasMore: false };
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
var createCustomTransport = (stream, getLogs, getLogsByRunId) => {
|
|
79
|
+
let transport = stream;
|
|
80
|
+
if (getLogs) {
|
|
81
|
+
transport.getLogs = getLogs;
|
|
82
|
+
}
|
|
83
|
+
if (getLogsByRunId) {
|
|
84
|
+
transport.getLogsByRunId = getLogsByRunId;
|
|
85
|
+
}
|
|
86
|
+
return transport;
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export { LoggerTransport, MultiLogger, createCustomTransport, noopLogger };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/runtime-context/index.ts
|
|
4
|
+
var RuntimeContext = class {
|
|
5
|
+
registry = /* @__PURE__ */ new Map();
|
|
6
|
+
constructor(iterable) {
|
|
7
|
+
this.registry = new Map(iterable);
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* set a value with strict typing if `Values` is a Record and the key exists in it.
|
|
11
|
+
*/
|
|
12
|
+
set(key, value) {
|
|
13
|
+
this.registry.set(key, value);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Get a value with its type
|
|
17
|
+
*/
|
|
18
|
+
get(key) {
|
|
19
|
+
return this.registry.get(key);
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Check if a key exists in the container
|
|
23
|
+
*/
|
|
24
|
+
has(key) {
|
|
25
|
+
return this.registry.has(key);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Delete a value by key
|
|
29
|
+
*/
|
|
30
|
+
delete(key) {
|
|
31
|
+
return this.registry.delete(key);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Clear all values from the container
|
|
35
|
+
*/
|
|
36
|
+
clear() {
|
|
37
|
+
this.registry.clear();
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get all keys in the container
|
|
41
|
+
*/
|
|
42
|
+
keys() {
|
|
43
|
+
return this.registry.keys();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get all values in the container
|
|
47
|
+
*/
|
|
48
|
+
values() {
|
|
49
|
+
return this.registry.values();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get all entries in the container
|
|
53
|
+
*/
|
|
54
|
+
entries() {
|
|
55
|
+
return this.registry.entries();
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Get the size of the container
|
|
59
|
+
*/
|
|
60
|
+
size() {
|
|
61
|
+
return this.registry.size;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Execute a function for each entry in the container
|
|
65
|
+
*/
|
|
66
|
+
forEach(callbackfn) {
|
|
67
|
+
this.registry.forEach(callbackfn);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
exports.RuntimeContext = RuntimeContext;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/storage/storageWithInit.ts
|
|
4
|
+
var isAugmentedSymbol = Symbol("isAugmented");
|
|
5
|
+
function augmentWithInit(storage) {
|
|
6
|
+
let hasInitialized = null;
|
|
7
|
+
const ensureInit = async () => {
|
|
8
|
+
if (!hasInitialized) {
|
|
9
|
+
hasInitialized = storage.init();
|
|
10
|
+
}
|
|
11
|
+
await hasInitialized;
|
|
12
|
+
};
|
|
13
|
+
if (storage[isAugmentedSymbol]) {
|
|
14
|
+
return storage;
|
|
15
|
+
}
|
|
16
|
+
const proxy = new Proxy(storage, {
|
|
17
|
+
get(target, prop) {
|
|
18
|
+
if (prop === isAugmentedSymbol) {
|
|
19
|
+
return true;
|
|
20
|
+
}
|
|
21
|
+
const value = target[prop];
|
|
22
|
+
if (typeof value === "function" && prop !== "init") {
|
|
23
|
+
return async (...args) => {
|
|
24
|
+
await ensureInit();
|
|
25
|
+
return Reflect.apply(value, target, args);
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
return Reflect.get(target, prop);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
return proxy;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.augmentWithInit = augmentWithInit;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkB6TOBUS6_cjs = require('./chunk-B6TOBUS6.cjs');
|
|
4
|
+
var chunkP3Q73CAW_cjs = require('./chunk-P3Q73CAW.cjs');
|
|
5
|
+
|
|
6
|
+
// src/vector/vector.ts
|
|
7
|
+
var MastraVector = class extends chunkP3Q73CAW_cjs.MastraBase {
|
|
8
|
+
constructor() {
|
|
9
|
+
super({ name: "MastraVector", component: "VECTOR" });
|
|
10
|
+
}
|
|
11
|
+
get indexSeparator() {
|
|
12
|
+
return "_";
|
|
13
|
+
}
|
|
14
|
+
async validateExistingIndex(indexName, dimension, metric) {
|
|
15
|
+
let info;
|
|
16
|
+
try {
|
|
17
|
+
info = await this.describeIndex({ indexName });
|
|
18
|
+
} catch (infoError) {
|
|
19
|
+
const mastraError = new chunkB6TOBUS6_cjs.MastraError(
|
|
20
|
+
{
|
|
21
|
+
id: "VECTOR_VALIDATE_INDEX_FETCH_FAILED",
|
|
22
|
+
text: `Index "${indexName}" already exists, but failed to fetch index info for dimension check.`,
|
|
23
|
+
domain: "MASTRA_VECTOR" /* MASTRA_VECTOR */,
|
|
24
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
25
|
+
details: { indexName }
|
|
26
|
+
},
|
|
27
|
+
infoError
|
|
28
|
+
);
|
|
29
|
+
this.logger?.trackException(mastraError);
|
|
30
|
+
this.logger?.error(mastraError.toString());
|
|
31
|
+
throw mastraError;
|
|
32
|
+
}
|
|
33
|
+
const existingDim = info?.dimension;
|
|
34
|
+
const existingMetric = info?.metric;
|
|
35
|
+
if (existingDim === dimension) {
|
|
36
|
+
this.logger?.info(
|
|
37
|
+
`Index "${indexName}" already exists with ${existingDim} dimensions and metric ${existingMetric}, skipping creation.`
|
|
38
|
+
);
|
|
39
|
+
if (existingMetric !== metric) {
|
|
40
|
+
this.logger?.warn(
|
|
41
|
+
`Attempted to create index with metric "${metric}", but index already exists with metric "${existingMetric}". To use a different metric, delete and recreate the index.`
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
} else if (info) {
|
|
45
|
+
const mastraError = new chunkB6TOBUS6_cjs.MastraError({
|
|
46
|
+
id: "VECTOR_VALIDATE_INDEX_DIMENSION_MISMATCH",
|
|
47
|
+
text: `Index "${indexName}" already exists with ${existingDim} dimensions, but ${dimension} dimensions were requested`,
|
|
48
|
+
domain: "MASTRA_VECTOR" /* MASTRA_VECTOR */,
|
|
49
|
+
category: "USER" /* USER */,
|
|
50
|
+
details: { indexName, existingDim, requestedDim: dimension }
|
|
51
|
+
});
|
|
52
|
+
this.logger?.trackException(mastraError);
|
|
53
|
+
this.logger?.error(mastraError.toString());
|
|
54
|
+
throw mastraError;
|
|
55
|
+
} else {
|
|
56
|
+
const mastraError = new chunkB6TOBUS6_cjs.MastraError({
|
|
57
|
+
id: "VECTOR_VALIDATE_INDEX_NO_DIMENSION",
|
|
58
|
+
text: `Index "${indexName}" already exists, but could not retrieve its dimensions for validation.`,
|
|
59
|
+
domain: "MASTRA_VECTOR" /* MASTRA_VECTOR */,
|
|
60
|
+
category: "SYSTEM" /* SYSTEM */,
|
|
61
|
+
details: { indexName }
|
|
62
|
+
});
|
|
63
|
+
this.logger?.trackException(mastraError);
|
|
64
|
+
this.logger?.error(mastraError.toString());
|
|
65
|
+
throw mastraError;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
exports.MastraVector = MastraVector;
|