@mastra/libsql 1.10.1-alpha.0 → 1.10.1-alpha.2
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 +30 -0
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/docs-memory-semantic-recall.md +68 -6
- package/dist/index.cjs +46 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +46 -8
- package/dist/index.js.map +1 -1
- package/dist/storage/db/utils.d.ts +11 -0
- package/dist/storage/db/utils.d.ts.map +1 -1
- package/dist/storage/domains/memory/index.d.ts +2 -1
- package/dist/storage/domains/memory/index.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1170,6 +1170,37 @@ var LibSQLVector = class extends MastraVector {
|
|
|
1170
1170
|
});
|
|
1171
1171
|
}
|
|
1172
1172
|
};
|
|
1173
|
+
var safeStringify = (value) => {
|
|
1174
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
1175
|
+
const sanitize = (val) => {
|
|
1176
|
+
if (val === null || val === void 0) return val;
|
|
1177
|
+
if (typeof val === "function") return void 0;
|
|
1178
|
+
if (typeof val === "symbol") return void 0;
|
|
1179
|
+
if (typeof val === "bigint") return val.toString();
|
|
1180
|
+
if (typeof val !== "object") return val;
|
|
1181
|
+
if (ancestors.has(val)) return void 0;
|
|
1182
|
+
if (typeof val.toJSON === "function") {
|
|
1183
|
+
return sanitize(val.toJSON());
|
|
1184
|
+
}
|
|
1185
|
+
ancestors.add(val);
|
|
1186
|
+
try {
|
|
1187
|
+
if (Array.isArray(val)) {
|
|
1188
|
+
return val.map((item) => sanitize(item));
|
|
1189
|
+
}
|
|
1190
|
+
const result = {};
|
|
1191
|
+
for (const key of Object.keys(val)) {
|
|
1192
|
+
const sanitized = sanitize(val[key]);
|
|
1193
|
+
if (sanitized !== void 0) {
|
|
1194
|
+
result[key] = sanitized;
|
|
1195
|
+
}
|
|
1196
|
+
}
|
|
1197
|
+
return result;
|
|
1198
|
+
} finally {
|
|
1199
|
+
ancestors.delete(val);
|
|
1200
|
+
}
|
|
1201
|
+
};
|
|
1202
|
+
return JSON.stringify(sanitize(value)) ?? "null";
|
|
1203
|
+
};
|
|
1173
1204
|
function buildSelectColumns(tableName) {
|
|
1174
1205
|
const schema = TABLE_SCHEMAS[tableName];
|
|
1175
1206
|
return Object.keys(schema).map((col) => {
|
|
@@ -1236,12 +1267,12 @@ function prepareStatement({ tableName, record }) {
|
|
|
1236
1267
|
}
|
|
1237
1268
|
const colDef = schema[col];
|
|
1238
1269
|
if (colDef?.type === "jsonb") {
|
|
1239
|
-
return
|
|
1270
|
+
return safeStringify(v);
|
|
1240
1271
|
}
|
|
1241
1272
|
if (v instanceof Date) {
|
|
1242
1273
|
return v.toISOString();
|
|
1243
1274
|
}
|
|
1244
|
-
return typeof v === "object" ?
|
|
1275
|
+
return typeof v === "object" ? safeStringify(v) : v;
|
|
1245
1276
|
});
|
|
1246
1277
|
const placeholders = columnNames.map((col) => {
|
|
1247
1278
|
const colDef = schema[col];
|
|
@@ -1284,12 +1315,12 @@ function transformToSqlValue(value, forceJsonStringify = false) {
|
|
|
1284
1315
|
return null;
|
|
1285
1316
|
}
|
|
1286
1317
|
if (forceJsonStringify) {
|
|
1287
|
-
return
|
|
1318
|
+
return safeStringify(value);
|
|
1288
1319
|
}
|
|
1289
1320
|
if (value instanceof Date) {
|
|
1290
1321
|
return value.toISOString();
|
|
1291
1322
|
}
|
|
1292
|
-
return typeof value === "object" ?
|
|
1323
|
+
return typeof value === "object" ? safeStringify(value) : value;
|
|
1293
1324
|
}
|
|
1294
1325
|
function prepareDeleteStatement({ tableName, keys }) {
|
|
1295
1326
|
const parsedTableName = parseSqlIdentifier(tableName, "table name");
|
|
@@ -6607,11 +6638,18 @@ var MemoryLibSQL = class extends MemoryStorage {
|
|
|
6607
6638
|
});
|
|
6608
6639
|
return updatedResource;
|
|
6609
6640
|
}
|
|
6610
|
-
async getThreadById({
|
|
6641
|
+
async getThreadById({
|
|
6642
|
+
threadId,
|
|
6643
|
+
resourceId
|
|
6644
|
+
}) {
|
|
6611
6645
|
try {
|
|
6646
|
+
const keys = { id: threadId };
|
|
6647
|
+
if (resourceId !== void 0) {
|
|
6648
|
+
keys.resourceId = resourceId;
|
|
6649
|
+
}
|
|
6612
6650
|
const result = await this.#db.select({
|
|
6613
6651
|
tableName: TABLE_THREADS,
|
|
6614
|
-
keys
|
|
6652
|
+
keys
|
|
6615
6653
|
});
|
|
6616
6654
|
if (!result) {
|
|
6617
6655
|
return null;
|
|
@@ -10605,7 +10643,7 @@ var WorkflowsLibSQL = class extends WorkflowsStorage {
|
|
|
10605
10643
|
VALUES (?, ?, jsonb(?), ?, ?)
|
|
10606
10644
|
ON CONFLICT(workflow_name, run_id)
|
|
10607
10645
|
DO UPDATE SET snapshot = excluded.snapshot, updatedAt = excluded.updatedAt`,
|
|
10608
|
-
args: [workflowName, runId,
|
|
10646
|
+
args: [workflowName, runId, safeStringify(snapshot), now, now]
|
|
10609
10647
|
});
|
|
10610
10648
|
await tx.commit();
|
|
10611
10649
|
return snapshot.context;
|
|
@@ -10642,7 +10680,7 @@ var WorkflowsLibSQL = class extends WorkflowsStorage {
|
|
|
10642
10680
|
const updatedSnapshot = { ...snapshot, ...opts };
|
|
10643
10681
|
await tx.execute({
|
|
10644
10682
|
sql: `UPDATE ${TABLE_WORKFLOW_SNAPSHOT} SET snapshot = jsonb(?) WHERE workflow_name = ? AND run_id = ?`,
|
|
10645
|
-
args: [
|
|
10683
|
+
args: [safeStringify(updatedSnapshot), workflowName, runId]
|
|
10646
10684
|
});
|
|
10647
10685
|
await tx.commit();
|
|
10648
10686
|
return updatedSnapshot;
|