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

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,7 +1,7 @@
1
1
  import { a as e } from "./main-DmjVyuWr.js";
2
2
  import { At as t, B as n, Ct as r, F as i, In as a, Kn as o, L as s, M as c, Mt as l, On as u, P as d, Pt as f, Qn as p, R as m, Rt as h, Tt as g, Un as _, V as v, Vn as y, W as b, Z as x, Zt as S, c as C, en as w, et as T, i as E, jt as D, kn as ee, lt as O, n as te, nt as k, o as ne, p as A, sr as j, tr as M, x as N, z as P } from "./getPseudoElementBounds-5LArT6Xc.js";
3
- import { c as F, d as re, f as I, l as L, o as ie, t as ae, u as oe } from "./icons-CRxvozBE.js";
4
- import { t as se } from "./workbenchSelect-Cf1zlVm9.js";
3
+ import { c as F, d as re, f as I, l as L, o as ie, t as ae, u as oe } from "./icons-KIOgjHpD.js";
4
+ import { t as se } from "./workbenchSelect-CbXrdwxW.js";
5
5
  import * as R from "react";
6
6
  import { useEffect as ce, useRef as z, useState as le } from "react";
7
7
  import { Fragment as ue, jsx as B, jsxs as V } from "react/jsx-runtime";
@@ -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-DnsRkjYz.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 = {};
@@ -41,14 +41,18 @@ function i(e, t) {
41
41
  }
42
42
  //#endregion
43
43
  //#region src/flow/common/change.ts
