@mastra/core 0.0.0-commonjs-20250227130920
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 +21 -0
- package/README.md +180 -0
- package/dist/agent/index.cjs +1865 -0
- package/dist/agent/index.d.cts +15 -0
- package/dist/agent/index.d.ts +15 -0
- package/dist/agent/index.js +1 -0
- package/dist/base-D90KQ4XI.d.ts +139 -0
- package/dist/base-hs9NDAZ2.d.cts +139 -0
- package/dist/base-nKCMCNrM.d.ts +920 -0
- package/dist/base-nhesrHv3.d.cts +920 -0
- package/dist/base.cjs +138 -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 +158 -0
- package/dist/bundler/index.d.cts +28 -0
- package/dist/bundler/index.d.ts +28 -0
- package/dist/bundler/index.js +1 -0
- package/dist/chunk-33GSTUNK.js +620 -0
- package/dist/chunk-4YRYBCOZ.js +10 -0
- package/dist/chunk-55NFNRKO.js +10 -0
- package/dist/chunk-5XPCMNGW.js +215 -0
- package/dist/chunk-B3M27AMP.js +1479 -0
- package/dist/chunk-BB4KXGBU.js +83 -0
- package/dist/chunk-C6A6W6XS.js +77 -0
- package/dist/chunk-HQ55LN2U.js +318 -0
- package/dist/chunk-KNVTCZW7.js +416 -0
- package/dist/chunk-LH47WVJL.js +61 -0
- package/dist/chunk-NGD2HQYW.js +346 -0
- package/dist/chunk-NUDAZEOG.js +35 -0
- package/dist/chunk-OZ4XVJ6F.js +49 -0
- package/dist/chunk-PHMSPCTC.js +145 -0
- package/dist/chunk-PNZK456O.js +88 -0
- package/dist/chunk-QAAJAHDB.js +37 -0
- package/dist/chunk-RG66XEJT.js +8 -0
- package/dist/chunk-SIFBBGY6.js +190 -0
- package/dist/chunk-SVEAENO7.js +22 -0
- package/dist/chunk-SY5244IR.js +1499 -0
- package/dist/chunk-W5HVJX45.js +402 -0
- package/dist/chunk-WIBGG4X6.js +173 -0
- package/dist/chunk-ZDWFBE5L.js +1 -0
- package/dist/chunk-ZINPRHAN.js +22 -0
- package/dist/deployer/index.cjs +165 -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/eval/index.cjs +110 -0
- package/dist/eval/index.d.cts +28 -0
- package/dist/eval/index.d.ts +28 -0
- package/dist/eval/index.js +1 -0
- package/dist/filter/index.cjs +192 -0
- package/dist/filter/index.d.cts +90 -0
- package/dist/filter/index.d.ts +90 -0
- package/dist/filter/index.js +1 -0
- package/dist/hooks/index.cjs +87 -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-mKY1XrpK.d.cts +90 -0
- package/dist/index-mKY1XrpK.d.ts +90 -0
- package/dist/index.cjs +6844 -0
- package/dist/index.d.cts +97 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.js +119 -0
- package/dist/integration/index.cjs +113 -0
- package/dist/integration/index.d.cts +52 -0
- package/dist/integration/index.d.ts +52 -0
- package/dist/integration/index.js +1 -0
- package/dist/llm/index.cjs +2 -0
- package/dist/llm/index.d.cts +15 -0
- package/dist/llm/index.d.ts +15 -0
- package/dist/llm/index.js +1 -0
- package/dist/logger/index.cjs +159 -0
- package/dist/logger/index.d.cts +3 -0
- package/dist/logger/index.d.ts +3 -0
- package/dist/logger/index.js +1 -0
- package/dist/mastra/index.cjs +1741 -0
- package/dist/mastra/index.d.cts +67 -0
- package/dist/mastra/index.d.ts +67 -0
- package/dist/mastra/index.js +1 -0
- package/dist/memory/index.cjs +1907 -0
- package/dist/memory/index.d.cts +15 -0
- package/dist/memory/index.d.ts +15 -0
- package/dist/memory/index.js +1 -0
- package/dist/relevance/index.cjs +1927 -0
- package/dist/relevance/index.d.cts +21 -0
- package/dist/relevance/index.d.ts +21 -0
- package/dist/relevance/index.js +1 -0
- package/dist/storage/index.cjs +361 -0
- package/dist/storage/index.d.cts +15 -0
- package/dist/storage/index.d.ts +15 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage/libsql/index.cjs +770 -0
- package/dist/storage/libsql/index.d.cts +81 -0
- package/dist/storage/libsql/index.d.ts +81 -0
- package/dist/storage/libsql/index.js +1 -0
- package/dist/telemetry/index.cjs +413 -0
- package/dist/telemetry/index.d.cts +51 -0
- package/dist/telemetry/index.d.ts +51 -0
- package/dist/telemetry/index.js +1 -0
- package/dist/telemetry/otel-vendor.cjs +52 -0
- package/dist/telemetry/otel-vendor.d.cts +7 -0
- package/dist/telemetry/otel-vendor.d.ts +7 -0
- package/dist/telemetry/otel-vendor.js +7 -0
- package/dist/tools/index.cjs +25 -0
- package/dist/tools/index.d.cts +29 -0
- package/dist/tools/index.d.ts +29 -0
- package/dist/tools/index.js +1 -0
- package/dist/tts/index.cjs +328 -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-m9RryK9a.d.cts +14 -0
- package/dist/types-m9RryK9a.d.ts +14 -0
- package/dist/utils.cjs +179 -0
- package/dist/utils.d.cts +26 -0
- package/dist/utils.d.ts +26 -0
- package/dist/utils.js +1 -0
- package/dist/vector/index.cjs +145 -0
- package/dist/vector/index.d.cts +30 -0
- package/dist/vector/index.d.ts +30 -0
- package/dist/vector/index.js +1 -0
- package/dist/vector/libsql/index.cjs +951 -0
- package/dist/vector/libsql/index.d.cts +29 -0
- package/dist/vector/libsql/index.d.ts +29 -0
- package/dist/vector/libsql/index.js +1 -0
- package/dist/voice/index.cjs +369 -0
- package/dist/voice/index.d.cts +67 -0
- package/dist/voice/index.d.ts +67 -0
- package/dist/voice/index.js +76 -0
- package/dist/workflow-DqQ4pON_.d.cts +84 -0
- package/dist/workflow-Ng_F_Zaf.d.ts +84 -0
- package/dist/workflows/index.cjs +1628 -0
- package/dist/workflows/index.d.cts +48 -0
- package/dist/workflows/index.d.ts +48 -0
- package/dist/workflows/index.js +1 -0
- package/package.json +162 -0
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
import { TABLE_WORKFLOW_SNAPSHOT, TABLE_EVALS, TABLE_MESSAGES, TABLE_THREADS, TABLE_TRACES } from './chunk-RG66XEJT.js';
|
|
2
|
+
import { MastraBase } from './chunk-OZ4XVJ6F.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
|
+
constructor({ name }) {
|
|
18
|
+
super({
|
|
19
|
+
component: "STORAGE",
|
|
20
|
+
name
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
async __batchInsert({
|
|
24
|
+
tableName,
|
|
25
|
+
records
|
|
26
|
+
}) {
|
|
27
|
+
await this.init();
|
|
28
|
+
return this.batchInsert({ tableName, records });
|
|
29
|
+
}
|
|
30
|
+
async __getThreadById({ threadId }) {
|
|
31
|
+
await this.init();
|
|
32
|
+
return this.getThreadById({ threadId });
|
|
33
|
+
}
|
|
34
|
+
async __getThreadsByResourceId({ resourceId }) {
|
|
35
|
+
await this.init();
|
|
36
|
+
return this.getThreadsByResourceId({ resourceId });
|
|
37
|
+
}
|
|
38
|
+
async __saveThread({ thread }) {
|
|
39
|
+
await this.init();
|
|
40
|
+
return this.saveThread({ thread });
|
|
41
|
+
}
|
|
42
|
+
async __updateThread({
|
|
43
|
+
id,
|
|
44
|
+
title,
|
|
45
|
+
metadata
|
|
46
|
+
}) {
|
|
47
|
+
await this.init();
|
|
48
|
+
return this.updateThread({ id, title, metadata });
|
|
49
|
+
}
|
|
50
|
+
async __deleteThread({ threadId }) {
|
|
51
|
+
await this.init();
|
|
52
|
+
return this.deleteThread({ threadId });
|
|
53
|
+
}
|
|
54
|
+
async __getMessages({ threadId, selectBy, threadConfig }) {
|
|
55
|
+
await this.init();
|
|
56
|
+
return this.getMessages({ threadId, selectBy, threadConfig });
|
|
57
|
+
}
|
|
58
|
+
async __saveMessages({ messages }) {
|
|
59
|
+
await this.init();
|
|
60
|
+
return this.saveMessages({ messages });
|
|
61
|
+
}
|
|
62
|
+
async __getTraces({
|
|
63
|
+
scope,
|
|
64
|
+
page,
|
|
65
|
+
perPage,
|
|
66
|
+
attributes
|
|
67
|
+
}) {
|
|
68
|
+
await this.init();
|
|
69
|
+
return this.getTraces({ scope, page, perPage, attributes });
|
|
70
|
+
}
|
|
71
|
+
async init() {
|
|
72
|
+
if (await this.hasInitialized) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
this.hasInitialized = Promise.all([
|
|
76
|
+
this.createTable({
|
|
77
|
+
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
78
|
+
schema: {
|
|
79
|
+
workflow_name: {
|
|
80
|
+
type: "text"
|
|
81
|
+
},
|
|
82
|
+
run_id: {
|
|
83
|
+
type: "text"
|
|
84
|
+
},
|
|
85
|
+
snapshot: {
|
|
86
|
+
type: "text"
|
|
87
|
+
},
|
|
88
|
+
createdAt: {
|
|
89
|
+
type: "timestamp"
|
|
90
|
+
},
|
|
91
|
+
updatedAt: {
|
|
92
|
+
type: "timestamp"
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}),
|
|
96
|
+
this.createTable({
|
|
97
|
+
tableName: TABLE_EVALS,
|
|
98
|
+
schema: {
|
|
99
|
+
input: {
|
|
100
|
+
type: "text"
|
|
101
|
+
},
|
|
102
|
+
output: {
|
|
103
|
+
type: "text"
|
|
104
|
+
},
|
|
105
|
+
result: {
|
|
106
|
+
type: "jsonb"
|
|
107
|
+
},
|
|
108
|
+
agent_name: {
|
|
109
|
+
type: "text"
|
|
110
|
+
},
|
|
111
|
+
metric_name: {
|
|
112
|
+
type: "text"
|
|
113
|
+
},
|
|
114
|
+
instructions: {
|
|
115
|
+
type: "text"
|
|
116
|
+
},
|
|
117
|
+
test_info: {
|
|
118
|
+
type: "jsonb",
|
|
119
|
+
nullable: true
|
|
120
|
+
},
|
|
121
|
+
global_run_id: {
|
|
122
|
+
type: "text"
|
|
123
|
+
},
|
|
124
|
+
run_id: {
|
|
125
|
+
type: "text"
|
|
126
|
+
},
|
|
127
|
+
created_at: {
|
|
128
|
+
type: "timestamp"
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}),
|
|
132
|
+
this.createTable({
|
|
133
|
+
tableName: TABLE_THREADS,
|
|
134
|
+
schema: {
|
|
135
|
+
id: { type: "text", nullable: false, primaryKey: true },
|
|
136
|
+
resourceId: { type: "text", nullable: false },
|
|
137
|
+
title: { type: "text", nullable: false },
|
|
138
|
+
metadata: { type: "text", nullable: true },
|
|
139
|
+
createdAt: { type: "timestamp", nullable: false },
|
|
140
|
+
updatedAt: { type: "timestamp", nullable: false }
|
|
141
|
+
}
|
|
142
|
+
}),
|
|
143
|
+
this.createTable({
|
|
144
|
+
tableName: TABLE_MESSAGES,
|
|
145
|
+
schema: {
|
|
146
|
+
id: { type: "text", nullable: false, primaryKey: true },
|
|
147
|
+
thread_id: { type: "text", nullable: false },
|
|
148
|
+
content: { type: "text", nullable: false },
|
|
149
|
+
role: { type: "text", nullable: false },
|
|
150
|
+
type: { type: "text", nullable: false },
|
|
151
|
+
createdAt: { type: "timestamp", nullable: false }
|
|
152
|
+
}
|
|
153
|
+
}),
|
|
154
|
+
this.createTable({
|
|
155
|
+
tableName: TABLE_TRACES,
|
|
156
|
+
schema: {
|
|
157
|
+
id: { type: "text", nullable: false, primaryKey: true },
|
|
158
|
+
parentSpanId: { type: "text", nullable: true },
|
|
159
|
+
name: { type: "text", nullable: false },
|
|
160
|
+
traceId: { type: "text", nullable: false },
|
|
161
|
+
scope: { type: "text", nullable: false },
|
|
162
|
+
kind: { type: "integer", nullable: false },
|
|
163
|
+
attributes: { type: "jsonb", nullable: true },
|
|
164
|
+
status: { type: "jsonb", nullable: true },
|
|
165
|
+
events: { type: "jsonb", nullable: true },
|
|
166
|
+
links: { type: "jsonb", nullable: true },
|
|
167
|
+
other: { type: "text", nullable: true },
|
|
168
|
+
startTime: { type: "bigint", nullable: false },
|
|
169
|
+
endTime: { type: "bigint", nullable: false },
|
|
170
|
+
createdAt: { type: "timestamp", nullable: false }
|
|
171
|
+
}
|
|
172
|
+
})
|
|
173
|
+
]).then(() => true);
|
|
174
|
+
await this.hasInitialized;
|
|
175
|
+
}
|
|
176
|
+
async persistWorkflowSnapshot({
|
|
177
|
+
workflowName,
|
|
178
|
+
runId,
|
|
179
|
+
snapshot
|
|
180
|
+
}) {
|
|
181
|
+
await this.init();
|
|
182
|
+
const data = {
|
|
183
|
+
workflow_name: workflowName,
|
|
184
|
+
run_id: runId,
|
|
185
|
+
snapshot,
|
|
186
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
187
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
188
|
+
};
|
|
189
|
+
this.logger.debug("Persisting workflow snapshot", { workflowName, runId, data });
|
|
190
|
+
await this.insert({
|
|
191
|
+
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
192
|
+
record: data
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
async loadWorkflowSnapshot({
|
|
196
|
+
workflowName,
|
|
197
|
+
runId
|
|
198
|
+
}) {
|
|
199
|
+
if (!this.hasInitialized) {
|
|
200
|
+
await this.init();
|
|
201
|
+
}
|
|
202
|
+
this.logger.debug("Loading workflow snapshot", { workflowName, runId });
|
|
203
|
+
const d = await this.load({
|
|
204
|
+
tableName: TABLE_WORKFLOW_SNAPSHOT,
|
|
205
|
+
keys: { workflow_name: workflowName, run_id: runId }
|
|
206
|
+
});
|
|
207
|
+
return d ? d.snapshot : null;
|
|
208
|
+
}
|
|
209
|
+
async __getEvalsByAgentName(agentName, type) {
|
|
210
|
+
await this.init();
|
|
211
|
+
return this.getEvalsByAgentName(agentName, type);
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export { MastraStorage };
|