@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.d.mts CHANGED
@@ -95,7 +95,9 @@ declare class LibSQLMemoryAdapter implements StorageAdapter {
95
95
  /**
96
96
  * Get messages with optional filtering
97
97
  */
98
- getMessages(userId: string, conversationId: string, options?: GetMessagesOptions): Promise<UIMessage[]>;
98
+ getMessages(userId: string, conversationId: string, options?: GetMessagesOptions): Promise<UIMessage<{
99
+ createdAt: Date;
100
+ }>[]>;
99
101
  getConversationSteps(userId: string, conversationId: string, options?: GetConversationStepsOptions): Promise<ConversationStepRecord[]>;
100
102
  /**
101
103
  * Clear messages for a user
@@ -158,6 +160,17 @@ declare class LibSQLMemoryAdapter implements StorageAdapter {
158
160
  * Get workflow state by execution ID
159
161
  */
160
162
  getWorkflowState(executionId: string): Promise<WorkflowStateEntry | null>;
163
+ /**
164
+ * Query workflow states with optional filters
165
+ */
166
+ queryWorkflowRuns(query: {
167
+ workflowId?: string;
168
+ status?: WorkflowStateEntry["status"];
169
+ from?: Date;
170
+ to?: Date;
171
+ limit?: number;
172
+ offset?: number;
173
+ }): Promise<WorkflowStateEntry[]>;
161
174
  /**
162
175
  * Set workflow state
163
176
  */
package/dist/index.d.ts CHANGED
@@ -95,7 +95,9 @@ declare class LibSQLMemoryAdapter implements StorageAdapter {
95
95
  /**
96
96
  * Get messages with optional filtering
97
97
  */
98
- getMessages(userId: string, conversationId: string, options?: GetMessagesOptions): Promise<UIMessage[]>;
98
+ getMessages(userId: string, conversationId: string, options?: GetMessagesOptions): Promise<UIMessage<{
99
+ createdAt: Date;
100
+ }>[]>;
99
101
  getConversationSteps(userId: string, conversationId: string, options?: GetConversationStepsOptions): Promise<ConversationStepRecord[]>;
100
102
  /**
101
103
  * Clear messages for a user
@@ -158,6 +160,17 @@ declare class LibSQLMemoryAdapter implements StorageAdapter {
158
160
  * Get workflow state by execution ID
159
161
  */
160
162
  getWorkflowState(executionId: string): Promise<WorkflowStateEntry | null>;
163
+ /**
164
+ * Query workflow states with optional filters
165
+ */
166
+ queryWorkflowRuns(query: {
167
+ workflowId?: string;
168
+ status?: WorkflowStateEntry["status"];
169
+ from?: Date;
170
+ to?: Date;
171
+ limit?: number;
172
+ offset?: number;
173
+ }): Promise<WorkflowStateEntry[]>;
161
174
  /**
162
175
  * Set workflow state
163
176
  */
package/dist/index.js CHANGED
@@ -563,11 +563,15 @@ var LibSQLMemoryAdapter = class {
563
563
  } else {
564
564
  parts = [];
565
565
  }
566
+ const metadata = row.metadata ? JSON.parse(row.metadata) : {};
566
567
  return {
567
568
  id: row.message_id,
568
569
  role: row.role,
569
570
  parts,
570
- metadata: row.metadata ? JSON.parse(row.metadata) : void 0
571
+ metadata: {
572
+ ...metadata,
573
+ createdAt: row.created_at ? new Date(row.created_at) : void 0
574
+ }
571
575
  };
572
576
  });
573
577
  }
@@ -949,6 +953,63 @@ var LibSQLMemoryAdapter = class {
949
953
  updatedAt: new Date(row.updated_at)
950
954
  };
951
955
  }
956
+ /**
957
+ * Query workflow states with optional filters
958
+ */
959
+ async queryWorkflowRuns(query) {
960
+ await this.initialize();
961
+ const workflowStatesTable = `${this.tablePrefix}_workflow_states`;
962
+ const conditions = [];
963
+ const args = [];
964
+ if (query.workflowId) {
965
+ conditions.push("workflow_id = ?");
966
+ args.push(query.workflowId);
967
+ }
968
+ if (query.status) {
969
+ conditions.push("status = ?");
970
+ args.push(query.status);
971
+ }
972
+ if (query.from) {
973
+ conditions.push("created_at >= ?");
974
+ args.push(query.from.toISOString());
975
+ }
976
+ if (query.to) {
977
+ conditions.push("created_at <= ?");
978
+ args.push(query.to.toISOString());
979
+ }
980
+ let sql = `SELECT * FROM ${workflowStatesTable}`;
981
+ if (conditions.length > 0) {
982
+ sql += ` WHERE ${conditions.join(" AND ")}`;
983
+ }
984
+ sql += " ORDER BY created_at DESC";
985
+ if (query.limit !== void 0) {
986
+ sql += " LIMIT ?";
987
+ args.push(query.limit);
988
+ }
989
+ if (query.offset !== void 0) {
990
+ sql += " OFFSET ?";
991
+ args.push(query.offset);
992
+ }
993
+ const result = await this.client.execute({
994
+ sql,
995
+ args
996
+ });
997
+ return result.rows.map((row) => ({
998
+ id: row.id,
999
+ workflowId: row.workflow_id,
1000
+ workflowName: row.workflow_name,
1001
+ status: row.status,
1002
+ suspension: row.suspension ? JSON.parse(row.suspension) : void 0,
1003
+ events: row.events ? JSON.parse(row.events) : void 0,
1004
+ output: row.output ? JSON.parse(row.output) : void 0,
1005
+ cancellation: row.cancellation ? JSON.parse(row.cancellation) : void 0,
1006
+ userId: row.user_id,
1007
+ conversationId: row.conversation_id,
1008
+ metadata: row.metadata ? JSON.parse(row.metadata) : void 0,
1009
+ createdAt: new Date(row.created_at),
1010
+ updatedAt: new Date(row.updated_at)
1011
+ }));
1012
+ }
952
1013
  /**
953
1014
  * Set workflow state
954
1015
  */