@cascade-flow/runner 0.2.3 → 0.2.5
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/README.md +25 -78
- package/dist/index.d.ts +1 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +203 -495
- package/dist/index.js.map +7 -7
- package/dist/validation.d.ts +27 -0
- package/dist/validation.d.ts.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Runner
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Workflow discovery and step execution utilities used by the worker package.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -8,65 +8,35 @@ Core workflow execution engine for direct (non-queue) execution.
|
|
|
8
8
|
bun install
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
11
|
+
## Exports
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// Execute workflow
|
|
17
|
-
const results = await runAll({
|
|
18
|
-
workflow: "my-workflow",
|
|
19
|
-
input: { userId: "123" },
|
|
20
|
-
only: ["step1", "step2"], // Optional: run subset
|
|
21
|
-
resume: true, // Optional: resume from previous run
|
|
22
|
-
runId: "previous-run-id", // Optional: specific run to resume
|
|
23
|
-
});
|
|
24
|
-
```
|
|
14
|
+
// Step execution
|
|
15
|
+
executeStepInProcess(stepFile, stepId, dependencies, ctx, attemptNumber, backend, onLog?, options?): Promise<{ result, logs }>;
|
|
25
16
|
|
|
26
|
-
|
|
17
|
+
// Discovery
|
|
18
|
+
discoverWorkflows(dir?: string): Promise<WorkflowMetadata[]>;
|
|
19
|
+
discoverSteps(workflowDir: string): Promise<LoadedStep[]>;
|
|
27
20
|
|
|
28
|
-
|
|
21
|
+
// Versioning
|
|
22
|
+
calculateWorkflowHash(workflow): Promise<string>;
|
|
23
|
+
getGitInfo(dir): Promise<GitInfo | undefined>;
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
import { step as dependency } from "../other-step/step.ts";
|
|
25
|
+
// Validation
|
|
26
|
+
getAllDependents(stepId, steps): string[];
|
|
27
|
+
validateWorkflowVersion(workflowSlug, runId, currentVersionId, backend, log): Promise<string>;
|
|
34
28
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
exportOutput: true,
|
|
38
|
-
fn: async ({ dependencies, ctx }) => {
|
|
39
|
-
return { result: dependencies.dependency.value * 2 };
|
|
40
|
-
}
|
|
41
|
-
});
|
|
29
|
+
// Types
|
|
30
|
+
LoadedStep // Step with resolved dependencies
|
|
42
31
|
```
|
|
43
32
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
```typescript
|
|
47
|
-
// workflows/my-workflow/input-schema.ts
|
|
48
|
-
import { z } from "zod";
|
|
49
|
-
export const inputSchema = z.object({
|
|
50
|
-
userId: z.string(),
|
|
51
|
-
count: z.number()
|
|
52
|
-
});
|
|
53
|
-
export type WorkflowInput = z.infer<typeof inputSchema>;
|
|
54
|
-
|
|
55
|
-
// workflows/my-workflow/defineStep.ts
|
|
56
|
-
import { baseDefineStep } from "runner";
|
|
57
|
-
import type { WorkflowInput } from "./input-schema";
|
|
58
|
-
export const defineStep = baseDefineStep<WorkflowInput>();
|
|
59
|
-
|
|
60
|
-
// workflows/my-workflow/steps/my-step/step.ts
|
|
61
|
-
import { defineStep } from "../../defineStep";
|
|
33
|
+
## Key Features
|
|
62
34
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
});
|
|
69
|
-
```
|
|
35
|
+
- **Workflow discovery** - Auto-discovers workflows from `./workflows/` directory
|
|
36
|
+
- **Step discovery** - Loads and wires step dependencies with full TypeScript inference
|
|
37
|
+
- **Subprocess execution** - Executes steps in isolated child processes
|
|
38
|
+
- **Cycle detection** - DFS validation prevents circular dependencies
|
|
39
|
+
- **Version tracking** - SHA-256 hashing for workflow version comparison
|
|
70
40
|
|
|
71
41
|
## Workflow Structure
|
|
72
42
|
|
|
@@ -74,37 +44,14 @@ export const step = defineStep({
|
|
|
74
44
|
workflows/my-workflow/
|
|
75
45
|
├── workflow.json # {"name": "My Workflow"}
|
|
76
46
|
├── input-schema.ts # Optional: Zod schema
|
|
77
|
-
├── defineStep.ts # Optional: Typed helper
|
|
78
47
|
└── steps/
|
|
79
48
|
├── step-1/step.ts # Flat step
|
|
80
49
|
├── step-2/step.ts # Flat step
|
|
81
50
|
└── data-processing/ # Optional: Group directory
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
└── transform/
|
|
85
|
-
└── normalize/step.ts # Nested step
|
|
51
|
+
└── extract/
|
|
52
|
+
└── fetch-data/step.ts # Nested step
|
|
86
53
|
```
|
|
87
54
|
|
|
88
|
-
##
|
|
89
|
-
|
|
90
|
-
- **Promise caching** - Automatic parallelization via cached promises
|
|
91
|
-
- **Type-safe dependencies** - Import step objects for full TypeScript inference
|
|
92
|
-
- **Cycle detection** - DFS validation prevents circular dependencies
|
|
93
|
-
- **Resume capability** - Continue from previous runs
|
|
94
|
-
- **Pluggable backend** - Abstract persistence layer
|
|
95
|
-
- **Nested step groups** - Organize steps in arbitrary directory hierarchies (purely organizational)
|
|
55
|
+
## Note
|
|
96
56
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
```typescript
|
|
100
|
-
// Main execution
|
|
101
|
-
runAll(options: RunAllOptions): Promise<WorkflowOutput>;
|
|
102
|
-
|
|
103
|
-
// Step helpers
|
|
104
|
-
defineStep(config: StepConfig): StepDefinition;
|
|
105
|
-
baseDefineStep<TInput>(): typeof defineStep;
|
|
106
|
-
|
|
107
|
-
// Discovery
|
|
108
|
-
discoverWorkflows(dir?: string): Promise<WorkflowMetadata[]>;
|
|
109
|
-
discoverSteps(workflowDir: string): Promise<LoadedStep[]>;
|
|
110
|
-
```
|
|
57
|
+
For workflow authoring APIs (`defineStep`, `baseDefineStep`, `Skip`, `optional`), see the `@cascade-flow/workflow` package.
|
package/dist/index.d.ts
CHANGED
|
@@ -13,15 +13,7 @@ export declare function executeStepInProcess(stepFile: string, stepId: string, d
|
|
|
13
13
|
result: StepOutput;
|
|
14
14
|
logs: LogEntry[];
|
|
15
15
|
}>;
|
|
16
|
-
export declare function runAll(options: {
|
|
17
|
-
workflow: string;
|
|
18
|
-
only?: string[];
|
|
19
|
-
ctx?: Partial<RunnerContext>;
|
|
20
|
-
resume?: boolean;
|
|
21
|
-
runId?: string;
|
|
22
|
-
backend: Backend;
|
|
23
|
-
input?: unknown;
|
|
24
|
-
}): Promise<Record<string, StepOutput>>;
|
|
25
16
|
export { discoverWorkflows, discoverSteps } from "./discovery";
|
|
26
17
|
export { calculateWorkflowHash, getGitInfo } from "./versioning";
|
|
18
|
+
export { getAllDependents, validateWorkflowVersion } from "./validation";
|
|
27
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAEzE,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1C,YAAY,EAAE,UAAU,EAAE,CAAC;AAE3B;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACrC,GAAG,EAAE,aAAa,EAClB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,OAAO,EAChB,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC/C,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,GACjC,OAAO,CAAC;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,QAAQ,EAAE,CAAA;CAAE,CAAC,CAoBnD;AAGD,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG/D,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAGjE,OAAO,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC"}
|