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

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 (43) hide show
  1. package/README.md +1 -1
  2. package/dist/browser/{createResourceDialog-4H5_lZ6s.js → createResourceDialog-Btjes3wD.js} +2 -2
  3. package/dist/browser/flow-authoring-edge.d.ts +3 -3
  4. package/dist/browser/flow-authoring-node.d.ts +26 -46
  5. package/dist/browser/flow-authoring.js +9155 -21002
  6. package/dist/browser/flow-change-schema.d.ts +1 -1
  7. package/dist/browser/flow-change.d.ts +14 -104
  8. package/dist/browser/flow-change.js +121 -296
  9. package/dist/browser/{flowChanges-ZzG-f9cg.js → flowChanges-BxutPLYO.js} +1494 -1830
  10. package/dist/browser/{flowWorkspace-ChpRaTMX.js → flowWorkspace-Dg4mqfa6.js} +118 -293
  11. package/dist/browser/{icons-CdAB9wyS.js → icons-p2A9zs8t.js} +126 -317
  12. package/dist/browser/lib-DrKav3HG.js +11403 -0
  13. package/dist/browser/preview.css +1 -1
  14. package/dist/browser/preview.js +9308 -9565
  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 +210 -411
  20. package/dist/browser/{workbenchSelect-BRZN4ish.js → workbenchSelect-LRp_Xjeq.js} +1 -1
  21. package/dist/common/control-api-conformance.js +212 -245
  22. package/dist/common/control-api.d.ts +6 -6
  23. package/dist/common/control-api.js +216 -250
  24. package/dist/common/control-requests.js +468 -1476
  25. package/dist/common/decision.js +6325 -6369
  26. package/dist/common/flow-agent.d.ts +1 -1
  27. package/dist/common/flow-connectionUsage.d.ts +1 -2
  28. package/dist/common/flow-encoding.d.ts +2 -4
  29. package/dist/common/flow-encoding.js +119 -180
  30. package/dist/common/flow-graph.d.ts +10 -10
  31. package/dist/common/flow-semantics.d.ts +4 -9
  32. package/dist/common/flow-semantics.js +9024 -9230
  33. package/dist/common/flowInspection.d.ts +3 -21
  34. package/dist/common/integration-trigger.js +8642 -8686
  35. package/dist/common/mcp.d.ts +0 -1
  36. package/dist/common/mcp.js +117 -140
  37. package/dist/common/openapi.js +6325 -6369
  38. package/dist/common/poll-trigger.js +8642 -8686
  39. package/dist/common/run-events.js +0 -1
  40. package/dist/common/scheduler.d.ts +3 -9
  41. package/dist/common/scheduler.js +116 -207
  42. package/dist/common/webhook-trigger.js +6325 -6369
  43. package/package.json +1 -1
@@ -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]))
@@ -9649,9 +9654,11 @@ 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
  ])
@@ -9706,7 +9713,7 @@ var webhookOptions = object({
9706
9713
  allowedOrigins: strings.optional(),
9707
9714
  noResponseBody: never().optional(),
9708
9715
  responseData: text.optional(),
9709
- responseHeaders: record(text, text).optional(),
9716
+ responseHeaders: record$1(text, text).optional(),
9710
9717
  responseStatusCode: number().int().min(200).max(599).optional()
9711
9718
  });
