@oomol-lab/open-flow 0.1.0-beta.55 → 0.1.0-beta.57

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 (51) hide show
  1. package/README.md +1 -1
  2. package/dist/browser/{createResourceDialog-4H5_lZ6s.js → createResourceDialog-C23SBjYd.js} +2 -2
  3. package/dist/browser/flow-authoring-edge.d.ts +3 -3
  4. package/dist/browser/flow-authoring-node.d.ts +30 -46
  5. package/dist/browser/flow-authoring.js +9215 -21030
  6. package/dist/browser/flow-change-schema.d.ts +267 -1
  7. package/dist/browser/flow-change.d.ts +19 -104
  8. package/dist/browser/flow-change.js +154 -298
  9. package/dist/browser/{flowChanges-ZzG-f9cg.js → flowChanges-fBiAeTzR.js} +2347 -2216
  10. package/dist/browser/{flowWorkspace-ChpRaTMX.js → flowWorkspace-MqcEfg7T.js} +118 -293
  11. package/dist/browser/{icons-CdAB9wyS.js → icons-6oQ8Q9Wm.js} +4309 -4454
  12. package/dist/browser/lib-DrKav3HG.js +11403 -0
  13. package/dist/browser/preview.css +1 -1
  14. package/dist/browser/preview.js +9609 -9548
  15. package/dist/browser/ui-idTooltip.d.ts +11 -0
  16. package/dist/browser/ui.d.ts +5 -0
  17. package/dist/browser/ui.js +83 -1
  18. package/dist/browser/workbench.css +1 -1
  19. package/dist/browser/workbench.js +227 -417
  20. package/dist/browser/{workbenchSelect-BRZN4ish.js → workbenchSelect-DpLbIr29.js} +1 -1
  21. package/dist/common/authoring.d.ts +207 -0
  22. package/dist/common/authoringSchema.d.ts +1293 -0
  23. package/dist/common/control-api-conformance.js +1060 -623
  24. package/dist/common/control-api-errors.d.ts +2 -1
  25. package/dist/common/control-api.d.ts +87 -6
  26. package/dist/common/control-api.js +1058 -705
  27. package/dist/common/control-requests.d.ts +128 -0
  28. package/dist/common/control-requests.js +2913 -1145
  29. package/dist/common/decision.js +6337 -6371
  30. package/dist/common/flow-agent.d.ts +1 -1
  31. package/dist/common/flow-connectionUsage.d.ts +1 -2
  32. package/dist/common/flow-encoding.d.ts +2 -4
  33. package/dist/common/flow-encoding.js +131 -182
  34. package/dist/common/flow-graph.d.ts +10 -10
  35. package/dist/common/flow-semantics.d.ts +13 -9
  36. package/dist/common/flow-semantics.js +9051 -9232
  37. package/dist/common/flowInspection.d.ts +3 -21
  38. package/dist/common/integration-trigger.js +8653 -8687
  39. package/dist/common/lib-DrKav3HG.js +11403 -0
  40. package/dist/common/mcp.d.ts +120 -12
  41. package/dist/common/mcp.js +537 -188
  42. package/dist/common/openapi.js +6337 -6371
  43. package/dist/common/poll-trigger.js +8653 -8687
  44. package/dist/common/run-events.js +0 -1
  45. package/dist/common/scheduler.d.ts +3 -9
  46. package/dist/common/scheduler.js +128 -209
  47. package/dist/common/webhook-trigger.js +6337 -6371
  48. package/package.json +7 -1
  49. package/skills/open-flow/SKILL.md +32 -0
  50. package/skills/open-flow/references/flow-authoring.md +356 -0
  51. package/skills/open-flow/references/flow-n8n-conversion.md +196 -0
@@ -1,9 +1,9 @@
1
1
  //#region src/openapi/common/authBindings.ts
2
2
  /** Never allow credentials to enter a Revision as literal node inputs. */
3
3
  function assertOpenApiAuthBindings(document) {
4
- for (const graph of [document.graph, ...Object.values(document.subflows).map((subflow) => subflow.graph)]) for (const node of Object.values(graph.nodes)) {
5
- if (node.kind != "task" || node.taskId == null || document.tasks[node.taskId]?.executor.kind != "openapi") continue;
6
- for (const [handle, mapping] of Object.entries(node.inputs)) if (handle.startsWith("auth.") && (mapping.kind == "value" || mapping.kind == "sources" && mapping.sources.some((source) => source.kind == "flow"))) throw new TypeError("OpenAPI authentication accepts deployment variables and upstream outputs only.");
4
+ for (const node of Object.values(document.graph.nodes)) {
5
+ if (node.kind != "task" || !("executor" in node.task) || node.task.executor.kind != "openapi") continue;
6
+ for (const [handle, mapping] of Object.entries(node.inputs)) if (handle.startsWith("auth.") && mapping.kind == "value") throw new TypeError("OpenAPI authentication accepts deployment variables and upstream outputs only.");
7
7
  }
8
8
  }
9
9
  //#endregion
@@ -2833,6 +2833,9 @@ function handlePipeResult(left, next, ctx) {
2833
2833
  issues: left.issues
2834
2834
  }, ctx);
2835
2835
  }
2836
+ var $ZodPreprocess = /*@__PURE__*/ $constructor("$ZodPreprocess", (inst, def) => {
2837
+ $ZodPipe.init(inst, def);
2838
+ });
2836
2839
  var $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2837
