@voltagent/libsql 1.0.1 → 1.0.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/dist/index.mjs CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  ConversationAlreadyExistsError,
11
11
  ConversationNotFoundError
12
12
  } from "@voltagent/core";
13
+ import { safeStringify } from "@voltagent/internal";
13
14
  import { createPinoLogger } from "@voltagent/logger";
14
15
  var LibSQLMemoryAdapter = class {
15
16
  static {
@@ -310,8 +311,8 @@ var LibSQLMemoryAdapter = class {
310
311
  message.id,
311
312
  userId,
312
313
  message.role,
313
- JSON.stringify(message.parts),
314
- message.metadata ? JSON.stringify(message.metadata) : null,
314
+ safeStringify(message.parts),
315
+ message.metadata ? safeStringify(message.metadata) : null,
315
316
  2,
316
317
  // format_version
317
318
  (/* @__PURE__ */ new Date()).toISOString()
@@ -341,8 +342,8 @@ var LibSQLMemoryAdapter = class {
341
342
  message.id,
342
343
  userId,
343
344
  message.role,
344
- JSON.stringify(message.parts),
345
- message.metadata ? JSON.stringify(message.metadata) : null,
345
+ safeStringify(message.parts),
346
+ message.metadata ? safeStringify(message.metadata) : null,
346
347
  2,
347
348
  // format_version
348
349
  now
@@ -477,7 +478,7 @@ var LibSQLMemoryAdapter = class {
477
478
  input.resourceId,
478
479
  input.userId,
479
480
  input.title,
480
- JSON.stringify(input.metadata || {}),
481
+ safeStringify(input.metadata || {}),
481
482
  now,
482
483
  now
483
484
  ]
@@ -604,7 +605,7 @@ var LibSQLMemoryAdapter = class {
604
605
  }
605
606
  if (updates.metadata !== void 0) {
606
607
  fieldsToUpdate.push("metadata = ?");
607
- args.push(JSON.stringify(updates.metadata));
608
+ args.push(safeStringify(updates.metadata));
608
609
  }
609
610
  args.push(id);
610
611
  await this.client.execute({
@@ -679,12 +680,12 @@ var LibSQLMemoryAdapter = class {
679
680
  metadata.workingMemory = params.content;
680
681
  await this.client.execute({
681
682
  sql: `UPDATE ${usersTable} SET metadata = ?, updated_at = ? WHERE id = ?`,
682
- args: [JSON.stringify(metadata), now, params.userId]
683
+ args: [safeStringify(metadata), now, params.userId]
683
684
  });
684
685
  } else {
685
686
  await this.client.execute({
686
687
  sql: `INSERT INTO ${usersTable} (id, metadata, created_at, updated_at) VALUES (?, ?, ?, ?)`,
687
- args: [params.userId, JSON.stringify({ workingMemory: params.content }), now, now]
688
+ args: [params.userId, safeStringify({ workingMemory: params.content }), now, now]
688
689
  });
689
690
  }
690
691
  }
@@ -714,7 +715,7 @@ var LibSQLMemoryAdapter = class {
714
715
  delete metadata.workingMemory;
715
716
  await this.client.execute({
716
717
  sql: `UPDATE ${usersTable} SET metadata = ?, updated_at = ? WHERE id = ?`,
717
- args: [JSON.stringify(metadata), (/* @__PURE__ */ new Date()).toISOString(), params.userId]
718
+ args: [safeStringify(metadata), (/* @__PURE__ */ new Date()).toISOString(), params.userId]
718
719
  });
719
720
  }
720
721
  }
@@ -765,10 +766,10 @@ var LibSQLMemoryAdapter = class {
765
766
  state.workflowId,
766
767
  state.workflowName,
767
768
  state.status,
768
- state.suspension ? JSON.stringify(state.suspension) : null,
769
+ state.suspension ? safeStringify(state.suspension) : null,
769
770
  state.userId || null,
770
771
  state.conversationId || null,
771
- state.metadata ? JSON.stringify(state.metadata) : null,
772
+ state.metadata ? safeStringify(state.metadata) : null,
772
773
  state.createdAt.toISOString(),
773
774
  state.updatedAt.toISOString()
774
775
  ]
@@ -825,7 +826,7 @@ var LibSQLMemoryAdapter = class {
825
826
  import { existsSync, mkdirSync } from "fs";
826
827
  import { dirname } from "path";
827
828
  import { createClient as createClient2 } from "@libsql/client";
828
- import { safeStringify } from "@voltagent/internal/utils";
829
+ import { safeStringify as safeStringify2 } from "@voltagent/internal/utils";
829
830
  import { createPinoLogger as createPinoLogger2 } from "@voltagent/logger";
830
831
  var LibSQLObservabilityAdapter = class {
831
832
  static {
@@ -1029,11 +1030,11 @@ var LibSQLObservabilityAdapter = class {
1029
1030
  span.duration || null,
1030
1031
  span.status.code,
1031
1032
  span.status.message || null,
1032
- safeStringify(span.attributes),
1033
- safeStringify(span.events),
1034
- span.links ? safeStringify(span.links) : null,
1035
- span.resource ? safeStringify(span.resource) : null,
1036
- span.instrumentationScope ? safeStringify(span.instrumentationScope) : null
1033
+ safeStringify2(span.attributes),
1034
+ safeStringify2(span.events),
1035
+ span.links ? safeStringify2(span.links) : null,
1036
+ span.resource ? safeStringify2(span.resource) : null,
1037
+ span.instrumentationScope ? safeStringify2(span.instrumentationScope) : null
1037
1038
  ]
1038
1039
  },
1039
1040
  // Update or insert trace metadata with entity columns
@@ -1092,15 +1093,15 @@ var LibSQLObservabilityAdapter = class {
1092
1093
  }
1093
1094
  if (updates.attributes !== void 0) {
1094
1095
  setClauses.push("attributes = ?");
1095
- args.push(safeStringify(updates.attributes));
1096
+ args.push(safeStringify2(updates.attributes));
1096
1097
  }
1097
1098
  if (updates.events !== void 0) {
1098
1099
  setClauses.push("events = ?");
1099
- args.push(safeStringify(updates.events));
1100
+ args.push(safeStringify2(updates.events));
1100
1101
  }
1101
1102
  if (updates.links !== void 0) {
1102
1103
  setClauses.push("links = ?");
1103
- args.push(safeStringify(updates.links));
1104
+ args.push(safeStringify2(updates.links));
1104
1105
  }
1105
1106
  if (setClauses.length === 0) {
1106
1107
  return;
@@ -1398,10 +1399,10 @@ var LibSQLObservabilityAdapter = class {
1398
1399
  const traceFlags = spanContext.traceFlags ?? null;
1399
1400
  const severityNumber = logRecord.severityNumber ?? null;
1400
1401
  const severityText = logRecord.severityText || null;
1401
- const body = typeof logRecord.body === "string" ? logRecord.body : safeStringify(logRecord.body);
1402
- const attributes = logRecord.attributes ? safeStringify(logRecord.attributes) : null;
1403
- const resource = logRecord.resource?.attributes ? safeStringify(logRecord.resource.attributes) : null;
1404
- const instrumentationScope = logRecord.instrumentationLibrary || logRecord.instrumentationScope ? safeStringify(logRecord.instrumentationLibrary || logRecord.instrumentationScope) : null;
1402
+ const body = typeof logRecord.body === "string" ? logRecord.body : safeStringify2(logRecord.body);
1403
+ const attributes = logRecord.attributes ? safeStringify2(logRecord.attributes) : null;
1404
+ const resource = logRecord.resource?.attributes ? safeStringify2(logRecord.resource.attributes) : null;
1405
+ const instrumentationScope = logRecord.instrumentationLibrary || logRecord.instrumentationScope ? safeStringify2(logRecord.instrumentationLibrary || logRecord.instrumentationScope) : null;
1405
1406
  await this.client.execute({
1406
1407
  sql: `
1407
1408
  INSERT INTO ${this.tablePrefix}_logs (
@@ -1645,6 +1646,7 @@ import { createClient as createClient3 } from "@libsql/client";
1645
1646
  import {
1646
1647
  cosineSimilarity
1647
1648
  } from "@voltagent/core";
1649
+ import { safeStringify as safeStringify3 } from "@voltagent/internal";
1648
1650
  import { createPinoLogger as createPinoLogger3 } from "@voltagent/logger";
1649
1651
  var LibSQLVectorAdapter = class {
1650
1652
  static {
@@ -1794,7 +1796,7 @@ var LibSQLVectorAdapter = class {
1794
1796
  }
1795
1797
  const tableName = `${this.tablePrefix}_vectors`;
1796
1798
  const serializedVector = this.serializeVector(vector);
1797
- const metadataJson = metadata ? JSON.stringify(metadata) : null;
1799
+ const metadataJson = metadata ? safeStringify3(metadata) : null;
1798
1800
  await this.executeWithRetry(async () => {
1799
1801
  await this.client.execute({
1800
1802
  sql: `
@@ -1835,7 +1837,7 @@ var LibSQLVectorAdapter = class {
1835
1837
  );
1836
1838
  }
1837
1839
  const serializedVector = this.serializeVector(item.vector);
1838
- const metadataJson = item.metadata ? JSON.stringify(item.metadata) : null;
1840
+ const metadataJson = item.metadata ? safeStringify3(item.metadata) : null;
1839
1841
  const content = item.content ?? null;
1840
1842
  stmts.push({
1841
1843
  sql: `INSERT OR REPLACE INTO ${tableName} (id, vector, dimensions, metadata, content, updated_at) VALUES (?, ?, ?, ?, ?, CURRENT_TIMESTAMP)`,