@mastra/libsql 1.6.2 → 1.6.3
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 +22 -0
- package/LICENSE.md +15 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/index.cjs +74 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +74 -4
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +1 -0
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/dist/storage/domains/workflows/index.d.ts +1 -0
- package/dist/storage/domains/workflows/index.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -5166,7 +5166,8 @@ var MemoryLibSQL = class extends MemoryStorage {
|
|
|
5166
5166
|
"isBufferingObservation",
|
|
5167
5167
|
"isBufferingReflection",
|
|
5168
5168
|
"lastBufferedAtTokens",
|
|
5169
|
-
"lastBufferedAtTime"
|
|
5169
|
+
"lastBufferedAtTime",
|
|
5170
|
+
"metadata"
|
|
5170
5171
|
]
|
|
5171
5172
|
});
|
|
5172
5173
|
}
|
|
@@ -6136,9 +6137,11 @@ var MemoryLibSQL = class extends MemoryStorage {
|
|
|
6136
6137
|
]
|
|
6137
6138
|
});
|
|
6138
6139
|
const clonedMessages = [];
|
|
6140
|
+
const messageIdMap = {};
|
|
6139
6141
|
const targetResourceId = resourceId || sourceThread.resourceId;
|
|
6140
6142
|
for (const sourceMsg of sourceMessages) {
|
|
6141
6143
|
const newMessageId = crypto.randomUUID();
|
|
6144
|
+
messageIdMap[sourceMsg.id] = newMessageId;
|
|
6142
6145
|
const contentStr = sourceMsg.content;
|
|
6143
6146
|
let parsedContent;
|
|
6144
6147
|
try {
|
|
@@ -6172,7 +6175,8 @@ var MemoryLibSQL = class extends MemoryStorage {
|
|
|
6172
6175
|
await tx.commit();
|
|
6173
6176
|
return {
|
|
6174
6177
|
thread: newThread,
|
|
6175
|
-
clonedMessages
|
|
6178
|
+
clonedMessages,
|
|
6179
|
+
messageIdMap
|
|
6176
6180
|
};
|
|
6177
6181
|
} catch (error) {
|
|
6178
6182
|
await tx.rollback();
|
|
@@ -6362,6 +6366,68 @@ var MemoryLibSQL = class extends MemoryStorage {
|
|
|
6362
6366
|
);
|
|
6363
6367
|
}
|
|
6364
6368
|
}
|
|
6369
|
+
async insertObservationalMemoryRecord(record) {
|
|
6370
|
+
try {
|
|
6371
|
+
const lookupKey = this.getOMKey(record.threadId, record.resourceId);
|
|
6372
|
+
await this.#client.execute({
|
|
6373
|
+
sql: `INSERT INTO "${OM_TABLE}" (
|
|
6374
|
+
id, "lookupKey", scope, "resourceId", "threadId",
|
|
6375
|
+
"activeObservations", "activeObservationsPendingUpdate",
|
|
6376
|
+
"originType", config, "generationCount", "lastObservedAt", "lastReflectionAt",
|
|
6377
|
+
"pendingMessageTokens", "totalTokensObserved", "observationTokenCount",
|
|
6378
|
+
"observedMessageIds", "bufferedObservationChunks",
|
|
6379
|
+
"bufferedReflection", "bufferedReflectionTokens", "bufferedReflectionInputTokens",
|
|
6380
|
+
"reflectedObservationLineCount",
|
|
6381
|
+
"isObserving", "isReflecting", "isBufferingObservation", "isBufferingReflection",
|
|
6382
|
+
"lastBufferedAtTokens", "lastBufferedAtTime",
|
|
6383
|
+
"observedTimezone", metadata, "createdAt", "updatedAt"
|
|
6384
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
6385
|
+
args: [
|
|
6386
|
+
record.id,
|
|
6387
|
+
lookupKey,
|
|
6388
|
+
record.scope,
|
|
6389
|
+
record.resourceId,
|
|
6390
|
+
record.threadId || null,
|
|
6391
|
+
record.activeObservations || "",
|
|
6392
|
+
null,
|
|
6393
|
+
record.originType || "initial",
|
|
6394
|
+
record.config ? JSON.stringify(record.config) : null,
|
|
6395
|
+
record.generationCount || 0,
|
|
6396
|
+
record.lastObservedAt ? record.lastObservedAt.toISOString() : null,
|
|
6397
|
+
null,
|
|
6398
|
+
record.pendingMessageTokens || 0,
|
|
6399
|
+
record.totalTokensObserved || 0,
|
|
6400
|
+
record.observationTokenCount || 0,
|
|
6401
|
+
record.observedMessageIds ? JSON.stringify(record.observedMessageIds) : null,
|
|
6402
|
+
record.bufferedObservationChunks ? JSON.stringify(record.bufferedObservationChunks) : null,
|
|
6403
|
+
record.bufferedReflection || null,
|
|
6404
|
+
record.bufferedReflectionTokens ?? null,
|
|
6405
|
+
record.bufferedReflectionInputTokens ?? null,
|
|
6406
|
+
record.reflectedObservationLineCount ?? null,
|
|
6407
|
+
record.isObserving || false,
|
|
6408
|
+
record.isReflecting || false,
|
|
6409
|
+
record.isBufferingObservation || false,
|
|
6410
|
+
record.isBufferingReflection || false,
|
|
6411
|
+
record.lastBufferedAtTokens || 0,
|
|
6412
|
+
record.lastBufferedAtTime ? record.lastBufferedAtTime.toISOString() : null,
|
|
6413
|
+
record.observedTimezone || null,
|
|
6414
|
+
record.metadata ? JSON.stringify(record.metadata) : null,
|
|
6415
|
+
record.createdAt.toISOString(),
|
|
6416
|
+
record.updatedAt.toISOString()
|
|
6417
|
+
]
|
|
6418
|
+
});
|
|
6419
|
+
} catch (error) {
|
|
6420
|
+
throw new MastraError(
|
|
6421
|
+
{
|
|
6422
|
+
id: createStorageErrorId("LIBSQL", "INSERT_OBSERVATIONAL_MEMORY_RECORD", "FAILED"),
|
|
6423
|
+
domain: ErrorDomain.STORAGE,
|
|
6424
|
+
category: ErrorCategory.THIRD_PARTY,
|
|
6425
|
+
details: { id: record.id, threadId: record.threadId, resourceId: record.resourceId }
|
|
6426
|
+
},
|
|
6427
|
+
error
|
|
6428
|
+
);
|
|
6429
|
+
}
|
|
6430
|
+
}
|
|
6365
6431
|
async updateActiveObservations(input) {
|
|
6366
6432
|
try {
|
|
6367
6433
|
const now = /* @__PURE__ */ new Date();
|
|
@@ -6446,8 +6512,8 @@ var MemoryLibSQL = class extends MemoryStorage {
|
|
|
6446
6512
|
"originType", config, "generationCount", "lastObservedAt", "lastReflectionAt",
|
|
6447
6513
|
"pendingMessageTokens", "totalTokensObserved", "observationTokenCount",
|
|
6448
6514
|
"isObserving", "isReflecting", "isBufferingObservation", "isBufferingReflection", "lastBufferedAtTokens", "lastBufferedAtTime",
|
|
6449
|
-
"observedTimezone", "createdAt", "updatedAt"
|
|
6450
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
6515
|
+
"observedTimezone", metadata, "createdAt", "updatedAt"
|
|
6516
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
6451
6517
|
args: [
|
|
6452
6518
|
id,
|
|
6453
6519
|
lookupKey,
|
|
@@ -6477,6 +6543,7 @@ var MemoryLibSQL = class extends MemoryStorage {
|
|
|
6477
6543
|
null,
|
|
6478
6544
|
// lastBufferedAtTime
|
|
6479
6545
|
record.observedTimezone || null,
|
|
6546
|
+
record.metadata ? JSON.stringify(record.metadata) : null,
|
|
6480
6547
|
now.toISOString(),
|
|
6481
6548
|
now.toISOString()
|
|
6482
6549
|
]
|
|
@@ -9274,6 +9341,9 @@ var WorkflowsLibSQL = class extends WorkflowsStorage {
|
|
|
9274
9341
|
(err) => this.logger.warn("LibSQL Workflows: Failed to setup PRAGMA settings.", err)
|
|
9275
9342
|
);
|
|
9276
9343
|
}
|
|
9344
|
+
supportsConcurrentUpdates() {
|
|
9345
|
+
return true;
|
|
9346
|
+
}
|
|
9277
9347
|
parseWorkflowRun(row) {
|
|
9278
9348
|
let parsedSnapshot = row.snapshot;
|
|
9279
9349
|
if (typeof parsedSnapshot === "string") {
|