@smithers-orchestrator/engine 0.18.0 → 0.20.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.
- package/package.json +15 -15
- package/src/effect/builder.js +300 -34
- package/src/index.d.ts +91 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithers-orchestrator/engine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": "Concrete Smithers workflow execution engine",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -33,20 +33,20 @@
|
|
|
33
33
|
"react": "^19.2.5",
|
|
34
34
|
"react-dom": "^19.2.5",
|
|
35
35
|
"zod": "^4.3.6",
|
|
36
|
-
"@smithers-orchestrator/agents": "0.
|
|
37
|
-
"@smithers-orchestrator/
|
|
38
|
-
"@smithers-orchestrator/
|
|
39
|
-
"@smithers-orchestrator/
|
|
40
|
-
"@smithers-orchestrator/graph": "0.
|
|
41
|
-
"@smithers-orchestrator/memory": "0.
|
|
42
|
-
"@smithers-orchestrator/
|
|
43
|
-
"@smithers-orchestrator/
|
|
44
|
-
"@smithers-orchestrator/
|
|
45
|
-
"@smithers-orchestrator/
|
|
46
|
-
"@smithers-orchestrator/
|
|
47
|
-
"@smithers-orchestrator/
|
|
48
|
-
"@smithers-orchestrator/
|
|
49
|
-
"@smithers-orchestrator/
|
|
36
|
+
"@smithers-orchestrator/agents": "0.20.0",
|
|
37
|
+
"@smithers-orchestrator/driver": "0.20.0",
|
|
38
|
+
"@smithers-orchestrator/components": "0.20.0",
|
|
39
|
+
"@smithers-orchestrator/db": "0.20.0",
|
|
40
|
+
"@smithers-orchestrator/graph": "0.20.0",
|
|
41
|
+
"@smithers-orchestrator/memory": "0.20.0",
|
|
42
|
+
"@smithers-orchestrator/errors": "0.20.0",
|
|
43
|
+
"@smithers-orchestrator/observability": "0.20.0",
|
|
44
|
+
"@smithers-orchestrator/react-reconciler": "0.20.0",
|
|
45
|
+
"@smithers-orchestrator/sandbox": "0.20.0",
|
|
46
|
+
"@smithers-orchestrator/scheduler": "0.20.0",
|
|
47
|
+
"@smithers-orchestrator/scorers": "0.20.0",
|
|
48
|
+
"@smithers-orchestrator/vcs": "0.20.0",
|
|
49
|
+
"@smithers-orchestrator/time-travel": "0.20.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/bun": "latest",
|
package/src/effect/builder.js
CHANGED
|
@@ -14,6 +14,9 @@ import { SmithersError } from "@smithers-orchestrator/errors/SmithersError";
|
|
|
14
14
|
/**
|
|
15
15
|
* @typedef {import("effect").Schema.Schema<unknown, unknown, never>} AnySchema
|
|
16
16
|
*/
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {unknown | Promise<unknown> | import("effect").Effect.Effect<unknown, unknown, unknown>} AnyEffect
|
|
19
|
+
*/
|
|
17
20
|
/**
|
|
18
21
|
* @typedef {{ needs?: Record<string, BuilderStepHandle>; request: (ctx: Record<string, unknown>) => { title: string; summary?: string | null; }; onDeny?: "fail" | "continue" | "skip"; }} ApprovalOptions
|
|
19
22
|
*/
|
|
@@ -24,6 +27,41 @@ import { SmithersError } from "@smithers-orchestrator/errors/SmithersError";
|
|
|
24
27
|
/** @typedef {import("./BuilderStepHandle.ts").BuilderStepHandle} BuilderStepHandle */
|
|
25
28
|
/** @typedef {import("@smithers-orchestrator/scheduler/RetryPolicy").RetryPolicy} RetryPolicy */
|
|
26
29
|
/** @typedef {import("./SmithersSqliteOptions.ts").SmithersSqliteOptions} SmithersSqliteOptions */
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {{
|
|
32
|
+
* output: AnySchema;
|
|
33
|
+
* needs?: Record<string, BuilderStepHandle>;
|
|
34
|
+
* run?: (ctx: BuilderStepContext) => AnyEffect;
|
|
35
|
+
* retry?: unknown;
|
|
36
|
+
* retryPolicy?: RetryPolicy;
|
|
37
|
+
* timeout?: unknown;
|
|
38
|
+
* skipIf?: (ctx: BuilderStepContext) => boolean;
|
|
39
|
+
* cache?: import("@smithers-orchestrator/scheduler/CachePolicy").CachePolicy;
|
|
40
|
+
* }} StepOptions
|
|
41
|
+
*/
|
|
42
|
+
/**
|
|
43
|
+
* @typedef {{
|
|
44
|
+
* step: (id: string, options: StepOptions) => BuilderStepHandle;
|
|
45
|
+
* approval: (id: string, options: ApprovalOptions) => BuilderStepHandle;
|
|
46
|
+
* sequence: (...nodes: BuilderNode[]) => BuilderNode;
|
|
47
|
+
* parallel: (...nodesOrOptions: [...BuilderNode[], { maxConcurrency?: number }] | BuilderNode[]) => BuilderNode;
|
|
48
|
+
* loop: (options: { id?: string; children: BuilderNode; until: (outputs: Record<string, unknown>) => boolean; maxIterations?: number; onMaxReached?: "fail" | "return-last"; }) => BuilderNode;
|
|
49
|
+
* match: (source: BuilderStepHandle, options: { when: (value: unknown) => boolean; then: () => BuilderNode; else?: () => BuilderNode; }) => BuilderNode;
|
|
50
|
+
* component: (instanceId: string, definition: ComponentDefinition, params?: Record<string, unknown>) => BuilderNode;
|
|
51
|
+
* }} BuilderApi
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* @typedef {{ execute: (input: unknown, opts?: Omit<Parameters<typeof runWorkflow>[1], "input">) => import("effect").Effect.Effect<unknown, unknown, unknown> }} BuiltSmithersWorkflow
|
|
55
|
+
*/
|
|
56
|
+
/**
|
|
57
|
+
* @typedef {{ build: (buildGraph: ($: BuilderApi) => BuilderNode) => BuiltSmithersWorkflow }} WorkflowDefinitionBuilder
|
|
58
|
+
*/
|
|
59
|
+
/**
|
|
60
|
+
* @typedef {{ kind: "component-definition"; name: string; buildWithPrefix: (prefix: string, params?: Record<string, unknown>) => BuilderNode }} ComponentDefinition
|
|
61
|
+
*/
|
|
62
|
+
/**
|
|
63
|
+
* @typedef {{ build: (buildGraph: ($: BuilderApi, params?: Record<string, unknown>) => BuilderNode) => ComponentDefinition }} ComponentDefinitionBuilder
|
|
64
|
+
*/
|
|
27
65
|
|
|
28
66
|
const SmithersSqlite = Context.GenericTag("smithers/effect/sqlite");
|
|
29
67
|
class ApprovalDecision extends Schema.Class("ApprovalDecision")({
|
|
@@ -751,25 +789,262 @@ function normalizeExecutionError(result) {
|
|
|
751
789
|
}
|
|
752
790
|
return new SmithersError("WORKFLOW_EXECUTION_FAILED", `Workflow execution ended with status "${result.status}"`, { status: result.status });
|
|
753
791
|
}
|
|
792
|
+
/**
|
|
793
|
+
* @typedef {{ _tag: "WorkflowGraph"; expr: unknown; pipe: (...fns: Array<(g: any) => any>) => any }} WorkflowGraph
|
|
794
|
+
*/
|
|
795
|
+
|
|
796
|
+
/**
|
|
797
|
+
* @param {unknown} value
|
|
798
|
+
* @returns {value is WorkflowGraph}
|
|
799
|
+
*/
|
|
800
|
+
function isWorkflowGraph(value) {
|
|
801
|
+
return Boolean(value) && typeof value === "object" && /** @type {any} */ (value)._tag === "WorkflowGraph";
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* @param {unknown} expr
|
|
806
|
+
* @returns {WorkflowGraph}
|
|
807
|
+
*/
|
|
808
|
+
function makeGraph(expr) {
|
|
809
|
+
/** @type {WorkflowGraph} */
|
|
810
|
+
const graph = /** @type {any} */ ({ _tag: "WorkflowGraph", expr });
|
|
811
|
+
graph.pipe = function pipe(...fns) {
|
|
812
|
+
return fns.reduce((acc, fn) => fn(acc), graph);
|
|
813
|
+
};
|
|
814
|
+
return graph;
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* Build the graph constructors shared by Smithers.workflow and Smithers.fragment.
|
|
819
|
+
*/
|
|
820
|
+
function makeFactory() {
|
|
821
|
+
return {
|
|
822
|
+
/**
|
|
823
|
+
* @param {string} id
|
|
824
|
+
* @param {StepOptions} options
|
|
825
|
+
*/
|
|
826
|
+
step: (id, options) => makeGraph({ _tag: "Step", id, options }),
|
|
827
|
+
/**
|
|
828
|
+
* @param {string} id
|
|
829
|
+
* @param {ApprovalOptions} options
|
|
830
|
+
*/
|
|
831
|
+
approval: (id, options) => makeGraph({ _tag: "Approval", id, options }),
|
|
832
|
+
/**
|
|
833
|
+
* @param {WorkflowGraph[]} children
|
|
834
|
+
*/
|
|
835
|
+
sequence: (...children) => makeGraph({ _tag: "Sequence", children }),
|
|
836
|
+
parallel: (...args) => {
|
|
837
|
+
let maxConcurrency;
|
|
838
|
+
const items = [...args];
|
|
839
|
+
const last = items[items.length - 1];
|
|
840
|
+
if (last &&
|
|
841
|
+
typeof last === "object" &&
|
|
842
|
+
!Array.isArray(last) &&
|
|
843
|
+
!isWorkflowGraph(last) &&
|
|
844
|
+
"maxConcurrency" in last) {
|
|
845
|
+
maxConcurrency = Number(last.maxConcurrency);
|
|
846
|
+
items.pop();
|
|
847
|
+
}
|
|
848
|
+
return makeGraph({ _tag: "Parallel", children: items, maxConcurrency });
|
|
849
|
+
},
|
|
850
|
+
match: (source, options) => makeGraph({
|
|
851
|
+
_tag: "Match",
|
|
852
|
+
source,
|
|
853
|
+
when: options.when,
|
|
854
|
+
then: options.then,
|
|
855
|
+
else: options.else,
|
|
856
|
+
}),
|
|
857
|
+
branch: (options) => makeGraph({
|
|
858
|
+
_tag: "Branch",
|
|
859
|
+
condition: options.condition,
|
|
860
|
+
needs: options.needs,
|
|
861
|
+
then: options.then,
|
|
862
|
+
else: options.else,
|
|
863
|
+
}),
|
|
864
|
+
loop: (options) => makeGraph({
|
|
865
|
+
_tag: "Loop",
|
|
866
|
+
id: options.id,
|
|
867
|
+
child: options.children,
|
|
868
|
+
until: options.until,
|
|
869
|
+
maxIterations: options.maxIterations,
|
|
870
|
+
onMaxReached: options.onMaxReached,
|
|
871
|
+
}),
|
|
872
|
+
worktree: (options) => makeGraph({
|
|
873
|
+
_tag: "Worktree",
|
|
874
|
+
id: options.id,
|
|
875
|
+
path: options.path,
|
|
876
|
+
branch: options.branch,
|
|
877
|
+
skipIf: options.skipIf,
|
|
878
|
+
needs: options.needs,
|
|
879
|
+
child: options.children,
|
|
880
|
+
}),
|
|
881
|
+
scope: (instanceId, child) => makeGraph({
|
|
882
|
+
_tag: "Scope",
|
|
883
|
+
instanceId,
|
|
884
|
+
child,
|
|
885
|
+
}),
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
/**
|
|
890
|
+
* @param {string} prefix
|
|
891
|
+
* @param {string | undefined} id
|
|
892
|
+
*/
|
|
893
|
+
function applyPrefixId(prefix, id) {
|
|
894
|
+
if (!id) return id;
|
|
895
|
+
return prefix ? `${prefix}.${id}` : id;
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
/**
|
|
899
|
+
* @param {Record<string, WorkflowGraph> | undefined} needs
|
|
900
|
+
* @param {string} prefix
|
|
901
|
+
* @param {Map<string, Map<WorkflowGraph, BuilderNode>>} memo
|
|
902
|
+
*/
|
|
903
|
+
function compileNeeds(needs, prefix, memo) {
|
|
904
|
+
if (!needs) return undefined;
|
|
905
|
+
const out = {};
|
|
906
|
+
for (const [key, dep] of Object.entries(needs)) {
|
|
907
|
+
out[key] = compileGraph(dep, prefix, memo);
|
|
908
|
+
}
|
|
909
|
+
return out;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* Walk a graph expression tree and produce a BuilderNode tree at the active prefix.
|
|
914
|
+
* Memoizes per (prefix, graph) so a value referenced as both a child and a needs source
|
|
915
|
+
* compiles to a single handle, while reuse under different scopes produces distinct handles.
|
|
916
|
+
*
|
|
917
|
+
* @param {WorkflowGraph} graph
|
|
918
|
+
* @param {string} [prefix]
|
|
919
|
+
* @param {Map<string, Map<WorkflowGraph, BuilderNode>>} [memo]
|
|
920
|
+
* @returns {BuilderNode}
|
|
921
|
+
*/
|
|
922
|
+
function compileGraph(graph, prefix = "", memo = new Map()) {
|
|
923
|
+
let perPrefix = memo.get(prefix);
|
|
924
|
+
if (!perPrefix) {
|
|
925
|
+
perPrefix = new Map();
|
|
926
|
+
memo.set(prefix, perPrefix);
|
|
927
|
+
}
|
|
928
|
+
const cached = perPrefix.get(graph);
|
|
929
|
+
if (cached) return cached;
|
|
930
|
+
|
|
931
|
+
const builder = createBuilder(prefix);
|
|
932
|
+
const expr = /** @type {any} */ (graph.expr);
|
|
933
|
+
let node;
|
|
934
|
+
|
|
935
|
+
switch (expr._tag) {
|
|
936
|
+
case "Step": {
|
|
937
|
+
const compiledOptions = {
|
|
938
|
+
...expr.options,
|
|
939
|
+
needs: compileNeeds(expr.options.needs, prefix, memo) ?? {},
|
|
940
|
+
};
|
|
941
|
+
node = builder.step(expr.id, compiledOptions);
|
|
942
|
+
break;
|
|
943
|
+
}
|
|
944
|
+
case "Approval": {
|
|
945
|
+
const compiledOptions = {
|
|
946
|
+
...expr.options,
|
|
947
|
+
needs: compileNeeds(expr.options.needs, prefix, memo) ?? {},
|
|
948
|
+
};
|
|
949
|
+
node = builder.approval(expr.id, compiledOptions);
|
|
950
|
+
break;
|
|
951
|
+
}
|
|
952
|
+
case "Sequence": {
|
|
953
|
+
node = {
|
|
954
|
+
kind: "sequence",
|
|
955
|
+
children: expr.children.map((c) => compileGraph(c, prefix, memo)),
|
|
956
|
+
};
|
|
957
|
+
break;
|
|
958
|
+
}
|
|
959
|
+
case "Parallel": {
|
|
960
|
+
node = {
|
|
961
|
+
kind: "parallel",
|
|
962
|
+
children: expr.children.map((c) => compileGraph(c, prefix, memo)),
|
|
963
|
+
maxConcurrency: expr.maxConcurrency,
|
|
964
|
+
};
|
|
965
|
+
break;
|
|
966
|
+
}
|
|
967
|
+
case "Match": {
|
|
968
|
+
node = {
|
|
969
|
+
kind: "match",
|
|
970
|
+
source: compileGraph(expr.source, prefix, memo),
|
|
971
|
+
when: expr.when,
|
|
972
|
+
then: compileGraph(expr.then, prefix, memo),
|
|
973
|
+
else: expr.else ? compileGraph(expr.else, prefix, memo) : undefined,
|
|
974
|
+
};
|
|
975
|
+
break;
|
|
976
|
+
}
|
|
977
|
+
case "Branch": {
|
|
978
|
+
node = {
|
|
979
|
+
kind: "branch",
|
|
980
|
+
condition: expr.condition,
|
|
981
|
+
needs: compileNeeds(expr.needs, prefix, memo),
|
|
982
|
+
then: compileGraph(expr.then, prefix, memo),
|
|
983
|
+
else: expr.else ? compileGraph(expr.else, prefix, memo) : undefined,
|
|
984
|
+
};
|
|
985
|
+
break;
|
|
986
|
+
}
|
|
987
|
+
case "Loop": {
|
|
988
|
+
node = {
|
|
989
|
+
kind: "loop",
|
|
990
|
+
id: applyPrefixId(prefix, expr.id),
|
|
991
|
+
children: compileGraph(expr.child, prefix, memo),
|
|
992
|
+
until: expr.until,
|
|
993
|
+
maxIterations: expr.maxIterations,
|
|
994
|
+
onMaxReached: expr.onMaxReached,
|
|
995
|
+
};
|
|
996
|
+
break;
|
|
997
|
+
}
|
|
998
|
+
case "Worktree": {
|
|
999
|
+
node = {
|
|
1000
|
+
kind: "worktree",
|
|
1001
|
+
id: applyPrefixId(prefix, expr.id),
|
|
1002
|
+
path: expr.path,
|
|
1003
|
+
branch: expr.branch,
|
|
1004
|
+
skipIf: expr.skipIf,
|
|
1005
|
+
needs: compileNeeds(expr.needs, prefix, memo),
|
|
1006
|
+
children: compileGraph(expr.child, prefix, memo),
|
|
1007
|
+
};
|
|
1008
|
+
break;
|
|
1009
|
+
}
|
|
1010
|
+
case "Scope": {
|
|
1011
|
+
const nextPrefix = prefix ? `${prefix}.${expr.instanceId}` : expr.instanceId;
|
|
1012
|
+
node = compileGraph(expr.child, nextPrefix, memo);
|
|
1013
|
+
break;
|
|
1014
|
+
}
|
|
1015
|
+
default:
|
|
1016
|
+
throw new SmithersError("UNKNOWN_GRAPH_EXPR", `Unknown graph expression _tag: "${expr._tag}"`);
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
perPrefix.set(graph, node);
|
|
1020
|
+
return node;
|
|
1021
|
+
}
|
|
1022
|
+
|
|
754
1023
|
/**
|
|
755
1024
|
* @param {{ name: string; input: AnySchema }} options
|
|
756
1025
|
*/
|
|
757
|
-
function
|
|
1026
|
+
export function workflow(options) {
|
|
1027
|
+
const factory = makeFactory();
|
|
758
1028
|
return {
|
|
1029
|
+
...factory,
|
|
759
1030
|
/**
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
1031
|
+
* Finalize the workflow definition. Compiles the graph expression tree to a
|
|
1032
|
+
* BuilderNode tree, allocates step handles with active prefixes, and returns
|
|
1033
|
+
* a runnable workflow.
|
|
1034
|
+
*
|
|
1035
|
+
* @param {WorkflowGraph} graph
|
|
1036
|
+
*/
|
|
1037
|
+
from(graph) {
|
|
1038
|
+
const root = compileGraph(graph);
|
|
765
1039
|
annotateLoops(root);
|
|
766
1040
|
const handles = collectHandles(root);
|
|
767
1041
|
assertUniqueHandleIds(handles);
|
|
768
1042
|
return {
|
|
1043
|
+
node: root,
|
|
769
1044
|
/**
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
1045
|
+
* @param {unknown} input
|
|
1046
|
+
* @param {Omit<Parameters<typeof runWorkflow>[1], "input">} [opts]
|
|
1047
|
+
*/
|
|
773
1048
|
execute(input, opts) {
|
|
774
1049
|
return Effect.gen(function* () {
|
|
775
1050
|
const env = yield* Effect.context();
|
|
@@ -777,12 +1052,12 @@ function _createWorkflow(options) {
|
|
|
777
1052
|
const decodedInput = decodeSchema(options.input, input);
|
|
778
1053
|
const encodedInput = JSON.parse(JSON.stringify(encodeSchema(options.input, decodedInput) ?? {}));
|
|
779
1054
|
return yield* Effect.acquireUseRelease(Effect.sync(() => createBuilderDb(sqliteConfig.filename, handles)), (runtime) => Effect.promise(async () => {
|
|
780
|
-
const
|
|
1055
|
+
const wf = {
|
|
781
1056
|
db: runtime.db,
|
|
782
|
-
build: (ctx) => React.createElement(Workflow, { name: options.name }, renderNode(
|
|
1057
|
+
build: (ctx) => React.createElement(Workflow, { name: options.name }, renderNode(root, ctx, decodedInput, env)),
|
|
783
1058
|
opts: {},
|
|
784
1059
|
};
|
|
785
|
-
const result = await Effect.runPromise(runWorkflow(
|
|
1060
|
+
const result = await Effect.runPromise(runWorkflow(wf, {
|
|
786
1061
|
...opts,
|
|
787
1062
|
input: encodedInput,
|
|
788
1063
|
}));
|
|
@@ -801,37 +1076,28 @@ function _createWorkflow(options) {
|
|
|
801
1076
|
},
|
|
802
1077
|
};
|
|
803
1078
|
}
|
|
1079
|
+
|
|
804
1080
|
/**
|
|
805
|
-
*
|
|
1081
|
+
* Build a graph fragment whose steps live across workflows. Same constructors as
|
|
1082
|
+
* a workflow handle, minus `from` — fragments are values, not workflows. They compile
|
|
1083
|
+
* when mounted into a real workflow via `G.scope(instanceId, fragment)`.
|
|
1084
|
+
*
|
|
1085
|
+
* @param {AnySchema} _inputSchema
|
|
806
1086
|
*/
|
|
807
|
-
function
|
|
808
|
-
return
|
|
809
|
-
/**
|
|
810
|
-
* @param {($: BuilderApi, params: Record<string, unknown>) => BuilderNode} buildGraph
|
|
811
|
-
* @returns {ComponentDefinition}
|
|
812
|
-
*/
|
|
813
|
-
build(buildGraph) {
|
|
814
|
-
return {
|
|
815
|
-
kind: "component-definition",
|
|
816
|
-
name: options.name,
|
|
817
|
-
/**
|
|
818
|
-
* @param {string} prefix
|
|
819
|
-
* @param {Record<string, unknown>} params
|
|
820
|
-
*/
|
|
821
|
-
buildWithPrefix(prefix, params) {
|
|
822
|
-
return buildGraph(createBuilder(prefix), params);
|
|
823
|
-
},
|
|
824
|
-
};
|
|
825
|
-
},
|
|
826
|
-
};
|
|
1087
|
+
export function fragment(_inputSchema) {
|
|
1088
|
+
return makeFactory();
|
|
827
1089
|
}
|
|
1090
|
+
|
|
828
1091
|
/**
|
|
829
1092
|
* @param {SmithersSqliteOptions} options
|
|
830
1093
|
*/
|
|
831
1094
|
function sqlite(options) {
|
|
832
1095
|
return Layer.succeed(SmithersSqlite, options);
|
|
833
1096
|
}
|
|
834
|
-
|
|
1097
|
+
|
|
1098
|
+
/** @type {{ sqlite: typeof sqlite; workflow: typeof workflow; fragment: typeof fragment }} */
|
|
835
1099
|
export const Smithers = {
|
|
836
1100
|
sqlite,
|
|
1101
|
+
workflow,
|
|
1102
|
+
fragment,
|
|
837
1103
|
};
|
package/src/index.d.ts
CHANGED
|
@@ -1220,10 +1220,95 @@ type WorktreeNode = {
|
|
|
1220
1220
|
children: BuilderNode$1;
|
|
1221
1221
|
};
|
|
1222
1222
|
type BuilderNode$1 = BuilderStepHandle$1 | SequenceNode | ParallelNode | LoopNode | MatchNode | BranchNode | WorktreeNode;
|
|
1223
|
-
|
|
1224
|
-
|
|
1223
|
+
type StepOptions = {
|
|
1224
|
+
output: AnySchema$1;
|
|
1225
|
+
needs?: Record<string, BuilderStepHandle$1>;
|
|
1226
|
+
run?: (ctx: BuilderStepContext$1) => AnyEffect;
|
|
1227
|
+
retry?: unknown;
|
|
1228
|
+
retryPolicy?: RetryPolicy$1;
|
|
1229
|
+
timeout?: unknown;
|
|
1230
|
+
skipIf?: (ctx: BuilderStepContext$1) => boolean;
|
|
1231
|
+
cache?: CachePolicy;
|
|
1232
|
+
};
|
|
1233
|
+
type ComponentDefinition = {
|
|
1234
|
+
kind: "component-definition";
|
|
1235
|
+
name: string;
|
|
1236
|
+
buildWithPrefix: (prefix: string, params?: Record<string, unknown>) => BuilderNode$1;
|
|
1237
|
+
};
|
|
1238
|
+
type BuilderApi = {
|
|
1239
|
+
step: (id: string, options: StepOptions) => BuilderStepHandle$1;
|
|
1240
|
+
approval: (id: string, options: ApprovalOptions$1) => BuilderStepHandle$1;
|
|
1241
|
+
sequence: (...nodes: BuilderNode$1[]) => BuilderNode$1;
|
|
1242
|
+
parallel: (...nodesOrOptions: Array<BuilderNode$1 | {
|
|
1243
|
+
maxConcurrency?: number;
|
|
1244
|
+
}>) => BuilderNode$1;
|
|
1245
|
+
loop: (options: {
|
|
1246
|
+
id?: string;
|
|
1247
|
+
children: BuilderNode$1;
|
|
1248
|
+
until: (outputs: Record<string, unknown>) => boolean;
|
|
1249
|
+
maxIterations?: number;
|
|
1250
|
+
onMaxReached?: "fail" | "return-last";
|
|
1251
|
+
}) => BuilderNode$1;
|
|
1252
|
+
match: (source: BuilderStepHandle$1, options: {
|
|
1253
|
+
when: (value: unknown) => boolean;
|
|
1254
|
+
then: () => BuilderNode$1;
|
|
1255
|
+
else?: () => BuilderNode$1;
|
|
1256
|
+
}) => BuilderNode$1;
|
|
1257
|
+
component: (instanceId: string, definition: ComponentDefinition, params?: Record<string, unknown>) => BuilderNode$1;
|
|
1258
|
+
};
|
|
1259
|
+
type BuiltSmithersWorkflow = {
|
|
1260
|
+
execute: (input: unknown, opts?: Omit<Parameters<typeof runWorkflow>[1], "input">) => Effect.Effect<unknown, unknown, unknown>;
|
|
1261
|
+
};
|
|
1262
|
+
type WorkflowGraph<I = unknown, A = unknown> = {
|
|
1263
|
+
readonly _tag: "WorkflowGraph";
|
|
1264
|
+
readonly expr: unknown;
|
|
1265
|
+
pipe<B = A>(...fns: Array<(g: WorkflowGraph<I, any>) => WorkflowGraph<I, any>>): WorkflowGraph<I, B>;
|
|
1266
|
+
};
|
|
1267
|
+
type GraphFactory = {
|
|
1268
|
+
step: (id: string, options: StepOptions$1) => WorkflowGraph;
|
|
1269
|
+
approval: (id: string, options: ApprovalOptions$1) => WorkflowGraph;
|
|
1270
|
+
sequence: (...children: WorkflowGraph[]) => WorkflowGraph;
|
|
1271
|
+
parallel: (...nodesOrOptions: Array<WorkflowGraph | { maxConcurrency?: number }>) => WorkflowGraph;
|
|
1272
|
+
match: (source: WorkflowGraph, options: {
|
|
1273
|
+
when: (value: unknown) => boolean;
|
|
1274
|
+
then: WorkflowGraph;
|
|
1275
|
+
else?: WorkflowGraph;
|
|
1276
|
+
}) => WorkflowGraph;
|
|
1277
|
+
branch: (options: {
|
|
1278
|
+
condition: (ctx: Record<string, unknown>) => boolean;
|
|
1279
|
+
needs?: Record<string, WorkflowGraph>;
|
|
1280
|
+
then: WorkflowGraph;
|
|
1281
|
+
else?: WorkflowGraph;
|
|
1282
|
+
}) => WorkflowGraph;
|
|
1283
|
+
loop: (options: {
|
|
1284
|
+
id?: string;
|
|
1285
|
+
children: WorkflowGraph;
|
|
1286
|
+
until: (outputs: Record<string, unknown>) => boolean;
|
|
1287
|
+
maxIterations?: number;
|
|
1288
|
+
onMaxReached?: "fail" | "return-last";
|
|
1289
|
+
}) => WorkflowGraph;
|
|
1290
|
+
worktree: (options: {
|
|
1291
|
+
id?: string;
|
|
1292
|
+
path: string;
|
|
1293
|
+
branch?: string;
|
|
1294
|
+
skipIf?: (ctx: Record<string, unknown>) => boolean;
|
|
1295
|
+
needs?: Record<string, WorkflowGraph>;
|
|
1296
|
+
children: WorkflowGraph;
|
|
1297
|
+
}) => WorkflowGraph;
|
|
1298
|
+
scope: (instanceId: string, child: WorkflowGraph) => WorkflowGraph;
|
|
1299
|
+
};
|
|
1300
|
+
type WorkflowHandle = GraphFactory & {
|
|
1301
|
+
from(graph: WorkflowGraph): BuiltSmithersWorkflow & { node: BuilderNode$1 };
|
|
1302
|
+
};
|
|
1303
|
+
declare function workflow(options: {
|
|
1304
|
+
name: string;
|
|
1305
|
+
input: AnySchema$1;
|
|
1306
|
+
}): WorkflowHandle;
|
|
1307
|
+
declare function fragment(_inputSchema: AnySchema$1): GraphFactory;
|
|
1225
1308
|
declare const Smithers: {
|
|
1226
1309
|
sqlite: typeof sqlite;
|
|
1310
|
+
workflow: typeof workflow;
|
|
1311
|
+
fragment: typeof fragment;
|
|
1227
1312
|
};
|
|
1228
1313
|
type AnySchema = effect.Schema.Schema<unknown, unknown, never>;
|
|
1229
1314
|
type ApprovalOptions = {
|
|
@@ -1234,6 +1319,9 @@ type ApprovalOptions = {
|
|
|
1234
1319
|
};
|
|
1235
1320
|
onDeny?: "fail" | "continue" | "skip";
|
|
1236
1321
|
};
|
|
1322
|
+
type BuiltSmithersWorkflow$1 = BuiltSmithersWorkflow;
|
|
1323
|
+
type BuilderApi$1 = BuilderApi;
|
|
1324
|
+
type StepOptions$1 = StepOptions;
|
|
1237
1325
|
type BuilderNode = BuilderNode$1;
|
|
1238
1326
|
type BuilderStepContext = Record<string, unknown> & {
|
|
1239
1327
|
input: unknown;
|
|
@@ -1594,4 +1682,4 @@ type SmithersWorkflow = any;
|
|
|
1594
1682
|
|
|
1595
1683
|
type ChildWorkflowDefinition = ChildWorkflowDefinition$1;
|
|
1596
1684
|
|
|
1597
|
-
export { type AlertHumanRequestOptions, AlertRuntime, type AlertRuntimeServices, type AnySchema, type ApprovalOptions, type ApprovalPayload, ApprovalPayloadSchema, type ApprovalResult, ApprovalResultSchema, type BridgeManagedTaskKind, type BuilderNode, type BuilderStepContext, type BuilderStepHandle, type CancelPayload, CancelPayloadSchema, type CancelResult, CancelResultSchema, type ChildWorkflowDefinition, type ChildWorkflowExecuteOptions, CodeplaneSandboxExecutorLive, type ComputeTaskBridgeToolConfig, type ContinuationRequest, type CorrelatedSmithersEvent, type CorrelationContext, type DiffBundle, DockerSandboxExecutorLive, EventBus, type ExecuteTaskActivityOptions, type FilePatch, type GetRunPayload, GetRunPayloadSchema, type GetRunResult, GetRunResultSchema, HUMAN_REQUEST_KINDS, HUMAN_REQUEST_STATUSES, type HijackState, type HotReloadEvent, HotWorkflowController, type HumanRequestKind, type HumanRequestSchemaValidation, type HumanRequestStatus, type JsonSchema, type LegacyExecuteTaskFn, type ListRunsPayload, ListRunsPayloadSchema, type OverlayOptions, type PlanNode, type RalphMeta, type RalphState, type RalphStateMap, type ReadonlyTaskStateMap, RetriableTaskFailure, type RetryPolicy, type RetryWaitMap, type RunResult$2 as RunResult, RunStatusSchema, type RunSummary, RunSummarySchema, type SQLiteTable, SandboxHttpRunner, type ScheduleResult, type ScheduleSnapshot, type SignalPayload, SignalPayloadSchema, type SignalResult, SignalResultSchema, type SignalRunOptions, Smithers, type SmithersAlertPolicy, type SmithersEvent, SmithersRpcGroup, type SmithersSqliteOptions, SqlMessageStorage, type StaticTaskBridgeToolConfig, type TaskActivityContext, type TaskActivityRetryOptions, type TaskBridgeToolConfig, type TaskRecord, TaskResult, type TaskState, type TaskStateMap, TaskWorkerEntity, WatchTree, type WatchTreeOptions, WorkerDispatchKind, WorkerTask$1 as WorkerTask, WorkerTaskKind, type WorkflowPatchDecisionRecord, type WorkflowPatchDecisions, type WorkflowVersioningRuntime, type WorkflowVersioningRuntimeOptions, type XmlNode, type _TaskActivityContext, applyDiffBundle, approve, approveNode, awaitApprovalDurableDeferred, awaitWaitForEventDurableDeferred, bridgeApprovalResolve, bridgeSignalResolve, bridgeWaitForEventResolve, buildHumanRequestId, buildOverlay, buildPlanTree, canExecuteBridgeManagedComputeTask, canExecuteBridgeManagedStaticTask, cancel, cancelPendingTimersBridge, cleanupGenerations, computeDiffBundle, computeDiffBundleBetweenRefs, createSchedulerWakeQueue, createWorkflowVersioningRuntime, denyNode, dispatchWorkerTask, ensureSqlMessageStorage, ensureSqlMessageStorageEffect, executeChildWorkflow, executeComputeTaskBridge, executeStaticTaskBridge, executeTaskActivity, executeTaskBridge, executeTaskBridgeEffect, getDefinedToolMetadata, getHumanTaskPrompt, getRun, getSqlMessageStorage, getWorkflowMakeBridgeRuntime, getWorkflowPatchDecisions, getWorkflowVersioningRuntime, isBridgeManagedTimerTask, isBridgeManagedWaitForEventTask, isHumanRequestPastTimeout, isHumanTaskMeta, isPidAlive, isRunHeartbeatFresh, isTaskResultFailure, jsonSchemaToZod, listRuns, makeAbortError, makeApprovalDurableDeferred, makeDurableDeferredBridgeExecutionId, makeTaskActivity, makeTaskBridgeKey, makeWaitForEventDurableDeferred, makeWorkerTask, parseAttemptMetaJson, parseRuntimeOwnerPid, renderFrame, resolveDeferredTaskStateBridge, resolveOverlayEntry, resolveSchema, runWorkflow, runWorkflowWithMakeBridge, scheduleTasks, signal, signalRun, subscribeTaskWorkerDispatches, usePatched, validateHumanRequestValue, wireAbortSignal, withWorkflowMakeBridgeRuntime, withWorkflowVersioningRuntime };
|
|
1685
|
+
export { type AlertHumanRequestOptions, AlertRuntime, type AlertRuntimeServices, type AnySchema, type ApprovalOptions, type ApprovalPayload, ApprovalPayloadSchema, type ApprovalResult, ApprovalResultSchema, type BridgeManagedTaskKind, type BuilderApi$1 as BuilderApi, type BuilderNode, type BuilderStepContext, type BuilderStepHandle, type BuiltSmithersWorkflow$1 as BuiltSmithersWorkflow, type CancelPayload, CancelPayloadSchema, type CancelResult, CancelResultSchema, type ChildWorkflowDefinition, type ChildWorkflowExecuteOptions, CodeplaneSandboxExecutorLive, type ComputeTaskBridgeToolConfig, type ContinuationRequest, type CorrelatedSmithersEvent, type CorrelationContext, type DiffBundle, DockerSandboxExecutorLive, EventBus, type ExecuteTaskActivityOptions, type FilePatch, type GetRunPayload, GetRunPayloadSchema, type GetRunResult, GetRunResultSchema, type GraphFactory, HUMAN_REQUEST_KINDS, HUMAN_REQUEST_STATUSES, type HijackState, type HotReloadEvent, HotWorkflowController, type HumanRequestKind, type HumanRequestSchemaValidation, type HumanRequestStatus, type JsonSchema, type LegacyExecuteTaskFn, type ListRunsPayload, ListRunsPayloadSchema, type OverlayOptions, type PlanNode, type RalphMeta, type RalphState, type RalphStateMap, type ReadonlyTaskStateMap, RetriableTaskFailure, type RetryPolicy, type RetryWaitMap, type RunResult$2 as RunResult, RunStatusSchema, type RunSummary, RunSummarySchema, type SQLiteTable, SandboxHttpRunner, type ScheduleResult, type ScheduleSnapshot, type SignalPayload, SignalPayloadSchema, type SignalResult, SignalResultSchema, type SignalRunOptions, Smithers, type SmithersAlertPolicy, type SmithersEvent, SmithersRpcGroup, type SmithersSqliteOptions, SqlMessageStorage, type StaticTaskBridgeToolConfig, type StepOptions$1 as StepOptions, type TaskActivityContext, type TaskActivityRetryOptions, type TaskBridgeToolConfig, type TaskRecord, TaskResult, type TaskState, type TaskStateMap, TaskWorkerEntity, WatchTree, type WatchTreeOptions, WorkerDispatchKind, WorkerTask$1 as WorkerTask, WorkerTaskKind, type WorkflowGraph, type WorkflowHandle, type WorkflowPatchDecisionRecord, type WorkflowPatchDecisions, type WorkflowVersioningRuntime, type WorkflowVersioningRuntimeOptions, type XmlNode, type _TaskActivityContext, applyDiffBundle, approve, approveNode, awaitApprovalDurableDeferred, awaitWaitForEventDurableDeferred, bridgeApprovalResolve, bridgeSignalResolve, bridgeWaitForEventResolve, buildHumanRequestId, buildOverlay, buildPlanTree, canExecuteBridgeManagedComputeTask, canExecuteBridgeManagedStaticTask, cancel, cancelPendingTimersBridge, cleanupGenerations, computeDiffBundle, computeDiffBundleBetweenRefs, createSchedulerWakeQueue, createWorkflowVersioningRuntime, denyNode, dispatchWorkerTask, ensureSqlMessageStorage, ensureSqlMessageStorageEffect, executeChildWorkflow, executeComputeTaskBridge, executeStaticTaskBridge, executeTaskActivity, executeTaskBridge, executeTaskBridgeEffect, fragment, getDefinedToolMetadata, getHumanTaskPrompt, getRun, getSqlMessageStorage, getWorkflowMakeBridgeRuntime, getWorkflowPatchDecisions, getWorkflowVersioningRuntime, isBridgeManagedTimerTask, isBridgeManagedWaitForEventTask, isHumanRequestPastTimeout, isHumanTaskMeta, isPidAlive, isRunHeartbeatFresh, isTaskResultFailure, jsonSchemaToZod, listRuns, makeAbortError, makeApprovalDurableDeferred, makeDurableDeferredBridgeExecutionId, makeTaskActivity, makeTaskBridgeKey, makeWaitForEventDurableDeferred, makeWorkerTask, parseAttemptMetaJson, parseRuntimeOwnerPid, renderFrame, resolveDeferredTaskStateBridge, resolveOverlayEntry, resolveSchema, runWorkflow, runWorkflowWithMakeBridge, scheduleTasks, signal, signalRun, subscribeTaskWorkerDispatches, usePatched, validateHumanRequestValue, wireAbortSignal, withWorkflowMakeBridgeRuntime, withWorkflowVersioningRuntime, workflow };
|