@mastra/libsql 1.25.1-alpha.0 → 1.25.2-alpha.0
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/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-agents-human-in-the-loop.md +5 -3
- package/dist/docs/references/docs-memory-memory-processors.md +2 -5
- package/dist/docs/references/docs-memory-semantic-recall.md +2 -2
- package/dist/docs/references/docs-memory-working-memory.md +16 -0
- package/dist/docs/references/reference-file-based-agents-memory.md +0 -2
- package/dist/docs/references/reference-file-based-agents-storage.md +0 -2
- package/dist/docs/references/reference-memory-memory-class.md +2 -2
- package/dist/index.cjs +147 -133
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +147 -133
- package/dist/index.js.map +1 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -7861,6 +7861,14 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
7861
7861
|
initialBackoffMs: config.initialBackoffMs
|
|
7862
7862
|
});
|
|
7863
7863
|
}
|
|
7864
|
+
/**
|
|
7865
|
+
* Runs a write behind the per-client write lock and retries it on transient SQLite lock
|
|
7866
|
+
* errors (`SQLITE_BUSY`), like the shared `LibSQLDB` writes. Each retry re-queues on the lock.
|
|
7867
|
+
* `fn` must be safe to rerun: a single statement, a batch, or a transaction that rolls back.
|
|
7868
|
+
*/
|
|
7869
|
+
#write(operation, fn) {
|
|
7870
|
+
return this.#db.executeWriteOperationWithRetry(() => withClientWriteLock(this.#client, fn), operation);
|
|
7871
|
+
}
|
|
7864
7872
|
async init() {
|
|
7865
7873
|
await this.#db.createTable({
|
|
7866
7874
|
tableName: TABLE_THREADS,
|
|
@@ -8362,9 +8370,9 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
8362
8370
|
const threadUpdateStatement = batchStatements[batchStatements.length - 1];
|
|
8363
8371
|
for (let i = 0; i < messageStatements.length; i += BATCH_SIZE) {
|
|
8364
8372
|
const batch = messageStatements.slice(i, i + BATCH_SIZE);
|
|
8365
|
-
if (batch.length > 0) await this.#client.batch(batch, "write");
|
|
8373
|
+
if (batch.length > 0) await this.#write("saveMessages", () => this.#client.batch(batch, "write"));
|
|
8366
8374
|
}
|
|
8367
|
-
if (threadUpdateStatement) await this.#client.execute(threadUpdateStatement);
|
|
8375
|
+
if (threadUpdateStatement) await this.#write("saveMessages", () => this.#client.execute(threadUpdateStatement));
|
|
8368
8376
|
return { messages: new MessageList().add(messages, "memory").get.all.db() };
|
|
8369
8377
|
} catch (error) {
|
|
8370
8378
|
throw new MastraError({
|
|
@@ -8430,7 +8438,7 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
8430
8438
|
sql: `UPDATE ${TABLE_THREADS} SET updatedAt = ? WHERE id = ?`,
|
|
8431
8439
|
args: [now, threadId]
|
|
8432
8440
|
});
|
|
8433
|
-
await this.#client.batch(batchStatements, "write");
|
|
8441
|
+
await this.#write("updateMessages", () => this.#client.batch(batchStatements, "write"));
|
|
8434
8442
|
return (await this.#client.execute({
|
|
8435
8443
|
sql: selectSql,
|
|
8436
8444
|
args: messageIds
|
|
@@ -8440,35 +8448,37 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
8440
8448
|
if (!messageIds || messageIds.length === 0) return;
|
|
8441
8449
|
try {
|
|
8442
8450
|
const BATCH_SIZE = 100;
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
|
|
8450
|
-
|
|
8451
|
-
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8455
|
-
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
|
|
8460
|
-
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8451
|
+
await this.#write("deleteMessages", async () => {
|
|
8452
|
+
const threadIds = /* @__PURE__ */ new Set();
|
|
8453
|
+
const tx = await this.#client.transaction("write");
|
|
8454
|
+
try {
|
|
8455
|
+
for (let i = 0; i < messageIds.length; i += BATCH_SIZE) {
|
|
8456
|
+
const batch = messageIds.slice(i, i + BATCH_SIZE);
|
|
8457
|
+
const placeholders = batch.map(() => "?").join(",");
|
|
8458
|
+
(await tx.execute({
|
|
8459
|
+
sql: `SELECT DISTINCT thread_id FROM "${TABLE_MESSAGES}" WHERE id IN (${placeholders})`,
|
|
8460
|
+
args: batch
|
|
8461
|
+
})).rows?.forEach((row) => {
|
|
8462
|
+
if (row.thread_id) threadIds.add(row.thread_id);
|
|
8463
|
+
});
|
|
8464
|
+
await tx.execute({
|
|
8465
|
+
sql: `DELETE FROM "${TABLE_MESSAGES}" WHERE id IN (${placeholders})`,
|
|
8466
|
+
args: batch
|
|
8467
|
+
});
|
|
8468
|
+
}
|
|
8469
|
+
if (threadIds.size > 0) {
|
|
8470
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
8471
|
+
for (const threadId of threadIds) await tx.execute({
|
|
8472
|
+
sql: `UPDATE "${TABLE_THREADS}" SET "updatedAt" = ? WHERE id = ?`,
|
|
8473
|
+
args: [now, threadId]
|
|
8474
|
+
});
|
|
8475
|
+
}
|
|
8476
|
+
await tx.commit();
|
|
8477
|
+
} catch (error) {
|
|
8478
|
+
await tx.rollback();
|
|
8479
|
+
throw error;
|
|
8466
8480
|
}
|
|
8467
|
-
|
|
8468
|
-
} catch (error) {
|
|
8469
|
-
await tx.rollback();
|
|
8470
|
-
throw error;
|
|
8471
|
-
}
|
|
8481
|
+
});
|
|
8472
8482
|
} catch (error) {
|
|
8473
8483
|
throw new MastraError({
|
|
8474
8484
|
id: createStorageErrorId("LIBSQL", "DELETE_MESSAGES", "FAILED"),
|
|
@@ -8533,10 +8543,10 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
8533
8543
|
updates.push("updatedAt = ?");
|
|
8534
8544
|
values.push(updatedResource.updatedAt.toISOString());
|
|
8535
8545
|
values.push(resourceId);
|
|
8536
|
-
await this.#client.execute({
|
|
8546
|
+
await this.#write("updateResource", () => this.#client.execute({
|
|
8537
8547
|
sql: `UPDATE ${TABLE_RESOURCES} SET ${updates.join(", ")} WHERE id = ?`,
|
|
8538
8548
|
args: values
|
|
8539
|
-
});
|
|
8549
|
+
}));
|
|
8540
8550
|
return updatedResource;
|
|
8541
8551
|
}
|
|
8542
8552
|
async getThreadById({ threadId, resourceId }) {
|
|
@@ -8573,49 +8583,51 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
8573
8583
|
*/
|
|
8574
8584
|
async updateThreadResourceId({ threadId, resourceId }) {
|
|
8575
8585
|
try {
|
|
8576
|
-
|
|
8577
|
-
|
|
8578
|
-
|
|
8579
|
-
|
|
8580
|
-
|
|
8581
|
-
|
|
8582
|
-
|
|
8583
|
-
|
|
8584
|
-
|
|
8585
|
-
|
|
8586
|
-
|
|
8587
|
-
|
|
8588
|
-
|
|
8589
|
-
|
|
8590
|
-
|
|
8591
|
-
|
|
8592
|
-
|
|
8586
|
+
return await this.#write("updateThreadResourceId", async () => {
|
|
8587
|
+
const tx = await this.#client.transaction("write");
|
|
8588
|
+
try {
|
|
8589
|
+
const row = (await tx.execute({
|
|
8590
|
+
sql: `SELECT * FROM "${TABLE_THREADS}" WHERE id = ?`,
|
|
8591
|
+
args: [threadId]
|
|
8592
|
+
})).rows?.[0];
|
|
8593
|
+
if (!row) throw new Error(`Thread "${threadId}" not found`);
|
|
8594
|
+
const currentResourceId = row.resourceId;
|
|
8595
|
+
const normalized = {
|
|
8596
|
+
id: row.id,
|
|
8597
|
+
resourceId: currentResourceId,
|
|
8598
|
+
title: row.title,
|
|
8599
|
+
metadata: typeof row.metadata === "string" ? JSON.parse(row.metadata) : row.metadata,
|
|
8600
|
+
createdAt: new Date(row.createdAt),
|
|
8601
|
+
updatedAt: new Date(row.updatedAt)
|
|
8602
|
+
};
|
|
8603
|
+
if (currentResourceId === resourceId) {
|
|
8604
|
+
await tx.commit();
|
|
8605
|
+
return normalized;
|
|
8606
|
+
}
|
|
8607
|
+
const now = /* @__PURE__ */ new Date();
|
|
8608
|
+
await tx.execute({
|
|
8609
|
+
sql: `UPDATE "${TABLE_THREADS}" SET "resourceId" = ?, "updatedAt" = ? WHERE id = ?`,
|
|
8610
|
+
args: [
|
|
8611
|
+
resourceId,
|
|
8612
|
+
now.toISOString(),
|
|
8613
|
+
threadId
|
|
8614
|
+
]
|
|
8615
|
+
});
|
|
8616
|
+
await tx.execute({
|
|
8617
|
+
sql: `UPDATE "${TABLE_MESSAGES}" SET "resourceId" = ? WHERE thread_id = ?`,
|
|
8618
|
+
args: [resourceId, threadId]
|
|
8619
|
+
});
|
|
8593
8620
|
await tx.commit();
|
|
8594
|
-
return
|
|
8595
|
-
|
|
8596
|
-
const now = /* @__PURE__ */ new Date();
|
|
8597
|
-
await tx.execute({
|
|
8598
|
-
sql: `UPDATE "${TABLE_THREADS}" SET "resourceId" = ?, "updatedAt" = ? WHERE id = ?`,
|
|
8599
|
-
args: [
|
|
8621
|
+
return {
|
|
8622
|
+
...normalized,
|
|
8600
8623
|
resourceId,
|
|
8601
|
-
now
|
|
8602
|
-
|
|
8603
|
-
|
|
8604
|
-
|
|
8605
|
-
|
|
8606
|
-
|
|
8607
|
-
|
|
8608
|
-
});
|
|
8609
|
-
await tx.commit();
|
|
8610
|
-
return {
|
|
8611
|
-
...normalized,
|
|
8612
|
-
resourceId,
|
|
8613
|
-
updatedAt: now
|
|
8614
|
-
};
|
|
8615
|
-
} catch (error) {
|
|
8616
|
-
await tx.rollback();
|
|
8617
|
-
throw error;
|
|
8618
|
-
}
|
|
8624
|
+
updatedAt: now
|
|
8625
|
+
};
|
|
8626
|
+
} catch (error) {
|
|
8627
|
+
await tx.rollback();
|
|
8628
|
+
throw error;
|
|
8629
|
+
}
|
|
8630
|
+
});
|
|
8619
8631
|
} catch (error) {
|
|
8620
8632
|
throw new MastraError({
|
|
8621
8633
|
id: createStorageErrorId("LIBSQL", "UPDATE_THREAD_RESOURCE_ID", "FAILED"),
|
|
@@ -8777,7 +8789,7 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
8777
8789
|
updatedAt: now
|
|
8778
8790
|
};
|
|
8779
8791
|
try {
|
|
8780
|
-
await this.#client.execute({
|
|
8792
|
+
await this.#write("updateThread", () => this.#client.execute({
|
|
8781
8793
|
sql: `UPDATE ${TABLE_THREADS} SET title = COALESCE(?, title), metadata = jsonb(?), updatedAt = ? WHERE id = ?`,
|
|
8782
8794
|
args: [
|
|
8783
8795
|
title ?? null,
|
|
@@ -8785,7 +8797,7 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
8785
8797
|
now.toISOString(),
|
|
8786
8798
|
id
|
|
8787
8799
|
]
|
|
8788
|
-
});
|
|
8800
|
+
}));
|
|
8789
8801
|
return updatedThread;
|
|
8790
8802
|
} catch (error) {
|
|
8791
8803
|
throw new MastraError({
|
|
@@ -8799,14 +8811,14 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
8799
8811
|
}
|
|
8800
8812
|
async deleteThread({ threadId }) {
|
|
8801
8813
|
try {
|
|
8802
|
-
await this.#client.execute({
|
|
8814
|
+
await this.#write("deleteThread", () => this.#client.execute({
|
|
8803
8815
|
sql: `DELETE FROM ${TABLE_MESSAGES} WHERE thread_id = ?`,
|
|
8804
8816
|
args: [threadId]
|
|
8805
|
-
});
|
|
8806
|
-
await this.#client.execute({
|
|
8817
|
+
}));
|
|
8818
|
+
await this.#write("deleteThread", () => this.#client.execute({
|
|
8807
8819
|
sql: `DELETE FROM ${TABLE_THREADS} WHERE id = ?`,
|
|
8808
8820
|
args: [threadId]
|
|
8809
|
-
});
|
|
8821
|
+
}));
|
|
8810
8822
|
} catch (error) {
|
|
8811
8823
|
throw new MastraError({
|
|
8812
8824
|
id: createStorageErrorId("LIBSQL", "DELETE_THREAD", "FAILED"),
|
|
@@ -8879,48 +8891,50 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
8879
8891
|
createdAt: now,
|
|
8880
8892
|
updatedAt: now
|
|
8881
8893
|
};
|
|
8882
|
-
|
|
8883
|
-
|
|
8884
|
-
|
|
8885
|
-
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
newThread.id,
|
|
8889
|
-
newThread.resourceId,
|
|
8890
|
-
newThread.title ?? "",
|
|
8891
|
-
JSON.stringify(newThread.metadata),
|
|
8892
|
-
nowStr,
|
|
8893
|
-
nowStr
|
|
8894
|
-
]
|
|
8895
|
-
});
|
|
8896
|
-
const messageIdMap = {};
|
|
8897
|
-
const targetResourceId = resourceId || sourceThread.resourceId;
|
|
8898
|
-
for (const sourceMsg of sourceMessages) {
|
|
8899
|
-
const newMessageId = crypto.randomUUID();
|
|
8900
|
-
const sourceMsgId = sourceMsg.id;
|
|
8901
|
-
messageIdMap[sourceMsgId] = newMessageId;
|
|
8902
|
-
const insertResult = await tx.execute({
|
|
8903
|
-
sql: `INSERT INTO "${TABLE_MESSAGES}" (id, thread_id, content, role, type, "createdAt", "resourceId")
|
|
8904
|
-
SELECT ?, ?, content, role, type, "createdAt", ?
|
|
8905
|
-
FROM "${TABLE_MESSAGES}" WHERE id = ?`,
|
|
8894
|
+
return await this.#write("copyThread", async () => {
|
|
8895
|
+
const tx = await this.#client.transaction("write");
|
|
8896
|
+
try {
|
|
8897
|
+
await tx.execute({
|
|
8898
|
+
sql: `INSERT INTO "${TABLE_THREADS}" (id, "resourceId", title, metadata, "createdAt", "updatedAt")
|
|
8899
|
+
VALUES (?, ?, ?, jsonb(?), ?, ?)`,
|
|
8906
8900
|
args: [
|
|
8907
|
-
|
|
8908
|
-
|
|
8909
|
-
|
|
8910
|
-
|
|
8901
|
+
newThread.id,
|
|
8902
|
+
newThread.resourceId,
|
|
8903
|
+
newThread.title ?? "",
|
|
8904
|
+
JSON.stringify(newThread.metadata),
|
|
8905
|
+
nowStr,
|
|
8906
|
+
nowStr
|
|
8911
8907
|
]
|
|
8912
8908
|
});
|
|
8913
|
-
|
|
8909
|
+
const messageIdMap = {};
|
|
8910
|
+
const targetResourceId = resourceId || sourceThread.resourceId;
|
|
8911
|
+
for (const sourceMsg of sourceMessages) {
|
|
8912
|
+
const newMessageId = crypto.randomUUID();
|
|
8913
|
+
const sourceMsgId = sourceMsg.id;
|
|
8914
|
+
messageIdMap[sourceMsgId] = newMessageId;
|
|
8915
|
+
const insertResult = await tx.execute({
|
|
8916
|
+
sql: `INSERT INTO "${TABLE_MESSAGES}" (id, thread_id, content, role, type, "createdAt", "resourceId")
|
|
8917
|
+
SELECT ?, ?, content, role, type, "createdAt", ?
|
|
8918
|
+
FROM "${TABLE_MESSAGES}" WHERE id = ?`,
|
|
8919
|
+
args: [
|
|
8920
|
+
newMessageId,
|
|
8921
|
+
newThreadId,
|
|
8922
|
+
targetResourceId,
|
|
8923
|
+
sourceMsgId
|
|
8924
|
+
]
|
|
8925
|
+
});
|
|
8926
|
+
if (insertResult.rowsAffected !== 1) throw new Error(`Failed to copy message ${sourceMsgId}: expected 1 row copied but got ${insertResult.rowsAffected}`);
|
|
8927
|
+
}
|
|
8928
|
+
await tx.commit();
|
|
8929
|
+
return {
|
|
8930
|
+
thread: newThread,
|
|
8931
|
+
messageIdMap
|
|
8932
|
+
};
|
|
8933
|
+
} catch (error) {
|
|
8934
|
+
await tx.rollback();
|
|
8935
|
+
throw error;
|
|
8914
8936
|
}
|
|
8915
|
-
|
|
8916
|
-
return {
|
|
8917
|
-
thread: newThread,
|
|
8918
|
-
messageIdMap
|
|
8919
|
-
};
|
|
8920
|
-
} catch (error) {
|
|
8921
|
-
await tx.rollback();
|
|
8922
|
-
throw error;
|
|
8923
|
-
}
|
|
8937
|
+
});
|
|
8924
8938
|
} catch (error) {
|
|
8925
8939
|
if (error instanceof MastraError) throw error;
|
|
8926
8940
|
throw new MastraError({
|
|
@@ -9080,7 +9094,7 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
9080
9094
|
config: input.config,
|
|
9081
9095
|
observedTimezone: input.observedTimezone
|
|
9082
9096
|
};
|
|
9083
|
-
await
|
|
9097
|
+
await this.#write("initializeObservationalMemory", () => this.#client.execute({
|
|
9084
9098
|
sql: `INSERT INTO "${OM_TABLE}" (
|
|
9085
9099
|
id, "lookupKey", scope, "resourceId", "threadId",
|
|
9086
9100
|
"activeObservations", "activeObservationsPendingUpdate",
|
|
@@ -9132,7 +9146,7 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
9132
9146
|
async insertObservationalMemoryRecord(record) {
|
|
9133
9147
|
try {
|
|
9134
9148
|
const lookupKey = this.getOMKey(record.threadId, record.resourceId);
|
|
9135
|
-
await
|
|
9149
|
+
await this.#write("insertObservationalMemoryRecord", () => this.#client.execute({
|
|
9136
9150
|
sql: `INSERT INTO "${OM_TABLE}" (
|
|
9137
9151
|
id, "lookupKey", scope, "resourceId", "threadId",
|
|
9138
9152
|
"activeObservations", "activeObservationsPendingUpdate",
|
|
@@ -9196,7 +9210,7 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
9196
9210
|
try {
|
|
9197
9211
|
const now = /* @__PURE__ */ new Date();
|
|
9198
9212
|
const observedMessageIdsJson = input.observedMessageIds ? JSON.stringify(input.observedMessageIds) : null;
|
|
9199
|
-
if ((await
|
|
9213
|
+
if ((await this.#write("updateActiveObservations", () => this.#client.execute({
|
|
9200
9214
|
sql: `UPDATE "${OM_TABLE}" SET
|
|
9201
9215
|
"activeObservations" = ?,
|
|
9202
9216
|
"lastObservedAt" = ?,
|
|
@@ -9234,7 +9248,7 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
9234
9248
|
}
|
|
9235
9249
|
async createReflectionGeneration(input) {
|
|
9236
9250
|
try {
|
|
9237
|
-
return await
|
|
9251
|
+
return await this.#write("createReflectionGeneration", async () => {
|
|
9238
9252
|
const tx = await this.#client.transaction("write");
|
|
9239
9253
|
try {
|
|
9240
9254
|
const record = await this.#insertReflectionGeneration(tx, input);
|
|
@@ -9330,7 +9344,7 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
9330
9344
|
}
|
|
9331
9345
|
async setReflectingFlag(id, isReflecting) {
|
|
9332
9346
|
try {
|
|
9333
|
-
if ((await
|
|
9347
|
+
if ((await this.#write("setReflectingFlag", () => this.#client.execute({
|
|
9334
9348
|
sql: `UPDATE "${OM_TABLE}" SET "isReflecting" = ?, "updatedAt" = ? WHERE id = ?`,
|
|
9335
9349
|
args: [
|
|
9336
9350
|
isReflecting,
|
|
@@ -9362,7 +9376,7 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
9362
9376
|
}
|
|
9363
9377
|
async setObservingFlag(id, isObserving) {
|
|
9364
9378
|
try {
|
|
9365
|
-
if ((await
|
|
9379
|
+
if ((await this.#write("setObservingFlag", () => this.#client.execute({
|
|
9366
9380
|
sql: `UPDATE "${OM_TABLE}" SET "isObserving" = ?, "updatedAt" = ? WHERE id = ?`,
|
|
9367
9381
|
args: [
|
|
9368
9382
|
isObserving,
|
|
@@ -9413,7 +9427,7 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
9413
9427
|
id
|
|
9414
9428
|
];
|
|
9415
9429
|
}
|
|
9416
|
-
if ((await
|
|
9430
|
+
if ((await this.#write("setBufferingObservationFlag", () => this.#client.execute({
|
|
9417
9431
|
sql,
|
|
9418
9432
|
args
|
|
9419
9433
|
}))).rowsAffected === 0) throw new MastraError({
|
|
@@ -9443,7 +9457,7 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
9443
9457
|
}
|
|
9444
9458
|
async setBufferingReflectionFlag(id, isBuffering) {
|
|
9445
9459
|
try {
|
|
9446
|
-
if ((await
|
|
9460
|
+
if ((await this.#write("setBufferingReflectionFlag", () => this.#client.execute({
|
|
9447
9461
|
sql: `UPDATE "${OM_TABLE}" SET "isBufferingReflection" = ?, "updatedAt" = ? WHERE id = ?`,
|
|
9448
9462
|
args: [
|
|
9449
9463
|
isBuffering,
|
|
@@ -9476,7 +9490,7 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
9476
9490
|
async clearObservationalMemory(threadId, resourceId) {
|
|
9477
9491
|
try {
|
|
9478
9492
|
const lookupKey = this.getOMKey(threadId, resourceId);
|
|
9479
|
-
await
|
|
9493
|
+
await this.#write("clearObservationalMemory", () => this.#client.execute({
|
|
9480
9494
|
sql: `DELETE FROM "${OM_TABLE}" WHERE "lookupKey" = ?`,
|
|
9481
9495
|
args: [lookupKey]
|
|
9482
9496
|
}));
|
|
@@ -9494,7 +9508,7 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
9494
9508
|
}
|
|
9495
9509
|
async setPendingMessageTokens(id, tokenCount) {
|
|
9496
9510
|
try {
|
|
9497
|
-
if ((await
|
|
9511
|
+
if ((await this.#write("setPendingMessageTokens", () => this.#client.execute({
|
|
9498
9512
|
sql: `UPDATE "${OM_TABLE}" SET
|
|
9499
9513
|
"pendingMessageTokens" = ?,
|
|
9500
9514
|
"updatedAt" = ?
|
|
@@ -9529,7 +9543,7 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
9529
9543
|
}
|
|
9530
9544
|
async updateObservationalMemoryConfig(input) {
|
|
9531
9545
|
try {
|
|
9532
|
-
await
|
|
9546
|
+
await this.#write("updateObservationalMemoryConfig", async () => {
|
|
9533
9547
|
const tx = await this.#client.transaction("write");
|
|
9534
9548
|
try {
|
|
9535
9549
|
const selectResult = await tx.execute({
|
|
@@ -9573,7 +9587,7 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
9573
9587
|
async updateBufferedObservations(input) {
|
|
9574
9588
|
try {
|
|
9575
9589
|
const nowStr = (/* @__PURE__ */ new Date()).toISOString();
|
|
9576
|
-
await
|
|
9590
|
+
await this.#write("updateBufferedObservations", async () => {
|
|
9577
9591
|
const tx = await this.#client.transaction("write");
|
|
9578
9592
|
try {
|
|
9579
9593
|
const current = await tx.execute({
|
|
@@ -9654,7 +9668,7 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
9654
9668
|
async swapBufferedToActive(input) {
|
|
9655
9669
|
try {
|
|
9656
9670
|
const nowStr = (/* @__PURE__ */ new Date()).toISOString();
|
|
9657
|
-
return await
|
|
9671
|
+
return await this.#write("swapBufferedToActive", async () => {
|
|
9658
9672
|
const tx = await this.#client.transaction("write");
|
|
9659
9673
|
try {
|
|
9660
9674
|
const current = await tx.execute({
|
|
@@ -9803,7 +9817,7 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
9803
9817
|
async updateBufferedReflection(input) {
|
|
9804
9818
|
try {
|
|
9805
9819
|
const nowStr = (/* @__PURE__ */ new Date()).toISOString();
|
|
9806
|
-
if ((await
|
|
9820
|
+
if ((await this.#write("updateBufferedReflection", () => this.#client.execute({
|
|
9807
9821
|
sql: `UPDATE "${OM_TABLE}" SET
|
|
9808
9822
|
"bufferedReflection" = CASE
|
|
9809
9823
|
WHEN "bufferedReflection" IS NOT NULL AND "bufferedReflection" != ''
|
|
@@ -9843,7 +9857,7 @@ var MemoryLibSQL = class MemoryLibSQL extends MemoryStorage {
|
|
|
9843
9857
|
}
|
|
9844
9858
|
async swapBufferedReflectionToActive(input) {
|
|
9845
9859
|
try {
|
|
9846
|
-
return await
|
|
9860
|
+
return await this.#write("swapBufferedReflectionToActive", async () => {
|
|
9847
9861
|
const tx = await this.#client.transaction("write");
|
|
9848
9862
|
try {
|
|
9849
9863
|
const current = await tx.execute({
|