@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
@@ -2796,6 +2796,9 @@ function handlePipeResult(left, next, ctx) {
2796
2796
  issues: left.issues
2797
2797
  }, ctx);
2798
2798
  }
2799
+ var $ZodPreprocess = /*@__PURE__*/ $constructor("$ZodPreprocess", (inst, def) => {
2800
+ $ZodPipe.init(inst, def);
2801
+ });
2799
2802
  var $ZodReadonly = /*@__PURE__*/ $constructor("$ZodReadonly", (inst, def) => {
2800
2803
  $ZodType.init(inst, def);
2801
2804
  defineLazyInternal(inst, "propValues", (zod) => zod.def.innerType._zod.propValues);
@@ -5411,7 +5414,7 @@ var ZodRecord = /*@__PURE__*/ $constructor("ZodRecord", (inst, def) => {
5411
5414
  inst.keyType = def.keyType;
5412
5415
  inst.valueType = def.valueType;
5413
5416
  });
5414
- function record(keyType, valueType, params) {
5417
+ function record$1(keyType, valueType, params) {
5415
5418
  if (!valueType || !valueType._zod) return new ZodRecord({
5416
5419
  type: "record",
5417
5420
  keyType: string(),
@@ -5620,6 +5623,10 @@ function pipe(in_, out) {
5620
5623
  out
5621
5624
  });
5622
5625
  }
5626
+ var ZodPreprocess = /*@__PURE__*/ $constructor("ZodPreprocess", (inst, def) => {
5627
+ ZodPipe.init(inst, def);
5628
+ $ZodPreprocess.init(inst, def);
5629
+ });
5623
5630
  var ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
5624
5631
  $ZodReadonly.init(inst, def);
5625
5632
  ZodType.init(inst, def);
@@ -5663,11 +5670,18 @@ function json$1(params) {
5663
5670
  boolean(),
5664
5671
  _null(),
5665
5672
  array(jsonSchema),
5666
- record(string(), jsonSchema)
5673
+ record$1(string(), jsonSchema)
5667
5674
  ]);
5668
5675
  });
5669
5676
  return jsonSchema;
5670
5677
  }
5678
+ function preprocess(fn, schema) {
5679
+ return new ZodPreprocess({
5680
+ type: "pipe",
5681
+ in: transform(fn),
5682
+ out: schema
5683
+ });
5684
+ }
5671
5685
  //#endregion
5672
5686
  //#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.js
