@oomol-lab/open-flow 0.1.0-beta.5 → 0.1.0-beta.6

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,6 +1,6 @@
1
1
  import { I as e, j as t, t as n } from "./dist-DxahK_I8.js";
2
2
  import { r } from "./dist-BKuSVKCC.js";
3
- import { r as i } from "./flowWorkspace-VnS8nLMT.js";
3
+ import { r as i } from "./flowWorkspace-CPBHm14t.js";
4
4
  //#region ../../node_modules/.bun/@uiw+codemirror-themes@4.25.11/node_modules/@uiw/codemirror-themes/esm/index.js
5
5
  var a = (e) => {
6
6
  var i = e.theme, a = e.settings, o = a === void 0 ? {} : a, s = e.styles, c = s === void 0 ? [] : s, l = { ".cm-gutters": {} }, u = {};
@@ -629,6 +629,12 @@ function _(e, t, n) {
629
629
  node: {
630
630
  actions: ["continue"],
631
631
  concurrency: 1,
632
+ input: {
633
+ handle: "value",
634
+ jsonSchema: {},
635
+ nullable: !0,
636
+ value: null
637
+ },
632
638
  inputs: { value: {
633
639
  kind: "value",
634
640
  value: null
@@ -66,6 +66,7 @@ export interface ValueNode extends GraphNodeBase {
66
66
  export type WaitAction = 'approve' | 'continue' | 'reject';
67
67
  export interface WaitNode extends GraphNodeBase {
68
68
  readonly actions: readonly ['continue'] | readonly ['approve', 'reject'];
69
+ readonly input: InputPort;
69
70
  readonly kind: 'wait';
70
71
  readonly notification?: {
71
72
  readonly inputs: Readonly<Record<string, InputMapping>>;
@@ -73,6 +74,7 @@ export interface WaitNode extends GraphNodeBase {
73
74
  readonly taskId: string;
74
75
  };
75
76
  readonly prompt: string;
77
+ readonly timeoutMs?: never;
76
78
  }
77
79
  export type ConditionOperator = '!=' | '<' | '<=' | '==' | '>' | '>=' | 'contains' | 'endsWith' | 'hasKey' | 'hasValue' | 'isEmpty' | 'isFalse' | 'isNotEmpty' | 'isNotNull' | 'isNull' | 'isTrue' | 'notContains' | 'notHasKey' | 'notHasValue' | 'startsWith';
78
80
  export interface ConditionExpression {
@@ -1657,7 +1657,7 @@ var tt = class {
1657
1657
  value: "值",
1658
1658
  valueDescription: "为下游节点提供可复用的字面量。",
1659
1659
  wait: "等待",
1660
- waitDescription: "暂停 Run,直到 Operator 继续或审批。",
1660
+ waitDescription: "暂停 Run,直到 Operator 继续、审批或拒绝。",
1661
1661
  webhook: "Webhook",
1662
1662
  webhookDescription: "通过专属 HTTP 入口接收外部事件。"
1663
1663
  },
@@ -4089,7 +4089,7 @@ var tt = class {
4089
4089
  value: "Значение",
4090
4090
  valueDescription: "Передавать нижестоящим узлам переиспользуемые литеральные значения.",
4091
4091
  wait: "Ожидание",
4092
- waitDescription: "Приостановить Run, пока оператор не продолжит или не одобрит его.",
4092
+ waitDescription: "Приостановить Run, пока оператор не продолжит, не одобрит или не отклонит его.",
4093
4093
  webhook: "Webhook",
4094
4094
  webhookDescription: "Получать внешние события через выделенный HTTP-адрес."
4095
4095
  },
@@ -5610,6 +5610,12 @@ function At(e, t, n) {
5610
5610
  node: {
5611
5611
  actions: ["continue"],
5612
5612
  concurrency: 1,
5613
+ input: {
5614
+ handle: "value",
5615
+ jsonSchema: {},
5616
+ nullable: !0,
5617
+ value: null
5618
+ },
5613
5619
  inputs: { value: {
5614
5620
  kind: "value",
5615
5621
  value: null
@@ -6351,7 +6357,7 @@ var mn = class {
6351
6357
  }
6352
6358
  async cancel() {
6353
6359
  let e = this.#o.value.run;
6354
- if (!pn(e) || this.#o.value.cancelingRunId != null) return;
6360
+ if (!pn(e) || this.#o.value.cancelingRunId != null || this.#o.value.resolvingAction != null) return;
6355
6361
  let t = this.#e.begin();
6356
6362
  this.#a(void 0), this.#p({ cancelingRunId: e.runId });
6357
6363
  try {
@@ -6375,7 +6381,7 @@ var mn = class {
6375
6381
  }
6376
6382
  async resolve(e) {
6377
6383
  let t = this.#o.value.run, n = t?.status == "waiting" && "waiting" in t ? t.waiting : void 0;
6378
- if (!(t == null || n == null || this.#o.value.resolvingAction != null || !n.actions.some((t) => t == e))) {
6384
+ if (!(t == null || n == null || this.#o.value.cancelingRunId != null || this.#o.value.resolvingAction != null || !n.actions.some((t) => t == e))) {
6379
6385
  this.#a(void 0), this.#p({ resolvingAction: e });
6380
6386
  try {
6381
6387
  let r = await this.#t.resolveRunWait(t.runId, n.waitId, e), i = this.#o.value.run;
@@ -10498,17 +10504,21 @@ function Ga(e) {
10498
10504
  nullable: t.nullable
10499
10505
  });
10500
10506
  break;
10501
- case "wait":
10502
- t.set("value", {
10503
- defaultValue: null,
10504
- jsonSchema: {},
10505
- nullable: !0
10507
+ case "wait": {
10508
+ let r = e.node.input;
10509
+ t.set(r.handle, {
10510
+ defaultValue: r.value,
10511
+ description: r.description,
10512
+ jsonSchema: r.jsonSchema,
10513
+ nullable: r.nullable
10506
10514
  });
10507
10515
  for (let t of e.node.actions) n.set(t, {
10508
- jsonSchema: {},
10509
- nullable: !0
10516
+ description: r.description,
10517
+ jsonSchema: r.jsonSchema,
10518
+ nullable: r.nullable
10510
10519
  });
10511
10520
  break;
10521
+ }
10512
10522
  case "subflow": {
10513
10523
  let r = e.definition;
10514
10524
  for (let e of r?.inputs ?? []) t.set(e.handle, {
@@ -10588,7 +10598,9 @@ function qa(e, t, n) {
10588
10598
  }
10589
10599
  function Ja(e, t, n, r) {
10590
10600
  if (t.kind != "flow" || n?.flowId != e.revision.flowId || n.revisionId != e.revision.revisionId) return { nodes: /* @__PURE__ */ new Map() };
10591
- let i = n.status == "queued" || n.status == "starting" || n.status == "running" || n.status == "waiting", a = /* @__PURE__ */ new Map(), o = r.find((t) => t.kind == "run.started" && t.payload.flowId == e.revision.flowId)?.payload.scopeId;
10601
+ let i = n.status == "queued" || n.status == "starting" || n.status == "running" || n.status == "waiting", a = /* @__PURE__ */ new Map();
10602
+ n.status == "waiting" && "waiting" in n && n.waiting != null && a.set(n.waiting.nodeId, { status: "waiting" });
10603
+ let o = r.find((t) => t.kind == "run.started" && t.payload.flowId == e.revision.flowId)?.payload.scopeId;
10592
10604
  if (typeof o != "string") return {
10593
10605
  nodes: a,
10594
10606
  status: i ? "running" : "idle"
@@ -10628,13 +10640,6 @@ function Ja(e, t, n, r) {
10628
10640
  });
10629
10641
  }
10630
10642
  }
10631
- if (n.status == "waiting" && "waiting" in n && n.waiting != null) {
10632
- let e = a.get(n.waiting.nodeId);
10633
- a.set(n.waiting.nodeId, {
10634
- ...e,
10635
- status: "waiting"
10636
- });
10637
- }
10638
10643
  if (!i) for (let [e, t] of a) (t.status == "running" || t.status == "waiting") && a.set(e, {
10639
10644
  ...t,
10640
10645
  status: "idle"
@@ -11504,7 +11509,7 @@ function Ro(e, t, n, r, i) {
11504
11509
  case "code": return Tt(t, {
11505
11510
  moduleId: n,
11506
11511
  nodeId: n
11507
- }, r.name);
11512
+ }, r.name, void 0, r.ports);
11508
11513
  case "llm": return Dt(t, {
11509
11514
  nodeId: n,
11510
11515
  taskId: i()
@@ -11760,7 +11765,7 @@ function Jo(e, t, n, i) {
11760
11765
  defaultOutput: o.defaultOutput,
11761
11766
  input: o.input
11762
11767
  };
11763
- r(e, i) || f.push({
11768
+ (!r(o.cases, i.cases) || o.defaultOutput != i.defaultOutput || !r(o.input, i.input)) && f.push({
11764
11769
  before: e,
11765
11770
  kind: "graph.node.condition.set",
11766
11771
  nodeId: n,
@@ -11817,22 +11822,53 @@ function Xo(e, t, n, i) {
11817
11822
  target: t,
11818
11823
  value: c
11819
11824
  });
11820
- for (let [e, r] of Object.entries(a.nodes)) if (e != n && "inputs" in r) for (let [i, a] of Object.entries(r.inputs)) {
11821
- if (a.kind != "sources") continue;
11822
- let r = a.sources.filter((e) => e.kind != "node" || e.nodeId != n || l.has(e.output));
11823
- r.length != a.sources.length && u.push({
11824
- before: a,
11825
- handle: i,
11826
- kind: "graph.node.input.set",
11827
- nodeId: e,
11828
- target: t,
11829
- value: r.length == 0 ? void 0 : {
11825
+ for (let [e, i] of Object.entries(a.nodes)) {
11826
+ if (e == n || !("inputs" in i)) continue;
11827
+ for (let [r, a] of Object.entries(i.inputs)) {
11828
+ if (a.kind != "sources") continue;
11829
+ let i = a.sources.filter((e) => e.kind != "node" || e.nodeId != n || l.has(e.output));
11830
+ i.length != a.sources.length && u.push({
11831
+ before: a,
11832
+ handle: r,
11833
+ kind: "graph.node.input.set",
11834
+ nodeId: e,
11835
+ target: t,
11836
+ value: i.length == 0 ? void 0 : {
11837
+ kind: "sources",
11838
+ sources: i
11839
+ }
11840
+ });
11841
+ }
11842
+ if (i.kind != "wait" || i.notification == null) continue;
11843
+ let a = { ...i.notification.inputs };
11844
+ for (let [e, t] of Object.entries(a)) {
11845
+ if (t.kind != "sources") continue;
11846
+ let r = t.sources.filter((e) => e.kind != "node" || e.nodeId != n || l.has(e.output));
11847
+ r.length != t.sources.length && (r.length == 0 ? delete a[e] : a[e] = {
11830
11848
  kind: "sources",
11831
11849
  sources: r
11850
+ });
11851
+ }
11852
+ r(a, i.notification.inputs) || u.push({
11853
+ before: {
11854
+ actions: i.actions,
11855
+ notification: i.notification,
11856
+ prompt: i.prompt
11857
+ },
11858
+ kind: "graph.node.wait.set",
11859
+ nodeId: e,
11860
+ target: t,
11861
+ value: {
11862
+ actions: i.actions,
11863
+ notification: {
11864
+ ...i.notification,
11865
+ inputs: a
11866
+ },
11867
+ prompt: i.prompt
11832
11868
  }
11833
11869
  });
11834
11870
  }
11835
- if (u.length != 0) return Io(e, D(e.revision.content, u), o.notification?.taskId == i.notification?.taskId ? void 0 : o.notification?.taskId);
11871
+ return u.length == 0 ? [] : Io(e, D(e.revision.content, u), o.notification?.taskId == i.notification?.taskId ? void 0 : o.notification?.taskId);
11836
11872
  }
11837
11873
  function Zo(e, t, n, r) {
11838
11874
  let i = e.graph({ kind: "flow" })?.nodes[t], a = Fo(n);