@voltagent/libsql 1.0.12 → 1.0.14

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
@@ -531,11 +531,15 @@ var LibSQLMemoryAdapter = class {
531
531
  } else {
532
532
  parts = [];
533
533
  }
534
+ const metadata = row.metadata ? JSON.parse(row.metadata) : {};
534
535
  return {
535
536
  id: row.message_id,
536
537
  role: row.role,
537
538
  parts,
538
- metadata: row.metadata ? JSON.parse(row.metadata) : void 0
539
+ metadata: {
540
+ ...metadata,
541
+ createdAt: row.created_at ? new Date(row.created_at) : void 0
542
+ }
539
543
  };
540
544
  });
541
545
  }
@@ -917,6 +921,63 @@ var LibSQLMemoryAdapter = class {
917
921
  updatedAt: new Date(row.updated_at)
918
922
  };
919
923
  }
924
+ /**
925
+ * Query workflow states with optional filters
926
+ */
927
+ async queryWorkflowRuns(query) {
928
+ await this.initialize();
929
+ const workflowStatesTable = `${this.tablePrefix}_workflow_states`;
930
+ const conditions = [];
931
+ const args = [];
932
+ if (query.workflowId) {
933
+ conditions.push("workflow_id = ?");
934
+ args.push(query.workflowId);
935
+ }
936
+ if (query.status) {
937
+ conditions.push("status = ?");
938
+ args.push(query.status);
939
+ }
940
+ if (query.from) {
941
+ conditions.push("created_at >= ?");
942
+ args.push(query.from.toISOString());
943
+ }
944
+ if (query.to) {
945
+ conditions.push("created_at <= ?");
946
+ args.push(query.to.toISOString());
947
+ }
948
+ let sql = `SELECT * FROM ${workflowStatesTable}`;
949
+ if (conditions.length > 0) {
950
+ sql += ` WHERE ${conditions.join(" AND ")}`;
951
+ }
952
+ sql += " ORDER BY created_at DESC";
953
+ if (query.limit !== void 0) {
954
+ sql += " LIMIT ?";
955
+ args.push(query.limit);
956
+ }
957
+ if (query.offset !== void 0) {
958
+ sql += " OFFSET ?";
959
+ args.push(query.offset);
960
+ }
961
+ const result = await this.client.execute({
962
+ sql,
963
+ args
964
+ });
965
+ return result.rows.map((row) => ({
966
+ id: row.id,
967
+ workflowId: row.workflow_id,
968
+ workflowName: row.workflow_name,
969
+ status: row.status,
970
+ suspension: row.suspension ? JSON.parse(row.suspension) : void 0,
971
+ events: row.events ? JSON.parse(row.events) : void 0,
972
+ output: row.output ? JSON.parse(row.output) : void 0,
973
+ cancellation: row.cancellation ? JSON.parse(row.cancellation) : void 0,
974
+ userId: row.user_id,
975
+ conversationId: row.conversation_id,
976
+ metadata: row.metadata ? JSON.parse(row.metadata) : void 0,
977
+ createdAt: new Date(row.created_at),
978
+ updatedAt: new Date(row.updated_at)
979
+ }));
980
+ }
920
981
  /**
921
982
  * Set workflow state
922
983
  */