@multiplier-labs/stepflow 0.3.1

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.
Files changed (76) hide show
  1. package/.github/workflows/publish.yml +30 -0
  2. package/README.md +408 -0
  3. package/dist/chunk-FQCT3I2A.js +1512 -0
  4. package/dist/chunk-FQCT3I2A.js.map +1 -0
  5. package/dist/chunk-GXY66V7Q.js +111 -0
  6. package/dist/chunk-GXY66V7Q.js.map +1 -0
  7. package/dist/chunk-U5QGN3RT.js +715 -0
  8. package/dist/chunk-U5QGN3RT.js.map +1 -0
  9. package/dist/chunk-XCF4PLN7.js +575 -0
  10. package/dist/chunk-XCF4PLN7.js.map +1 -0
  11. package/dist/events/index.d.ts +346 -0
  12. package/dist/events/index.js +11 -0
  13. package/dist/events/index.js.map +1 -0
  14. package/dist/index-CPfGsmrp.d.ts +567 -0
  15. package/dist/index.d.ts +748 -0
  16. package/dist/index.js +1707 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/scheduler/index.d.ts +6 -0
  19. package/dist/scheduler/index.js +12 -0
  20. package/dist/scheduler/index.js.map +1 -0
  21. package/dist/storage/index.d.ts +402 -0
  22. package/dist/storage/index.js +13 -0
  23. package/dist/storage/index.js.map +1 -0
  24. package/dist/types-BVShq7zT.d.ts +150 -0
  25. package/dist/types-BlwFEGzj.d.ts +276 -0
  26. package/dist/types-DzkEqnQJ.d.ts +75 -0
  27. package/docs/github-packages-setup.md +97 -0
  28. package/docs/stepflow-api-reference.md +1662 -0
  29. package/package.json +85 -0
  30. package/src/core/engine.test.ts +1421 -0
  31. package/src/core/engine.ts +717 -0
  32. package/src/core/index.ts +7 -0
  33. package/src/core/orchestrator.ts +590 -0
  34. package/src/core/types.ts +242 -0
  35. package/src/events/index.ts +8 -0
  36. package/src/events/memory.test.ts +109 -0
  37. package/src/events/memory.ts +95 -0
  38. package/src/events/socketio.test.ts +428 -0
  39. package/src/events/socketio.ts +269 -0
  40. package/src/events/types.ts +121 -0
  41. package/src/events/webhook.test.ts +695 -0
  42. package/src/events/webhook.ts +591 -0
  43. package/src/index.ts +270 -0
  44. package/src/planning/index.ts +52 -0
  45. package/src/planning/planner.ts +601 -0
  46. package/src/planning/planning.test.ts +790 -0
  47. package/src/planning/registry.test.ts +445 -0
  48. package/src/planning/registry.ts +369 -0
  49. package/src/planning/types.ts +570 -0
  50. package/src/scheduler/cron.test.ts +480 -0
  51. package/src/scheduler/cron.ts +449 -0
  52. package/src/scheduler/index.ts +18 -0
  53. package/src/scheduler/postgres-persistence.test.ts +906 -0
  54. package/src/scheduler/postgres-persistence.ts +546 -0
  55. package/src/scheduler/sqlite-persistence.test.ts +235 -0
  56. package/src/scheduler/sqlite-persistence.ts +268 -0
  57. package/src/scheduler/types.ts +78 -0
  58. package/src/storage/index.ts +27 -0
  59. package/src/storage/memory.test.ts +399 -0
  60. package/src/storage/memory.ts +248 -0
  61. package/src/storage/postgres.ts +1550 -0
  62. package/src/storage/sqlite.test.ts +593 -0
  63. package/src/storage/sqlite.ts +662 -0
  64. package/src/storage/types.ts +368 -0
  65. package/src/utils/errors.test.ts +152 -0
  66. package/src/utils/errors.ts +191 -0
  67. package/src/utils/id.ts +21 -0
  68. package/src/utils/index.ts +8 -0
  69. package/src/utils/logger.test.ts +127 -0
  70. package/src/utils/logger.ts +96 -0
  71. package/src/utils/postgres-deps.ts +63 -0
  72. package/src/utils/retry.test.ts +197 -0
  73. package/src/utils/retry.ts +121 -0
  74. package/tsconfig.json +21 -0
  75. package/tsup.config.ts +14 -0
  76. package/vitest.config.ts +9 -0