2840
  $ZodType.init(inst, def);
2838
2841
  defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
@@ -5634,7 +5637,7 @@ var ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
5634
5637
  inst.keyType = def.keyType;
5635
5638
  inst.valueType = def.valueType;
5636
5639
  });
5637
- function record(keyType, valueType, params) {
5640
+ function record$1(keyType, valueType, params) {
5638
5641
  if (!valueType || !valueType._zod) return new ZodRecord({
5639
5642
  type: "record",
5640
5643
  keyType: string(),
@@ -5843,6 +5846,10 @@ function pipe(in_, out) {
5843
5846
  out
5844
5847
  });
5845
5848
  }
5849
+ var ZodPreprocess = /*@__PURE__*/ $constructor("ZodPreprocess", (inst, def) => {
5850
+ ZodPipe.init(inst, def);
5851
+ $ZodPreprocess.init(inst, def);
5852
+ });
5846
5853
  var ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
5847
5854
  $ZodReadonly.init(inst, def);
5848
5855
  ZodType.init(inst, def);
@@ -5886,11 +5893,18 @@ function json$1(params) {
5886
5893
  boolean(),
5887
5894
  _null(),
5888
5895
  array(jsonSchema),
5889
- record(string(), jsonSchema)
5896
+ record$1(string(), jsonSchema)
5890
5897
  ]);
5891
5898
  });
5892
5899
  return jsonSchema;
5893
5900
  }
5901
+ function preprocess(fn, schema) {
5902
+ return new ZodPreprocess({
5903
+ type: "pipe",
5904
+ in: transform(fn),
5905
+ out: schema
5906
+ });
5907
+ }
5894
5908
  //#endregion
5895
5909
  //#region src/json-schema-subset/utils.ts
5896
5910
  var nextId = 0;
@@ -8538,7 +8552,7 @@ var isObject = (x) => x !== null && typeof x === "object";
8538
8552
  var isPlainObject = (x) => isObject(x) && !isArray(x);
8539
8553
  var toPlainObject = (x) => isPlainObject(x) ? x : void 0;
8540
8554
  //#endregion
8541
- //#region src/manifest/common/schemaComparer.ts
8555
+ //#region src/flow/common/schemaComparer.ts
8542
8556
  function isStringLikeSchema(value) {
8543
8557
  return toPlainObject(value)?.type === "string";
8544
8558
  }
@@ -8769,7 +8783,7 @@ var webhookMethods = [
8769
8783
  ];
8770
8784
  //#endregion
8771
8785
  //#region src/flow/common/changeSchema.ts
8772
- var currentFlowModelVersion = 5;
8786
+ var currentFlowModelVersion = 6;
8773
8787
  var text = string();
8774
8788
  var json = json$1();
8775
8789
  var strings = array(text);
@@ -8784,24 +8798,15 @@ var group = object({
8784
8798
  collapsed: boolean().optional(),
8785
8799
  group: text
8786
8800
  });
