@smithers-orchestrator/driver 0.16.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 (45) hide show
  1. package/LICENSE +21 -0
  2. package/package.json +80 -0
  3. package/src/ContinueAsNewHandler.ts +7 -0
  4. package/src/CreateWorkflowSession.ts +5 -0
  5. package/src/CreateWorkflowSessionOptions.ts +9 -0
  6. package/src/OutputAccessor.ts +20 -0
  7. package/src/OutputKey.ts +1 -0
  8. package/src/OutputSnapshot.ts +3 -0
  9. package/src/RunAuthContext.ts +6 -0
  10. package/src/RunOptions.ts +42 -0
  11. package/src/RunResult.ts +9 -0
  12. package/src/RunStatus.ts +9 -0
  13. package/src/SafeParser.ts +5 -0
  14. package/src/SchedulerWaitHandler.ts +6 -0
  15. package/src/SmithersCtx.js +195 -0
  16. package/src/SmithersCtxOptions.ts +14 -0
  17. package/src/SmithersRuntimeConfig.ts +3 -0
  18. package/src/SmithersTaskRuntime.ts +22 -0
  19. package/src/SpawnCaptureOptions.ts +12 -0
  20. package/src/SpawnCaptureResult.ts +5 -0
  21. package/src/TaskCompletedEvent.ts +5 -0
  22. package/src/TaskExecutor.ts +7 -0
  23. package/src/TaskExecutorContext.ts +7 -0
  24. package/src/TaskFailedEvent.ts +5 -0
  25. package/src/WaitHandler.ts +8 -0
  26. package/src/WorkflowDefinition.ts +16 -0
  27. package/src/WorkflowDriver.js +519 -0
  28. package/src/WorkflowDriverOptions.ts +27 -0
  29. package/src/WorkflowElement.ts +5 -0
  30. package/src/WorkflowGraphRenderer.ts +9 -0
  31. package/src/WorkflowRuntime.ts +3 -0
  32. package/src/WorkflowSession.ts +11 -0
  33. package/src/buildCurrentScopes.js +34 -0
  34. package/src/child-process.js +222 -0
  35. package/src/defaultTaskExecutor.js +28 -0
  36. package/src/filterRowsByNodeId.js +19 -0
  37. package/src/ignoreSyncError.js +16 -0
  38. package/src/index.d.ts +411 -0
  39. package/src/index.js +31 -0
  40. package/src/interop.js +1 -0
  41. package/src/normalizeInputRow.js +27 -0
  42. package/src/task-runtime.js +30 -0
  43. package/src/withAbort.js +43 -0
  44. package/src/withLogicalIterationShortcuts.js +46 -0
  45. package/src/workflow-types.ts +20 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 William Cory
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@smithers-orchestrator/driver",
3
+ "version": "0.16.0",
4
+ "description": "Workflow execution driver — runs tasks, acts on EngineDecisions, reports results",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "exports": {
8
+ ".": {
9
+ "types": "./src/index.d.ts",
10
+ "import": "./src/index.js",
11
+ "default": "./src/index.js"
12
+ },
13
+ "./interop": {
14
+ "types": "./src/index.d.ts",
15
+ "import": "./src/interop.js",
16
+ "default": "./src/interop.js"
17
+ },
18
+ "./RunOptions": {
19
+ "types": "./src/index.d.ts"
20
+ },
21
+ "./RunResult": {
22
+ "types": "./src/index.d.ts"
23
+ },
24
+ "./RunStatus": {
25
+ "types": "./src/index.d.ts"
26
+ },
27
+ "./RunAuthContext": {
28
+ "types": "./src/index.d.ts"
29
+ },
30
+ "./SmithersCtx": {
31
+ "types": "./src/index.d.ts",
32
+ "import": "./src/SmithersCtx.js",
33
+ "default": "./src/SmithersCtx.js"
34
+ },
35
+ "./OutputAccessor": {
36
+ "types": "./src/index.d.ts"
37
+ },
38
+ "./OutputKey": {
39
+ "types": "./src/index.d.ts"
40
+ },
41
+ "./workflow-types": {
42
+ "types": "./src/index.d.ts"
43
+ },
44
+ "./task-runtime": {
45
+ "types": "./src/index.d.ts",
46
+ "import": "./src/task-runtime.js",
47
+ "default": "./src/task-runtime.js"
48
+ },
49
+ "./child-process": {
50
+ "types": "./src/index.d.ts",
51
+ "import": "./src/child-process.js",
52
+ "default": "./src/child-process.js"
53
+ },
54
+ "./*": {
55
+ "types": "./src/index.d.ts",
56
+ "import": "./src/*.js",
57
+ "default": "./src/*.js"
58
+ }
59
+ },
60
+ "files": [
61
+ "src/"
62
+ ],
63
+ "dependencies": {
64
+ "effect": "^3.21.0",
65
+ "zod": "^4.3.6",
66
+ "@smithers-orchestrator/db": "0.16.0",
67
+ "@smithers-orchestrator/graph": "0.16.0",
68
+ "@smithers-orchestrator/errors": "0.16.0",
69
+ "@smithers-orchestrator/scheduler": "0.16.0",
70
+ "@smithers-orchestrator/observability": "0.16.0"
71
+ },
72
+ "devDependencies": {
73
+ "@types/bun": "latest",
74
+ "typescript": "~5.9.3"
75
+ },
76
+ "scripts": {
77
+ "typecheck": "tsc -p tsconfig.json --noEmit",
78
+ "build": "tsup --dts-only"
79
+ }
80
+ }
@@ -0,0 +1,7 @@
1
+ import type { RunOptions } from "./RunOptions.ts";
2
+ import type { RunResult } from "./RunResult.ts";
3
+
4
+ export type ContinueAsNewHandler = (
5
+ transition: unknown,
6
+ context: { runId: string; options: RunOptions },
7
+ ) => Promise<RunResult> | RunResult;
@@ -0,0 +1,5 @@
1
+ import type { CreateWorkflowSessionOptions } from "./CreateWorkflowSessionOptions.ts";
2
+
3
+ export type CreateWorkflowSession = (
4
+ opts: CreateWorkflowSessionOptions,
5
+ ) => unknown;
@@ -0,0 +1,9 @@
1
+ import type { RunOptions } from "./RunOptions.ts";
2
+
3
+ export type CreateWorkflowSessionOptions = {
4
+ db?: unknown;
5
+ runId: string;
6
+ rootDir?: string;
7
+ workflowPath?: string | null;
8
+ options: RunOptions;
9
+ };
@@ -0,0 +1,20 @@
1
+ import type { z } from "zod";
2
+
3
+ export type InferRow<TTable> = TTable extends { $inferSelect: infer R } ? R : never;
4
+
5
+ export type InferOutputEntry<T> = T extends z.ZodTypeAny
6
+ ? z.infer<T>
7
+ : T extends { $inferSelect: unknown }
8
+ ? InferRow<T>
9
+ : never;
10
+
11
+ type FallbackTableName<Schema> = [keyof Schema & string] extends [never]
12
+ ? string
13
+ : never;
14
+
15
+ export type OutputAccessor<Schema, TRow = unknown> = {
16
+ (table: FallbackTableName<Schema>): Array<TRow>;
17
+ <K extends keyof Schema & string>(table: K): Array<InferOutputEntry<Schema[K]>>;
18
+ } & {
19
+ [K in keyof Schema & string]: Array<InferOutputEntry<Schema[K]>>;
20
+ };
@@ -0,0 +1 @@
1
+ export type OutputKey = { nodeId: string; iteration?: number };
@@ -0,0 +1,3 @@
1
+ export type OutputSnapshot<TFallback = unknown> = {
2
+ [tableName: string]: Array<TFallback>;
3
+ };
@@ -0,0 +1,6 @@
1
+ export type RunAuthContext = {
2
+ triggeredBy: string;
3
+ scopes: string[];
4
+ role: string;
5
+ createdAt: string;
6
+ };
@@ -0,0 +1,42 @@
1
+ import type { RunAuthContext } from "./RunAuthContext.ts";
2
+ import type { SmithersEvent } from "@smithers-orchestrator/observability/SmithersEvent";
3
+
4
+ export type HotReloadOptions = {
5
+ /** Root directory to watch for changes (default: auto-detect from workflow entry) */
6
+ rootDir?: string;
7
+ /** Directory for generation overlays (default: .smithers/hmr/<runId>) */
8
+ outDir?: string;
9
+ /** Max overlay generations to keep (default: 3) */
10
+ maxGenerations?: number;
11
+ /** Whether to cancel tasks that become unmounted after hot reload (default: false) */
12
+ cancelUnmounted?: boolean;
13
+ /** Debounce interval in ms for file change events (default: 100) */
14
+ debounceMs?: number;
15
+ };
16
+
17
+ export type RunOptions = {
18
+ runId?: string;
19
+ parentRunId?: string | null;
20
+ input: Record<string, unknown>;
21
+ maxConcurrency?: number;
22
+ onProgress?: (e: SmithersEvent) => void;
23
+ signal?: AbortSignal;
24
+ resume?: boolean;
25
+ force?: boolean;
26
+ workflowPath?: string;
27
+ rootDir?: string;
28
+ logDir?: string | null;
29
+ allowNetwork?: boolean;
30
+ maxOutputBytes?: number;
31
+ toolTimeoutMs?: number;
32
+ hot?: boolean | HotReloadOptions;
33
+ auth?: RunAuthContext | null;
34
+ config?: Record<string, unknown>;
35
+ cliAgentToolsDefault?: "all" | "explicit-only";
36
+ resumeClaim?: {
37
+ claimOwnerId: string;
38
+ claimHeartbeatAtMs: number;
39
+ restoreRuntimeOwnerId?: string | null;
40
+ restoreHeartbeatAtMs?: number | null;
41
+ };
42
+ };
@@ -0,0 +1,9 @@
1
+ import type { RunStatus } from "./RunStatus.ts";
2
+
3
+ export type RunResult = {
4
+ readonly runId: string;
5
+ readonly status: RunStatus;
6
+ readonly output?: unknown;
7
+ readonly error?: unknown;
8
+ readonly nextRunId?: string;
9
+ };
@@ -0,0 +1,9 @@
1
+ export type RunStatus =
2
+ | "running"
3
+ | "waiting-approval"
4
+ | "waiting-event"
5
+ | "waiting-timer"
6
+ | "finished"
7
+ | "continued"
8
+ | "failed"
9
+ | "cancelled";
@@ -0,0 +1,5 @@
1
+ export type SafeParser = {
2
+ safeParse(value: unknown):
3
+ | { success: true; data: unknown }
4
+ | { success: false; error?: unknown };
5
+ };
@@ -0,0 +1,6 @@
1
+ import type { TaskDescriptor } from "@smithers-orchestrator/graph/types";
2
+
3
+ export type SchedulerWaitHandler = (
4
+ durationMs: number,
5
+ context: { runId: string; tasks: readonly TaskDescriptor[] },
6
+ ) => Promise<void> | void;
@@ -0,0 +1,195 @@
1
+ import { SmithersError } from "@smithers-orchestrator/errors/SmithersError";
2
+ import { buildCurrentScopes } from "./buildCurrentScopes.js";
3
+ import { filterRowsByNodeId } from "./filterRowsByNodeId.js";
4
+ import { normalizeInputRow } from "./normalizeInputRow.js";
5
+ import { withLogicalIterationShortcuts } from "./withLogicalIterationShortcuts.js";
6
+ /** @typedef {import("./OutputKey.ts").OutputKey} OutputKey */
7
+ /** @typedef {import("./SafeParser.ts").SafeParser} SafeParser */
8
+ /** @typedef {import("./SmithersCtxOptions.ts").SmithersCtxOptions} SmithersCtxOptions */
9
+ /** @typedef {import("./RunAuthContext.ts").RunAuthContext} RunAuthContext */
10
+ /** @typedef {import("./SmithersRuntimeConfig.ts").SmithersRuntimeConfig} SmithersRuntimeConfig */
11
+ /** @typedef {unknown} TableRef */
12
+ /** @typedef {Record<string, unknown> & { iteration?: number; nodeId?: string }} OutputRow */
13
+ /**
14
+ * @template Schema
15
+ * @typedef {import("./OutputAccessor.ts").OutputAccessor<Schema>} OutputAccessor
16
+ */
17
+
18
+ /**
19
+ * @param {TableRef} table
20
+ * @returns {string | undefined}
21
+ */
22
+ function resolveDrizzleName(table) {
23
+ if (!table || typeof table !== "object")
24
+ return undefined;
25
+ const tableObj = /** @type {Record<string, unknown>} */ (table);
26
+ const tableMeta = tableObj._;
27
+ if (tableMeta &&
28
+ typeof tableMeta === "object" &&
29
+ typeof (/** @type {Record<string, unknown>} */ (tableMeta)).name === "string") {
30
+ return /** @type {string} */ ((/** @type {Record<string, unknown>} */ (tableMeta)).name);
31
+ }
32
+ if (typeof tableObj.name === "string")
33
+ return /** @type {string} */ (tableObj.name);
34
+ return undefined;
35
+ }
36
+
37
+ /**
38
+ * @template {unknown} [Schema=unknown]
39
+ */
40
+ export class SmithersCtx {
41
+ /** @type {string} */
42
+ runId;
43
+ /** @type {number} */
44
+ iteration;
45
+ /** @type {Record<string, number> | undefined} */
46
+ iterations;
47
+ /** @type {Schema extends { input: infer T } ? T : unknown} */
48
+ input;
49
+ /** @type {RunAuthContext | null} */
50
+ auth;
51
+ /** @type {SmithersRuntimeConfig | null | undefined} */
52
+ __smithersRuntime;
53
+ /** @type {OutputAccessor<Schema>} */
54
+ outputs;
55
+ /** @type {import("./OutputSnapshot.ts").OutputSnapshot} */
56
+ _outputs;
57
+ /** @type {Map<unknown, string> | undefined} */
58
+ _zodToKeyName;
59
+ /** @type {Set<string>} */
60
+ _currentScopes;
61
+ /**
62
+ * @param {SmithersCtxOptions} opts
63
+ */
64
+ constructor(opts) {
65
+ this.runId = opts.runId;
66
+ this.iteration = opts.iteration;
67
+ this.iterations = withLogicalIterationShortcuts(opts.iterations);
68
+ this.input = /** @type {Schema extends { input: infer T } ? T : unknown} */ (normalizeInputRow(opts.input));
69
+ this.auth = opts.auth ?? null;
70
+ this.__smithersRuntime = opts.runtimeConfig ?? null;
71
+ this._outputs = opts.outputs;
72
+ this._zodToKeyName = opts.zodToKeyName;
73
+ this._currentScopes = buildCurrentScopes(this.iterations);
74
+ /**
75
+ * @param {string} table
76
+ */
77
+ const outputsFn = (table) => opts.outputs[table] ?? [];
78
+ for (const [name, rows] of Object.entries(opts.outputs)) {
79
+ outputsFn[name] = rows;
80
+ }
81
+ this.outputs = /** @type {OutputAccessor<Schema>} */ (/** @type {unknown} */ (outputsFn));
82
+ }
83
+ /**
84
+ * @param {TableRef} table
85
+ * @param {OutputKey} key
86
+ * @returns {OutputRow}
87
+ */
88
+ output(table, key) {
89
+ const row = this.resolveRow(table, key);
90
+ if (!row) {
91
+ throw new SmithersError("MISSING_OUTPUT", `Missing output for nodeId=${key.nodeId} iteration=${key.iteration ?? 0}`, { nodeId: key.nodeId, iteration: key.iteration ?? 0 });
92
+ }
93
+ return row;
94
+ }
95
+ /**
96
+ * @param {TableRef} table
97
+ * @param {OutputKey} key
98
+ * @returns {OutputRow | undefined}
99
+ */
100
+ outputMaybe(table, key) {
101
+ return this.resolveRow(table, key);
102
+ }
103
+ /**
104
+ * @param {TableRef} table
105
+ * @param {string} nodeId
106
+ * @returns {OutputRow | undefined}
107
+ */
108
+ latest(table, nodeId) {
109
+ const tableName = this.resolveTableName(table);
110
+ const rows = this._outputs[tableName] ?? [];
111
+ const matching = filterRowsByNodeId(rows, nodeId, this._currentScopes);
112
+ /** @type {OutputRow | undefined} */
113
+ let best = undefined;
114
+ let bestIteration = -Infinity;
115
+ for (const row of matching) {
116
+ const iter = Number.isFinite(Number(row.iteration))
117
+ ? Number(row.iteration)
118
+ : 0;
119
+ if (!best || iter >= bestIteration) {
120
+ best = row;
121
+ bestIteration = iter;
122
+ }
123
+ }
124
+ return best;
125
+ }
126
+ /**
127
+ * @param {unknown} value
128
+ * @param {SafeParser} schema
129
+ * @returns {unknown[]}
130
+ */
131
+ latestArray(value, schema) {
132
+ if (value == null)
133
+ return [];
134
+ let arr;
135
+ if (typeof value === "string") {
136
+ try {
137
+ const parsed = JSON.parse(value);
138
+ arr = Array.isArray(parsed) ? parsed : [parsed];
139
+ }
140
+ catch {
141
+ return [];
142
+ }
143
+ }
144
+ else {
145
+ arr = Array.isArray(value) ? value : [value];
146
+ }
147
+ return arr.flatMap((item) => {
148
+ const parsed = schema.safeParse(item);
149
+ return parsed.success ? [parsed.data] : [];
150
+ });
151
+ }
152
+ /**
153
+ * @param {TableRef} table
154
+ * @param {string} nodeId
155
+ * @returns {number}
156
+ */
157
+ iterationCount(table, nodeId) {
158
+ const tableName = this.resolveTableName(table);
159
+ const rows = this._outputs[tableName] ?? [];
160
+ const matching = filterRowsByNodeId(rows, nodeId, this._currentScopes);
161
+ const seen = new Set();
162
+ for (const row of matching) {
163
+ const iter = Number.isFinite(Number(row.iteration))
164
+ ? Number(row.iteration)
165
+ : 0;
166
+ seen.add(iter);
167
+ }
168
+ return seen.size;
169
+ }
170
+ /**
171
+ * @param {TableRef} table
172
+ * @returns {string}
173
+ */
174
+ resolveTableName(table) {
175
+ if (typeof table === "string")
176
+ return table;
177
+ const zodKey = this._zodToKeyName?.get(table);
178
+ if (zodKey)
179
+ return zodKey;
180
+ return resolveDrizzleName(table) ?? String(table);
181
+ }
182
+ /**
183
+ * @param {TableRef} table
184
+ * @param {OutputKey} key
185
+ * @returns {OutputRow | undefined}
186
+ */
187
+ resolveRow(table, key) {
188
+ const tableName = this.resolveTableName(table);
189
+ const rows = this._outputs[tableName] ?? [];
190
+ const matching = filterRowsByNodeId(rows, key.nodeId, this._currentScopes);
191
+ return matching.find((row) => {
192
+ return (row.iteration ?? 0) === (key.iteration ?? this.iteration);
193
+ });
194
+ }
195
+ }
@@ -0,0 +1,14 @@
1
+ import type { OutputSnapshot } from "./OutputSnapshot.ts";
2
+ import type { RunAuthContext } from "./RunAuthContext.ts";
3
+ import type { SmithersRuntimeConfig } from "./SmithersRuntimeConfig.ts";
4
+
5
+ export type SmithersCtxOptions = {
6
+ runId: string;
7
+ iteration: number;
8
+ iterations?: Record<string, number>;
9
+ input: unknown;
10
+ auth?: RunAuthContext | null;
11
+ outputs: OutputSnapshot;
12
+ zodToKeyName?: Map<any, string>;
13
+ runtimeConfig?: SmithersRuntimeConfig;
14
+ };
@@ -0,0 +1,3 @@
1
+ export type SmithersRuntimeConfig = {
2
+ cliAgentToolsDefault?: "all" | "explicit-only";
3
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Structural stand-in for the full `SmithersDb` class exported from
3
+ * `@smithers-orchestrator/db/adapter`. The generated `@smithers-orchestrator/db` index.d.ts does not
4
+ * expose `SmithersDb` as a named export (it emits `SmithersDb$1` plus a
5
+ * non-exported alias), and the package's wildcard subpath mapping sends every
6
+ * `@smithers-orchestrator/db/<sub>` type lookup back to that same bundle. Until the db
7
+ * package fixes its public type surface, we keep the runtime `db` handle typed
8
+ * as a branded record so consumers cannot treat it as arbitrary `any` while
9
+ * still allowing a real `SmithersDb` instance to flow through.
10
+ */
11
+ type SmithersDb = Record<string, unknown> & { readonly __smithersDbBrand?: never };
12
+
13
+ export type SmithersTaskRuntime = {
14
+ runId: string;
15
+ stepId: string;
16
+ attempt: number;
17
+ iteration: number;
18
+ signal: AbortSignal;
19
+ db: SmithersDb;
20
+ heartbeat: (data?: unknown) => void;
21
+ lastHeartbeat: unknown | null;
22
+ };
@@ -0,0 +1,12 @@
1
+ export type SpawnCaptureOptions = {
2
+ cwd: string;
3
+ env?: Record<string, string | undefined>;
4
+ input?: string;
5
+ signal?: AbortSignal;
6
+ timeoutMs?: number;
7
+ idleTimeoutMs?: number;
8
+ maxOutputBytes?: number;
9
+ detached?: boolean;
10
+ onStdout?: (chunk: string) => void;
11
+ onStderr?: (chunk: string) => void;
12
+ };
@@ -0,0 +1,5 @@
1
+ export type SpawnCaptureResult = {
2
+ stdout: string;
3
+ stderr: string;
4
+ exitCode: number | null;
5
+ };
@@ -0,0 +1,5 @@
1
+ export type TaskCompletedEvent = {
2
+ nodeId: string;
3
+ iteration: number;
4
+ output: unknown;
5
+ };
@@ -0,0 +1,7 @@
1
+ import type { TaskDescriptor } from "@smithers-orchestrator/graph/types";
2
+ import type { TaskExecutorContext } from "./TaskExecutorContext.ts";
3
+
4
+ export type TaskExecutor = (
5
+ task: TaskDescriptor,
6
+ context: TaskExecutorContext,
7
+ ) => Promise<unknown> | unknown;
@@ -0,0 +1,7 @@
1
+ import type { RunOptions } from "./RunOptions.ts";
2
+
3
+ export type TaskExecutorContext = {
4
+ runId: string;
5
+ options: RunOptions;
6
+ signal?: AbortSignal;
7
+ };
@@ -0,0 +1,5 @@
1
+ export type TaskFailedEvent = {
2
+ nodeId: string;
3
+ iteration: number;
4
+ error: unknown;
5
+ };
@@ -0,0 +1,8 @@
1
+ import type { RunOptions } from "./RunOptions.ts";
2
+ import type { RunResult } from "./RunResult.ts";
3
+ import type { EngineDecision, WaitReason } from "@smithers-orchestrator/scheduler";
4
+
5
+ export type WaitHandler = (
6
+ reason: WaitReason,
7
+ context: { runId: string; options: RunOptions },
8
+ ) => Promise<EngineDecision | RunResult> | EngineDecision | RunResult;
@@ -0,0 +1,16 @@
1
+ import type { SmithersWorkflowOptions } from "@smithers-orchestrator/scheduler/SmithersWorkflowOptions";
2
+ import type { SchemaRegistryEntry } from "@smithers-orchestrator/db/SchemaRegistryEntry";
3
+ import type { z } from "zod";
4
+ import type { WorkflowElement } from "./WorkflowElement.ts";
5
+
6
+ type WorkflowSmithersCtx<Schema = unknown> = import("./SmithersCtx.js").SmithersCtx<Schema>;
7
+
8
+ export type WorkflowDefinition<Schema = unknown> = {
9
+ readableName?: string;
10
+ description?: string;
11
+ db?: unknown;
12
+ build: (ctx: WorkflowSmithersCtx<Schema>) => WorkflowElement;
13
+ opts: SmithersWorkflowOptions;
14
+ schemaRegistry?: Map<string, SchemaRegistryEntry>;
15
+ zodToKeyName?: Map<z.ZodObject<z.ZodRawShape>, string>;
16
+ };