@cascade-flow/runner 0.1.0 → 0.2.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.
@@ -1,5 +1,5 @@
1
1
  import type { LogEntry } from "@cascade-flow/backend-interface";
2
- import type { StepOutput, RunnerContext } from "./types.ts";
2
+ import type { StepOutput, RunnerContext } from "@cascade-flow/workflow";
3
3
  type SubprocessOptions = {
4
4
  signal?: AbortSignal;
5
5
  };
@@ -1 +1 @@
1
- {"version":3,"file":"subprocess-executor.d.ts","sourceRoot":"","sources":["../src/subprocess-executor.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAc5D,KAAK,iBAAiB,GAAG;IACvB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAiDF;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,uBAAuB,CAC3C,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,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC/C,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,QAAQ,EAAE,CAAA;CAAE,CAAC,CA4JnD"}
1
+ {"version":3,"file":"subprocess-executor.d.ts","sourceRoot":"","sources":["../src/subprocess-executor.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAcxE,KAAK,iBAAiB,GAAG;IACvB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB,CAAC;AAkDF;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,uBAAuB,CAC3C,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,UAAU,EAAE,MAAM,EAClB,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,QAAQ,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,EAC/C,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,QAAQ,EAAE,CAAA;CAAE,CAAC,CA8JnD"}
package/dist/types.d.ts CHANGED
@@ -2,42 +2,7 @@
2
2
  * Shared types for the workflow runner
3
3
  */
4
4
  import { z } from "zod";
5
- /**
6
- * JSON primitive types
7
- */
8
- export type JSONPrimitive = string | number | boolean | null;
9
- /**
10
- * JSON array - an array of JSON values
11
- */
12
- export interface JSONArray extends Array<JSONValue> {
13
- }
14
- /**
15
- * JSON object - an object with string keys and JSON values
16
- */
17
- export interface JSONObject {
18
- [key: string]: JSONValue;
19
- }
20
- /**
21
- * JSON value - any valid JSON type
22
- */
23
- export type JSONValue = JSONPrimitive | JSONArray | JSONObject;
24
- /**
25
- * Step output must be JSON-serializable
26
- */
27
- export type StepOutput = JSONValue;
28
- /**
29
- * Base step definition with common properties
30
- * Generic over dependencies type and function signature
31
- */
32
- export type BaseStepDefinition<TDeps = any, TFn = any> = {
33
- name?: string;
34
- dependencies?: TDeps;
35
- exportOutput?: boolean;
36
- maxRetries?: number;
37
- retryDelayMs?: number;
38
- timeoutMs?: number;
39
- fn: TFn;
40
- };
5
+ import type { StepOutput, BaseStepDefinition, RunnerContext } from "@cascade-flow/workflow";
41
6
  export type StepModuleExport = {
42
7
  step: BaseStepDefinition<Record<string, any>, // other steps' `step` objects
43
8
  (args: {
@@ -47,8 +12,10 @@ export type StepModuleExport = {
47
12
  };
48
13
  /**
49
14
  * Loaded step representation after discovery
50
- * - id: The step's unique identifier (always the directory name)
51
- * - name: The step's display name (from step.name or falls back to directory name)
15
+ * - id: The step's unique identifier (relative path from steps directory)
16
+ * For flat steps: just the directory name (e.g., "fetch-users")
17
+ * For nested steps: full relative path (e.g., "data-processing/extract/fetch-users")
18
+ * - name: The step's display name (from step.name or falls back to last segment of path)
52
19
  * - dir: Absolute path to the step directory
53
20
  */
54
21
  export type LoadedStep = {
@@ -96,32 +63,4 @@ export type LocalWorkflowMetadata = {
96
63
  stepsDir: string;
97
64
  inputSchema?: z.ZodSchema<any>;
98
65
  };
99
- export type RunnerContext = {
100
- runId: string;
101
- workflow: {
102
- slug: string;
103
- name: string;
104
- };
105
- input?: unknown;
106
- log: (...args: any[]) => void;
107
- };
108
- export type InferStepOutput<T> = T extends {
109
- fn: (...args: any[]) => infer R;
110
- } ? Awaited<R> : never;
111
- /**
112
- * Unwrap an OptionalDependency to get the underlying step type
113
- * @internal
114
- */
115
- export type UnwrapOptional<T> = T extends import("@cascade-flow/workflow").OptionalDependency<infer U extends {
116
- fn: (...args: any[]) => any;
117
- }> ? U : T;
118
- /**
119
- * Infer the output type of a dependency, making it optional if wrapped with optional()
120
- * - Regular dependency: returns the step's output type
121
- * - Optional dependency: returns the step's output type | undefined
122
- *
123
- * Uses branded type check (__optional property) for unambiguous type narrowing
124
- * @internal
125
- */
126
- export type InferDependencyOutput<T> = '__optional' extends keyof T ? InferStepOutput<UnwrapOptional<T>> | undefined : InferStepOutput<T>;
127
66
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KA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M,EAAE,UAAU,CAAC,CAAC;CAC1C,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oBAAoB;;iBAE/B,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,gBAAgB;;;;;;;;kBAUlB,CAAC;AAEZ;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;CAChC,CAAC"}
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Workflow versioning utilities
3
+ *
4
+ * Provides functions to calculate workflow content hashes and collect git metadata
5
+ * for tracking workflow versions over time.
6
+ */
7
+ import type { LocalWorkflowMetadata } from "./types.js";
8
+ import type { WorkflowVersionGitInfo } from "@cascade-flow/backend-interface";
9
+ /**
10
+ * Calculate a deterministic hash of workflow content
11
+ *
12
+ * Hashes all step files, workflow.json, and input-schema.ts (if exists)
13
+ * to create a unique identifier for this version of the workflow.
14
+ *
15
+ * @param workflow - Workflow metadata including directory path
16
+ * @returns SHA-256 hash prefixed with "sha256:"
17
+ */
18
+ export declare function calculateWorkflowHash(workflow: LocalWorkflowMetadata): Promise<string>;
19
+ /**
20
+ * Get git information for the current repository
21
+ *
22
+ * Returns commit hash, branch name, and dirty status.
23
+ * Returns undefined if not in a git repository or if git is not available.
24
+ *
25
+ * @param workflowDir - Workflow directory (used to find git root)
26
+ * @returns Git info or undefined
27
+ */
28
+ export declare function getGitInfo(workflowDir: string): Promise<WorkflowVersionGitInfo | undefined>;
29
+ //# sourceMappingURL=versioning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versioning.d.ts","sourceRoot":"","sources":["../src/versioning.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAKH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAM9E;;;;;;;;GAQG;AACH,wBAAsB,qBAAqB,CACzC,QAAQ,EAAE,qBAAqB,GAC9B,OAAO,CAAC,MAAM,CAAC,CA+CjB;AAmCD;;;;;;;;GAQG;AACH,wBAAsB,UAAU,CAC9B,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,sBAAsB,GAAG,SAAS,CAAC,CA6B7C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cascade-flow/runner",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -22,9 +22,9 @@
22
22
  "test:coverage": "bun test --coverage"
23
23
  },
24
24
  "dependencies": {
25
- "@cascade-flow/backend-filesystem": "0.1.0",
26
- "@cascade-flow/backend-interface": "0.1.0",
27
- "@cascade-flow/workflow": "0.1.0",
25
+ "@cascade-flow/backend-filesystem": "0.2.1",
26
+ "@cascade-flow/backend-interface": "0.2.0",
27
+ "@cascade-flow/workflow": "0.2.0",
28
28
  "zod": "^4.1.12"
29
29
  },
30
30
  "devDependencies": {