44
- var a = class extends Error {};
45
- function o() {
46
- throw new a();
44
+ var a = class extends Error {
45
+ constructor(e) {
46
+ super(e), this.name = "FlowChangeError";
47
+ }
48
+ };
49
+ function o(e) {
50
+ throw new a(e);
47
51
  }
48
52
  function s(e, t) {
49
53
  if (t.kind == "flow") return e.graph;
50
54
  let n = e.subflows[t.id];
51
- return n ?? o(), n.graph;
55
+ return n ?? o("The target Subflow does not exist."), n.graph;
52
56
  }
53
57
  function c(e, t, n) {
54
58
  if (t.kind == "flow") return {
@@ -56,7 +60,7 @@ function c(e, t, n) {
56
60
  graph: n
57
61
  };
58
62
  let r = e.subflows[t.id];
59
- return r ?? o(), {
63
+ return r ?? o("The target Subflow does not exist."), {
60
64
  ...e,
61
65
  subflows: {
62
66
  ...e.subflows,
@@ -87,20 +91,20 @@ function u(e, t) {
87
91
  let n = { ...e.document }, r = { ...e.modules };
88
92
  for (let e of t) switch (e.kind) {
89
93
  case "binding.create":
90
- n.bindings[e.bindingId] != null && o(), n.bindings = {
94
+ n.bindings[e.bindingId] != null && o("A Binding with this ID already exists."), n.bindings = {
91
95
  ...n.bindings,
92
96
  [e.bindingId]: e.binding
93
97
  };
94
98
  break;
95
99
  case "binding.delete": {
96
- n.bindings[e.bindingId] ?? o();
100
+ n.bindings[e.bindingId] ?? o("The Binding does not exist.");
97
101
  let t = { ...n.bindings };
98
102
  delete t[e.bindingId], n.bindings = t;
99
103
  break;
100
104
  }
101
105
  case "binding.target.set": {
102
106
  let t = n.bindings[e.bindingId];
103
- (t == null || t.target != e.before) && o(), n.bindings = {
107
+ t ?? o("The Binding does not exist."), t.target != e.before && o("The Binding target changed before this operation was applied."), n.bindings = {
104
108
  ...n.bindings,
105
109
  [e.bindingId]: {
106
110
  ...t,
@@ -111,17 +115,17 @@ function u(e, t) {
111
115
  }
112
116
  case "graph.edge.connect": {
113
117
  let t = s(n, e.target);
114
- t.nodes[e.edge.source] ?? o();
118
+ t.nodes[e.edge.source] ?? o("The source Node does not exist.");
115
119
  let r = t.nodes[e.edge.target];
116
- (r == null || !("inputs" in r)) && o();
120
+ (r == null || !("inputs" in r)) && o("The target Node does not accept inputs.");
117
121
  let a = r.inputs[e.edge.targetHandle];
118
- i(a, e.before) || o();
122
+ i(a, e.before) || o("The target input changed before this operation was applied.");
119
123
  let l = {
120
124
  kind: "node",
121
125
  nodeId: e.edge.source,
122
126
  output: e.edge.sourceHandle
123
127
  }, u = a?.kind == "sources" ? a.sources.filter((e) => e.kind != "binding" || n.bindings[e.bindingId]?.kind != "variable") : [];
124
- u.some((e) => e.kind == "node" && e.nodeId == l.nodeId && e.output == l.output) && o();
128
+ u.some((e) => e.kind == "node" && e.nodeId == l.nodeId && e.output == l.output) && o("The Nodes are already connected.");
125
129
  let d = {
126
130
  ...r,
127
131
  inputs: {
@@ -140,11 +144,11 @@ function u(e, t) {
140
144
  }
141
145
  case "graph.edge.disconnect": {
142
146
  let t = s(n, e.target), r = t.nodes[e.edge.target];
143
- (r == null || !("inputs" in r)) && o();
147
+ (r == null || !("inputs" in r)) && o("The target Node does not accept inputs.");
144
148
  let a = r.inputs[e.edge.targetHandle];
145
- (a?.kind != "sources" || !i(a, e.before)) && o();
149
+ (a?.kind != "sources" || !i(a, e.before)) && o("The target input changed before this operation was applied.");
146
150
  let l = a.sources.filter((t) => t.kind != "node" || t.nodeId != e.edge.source || t.output != e.edge.sourceHandle);
147
- l.length == a.sources.length && o();
151
+ l.length == a.sources.length && o("The Nodes are not connected.");
148
152
  let u = { ...r.inputs };
149
153
  l.length == 0 ? delete u[e.edge.targetHandle] : u[e.edge.targetHandle] = {
150
154
  kind: "sources",
@@ -160,7 +164,7 @@ function u(e, t) {
160
164
  }
161
165
  case "graph.node.additional-inputs.set": {
162
166
  let t = s(n, e.target), r = t.nodes[e.nodeId];
163
- (r?.kind != "task" || !i(r.additionalInputs, e.before)) && o();
167
+ r?.kind != "task" && o("The Task Node does not exist."), i(r.additionalInputs, e.before) || o("The Task Node inputs changed before this operation was applied.");
164
168
  let { additionalInputs: a, ...l } = r, u = e.value == null ? l : {
165
169
  ...l,
166
170
  additionalInputs: e.value
@@ -173,7 +177,7 @@ function u(e, t) {
173
177
  }
174
178
  case "graph.node.condition.set": {
175
179
  let t = s(n, e.target), r = t.nodes[e.nodeId];
176
- r?.kind != "condition" && o(), (!i(r.cases, e.before.cases) || r.defaultOutput != e.before.defaultOutput || !i(r.input, e.before.input)) && o();
180
+ r?.kind != "condition" && o("The Condition Node does not exist."), (!i(r.cases, e.before.cases) || r.defaultOutput != e.before.defaultOutput || !i(r.input, e.before.input)) && o("The Condition Node changed before this operation was applied.");
177
181
  let { defaultOutput: a, ...l } = r, u = e.value.defaultOutput == null ? {
178
182
  ...l,
179
183
  ...e.value
@@ -189,7 +193,7 @@ function u(e, t) {
189
193
  }
190
194
  case "graph.node.create": {
191
195
  let t = s(n, e.target);
192
- (t.nodes[e.nodeId] != null || e.target.kind == "subflow" && !("inputs" in e.node)) && o(), Object.assign(n, c(n, e.target, { nodes: {
196
+ t.nodes[e.nodeId] != null && o("A Node with this ID already exists in the target graph."), e.target.kind == "subflow" && !("inputs" in e.node) && o("Trigger Nodes cannot be created inside a Subflow."), Object.assign(n, c(n, e.target, { nodes: {
193
197
  ...t.nodes,
194
198
  [e.nodeId]: e.node
195
199
  } }));
@@ -197,7 +201,7 @@ function u(e, t) {
197
201
  }
198
202
  case "graph.node.delete": {
199
203
  let t = s(n, e.target);
200
- t.nodes[e.nodeId] ?? o();
204
+ t.nodes[e.nodeId] ?? o("The Node does not exist in the target graph.");
201
205
  let r = /* @__PURE__ */ new Set([e.nodeId]), i = Object.fromEntries(Object.entries(t.nodes).flatMap(([e, t]) => r.has(e) ? [] : [[e, l(t, r)]]));
202
206
  if (Object.assign(n, c(n, e.target, { nodes: i })), e.target.kind == "subflow") {
203
207
  let t = n.subflows[e.target.id], i = t.outputs.map((e) => ({
@@ -216,7 +220,7 @@ function u(e, t) {
216
220
  }
217
221
  case "graph.node.field.set": {
218
222
  let t = s(n, e.target), r = t.nodes[e.nodeId];
219
- (r == null || !i(Reflect.get(r, e.field), e.before)) && o(), e.field == "concurrency" && e.value == null && o();
223
+ r ?? o("The Node does not exist in the target graph."), i(Reflect.get(r, e.field), e.before) || o("The Node field changed before this operation was applied."), e.field == "concurrency" && e.value == null && o("Node concurrency cannot be removed.");
220
224
  let a = { ...r };
221
225
  e.value == null ? Reflect.deleteProperty(a, e.field) : Object.assign(a, { [e.field]: e.value }), Object.assign(n, c(n, e.target, { nodes: {
222
226
  ...t.nodes,
@@ -226,7 +230,7 @@ function u(e, t) {
226
230
  }
227
231
  case "graph.node.input.set": {
228
232
  let t = s(n, e.target), r = t.nodes[e.nodeId];
229
- (r == null || !("inputs" in r) || !i(r.inputs[e.handle], e.before)) && o();
233
+ (r == null || !("inputs" in r)) && o("The Node does not accept inputs."), i(r.inputs[e.handle], e.before) || o("The Node input changed before this operation was applied.");
230
234
  let a = { ...r.inputs };
231
235
  e.value == null ? delete a[e.handle] : a[e.handle] = e.value, Object.assign(n, c(n, e.target, { nodes: {
232
236
  ...t.nodes,
@@ -239,7 +243,7 @@ function u(e, t) {
239
243
  }
240
244
  case "graph.node.task.name.set": {
241
245
  let t = s(n, e.target), r = t.nodes[e.nodeId];
242
- (r?.kind != "task" || r.task == null || r.task.name != e.before) && o();
246
+ (r?.kind != "task" || r.task == null) && o("The inline Task Node does not exist."), r.task.name != e.before && o("The inline Task name changed before this operation was applied.");
243
247
  let i = {
244
248
  ...r,
245
249
  task: {
@@ -255,10 +259,10 @@ function u(e, t) {
255
259
  }
256
260
  case "graph.node.task.ports.set": {
257
261
  let t = s(n, e.target), r = t.nodes[e.nodeId];
258
- (r?.kind != "task" || r.task == null || !i({
262
+ (r?.kind != "task" || r.task == null) && o("The inline Task Node does not exist."), i({
259
263
  inputs: r.task.inputs,
260
264
  outputs: r.task.outputs
261
- }, e.before)) && o();
265
+ }, e.before) || o("The inline Task ports changed before this operation was applied.");
262
266
  let a = {
263
267
  ...r,
264
268
  task: {
@@ -274,7 +278,7 @@ function u(e, t) {
274
278
  }
275
279
  case "graph.node.values.set": {
276
280
  let t = s(n, e.target), r = t.nodes[e.nodeId];
277
- (r?.kind != "value" || !i(r.values, e.before)) && o(), Object.assign(n, c(n, e.target, { nodes: {
281
+ r?.kind != "value" && o("The Value Node does not exist."), i(r.values, e.before) || o("The Value Node changed before this operation was applied."), Object.assign(n, c(n, e.target, { nodes: {
278
282
  ...t.nodes,
279
283
  [e.nodeId]: {
280
284
  ...r,
@@ -289,7 +293,7 @@ function u(e, t) {
289
293
  actions: r.actions,
290
294
  ...r.notification == null ? {} : { notification: r.notification },
291
295
  prompt: r.prompt
292
- }, e.before)) && o();
296
+ }, e.before)) && o("The Wait Node changed before this operation was applied.");
293
297
  let { notification: a, ...s } = r, c = e.value.notification == null ? {
294
298
  ...s,
295
299
  ...e.value
@@ -305,7 +309,7 @@ function u(e, t) {
305
309
  }
306
310
  case "graph.node.webhook.set": {
307
311
  let t = s(n, e.target), r = t.nodes[e.nodeId];
308
- (r?.kind != "webhook" || !i(r.inputsDef, e.before.inputsDef) || !i(r.options, e.before.options)) && o();
312
+ r?.kind != "webhook" && o("The Webhook Node does not exist."), (!i(r.inputsDef, e.before.inputsDef) || !i(r.options, e.before.options)) && o("The Webhook Node changed before this operation was applied.");
309
313
  let { options: a, ...l } = r, u = e.value.options == null ? {
310
314
  ...l,
311
315
  inputsDef: e.value.inputsDef
@@ -321,7 +325,7 @@ function u(e, t) {
321
325
  }
322
326
  case "graph.trigger.config.set": {
323
327
  let t = n.graph, r = t.nodes[e.nodeId];
324
- (r == null || r.kind != "integration" && r.kind != "poll" || !i(r.config[e.name], e.before)) && o();
328
+ (r == null || r.kind != "integration" && r.kind != "poll") && o("The configurable Trigger Node does not exist."), i(r.config[e.name], e.before) || o("The Trigger configuration changed before this operation was applied.");
325
329
  let a = { ...r.config };
326
330
  e.value === void 0 ? delete a[e.name] : a[e.name] = e.value, n.graph = { nodes: {
327
331
  ...t.nodes,
@@ -334,7 +338,7 @@ function u(e, t) {
334
338
  }
335
339
  case "graph.trigger.schedule.set": {
336
340
  let t = n.graph, r = t.nodes[e.nodeId];
337
- (r == null || r.kind != "cron" && r.kind != "poll") && o(), i(r.kind == "cron" ? r.cronTimes : r.pollTimes, e.before) || o();
341
+ (r == null || r.kind != "cron" && r.kind != "poll") && o("The scheduled Trigger Node does not exist."), i(r.kind == "cron" ? r.cronTimes : r.pollTimes, e.before) || o("The Trigger schedule changed before this operation was applied.");
338
342
  let a = r.kind == "cron" ? {
339
343
  ...r,
340
344
  cronTimes: e.value
@@ -349,14 +353,14 @@ function u(e, t) {
349
353
  break;
350
354
  }
351
355
  case "module.create":
352
- r[e.moduleId] != null && o(), r[e.moduleId] = e.module;
356
+ r[e.moduleId] != null && o("A CodeModule with this ID already exists."), r[e.moduleId] = e.module;
353
357
  break;
354
358
  case "module.delete":
355
- r[e.moduleId] ?? o(), delete r[e.moduleId];
359
+ r[e.moduleId] ?? o("The CodeModule does not exist."), delete r[e.moduleId];
356
360
  break;
357
361
  case "module.rename": {
358
362
  let t = r[e.moduleId];
359
- (t == null || t.name != e.before) && o(), r[e.moduleId] = {
363
+ t ?? o("The CodeModule does not exist."), t.name != e.before && o("The CodeModule name changed before this operation was applied."), r[e.moduleId] = {
360
364
  ...t,
361
365
  name: e.name
362
366
  };
@@ -364,7 +368,7 @@ function u(e, t) {
364
368
  }
365
369
  case "module.source.replace": {
366
370
  let t = r[e.moduleId];
367
- (t == null || t.source != e.beforeSource || !i(t.imports, e.beforeImports)) && o(), r[e.moduleId] = {
371
+ t ?? o("The CodeModule does not exist."), (t.source != e.beforeSource || !i(t.imports, e.beforeImports)) && o("The CodeModule source changed before this operation was applied."), r[e.moduleId] = {
368
372
  ...t,
369
373
  imports: e.imports,
370
374
  source: e.source
@@ -372,18 +376,18 @@ function u(e, t) {
372
376
  break;
373
377
  }
374
378
  case "subflow.create":
375
- n.subflows[e.subflowId] != null && o(), n.subflows = {
379
+ n.subflows[e.subflowId] != null && o("A Subflow with this ID already exists."), n.subflows = {
376
380
  ...n.subflows,
377
381
  [e.subflowId]: e.subflow
378
382
  };
379
383
  break;
380
384
  case "subflow.definition.set": {
381
385
  let t = n.subflows[e.subflowId];
382
- (t == null || !i({
386
+ t ?? o("The Subflow does not exist."), i({
383
387
  inputs: t.inputs,
384
388
  name: t.name,
385
389
  outputs: t.outputs
386
- }, e.before)) && o(), n.subflows = {
390
+ }, e.before) || o("The Subflow definition changed before this operation was applied."), n.subflows = {
387
391
  ...n.subflows,
388
392
  [e.subflowId]: {
389
393
  ...e.definition,
@@ -393,20 +397,20 @@ function u(e, t) {
393
397
  break;
394
398
  }
395
399
  case "subflow.delete": {
396
- n.subflows[e.subflowId] ?? o();
400
+ n.subflows[e.subflowId] ?? o("The Subflow does not exist.");
397
401
  let t = { ...n.subflows };
398
402
  delete t[e.subflowId], n.subflows = t;
399
403
  break;
400
404
  }
401
405
  case "task.create":
402
- n.tasks[e.taskId] != null && o(), n.tasks = {
406
+ n.tasks[e.taskId] != null && o("A Task with this ID already exists."), n.tasks = {
403
407
  ...n.tasks,
404
408
  [e.taskId]: e.task
405
409
  };
406
410
  break;
407
411
  case "task.connector.connection.set": {
408
412
  let t = n.tasks[e.taskId];
409
- (t == null || !("executor" in t) || t.executor.kind != "connector" || t.executor.connectionId != e.before) && o();
413
+ (t == null || !("executor" in t) || t.executor.kind != "connector") && o("The Connector Task does not exist."), t.executor.connectionId != e.before && o("The Connector Task connection changed before this operation was applied.");
410
414
  let { connectionId: r, ...i } = t.executor, a = e.value == null ? i : {
411
415
  ...i,
412
416
  connectionId: e.value
@@ -421,14 +425,14 @@ function u(e, t) {
421
425
  break;
422
426
  }
423
427
  case "task.delete": {
424
- n.tasks[e.taskId] ?? o();
428
+ n.tasks[e.taskId] ?? o("The Task does not exist.");
425
429
  let t = { ...n.tasks };
426
430
  delete t[e.taskId], n.tasks = t;
427
431
  break;
428
432
  }
429
433
  case "task.llm.mode.set": {
430
434
  let t = n.tasks[e.taskId];
431
- (t == null || !("executor" in t) || t.executor.kind != "llm" || t.executor.mode != e.before) && o(), n.tasks = {
435
+ (t == null || !("executor" in t) || t.executor.kind != "llm") && o("The LLM Task does not exist."), t.executor.mode != e.before && o("The LLM Task mode changed before this operation was applied."), n.tasks = {
432
436
  ...n.tasks,
433
437
  [e.taskId]: {
434
438
  ...t,
@@ -442,7 +446,7 @@ function u(e, t) {
442
446
  }
443
447
  case "task.name.set": {
444
448
  let t = n.tasks[e.taskId];
445
- (t == null || t.name != e.before) && o(), n.tasks = {
449
+ t ?? o("The Task does not exist."), t.name != e.before && o("The Task name changed before this operation was applied."), n.tasks = {
446
450
  ...n.tasks,
447
451
  [e.taskId]: {
448
452
  ...t,
@@ -629,6 +633,12 @@ function _(e, t, n) {
629
633
  node: {
630
634
  actions: ["continue"],
631
635
  concurrency: 1,
636
+ input: {
637
+ handle: "value",
638
+ jsonSchema: {},
639
+ nullable: !0,
640
+ value: null
641
+ },
632
642
  inputs: { value: {
633
643
  kind: "value",
634
644
  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 {
@@ -403,6 +405,7 @@ export type ChangeOperation = {
403
405
  readonly value: string;
404
406
  };
405
407
  export declare class FlowChangeError extends Error {
408
+ constructor(message: string);
406
409
  }
407
410
  export declare function applyFlowChanges(content: RevisionContent, operations: readonly ChangeOperation[]): RevisionContent;
408
411
  export {};