@@ -0,0 +1,567 @@
1
+ import { L as Logger, g as WorkflowDefinition, W as WorkflowKind, R as RunStatus } from './types-BVShq7zT.js';
2
+ import { i as StorageAdapter, j as WorkflowRunRecord } from './types-BlwFEGzj.js';
3
+ import { a as EventTransport, E as EventCallback, U as Unsubscribe } from './types-DzkEqnQJ.js';
4
+ import { Database } from 'better-sqlite3';
5
+ import { Pool, PoolConfig } from 'pg';
6
+
7
+ /**
8
+ * Main WorkflowEngine class.
9
+ *
10
+ * This is the primary entry point for the workflow engine.
11
+ * It provides methods for registering workflows, starting runs,
12
+ * and managing workflow execution.
13
+ */
14
+
15
+ /**
16
+ * Configuration for the workflow engine.
17
+ */
18
+ interface WorkflowEngineConfig {
19
+ /** Storage adapter for persistence (default: MemoryStorageAdapter) */
20
+ storage?: StorageAdapter;
21
+ /** Event transport for real-time updates (default: MemoryEventTransport) */
22
+ events?: EventTransport;
23
+ /** Logger instance (default: ConsoleLogger) */
24
+ logger?: Logger;
25
+ /** Global settings */
26
+ settings?: {
27
+ /** Default timeout for workflows in ms */
28
+ defaultTimeout?: number;
29
+ /** Maximum concurrent workflows */
30
+ maxConcurrency?: number;
31
+ };
32
+ }
33
+ /**
34
+ * Options for starting a workflow run.
35
+ */
36
+ interface StartRunOptions<TInput = Record<string, unknown>> {
37
+ /** Workflow type to run */
38
+ kind: WorkflowKind;
39
+ /** Input parameters */
40
+ input?: TInput;
41
+ /** Optional metadata (e.g., userId, topicId) */
42
+ metadata?: Record<string, unknown>;
43
+ /** Parent run ID (for child workflows) */
44
+ parentRunId?: string;
45
+ /** Delay before starting (ms) */
46
+ delay?: number;
47
+ /** Priority for queue ordering (higher = runs first, default: 0) */
48
+ priority?: number;
49
+ }
50
+ declare class WorkflowEngine {
51
+ private registry;
52
+ private storage;
53
+ private events;
54
+ private logger;
55
+ private activeRuns;
56
+ private settings;
57
+ private runQueue;
58
+ constructor(config?: WorkflowEngineConfig);
59
+ /**
60
+ * Initialize the engine and its storage/event adapters.
61
+ * Call this before starting runs if your storage adapter requires initialization
62
+ * (e.g., PostgresStorageAdapter).
63
+ */
64
+ initialize(): Promise<void>;
65
+ /**
66
+ * Get the current number of active runs.
67
+ */
68
+ getActiveRunCount(): number;
69
+ /**
70
+ * Get the number of queued runs waiting for capacity.
71
+ */
72
+ getQueuedRunCount(): number;
73
+ /**
74
+ * Check if capacity is available for a new run.
75
+ */
76
+ private hasCapacity;
77
+ /**
78
+ * Register a workflow definition.
79
+ * Must be called before runs of this type can be started.
80
+ *
81
+ * @param definition - The workflow definition
82
+ * @throws WorkflowAlreadyRegisteredError if already registered
83
+ */
84
+ registerWorkflow<TInput = Record<string, unknown>>(definition: WorkflowDefinition<TInput>): void;
85
+ /**
86
+ * Unregister a workflow definition.
87
+ *
88
+ * @param kind - The workflow kind to unregister
89
+ * @returns true if the workflow was unregistered, false if not found
90
+ */
91
+ unregisterWorkflow(kind: WorkflowKind): boolean;
92
+ /**
93
+ * Get a registered workflow definition.
94
+ *
95
+ * @param kind - The workflow kind
96
+ * @returns The workflow definition or undefined
97
+ */
98
+ getWorkflow(kind: WorkflowKind): WorkflowDefinition | undefined;
99
+ /**
100
+ * Get all registered workflow kinds.
101
+ */
102
+ getRegisteredWorkflows(): WorkflowKind[];
103
+ /**
104
+ * Start a new workflow run (non-blocking).
105
+ * The run executes asynchronously and this method returns immediately.
106
+ * If maxConcurrency is set and reached, the run is queued.
107
+ *
108
+ * @param options - Run options including kind and input
109
+ * @returns The generated run ID
110
+ * @throws WorkflowNotFoundError if the workflow kind is not registered
111
+ */
112
+ startRun<TInput = Record<string, unknown>>(options: StartRunOptions<TInput>): Promise<string>;
113
+ /**
114
+ * Queue a run in priority order.
115
+ */
116
+ private queueRun;
117
+ /**
118
+ * Execute a run (internal method).
119
+ */
120
+ private executeRun;
121
+ /**
122
+ * Launch a workflow run asynchronously.
123
+ * Shared by both executeRun (new runs) and resumeRun (checkpoint recovery).
124
+ */
125
+ private launchRun;
126
+ /**
127
+ * Process the queue and start runs if capacity is available.
128
+ */
129
+ private processQueue;
130
+ /**
131
+ * Start a child workflow from within a parent workflow.
132
+ * Called internally by the context.spawnChild helper.
133
+ */
134
+ private spawnChild;
135
+ /**
136
+ * Cancel a running workflow.
137
+ * Signals the workflow to stop at the next cancellation point.
138
+ *
139
+ * @param runId - The run ID to cancel
140
+ * @throws {RunNotFoundError} If no run with the given ID exists
141
+ */
142
+ cancelRun(runId: string): Promise<void>;
143
+ /**
144
+ * Get the current status of a run.
145
+ *
146
+ * @param runId - The run ID to look up
147
+ * @returns The run record or null if not found
148
+ */
149
+ getRunStatus(runId: string): Promise<WorkflowRunRecord | null>;
150
+ private static readonly TERMINAL_STATUSES;
151
+ private static readonly TERMINAL_EVENT_TYPES;
152
+ /**
153
+ * Wait for a run to complete.
154
+ * Subscribes to run events and resolves when a terminal event fires.
155
+ * Falls back to an initial storage read to avoid race conditions.
156
+ *
157
+ * @param runId - The run ID to wait for
158
+ * @param options - Wait options
159
+ * @returns The final run record
160
+ */
161
+ waitForRun(runId: string, options?: {
162
+ timeout?: number;
163
+ }): Promise<WorkflowRunRecord>;
164
+ /**
165
+ * Resume an interrupted workflow run from its checkpoint.
166
+ * The run must be in 'queued' or 'running' status.
167
+ *
168
+ * @param runId - The run ID to resume
169
+ * @returns The run ID (same as input)
170
+ * @throws {RunNotFoundError} If no run with the given ID exists
171
+ * @throws {Error} If the run status is not 'queued' or 'running'
172
+ * @throws {WorkflowNotFoundError} If the workflow kind is not registered
173
+ */
174
+ resumeRun(runId: string): Promise<string>;
175
+ /**
176
+ * Get all runs that were interrupted and can be resumed.
177
+ * Returns runs with status 'queued' or 'running'.
178
+ */
179
+ getResumableRuns(): Promise<WorkflowRunRecord[]>;
180
+ /**
181
+ * Resume all interrupted runs.
182
+ * Useful for recovering after a server restart.
183
+ *
184
+ * @returns Array of resumed run IDs
185
+ */
186
+ resumeAllInterrupted(): Promise<string[]>;
187
+ /**
188
+ * Subscribe to events for a specific run.
189
+ *
190
+ * @param runId - The run ID to subscribe to
191
+ * @param callback - Event handler
192
+ * @returns Unsubscribe function
193
+ */
194
+ subscribeToRun(runId: string, callback: EventCallback): Unsubscribe;
195
+ /**
196
+ * Subscribe to all workflow events.
197
+ *
198
+ * @param callback - Event handler
199
+ * @returns Unsubscribe function
200
+ */
201
+ subscribeToAll(callback: EventCallback): Unsubscribe;
202
+ /**
203
+ * Get the storage adapter.
204
+ * Useful for querying runs and steps directly.
205
+ */
206
+ getStorage(): StorageAdapter;
207
+ /**
208
+ * Get the event transport.
209
+ * Useful for custom event handling.
210
+ */
211
+ getEvents(): EventTransport;
212
+ /**
213
+ * Shutdown the engine gracefully.
214
+ * Cancels all active runs and closes resources.
215
+ */
216
+ shutdown(): Promise<void>;
217
+ }
218
+
219
+ /**
220
+ * Scheduler types for the workflow engine.
221
+ * Defines the type contracts for the cron and workflow-completion trigger
222
+ * scheduler, implemented by {@link CronScheduler}, {@link SQLiteSchedulePersistence},
223
+ * and {@link PostgresSchedulePersistence}.
224
+ */
225
+
226
+ /**
227
+ * Schedule trigger types.
228
+ */
229
+ type TriggerType = "cron" | "workflow_completed" | "manual";
230
+ /**
231
+ * Schedule definition.
232
+ */
233
+ interface WorkflowSchedule {
234
+ id: string;
235
+ workflowKind: WorkflowKind;
236
+ triggerType: TriggerType;
237
+ /** Cron expression for time-based triggers (e.g. `0 0 * * *` for daily). Only used when triggerType is 'cron'. */
238
+ cronExpression?: string;
239
+ /** IANA timezone for cron evaluation (e.g. 'America/New_York'). Defaults to 'UTC'. */
240
+ timezone?: string;
241
+ /** Workflow kind that triggers this schedule on completion. Only used when triggerType is 'workflow_completed'. */
242
+ triggerOnWorkflowKind?: WorkflowKind;
243
+ /** Run statuses that activate the completion trigger. If empty, any terminal status triggers. */
244
+ triggerOnStatus?: RunStatus[];
245
+ /** Input payload passed to the spawned workflow run. */
246
+ input?: Record<string, unknown>;
247
+ /** Arbitrary metadata attached to the spawned workflow run. */
248
+ metadata?: Record<string, unknown>;
249
+ /** Whether this schedule is active. Disabled schedules are not evaluated. */
250
+ enabled: boolean;
251
+ /** Timestamp of the most recent run spawned by this schedule. */
252
+ lastRunAt?: Date;
253
+ /** Run ID of the most recent run spawned by this schedule. */
254
+ lastRunId?: string;
255
+ /** Next scheduled execution time, computed from the cron expression and timezone. */
256
+ nextRunAt?: Date;
257
+ }
258
+ /**
259
+ * Scheduler interface.
260
+ * Implement this to create custom schedulers.
261
+ */
262
+ interface Scheduler {
263
+ /** Start the scheduler */
264
+ start(): Promise<void>;
265
+ /** Stop the scheduler */
266
+ stop(): Promise<void>;
267
+ /** Add a schedule */
268
+ addSchedule(schedule: Omit<WorkflowSchedule, "id">): Promise<WorkflowSchedule>;
269
+ /** Remove a schedule */
270
+ removeSchedule(scheduleId: string): Promise<void>;
271
+ /** Update a schedule */
272
+ updateSchedule(scheduleId: string, updates: Partial<WorkflowSchedule>): Promise<void>;
273
+ /** Get all schedules */
274
+ getSchedules(): Promise<WorkflowSchedule[]>;
275
+ /** Manually trigger a scheduled workflow */
276
+ triggerNow(scheduleId: string): Promise<string>;
277
+ }
278
+
279
+ /**
280
+ * CronScheduler - Scheduler implementation using cron expressions.
281
+ *
282
+ * Provides time-based and workflow-completion-based triggers for workflows.
283
+ */
284
+
285
+ /**
286
+ * Configuration for the CronScheduler.
287
+ */
288
+ interface CronSchedulerConfig {
289
+ /** The workflow engine instance */
290
+ engine: WorkflowEngine;
291
+ /** Logger instance */
292
+ logger?: Logger;
293
+ /** Poll interval for checking schedules (ms, default: 1000) */
294
+ pollInterval?: number;
295
+ /** Optional persistence adapter for schedules */
296
+ persistence?: SchedulePersistence;
297
+ }
298
+ /**
299
+ * Interface for schedule persistence.
300
+ * Implement this to persist schedules to a database.
301
+ */
302
+ interface SchedulePersistence {
303
+ /** Load all schedules from storage */
304
+ loadSchedules(): Promise<WorkflowSchedule[]>;
305
+ /** Save a schedule */
306
+ saveSchedule(schedule: WorkflowSchedule): Promise<void>;
307
+ /** Update a schedule */
308
+ updateSchedule(scheduleId: string, updates: Partial<WorkflowSchedule>): Promise<void>;
309
+ /** Delete a schedule */
310
+ deleteSchedule(scheduleId: string): Promise<void>;
311
+ }
312
+ /**
313
+ * Scheduler implementation that supports cron expressions and workflow completion triggers.
314
+ *
315
+ * @example
316
+ * ```typescript
317
+ * const scheduler = new CronScheduler({
318
+ * engine,
319
+ * pollInterval: 1000,
320
+ * });
321
+ *
322
+ * // Add a cron schedule (every day at midnight)
323
+ * await scheduler.addSchedule({
324
+ * workflowKind: 'cleanup.daily',
325
+ * triggerType: 'cron',
326
+ * cronExpression: '0 0 * * *',
327
+ * enabled: true,
328
+ * });
329
+ *
330
+ * // Add a workflow completion trigger
331
+ * await scheduler.addSchedule({
332
+ * workflowKind: 'notification.send',
333
+ * triggerType: 'workflow_completed',
334
+ * triggerOnWorkflowKind: 'order.process',
335
+ * triggerOnStatus: ['succeeded'],
336
+ * enabled: true,
337
+ * });
338
+ *
339
+ * await scheduler.start();
340
+ * ```
341
+ */
342
+ declare class CronScheduler implements Scheduler {
343
+ private engine;
344
+ private logger;
345
+ private pollInterval;
346
+ private persistence?;
347
+ private schedules;
348
+ private running;
349
+ private pollTimer;
350
+ private eventUnsubscribe;
351
+ constructor(config: CronSchedulerConfig);
352
+ /**
353
+ * Start the scheduler.
354
+ * Begins polling for cron schedules and subscribes to workflow completion events.
355
+ */
356
+ start(): Promise<void>;
357
+ /**
358
+ * Stop the scheduler.
359
+ * Stops polling and unsubscribes from events.
360
+ */
361
+ stop(): Promise<void>;
362
+ /**
363
+ * Add a new schedule.
364
+ */
365
+ addSchedule(scheduleData: Omit<WorkflowSchedule, "id">): Promise<WorkflowSchedule>;
366
+ /**
367
+ * Remove a schedule.
368
+ */
369
+ removeSchedule(scheduleId: string): Promise<void>;
370
+ /**
371
+ * Update a schedule.
372
+ */
373
+ updateSchedule(scheduleId: string, updates: Partial<WorkflowSchedule>): Promise<void>;
374
+ /**
375
+ * Get all schedules.
376
+ */
377
+ getSchedules(): Promise<WorkflowSchedule[]>;
378
+ /**
379
+ * Get a schedule by ID.
380
+ */
381
+ getSchedule(scheduleId: string): WorkflowSchedule | undefined;
382
+ /**
383
+ * Manually trigger a scheduled workflow.
384
+ */
385
+ triggerNow(scheduleId: string): Promise<string>;
386
+ /**
387
+ * Check all cron schedules and execute those that are due.
388
+ */
389
+ private checkSchedules;
390
+ /**
391
+ * Handle workflow events for completion triggers.
392
+ */
393
+ private handleWorkflowEvent;
394
+ /**
395
+ * Execute a schedule by starting the workflow.
396
+ */
397
+ private executeSchedule;
398
+ /**
399
+ * Update the next run time for a cron schedule.
400
+ */
401
+ private updateNextRunTime;
402
+ }
403
+
404
+ /**
405
+ * SQLite persistence adapter for schedules.
406
+ *
407
+ * Stores workflow schedules in a SQLite database table.
408
+ */
409
+
410
+ /**
411
+ * Configuration for SQLiteSchedulePersistence.
412
+ */
413
+ interface SQLiteSchedulePersistenceConfig {
414
+ /** SQLite database instance */
415
+ db: Database;
416
+ /** Table name for schedules (default: workflow_schedules) */
417
+ tableName?: string;
418
+ }
419
+ /**
420
+ * SQLite-based persistence for workflow schedules.
421
+ *
422
+ * @example
423
+ * ```typescript
424
+ * import Database from 'better-sqlite3';
425
+ *
426
+ * const db = new Database('workflow.db');
427
+ * const persistence = new SQLiteSchedulePersistence({ db });
428
+ *
429
+ * const scheduler = new CronScheduler({
430
+ * engine,
431
+ * persistence,
432
+ * });
433
+ * ```
434
+ */
435
+ declare class SQLiteSchedulePersistence implements SchedulePersistence {
436
+ private db;
437
+ private tableName;
438
+ private stmts;
439
+ constructor(config: SQLiteSchedulePersistenceConfig);
440
+ private initializeDatabase;
441
+ loadSchedules(): Promise<WorkflowSchedule[]>;
442
+ saveSchedule(schedule: WorkflowSchedule): Promise<void>;
443
+ updateSchedule(scheduleId: string, updates: Partial<WorkflowSchedule>): Promise<void>;
444
+ deleteSchedule(scheduleId: string): Promise<void>;
445
+ private rowToSchedule;
446
+ }
447
+
448
+ /**
449
+ * PostgreSQL persistence adapter for schedules.
450
+ *
451
+ * Stores workflow schedules in a PostgreSQL database table using Kysely.
452
+ */
453
+
454
+ /**
455
+ * Configuration for PostgresSchedulePersistence.
456
+ */
457
+ interface PostgresSchedulePersistenceConfig {
458
+ /**
459
+ * PostgreSQL connection string.
460
+ * Example: "postgresql://user:pass@localhost:5432/dbname"
461
+ */
462
+ connectionString?: string;
463
+ /**
464
+ * Existing pg.Pool instance for connection sharing with application.
465
+ * If provided, the adapter will not close this pool on close().
466
+ */
467
+ pool?: Pool;
468
+ /**
469
+ * Pool configuration options (if not providing pool or connectionString).
470
+ */
471
+ poolConfig?: PoolConfig;
472
+ /**
473
+ * Schema name for the schedules table.
474
+ * @default 'public'
475
+ */
476
+ schema?: string;
477
+ /**
478
+ * Table name for schedules.
479
+ * @default 'workflow_schedules'
480
+ */
481
+ tableName?: string;
482
+ /**
483
+ * Automatically create tables on initialization.
484
+ * @default true
485
+ */
486
+ autoMigrate?: boolean;
487
+ }
488
+ /**
489
+ * PostgreSQL-based persistence for workflow schedules.
490
+ *
491
+ * @example
492
+ * ```typescript
493
+ * const persistence = new PostgresSchedulePersistence({
494
+ * connectionString: process.env.DATABASE_URL,
495
+ * });
496
+ *
497
+ * await persistence.initialize();
498
+ *
499
+ * const scheduler = new CronScheduler({
500
+ * engine,
501
+ * persistence,
502
+ * });
503
+ * ```
504
+ *
505
+ * @example Sharing connection pool
506
+ * ```typescript
507
+ * import pg from 'pg';
508
+ *
509
+ * const pool = new pg.Pool({
510
+ * connectionString: process.env.DATABASE_URL,
511
+ * });
512
+ *
513
+ * const persistence = new PostgresSchedulePersistence({ pool });
514
+ * await persistence.initialize();
515
+ * ```
516
+ */
517
+ declare class PostgresSchedulePersistence implements SchedulePersistence {
518
+ private db;
519
+ private pool;
520
+ private ownsPool;
521
+ private schema;
522
+ private tableName;
523
+ private autoMigrate;
524
+ private initialized;
525
+ private config;
526
+ constructor(config: PostgresSchedulePersistenceConfig);
527
+ /**
528
+ * Get a schema-scoped query builder.
529
+ * All queries MUST use this instead of this.db directly to respect config.schema.
530
+ */
531
+ private get qb();
532
+ private ensureInitialized;
533
+ /**
534
+ * Initialize the persistence layer.
535
+ * Creates the schedules table if autoMigrate is enabled.
536
+ */
537
+ initialize(): Promise<void>;
538
+ /**
539
+ * Close the database connection.
540
+ * Only closes the pool if it was created by this adapter.
541
+ */
542
+ close(): Promise<void>;
543
+ private createTables;
544
+ loadSchedules(): Promise<WorkflowSchedule[]>;
545
+ saveSchedule(schedule: WorkflowSchedule): Promise<void>;
546
+ updateSchedule(scheduleId: string, updates: Partial<WorkflowSchedule>): Promise<void>;
547
+ deleteSchedule(scheduleId: string): Promise<void>;
548
+ /**
549
+ * Get a schedule by ID.
550
+ */
551
+ getSchedule(scheduleId: string): Promise<WorkflowSchedule | null>;
552
+ /**
553
+ * Get all enabled schedules that are due to run.
554
+ */
555
+ getDueSchedules(): Promise<WorkflowSchedule[]>;
556
+ /**
557
+ * Get schedules by workflow kind.
558
+ */
559
+ getSchedulesByWorkflowKind(workflowKind: string): Promise<WorkflowSchedule[]>;
560
+ /**
561
+ * Get workflow completion triggers for a specific workflow kind.
562
+ */
563
+ getCompletionTriggers(triggerOnWorkflowKind: string): Promise<WorkflowSchedule[]>;
564
+ private rowToSchedule;
565
+ }
566
+
567
+ export { CronScheduler as C, PostgresSchedulePersistence as P, SQLiteSchedulePersistence as S, type TriggerType as T, WorkflowEngine as W, type CronSchedulerConfig as a, type PostgresSchedulePersistenceConfig as b, type SQLiteSchedulePersistenceConfig as c, type SchedulePersistence as d, type Scheduler as e, type StartRunOptions as f, type WorkflowEngineConfig as g, type WorkflowSchedule as h };