@oomol-lab/open-flow 0.1.0-beta.25 → 0.1.0-beta.26
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/dist/browser/{createResourceDialog-DNgEsFmG.js → createResourceDialog-BwI2JmPE.js} +1 -1
- package/dist/browser/flow-change.d.ts +14 -0
- package/dist/browser/flow-change.js +38 -17
- package/dist/browser/{flowChanges-CfvUDu1U.js → flowChanges-BqPtWEI9.js} +2209 -2290
- package/dist/browser/{flowWorkspace-BsMrs6KT.js → flowWorkspace-CpMGzmfz.js} +31856 -31817
- package/dist/browser/{inputValues-BXC9GGGa.js → inputValues-CeeJw_G8.js} +1 -1
- package/dist/browser/{switch-Db5aHXHa.js → switch-CyZ96-UF.js} +835 -512
- package/dist/browser/theme.css +22 -0
- package/dist/browser/ui.css +1 -1
- package/dist/browser/workbench.css +1 -1
- package/dist/browser/workbench.js +340 -340
- package/dist/browser/{workbenchSelect-CXeaZhuN.js → workbenchSelect-BUu7CjUA.js} +127 -104
- package/dist/common/control-api-conformance.js +1 -1
- package/dist/common/control-api.d.ts +2 -0
- package/dist/common/control-api.js +1783 -1742
- package/dist/common/engine-contract.d.ts +2 -2
- package/dist/common/flow-graph.d.ts +25 -3
- package/dist/common/flow-schema.d.ts +11 -1
- package/dist/common/flow-semantics.d.ts +2 -1
- package/dist/common/flow-semantics.js +1460 -1374
- package/dist/common/mcp.js +283 -243
- package/dist/common/runtime-contract.d.ts +2 -0
- package/dist/common/runtime-contract.js +96 -32
- package/dist/common/scheduler.js +98 -128
- package/package.json +1 -1
package/dist/common/scheduler.js
CHANGED
|
@@ -7804,35 +7804,17 @@ function jf(e) {
|
|
|
7804
7804
|
}
|
|
7805
7805
|
//#endregion
|
|
7806
7806
|
//#region src/execution/common/scheduler.ts
|
|
7807
|
-
function Mf(e, t
|
|
7808
|
-
let r = !1;
|
|
7809
|
-
for (let i of Object.values(e.inputs)) {
|
|
7810
|
-
if (i.kind != "sources") continue;
|
|
7811
|
-
let e = !1, a = !1;
|
|
7812
|
-
for (let r of i.sources) {
|
|
7813
|
-
if (r.kind != "node") {
|
|
7814
|
-
e = !0;
|
|
7815
|
-
continue;
|
|
7816
|
-
}
|
|
7817
|
-
let i = n(r.nodeId);
|
|
7818
|
-
i != null && Object.hasOwn(i, r.output) ? e = !0 : t(r.nodeId) || (a = !0);
|
|
7819
|
-
}
|
|
7820
|
-
if (!e && !a) return "missing";
|
|
7821
|
-
r ||= a;
|
|
7822
|
-
}
|
|
7823
|
-
return r ? "pending" : "ready";
|
|
7824
|
-
}
|
|
7825
|
-
function Nf(e, t) {
|
|
7807
|
+
function Mf(e, t) {
|
|
7826
7808
|
return e.edges.some((e) => e.source == t && e.sourceHandle == "notification") || Object.values(e.nodes).some((e) => "inputs" in e && Object.values(e.inputs).some((e) => e.kind == "sources" && e.sources.some((e) => e.kind == "node" && e.nodeId == t && e.output == "notification")));
|
|
7827
7809
|
}
|
|
7828
|
-
var
|
|
7829
|
-
function
|
|
7810
|
+
var Nf = 12e4;
|
|
7811
|
+
function Pf(e, t) {
|
|
7830
7812
|
return t?.(e) ?? {
|
|
7831
7813
|
code: "node.failed",
|
|
7832
7814
|
message: e instanceof Error ? e.message : String(e)
|
|
7833
7815
|
};
|
|
7834
7816
|
}
|
|
7835
|
-
function
|
|
7817
|
+
function Ff(e, t) {
|
|
7836
7818
|
switch (t.kind) {
|
|
7837
7819
|
case "condition": return { [t.input.handle]: t.input };
|
|
7838
7820
|
case "value": return {};
|
|
@@ -7841,7 +7823,7 @@ function If(e, t) {
|
|
|
7841
7823
|
case "wait": return { [t.input.handle]: t.input };
|
|
7842
7824
|
}
|
|
7843
7825
|
}
|
|
7844
|
-
function
|
|
7826
|
+
function If(e, t) {
|
|
7845
7827
|
if (t.name != null) return t.name;
|
|
7846
7828
|
switch (t.kind) {
|
|
7847
7829
|
case "condition": return;
|
|
@@ -7851,45 +7833,45 @@ function Lf(e, t) {
|
|
|
7851
7833
|
case "wait": return "Wait";
|
|
7852
7834
|
}
|
|
7853
7835
|
}
|
|
7854
|
-
function
|
|
7836
|
+
function Lf(e, t) {
|
|
7855
7837
|
return t.kind == "task" ? t.task == null ? e.tasks[t.taskId].executor.kind : "javascript" : t.kind;
|
|
7856
7838
|
}
|
|
7857
|
-
function
|
|
7839
|
+
function Rf(e, t) {
|
|
7858
7840
|
if (typeof e != "object" || !e || Array.isArray(e)) throw Error(`${t} must be an object.`);
|
|
7859
7841
|
return e;
|
|
7860
7842
|
}
|
|
7861
|
-
function
|
|
7843
|
+
function zf(e, t, n) {
|
|
7862
7844
|
let r = Object.keys(e);
|
|
7863
7845
|
if (r.length != t.length || r.some((e) => !t.includes(e))) throw Error(`${n} contains unsupported fields.`);
|
|
7864
7846
|
}
|
|
7865
|
-
function
|
|
7847
|
+
function Bf(e, t) {
|
|
7866
7848
|
if (typeof e != "string" || e.length == 0) throw Error(`${t} must be a non-empty string.`);
|
|
7867
7849
|
return e;
|
|
7868
7850
|
}
|
|
7869
|
-
function
|
|
7851
|
+
function Vf(e, t, n = 0) {
|
|
7870
7852
|
if (n > 64) throw Error(`${t} exceeds the maximum JSON depth.`);
|
|
7871
7853
|
if (e === null || typeof e == "boolean" || typeof e == "string" || typeof e == "number" && Number.isFinite(e)) return e;
|
|
7872
|
-
if (Array.isArray(e)) return e.map((e) =>
|
|
7873
|
-
let r =
|
|
7874
|
-
return Object.fromEntries(Object.entries(r).map(([e, r]) => [e,
|
|
7854
|
+
if (Array.isArray(e)) return e.map((e) => Vf(e, t, n + 1));
|
|
7855
|
+
let r = Rf(e, t);
|
|
7856
|
+
return Object.fromEntries(Object.entries(r).map(([e, r]) => [e, Vf(r, t, n + 1)]));
|
|
7875
7857
|
}
|
|
7876
|
-
var
|
|
7858
|
+
var Hf = ss({
|
|
7877
7859
|
state: Vs(),
|
|
7878
7860
|
callId: j().min(1),
|
|
7879
7861
|
toolId: j().min(1),
|
|
7880
7862
|
input: L(j(), Vs()),
|
|
7881
7863
|
rounds: N().int().nonnegative(),
|
|
7882
7864
|
version: z(1)
|
|
7883
|
-
}),
|
|
7865
|
+
}), Uf = I([ss({
|
|
7884
7866
|
kind: z("completed"),
|
|
7885
7867
|
output: Vs()
|
|
7886
7868
|
}), ss({
|
|
7887
7869
|
kind: z("suspended"),
|
|
7888
|
-
checkpoint:
|
|
7870
|
+
checkpoint: Hf
|
|
7889
7871
|
})]);
|
|
7890
|
-
function
|
|
7891
|
-
let t =
|
|
7892
|
-
if (
|
|
7872
|
+
function Wf(e) {
|
|
7873
|
+
let t = Rf(e, "Flow Run checkpoint");
|
|
7874
|
+
if (zf(t, [
|
|
7893
7875
|
"agents",
|
|
7894
7876
|
"bindingValues",
|
|
7895
7877
|
"inputs",
|
|
@@ -7898,18 +7880,18 @@ function Gf(e) {
|
|
|
7898
7880
|
"version",
|
|
7899
7881
|
"waits"
|
|
7900
7882
|
], "Flow Run checkpoint"), t.version != 3) throw Error("Flow Run checkpoint version is unsupported.");
|
|
7901
|
-
let n = Object.fromEntries(Object.entries(
|
|
7883
|
+
let n = Object.fromEntries(Object.entries(Rf(t.bindingValues, "Checkpoint bindings")).map(([e, t]) => {
|
|
7902
7884
|
if (typeof t != "string") throw Error("Checkpoint binding must be a string.");
|
|
7903
7885
|
return [e, t];
|
|
7904
|
-
})), r = Object.fromEntries(Object.entries(
|
|
7905
|
-
let n =
|
|
7906
|
-
return
|
|
7907
|
-
jobId:
|
|
7908
|
-
outputs: Object.fromEntries(Object.entries(
|
|
7886
|
+
})), r = Object.fromEntries(Object.entries(Rf(t.inputs, "Checkpoint inputs")).map(([e, t]) => [e, Object.fromEntries(Object.entries(Rf(t, "Checkpoint node inputs")).map(([e, t]) => [e, Vf(t, "Checkpoint input")]))])), i = Object.fromEntries(Object.entries(Rf(t.results, "Checkpoint results")).map(([e, t]) => {
|
|
7887
|
+
let n = Rf(t, "Checkpoint result");
|
|
7888
|
+
return zf(n, ["jobId", "outputs"], "Checkpoint result"), [e, {
|
|
7889
|
+
jobId: Bf(n.jobId, "Checkpoint job ID"),
|
|
7890
|
+
outputs: Object.fromEntries(Object.entries(Rf(n.outputs, "Checkpoint outputs")).map(([e, t]) => [e, Vf(t, "Checkpoint output")]))
|
|
7909
7891
|
}];
|
|
7910
7892
|
}));
|
|
7911
7893
|
if (!Array.isArray(t.skipped)) throw Error("Checkpoint skipped nodes must be an array.");
|
|
7912
|
-
let a = t.skipped.map((e) =>
|
|
7894
|
+
let a = t.skipped.map((e) => Bf(e, "Checkpoint skipped node"));
|
|
7913
7895
|
if (new Set(a).size != a.length || a.some((e) => i[e] != null)) throw Error("Checkpoint node states conflict.");
|
|
7914
7896
|
let o = P(ss({
|
|
7915
7897
|
jobId: j().min(1),
|
|
@@ -7921,7 +7903,7 @@ function Gf(e) {
|
|
|
7921
7903
|
invocationId: j().min(1),
|
|
7922
7904
|
input: L(j(), Vs()),
|
|
7923
7905
|
remainingMs: N().positive().optional(),
|
|
7924
|
-
checkpoint:
|
|
7906
|
+
checkpoint: Hf
|
|
7925
7907
|
})).parse(t.agents), c = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set();
|
|
7926
7908
|
for (let e of o) {
|
|
7927
7909
|
if (i[e.nodeId] != null || a.includes(e.nodeId) || c.has(e.nodeId) || l.has(e.waitId)) throw Error("Checkpoint waiting node states conflict.");
|
|
@@ -7938,18 +7920,18 @@ function Gf(e) {
|
|
|
7938
7920
|
waits: o
|
|
7939
7921
|
};
|
|
7940
7922
|
}
|
|
7941
|
-
function
|
|
7923
|
+
function Gf(e, t) {
|
|
7942
7924
|
if (e === t) return !0;
|
|
7943
7925
|
if (e == null || t == null || typeof e != "object" || typeof t != "object") return !1;
|
|
7944
|
-
if (Array.isArray(e) || Array.isArray(t)) return Array.isArray(e) && Array.isArray(t) && e.length == t.length && e.every((e, n) =>
|
|
7926
|
+
if (Array.isArray(e) || Array.isArray(t)) return Array.isArray(e) && Array.isArray(t) && e.length == t.length && e.every((e, n) => Gf(e, t[n]));
|
|
7945
7927
|
let n = Object.entries(e), r = Object.entries(t), i = t;
|
|
7946
|
-
return n.length == r.length && n.every(([e, t]) => Object.hasOwn(i, e) &&
|
|
7928
|
+
return n.length == r.length && n.every(([e, t]) => Object.hasOwn(i, e) && Gf(t, i[e]));
|
|
7947
7929
|
}
|
|
7948
|
-
function
|
|
7930
|
+
function Kf(e, t, n) {
|
|
7949
7931
|
let r = Object.hasOwn(n, t.input) ? n[t.input] : null, i = t.value;
|
|
7950
7932
|
switch (t.operator) {
|
|
7951
|
-
case "==": return i !== void 0 &&
|
|
7952
|
-
case "!=": return i !== void 0 && !
|
|
7933
|
+
case "==": return i !== void 0 && Gf(r, i);
|
|
7934
|
+
case "!=": return i !== void 0 && !Gf(r, i);
|
|
7953
7935
|
case ">": return typeof r == "number" && typeof i == "number" && r > i;
|
|
7954
7936
|
case ">=": return typeof r == "number" && typeof i == "number" && r >= i;
|
|
7955
7937
|
case "<": return typeof r == "number" && typeof i == "number" && r < i;
|
|
@@ -7957,7 +7939,7 @@ function qf(e, t, n) {
|
|
|
7957
7939
|
case "contains":
|
|
7958
7940
|
case "notContains": {
|
|
7959
7941
|
let e;
|
|
7960
|
-
return typeof r == "string" && typeof i == "string" ? e = r.includes(i) : Array.isArray(r) && i !== void 0 && (e = r.some((e) =>
|
|
7942
|
+
return typeof r == "string" && typeof i == "string" ? e = r.includes(i) : Array.isArray(r) && i !== void 0 && (e = r.some((e) => Gf(e, i))), e == null ? !1 : t.operator == "contains" ? e : !e;
|
|
7961
7943
|
}
|
|
7962
7944
|
case "startsWith": return typeof r == "string" && typeof i == "string" && r.startsWith(i);
|
|
7963
7945
|
case "endsWith": return typeof r == "string" && typeof i == "string" && r.endsWith(i);
|
|
@@ -7970,7 +7952,7 @@ function qf(e, t, n) {
|
|
|
7970
7952
|
case "hasValue":
|
|
7971
7953
|
case "notHasValue": {
|
|
7972
7954
|
if (r == null || Array.isArray(r) || typeof r != "object" || i === void 0) return !1;
|
|
7973
|
-
let e = Object.values(r).some((e) =>
|
|
7955
|
+
let e = Object.values(r).some((e) => Gf(e, i));
|
|
7974
7956
|
return t.operator == "hasValue" ? e : !e;
|
|
7975
7957
|
}
|
|
7976
7958
|
case "isEmpty":
|
|
@@ -7984,17 +7966,17 @@ function qf(e, t, n) {
|
|
|
7984
7966
|
case "isFalse": return r === !1;
|
|
7985
7967
|
}
|
|
7986
7968
|
}
|
|
7987
|
-
function
|
|
7969
|
+
function qf(e, t) {
|
|
7988
7970
|
if (e === void 0) return {};
|
|
7989
7971
|
if (typeof e != "object" || !e || Array.isArray(e)) throw Error(`Node "${t}" must return an object.`);
|
|
7990
7972
|
return e;
|
|
7991
7973
|
}
|
|
7992
|
-
function
|
|
7974
|
+
function Jf(e, t) {
|
|
7993
7975
|
let n = t.kind == "task" && t.taskId != null ? e.tasks[t.taskId] : void 0;
|
|
7994
7976
|
return n?.executor.kind == "agent" ? n.executor : void 0;
|
|
7995
7977
|
}
|
|
7996
|
-
function
|
|
7997
|
-
let r =
|
|
7978
|
+
function Yf(e, t, n) {
|
|
7979
|
+
let r = Jf(e, t)?.notification;
|
|
7998
7980
|
if (r == null) return;
|
|
7999
7981
|
let i = e.tasks[r.taskId];
|
|
8000
7982
|
return {
|
|
@@ -8007,13 +7989,13 @@ function Xf(e, t, n) {
|
|
|
8007
7989
|
}))
|
|
8008
7990
|
};
|
|
8009
7991
|
}
|
|
8010
|
-
function
|
|
7992
|
+
function Xf(e, t, n) {
|
|
8011
7993
|
let r = e.tools.find((e) => e.id == t.toolId);
|
|
8012
7994
|
if (r == null || !r.approval || t.rounds > e.maxRounds) throw Error("Agent pause does not match its tool declaration.");
|
|
8013
7995
|
for (let e of r.inputs) {
|
|
8014
7996
|
let r = t.input[e.handle];
|
|
8015
7997
|
if (r === void 0 || !(r === null && e.nullable) && !Of(r, e.jsonSchema)) throw Error("Agent pause arguments are invalid.");
|
|
8016
|
-
if (e.source.kind != "model" && !
|
|
7998
|
+
if (e.source.kind != "model" && !Gf(r, kf(e.source, n))) throw Error("Agent pause changed fixed arguments.");
|
|
8017
7999
|
}
|
|
8018
8000
|
if (Object.keys(t.input).length != r.inputs.length) throw Error("Agent pause contains undeclared arguments.");
|
|
8019
8001
|
return {
|
|
@@ -8024,23 +8006,23 @@ function Zf(e, t, n) {
|
|
|
8024
8006
|
input: t.input
|
|
8025
8007
|
};
|
|
8026
8008
|
}
|
|
8027
|
-
function
|
|
8028
|
-
let i =
|
|
8029
|
-
|
|
8009
|
+
function Zf(e, t, n, r) {
|
|
8010
|
+
let i = qf(r, t), a = n.kind == "task" && n.taskId != null && e.tasks[n.taskId].executor.kind == "connector", o = n.kind == "wait" ? Af(n) : n.kind == "task" ? al(n.task == null ? e.tasks[n.taskId].outputs : n.task.outputs) : n.kind == "subflow" ? al(e.subflows[n.subflowId].outputs) : n.kind == "value" ? al(n.values) : Object.fromEntries([...n.cases.map((e) => e.output), ...n.defaultOutput == null ? [] : [n.defaultOutput]].map((e) => [e, n.input])), s = qf(Vf(Object.fromEntries(Object.entries(i).map(([e, t]) => [e, Object.hasOwn(o, e) && t === void 0 ? null : t])), `Node "${t}" outputs`), t), c = n.kind == "condition" || n.kind == "wait" ? s : {
|
|
8011
|
+
...Object.fromEntries(Object.keys(o).map((e) => [e, null])),
|
|
8012
|
+
...s
|
|
8013
|
+
}, l = {};
|
|
8014
|
+
for (let [e, n] of Object.entries(c)) {
|
|
8030
8015
|
let r = o[e];
|
|
8031
8016
|
if (r == null) {
|
|
8032
8017
|
if (a) continue;
|
|
8033
8018
|
throw Error(`Node "${t}" output "${e}" does not match its declaration.`);
|
|
8034
8019
|
}
|
|
8035
8020
|
if (!(n === null && r.nullable) && !Of(n, r.jsonSchema)) throw Error(`Node "${t}" output "${e}" does not match its declaration.`);
|
|
8036
|
-
|
|
8037
|
-
}
|
|
8038
|
-
if (n.kind != "condition" && n.kind != "wait") {
|
|
8039
|
-
for (let e of Object.keys(o)) if (!Object.hasOwn(i, e)) throw Error(`Node "${t}" did not return output "${e}".`);
|
|
8021
|
+
l[e] = n;
|
|
8040
8022
|
}
|
|
8041
|
-
return
|
|
8023
|
+
return l;
|
|
8042
8024
|
}
|
|
8043
|
-
function
|
|
8025
|
+
function Qf(e, t, n, r, i) {
|
|
8044
8026
|
let a = new Map(Object.entries(n.results)), o = new Set(n.skipped), s = n.inputs, c = n.agents, l = (e) => a.has(e) || o.has(e), u = new Map(n.waits.filter((e) => e.notification != null).map((e) => [e.nodeId, e.notification])), d = (e) => l(e.source) || e.sourceHandle == "notification" && u.has(e.source), f = (e) => {
|
|
8045
8027
|
let t = a.get(e.source);
|
|
8046
8028
|
return e.sourceHandle == "notification" && u.has(e.source) || t != null && (e.sourceHandle == null || Object.hasOwn(t.outputs, e.sourceHandle));
|
|
@@ -8061,44 +8043,42 @@ function $f(e, t, n, r, i) {
|
|
|
8061
8043
|
if (!l(n)) continue;
|
|
8062
8044
|
let o = r.get(n) ?? [];
|
|
8063
8045
|
if (!o.every(d)) throw Error("Checkpoint node dependencies are incomplete.");
|
|
8064
|
-
let s = o.length == 0 && t.kind == "subflow" || o.some(f)
|
|
8065
|
-
if (
|
|
8066
|
-
let
|
|
8067
|
-
if (
|
|
8068
|
-
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
let t = Object.keys(h.outputs).length;
|
|
8072
|
-
if (i.kind == "condition" && (t > 1 || i.defaultOutput != null && t != 1) || i.kind == "wait" && i.actions.filter((e) => Object.hasOwn(h.outputs, e)).length != 1) throw Error("Checkpoint branch result is invalid.");
|
|
8046
|
+
let s = o.length == 0 && t.kind == "subflow" || o.some(f);
|
|
8047
|
+
if (a.has(n) != s) throw Error("Checkpoint node state conflicts with its execution branches.");
|
|
8048
|
+
let c = a.get(n);
|
|
8049
|
+
if (c != null) {
|
|
8050
|
+
if (!Gf(Zf(e, n, i, c.outputs), c.outputs)) throw Error("Checkpoint node outputs are incomplete.");
|
|
8051
|
+
let t = Object.keys(c.outputs).length;
|
|
8052
|
+
if (i.kind == "condition" && (t > 1 || i.defaultOutput != null && t != 1) || i.kind == "wait" && i.actions.filter((e) => Object.hasOwn(c.outputs, e)).length != 1) throw Error("Checkpoint branch result is invalid.");
|
|
8073
8053
|
}
|
|
8074
8054
|
}
|
|
8075
8055
|
if (t.kind == "flow" && p != 1) throw Error("Checkpoint must contain exactly one selected Trigger.");
|
|
8076
8056
|
for (let [n, r] of Object.entries(s)) {
|
|
8077
8057
|
let i = t.graph.nodes[n];
|
|
8078
|
-
if (!("inputs" in i) || Object.keys(r).some((t) =>
|
|
8058
|
+
if (!("inputs" in i) || Object.keys(r).some((t) => Ff(e, i)[t] == null)) throw Error("Checkpoint launch inputs do not match the prepared graph.");
|
|
8079
8059
|
}
|
|
8080
8060
|
for (let a of n.waits) {
|
|
8081
8061
|
let n = t.graph.nodes[a.nodeId];
|
|
8082
8062
|
if (n == null || !("inputs" in n)) throw Error("Checkpoint waiting node is missing.");
|
|
8083
|
-
let o =
|
|
8063
|
+
let o = Jf(e, n), s = c[a.nodeId];
|
|
8084
8064
|
if (n.kind != "wait" && o == null) throw Error("Checkpoint waiting node cannot suspend.");
|
|
8085
8065
|
if (o != null) {
|
|
8086
8066
|
if (s != null && s.invocationId != a.jobId) throw Error("Checkpoint Agent invocation identity changed.");
|
|
8087
8067
|
if (s == null || n.timeoutMs == null != (s.remainingMs == null) || s.remainingMs != null && s.remainingMs > n.timeoutMs) throw Error("Checkpoint Agent budget is invalid.");
|
|
8088
|
-
let e =
|
|
8089
|
-
if (!
|
|
8090
|
-
if (!
|
|
8068
|
+
let e = Xf(o, s.checkpoint, s.input);
|
|
8069
|
+
if (!Gf(a.value, e)) throw Error("Checkpoint Agent approval does not match its saved call.");
|
|
8070
|
+
if (!Gf(i(a.nodeId, n), s.input)) throw Error("Checkpoint Agent inputs changed.");
|
|
8091
8071
|
} else {
|
|
8092
8072
|
if (s != null) throw Error("Checkpoint Wait contains Agent state.");
|
|
8093
|
-
if (n.kind != "wait" || !
|
|
8094
|
-
if (
|
|
8095
|
-
a.notification != null &&
|
|
8073
|
+
if (n.kind != "wait" || !Gf(i(a.nodeId, n)[n.input.handle], a.value)) throw Error("Checkpoint Wait input changed.");
|
|
8074
|
+
if (Mf(t.graph, a.nodeId) != (a.notification != null)) throw Error("Checkpoint Wait notification is missing or unexpected.");
|
|
8075
|
+
a.notification != null && Zf(e, a.nodeId, n, { notification: a.notification });
|
|
8096
8076
|
}
|
|
8097
8077
|
let l = r.get(a.nodeId) ?? [];
|
|
8098
8078
|
if (!l.every(d) || l.length == 0 || !l.some(f)) throw Error("Flow Run checkpoint Wait dependencies are incomplete.");
|
|
8099
8079
|
}
|
|
8100
8080
|
}
|
|
8101
|
-
function
|
|
8081
|
+
function $f(i, o, s, c, l, u = {}, d, f) {
|
|
8102
8082
|
return t.scoped(t.gen(function* () {
|
|
8103
8083
|
f ?? (yield* i.emit({
|
|
8104
8084
|
flowId: o.flowId,
|
|
@@ -8135,14 +8115,14 @@ function ep(i, o, s, c, l, u = {}, d, f) {
|
|
|
8135
8115
|
let t = ee.get(e.nodeId)?.outputs ?? (v.has(e.nodeId) ? { notification: v.get(e.nodeId) } : void 0);
|
|
8136
8116
|
return t != null && Object.hasOwn(t, e.output) ? [t[e.output]] : [];
|
|
8137
8117
|
});
|
|
8138
|
-
if (t.length
|
|
8139
|
-
a = t[0];
|
|
8118
|
+
if (t.length > 1) throw Error(`${r} has multiple available sources.`);
|
|
8119
|
+
a = t[0] ?? null;
|
|
8140
8120
|
}
|
|
8141
|
-
if (a === void 0 &&
|
|
8121
|
+
if (a === void 0 && (a = null), !(a === null && t.nullable) && !Of(a, t.jsonSchema)) throw Error(`${r} does not match its declared schema.`);
|
|
8142
8122
|
return a;
|
|
8143
8123
|
}, ge = (e, t) => {
|
|
8144
8124
|
let n = t.inputs;
|
|
8145
|
-
return Object.fromEntries(Object.entries(
|
|
8125
|
+
return Object.fromEntries(Object.entries(Ff(i.prepared, t)).map(([t, r]) => [t, he(n[t], r, re[e]?.[t], `Node "${e}" input "${t}"`)]));
|
|
8146
8126
|
}, _e = (e, n, r) => t.uninterruptible(t.gen(function* () {
|
|
8147
8127
|
yield* i.emit({
|
|
8148
8128
|
jobId: n,
|
|
@@ -8159,8 +8139,8 @@ function ep(i, o, s, c, l, u = {}, d, f) {
|
|
|
8159
8139
|
type: "run.progress"
|
|
8160
8140
|
});
|
|
8161
8141
|
})), b, ve = (e, n, r, a, c) => {
|
|
8162
|
-
let l =
|
|
8163
|
-
let p =
|
|
8142
|
+
let l = Jf(i.prepared, n), u = de[e], d = u?.remainingMs ?? n.timeoutMs, f = performance.now(), p = t.gen(function* () {
|
|
8143
|
+
let p = Lf(i.prepared, n), m = If(i.prepared, n), h = Object.fromEntries(Object.entries(a).filter(([e]) => {
|
|
8164
8144
|
if (n.kind == "wait") return e == n.input.handle;
|
|
8165
8145
|
let t = n.inputs[e];
|
|
8166
8146
|
return t?.kind != "sources" || t.sources.every((e) => e.kind != "binding");
|
|
@@ -8179,7 +8159,7 @@ function ep(i, o, s, c, l, u = {}, d, f) {
|
|
|
8179
8159
|
case "condition": {
|
|
8180
8160
|
let e = n.cases.find((e) => {
|
|
8181
8161
|
if (e.expressions.length == 0) return !1;
|
|
8182
|
-
let t = e.expressions.map((e) =>
|
|
8162
|
+
let t = e.expressions.map((e) => Kf(n, e, a));
|
|
8183
8163
|
return e.relation == "all" ? t.every(Boolean) : t.some(Boolean);
|
|
8184
8164
|
})?.output ?? n.defaultOutput;
|
|
8185
8165
|
g = e == null ? {} : { [e]: a[n.input.handle] ?? null };
|
|
@@ -8190,7 +8170,7 @@ function ep(i, o, s, c, l, u = {}, d, f) {
|
|
|
8190
8170
|
break;
|
|
8191
8171
|
case "subflow": {
|
|
8192
8172
|
let e = i.prepared.subflows[n.subflowId];
|
|
8193
|
-
g = yield*
|
|
8173
|
+
g = yield* $f(i, {
|
|
8194
8174
|
flowId: n.subflowId,
|
|
8195
8175
|
graph: e.graph,
|
|
8196
8176
|
kind: "subflow"
|
|
@@ -8220,10 +8200,10 @@ function ep(i, o, s, c, l, u = {}, d, f) {
|
|
|
8220
8200
|
}
|
|
8221
8201
|
});
|
|
8222
8202
|
if (l != null) {
|
|
8223
|
-
let n =
|
|
8203
|
+
let n = Uf.parse(m);
|
|
8224
8204
|
if (n.kind == "suspended") {
|
|
8225
8205
|
if (o.kind != "flow") return yield* t.fail(/* @__PURE__ */ Error("Subflow Agent is not supported."));
|
|
8226
|
-
let i = n.checkpoint, s =
|
|
8206
|
+
let i = n.checkpoint, s = Xf(l, i, a), c = d == null ? void 0 : d - (performance.now() - f);
|
|
8227
8207
|
if (c != null && c <= 0) throw Error(`Node "${e}" timed out.`);
|
|
8228
8208
|
return {
|
|
8229
8209
|
kind: "suspended",
|
|
@@ -8237,7 +8217,7 @@ function ep(i, o, s, c, l, u = {}, d, f) {
|
|
|
8237
8217
|
};
|
|
8238
8218
|
}
|
|
8239
8219
|
g = { output: n.output };
|
|
8240
|
-
} else g =
|
|
8220
|
+
} else g = qf(m, e);
|
|
8241
8221
|
break;
|
|
8242
8222
|
}
|
|
8243
8223
|
case "wait": return yield* t.fail(/* @__PURE__ */ Error("Wait jobs are handled by the Scheduler suspension boundary."));
|
|
@@ -8245,7 +8225,7 @@ function ep(i, o, s, c, l, u = {}, d, f) {
|
|
|
8245
8225
|
return yield* t.try({
|
|
8246
8226
|
try: () => ({
|
|
8247
8227
|
kind: "completed",
|
|
8248
|
-
outputs:
|
|
8228
|
+
outputs: Zf(i.prepared, e, n, g)
|
|
8249
8229
|
}),
|
|
8250
8230
|
catch: (e) => e instanceof Error ? e : Error(String(e))
|
|
8251
8231
|
});
|
|
@@ -8256,7 +8236,7 @@ function ep(i, o, s, c, l, u = {}, d, f) {
|
|
|
8256
8236
|
}));
|
|
8257
8237
|
}, ye = (e, n, s) => t.gen(function* () {
|
|
8258
8238
|
if (o.kind != "flow" || i.waits == null) return yield* t.fail(/* @__PURE__ */ Error("Wait host is unavailable."));
|
|
8259
|
-
let c = o.graph.nodes[e], l = a(), u = c.kind == "wait" &&
|
|
8239
|
+
let c = o.graph.nodes[e], l = a(), u = c.kind == "wait" && Mf(o.graph, e), d = yield* i.waits.create({
|
|
8260
8240
|
jobId: n,
|
|
8261
8241
|
nodeId: e,
|
|
8262
8242
|
value: s,
|
|
@@ -8264,9 +8244,9 @@ function ep(i, o, s, c, l, u = {}, d, f) {
|
|
|
8264
8244
|
notify: u,
|
|
8265
8245
|
actions: c.kind == "wait" ? c.actions : ["approve", "reject"],
|
|
8266
8246
|
prompt: c.kind == "wait" ? c.prompt : JSON.stringify(s, null, 2),
|
|
8267
|
-
...c.kind == "wait" ? {} : { notification:
|
|
8247
|
+
...c.kind == "wait" ? {} : { notification: Yf(i.prepared, c, de[e].input) }
|
|
8268
8248
|
});
|
|
8269
|
-
u && (
|
|
8249
|
+
u && (Zf(i.prepared, e, c, { notification: d }), v.set(e, d)), _.set(e, {
|
|
8270
8250
|
jobId: n,
|
|
8271
8251
|
nodeId: e,
|
|
8272
8252
|
value: s,
|
|
@@ -8277,7 +8257,7 @@ function ep(i, o, s, c, l, u = {}, d, f) {
|
|
|
8277
8257
|
yield* r.offer(y, void 0);
|
|
8278
8258
|
}), x = (e, t, n) => n.kind == "completed" ? (delete de[e], _e(e, t, n.outputs)) : (de[e] = n.agent, ye(e, t, n.value)), be = (e, n, r) => r.pipe(t.catchDefect((e) => t.fail(e instanceof Error ? e : Error(String(e)))), t.tapError((r) => t.gen(function* () {
|
|
8279
8259
|
oe ?? (se ??= r), yield* i.emit({
|
|
8280
|
-
...
|
|
8260
|
+
...Pf(r, i.projectFailure),
|
|
8281
8261
|
jobId: n,
|
|
8282
8262
|
nodeId: e,
|
|
8283
8263
|
runId: s,
|
|
@@ -8292,18 +8272,8 @@ function ep(i, o, s, c, l, u = {}, d, f) {
|
|
|
8292
8272
|
if (!("inputs" in n)) return;
|
|
8293
8273
|
let a = m.get(e) ?? [];
|
|
8294
8274
|
if (!a.every(pe)) return;
|
|
8295
|
-
|
|
8296
|
-
|
|
8297
|
-
if (l == "missing") {
|
|
8298
|
-
te.add(e), ae(t.gen(function* () {
|
|
8299
|
-
c || (yield* i.emit({
|
|
8300
|
-
type: "node.log",
|
|
8301
|
-
runId: s,
|
|
8302
|
-
nodeId: e,
|
|
8303
|
-
jobId: i.createId(),
|
|
8304
|
-
level: "info",
|
|
8305
|
-
message: "Node skipped because an input source did not produce a value on this execution path."
|
|
8306
|
-
}));
|
|
8275
|
+
if (a.length == 0 && o.kind == "flow" || a.length > 0 && !a.some(me)) {
|
|
8276
|
+
te.add(e), ae(t.sync(() => {
|
|
8307
8277
|
for (let t of h.get(e) ?? []) b(t);
|
|
8308
8278
|
}).pipe(t.tapCause((e) => t.sync(() => {
|
|
8309
8279
|
oe ??= e;
|
|
@@ -8311,8 +8281,8 @@ function ep(i, o, s, c, l, u = {}, d, f) {
|
|
|
8311
8281
|
return;
|
|
8312
8282
|
}
|
|
8313
8283
|
ne.add(e);
|
|
8314
|
-
let
|
|
8315
|
-
ae(be(e,
|
|
8284
|
+
let c = i.createId();
|
|
8285
|
+
ae(be(e, c, t.gen(function* () {
|
|
8316
8286
|
let r = yield* t.try({
|
|
8317
8287
|
try: () => ge(e, n),
|
|
8318
8288
|
catch: (e) => e instanceof Error ? e : Error(String(e))
|
|
@@ -8321,20 +8291,20 @@ function ep(i, o, s, c, l, u = {}, d, f) {
|
|
|
8321
8291
|
let t = n.inputs[n.input.handle];
|
|
8322
8292
|
yield* i.emit({
|
|
8323
8293
|
inputs: t?.kind == "sources" && t.sources.some((e) => e.kind == "binding") ? {} : { [n.input.handle]: r[n.input.handle] },
|
|
8324
|
-
jobId:
|
|
8294
|
+
jobId: c,
|
|
8325
8295
|
nodeId: e,
|
|
8326
8296
|
nodeKind: "wait",
|
|
8327
8297
|
...n.name == null ? {} : { nodeTitle: n.name },
|
|
8328
8298
|
runId: s,
|
|
8329
8299
|
type: "node.started"
|
|
8330
|
-
}), yield* ye(e,
|
|
8300
|
+
}), yield* ye(e, c, r[n.input.handle]);
|
|
8331
8301
|
return;
|
|
8332
8302
|
}
|
|
8333
|
-
let a = yield* ve(e, n,
|
|
8334
|
-
if (yield* x(e,
|
|
8303
|
+
let a = yield* ve(e, n, c, r);
|
|
8304
|
+
if (yield* x(e, c, a), a.kind == "completed") for (let t of h.get(e) ?? []) b(t);
|
|
8335
8305
|
})).pipe(t.ensuring(r.offer(y, void 0))));
|
|
8336
8306
|
}, f != null && (yield* t.try({
|
|
8337
|
-
try: () =>
|
|
8307
|
+
try: () => Qf(i.prepared, o, f.checkpoint, m, ge),
|
|
8338
8308
|
catch: (e) => e instanceof Error ? e : Error(String(e))
|
|
8339
8309
|
}));
|
|
8340
8310
|
for (let e of p) b(e);
|
|
@@ -8347,7 +8317,7 @@ function ep(i, o, s, c, l, u = {}, d, f) {
|
|
|
8347
8317
|
ae(be(a.nodeId, a.jobId, t.gen(function* () {
|
|
8348
8318
|
if (c.kind == "wait") {
|
|
8349
8319
|
if (!c.actions.some((e) => e == s)) return yield* t.fail(/* @__PURE__ */ Error("Resolution does not match Wait actions."));
|
|
8350
|
-
yield* _e(a.nodeId, a.jobId,
|
|
8320
|
+
yield* _e(a.nodeId, a.jobId, Zf(i.prepared, a.nodeId, c, {
|
|
8351
8321
|
...a.notification == null ? {} : { notification: a.notification },
|
|
8352
8322
|
[s]: a.value
|
|
8353
8323
|
}));
|
|
@@ -8372,7 +8342,7 @@ function ep(i, o, s, c, l, u = {}, d, f) {
|
|
|
8372
8342
|
let o = yield* n.size(ie);
|
|
8373
8343
|
if (o == 0 && _.size == 0) break;
|
|
8374
8344
|
o > 0 ? ue = void 0 : ue ??= a;
|
|
8375
|
-
let c = ue == null ? ce :
|
|
8345
|
+
let c = ue == null ? ce : Nf - (a - ue);
|
|
8376
8346
|
if (ue != null && c <= 0) {
|
|
8377
8347
|
let e = {
|
|
8378
8348
|
bindingValues: i.bindingValues,
|
|
@@ -8385,7 +8355,7 @@ function ep(i, o, s, c, l, u = {}, d, f) {
|
|
|
8385
8355
|
}, n = JSON.stringify(e);
|
|
8386
8356
|
return new TextEncoder().encode(n).byteLength > 16777216 ? yield* t.fail(/* @__PURE__ */ Error("Flow Run checkpoint exceeds 16 MiB.")) : {
|
|
8387
8357
|
kind: "waiting",
|
|
8388
|
-
checkpoint:
|
|
8358
|
+
checkpoint: Wf(JSON.parse(n)),
|
|
8389
8359
|
...ce == null ? {} : { remainingMs: ce }
|
|
8390
8360
|
};
|
|
8391
8361
|
}
|
|
@@ -8430,15 +8400,15 @@ function ep(i, o, s, c, l, u = {}, d, f) {
|
|
|
8430
8400
|
}), Se;
|
|
8431
8401
|
}));
|
|
8432
8402
|
}
|
|
8433
|
-
function
|
|
8403
|
+
function ep(e, n) {
|
|
8434
8404
|
let r = n.emit ?? (() => t.void);
|
|
8435
8405
|
return t.gen(function* () {
|
|
8436
8406
|
if (n.resume != null && (n.inputs != null || n.trigger != null || n.bindingValues != null)) return yield* t.fail(/* @__PURE__ */ Error("A resumed Flow Run cannot accept launch inputs, binding values, or a Trigger seed."));
|
|
8437
|
-
let i = n.resume == null ? void 0 :
|
|
8407
|
+
let i = n.resume == null ? void 0 : Wf(n.resume.checkpoint);
|
|
8438
8408
|
if (i != null && new TextEncoder().encode(JSON.stringify(i)).byteLength > 16777216) return yield* t.fail(/* @__PURE__ */ Error("Flow Run checkpoint exceeds 16 MiB."));
|
|
8439
8409
|
if (i == null && n.trigger == null) return yield* t.fail(/* @__PURE__ */ Error("A Flow Run requires a Trigger seed."));
|
|
8440
8410
|
let a = n.trigger == null ? void 0 : e.graph.nodes[n.trigger.nodeId];
|
|
8441
|
-
return n.trigger != null && (a == null || "inputs" in a) ? yield* t.fail(/* @__PURE__ */ Error(`Node "${n.trigger.nodeId}" is not a TriggerNode in Flow "${n.flowId}".`)) : yield*
|
|
8411
|
+
return n.trigger != null && (a == null || "inputs" in a) ? yield* t.fail(/* @__PURE__ */ Error(`Node "${n.trigger.nodeId}" is not a TriggerNode in Flow "${n.flowId}".`)) : yield* $f({
|
|
8442
8412
|
bindingValues: i?.bindingValues ?? n.bindingValues ?? {},
|
|
8443
8413
|
createId: n.createId,
|
|
8444
8414
|
emit: r,
|
|
@@ -8455,4 +8425,4 @@ function tp(e, n) {
|
|
|
8455
8425
|
});
|
|
8456
8426
|
}
|
|
8457
8427
|
//#endregion
|
|
8458
|
-
export {
|
|
8428
|
+
export { Wf as decodeFlowRunCheckpoint, ep as runFlow, Nf as waitRetentionMs };
|