@mastra/convex 0.0.0-fix-prompt-enhance-route-20251210210827 → 0.0.0-fix-11329-windows-path-20251222155941
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/CHANGELOG.md +206 -5
- package/README.md +1 -1
- package/dist/{chunk-QKN2PWR2.cjs → chunk-BKVR7SL7.cjs} +2 -89
- package/dist/chunk-BKVR7SL7.cjs.map +1 -0
- package/dist/{chunk-NZCHEPNU.js → chunk-KSAPIIEJ.js} +5 -65
- package/dist/chunk-KSAPIIEJ.js.map +1 -0
- package/dist/chunk-PKUUSREO.js +76 -0
- package/dist/chunk-PKUUSREO.js.map +1 -0
- package/dist/chunk-ZBUP3DS6.cjs +93 -0
- package/dist/chunk-ZBUP3DS6.cjs.map +1 -0
- package/dist/index.cjs +177 -168
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +161 -152
- package/dist/index.js.map +1 -1
- package/dist/schema.cjs +72 -0
- package/dist/schema.cjs.map +1 -0
- package/dist/schema.d.ts +151 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +3 -0
- package/dist/schema.js.map +1 -0
- package/dist/server/index.cjs +19 -18
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +2 -1
- package/dist/storage/db/index.d.ts +57 -0
- package/dist/storage/db/index.d.ts.map +1 -0
- package/dist/storage/domains/{memory.d.ts → memory/index.d.ts} +6 -4
- package/dist/storage/domains/memory/index.d.ts.map +1 -0
- package/dist/storage/domains/{scores.d.ts → scores/index.d.ts} +6 -4
- package/dist/storage/domains/scores/index.d.ts.map +1 -0
- package/dist/storage/domains/{workflows.d.ts → workflows/index.d.ts} +9 -13
- package/dist/storage/domains/workflows/index.d.ts.map +1 -0
- package/dist/storage/index.d.ts +32 -39
- package/dist/storage/index.d.ts.map +1 -1
- package/package.json +15 -6
- package/dist/chunk-NZCHEPNU.js.map +0 -1
- package/dist/chunk-QKN2PWR2.cjs.map +0 -1
- package/dist/storage/domains/memory.d.ts.map +0 -1
- package/dist/storage/domains/scores.d.ts.map +0 -1
- package/dist/storage/domains/workflows.d.ts.map +0 -1
- package/dist/storage/operations.d.ts +0 -40
- package/dist/storage/operations.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var chunkBKVR7SL7_cjs = require('./chunk-BKVR7SL7.cjs');
|
|
4
|
+
var chunkZBUP3DS6_cjs = require('./chunk-ZBUP3DS6.cjs');
|
|
4
5
|
var storage = require('@mastra/core/storage');
|
|
5
6
|
var agent = require('@mastra/core/agent');
|
|
6
7
|
var error = require('@mastra/core/error');
|
|
7
8
|
var crypto = require('crypto');
|
|
9
|
+
var base = require('@mastra/core/base');
|
|
8
10
|
var vector = require('@mastra/core/vector');
|
|
9
11
|
|
|
10
12
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
@@ -74,13 +76,114 @@ var ConvexAdminClient = class {
|
|
|
74
76
|
return result;
|
|
75
77
|
}
|
|
76
78
|
};
|
|
79
|
+
function resolveConvexConfig(config) {
|
|
80
|
+
if ("client" in config) {
|
|
81
|
+
return config.client;
|
|
82
|
+
}
|
|
83
|
+
return new ConvexAdminClient(config);
|
|
84
|
+
}
|
|
85
|
+
var ConvexDB = class extends base.MastraBase {
|
|
86
|
+
constructor(client) {
|
|
87
|
+
super({ name: "convex-db" });
|
|
88
|
+
this.client = client;
|
|
89
|
+
}
|
|
90
|
+
async hasColumn(_table, _column) {
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
async clearTable({ tableName }) {
|
|
94
|
+
let hasMore = true;
|
|
95
|
+
while (hasMore) {
|
|
96
|
+
const response = await this.client.callStorageRaw({
|
|
97
|
+
op: "clearTable",
|
|
98
|
+
tableName
|
|
99
|
+
});
|
|
100
|
+
hasMore = response.hasMore ?? false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async dropTable({ tableName }) {
|
|
104
|
+
let hasMore = true;
|
|
105
|
+
while (hasMore) {
|
|
106
|
+
const response = await this.client.callStorageRaw({
|
|
107
|
+
op: "dropTable",
|
|
108
|
+
tableName
|
|
109
|
+
});
|
|
110
|
+
hasMore = response.hasMore ?? false;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async insert({ tableName, record }) {
|
|
114
|
+
await this.client.callStorage({
|
|
115
|
+
op: "insert",
|
|
116
|
+
tableName,
|
|
117
|
+
record: this.normalizeRecord(tableName, record)
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
async batchInsert({ tableName, records }) {
|
|
121
|
+
if (records.length === 0) return;
|
|
122
|
+
await this.client.callStorage({
|
|
123
|
+
op: "batchInsert",
|
|
124
|
+
tableName,
|
|
125
|
+
records: records.map((record) => this.normalizeRecord(tableName, record))
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
async load({ tableName, keys }) {
|
|
129
|
+
const result = await this.client.callStorage({
|
|
130
|
+
op: "load",
|
|
131
|
+
tableName,
|
|
132
|
+
keys
|
|
133
|
+
});
|
|
134
|
+
return result;
|
|
135
|
+
}
|
|
136
|
+
async queryTable(tableName, filters) {
|
|
137
|
+
return this.client.callStorage({
|
|
138
|
+
op: "queryTable",
|
|
139
|
+
tableName,
|
|
140
|
+
filters
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
async deleteMany(tableName, ids) {
|
|
144
|
+
if (ids.length === 0) return;
|
|
145
|
+
await this.client.callStorage({
|
|
146
|
+
op: "deleteMany",
|
|
147
|
+
tableName,
|
|
148
|
+
ids
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
normalizeRecord(tableName, record) {
|
|
152
|
+
const normalized = { ...record };
|
|
153
|
+
if (tableName === storage.TABLE_WORKFLOW_SNAPSHOT && !normalized.id) {
|
|
154
|
+
const runId = normalized.run_id || normalized.runId;
|
|
155
|
+
const workflowName = normalized.workflow_name || normalized.workflowName;
|
|
156
|
+
normalized.id = workflowName ? `${workflowName}-${runId}` : runId;
|
|
157
|
+
}
|
|
158
|
+
if (!normalized.id) {
|
|
159
|
+
normalized.id = crypto__default.default.randomUUID();
|
|
160
|
+
}
|
|
161
|
+
for (const [key, value] of Object.entries(normalized)) {
|
|
162
|
+
if (value instanceof Date) {
|
|
163
|
+
normalized[key] = value.toISOString();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
return normalized;
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
// src/storage/domains/memory/index.ts
|
|
77
171
|
var MemoryConvex = class extends storage.MemoryStorage {
|
|
78
|
-
|
|
172
|
+
#db;
|
|
173
|
+
constructor(config) {
|
|
79
174
|
super();
|
|
80
|
-
|
|
175
|
+
const client = resolveConvexConfig(config);
|
|
176
|
+
this.#db = new ConvexDB(client);
|
|
177
|
+
}
|
|
178
|
+
async init() {
|
|
179
|
+
}
|
|
180
|
+
async dangerouslyClearAll() {
|
|
181
|
+
await this.#db.clearTable({ tableName: storage.TABLE_THREADS });
|
|
182
|
+
await this.#db.clearTable({ tableName: storage.TABLE_MESSAGES });
|
|
183
|
+
await this.#db.clearTable({ tableName: storage.TABLE_RESOURCES });
|
|
81
184
|
}
|
|
82
185
|
async getThreadById({ threadId }) {
|
|
83
|
-
const row = await this.
|
|
186
|
+
const row = await this.#db.load({
|
|
84
187
|
tableName: storage.TABLE_THREADS,
|
|
85
188
|
keys: { id: threadId }
|
|
86
189
|
});
|
|
@@ -93,7 +196,7 @@ var MemoryConvex = class extends storage.MemoryStorage {
|
|
|
93
196
|
};
|
|
94
197
|
}
|
|
95
198
|
async saveThread({ thread }) {
|
|
96
|
-
await this.
|
|
199
|
+
await this.#db.insert({
|
|
97
200
|
tableName: storage.TABLE_THREADS,
|
|
98
201
|
record: {
|
|
99
202
|
...thread,
|
|
@@ -129,21 +232,21 @@ var MemoryConvex = class extends storage.MemoryStorage {
|
|
|
129
232
|
return updated;
|
|
130
233
|
}
|
|
131
234
|
async deleteThread({ threadId }) {
|
|
132
|
-
const messages = await this.
|
|
235
|
+
const messages = await this.#db.queryTable(storage.TABLE_MESSAGES, [
|
|
133
236
|
{ field: "thread_id", value: threadId }
|
|
134
237
|
]);
|
|
135
|
-
await this.
|
|
238
|
+
await this.#db.deleteMany(
|
|
136
239
|
storage.TABLE_MESSAGES,
|
|
137
240
|
messages.map((msg) => msg.id)
|
|
138
241
|
);
|
|
139
|
-
await this.
|
|
242
|
+
await this.#db.deleteMany(storage.TABLE_THREADS, [threadId]);
|
|
140
243
|
}
|
|
141
244
|
async listThreadsByResourceId(args) {
|
|
142
245
|
const { resourceId, page = 0, perPage: perPageInput, orderBy } = args;
|
|
143
246
|
const perPage = storage.normalizePerPage(perPageInput, 100);
|
|
144
247
|
const { field, direction } = this.parseOrderBy(orderBy);
|
|
145
248
|
const { offset, perPage: perPageForResponse } = storage.calculatePagination(page, perPageInput, perPage);
|
|
146
|
-
const rows = await this.
|
|
249
|
+
const rows = await this.#db.queryTable(storage.TABLE_THREADS, [{ field: "resourceId", value: resourceId }]);
|
|
147
250
|
const threads = rows.map((row) => ({
|
|
148
251
|
...row,
|
|
149
252
|
metadata: typeof row.metadata === "string" ? JSON.parse(row.metadata) : row.metadata,
|
|
@@ -186,9 +289,7 @@ var MemoryConvex = class extends storage.MemoryStorage {
|
|
|
186
289
|
const { field, direction } = this.parseOrderBy(orderBy, "ASC");
|
|
187
290
|
let rows = [];
|
|
188
291
|
for (const tid of threadIds) {
|
|
189
|
-
const threadRows = await this.
|
|
190
|
-
{ field: "thread_id", value: tid }
|
|
191
|
-
]);
|
|
292
|
+
const threadRows = await this.#db.queryTable(storage.TABLE_MESSAGES, [{ field: "thread_id", value: tid }]);
|
|
192
293
|
rows.push(...threadRows);
|
|
193
294
|
}
|
|
194
295
|
if (resourceId) {
|
|
@@ -232,14 +333,14 @@ var MemoryConvex = class extends storage.MemoryStorage {
|
|
|
232
333
|
}
|
|
233
334
|
}
|
|
234
335
|
if (!target) {
|
|
235
|
-
const messageRows = await this.
|
|
336
|
+
const messageRows = await this.#db.queryTable(storage.TABLE_MESSAGES, [
|
|
236
337
|
{ field: "id", value: includeItem.id }
|
|
237
338
|
]);
|
|
238
339
|
if (messageRows.length > 0) {
|
|
239
340
|
target = messageRows[0];
|
|
240
341
|
targetThreadId = target.thread_id;
|
|
241
342
|
if (targetThreadId && !threadMessagesCache.has(targetThreadId)) {
|
|
242
|
-
const otherThreadRows = await this.
|
|
343
|
+
const otherThreadRows = await this.#db.queryTable(storage.TABLE_MESSAGES, [
|
|
243
344
|
{ field: "thread_id", value: targetThreadId }
|
|
244
345
|
]);
|
|
245
346
|
threadMessagesCache.set(targetThreadId, otherThreadRows);
|
|
@@ -282,7 +383,7 @@ var MemoryConvex = class extends storage.MemoryStorage {
|
|
|
282
383
|
if (messageIds.length === 0) {
|
|
283
384
|
return { messages: [] };
|
|
284
385
|
}
|
|
285
|
-
const rows = await this.
|
|
386
|
+
const rows = await this.#db.queryTable(storage.TABLE_MESSAGES, void 0);
|
|
286
387
|
const filtered = rows.filter((row) => messageIds.includes(row.id)).map((row) => this.parseStoredMessage(row));
|
|
287
388
|
const list = new agent.MessageList().add(filtered, "memory");
|
|
288
389
|
return { messages: list.get.all.db() };
|
|
@@ -307,7 +408,7 @@ var MemoryConvex = class extends storage.MemoryStorage {
|
|
|
307
408
|
resourceId: message.resourceId
|
|
308
409
|
};
|
|
309
410
|
});
|
|
310
|
-
await this.
|
|
411
|
+
await this.#db.batchInsert({
|
|
311
412
|
tableName: storage.TABLE_MESSAGES,
|
|
312
413
|
records: normalized
|
|
313
414
|
});
|
|
@@ -316,7 +417,7 @@ var MemoryConvex = class extends storage.MemoryStorage {
|
|
|
316
417
|
for (const threadId of threadIds) {
|
|
317
418
|
const thread = await this.getThreadById({ threadId });
|
|
318
419
|
if (thread) {
|
|
319
|
-
await this.
|
|
420
|
+
await this.#db.insert({
|
|
320
421
|
tableName: storage.TABLE_THREADS,
|
|
321
422
|
record: {
|
|
322
423
|
...thread,
|
|
@@ -335,7 +436,7 @@ var MemoryConvex = class extends storage.MemoryStorage {
|
|
|
335
436
|
messages
|
|
336
437
|
}) {
|
|
337
438
|
if (messages.length === 0) return [];
|
|
338
|
-
const existing = await this.
|
|
439
|
+
const existing = await this.#db.queryTable(storage.TABLE_MESSAGES, void 0);
|
|
339
440
|
const updated = [];
|
|
340
441
|
const affectedThreadIds = /* @__PURE__ */ new Set();
|
|
341
442
|
for (const update of messages) {
|
|
@@ -364,7 +465,7 @@ var MemoryConvex = class extends storage.MemoryStorage {
|
|
|
364
465
|
};
|
|
365
466
|
current.content = JSON.stringify(mergedContent);
|
|
366
467
|
}
|
|
367
|
-
await this.
|
|
468
|
+
await this.#db.insert({
|
|
368
469
|
tableName: storage.TABLE_MESSAGES,
|
|
369
470
|
record: current
|
|
370
471
|
});
|
|
@@ -374,7 +475,7 @@ var MemoryConvex = class extends storage.MemoryStorage {
|
|
|
374
475
|
for (const threadId of affectedThreadIds) {
|
|
375
476
|
const thread = await this.getThreadById({ threadId });
|
|
376
477
|
if (thread) {
|
|
377
|
-
await this.
|
|
478
|
+
await this.#db.insert({
|
|
378
479
|
tableName: storage.TABLE_THREADS,
|
|
379
480
|
record: {
|
|
380
481
|
...thread,
|
|
@@ -389,7 +490,7 @@ var MemoryConvex = class extends storage.MemoryStorage {
|
|
|
389
490
|
return updated;
|
|
390
491
|
}
|
|
391
492
|
async deleteMessages(messageIds) {
|
|
392
|
-
await this.
|
|
493
|
+
await this.#db.deleteMany(storage.TABLE_MESSAGES, messageIds);
|
|
393
494
|
}
|
|
394
495
|
async saveResource({ resource }) {
|
|
395
496
|
const record = {
|
|
@@ -400,14 +501,14 @@ var MemoryConvex = class extends storage.MemoryStorage {
|
|
|
400
501
|
if (resource.metadata !== void 0) {
|
|
401
502
|
record.metadata = resource.metadata;
|
|
402
503
|
}
|
|
403
|
-
await this.
|
|
504
|
+
await this.#db.insert({
|
|
404
505
|
tableName: storage.TABLE_RESOURCES,
|
|
405
506
|
record
|
|
406
507
|
});
|
|
407
508
|
return resource;
|
|
408
509
|
}
|
|
409
510
|
async getResourceById({ resourceId }) {
|
|
410
|
-
const record = await this.
|
|
511
|
+
const record = await this.#db.load({
|
|
411
512
|
tableName: storage.TABLE_RESOURCES,
|
|
412
513
|
keys: { id: resourceId }
|
|
413
514
|
});
|
|
@@ -493,12 +594,19 @@ var MemoryConvex = class extends storage.MemoryStorage {
|
|
|
493
594
|
}
|
|
494
595
|
};
|
|
495
596
|
var ScoresConvex = class extends storage.ScoresStorage {
|
|
496
|
-
|
|
597
|
+
#db;
|
|
598
|
+
constructor(config) {
|
|
497
599
|
super();
|
|
498
|
-
|
|
600
|
+
const client = resolveConvexConfig(config);
|
|
601
|
+
this.#db = new ConvexDB(client);
|
|
602
|
+
}
|
|
603
|
+
async init() {
|
|
604
|
+
}
|
|
605
|
+
async dangerouslyClearAll() {
|
|
606
|
+
await this.#db.clearTable({ tableName: storage.TABLE_SCORERS });
|
|
499
607
|
}
|
|
500
608
|
async getScoreById({ id }) {
|
|
501
|
-
const row = await this.
|
|
609
|
+
const row = await this.#db.load({
|
|
502
610
|
tableName: storage.TABLE_SCORERS,
|
|
503
611
|
keys: { id }
|
|
504
612
|
});
|
|
@@ -512,7 +620,7 @@ var ScoresConvex = class extends storage.ScoresStorage {
|
|
|
512
620
|
createdAt: now.toISOString(),
|
|
513
621
|
updatedAt: now.toISOString()
|
|
514
622
|
};
|
|
515
|
-
await this.
|
|
623
|
+
await this.#db.insert({
|
|
516
624
|
tableName: storage.TABLE_SCORERS,
|
|
517
625
|
record
|
|
518
626
|
});
|
|
@@ -563,7 +671,7 @@ var ScoresConvex = class extends storage.ScoresStorage {
|
|
|
563
671
|
new Error("page must be >= 0")
|
|
564
672
|
);
|
|
565
673
|
}
|
|
566
|
-
const rows = await this.
|
|
674
|
+
const rows = await this.#db.queryTable(storage.TABLE_SCORERS, void 0);
|
|
567
675
|
const filtered = rows.filter((row) => filters.scorerId ? row.scorerId === filters.scorerId : true).filter((row) => filters.entityId ? row.entityId === filters.entityId : true).filter((row) => filters.entityType ? row.entityType === filters.entityType : true).filter((row) => filters.runId ? row.runId === filters.runId : true).filter((row) => filters.source ? row.source === filters.source : true).sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime());
|
|
568
676
|
const { perPage, page } = pagination;
|
|
569
677
|
const perPageValue = perPage === false ? filtered.length : perPage;
|
|
@@ -589,9 +697,16 @@ var ScoresConvex = class extends storage.ScoresStorage {
|
|
|
589
697
|
}
|
|
590
698
|
};
|
|
591
699
|
var WorkflowsConvex = class extends storage.WorkflowsStorage {
|
|
592
|
-
|
|
700
|
+
#db;
|
|
701
|
+
constructor(config) {
|
|
593
702
|
super();
|
|
594
|
-
|
|
703
|
+
const client = resolveConvexConfig(config);
|
|
704
|
+
this.#db = new ConvexDB(client);
|
|
705
|
+
}
|
|
706
|
+
async init() {
|
|
707
|
+
}
|
|
708
|
+
async dangerouslyClearAll() {
|
|
709
|
+
await this.#db.clearTable({ tableName: storage.TABLE_WORKFLOW_SNAPSHOT });
|
|
595
710
|
}
|
|
596
711
|
async updateWorkflowResults({
|
|
597
712
|
workflowName,
|
|
@@ -638,11 +753,11 @@ var WorkflowsConvex = class extends storage.WorkflowsStorage {
|
|
|
638
753
|
snapshot
|
|
639
754
|
}) {
|
|
640
755
|
const now = /* @__PURE__ */ new Date();
|
|
641
|
-
const existing = await this.
|
|
756
|
+
const existing = await this.#db.load({
|
|
642
757
|
tableName: storage.TABLE_WORKFLOW_SNAPSHOT,
|
|
643
758
|
keys: { workflow_name: workflowName, run_id: runId }
|
|
644
759
|
});
|
|
645
|
-
await this.
|
|
760
|
+
await this.#db.insert({
|
|
646
761
|
tableName: storage.TABLE_WORKFLOW_SNAPSHOT,
|
|
647
762
|
record: {
|
|
648
763
|
workflow_name: workflowName,
|
|
@@ -658,7 +773,7 @@ var WorkflowsConvex = class extends storage.WorkflowsStorage {
|
|
|
658
773
|
workflowName,
|
|
659
774
|
runId
|
|
660
775
|
}) {
|
|
661
|
-
const row = await this.
|
|
776
|
+
const row = await this.#db.load({
|
|
662
777
|
tableName: storage.TABLE_WORKFLOW_SNAPSHOT,
|
|
663
778
|
keys: { workflow_name: workflowName, run_id: runId }
|
|
664
779
|
});
|
|
@@ -667,7 +782,7 @@ var WorkflowsConvex = class extends storage.WorkflowsStorage {
|
|
|
667
782
|
}
|
|
668
783
|
async listWorkflowRuns(args = {}) {
|
|
669
784
|
const { workflowName, fromDate, toDate, perPage, page, resourceId, status } = args;
|
|
670
|
-
let rows = await this.
|
|
785
|
+
let rows = await this.#db.queryTable(storage.TABLE_WORKFLOW_SNAPSHOT, void 0);
|
|
671
786
|
if (workflowName) rows = rows.filter((run) => run.workflow_name === workflowName);
|
|
672
787
|
if (resourceId) rows = rows.filter((run) => run.resourceId === resourceId);
|
|
673
788
|
if (fromDate) rows = rows.filter((run) => new Date(run.createdAt).getTime() >= fromDate.getTime());
|
|
@@ -699,7 +814,7 @@ var WorkflowsConvex = class extends storage.WorkflowsStorage {
|
|
|
699
814
|
runId,
|
|
700
815
|
workflowName
|
|
701
816
|
}) {
|
|
702
|
-
const runs = await this.
|
|
817
|
+
const runs = await this.#db.queryTable(storage.TABLE_WORKFLOW_SNAPSHOT, void 0);
|
|
703
818
|
const match = runs.find((run) => run.run_id === runId && (!workflowName || run.workflow_name === workflowName));
|
|
704
819
|
if (!match) return null;
|
|
705
820
|
return {
|
|
@@ -712,10 +827,10 @@ var WorkflowsConvex = class extends storage.WorkflowsStorage {
|
|
|
712
827
|
};
|
|
713
828
|
}
|
|
714
829
|
async deleteWorkflowRunById({ runId, workflowName }) {
|
|
715
|
-
await this.
|
|
830
|
+
await this.#db.deleteMany(storage.TABLE_WORKFLOW_SNAPSHOT, [`${workflowName}-${runId}`]);
|
|
716
831
|
}
|
|
717
832
|
async getRun(workflowName, runId) {
|
|
718
|
-
const runs = await this.
|
|
833
|
+
const runs = await this.#db.queryTable(storage.TABLE_WORKFLOW_SNAPSHOT, [
|
|
719
834
|
{ field: "workflow_name", value: workflowName }
|
|
720
835
|
]);
|
|
721
836
|
return runs.find((run) => run.run_id === runId) ?? null;
|
|
@@ -742,110 +857,23 @@ var WorkflowsConvex = class extends storage.WorkflowsStorage {
|
|
|
742
857
|
return JSON.parse(JSON.stringify(run.snapshot));
|
|
743
858
|
}
|
|
744
859
|
};
|
|
745
|
-
var StoreOperationsConvex = class extends storage.StoreOperations {
|
|
746
|
-
constructor(client) {
|
|
747
|
-
super();
|
|
748
|
-
this.client = client;
|
|
749
|
-
}
|
|
750
|
-
async hasColumn(_table, _column) {
|
|
751
|
-
return true;
|
|
752
|
-
}
|
|
753
|
-
async createTable(_args) {
|
|
754
|
-
}
|
|
755
|
-
async clearTable({ tableName }) {
|
|
756
|
-
let hasMore = true;
|
|
757
|
-
while (hasMore) {
|
|
758
|
-
const response = await this.client.callStorageRaw({
|
|
759
|
-
op: "clearTable",
|
|
760
|
-
tableName
|
|
761
|
-
});
|
|
762
|
-
hasMore = response.hasMore ?? false;
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
async dropTable({ tableName }) {
|
|
766
|
-
let hasMore = true;
|
|
767
|
-
while (hasMore) {
|
|
768
|
-
const response = await this.client.callStorageRaw({
|
|
769
|
-
op: "dropTable",
|
|
770
|
-
tableName
|
|
771
|
-
});
|
|
772
|
-
hasMore = response.hasMore ?? false;
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
async alterTable(_args) {
|
|
776
|
-
}
|
|
777
|
-
async insert({ tableName, record }) {
|
|
778
|
-
await this.client.callStorage({
|
|
779
|
-
op: "insert",
|
|
780
|
-
tableName,
|
|
781
|
-
record: this.normalizeRecord(tableName, record)
|
|
782
|
-
});
|
|
783
|
-
}
|
|
784
|
-
async batchInsert({ tableName, records }) {
|
|
785
|
-
if (records.length === 0) return;
|
|
786
|
-
await this.client.callStorage({
|
|
787
|
-
op: "batchInsert",
|
|
788
|
-
tableName,
|
|
789
|
-
records: records.map((record) => this.normalizeRecord(tableName, record))
|
|
790
|
-
});
|
|
791
|
-
}
|
|
792
|
-
async load({ tableName, keys }) {
|
|
793
|
-
const result = await this.client.callStorage({
|
|
794
|
-
op: "load",
|
|
795
|
-
tableName,
|
|
796
|
-
keys
|
|
797
|
-
});
|
|
798
|
-
return result;
|
|
799
|
-
}
|
|
800
|
-
async queryTable(tableName, filters) {
|
|
801
|
-
return this.client.callStorage({
|
|
802
|
-
op: "queryTable",
|
|
803
|
-
tableName,
|
|
804
|
-
filters
|
|
805
|
-
});
|
|
806
|
-
}
|
|
807
|
-
async deleteMany(tableName, ids) {
|
|
808
|
-
if (ids.length === 0) return;
|
|
809
|
-
await this.client.callStorage({
|
|
810
|
-
op: "deleteMany",
|
|
811
|
-
tableName,
|
|
812
|
-
ids
|
|
813
|
-
});
|
|
814
|
-
}
|
|
815
|
-
normalizeRecord(tableName, record) {
|
|
816
|
-
const normalized = { ...record };
|
|
817
|
-
if (tableName === storage.TABLE_WORKFLOW_SNAPSHOT && !normalized.id) {
|
|
818
|
-
const runId = normalized.run_id || normalized.runId;
|
|
819
|
-
const workflowName = normalized.workflow_name || normalized.workflowName;
|
|
820
|
-
normalized.id = workflowName ? `${workflowName}-${runId}` : runId;
|
|
821
|
-
}
|
|
822
|
-
if (!normalized.id) {
|
|
823
|
-
normalized.id = crypto__default.default.randomUUID();
|
|
824
|
-
}
|
|
825
|
-
for (const [key, value] of Object.entries(normalized)) {
|
|
826
|
-
if (value instanceof Date) {
|
|
827
|
-
normalized[key] = value.toISOString();
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
return normalized;
|
|
831
|
-
}
|
|
832
|
-
};
|
|
833
860
|
|
|
834
861
|
// src/storage/index.ts
|
|
862
|
+
var isClientConfig = (config) => {
|
|
863
|
+
return "client" in config;
|
|
864
|
+
};
|
|
835
865
|
var ConvexStore = class extends storage.MastraStorage {
|
|
836
|
-
operations;
|
|
837
866
|
memory;
|
|
838
867
|
workflows;
|
|
839
868
|
scores;
|
|
840
869
|
constructor(config) {
|
|
841
870
|
super({ id: config.id, name: config.name ?? "ConvexStore", disableInit: config.disableInit });
|
|
842
|
-
const client = new ConvexAdminClient(config);
|
|
843
|
-
|
|
844
|
-
this.memory = new MemoryConvex(
|
|
845
|
-
this.workflows = new WorkflowsConvex(
|
|
846
|
-
this.scores = new ScoresConvex(
|
|
871
|
+
const client = isClientConfig(config) ? config.client : new ConvexAdminClient(config);
|
|
872
|
+
const domainConfig = { client };
|
|
873
|
+
this.memory = new MemoryConvex(domainConfig);
|
|
874
|
+
this.workflows = new WorkflowsConvex(domainConfig);
|
|
875
|
+
this.scores = new ScoresConvex(domainConfig);
|
|
847
876
|
this.stores = {
|
|
848
|
-
operations: this.operations,
|
|
849
877
|
memory: this.memory,
|
|
850
878
|
workflows: this.workflows,
|
|
851
879
|
scores: this.scores
|
|
@@ -862,25 +890,6 @@ var ConvexStore = class extends storage.MastraStorage {
|
|
|
862
890
|
listScoresBySpan: false
|
|
863
891
|
};
|
|
864
892
|
}
|
|
865
|
-
async createTable(_args) {
|
|
866
|
-
}
|
|
867
|
-
async clearTable({ tableName }) {
|
|
868
|
-
await this.operations.clearTable({ tableName });
|
|
869
|
-
}
|
|
870
|
-
async dropTable({ tableName }) {
|
|
871
|
-
await this.operations.dropTable({ tableName });
|
|
872
|
-
}
|
|
873
|
-
async alterTable(_args) {
|
|
874
|
-
}
|
|
875
|
-
async insert({ tableName, record }) {
|
|
876
|
-
await this.operations.insert({ tableName, record });
|
|
877
|
-
}
|
|
878
|
-
async batchInsert({ tableName, records }) {
|
|
879
|
-
await this.operations.batchInsert({ tableName, records });
|
|
880
|
-
}
|
|
881
|
-
async load({ tableName, keys }) {
|
|
882
|
-
return this.operations.load({ tableName, keys });
|
|
883
|
-
}
|
|
884
893
|
async getThreadById({ threadId }) {
|
|
885
894
|
return this.memory.getThreadById({ threadId });
|
|
886
895
|
}
|
|
@@ -1294,61 +1303,61 @@ function cosineSimilarity(a, b) {
|
|
|
1294
1303
|
return dot / (Math.sqrt(magA) * Math.sqrt(magB));
|
|
1295
1304
|
}
|
|
1296
1305
|
|
|
1306
|
+
Object.defineProperty(exports, "mastraStorage", {
|
|
1307
|
+
enumerable: true,
|
|
1308
|
+
get: function () { return chunkBKVR7SL7_cjs.mastraStorage; }
|
|
1309
|
+
});
|
|
1297
1310
|
Object.defineProperty(exports, "TABLE_MESSAGES", {
|
|
1298
1311
|
enumerable: true,
|
|
1299
|
-
get: function () { return
|
|
1312
|
+
get: function () { return chunkZBUP3DS6_cjs.TABLE_MESSAGES; }
|
|
1300
1313
|
});
|
|
1301
1314
|
Object.defineProperty(exports, "TABLE_RESOURCES", {
|
|
1302
1315
|
enumerable: true,
|
|
1303
|
-
get: function () { return
|
|
1316
|
+
get: function () { return chunkZBUP3DS6_cjs.TABLE_RESOURCES; }
|
|
1304
1317
|
});
|
|
1305
1318
|
Object.defineProperty(exports, "TABLE_SCORERS", {
|
|
1306
1319
|
enumerable: true,
|
|
1307
|
-
get: function () { return
|
|
1320
|
+
get: function () { return chunkZBUP3DS6_cjs.TABLE_SCORERS; }
|
|
1308
1321
|
});
|
|
1309
1322
|
Object.defineProperty(exports, "TABLE_THREADS", {
|
|
1310
1323
|
enumerable: true,
|
|
1311
|
-
get: function () { return
|
|
1324
|
+
get: function () { return chunkZBUP3DS6_cjs.TABLE_THREADS; }
|
|
1312
1325
|
});
|
|
1313
1326
|
Object.defineProperty(exports, "TABLE_WORKFLOW_SNAPSHOT", {
|
|
1314
1327
|
enumerable: true,
|
|
1315
|
-
get: function () { return
|
|
1328
|
+
get: function () { return chunkZBUP3DS6_cjs.TABLE_WORKFLOW_SNAPSHOT; }
|
|
1316
1329
|
});
|
|
1317
1330
|
Object.defineProperty(exports, "mastraDocumentsTable", {
|
|
1318
1331
|
enumerable: true,
|
|
1319
|
-
get: function () { return
|
|
1332
|
+
get: function () { return chunkZBUP3DS6_cjs.mastraDocumentsTable; }
|
|
1320
1333
|
});
|
|
1321
1334
|
Object.defineProperty(exports, "mastraMessagesTable", {
|
|
1322
1335
|
enumerable: true,
|
|
1323
|
-
get: function () { return
|
|
1336
|
+
get: function () { return chunkZBUP3DS6_cjs.mastraMessagesTable; }
|
|
1324
1337
|
});
|
|
1325
1338
|
Object.defineProperty(exports, "mastraResourcesTable", {
|
|
1326
1339
|
enumerable: true,
|
|
1327
|
-
get: function () { return
|
|
1340
|
+
get: function () { return chunkZBUP3DS6_cjs.mastraResourcesTable; }
|
|
1328
1341
|
});
|
|
1329
1342
|
Object.defineProperty(exports, "mastraScoresTable", {
|
|
1330
1343
|
enumerable: true,
|
|
1331
|
-
get: function () { return
|
|
1332
|
-
});
|
|
1333
|
-
Object.defineProperty(exports, "mastraStorage", {
|
|
1334
|
-
enumerable: true,
|
|
1335
|
-
get: function () { return chunkQKN2PWR2_cjs.mastraStorage; }
|
|
1344
|
+
get: function () { return chunkZBUP3DS6_cjs.mastraScoresTable; }
|
|
1336
1345
|
});
|
|
1337
1346
|
Object.defineProperty(exports, "mastraThreadsTable", {
|
|
1338
1347
|
enumerable: true,
|
|
1339
|
-
get: function () { return
|
|
1348
|
+
get: function () { return chunkZBUP3DS6_cjs.mastraThreadsTable; }
|
|
1340
1349
|
});
|
|
1341
1350
|
Object.defineProperty(exports, "mastraVectorIndexesTable", {
|
|
1342
1351
|
enumerable: true,
|
|
1343
|
-
get: function () { return
|
|
1352
|
+
get: function () { return chunkZBUP3DS6_cjs.mastraVectorIndexesTable; }
|
|
1344
1353
|
});
|
|
1345
1354
|
Object.defineProperty(exports, "mastraVectorsTable", {
|
|
1346
1355
|
enumerable: true,
|
|
1347
|
-
get: function () { return
|
|
1356
|
+
get: function () { return chunkZBUP3DS6_cjs.mastraVectorsTable; }
|
|
1348
1357
|
});
|
|
1349
1358
|
Object.defineProperty(exports, "mastraWorkflowSnapshotsTable", {
|
|
1350
1359
|
enumerable: true,
|
|
1351
|
-
get: function () { return
|
|
1360
|
+
get: function () { return chunkZBUP3DS6_cjs.mastraWorkflowSnapshotsTable; }
|
|
1352
1361
|
});
|
|
1353
1362
|
exports.ConvexStore = ConvexStore;
|
|
1354
1363
|
exports.ConvexVector = ConvexVector;
|