@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.mjs CHANGED
@@ -139,6 +139,9 @@ var LibSQLMemoryAdapter = class {
139
139
  workflow_name TEXT NOT NULL,
140
140
  status TEXT NOT NULL,
141
141
  suspension TEXT,
142
+ events TEXT,
143
+ output TEXT,
144
+ cancellation TEXT,
142
145
  user_id TEXT,
143
146
  conversation_id TEXT,
144
147
  metadata TEXT,
@@ -156,6 +159,7 @@ var LibSQLMemoryAdapter = class {
156
159
  }, "initialize database schema");
157
160
  await this.addV2ColumnsToMessagesTable();
158
161
  await this.migrateDefaultUserIds();
162
+ await this.addWorkflowStateColumns();
159
163
  this.initialized = true;
160
164
  this.logger.debug("Database schema initialized");
161
165
  }
@@ -287,6 +291,42 @@ var LibSQLMemoryAdapter = class {
287
291
  this.logger.error("Failed to migrate default user_ids", error);
288
292
  }
289
293
  }
294
+ /**
295
+ * Add new columns to workflow_states table for event persistence
296
+ * This migration adds support for events, output, and cancellation tracking
297
+ */
298
+ async addWorkflowStateColumns() {
299
+ const workflowStatesTable = `${this.tablePrefix}_workflow_states`;
300
+ try {
301
+ const tableInfo = await this.client.execute(`PRAGMA table_info(${workflowStatesTable})`);
302
+ const columns = tableInfo.rows.map((row) => row.name);
303
+ if (!columns.includes("events")) {
304
+ try {
305
+ await this.client.execute(`ALTER TABLE ${workflowStatesTable} ADD COLUMN events TEXT`);
306
+ this.logger.debug("Added 'events' column to workflow_states table");
307
+ } catch (_e) {
308
+ }
309
+ }
310
+ if (!columns.includes("output")) {
311
+ try {
312
+ await this.client.execute(`ALTER TABLE ${workflowStatesTable} ADD COLUMN output TEXT`);
313
+ this.logger.debug("Added 'output' column to workflow_states table");
314
+ } catch (_e) {
315
+ }
316
+ }
317
+ if (!columns.includes("cancellation")) {
318
+ try {
319
+ await this.client.execute(
320
+ `ALTER TABLE ${workflowStatesTable} ADD COLUMN cancellation TEXT`
321
+ );
322
+ this.logger.debug("Added 'cancellation' column to workflow_states table");
323
+ } catch (_e) {
324
+ }
325
+ }
326
+ } catch (error) {
327
+ this.logger.warn("Failed to add workflow state columns (non-critical)", error);
328
+ }
329
+ }
290
330
  // ============================================================================
291
331
  // Message Operations
292
332
  // ============================================================================
@@ -721,6 +761,9 @@ var LibSQLMemoryAdapter = class {
721
761
  workflowName: row.workflow_name,
722
762
  status: row.status,
723
763
  suspension: row.suspension ? JSON.parse(row.suspension) : void 0,
764
+ events: row.events ? JSON.parse(row.events) : void 0,
765
+ output: row.output ? JSON.parse(row.output) : void 0,
766
+ cancellation: row.cancellation ? JSON.parse(row.cancellation) : void 0,
724
767
  userId: row.user_id,
725
768
  conversationId: row.conversation_id,
726
769
  metadata: row.metadata ? JSON.parse(row.metadata) : void 0,
@@ -735,15 +778,18 @@ var LibSQLMemoryAdapter = class {
735
778
  await this.initialize();
736
779
  const workflowStatesTable = `${this.tablePrefix}_workflow_states`;
737
780
  await this.client.execute({
738
- sql: `INSERT OR REPLACE INTO ${workflowStatesTable}
739
- (id, workflow_id, workflow_name, status, suspension, user_id, conversation_id, metadata, created_at, updated_at)
740
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
781
+ sql: `INSERT OR REPLACE INTO ${workflowStatesTable}
782
+ (id, workflow_id, workflow_name, status, suspension, events, output, cancellation, user_id, conversation_id, metadata, created_at, updated_at)
783
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
741
784
  args: [
742
785
  executionId,
743
786
  state.workflowId,
744
787
  state.workflowName,
745
788
  state.status,
746
789
  state.suspension ? safeStringify(state.suspension) : null,
790
+ state.events ? safeStringify(state.events) : null,
791
+ state.output ? safeStringify(state.output) : null,
792
+ state.cancellation ? safeStringify(state.cancellation) : null,
747
793
  state.userId || null,
748
794
  state.conversationId || null,
749
795
  state.metadata ? safeStringify(state.metadata) : null,
@@ -784,6 +830,9 @@ var LibSQLMemoryAdapter = class {
784
830
  workflowName: row.workflow_name,
785
831
  status: "suspended",
786
832
  suspension: row.suspension ? JSON.parse(row.suspension) : void 0,
833
+ events: row.events ? JSON.parse(row.events) : void 0,
834
+ output: row.output ? JSON.parse(row.output) : void 0,
835
+ cancellation: row.cancellation ? JSON.parse(row.cancellation) : void 0,
787
836
  userId: row.user_id,
788
837
  conversationId: row.conversation_id,
789
838
  metadata: row.metadata ? JSON.parse(row.metadata) : void 0,