9712
9719
  var webhook = {
@@ -9762,7 +9769,7 @@ var base = {
9762
9769
  var node = union([
9763
9770
  object({
9764
9771
  ...base,
9765
- inputs: record(text, never()),
9772
+ inputs: record$1(text, never()),
9766
9773
  kind: literal("condition"),
9767
9774
  ...condition
9768
9775
  }),
@@ -9772,21 +9779,10 @@ var node = union([
9772
9779
  kind: literal("value"),
9773
9780
  values: array(input)
9774
9781
  }),
9775
- object({
9776
- ...base,
9777
- kind: literal("subflow"),
9778
- subflowId: text
9779
- }),
9780
- object({
9781
- ...base,
9782
- kind: literal("task"),
9783
- task: inline,
9784
- additionalInputs: array(input).optional()
9785
- }),
9786
9782
  object({
9787
9783
  ...base,
9788
9784
  kind: literal("task"),
9789
- taskId: text,
9785
+ task: union([inline, managed]),
9790
9786
  additionalInputs: array(input).optional()
9791
9787
  }),
9792
9788
  strictObject({
@@ -9822,7 +9818,7 @@ var node = union([
9822
9818
  ...trigger,
9823
9819
  kind: literal("poll"),
9824
9820
  connectionId: text.min(1).optional(),
9825
- config: record(text, fixedInput),
9821
+ config: record$1(text, fixedInput),
9826
9822
  definition: object({
9827
9823
  ...definition,
9828
9824
  type: literal("poll")
@@ -9833,7 +9829,7 @@ var node = union([
9833
9829
  ...trigger,
9834
9830
  kind: literal("integration"),
9835
9831
  connectionId: text.min(1).optional(),
9836
- config: record(text, fixedInput),
9832
+ config: record$1(text, fixedInput),
9837
9833
  definition: object({
9838
9834
  ...definition,
9839
9835
  type: literal("integration"),
@@ -9841,10 +9837,6 @@ var node = union([
9841
9837
  })
9842
9838
  })
9843
9839
  ]);
9844
- var target = union([object({ kind: literal("flow") }), object({
9845
- kind: literal("subflow"),
9846
- id: text
9847
- })]);
9848
9840
  var edge = object({
9849
9841
  source: text,
9850
9842
  target: text,
@@ -9852,15 +9844,10 @@ var edge = object({
9852
9844
  });
9853
9845
  var at = {
9854
9846
  nodeId: text,
9855
- target
9847
+ target: never().optional()
9856
9848
  };
9857
- var subflow = object({
9858
- name: text,
9859
- inputs: array(input),
9860
- outputs: array(port.extend({ sources: array(union([nodeSource, flowSource])) }))
9861
- });
9862
9849
  var graph = object({
9863
- nodes: record(text, node),
9850
+ nodes: record$1(text, node),
9864
9851
  edges: array(edge).default([])
9865
9852
  });
9866
9853
  var binding = object({
@@ -9872,24 +9859,35 @@ var module = object({
9872
9859
  imports: strings,
9873
9860
  source: text
9874
9861
  });
9875
- var document = object({
9876
- bindings: record(text, binding),
9877
- graph,
9878
- subflows: record(text, subflow.extend({ graph })),
9879
- tasks: record(text, managed)
9880
- });
9862
+ var document = preprocess(rejectRetiredDefinitions, object({
9863
+ bindings: record$1(text, binding),
9864
+ graph
9865
+ }));
9881
9866
  object({
9882
9867
  modelVersion: union([
9883
9868
  literal(2),
9884
9869
  literal(4),
9885
- literal(5)
9870
+ literal(5),
9871
+ literal(6)
9886
9872
  ]),
9887
9873
  document,
9888
- modules: record(text, module)
9874
+ modules: record$1(text, module)
9889
9875
  }).extend({
9890
9876
  kind: literal("open-flow-flow-revision"),
9891
9877
  version: literal(1)
9892
9878
  });
9879
+ function rejectRetiredDefinitions(value) {
9880
+ const candidate = record(value);
9881
+ 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.");
9882
+ if (Object.values(record(record(candidate.graph).nodes)).some((candidateNode) => Object.hasOwn(record(candidateNode), "taskId"))) throw new TypeError("Task references are no longer supported.");
9883
+ const subflows = candidate.subflows;
9884
+ 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.");
9885
+ if (Object.values(record(record(candidate.graph).nodes)).some((candidateNode) => record(candidateNode).kind === "subflow")) throw new TypeError("Subflow nodes are no longer supported.");
9886
+ return value;
9887
+ }
9888
+ function record(value) {
9889
+ return value != null && typeof value == "object" && !Array.isArray(value) ? value : {};
9890
+ }
9893
9891
  var shapes = {
9894
9892
  "graph.trigger.sources.set": {
9895
9893
  nodeId: text,
@@ -9907,12 +9905,12 @@ var shapes = {
9907
9905
  value: text
9908
9906
  },
9909
9907
  "graph.edge.connect": {
9910
- target,
9911
- edge
9908
+ edge,
9909
+ target: never().optional()
9912
9910
  },
9913
9911
  "graph.edge.disconnect": {
9914
- target,
9915
- edge
9912
+ edge,
9913
+ target: never().optional()
9916
9914
  },
9917
9915
  "graph.node.create": {
9918
9916
  ...at,
@@ -9976,13 +9974,11 @@ var shapes = {
9976
9974
  },
9977
9975
  "graph.node.resolution.set": {
9978
9976
  ...at,
9979
- target: object({ kind: literal("flow") }),
9980
9977
  before: object(wait),
9981
9978
  value: object(wait)
9982
9979
  },
9983
9980
  "graph.node.webhook.set": {
9984
9981
  ...at,
9985
- target: object({ kind: literal("flow") }),
9986
9982
  before: object(webhook),
9987
9983
  value: object(webhook)
9988
9984
  },
@@ -10029,50 +10025,10 @@ var shapes = {
10029
10025
  imports: strings,
10030
10026
  source: text
10031
10027
  },
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
10028
+ "graph.node.task.set": {
10029
+ ...at,
10030
+ before: union([inline, managed]),
10031
+ value: union([inline, managed])
10076
10032
  }
10077
10033
  };
10078
10034
  array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object({
@@ -10311,8 +10267,8 @@ var schema = lazy(() => union([boolean(), strictObject({
10311
10267
  "https://json-schema.org/draft/2019-09/schema",
10312
10268
  "https://json-schema.org/draft/2020-12/schema"
10313
10269
  ]).optional(),
10314
- $defs: record(string(), schema).optional(),
10315
- definitions: record(string(), schema).optional(),
10270
+ $defs: record$1(string(), schema).optional(),
10271
+ definitions: record$1(string(), schema).optional(),
10316
10272
  pattern: string().refine((value) => {
10317
10273
  try {
10318
10274
  return new RegExp(value, "u").source.length > 0;
@@ -10329,16 +10285,16 @@ var schema = lazy(() => union([boolean(), strictObject({
10329
10285
  minProperties: number().int().nonnegative().optional(),
10330
10286
  maxProperties: number().int().nonnegative().optional(),
10331
10287
  propertyNames: schema.optional(),
10332
- patternProperties: record(string().refine((value) => {
10288
+ patternProperties: record$1(string().refine((value) => {
10333
10289
  try {
10334
10290
  return new RegExp(value, "u").source.length > 0;
10335
10291
  } catch {
10336
10292
  return false;
10337
10293
  }
10338
10294
  }, "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(),
10295
+ dependentRequired: record$1(string(), array(string())).optional(),
10296
+ dependentSchemas: record$1(string(), schema).optional(),
10297
+ dependencies: record$1(string(), union([schema, array(string())])).optional(),
10342
10298
  prefixItems: array(schema).optional(),
10343
10299
  additionalItems: schema.optional(),
10344
10300
  unevaluatedItems: schema.optional(),
@@ -10352,7 +10308,7 @@ var schema = lazy(() => union([boolean(), strictObject({
10352
10308
  deprecated: boolean().optional(),
10353
10309
  $comment: string().optional(),
10354
10310
  enum: array(json$1()).min(1).optional(),
10355
- properties: record(string(), schema).optional(),
10311
+ properties: record$1(string(), schema).optional(),
10356
10312
  required: array(string()).optional(),
10357
10313
  additionalProperties: schema.optional(),
10358
10314
  items: union([schema, array(schema)]).optional(),
@@ -10607,12 +10563,11 @@ function resolutionOutputPorts(node) {
10607
10563
  })]))
10608
10564
  };
10609
10565
  }
10610
- function nodeOutputPorts(document, node) {
10566
+ function nodeOutputPorts(node) {
10611
10567
  switch (node.kind) {
10612
10568
  case "condition": return {};
10613
10569
  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 ?? []);
10570
+ case "task": return portsByHandle(node.task.outputs);
10616
10571
  case "approval":
10617
10572
  case "wait": return resolutionOutputPorts(node);
10618
10573
  case "cron":
@@ -10643,30 +10598,28 @@ function nodeFailure(error, project) {
10643
10598
  message: error instanceof Error ? error.message : String(error)
10644
10599
  };
10645
10600
  }
10646
- function nodePorts(prepared, node) {
10601
+ function nodePorts(node) {
10647
10602
  switch (node.kind) {
10648
10603
  case "condition": return conditionInputPorts(node);
10649
10604
  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 ?? []]);
10605
+ case "task": return portsByHandle([...node.task.inputs, ...node.additionalInputs ?? []]);
10652
10606
  case "approval":
10653
10607
  case "wait": return portsByHandle(node.inputDefinitions);
10654
10608
  }
10655
10609
  }
10656
- function nodeTitle(prepared, node) {
10610
+ function nodeTitle(node) {
10657
10611
  if (node.name != null) return node.name;
10658
10612
  switch (node.kind) {
10659
10613
  case "condition": return;
10660
10614
  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;
10615
+ case "task": return node.task.name;
10663
10616
  case "approval": return "Approval";
10664
10617
  case "wait": return "Wait";
10665
10618
  }
10666
10619
  }
10667
- function nodeKind(prepared, node) {
10620
+ function nodeKind(node) {
10668
10621
  if (node.kind != "task") return node.kind;
10669
- return node.task != null ? "javascript" : prepared.tasks[node.taskId].executor.kind;
10622
+ return "moduleId" in node.task ? "javascript" : node.task.executor.kind;
10670
10623
  }
10671
10624
  function checkpointRecord(value, description) {
10672
10625
  if (value == null || typeof value != "object" || Array.isArray(value)) throw new Error(`${description} must be an object.`);
@@ -10692,7 +10645,7 @@ var agentCheckpointSchema = strictObject({
10692
10645
  state: json$1(),
10693
10646
  callId: string().min(1),
10694
10647
  toolId: string().min(1),
10695
- input: record(string(), json$1()),
10648
+ input: record$1(string(), json$1()),
10696
10649
  rounds: number().int().nonnegative(),
10697
10650
  version: literal(1)
10698
10651
  });
@@ -10729,8 +10682,8 @@ function decodeFlowRunCheckpoint(input) {
10729
10682
  outputs: Object.fromEntries(Object.entries(checkpointRecord(result.outputs, "Checkpoint outputs")).map(([handle, item]) => [handle, checkpointJson(item, "Checkpoint output")]))
10730
10683
  }];
10731
10684
  }));
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);
10685
+ const counts = record$1(string(), record$1(string(), number().int().positive().max(Number.MAX_SAFE_INTEGER))).parse(source.counts);
10686
+ const frames = record$1(string(), record$1(string(), record$1(string(), json$1()))).parse(source.frames);
10734
10687
  const savedWaitFields = {
10735
10688
  jobId: string().min(1),
10736
10689
  nodeId: string().min(1),
@@ -10747,9 +10700,9 @@ function decodeFlowRunCheckpoint(input) {
10747
10700
  ...wait,
10748
10701
  pending: notification
10749
10702
  }))])).min(1).parse(source.waits);
10750
- const agents = record(string(), strictObject({
10703
+ const agents = record$1(string(), strictObject({
10751
10704
  invocationId: string().min(1),
10752
- input: record(string(), json$1()),
10705
+ input: record$1(string(), json$1()),
10753
10706
  remainingMs: number().positive().optional(),
10754
10707
  checkpoint: agentCheckpointSchema
10755
10708
  })).parse(source.agents);
@@ -10787,18 +10740,16 @@ function outputRecord(value, nodeId) {
10787
10740
  if (value == null || typeof value != "object" || Array.isArray(value)) throw new Error(`Node "${nodeId}" must return an object.`);
10788
10741
  return value;
10789
10742
  }
10790
- function agentConfig(prepared, node) {
10791
- const task = node.kind == "task" && node.taskId != null ? prepared.tasks[node.taskId] : void 0;
10743
+ function agentConfig(node) {
10744
+ const task = node.kind == "task" && "executor" in node.task ? node.task : void 0;
10792
10745
  return task?.executor.kind == "agent" ? task.executor : void 0;
10793
10746
  }
10794
- function agentNotice(prepared, node, values) {
10795
- const notification = agentConfig(prepared, node)?.notification;
10747
+ function agentNotice(node, values) {
10748
+ const notification = agentConfig(node)?.notification;
10796
10749
  if (notification == null) return void 0;
10797
- const task = prepared.tasks[notification.taskId];
10798
10750
  return {
10799
- taskId: notification.taskId,
10800
10751
  messageHandle: notification.messageHandle,
10801
- input: Object.fromEntries(task.inputs.flatMap((port) => {
10752
+ input: Object.fromEntries(notification.inputDefinitions.flatMap((port) => {
10802
10753
  if (!("handle" in port) || port.handle == notification.messageHandle) return [];
10803
10754
  const source = notification.inputs[port.handle];
10804
10755
  return [[port.handle, source == null ? port.value ?? null : agentInput(source, values)]];
@@ -10822,10 +10773,10 @@ function agentApproval(config, checkpoint, inputs) {
10822
10773
  input: checkpoint.input
10823
10774
  };
10824
10775
  }
10825
- function validateOutputs(prepared, nodeId, node, value) {
10776
+ function validateOutputs(nodeId, node, value) {
10826
10777
  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) : {};
10778
+ const discardUndeclared = node.kind == "task" && "executor" in node.task && node.task.executor.kind == "connector";
10779
+ const ports = isResolutionNode(node) ? resolutionOutputPorts(node) : node.kind == "task" ? portsByHandle(node.task.outputs) : node.kind == "value" ? portsByHandle(node.values) : {};
10829
10780
  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
10781
  const complete = node.kind == "condition" || isResolutionNode(node) ? outputs : {
10831
10782
  ...Object.fromEntries(Object.keys(ports).map((handle) => [handle, null])),
@@ -10843,12 +10794,12 @@ function validateOutputs(prepared, nodeId, node, value) {
10843
10794
  }
10844
10795
  return validated;
10845
10796
  }
10846
- function validateCheckpoint(prepared, target, checkpoint, resolveInputs) {
10797
+ function validateCheckpoint(target, checkpoint, resolveInputs) {
10847
10798
  const launch = checkpoint.inputs;
10848
10799
  const agents = checkpoint.agents;
10849
10800
  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
10801
  for (const [scope, counts] of Object.entries(checkpoint.counts)) {
10851
- const graph = scope == "" ? target.graph : prepared.subflows[scope]?.graph;
10802
+ const graph = scope == "" ? target.graph : void 0;
10852
10803
  if (graph == null) throw new Error("Checkpoint execution counts reference an unknown graph.");
10853
10804
  for (const [id, count] of Object.entries(counts)) {
10854
10805
  const node = graph.nodes[id];
@@ -10863,7 +10814,7 @@ function validateCheckpoint(prepared, target, checkpoint, resolveInputs) {
10863
10814
  if (!matchesTriggerOutputs(node, outputs)) throw new Error("Checkpoint Trigger output is invalid.");
10864
10815
  } else {
10865
10816
  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.");
10817
+ if (!jsonEqual(validateOutputs(id, node, outputs), outputs)) throw new Error("Checkpoint node outputs are incomplete.");
10867
10818
  const count = Object.keys(outputs).length;
10868
10819
  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
10820
  }
@@ -10882,12 +10833,12 @@ function validateCheckpoint(prepared, target, checkpoint, resolveInputs) {
10882
10833
  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
10834
  for (const [id, values] of Object.entries(launch)) {
10884
10835
  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.");
10836
+ 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
10837
  }
10887
10838
  for (const waiting of checkpoint.waits) {
10888
10839
  const node = target.graph.nodes[waiting.nodeId];
10889
10840
  if (node == null || !("inputs" in node)) throw new Error("Checkpoint waiting node is missing.");
10890
- const config = agentConfig(prepared, node);
10841
+ const config = agentConfig(node);
10891
10842
  const saved = agents[waiting.jobId];
10892
10843
  if (!isResolutionNode(node) && config == null) throw new Error("Checkpoint waiting node cannot suspend.");
10893
10844
  if (config != null) {
@@ -10900,34 +10851,28 @@ function validateCheckpoint(prepared, target, checkpoint, resolveInputs) {
10900
10851
  if (saved != null) throw new Error("Checkpoint Wait contains Agent state.");
10901
10852
  if (!isResolutionNode(node) || !jsonEqual(resolveInputs(waiting.nodeId, node, waiting.jobId), waiting.value)) throw new Error("Checkpoint resolution input changed.");
10902
10853
  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 });
10854
+ if (waiting.pending != null) validateOutputs(waiting.nodeId, node, { pending: waiting.pending });
10904
10855
  }
10905
10856
  if (checkpoint.counts[""]?.[waiting.nodeId] == null) throw new Error("Checkpoint waiting execution count is missing.");
10906
10857
  }
10907
10858
  }
10908
- function runGraph(context, target, runId, inputs, parent, launchInputs = {}, trigger, resume) {
10859
+ function runGraph(context, target, runId, launchInputs = {}, trigger, resume) {
10909
10860
  return Effect.scoped(Effect.gen(function* () {
10910
10861
  if (resume == null) yield* context.emit({
10911
10862
  flowId: target.flowId,
10912
- ...parent == null ? {} : {
10913
- parentJobId: parent.jobId,
10914
- parentRunId: parent.runId
10915
- },
10916
10863
  runId,
10917
10864
  type: "run.started"
10918
10865
  });
10919
10866
  const order = Object.keys(target.graph.nodes).filter((id) => "inputs" in target.graph.nodes[id]);
10920
- const incoming = /* @__PURE__ */ new Set();
10921
10867
  const outgoing = /* @__PURE__ */ new Map();
10922
10868
  for (const edge of target.graph.edges) {
10923
- incoming.add(edge.target);
10924
10869
  const targets = outgoing.get(edge.source) ?? [];
10925
10870
  targets.push(edge);
10926
10871
  outgoing.set(edge.source, targets);
10927
10872
  }
10928
10873
  const resultNodes = order.filter((id) => !outgoing.has(id)).toSorted();
10929
10874
  const completed = new Map(Object.entries(resume?.checkpoint.results ?? {}));
10930
- const counts = context.counts[target.kind == "flow" ? "" : target.flowId] ??= {};
10875
+ const counts = context.counts[""] ??= {};
10931
10876
  const frames = { ...resume?.checkpoint.frames };
10932
10877
  const launch = resume?.checkpoint.inputs ?? launchInputs;
10933
10878
  if (resume == null) {
@@ -10958,7 +10903,6 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
10958
10903
  if (mapping?.kind == "sources") {
10959
10904
  const values = mapping.sources.flatMap((source) => {
10960
10905
  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
10906
  const outputs = valuesByNode[source.nodeId];
10963
10907
  if (outputs == null || !Object.hasOwn(outputs, source.output)) return [];
10964
10908
  const output = outputs[source.output];
@@ -10976,7 +10920,7 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
10976
10920
  };
10977
10921
  const resolveInputs = (nodeId, node, jobId) => {
10978
10922
  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")]));
10923
+ 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
10924
  };
10981
10925
  const commit = (nodeId, jobId, outputs, releasedHandles = Object.keys(outputs)) => Effect.uninterruptible(Effect.gen(function* () {
10982
10926
  yield* context.emit({
@@ -11009,15 +10953,15 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11009
10953
  for (const edge of outgoing.get(nodeId) ?? []) if (edge.sourceHandle == null || releasedHandles.includes(edge.sourceHandle)) scheduleReady(edge.target, frame, nodeId);
11010
10954
  };
11011
10955
  const executeNode = (nodeId, node, jobId, nodeInputs, resolution, previousId) => {
11012
- const config = agentConfig(context.prepared, node);
10956
+ const config = agentConfig(node);
11013
10957
  const saved = agents[jobId];
11014
10958
  const nodeRemainingMs = saved?.remainingMs ?? node.timeoutMs;
11015
10959
  const startedAt = performance.now();
11016
10960
  const execution = Effect.gen(function* () {
11017
- const kind = nodeKind(context.prepared, node);
11018
- const title = nodeTitle(context.prepared, node);
10961
+ const kind = nodeKind(node);
10962
+ const title = nodeTitle(node);
11019
10963
  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;
10964
+ if (node.kind == "task" && "executor" in node.task && node.task?.executor.kind == "openapi" && handle.startsWith("auth.")) return false;
11021
10965
  const mapping = nodeInputMappings(node)[handle];
11022
10966
  return mapping?.kind != "sources" || mapping.sources.every((source) => source.kind != "binding");
11023
10967
  }));
@@ -11040,28 +10984,16 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11040
10984
  case "value":
11041
10985
  outputs = Object.fromEntries(node.values.map((port) => [port.handle, port.value ?? null]));
11042
10986
  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
10987
  case "task": {
11056
10988
  const frame = frames[jobId];
11057
10989
  const additional = new Set((node.additionalInputs ?? []).map((port) => port.handle));
11058
10990
  const result = yield* context.invokeTask({
11059
10991
  additionalInputs: Object.fromEntries(Object.entries(nodeInputs).filter(([handle]) => additional.has(handle))),
11060
- blockId: node.task != null ? node.task.moduleId : node.taskId,
10992
+ blockId: "moduleId" in node.task ? node.task.moduleId : nodeId,
11061
10993
  flowId: target.flowId,
11062
10994
  input: Object.fromEntries(Object.entries(nodeInputs).filter(([handle]) => {
11063
10995
  if (additional.has(handle)) return false;
11064
- const task = node.taskId == null ? void 0 : context.prepared.tasks[node.taskId];
10996
+ const task = "executor" in node.task ? node.task : void 0;
11065
10997
  if (task?.executor.kind != "openapi") return true;
11066
10998
  const mapping = node.inputs[handle];
11067
10999
  return mapping?.kind != "unset" && (mapping != null || task.inputs.some((port) => "handle" in port && port.handle == handle && port.value !== void 0));
@@ -11074,7 +11006,7 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11074
11006
  jobId,
11075
11007
  nodeId,
11076
11008
  runId,
11077
- ...node.task != null ? {
11009
+ ..."moduleId" in node.task ? {
11078
11010
  capabilities: node.task.capabilities ?? [],
11079
11011
  moduleId: node.task.moduleId,
11080
11012
  getPrevious: () => {
@@ -11082,21 +11014,20 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11082
11014
  const previous = target.graph.nodes[previousId];
11083
11015
  return {
11084
11016
  id: previousId,
11085
- name: previous.name ?? ("inputs" in previous ? nodeTitle(context.prepared, previous) : void 0) ?? previousId,
11017
+ name: previous.name ?? ("inputs" in previous ? nodeTitle(previous) : void 0) ?? previousId,
11086
11018
  outputs: frame[previousId],
11087
- outputDefs: Object.entries(nodeOutputPorts(context.prepared, previous)).map(([handle, definition]) => Object.assign({
11019
+ outputDefs: Object.entries(nodeOutputPorts(previous)).map(([handle, definition]) => Object.assign({
11088
11020
  handle,
11089
11021
  jsonSchema: definition.jsonSchema,
11090
11022
  nullable: definition.nullable
11091
11023
  }, definition.description == null ? {} : { description: definition.description }))
11092
11024
  };
11093
11025
  }
11094
- } : { taskId: node.taskId }
11026
+ } : { kind: "managed" }
11095
11027
  });
11096
11028
  if (config != null) {
11097
11029
  const response = agentResultSchema.parse(result);
11098
11030
  if (response.kind == "suspended") {
11099
- if (target.kind != "flow") return yield* Effect.fail(/* @__PURE__ */ new Error("Subflow Agent is not supported."));
11100
11031
  const checkpoint = response.checkpoint;
11101
11032
  const value = agentApproval(config, checkpoint, nodeInputs);
11102
11033
  const left = nodeRemainingMs == null ? void 0 : nodeRemainingMs - (performance.now() - startedAt);
@@ -11122,7 +11053,7 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11122
11053
  return yield* Effect.try({
11123
11054
  try: () => ({
11124
11055
  kind: "completed",
11125
- outputs: validateOutputs(context.prepared, nodeId, node, outputs)
11056
+ outputs: validateOutputs(nodeId, node, outputs)
11126
11057
  }),
11127
11058
  catch: (error) => error instanceof Error ? error : new Error(String(error))
11128
11059
  });
@@ -11133,7 +11064,7 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11133
11064
  }));
11134
11065
  };
11135
11066
  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."));
11067
+ if (context.waits == null) return yield* Effect.fail(/* @__PURE__ */ new Error("Wait host is unavailable."));
11137
11068
  const node = target.graph.nodes[nodeId];
11138
11069
  const waitId = nanoid$1();
11139
11070
  const notify = isResolutionNode(node) && usesPending(target.graph, nodeId);
@@ -11145,10 +11076,10 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11145
11076
  notify,
11146
11077
  actions: isResolutionNode(node) ? resolutionActions(node) : ["approve", "reject"],
11147
11078
  prompt: isResolutionNode(node) ? node.prompt : JSON.stringify(value, null, 2),
11148
- ...isResolutionNode(node) ? {} : { notification: agentNotice(context.prepared, node, agents[jobId].input) }
11079
+ ...isResolutionNode(node) ? {} : { notification: agentNotice(node, agents[jobId].input) }
11149
11080
  });
11150
11081
  if (notify) {
11151
- validateOutputs(context.prepared, nodeId, node, { pending });
11082
+ validateOutputs(nodeId, node, { pending });
11152
11083
  const frame = {
11153
11084
  ...frames[jobId],
11154
11085
  [nodeId]: { pending }
@@ -11228,12 +11159,11 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11228
11159
  })).pipe(Effect.ensuring(Queue.offer(changes, void 0))));
11229
11160
  };
11230
11161
  if (resume != null) yield* Effect.try({
11231
- try: () => validateCheckpoint(context.prepared, target, resume.checkpoint, resolveInputs),
11162
+ try: () => validateCheckpoint(target, resume.checkpoint, resolveInputs),
11232
11163
  catch: (error) => error instanceof Error ? error : new Error(String(error))
11233
11164
  });
11234
11165
  if (resume == null) {
11235
11166
  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
11167
  }
11238
11168
  const applyResolutions = (resolutions, now) => {
11239
11169
  for (const saved of pendingWaits.values()) {
@@ -11249,7 +11179,7 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11249
11179
  runNode(observe(saved.nodeId, saved.jobId, Effect.gen(function* () {
11250
11180
  if (isResolutionNode(node)) {
11251
11181
  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, {
11182
+ yield* commit(saved.nodeId, saved.jobId, validateOutputs(saved.nodeId, node, {
11253
11183
  ...saved.pending == null ? {} : { pending: saved.pending },
11254
11184
  [action]: {
11255
11185
  inputs: saved.value,
@@ -11318,26 +11248,6 @@ function runGraph(context, target, runId, inputs, parent, launchInputs = {}, tri
11318
11248
  runId,
11319
11249
  type: "run.progress"
11320
11250
  });
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
11251
  const result = {
11342
11252
  kind: "node-results",
11343
11253
  nodes: resultNodes.flatMap((nodeId) => {
@@ -11380,9 +11290,8 @@ function runFlow(prepared, options) {
11380
11290
  remainingMs: options.remainingMs
11381
11291
  }, {
11382
11292
  flowId: options.flowId,
11383
- graph: prepared.graph,
11384
- kind: "flow"
11385
- }, options.runId, {}, void 0, options.inputs, options.trigger, checkpoint == null ? void 0 : { checkpoint });
11293
+ graph: prepared.graph
11294
+ }, options.runId, options.inputs, options.trigger, checkpoint == null ? void 0 : { checkpoint });
11386
11295
  });
11387
11296
  }
11388
11297
  //#endregion