@voltagent/libsql 1.0.9 → 1.0.10

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
@@ -78,6 +78,11 @@ declare class LibSQLMemoryAdapter implements StorageAdapter {
78
78
  * Updates messages with user_id='default' to use the actual user_id from their conversation
79
79
  */
80
80
  private migrateDefaultUserIds;
81
+ /**
82
+ * Add new columns to workflow_states table for event persistence
83
+ * This migration adds support for events, output, and cancellation tracking
84
+ */
85
+ private addWorkflowStateColumns;
81
86
  /**
82
87
  * Add a single message
83
88
  */
package/dist/index.d.ts CHANGED
@@ -78,6 +78,11 @@ declare class LibSQLMemoryAdapter implements StorageAdapter {
78
78
  * Updates messages with user_id='default' to use the actual user_id from their conversation
79
79
  */
80
80
  private migrateDefaultUserIds;
81
+ /**
82
+ * Add new columns to workflow_states table for event persistence
83
+ * This migration adds support for events, output, and cancellation tracking
84
+ */
85
+ private addWorkflowStateColumns;
81
86
  /**
82
87
  * Add a single message
83
88
  */
package/dist/index.js CHANGED
@@ -171,6 +171,9 @@ var LibSQLMemoryAdapter = class {
171
171
  workflow_name TEXT NOT NULL,
172
172
  status TEXT NOT NULL,
173
173
  suspension TEXT,
174
+ events TEXT,
175
+ output TEXT,
176
+ cancellation TEXT,
174
177
  user_id TEXT,
175
178
  conversation_id TEXT,
176
179
  metadata TEXT,
@@ -188,6 +191,7 @@ var LibSQLMemoryAdapter = class {
188
191
  }, "initialize database schema");
189
192
  await this.addV2ColumnsToMessagesTable();
190
193
  await this.migrateDefaultUserIds();
194
+ await this.addWorkflowStateColumns();
191
195
  this.initialized = true;
192
196
  this.logger.debug("Database schema initialized");
193
197
  }
@@ -319,6 +323,42 @@ var LibSQLMemoryAdapter = class {
319
323
  this.logger.error("Failed to migrate default user_ids", error);
320
324
  }
321
325
  }
326
+ /**
327
+ * Add new columns to workflow_states table for event persistence
328
+ * This migration adds support for events, output, and cancellation tracking
329
+ */
330
+ async addWorkflowStateColumns() {
331
+ const workflowStatesTable = `${this.tablePrefix}_workflow_states`;
332
+ try {
333
+ const tableInfo = await this.client.execute(`PRAGMA table_info(${workflowStatesTable})`);
334
+ const columns = tableInfo.rows.map((row) => row.name);
335
+ if (!columns.includes("events")) {
336
+ try {
337
+ await this.client.execute(`ALTER TABLE ${workflowStatesTable} ADD COLUMN events TEXT`);
338
+ this.logger.debug("Added 'events' column to workflow_states table");
339
+ } catch (_e) {
340
+ }
341
+ }
342
+ if (!columns.includes("output")) {
343
+ try {
344
+ await this.client.execute(`ALTER TABLE ${workflowStatesTable} ADD COLUMN output TEXT`);
345
+ this.logger.debug("Added 'output' column to workflow_states table");
346
+ } catch (_e) {
347
+ }
348
+ }
349
+ if (!columns.includes("cancellation")) {
350
+ try {
351
+ await this.client.execute(
352
+ `ALTER TABLE ${workflowStatesTable} ADD COLUMN cancellation TEXT`
353
+ );
354
+ this.logger.debug("Added 'cancellation' column to workflow_states table");
355
+ } catch (_e) {
356
+ }
357
+ }
358
+ } catch (error) {
359
+ this.logger.warn("Failed to add workflow state columns (non-critical)", error);
360
+ }
361
+ }
322
362
  // ============================================================================
323
363
  // Message Operations
324
364
  // ============================================================================
@@ -753,6 +793,9 @@ var LibSQLMemoryAdapter = class {
753
793
  workflowName: row.workflow_name,
754
794
  status: row.status,
755
795
  suspension: row.suspension ? JSON.parse(row.suspension) : void 0,
796
+ events: row.events ? JSON.parse(row.events) : void 0,
797
+ output: row.output ? JSON.parse(row.output) : void 0,
798
+ cancellation: row.cancellation ? JSON.parse(row.cancellation) : void 0,
756
799
  userId: row.user_id,
757
800
  conversationId: row.conversation_id,
758
801
  metadata: row.metadata ? JSON.parse(row.metadata) : void 0,
@@ -767,15 +810,18 @@ var LibSQLMemoryAdapter = class {
767
810
  await this.initialize();
768
811
  const workflowStatesTable = `${this.tablePrefix}_workflow_states`;
769
812
  await this.client.execute({
770
- sql: `INSERT OR REPLACE INTO ${workflowStatesTable}
771
- (id, workflow_id, workflow_name, status, suspension, user_id, conversation_id, metadata, created_at, updated_at)
772
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
813
+ sql: `INSERT OR REPLACE INTO ${workflowStatesTable}
814
+ (id, workflow_id, workflow_name, status, suspension, events, output, cancellation, user_id, conversation_id, metadata, created_at, updated_at)
815
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
773
816
  args: [
774
817
  executionId,
775
818
  state.workflowId,
776
819
  state.workflowName,
777
820
  state.status,
778
821
  state.suspension ? (0, import_internal.safeStringify)(state.suspension) : null,
822
+ state.events ? (0, import_internal.safeStringify)(state.events) : null,
823
+ state.output ? (0, import_internal.safeStringify)(state.output) : null,
824
+ state.cancellation ? (0, import_internal.safeStringify)(state.cancellation) : null,
779
825
  state.userId || null,
780
826
  state.conversationId || null,
781
827
  state.metadata ? (0, import_internal.safeStringify)(state.metadata) : null,
@@ -816,6 +862,9 @@ var LibSQLMemoryAdapter = class {
816
862
  workflowName: row.workflow_name,
817
863
  status: "suspended",
818
864
  suspension: row.suspension ? JSON.parse(row.suspension) : void 0,
865
+ events: row.events ? JSON.parse(row.events) : void 0,
866
+ output: row.output ? JSON.parse(row.output) : void 0,
867
+ cancellation: row.cancellation ? JSON.parse(row.cancellation) : void 0,
819
868
  userId: row.user_id,
820
869
  conversationId: row.conversation_id,
821
870
  metadata: row.metadata ? JSON.parse(row.metadata) : void 0,