8787
- var nodeSource = object({
8801
+ var source = union([object({
8788
8802
  kind: literal("node"),
8789
8803
  nodeId: text,
8790
8804
  output: text,
8791
8805
  field: text.optional()
8792
- });
8793
- var flowSource = object({
8794
- kind: literal("flow"),
8795
- input: text
8796
- });
8797
- var source = union([
8798
- nodeSource,
8799
- flowSource,
8800
- object({
8801
- kind: literal("binding"),
8802
- bindingId: text
8803
- })
8804
- ]);
8806
+ }), object({
8807
+ kind: literal("binding"),
8808
+ bindingId: text
8809
+ })]);
8805
8810
  var fixedInput = union([object({ kind: literal("unset") }), object({
8806
8811
  kind: literal("value"),
8807
8812
  value: json
@@ -8810,7 +8815,7 @@ var mapping = union([fixedInput, object({
8810
8815
  kind: literal("sources"),
8811
8816
  sources: array(source)
8812
8817
  })]);
8813
- var inputs = record(text, mapping);
8818
+ var inputs = record$1(text, mapping);
8814
8819
  var ports = {
8815
8820
  inputs: array(union([input, group])),
8816
8821
  outputs: array(union([port, group]))
@@ -8887,7 +8892,7 @@ var decisionQuestion = discriminatedUnion("type", [
8887
8892
  criteria: strings
8888
8893
  })
8889
8894
  ]);
8890
- var managed = object({
8895
+ var managedFields = object({
8891
8896
  ...ports,
8892
8897
  name: text,
8893
8898
  executor: union([
@@ -8938,13 +8943,16 @@ var managed = object({
8938
8943
  inputs: array(input.extend({ source: agentInput }))
8939
8944
  })),
8940
8945
  notification: object({
8941
- taskId: text,
8946
+ action: text,
8947
+ connectionId: text.optional(),
8948
+ inputDefinitions: array(input),
8942
8949
  messageHandle: text,
8943
- inputs: record(text, agentValue)
8950
+ inputs: record$1(text, agentValue)
8944
8951
  }).optional()
8945
8952
  })
8946
8953
  ])
8947
- }).transform(limitDecisionTask);
8954
+ });
8955
+ var managed = managedFields.transform(limitDecisionTask);
8948
8956
  var operand = union([object({
8949
8957
  kind: literal("value"),
8950
8958
  value: json.optional(),
@@ -8995,7 +9003,7 @@ var webhookOptions = object({
8995
9003
  allowedOrigins: strings.optional(),
8996
9004
  noResponseBody: never().optional(),
8997
9005
  responseData: text.optional(),
8998
- responseHeaders: record(text, text).optional(),
9006
+ responseHeaders: record$1(text, text).optional(),
8999
9007
  responseStatusCode: number().int().min(200).max(599).optional()
9000
9008
  });
9001
9009
  var webhook = {
@@ -9051,7 +9059,7 @@ var base = {
9051
9059
  var node = union([
9052
9060
  object({
9053
9061
  ...base,
9054
- inputs: record(text, never()),
9062
+ inputs: record$1(text, never()),
9055
9063
  kind: literal("condition"),
9056
9064
  ...condition
9057
9065
  }),
@@ -9061,21 +9069,10 @@ var node = union([
9061
9069
  kind: literal("value"),
9062
9070
  values: array(input)
9063
9071
  }),
9064
- object({
9065
- ...base,
9066
- kind: literal("subflow"),
9067
- subflowId: text
9068
- }),
9069
- object({
9070
- ...base,
9071
- kind: literal("task"),
9072
- task: inline,
9073
- additionalInputs: array(input).optional()
9074
- }),
9075
9072
  object({
9076
9073
  ...base,
9077
9074
  kind: literal("task"),
9078
- taskId: text,
9075
+ task: union([inline, managed]),
9079
9076
  additionalInputs: array(input).optional()
9080
9077
  }),
9081
9078
  strictObject({
@@ -9111,7 +9108,7 @@ var node = union([
9111
9108
  ...trigger,
9112
9109
  kind: literal("poll"),
9113
9110
  connectionId: text.min(1).optional(),
9114
- config: record(text, fixedInput),
9111
+ config: record$1(text, fixedInput),
9115
9112
  definition: object({
9116
9113
  ...definition,
9117
9114
  type: literal("poll")
@@ -9122,7 +9119,7 @@ var node = union([
9122
9119
  ...trigger,
9123
9120
  kind: literal("integration"),
9124
9121
  connectionId: text.min(1).optional(),
9125
- config: record(text, fixedInput),
9122
+ config: record$1(text, fixedInput),
9126
9123
  definition: object({
9127
9124
  ...definition,
9128
9125
  type: literal("integration"),
@@ -9130,10 +9127,10 @@ var node = union([
9130
9127
  })
9131
9128
  })
9132
9129
  ]);
9133
- var target = union([object({ kind: literal("flow") }), object({
9134
- kind: literal("subflow"),
9135
- id: text
9136
- })]);
9130
+ strictObject(condition), strictObject(wait), strictObject(webhook), managedFields.shape.executor.options[0].omit({ kind: true }).strict(), managedFields.shape.executor.options[1].omit({ kind: true }).strict(), managedFields.shape.executor.options[2].omit({ kind: true }).strict(), managedFields.shape.executor.options[3].omit({ kind: true }).strict(), managedFields.shape.executor.options[4].omit({
9131
+ kind: true,
9132
+ notification: true
9133
+ }).strict();
9137
9134
  var edge = object({
9138
9135
  source: text,
9139
9136
  target: text,
@@ -9141,15 +9138,10 @@ var edge = object({
9141
9138
  });
9142
9139
  var at = {
9143
9140
  nodeId: text,
9144
- target
9141
+ target: never().optional()
9145
9142
  };
9146
- var subflow = object({
9147
- name: text,
9148
- inputs: array(input),
9149
- outputs: array(port.extend({ sources: array(union([nodeSource, flowSource])) }))
9150
- });
9151
9143
  var graph = object({
9152
- nodes: record(text, node),
9144
+ nodes: record$1(text, node),
9153
9145
  edges: array(edge).default([])
9154
9146
  });
9155
9147
  var binding = object({
@@ -9161,24 +9153,35 @@ var module = object({
9161
9153
  imports: strings,
9162
9154
  source: text
9163
9155
  });
9164
- var document = object({
9165
- bindings: record(text, binding),
9166
- graph,
9167
- subflows: record(text, subflow.extend({ graph })),
9168
- tasks: record(text, managed)
9169
- });
9156
+ var document = preprocess(rejectRetiredDefinitions, object({
9157
+ bindings: record$1(text, binding),
9158
+ graph
9159
+ }));
9170
9160
  object({
9171
9161
  modelVersion: union([
9172
9162
  literal(2),
9173
9163
  literal(4),
9174
- literal(5)
9164
+ literal(5),
9165
+ literal(6)
9175
9166
  ]),
9176
9167
  document,
9177
- modules: record(text, module)
9168
+ modules: record$1(text, module)
9178
9169
  }).extend({
9179
9170
  kind: literal("open-flow-flow-revision"),
9180
9171
  version: literal(1)
9181
9172
  });
9173
+ function rejectRetiredDefinitions(value) {
9174
+ const candidate = record(value);
9175
+ if (candidate.tasks !== void 0 && (candidate.tasks === null || typeof candidate.tasks !== "object" || Array.isArray(candidate.tasks) || Object.keys(candidate.tasks).length > 0)) throw new TypeError("Independent Task definitions are no longer supported.");
9176
+ if (Object.values(record(record(candidate.graph).nodes)).some((candidateNode) => Object.hasOwn(record(candidateNode), "taskId"))) throw new TypeError("Task references are no longer supported.");
9177
+ const subflows = candidate.subflows;
9178
+ if (subflows !== void 0 && (subflows === null || typeof subflows !== "object" || Array.isArray(subflows) || Object.keys(subflows).length > 0)) throw new TypeError("Subflows are no longer supported.");
9179
+ if (Object.values(record(record(candidate.graph).nodes)).some((candidateNode) => record(candidateNode).kind === "subflow")) throw new TypeError("Subflow nodes are no longer supported.");
9180
+ return value;
9181
+ }
9182
+ function record(value) {
9183
+ return value != null && typeof value == "object" && !Array.isArray(value) ? value : {};
9184
+ }
9182
9185
  var shapes = {
9183
9186
  "graph.trigger.sources.set": {
9184
9187
  nodeId: text,
@@ -9196,17 +9199,22 @@ var shapes = {
9196
9199
  value: text
9197
9200
  },
9198
9201
  "graph.edge.connect": {
9199
- target,
9200
- edge
9202
+ edge,
9203
+ target: never().optional()
9201
9204
  },
9202
9205
  "graph.edge.disconnect": {
9203
- target,
9204
- edge
9206
+ edge,
9207
+ target: never().optional()
9205
9208
  },
9206
9209
  "graph.node.create": {
9207
9210
  ...at,
9208
9211
  node
9209
9212
  },
9213
+ "graph.node.replace": {
9214
+ ...at,
9215
+ before: node,
9216
+ node
9217
+ },
9210
9218
  "graph.node.delete": at,
9211
9219
  "graph.node.field.set": union([
9212
9220
  object({
@@ -9265,13 +9273,11 @@ var shapes = {
9265
9273
  },
9266
9274
  "graph.node.resolution.set": {
9267
9275
  ...at,
9268
- target: object({ kind: literal("flow") }),
9269
9276
  before: object(wait),
9270
9277
  value: object(wait)
9271
9278
  },
9272
9279
  "graph.node.webhook.set": {
9273
9280
  ...at,
9274
- target: object({ kind: literal("flow") }),
9275
9281
  before: object(webhook),
9276
9282
  value: object(webhook)
9277
9283
  },
@@ -9318,50 +9324,10 @@ var shapes = {
9318
9324
  imports: strings,
9319
9325
  source: text
9320
9326
  },
9321
- "subflow.create": {
9322
- subflowId: text,
9323
- subflow: subflow.extend({ graph })
9324
- },
9325
- "subflow.definition.set": {
9326
- subflowId: text,
9327
- before: subflow,
9328
- definition: subflow
9329
- },
9330
- "subflow.delete": { subflowId: text },
9331
- "task.create": {
9332
- taskId: text,
9333
- task: managed
9334
- },
9335
- "task.delete": { taskId: text },
9336
- "task.connector.connection.set": {
9337
- taskId: text,
9338
- before: text.optional(),
9339
- value: text.optional()
9340
- },
9341
- "task.decision.set": {
9342
- taskId: text,
9343
- before: managed,
9344
- value: managed
9345
- },
9346
- "task.openapi.set": {
9347
- taskId: text,
9348
- before: managed,
9349
- value: managed
9350
- },
9351
- "task.agent.set": {
9352
- taskId: text,
9353
- before: managed,
9354
- value: managed
9355
- },
9356
- "task.llm.mode.set": {
9357
- taskId: text,
9358
- before: _enum(["chat", "json"]),
9359
- value: _enum(["chat", "json"])
9360
- },
9361
- "task.name.set": {
9362
- taskId: text,
9363
- before: text,
9364
- value: text
9327
+ "graph.node.task.set": {
9328
+ ...at,
9329
+ before: union([inline, managed]),
9330
+ value: union([inline, managed])
9365
9331
  }
9366
9332
  };
9367
9333
  var variants = new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object({
@@ -9629,30 +9595,6 @@ var FlowChangeError = class extends Error {
9629
9595
  function invalid(message) {
9630
9596
  throw new FlowChangeError(message);
9631
9597
  }
9632
- function selectedGraph(document, target) {
9633
- if (target.kind == "flow") return document.graph;
9634
- const subflow = document.subflows[target.id];
9635
- if (subflow == null) invalid("The target Subflow does not exist.");
9636
- return subflow.graph;
9637
- }
9638
- function replaceGraph(document, target, value) {
9639
- if (target.kind == "flow") return {
9640
- ...document,
9641
- graph: value
9642
- };
9643
- const subflow = document.subflows[target.id];
9644
- if (subflow == null) invalid("The target Subflow does not exist.");
9645
- return {
9646
- ...document,
9647
- subflows: {
9648
- ...document.subflows,
9649
- [target.id]: {
9650
- ...subflow,
9651
- graph: value
9652
- }
9653
- }
9654
- };
9655
- }
9656
9598
  function applyFlowChanges(content, operations) {
9657
9599
  const document = { ...content.document };
9658
9600
  const modules = { ...content.modules };
@@ -9704,29 +9646,29 @@ function applyFlowChanges(content, operations) {
9704
9646
  break;
9705
9647
  }
9706
9648
  case "graph.edge.connect": {
9707
- const graph = selectedGraph(document, operation.target);
9649
+ const graph = document.graph;
9708
9650
  if (graph.nodes[operation.edge.source] == null) invalid("The source Node does not exist.");
9709
9651
  const node = graph.nodes[operation.edge.target];
9710
9652
  if (node == null || !("inputs" in node)) invalid("The target Node does not accept execution dependencies.");
9711
9653
  if (graph.edges.some((edge) => dequal(edge, operation.edge))) invalid("The Nodes are already connected.");
9712
- Object.assign(document, replaceGraph(document, operation.target, {
9654
+ Object.assign(document, { graph: {
9713
9655
  ...graph,
9714
9656
  edges: [...graph.edges, operation.edge]
9715
- }));
9657
+ } });
9716
9658
  break;
9717
9659
  }
9718
9660
  case "graph.edge.disconnect": {
9719
- const graph = selectedGraph(document, operation.target);
9661
+ const graph = document.graph;
9720
9662
  const edges = graph.edges.filter((edge) => !dequal(edge, operation.edge));
9721
9663
  if (edges.length == graph.edges.length) invalid("The Nodes are not connected.");
9722
- Object.assign(document, replaceGraph(document, operation.target, {
9664
+ Object.assign(document, { graph: {
9723
9665
  ...graph,
9724
9666
  edges
9725
- }));
9667
+ } });
9726
9668
  break;
9727
9669
  }
9728
9670
  case "graph.node.additional-inputs.set": {
9729
- const graph = selectedGraph(document, operation.target);
9671
+ const graph = document.graph;
9730
9672
  const node = graph.nodes[operation.nodeId];
9731
9673
  if (node?.kind != "task") invalid("The Task Node does not exist.");
9732
9674
  if (!dequal(node.additionalInputs, operation.before)) invalid("The Task Node inputs changed before this operation was applied.");
@@ -9735,17 +9677,17 @@ function applyFlowChanges(content, operations) {
9735
9677
  ...rest,
9736
9678
  additionalInputs: operation.value
9737
9679
  };
9738
- Object.assign(document, replaceGraph(document, operation.target, {
9680
+ Object.assign(document, { graph: {
9739
9681
  ...graph,
9740
9682
  nodes: {
9741
9683
  ...graph.nodes,
9742
9684
  [operation.nodeId]: updated
9743
9685
  }
9744
- }));
9686
+ } });
9745
9687
  break;
9746
9688
  }
9747
9689
  case "graph.node.condition.set": {
9748
- const graph = selectedGraph(document, operation.target);
9690
+ const graph = document.graph;
9749
9691
  const node = graph.nodes[operation.nodeId];
9750
9692
  if (node?.kind != "condition") invalid("The Condition Node does not exist.");
9751
9693
  if (!dequal(node.cases, operation.before.cases) || node.matchMode != operation.before.matchMode) invalid("The Condition Node changed before this operation was applied.");
@@ -9753,22 +9695,42 @@ function applyFlowChanges(content, operations) {
9753
9695
  ...node,
9754
9696
  ...operation.value
9755
9697
  };
9756
- Object.assign(document, replaceGraph(document, operation.target, {
9698
+ Object.assign(document, { graph: {
9757
9699
  ...graph,
9758
9700
  nodes: {
9759
9701
  ...graph.nodes,
9760
9702
  [operation.nodeId]: updated
9761
9703
  }
9762
- }));
9704
+ } });
9705
+ break;
9706
+ }
9707
+ case "graph.node.replace": {
9708
+ const graph = document.graph;
9709
+ if (!dequal(graph.nodes[operation.nodeId], operation.before)) invalid("The Node changed before this operation was applied.");
9710
+ if (operation.node.kind != operation.before.kind) invalid("Replacing a Node cannot change its kind.");
9711
+ if (operation.node.kind == "task" && "moduleId" in operation.node.task && operation.node.task.capabilities !== void 0) decodeConnectorCapabilities(operation.node.task.capabilities);
9712
+ const name = normalizeNodeName(operation.node.name ?? "");
9713
+ const issue = nodeNameIssue(graph, operation.nodeId, name);
9714
+ if (issue != null) invalid(`Node name is ${issue}.`);
9715
+ const node = name == operation.node.name ? operation.node : {
9716
+ ...operation.node,
9717
+ name
9718
+ };
9719
+ Object.assign(document, { graph: {
9720
+ ...graph,
9721
+ nodes: {
9722
+ ...graph.nodes,
9723
+ [operation.nodeId]: node
9724
+ }
9725
+ } });
9763
9726
  break;
9764
9727
  }
9765
9728
  case "graph.node.create": {
9766
- const graph = selectedGraph(document, operation.target);
9729
+ const graph = document.graph;
9767
9730
  if (graph.nodes[operation.nodeId] != null) invalid("A Node with this ID already exists in the target graph.");
9768
- if (operation.target.kind == "subflow" && !("inputs" in operation.node)) invalid("Trigger Nodes cannot be created inside a Subflow.");
9769
9731
  if (operation.node.kind == "error" && Object.values(graph.nodes).some((node) => node.kind == "error")) invalid("A graph can contain only one Flow Error node.");
9770
9732
  if (operation.node.kind == "manual" && Object.values(graph.nodes).some((node) => node.kind == "manual")) invalid("A graph can contain only one manual Trigger.");
9771
- if (operation.node.kind == "task" && operation.node.task?.capabilities !== void 0) decodeConnectorCapabilities(operation.node.task.capabilities);
9733
+ if (operation.node.kind == "task" && "moduleId" in operation.node.task && operation.node.task.capabilities !== void 0) decodeConnectorCapabilities(operation.node.task.capabilities);
9772
9734
  if (operation.node.name == null) invalid("A Node name cannot be empty.");
9773
9735
  const name = normalizeNodeName(operation.node.name);
9774
9736
  const issue = nodeNameIssue(graph, operation.nodeId, name);
@@ -9778,29 +9740,29 @@ function applyFlowChanges(content, operations) {
9778
9740
  ...operation.node,
9779
9741
  name
9780
9742
  };
9781
- Object.assign(document, replaceGraph(document, operation.target, {
9743
+ Object.assign(document, { graph: {
9782
9744
  ...graph,
9783
9745
  nodes: {
9784
9746
  ...graph.nodes,
9785
9747
  [operation.nodeId]: node
9786
9748
  }
9787
- }));
9749
+ } });
9788
9750
  break;
9789
9751
  }
9790
9752
  case "graph.node.delete": {
9791
- const graph = selectedGraph(document, operation.target);
9753
+ const graph = document.graph;
9792
9754
  if (graph.nodes[operation.nodeId] == null) invalid("The Node does not exist in the target graph.");
9793
9755
  const removed = /* @__PURE__ */ new Set([operation.nodeId]);
9794
9756
  const nodes = Object.fromEntries(Object.entries(graph.nodes).filter(([nodeId]) => !removed.has(nodeId)));
9795
- Object.assign(document, replaceGraph(document, operation.target, {
9757
+ Object.assign(document, { graph: {
9796
9758
  ...graph,
9797
9759
  edges: graph.edges.filter((edge) => !removed.has(edge.source) && !removed.has(edge.target)),
9798
9760
  nodes
9799
- }));
9761
+ } });
9800
9762
  break;
9801
9763
  }
9802
9764
  case "graph.node.field.set": {
9803
- const graph = selectedGraph(document, operation.target);
9765
+ const graph = document.graph;
9804
9766
  const node = graph.nodes[operation.nodeId];
9805
9767
  if (node == null) invalid("The Node does not exist in the target graph.");
9806
9768
  if (operation.field == "connectionId" && node.kind != "poll" && node.kind != "integration") invalid("Only provider Triggers select a node Connection.");
@@ -9815,24 +9777,24 @@ function applyFlowChanges(content, operations) {
9815
9777
  Object.assign(updated, { name });
9816
9778
  } else if (operation.value == null) Reflect.deleteProperty(updated, operation.field);
9817
9779
  else Object.assign(updated, { [operation.field]: operation.value });
9818
- Object.assign(document, replaceGraph(document, operation.target, {
9780
+ Object.assign(document, { graph: {
9819
9781
  ...graph,
9820
9782
  nodes: {
9821
9783
  ...graph.nodes,
9822
9784
  [operation.nodeId]: updated
9823
9785
  }
9824
- }));
9786
+ } });
9825
9787
  break;
9826
9788
  }
9827
9789
  case "graph.node.input.set": {
9828
- const graph = selectedGraph(document, operation.target);
9790
+ const graph = document.graph;
9829
9791
  const node = graph.nodes[operation.nodeId];
9830
9792
  if (node == null || !("inputs" in node)) invalid("The Node does not accept inputs.");
9831
9793
  if (!dequal(nodeInputMappings(node)[operation.handle], operation.before)) invalid("The Node input changed before this operation was applied.");
9832
9794
  const inputs = { ...node.inputs };
9833
9795
  if (operation.value == null) delete inputs[operation.handle];
9834
9796
  else inputs[operation.handle] = operation.value;
9835
- Object.assign(document, replaceGraph(document, operation.target, {
9797
+ Object.assign(document, { graph: {
9836
9798
  ...graph,
9837
9799
  nodes: {
9838
9800
  ...graph.nodes,
@@ -9841,18 +9803,18 @@ function applyFlowChanges(content, operations) {
9841
9803
  inputs
9842
9804
  }
9843
9805
  }
9844
- }));
9806
+ } });
9845
9807
  break;
9846
9808
  }
9847
9809
  case "graph.node.task.capabilities.set": {
9848
- const graph = selectedGraph(document, operation.target);
9810
+ const graph = document.graph;
9849
9811
  const node = graph.nodes[operation.nodeId];
9850
- if (node?.kind != "task" || node.task == null) invalid("The inline Task Node does not exist.");
9812
+ if (node?.kind != "task" || !("moduleId" in node.task)) invalid("The inline Task Node does not exist.");
9851
9813
  if (!dequal(node.task.capabilities, operation.before)) invalid("The inline Task capabilities changed before this operation was applied.");
9852
9814
  const task = { ...node.task };
9853
9815
  if (operation.value === void 0) delete task.capabilities;
9854
9816
  else task.capabilities = decodeConnectorCapabilities(operation.value);
9855
- Object.assign(document, replaceGraph(document, operation.target, {
9817
+ Object.assign(document, { graph: {
9856
9818
  ...graph,
9857
9819
  nodes: {
9858
9820
  ...graph.nodes,
@@ -9861,13 +9823,13 @@ function applyFlowChanges(content, operations) {
9861
9823
  task
9862
9824
  }
9863
9825
  }
9864
- }));
9826
+ } });
9865
9827
  break;
9866
9828
  }
9867
9829
  case "graph.node.task.name.set": {
9868
- const graph = selectedGraph(document, operation.target);
9830
+ const graph = document.graph;
9869
9831
  const node = graph.nodes[operation.nodeId];
9870
- if (node?.kind != "task" || node.task == null) invalid("The inline Task Node does not exist.");
9832
+ if (node?.kind != "task" || !("moduleId" in node.task)) invalid("The inline Task Node does not exist.");
9871
9833
  if (node.task.name != operation.before) invalid("The inline Task name changed before this operation was applied.");
9872
9834
  const updated = {
9873
9835
  ...node,
@@ -9876,19 +9838,19 @@ function applyFlowChanges(content, operations) {
9876
9838
  name: operation.value
9877
9839
  }
9878
9840
  };
9879
- Object.assign(document, replaceGraph(document, operation.target, {
9841
+ Object.assign(document, { graph: {
9880
9842
  ...graph,
9881
9843
  nodes: {
9882
9844
  ...graph.nodes,
9883
9845
  [operation.nodeId]: updated
9884
9846
  }
9885
- }));
9847
+ } });
9886
9848
  break;
9887
9849
  }
9888
9850
  case "graph.node.task.ports.set": {
9889
- const graph = selectedGraph(document, operation.target);
9851
+ const graph = document.graph;
9890
9852
  const node = graph.nodes[operation.nodeId];
9891
- if (node?.kind != "task" || node.task == null) invalid("The inline Task Node does not exist.");
9853
+ if (node?.kind != "task" || !("moduleId" in node.task)) invalid("The inline Task Node does not exist.");
9892
9854
  if (!dequal({
9893
9855
  inputs: node.task.inputs,
9894
9856
  outputs: node.task.outputs
@@ -9901,21 +9863,21 @@ function applyFlowChanges(content, operations) {
9901
9863
  outputs: operation.value.outputs
9902
9864
  }
9903
9865
  };
9904
- Object.assign(document, replaceGraph(document, operation.target, {
9866
+ Object.assign(document, { graph: {
9905
9867
  ...graph,
9906
9868
  nodes: {
9907
9869
  ...graph.nodes,
9908
9870
  [operation.nodeId]: updated
9909
9871
  }
9910
- }));
9872
+ } });
9911
9873
  break;
9912
9874
  }
9913
9875
  case "graph.node.values.set": {
9914
- const graph = selectedGraph(document, operation.target);
9876
+ const graph = document.graph;
9915
9877
  const node = graph.nodes[operation.nodeId];
9916
9878
  if (node?.kind != "value") invalid("The Value Node does not exist.");
9917
9879
  if (!dequal(node.values, operation.before)) invalid("The Value Node changed before this operation was applied.");
9918
- Object.assign(document, replaceGraph(document, operation.target, {
9880
+ Object.assign(document, { graph: {
9919
9881
  ...graph,
9920
9882
  nodes: {
9921
9883
  ...graph.nodes,
@@ -9924,7 +9886,7 @@ function applyFlowChanges(content, operations) {
9924
9886
  values: operation.value
9925
9887
  }
9926
9888
  }
9927
- }));
9889
+ } });
9928
9890
  break;
9929
9891
  }
9930
9892
  case "graph.node.resolution.set": {
@@ -9948,7 +9910,7 @@ function applyFlowChanges(content, operations) {
9948
9910
  break;
9949
9911
  }
9950
9912
  case "graph.node.webhook.set": {
9951
- const graph = selectedGraph(document, operation.target);
9913
+ const graph = document.graph;
9952
9914
  const node = graph.nodes[operation.nodeId];
9953
9915
  if (node?.kind != "webhook") invalid("The Webhook Node does not exist.");
9954
9916
  if (node.method != operation.before.method || !dequal(node.bodyFields, operation.before.bodyFields) || !dequal(node.options, operation.before.options)) invalid("The Webhook Node changed before this operation was applied.");
@@ -9961,13 +9923,13 @@ function applyFlowChanges(content, operations) {
9961
9923
  ...node,
9962
9924
  ...operation.value
9963
9925
  };
9964
- Object.assign(document, replaceGraph(document, operation.target, {
9926
+ Object.assign(document, { graph: {
9965
9927
  ...graph,
9966
9928
  nodes: {
9967
9929
  ...graph.nodes,
9968
9930
  [operation.nodeId]: updated
9969
9931
  }
9970
- }));
9932
+ } });
9971
9933
  break;
9972
9934
  }
9973
9935
  case "graph.trigger.config.set": {
@@ -10040,134 +10002,28 @@ function applyFlowChanges(content, operations) {
10040
10002
  };
10041
10003
  break;
10042
10004
  }
10043
- case "subflow.create":
10044
- if (document.subflows[operation.subflowId] != null) invalid("A Subflow with this ID already exists.");
10045
- for (const node of Object.values(operation.subflow.graph.nodes)) if (node.kind == "task" && node.task?.capabilities !== void 0) decodeConnectorCapabilities(node.task.capabilities);
10046
- document.subflows = {
10047
- ...document.subflows,
10048
- [operation.subflowId]: operation.subflow
10049
- };
10050
- break;
10051
- case "subflow.definition.set": {
10052
- const subflow = document.subflows[operation.subflowId];
10053
- if (subflow == null) invalid("The Subflow does not exist.");
10054
- if (!dequal({
10055
- inputs: subflow.inputs,
10056
- name: subflow.name,
10057
- outputs: subflow.outputs
10058
- }, operation.before)) invalid("The Subflow definition changed before this operation was applied.");
10059
- document.subflows = {
10060
- ...document.subflows,
10061
- [operation.subflowId]: {
10062
- ...operation.definition,
10063
- graph: subflow.graph
10064
- }
10065
- };
10066
- break;
10067
- }
10068
- case "subflow.delete": {
10069
- if (document.subflows[operation.subflowId] == null) invalid("The Subflow does not exist.");
10070
- const subflows = { ...document.subflows };
10071
- delete subflows[operation.subflowId];
10072
- document.subflows = subflows;
10073
- break;
10074
- }
10075
- case "task.create":
10076
- if (document.tasks[operation.taskId] != null) invalid("A Task with this ID already exists.");
10077
- document.tasks = {
10078
- ...document.tasks,
10079
- [operation.taskId]: operation.task
10080
- };
10081
- break;
10082
- case "task.connector.connection.set": {
10083
- const task = document.tasks[operation.taskId];
10084
- if (task == null || !("executor" in task) || task.executor.kind != "connector") invalid("The Connector Task does not exist.");
10085
- if (task.executor.connectionId != operation.before) invalid("The Connector Task connection changed before this operation was applied.");
10086
- const { connectionId: _, ...executor } = task.executor;
10087
- const next = operation.value == null ? executor : {
10088
- ...executor,
10089
- connectionId: operation.value
10090
- };
10091
- document.tasks = {
10092
- ...document.tasks,
10093
- [operation.taskId]: {
10094
- ...task,
10095
- executor: next
10096
- }
10097
- };
10098
- break;
10099
- }
10100
- case "task.delete": {
10101
- if (document.tasks[operation.taskId] == null) invalid("The Task does not exist.");
10102
- const tasks = { ...document.tasks };
10103
- delete tasks[operation.taskId];
10104
- document.tasks = tasks;
10105
- break;
10106
- }
10107
- case "task.decision.set": {
10108
- const task = document.tasks[operation.taskId];
10109
- if (task?.executor.kind != "decision" || operation.value.executor.kind != "decision") invalid("The AI Decision Task does not exist.");
10110
- if (!dequal(task, operation.before)) invalid("The AI Decision Task changed before this operation was applied.");
10111
- document.tasks = {
10112
- ...document.tasks,
10113
- [operation.taskId]: operation.value
10114
- };
10115
- break;
10116
- }
10117
- case "task.openapi.set": {
10118
- const task = document.tasks[operation.taskId];
10119
- if (task?.executor.kind != "openapi" || operation.value.executor.kind != "openapi") invalid("The OpenAPI Task does not exist.");
10120
- if (!dequal(task, operation.before)) invalid("The OpenAPI Task changed before this operation was applied.");
10121
- document.tasks = {
10122
- ...document.tasks,
10123
- [operation.taskId]: operation.value
10124
- };
10125
- break;
10126
- }
10127
- case "task.agent.set": {
10128
- const task = document.tasks[operation.taskId];
10129
- if (task?.executor.kind != "agent" || operation.value.executor.kind != "agent") invalid("The Agent Task does not exist.");
10130
- if (!dequal(task, operation.before)) invalid("The Agent Task changed before this operation was applied.");
10131
- document.tasks = {
10132
- ...document.tasks,
10133
- [operation.taskId]: operation.value
10134
- };
10135
- break;
10136
- }
10137
- case "task.llm.mode.set": {
10138
- const task = document.tasks[operation.taskId];
10139
- if (task == null || !("executor" in task) || task.executor.kind != "llm") invalid("The LLM Task does not exist.");
10140
- if (task.executor.mode != operation.before) invalid("The LLM Task mode changed before this operation was applied.");
10141
- document.tasks = {
10142
- ...document.tasks,
10143
- [operation.taskId]: {
10144
- ...task,
10145
- executor: {
10146
- ...task.executor,
10147
- mode: operation.value
10005
+ case "graph.node.task.set": {
10006
+ const graph = document.graph;
10007
+ const node = graph.nodes[operation.nodeId];
10008
+ if (node?.kind != "task") invalid("The Task Node does not exist.");
10009
+ if (!dequal(node.task, operation.before)) invalid("The Task configuration changed before this operation was applied.");
10010
+ document.graph = {
10011
+ ...graph,
10012
+ nodes: {
10013
+ ...graph.nodes,
10014
+ [operation.nodeId]: {
10015
+ ...node,
10016
+ task: operation.value
10148
10017
  }
10149
10018
  }
10150
10019
  };
10151
10020
  break;
10152
10021
  }
10153
- case "task.name.set": {
10154
- const task = document.tasks[operation.taskId];
10155
- if (task == null) invalid("The Task does not exist.");
10156
- if (task.name != operation.before) invalid("The Task name changed before this operation was applied.");
10157
- document.tasks = {
10158
- ...document.tasks,
10159
- [operation.taskId]: {
10160
- ...task,
10161
- name: operation.value
10162
- }
10163
- };
10164
- break;
10165
- }
10166
10022
  }
10167
10023
  assertOpenApiAuthBindings(document);
10168
10024
  return {
10169
10025
  document,
10170
- modelVersion: 5,
10026
+ modelVersion: 6,
10171
10027
  modules
10172
10028
  };
10173
10029
  }