5673
5687
  function deepCompareStrict(a, b) {
@@ -9226,7 +9240,7 @@ var isObject = (x) => x !== null && typeof x === "object";
9226
9240
  var isPlainObject = (x) => isObject(x) && !isArray(x);
9227
9241
  var toPlainObject = (x) => isPlainObject(x) ? x : void 0;
9228
9242
  //#endregion
9229
- //#region src/manifest/common/schemaComparer.ts
9243
+ //#region src/flow/common/schemaComparer.ts
9230
9244
  function isStringLikeSchema(value) {
9231
9245
  return toPlainObject(value)?.type === "string";
9232
9246
  }
@@ -9495,24 +9509,15 @@ var group = object({
9495
9509
  collapsed: boolean().optional(),
9496
9510
  group: text
9497
9511
  });
9498
- var nodeSource = object({
9512
+ var source = union([object({
9499
9513
  kind: literal("node"),
9500
9514
  nodeId: text,
9501
9515
  output: text,
9502
9516
  field: text.optional()
9503
- });
9504
- var flowSource = object({
9505
- kind: literal("flow"),
9506
- input: text
9507
- });
9508
- var source = union([
9509
- nodeSource,
9510
- flowSource,
9511
- object({
9512
- kind: literal("binding"),
9513
- bindingId: text
9514
- })
9515
- ]);
9517
+ }), object({
9518
+ kind: literal("binding"),
9519
+ bindingId: text
9520
+ })]);
9516
9521
  var fixedInput = union([object({ kind: literal("unset") }), object({
9517
9522
  kind: literal("value"),
9518
9523
  value: json
@@ -9521,7 +9526,7 @@ var mapping = union([fixedInput, object({
9521
9526
  kind: literal("sources"),
9522
9527
  sources: array(source)
9523
9528
  })]);
9524
- var inputs = record(text, mapping);
9529
+ var inputs = record$1(text, mapping);
9525
9530
  var ports = {
9526
9531
  inputs: array(union([input, group])),
9527
9532
  outputs: array(union([port, group]))
@@ -9598,7 +9603,7 @@ var decisionQuestion = discriminatedUnion("type", [
9598
9603
  criteria: strings
9599
9604
  })
9600
9605
  ]);
9601
- var managed = object({
9606
+ var managedFields = object({
9602
9607
  ...ports,
9603
9608
  name: text,
9604
9609
  executor: union([
@@ -9649,13 +9654,16 @@ var managed = object({
9649
9654
  inputs: array(input.extend({ source: agentInput$1 }))
9650
9655
  })),
9651
9656
  notification: object({
9652
- taskId: text,
9657
+ action: text,
9658
+ connectionId: text.optional(),
9659
+ inputDefinitions: array(input),
9653
9660
  messageHandle: text,
9654
- inputs: record(text, agentValue)
9661
+ inputs: record$1(text, agentValue)
9655
9662
  }).optional()
9656
9663
  })
9657
9664
  ])
9658
- }).transform(limitDecisionTask);
9665
+ });
9666
+ var managed = managedFields.transform(limitDecisionTask);
9659
9667
  var operand = union([object({
9660
9668
  kind: literal("value"),
9661
9669
  value: json.optional(),
@@ -9706,7 +9714,7 @@ var webhookOptions = object({
9706
9714
  allowedOrigins: strings.optional(),
9707
9715
  noResponseBody: never().optional(),
9708
9716
  responseData: text.optional(),
9709
- responseHeaders: record(text, text).optional(),
9717
+ responseHeaders: record$1(text, text).optional(),
9710
9718
  responseStatusCode: number().int().min(200).max(599).optional()
9711
9719
  });
9712
9720
  var webhook = {
@@ -9762,7 +9770,7 @@ var base = {
9762
9770
  var node = union([
9763
9771
  object({
9764
9772
  ...base,
9765
- inputs: record(text, never()),
9773
+ inputs: record$1(text, never()),
9766
9774
  kind: literal("condition"),
9767
9775
  ...condition
9768
9776
  }),
@@ -9772,21 +9780,10 @@ var node = union([
9772
9780
  kind: literal("value"),
9773
9781
  values: array(input)
9774
9782
  }),
9775
- object({
9776
- ...base,
9777
- kind: literal("subflow"),
9778
- subflowId: text
9779
- }),
9780
9783
  object({
9781
9784
  ...base,
9782
9785
  kind: literal("task"),
9783
- task: inline,
9784
- additionalInputs: array(input).optional()
9785
- }),
9786
- object({
9787
- ...base,
9788
- kind: literal("task"),
9789
- taskId: text,
9786
+ task: union([inline, managed]),
9790
9787
  additionalInputs: array(input).optional()
9791
9788
  }),
9792
9789
  strictObject({
@@ -9822,7 +9819,7 @@ var node = union([
9822
9819
  ...trigger,
9823
9820
  kind: literal("poll"),
9824
9821
  connectionId: text.min(1).optional(),
9825
- config: record(text, fixedInput),
9822
+ config: record$1(text, fixedInput),
9826
9823
  definition: object({
9827
9824
  ...definition,
9828
9825
  type: literal("poll")
@@ -9833,7 +9830,7 @@ var node = union([
9833
9830
  ...trigger,
9834
9831
  kind: literal("integration"),
9835
9832
  connectionId: text.min(1).optional(),
9836
- config: record(text, fixedInput),
9833
+ config: record$1(text, fixedInput),
9837
9834
  definition: object({
9838
9835
  ...definition,
9839
9836
  type: literal("integration"),
@@ -9841,10 +9838,10 @@ var node = union([
9841
9838
  })
9842
9839
  })
9843
9840
  ]);
9844
- var target = union([object({ kind: literal("flow") }), object({
9845
- kind: literal("subflow"),
9846
- id: text
9847
- })]);
9841
+ 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({
9842
+ kind: true,
9843
+ notification: true
9844
+ }).strict();
9848
9845
  var edge = object({
9849
9846
  source: text,
9850
9847
  target: text,
@@ -9852,15 +9849,10 @@ var edge = object({
9852
9849
  });
9853
9850
  var at = {
9854
9851
  nodeId: text,
9855
- target
9852
+ target: never().optional()
9856
9853
  };
9857
- var subflow = object({
9858
- name: text,
9859
- inputs: array(input),
9860
- outputs: array(port.extend({ sources: array(union([nodeSource, flowSource])) }))
9861
- });
9862
9854
  var graph = object({
9863
- nodes: record(text, node),
9855
+ nodes: record$1(text, node),
9864
9856
  edges: array(edge).default([])
9865
9857
  });
9866
9858
  var binding = object({
@@ -9872,24 +9864,35 @@ var module = object({
9872
9864
  imports: strings,
9873
9865
  source: text
9874
9866
  });
9875
- var document = object({
9876
- bindings: record(text, binding),
9877
- graph,
9878
- subflows: record(text, subflow.extend({ graph })),
9879
- tasks: record(text, managed)
9880
- });
9867
+ var document = preprocess(rejectRetiredDefinitions, object({
9868
+ bindings: record$1(text, binding),
9869
+ graph
9870
+ }));
9881
9871
  object({
9882
9872
  modelVersion: union([
9883
9873
  literal(2),
9884
9874
  literal(4),
9885
- literal(5)
9875
+ literal(5),
9876
+ literal(6)
9886
9877
  ]),
9887
9878
  document,
9888
- modules: record(text, module)
9879
+ modules: record$1(text, module)
9889
9880
  }).extend({
9890
9881
  kind: literal("open-flow-flow-revision"),
9891
9882
  version: literal(1)
9892
9883
  });
9884
+ function rejectRetiredDefinitions(value) {
9885
+ const candidate = record(value);
9886
+ 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.");
9887
+ if (Object.values(record(record(candidate.graph).nodes)).some((candidateNode) => Object.hasOwn(record(candidateNode), "taskId"))) throw new TypeError("Task references are no longer supported.");
9888
+ const subflows = candidate.subflows;
9889
+ 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.");
9890
+ if (Object.values(record(record(candidate.graph).nodes)).some((candidateNode) => record(candidateNode).kind === "subflow")) throw new TypeError("Subflow nodes are no longer supported.");
9891
+ return value;
9892
+ }
9893
+ function record(value) {
9894
+ return value != null && typeof value == "object" && !Array.isArray(value) ? value : {};
9895
+ }
9893
9896
  var shapes = {
9894
9897
  "graph.trigger.sources.set": {
9895
9898
  nodeId: text,
@@ -9907,17 +9910,22 @@ var shapes = {
9907
9910
  value: text
9908
9911
  },
9909
9912
  "graph.edge.connect": {
9910
- target,
9911
- edge
9913
+ edge,
9914
+ target: never().optional()
9912
9915
  },
9913
9916
  "graph.edge.disconnect": {
9914
- target,
9915
- edge
9917
+ edge,
9918
+ target: never().optional()
9916
9919
  },
9917
9920
  "graph.node.create": {
9918
9921
  ...at,
9919
9922
  node
9920
9923
  },
9924
+ "graph.node.replace": {
9925
+ ...at,
9926
+ before: node,
9927
+ node
9928
+ },
9921
9929
  "graph.node.delete": at,
9922
9930
  "graph.node.field.set": union([
9923
9931
  object({
@@ -9976,13 +9984,11 @@ var shapes = {
9976
9984
  },
9977
9985
  "graph.node.resolution.set": {
9978
9986
  ...at,
9979
- target: object({ kind: literal("flow") }),
9980
9987
  before: object(wait),
9981
9988
  value: object(wait)
9982
9989
  },
9983
9990
  "graph.node.webhook.set": {
9984
9991
  ...at,
9985
- target: object({ kind: literal("flow") }),
9986
9992
  before: object(webhook),
9987
9993
  value: object(webhook)
9988
9994
  },
@@ -10029,50 +10035,10 @@ var shapes = {
10029
10035
  imports: strings,
10030
10036
  source: text
10031
10037
  },
10032
- "subflow.create": {
10033
- subflowId: text,
10034
- subflow: subflow.extend({ graph })
10035
- },
10036
- "subflow.definition.set": {
10037
- subflowId: text,
10038
- before: subflow,
10039
- definition: subflow
10040
- },
10041
- "subflow.delete": { subflowId: text },
10042
- "task.create": {
10043
- taskId: text,
10044
- task: managed
10045
- },
10046
- "task.delete": { taskId: text },
10047
- "task.connector.connection.set": {
10048
- taskId: text,
10049
- before: text.optional(),
10050
- value: text.optional()
10051
- },
10052
- "task.decision.set": {
10053
- taskId: text,
10054
- before: managed,
10055
- value: managed
10056
- },
10057
- "task.openapi.set": {
10058
- taskId: text,
10059
- before: managed,
10060
- value: managed
10061
- },
10062
- "task.agent.set": {
10063
- taskId: text,
10064
- before: managed,
10065
- value: managed
10066
- },
10067
- "task.llm.mode.set": {
10068
- taskId: text,
10069
- before: _enum(["chat", "json"]),
10070
- value: _enum(["chat", "json"])
10071
- },
10072
- "task.name.set": {
10073
- taskId: text,
10074
- before: text,
10075
- value: text
10038
+ "graph.node.task.set": {
10039
+ ...at,
10040
+ before: union([inline, managed]),
10041
+ value: union([inline, managed])
10076
10042
  }
10077
10043
  };
10078
10044
  array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object({
@@ -10311,8 +10277,8 @@ var schema = lazy(() => union([boolean(), strictObject({
10311
10277
  "https://json-schema.org/draft/2019-09/schema",
10312
10278
  "https://json-schema.org/draft/2020-12/schema"
10313
10279
  ]).optional(),
10314
- $defs: record(string(), schema).optional(),
10315
- definitions: record(string(), schema).optional(),
10280
+ $defs: record$1(string(), schema).optional(),
10281
+ definitions: record$1(string(), schema).optional(),
10316
10282
  pattern: string().refine((value) => {
10317
10283
  try {
10318
10284
  return new RegExp(value, "u").source.length > 0;
@@ -10329,16 +10295,16 @@ var schema = lazy(() => union([boolean(), strictObject({
10329
10295
  minProperties: number().int().nonnegative().optional(),
10330
10296
  maxProperties: number().int().nonnegative().optional(),
10331
10297
  propertyNames: schema.optional(),
10332
- patternProperties: record(string().refine((value) => {
10298
+ patternProperties: record$1(string().refine((value) => {
10333
10299
  try {
10334
10300
  return new RegExp(value, "u").source.length > 0;
10335
10301
  } catch {
10336
10302
  return false;
10337
10303
  }
10338
10304
  }, "Invalid regular expression."), schema).optional(),
10339
- dependentRequired: record(string(), array(string())).optional(),
10340
- dependentSchemas: record(string(), schema).optional(),
10341
- dependencies: record(string(), union([schema, array(string())])).optional(),
10305
+ dependentRequired: record$1(string(), array(string())).optional(),
10306
+ dependentSchemas: record$1(string(), schema).optional(),
10307
+ dependencies: record$1(string(), union([schema, array(string())])).optional(),
10342
10308
  prefixItems: array(schema).optional(),
10343
10309
  additionalItems: schema.optional(),
10344
10310
  unevaluatedItems: schema.optional(),
@@ -10352,7 +10318,7 @@ var schema = lazy(() => union([boolean(), strictObject({
10352
10318
  deprecated: boolean().optional(),
10353
10319
  $comment: string().optional(),
10354
10320
  enum: array(json$1()).min(1).optional(),
10355
- properties: record(string(), schema).optional(),
10321
+ properties: record$1(string(), schema).optional(),
10356
10322
  required: array(string()).optional(),
10357
10323
  additionalProperties: schema.optional(),
10358
10324
  items: union([schema, array(schema)]).optional(),
@@ -10607,12 +10573,11 @@ function resolutionOutputPorts(node) {
10607
10573
  })]))
10608
10574
  };
10609
10575
  }
10610
- function nodeOutputPorts(document, node) {
10576
+ function nodeOutputPorts(node) {
10611
10577
  switch (node.kind) {
10612
10578
  case "condition": return {};
10613
10579
  case "value": return portsByHandle(node.values);
10614
- case "subflow": return portsByHandle(document.subflows[node.subflowId]?.outputs ?? []);
10615
- case "task": return portsByHandle(node.task != null ? node.task.outputs : document.tasks[node.taskId]?.outputs ?? []);
10580
+ case "task": return portsByHandle(node.task.outputs);
10616
10581
  case "approval":
10617
10582
  case "wait": return resolutionOutputPorts(node);
10618
10583
  case "cron":
@@ -10643,30 +10608,28 @@ function nodeFailure(error, project) {
10643
10608
  message: error instanceof Error ? error.message : String(error)
10644
10609
  };
10645
10610
  }
10646
- function nodePorts(prepared, node) {
10611
+ function nodePorts(node) {
10647
10612
  switch (node.kind) {
10648
10613
  case "condition": return conditionInputPorts(node);
10649
10614
  case "value": return {};
10650
- case "subflow": return portsByHandle(prepared.subflows[node.subflowId].inputs);
10651
- case "task": return portsByHandle([...node.task != null ? node.task.inputs : prepared.tasks[node.taskId].inputs, ...node.additionalInputs ?? []]);
10615
+ case "task": return portsByHandle([...node.task.inputs, ...node.additionalInputs ?? []]);
10652
10616
  case "approval":
10653
10617
  case "wait": return portsByHandle(node.inputDefinitions);
10654
10618
  }
10655
10619
  }
10656
- function nodeTitle(prepared, node) {
10620
+ function nodeTitle(node) {
10657
10621
  if (node.name != null) return node.name;
10658
10622
  switch (node.kind) {
10659
10623
  case "condition": return;
10660
10624
  case "value": return "Fixed Values";
10661
- case "subflow": return prepared.subflows[node.subflowId].name;
10662
- case "task": return node.task != null ? node.task.name : prepared.tasks[node.taskId].name;
10625
+ case "task": return node.task.name;
10663
10626
  case "approval": return "Approval";
10664
10627
  case "wait": return "Wait";
10665
10628
  }
10666
10629
  }
10667
- function nodeKind(prepared, node) {
10630
+ function nodeKind(node) {
10668
10631
  if (node.kind != "task") return node.kind;
10669
- return node.task != null ? "javascript" : prepared.tasks[node.taskId].executor.kind;
10632
+ return "moduleId" in node.task ? "javascript" : node.task.executor.kind;
10670
10633
  }
10671
10634
  function checkpointRecord(value, description) {
10672
10635
  if (value == null || typeof value != "object" || Array.isArray(value)) throw new Error(`${description} must be an object.`);
@@ -10692,7 +10655,7 @@ var agentCheckpointSchema = strictObject({
10692
10655
  state: json$1(),
10693
10656
  callId: string().min(1),
10694
10657
  toolId: string().min(1),
10695
- input: record(string(), json$1()),
10658
+ input: record$1(string(), json$1()),
10696
10659
  rounds: number().int().nonnegative(),
10697
10660
  version: literal(1)
10698
10661
  });
@@ -10729,8 +10692,8 @@ function decodeFlowRunCheckpoint(input) {
10729
10692
  outputs: Object.fromEntries(Object.entries(checkpointRecord(result.outputs, "Checkpoint outputs")).map(([handle, item]) => [handle, checkpointJson(item, "Checkpoint output")]))
10730
10693
  }];
10731
10694
  }));
10732
- const counts = record(string(), record(string(), number().int().positive().max(Number.MAX_SAFE_INTEGER))).parse(source.counts);
10733
- const frames = record(string(), record(string(), record(string(), json$1()))).parse(source.frames);
10695
+ const counts = record$1(string(), record$1(string(), number().int().positive().max(Number.MAX_SAFE_INTEGER))).parse(source.counts);
10696
+ const frames = record$1(string(), record$1(string(), record$1(string(), json$1()))).parse(source.frames);
10734
10697
  const savedWaitFields = {
10735
10698
  jobId: string().min(1),
10736
10699
  nodeId: string().min(1),
@@ -10747,9 +10710,9 @@ function decodeFlowRunCheckpoint(input) {
10747
10710
  ...wait,
10748
10711
  pending: notification
10749
10712
  }))])).min(1).parse(source.waits);
10750
- const agents = record(string(), strictObject({
10713
+ const agents = record$1(string(), strictObject({
10751
10714
  invocationId: string().min(1),
10752
- input: record(string(), json$1()),
10715
+ input: record$1(string(), json$1()),
10753
10716
  remainingMs: number().positive().optional(),
10754
10717
  checkpoint: agentCheckpointSchema
10755
10718
  })).parse(source.agents);
@@ -10787,18 +10750,16 @@ function outputRecord(value, nodeId) {
10787
10750
  if (value == null || typeof value != "object" || Array.isArray(value)) throw new Error(`Node "${nodeId}" must return an object.`);
10788
10751
  return value;
10789
10752
  }
10790
- function agentConfig(prepared, node) {
10791
- const task = node.kind == "task" && node.taskId != null ? prepared.tasks[node.taskId] : void 0;
10753
+ function agentConfig(node) {
10754
+ const task = node.kind == "task" && "executor" in node.task ? node.task : void 0;
10792
10755
  return task?.executor.kind == "agent" ? task.executor : void 0;
10793
10756
  }
10794
- function agentNotice(prepared, node, values) {
10795
- const notification = agentConfig(prepared, node)?.notification;
10757
+ function agentNotice(node, values) {
10758
+ const notification = agentConfig(node)?.notification;
10796
10759
  if (notification == null) return void 0;
10797
- const task = prepared.tasks[notification.taskId];
10798
10760
  return {
10799
- taskId: notification.taskId,
10800
10761
  messageHandle: notification.messageHandle,
10801
- input: Object.fromEntries(task.inputs.flatMap((port) => {
10762
+ input: Object.fromEntries(notification.inputDefinitions.flatMap((port) => {
10802
10763
  if (!("handle" in port) || port.handle == notification.messageHandle) return [];
10803
10764
  const source = notification.inputs[port.handle];
10804
10765
  return [[port.handle, source == null ? port.value ?? null : agentInput(source, values)]];
@@ -10822,10 +10783,10 @@ function agentApproval(config, checkpoint, inputs) {
10822
10783
  input: checkpoint.input
10823
10784
  };
10824
10785
  }
10825
- function validateOutputs(prepared, nodeId, node, value) {
10786
+ function validateOutputs(nodeId, node, value) {
10826
10787
  const raw = outputRecord(value, nodeId);
10827
- const discardUndeclared = node.kind == "task" && node.taskId != null && prepared.tasks[node.taskId].executor.kind == "connector";
10828
- const ports = isResolutionNode(node) ? resolutionOutputPorts(node) : node.kind == "task" ? portsByHandle(node.task != null ? node.task.outputs : prepared.tasks[node.taskId].outputs) : node.kind == "subflow" ? portsByHandle(prepared.subflows[node.subflowId].outputs) : node.kind == "value" ? portsByHandle(node.values) : {};
10788
+ const discardUndeclared = node.kind == "task" && "executor" in node.task && node.task.executor.kind == "connector";
10789
+ const ports = isResolutionNode(node) ? resolutionOutputPorts(node) : node.kind == "task" ? portsByHandle(node.task.outputs) : node.kind == "value" ? portsByHandle(node.values) : {};
10829
10790
  const outputs = outputRecord(checkpointJson(Object.fromEntries(Object.entries(raw).map(([handle, item]) => [handle, Object.hasOwn(ports, handle) && item === void 0 ? null : item])), `Node "${nodeId}" outputs`), nodeId);
10830
10791
  const complete = node.kind == "condition" || isResolutionNode(node) ? outputs : {
10831
10792
  ...Object.fromEntries(Object.keys(ports).map((handle) => [handle, null])),
@@ -10843,12 +10804,12 @@ function validateOutputs(prepared, nodeId, node, value) {
10843
10804
  }
10844
10805
  return validated;
10845
10806
  }
10846
- function validateCheckpoint(prepared, target, checkpoint, resolveInputs) {
10807
+ function validateCheckpoint(target, checkpoint, resolveInputs) {
10847
10808
  const launch = checkpoint.inputs;
10848
10809
  const agents = checkpoint.agents;
10849
10810
  if ([...Object.keys(checkpoint.results), ...Object.keys(launch)].some((id) => target.graph.nodes[id] == null)) throw new Error("Checkpoint nodes do not match the prepared graph.");
10850
10811
  for (const [scope, counts] of Object.entries(checkpoint.counts)) {
10851
- const graph = scope == "" ? target.graph : prepared.subflows[scope]?.graph;
10812
+ const graph = scope == "" ? target.graph : void 0;
10852
10813
  if (graph == null) throw new Error("Checkpoint execution counts reference an unknown graph.");
10853
10814
  for (const [id, count] of Object.entries(counts)) {
10854
10815
  const node = graph.nodes[id];
@@ -10863,7 +10824,7 @@ function validateCheckpoint(prepared, target, checkpoint, resolveInputs) {
10863
10824
  if (!matchesTriggerOutputs(node, outputs)) throw new Error("Checkpoint Trigger output is invalid.");
10864
10825
  } else {
10865
10826
  if (checkpoint.counts[""]?.[id] == null) throw new Error("Checkpoint execution count is missing.");
10866
- if (!jsonEqual(validateOutputs(prepared, id, node, outputs), outputs)) throw new Error("Checkpoint node outputs are incomplete.");
10827
+ if (!jsonEqual(validateOutputs(id, node, outputs), outputs)) throw new Error("Checkpoint node outputs are incomplete.");
10867
10828
  const count = Object.keys(outputs).length;
10868
10829
  if (node.kind == "condition" && count != 0 || isResolutionNode(node) && (resolutionActions(node).filter((action) => Object.hasOwn(outputs, action)).length > 1 || !resolutionActions(node).some((action) => Object.hasOwn(outputs, action)) && !(frame && Object.hasOwn(outputs, "pending")))) throw new Error("Checkpoint branch result is invalid.");
10869
10830
  }
@@ -10882,12 +10843,12 @@ function validateCheckpoint(prepared, target, checkpoint, resolveInputs) {
10882
10843
  for (const [id, count] of pendingCounts) if ((checkpoint.counts[""]?.[id] ?? 0) < count + (checkpoint.results[id] == null ? 0 : 1)) throw new Error("Checkpoint waiting execution count is incomplete.");
10883
10844
  for (const [id, values] of Object.entries(launch)) {
10884
10845
  const node = target.graph.nodes[id];
10885
- if (!("inputs" in node) || Object.keys(values).some((handle) => nodePorts(prepared, node)[handle] == null)) throw new Error("Checkpoint launch inputs do not match the prepared graph.");
10846
+ if (!("inputs" in node) || Object.keys(values).some((handle) => nodePorts(node)[handle] == null)) throw new Error("Checkpoint launch inputs do not match the prepared graph.");
10886
10847
  }
10887
10848
  for (const waiting of checkpoint.waits) {
10888
10849
  const node = target.graph.nodes[waiting.nodeId];
10889
10850
  if (node == null || !("inputs" in node)) throw new Error("Checkpoint waiting node is missing.");
10890
- const config = agentConfig(prepared, node);
10851
+ const config = agentConfig(node);
10891
10852
  const saved = agents[waiting.jobId];
10892
10853
  if (!isResolutionNode(node) && config == null) throw new Error("Checkpoint waiting node cannot suspend.");
10893
10854
  if (config != null) {
@@ -10900,34 +10861,28 @@ function validateCheckpoint(prepared, target, checkpoint, resolveInputs) {
10900
10861
  if (saved != null) throw new Error("Checkpoint Wait contains Agent state.");
10901
10862
  if (!isResolutionNode(node) || !jsonEqual(resolveInputs(waiting.nodeId, node, waiting.jobId), waiting.value)) throw new Error("Checkpoint resolution input changed.");
10902
10863
  if (usesPending(target.graph, waiting.nodeId) != (waiting.pending != null)) throw new Error("Checkpoint Wait pending output is missing or unexpected.");
10903
- if (waiting.pending != null) validateOutputs(prepared, waiting.nodeId, node, { pending: waiting.pending });
10864
+ if (waiting.pending != null) validateOutputs(waiting.nodeId, node, { pending: waiting.pending });
10904
10865
  }
10905
10866
  if (checkpoint.counts[""]?.[waiting.nodeId] == null) throw new Error("Checkpoint waiting execution count is missing.");
10906
10867
  }
10907
10868
  }
10908
- function runGraph(context, target, runId, inputs, parent, launchInputs = {}, trigger, resume) {
10869
+ function runGraph(context, target, runId, launchInputs = {}, trigger, resume) {
10909
10870
  return Effect.scoped(Effect.gen(function* () {
10910
10871
  if (resume == null) yield* context.emit({
10911
10872
  flowId: target.flowId,
10912
- ...parent == null ? {} : {
10913
- parentJobId: parent.jobId,
10914
- parentRunId: parent.runId
10915
- },
10916
10873
  runId,
10917
10874
  type: "run.started"
10918
10875
  });
10919
10876
  const order = Object.keys(target.graph.nodes).filter((id) => "inputs" in target.graph.nodes[id]);
10920
- const incoming = /* @__PURE__ */ new Set();
10921
10877
  const outgoing = /* @__PURE__ */ new Map();
10922
10878
  for (const edge of target.graph.edges) {
10923
- incoming.add(edge.target);
10924
10879
  const targets = outgoing.get(edge.source) ?? [];
10925
10880
  targets.push(edge);
10926
10881
  outgoing.set(edge.source, targets);
10927
10882
  }
10928
10883
  const resultNodes = order.filter((id) => !outgoing.has(id)).toSorted();
10929
10884
  const completed = new Map(Object.entries(resume?.checkpoint.results ?? {}));
10930
- const counts = context.counts[target.kind == "flow" ? "" : target.flowId] ??= {};
10885
+ const counts = context.counts[""] ??= {};
10931
10886
  const frames = { ...resume?.checkpoint.frames };
10932
10887
  const launch = resume?.checkpoint.inputs ?? launchInputs;
10933
10888
  if (resume == null) {
@@ -10958,7 +10913,6 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
10958
10913
  if (mapping?.kind == "sources") {
10959
10914
  const values = mapping.sources.flatMap((source) => {
10960
10915
  if (source.kind == "binding") return Object.hasOwn(context.bindingValues, source.bindingId) ? [context.bindingValues[source.bindingId]] : [];
10961
- if (source.kind == "flow") return Object.hasOwn(inputs, source.input) ? [inputs[source.input]] : [];
10962
10916
  const outputs = valuesByNode[source.nodeId];
10963
10917
  if (outputs == null || !Object.hasOwn(outputs, source.output)) return [];
10964
10918
  const output = outputs[source.output];
@@ -10976,7 +10930,7 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
10976
10930
  };
10977
10931
  const resolveInputs = (nodeId, node, jobId) => {
10978
10932
  const mappings = nodeInputMappings(node);
10979
- return Object.fromEntries(Object.entries(nodePorts(context.prepared, node)).map(([handle, port]) => [handle, resolveInput(mappings[handle], port, launch[nodeId]?.[handle], `Node "${nodeId}" input "${handle}"`, frames[jobId], node.kind == "condition")]));
10933
+ return Object.fromEntries(Object.entries(nodePorts(node)).map(([handle, port]) => [handle, resolveInput(mappings[handle], port, launch[nodeId]?.[handle], `Node "${nodeId}" input "${handle}"`, frames[jobId], node.kind == "condition")]));
10980
10934
  };
10981
10935
  const commit = (nodeId, jobId, outputs, releasedHandles = Object.keys(outputs)) => Effect.uninterruptible(Effect.gen(function* () {
10982
10936
  yield* context.emit({
@@ -11009,15 +10963,15 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11009
10963
  for (const edge of outgoing.get(nodeId) ?? []) if (edge.sourceHandle == null || releasedHandles.includes(edge.sourceHandle)) scheduleReady(edge.target, frame, nodeId);
11010
10964
  };
11011
10965
  const executeNode = (nodeId, node, jobId, nodeInputs, resolution, previousId) => {
11012
- const config = agentConfig(context.prepared, node);
10966
+ const config = agentConfig(node);
11013
10967
  const saved = agents[jobId];
11014
10968
  const nodeRemainingMs = saved?.remainingMs ?? node.timeoutMs;
11015
10969
  const startedAt = performance.now();
11016
10970
  const execution = Effect.gen(function* () {
11017
- const kind = nodeKind(context.prepared, node);
11018
- const title = nodeTitle(context.prepared, node);
10971
+ const kind = nodeKind(node);
10972
+ const title = nodeTitle(node);
11019
10973
  const projectedInputs = Object.fromEntries(Object.entries(nodeInputs).filter(([handle]) => {
11020
- if (node.kind == "task" && node.taskId != null && context.prepared.tasks[node.taskId]?.executor.kind == "openapi" && handle.startsWith("auth.")) return false;
10974
+ if (node.kind == "task" && "executor" in node.task && node.task?.executor.kind == "openapi" && handle.startsWith("auth.")) return false;
11021
10975
  const mapping = nodeInputMappings(node)[handle];
11022
10976
  return mapping?.kind != "sources" || mapping.sources.every((source) => source.kind != "binding");
11023
10977
  }));
@@ -11040,28 +10994,16 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11040
10994
  case "value":
11041
10995
  outputs = Object.fromEntries(node.values.map((port) => [port.handle, port.value ?? null]));
11042
10996
  break;
11043
- case "subflow": {
11044
- const subflow = context.prepared.subflows[node.subflowId];
11045
- outputs = yield* runGraph(context, {
11046
- flowId: node.subflowId,
11047
- graph: subflow.graph,
11048
- kind: "subflow"
11049
- }, context.createId(), nodeInputs, {
11050
- jobId,
11051
- runId
11052
- });
11053
- break;
11054
- }
11055
10997
  case "task": {
11056
10998
  const frame = frames[jobId];
11057
10999
  const additional = new Set((node.additionalInputs ?? []).map((port) => port.handle));
11058
11000
  const result = yield* context.invokeTask({
11059
11001
  additionalInputs: Object.fromEntries(Object.entries(nodeInputs).filter(([handle]) => additional.has(handle))),
11060
- blockId: node.task != null ? node.task.moduleId : node.taskId,
11002
+ blockId: "moduleId" in node.task ? node.task.moduleId : nodeId,
11061
11003
  flowId: target.flowId,
11062
11004
  input: Object.fromEntries(Object.entries(nodeInputs).filter(([handle]) => {
11063
11005
  if (additional.has(handle)) return false;
11064
- const task = node.taskId == null ? void 0 : context.prepared.tasks[node.taskId];
11006
+ const task = "executor" in node.task ? node.task : void 0;
11065
11007
  if (task?.executor.kind != "openapi") return true;
11066
11008
  const mapping = node.inputs[handle];
11067
11009
  return mapping?.kind != "unset" && (mapping != null || task.inputs.some((port) => "handle" in port && port.handle == handle && port.value !== void 0));
@@ -11074,7 +11016,7 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11074
11016
  jobId,
11075
11017
  nodeId,
11076
11018
  runId,
11077
- ...node.task != null ? {
11019
+ ..."moduleId" in node.task ? {
11078
11020
  capabilities: node.task.capabilities ?? [],
11079
11021
  moduleId: node.task.moduleId,
11080
11022
  getPrevious: () => {
@@ -11082,21 +11024,20 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11082
11024
  const previous = target.graph.nodes[previousId];
11083
11025
  return {
11084
11026
  id: previousId,
11085
- name: previous.name ?? ("inputs" in previous ? nodeTitle(context.prepared, previous) : void 0) ?? previousId,
11027
+ name: previous.name ?? ("inputs" in previous ? nodeTitle(previous) : void 0) ?? previousId,
11086
11028
  outputs: frame[previousId],
11087
- outputDefs: Object.entries(nodeOutputPorts(context.prepared, previous)).map(([handle, definition]) => Object.assign({
11029
+ outputDefs: Object.entries(nodeOutputPorts(previous)).map(([handle, definition]) => Object.assign({
11088
11030
  handle,
11089
11031
  jsonSchema: definition.jsonSchema,
11090
11032
  nullable: definition.nullable
11091
11033
  }, definition.description == null ? {} : { description: definition.description }))
11092
11034
  };
11093
11035
  }
11094
- } : { taskId: node.taskId }
11036
+ } : { kind: "managed" }
11095
11037
  });
11096
11038
  if (config != null) {
11097
11039
  const response = agentResultSchema.parse(result);
11098
11040
  if (response.kind == "suspended") {
11099
- if (target.kind != "flow") return yield* Effect.fail(/* @__PURE__ */ new Error("Subflow Agent is not supported."));
11100
11041
  const checkpoint = response.checkpoint;
11101
11042
  const value = agentApproval(config, checkpoint, nodeInputs);
11102
11043
  const left = nodeRemainingMs == null ? void 0 : nodeRemainingMs - (performance.now() - startedAt);
@@ -11122,7 +11063,7 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11122
11063
  return yield* Effect.try({
11123
11064
  try: () => ({
11124
11065
  kind: "completed",
11125
- outputs: validateOutputs(context.prepared, nodeId, node, outputs)
11066
+ outputs: validateOutputs(nodeId, node, outputs)
11126
11067
  }),
11127
11068
  catch: (error) => error instanceof Error ? error : new Error(String(error))
11128
11069
  });
@@ -11133,7 +11074,7 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11133
11074
  }));
11134
11075
  };
11135
11076
  const createWait = (nodeId, jobId, value) => Effect.gen(function* () {
11136
- if (target.kind != "flow" || context.waits == null) return yield* Effect.fail(/* @__PURE__ */ new Error("Wait host is unavailable."));
11077
+ if (context.waits == null) return yield* Effect.fail(/* @__PURE__ */ new Error("Wait host is unavailable."));
11137
11078
  const node = target.graph.nodes[nodeId];
11138
11079
  const waitId = nanoid$1();
11139
11080
  const notify = isResolutionNode(node) && usesPending(target.graph, nodeId);
@@ -11145,10 +11086,10 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11145
11086
  notify,
11146
11087
  actions: isResolutionNode(node) ? resolutionActions(node) : ["approve", "reject"],
11147
11088
  prompt: isResolutionNode(node) ? node.prompt : JSON.stringify(value, null, 2),
11148
- ...isResolutionNode(node) ? {} : { notification: agentNotice(context.prepared, node, agents[jobId].input) }
11089
+ ...isResolutionNode(node) ? {} : { notification: agentNotice(node, agents[jobId].input) }
11149
11090
  });
11150
11091
  if (notify) {
11151
- validateOutputs(context.prepared, nodeId, node, { pending });
11092
+ validateOutputs(nodeId, node, { pending });
11152
11093
  const frame = {
11153
11094
  ...frames[jobId],
11154
11095
  [nodeId]: { pending }
@@ -11228,12 +11169,11 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11228
11169
  })).pipe(Effect.ensuring(Queue.offer(changes, void 0))));
11229
11170
  };
11230
11171
  if (resume != null) yield* Effect.try({
11231
- try: () => validateCheckpoint(context.prepared, target, resume.checkpoint, resolveInputs),
11172
+ try: () => validateCheckpoint(target, resume.checkpoint, resolveInputs),
11232
11173
  catch: (error) => error instanceof Error ? error : new Error(String(error))
11233
11174
  });
11234
11175
  if (resume == null) {
11235
11176
  if (trigger != null) dispatch(trigger.nodeId, Object.keys(trigger.outputs), { [trigger.nodeId]: trigger.outputs });
11236
- else for (const nodeId of order) if (!incoming.has(nodeId)) scheduleReady(nodeId, {});
11237
11177
  }
11238
11178
  const applyResolutions = (resolutions, now) => {
11239
11179
  for (const saved of pendingWaits.values()) {
@@ -11249,7 +11189,7 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11249
11189
  runNode(observe(saved.nodeId, saved.jobId, Effect.gen(function* () {
11250
11190
  if (isResolutionNode(node)) {
11251
11191
  if (!resolutionActions(node).some((candidate) => candidate == action)) return yield* Effect.fail(/* @__PURE__ */ new Error("Resolution does not match node actions."));
11252
- yield* commit(saved.nodeId, saved.jobId, validateOutputs(context.prepared, saved.nodeId, node, {
11192
+ yield* commit(saved.nodeId, saved.jobId, validateOutputs(saved.nodeId, node, {
11253
11193
  ...saved.pending == null ? {} : { pending: saved.pending },
11254
11194
  [action]: {
11255
11195
  inputs: saved.value,
@@ -11318,26 +11258,6 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11318
11258
  runId,
11319
11259
  type: "run.progress"
11320
11260
  });
11321
- if (target.kind == "subflow") {
11322
- const subflow = context.prepared.subflows[target.flowId];
11323
- const outputs = yield* Effect.try({
11324
- try: () => Object.fromEntries(subflow.outputs.map((port) => [port.handle, resolveInput({
11325
- kind: "sources",
11326
- sources: port.sources
11327
- }, port, void 0, `Subflow output "${port.handle}"`, Object.fromEntries([...completed].map(([id, result]) => [id, result.outputs])))])),
11328
- catch: (error) => error instanceof Error ? error : new Error(String(error))
11329
- });
11330
- yield* context.emit({
11331
- result: {
11332
- kind: "function-outputs",
11333
- outputs,
11334
- target: "subflow"
11335
- },
11336
- runId,
11337
- type: "run.completed"
11338
- });
11339
- return outputs;
11340
- }
11341
11261
  const result = {
11342
11262
  kind: "node-results",
11343
11263
  nodes: resultNodes.flatMap((nodeId) => {
@@ -11380,9 +11300,8 @@ function runFlow(prepared, options) {
11380
11300
  remainingMs: options.remainingMs
11381
11301
  }, {
11382
11302
  flowId: options.flowId,
11383
- graph: prepared.graph,
11384
- kind: "flow"
11385
- }, options.runId, {}, void 0, options.inputs, options.trigger, checkpoint == null ? void 0 : { checkpoint });
11303
+ graph: prepared.graph
11304
+ }, options.runId, options.inputs, options.trigger, checkpoint == null ? void 0 : { checkpoint });
11386
11305
  });
11387
11306
  }
11388
11307
  //#endregion