@elsium-ai/workflows 0.8.0 → 0.9.0

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 (2) hide show
  1. package/README.md +77 -0
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -492,6 +492,83 @@ const result = await router.run({ type: 'text', content: 'Hello world' })
492
492
 
493
493
  ---
494
494
 
495
+ ## Resumable Workflows
496
+
497
+ ### `defineResumableWorkflow`
498
+
499
+ Creates a workflow that persists its progress to a checkpoint store after each step. If the process crashes or is interrupted, the workflow can be resumed from the last successful checkpoint.
500
+
501
+ ```ts
502
+ function defineResumableWorkflow(config: {
503
+ name: string
504
+ checkpointStore: CheckpointStore
505
+ steps: StepConfig[]
506
+ onStepComplete?: (result: StepResult) => void | Promise<void>
507
+ onComplete?: (result: WorkflowResult) => void | Promise<void>
508
+ }): ResumableWorkflow
509
+ ```
510
+
511
+ | Parameter | Type | Description |
512
+ | --- | --- | --- |
513
+ | `config.name` | `string` | Identifier for the workflow. |
514
+ | `config.checkpointStore` | `CheckpointStore` | Storage backend for persisting step results. |
515
+ | `config.steps` | `StepConfig[]` | Ordered list of steps to execute sequentially. |
516
+ | `config.onStepComplete` | `(result: StepResult) => void \| Promise<void>` | Optional callback fired after each step completes. |
517
+ | `config.onComplete` | `(result: WorkflowResult) => void \| Promise<void>` | Optional callback fired when the workflow finishes. |
518
+
519
+ **Returns:** `ResumableWorkflow`
520
+
521
+ ```ts
522
+ interface ResumableWorkflow extends Workflow {
523
+ resume(workflowId: string, options?: WorkflowRunOptions): Promise<WorkflowResult>
524
+ }
525
+ ```
526
+
527
+ The `resume(workflowId)` method reloads the checkpoint for the given workflow run and continues execution from the first incomplete step, reusing outputs from previously completed steps.
528
+
529
+ ### `createInMemoryCheckpointStore`
530
+
531
+ Creates an in-memory checkpoint store for development and testing.
532
+
533
+ ```ts
534
+ function createInMemoryCheckpointStore(): CheckpointStore
535
+ ```
536
+
537
+ ```ts
538
+ import { defineResumableWorkflow, createInMemoryCheckpointStore, step } from '@elsium-ai/workflows'
539
+
540
+ const checkpointStore = createInMemoryCheckpointStore()
541
+
542
+ const workflow = defineResumableWorkflow({
543
+ name: 'data-pipeline',
544
+ checkpointStore,
545
+ steps: [
546
+ step('fetch', {
547
+ handler: async (input: { url: string }) => {
548
+ return await fetch(input.url).then((r) => r.json())
549
+ },
550
+ }),
551
+ step('transform', {
552
+ handler: async (data: unknown) => {
553
+ return transformData(data)
554
+ },
555
+ }),
556
+ step('store', {
557
+ handler: async (transformed: unknown) => {
558
+ await saveToDatabase(transformed)
559
+ return { stored: true }
560
+ },
561
+ }),
562
+ ],
563
+ })
564
+
565
+ const result = await workflow.run({ url: 'https://api.example.com/data' })
566
+
567
+ const resumed = await workflow.resume(result.name)
568
+ ```
569
+
570
+ ---
571
+
495
572
  ## Part of ElsiumAI
496
573
 
497
574
  This package is the workflow layer of the [ElsiumAI](https://github.com/elsium-ai/elsium-ai) framework. See the [full documentation](https://github.com/elsium-ai/elsium-ai) for guides and examples.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elsium-ai/workflows",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "Multi-step workflow pipelines and DAG execution for ElsiumAI",
5
5
  "license": "MIT",
6
6
  "author": "Eric Utrera <ebutrera9103@gmail.com>",
@@ -26,7 +26,7 @@
26
26
  "dev": "bun --watch src/index.ts"
27
27
  },
28
28
  "dependencies": {
29
- "@elsium-ai/core": "^0.8.0",
29
+ "@elsium-ai/core": "^0.9.0",
30
30
  "zod": "^3.24.0"
31
31
  },
32
32
  "devDependencies": {