@oomol-lab/open-flow 0.1.0-beta.51 → 0.1.0-beta.53

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 (45) hide show
  1. package/dist/browser/{createResourceDialog-BDtXpRSt.js → createResourceDialog-BsaBMf7_.js} +2 -1
  2. package/dist/browser/flow-authoring.js +46 -3
  3. package/dist/browser/flow-change.d.ts +6 -1
  4. package/dist/browser/flow-change.js +46 -3
  5. package/dist/browser/{flowChanges-BWSXSnMX.js → flowChanges-CcscgZsW.js} +3492 -1939
  6. package/dist/browser/{flowWorkspace-DBaq2Eks.js → flowWorkspace-CoT_ewLX.js} +904 -330
  7. package/dist/browser/{workbenchSelect-C9kwcUmN.js → icons-0s-Q_3lp.js} +48 -32
  8. package/dist/browser/licenses.md +204 -0
  9. package/dist/browser/preview.css +282 -179
  10. package/dist/browser/preview.js +4311 -2200
  11. package/dist/browser/theme.css +2 -0
  12. package/dist/browser/ui-hostNavigationActions.d.ts +13 -0
  13. package/dist/browser/ui-hostTooltip.d.ts +8 -0
  14. package/dist/browser/ui-logo.d.ts +5 -0
  15. package/dist/browser/ui.css +82 -8
  16. package/dist/browser/ui.d.ts +3 -0
  17. package/dist/browser/ui.js +172 -8
  18. package/dist/browser/workbench-contract.d.ts +4 -11
  19. package/dist/browser/workbench.css +346 -200
  20. package/dist/browser/workbench.d.ts +1 -1
  21. package/dist/browser/workbench.js +1056 -367
  22. package/dist/browser/workbenchSelect-BqUPacsr.js +31 -0
  23. package/dist/common/authoringExamples.d.ts +4 -3
  24. package/dist/common/connector-proxy.d.ts +32 -0
  25. package/dist/common/control-api-conformance.js +54 -3
  26. package/dist/common/control-api.d.ts +6 -0
  27. package/dist/common/control-api.js +58 -4
  28. package/dist/common/control-requests.d.ts +4 -0
  29. package/dist/common/control-requests.js +1299 -68
  30. package/dist/common/feishu-subscriptions.d.ts +1 -5
  31. package/dist/common/flow-connectionUsage.d.ts +1 -0
  32. package/dist/common/flow-encoding.js +34 -0
  33. package/dist/common/flow-semantics.js +675 -252
  34. package/dist/common/integration-trigger.js +23 -0
  35. package/dist/common/mcp.js +54 -3
  36. package/dist/common/openapi.d.ts +53 -0
  37. package/dist/common/openapi.js +10390 -0
  38. package/dist/common/poll-trigger.js +23 -0
  39. package/dist/common/provider-triggers.d.ts +1 -1
  40. package/dist/common/provider-triggers.js +166 -16204
  41. package/dist/common/run-events.js +1 -0
  42. package/dist/common/scheduler.d.ts +1 -1
  43. package/dist/common/scheduler.js +31 -1
  44. package/dist/common/webhook-trigger.js +23 -0
  45. package/package.json +5 -1
@@ -1,196 +1,25 @@
1
- //#region src/flow/common/promptTemplate.ts
2
- var promptReferencePattern = /\{\{\s*([^{}\s]+)\s*\}\}/g;
3
- function renderPrompt(template, input) {
4
- return template.replace(promptReferencePattern, (match, name) => {
5
- if (!Object.hasOwn(input, name)) return match;
6
- const value = input[name];
7
- return typeof value == "string" ? value : JSON.stringify(value);
8
- });
9
- }
10
- //#endregion
11
- //#region src/flow/common/connectionUsage.ts
12
- function connectionUsage(document) {
13
- const uses = [];
14
- const graphs = [{
15
- graph: document.graph,
16
- target: { kind: "flow" },
17
- name: ""
18
- }, ...Object.entries(document.subflows).map(([id, subflow]) => ({
19
- graph: subflow.graph,
20
- target: {
21
- kind: "subflow",
22
- id
23
- },
24
- name: subflow.name
25
- }))];
26
- for (const { graph, target, name: graphName } of graphs) for (const [nodeId, node] of Object.entries(graph.nodes)) {
27
- const task = node.kind == "task" && node.taskId != null ? document.tasks[node.taskId] : void 0;
28
- const name = [graphName, node.name ?? task?.name ?? nodeId].filter(Boolean).join(" / ");
29
- const add = (kind, actionId, connectionId) => {
30
- uses.push({
31
- kind,
32
- providerId: actionId.split(".")[0],
33
- actionId,
34
- connectionId,
35
- nodeId,
36
- name,
37
- target
38
- });
39
- };
40
- if (node.kind == "poll" || node.kind == "integration") uses.push({
41
- kind: "trigger",
42
- providerId: node.definition.provider,
43
- connectionId: node.connectionId,
44
- nodeId,
45
- name,
46
- target
47
- });
48
- if (task?.executor.kind == "connector") add("connector", task.executor.action, task.executor.connectionId);
49
- if (node.kind == "task" && node.task != null) {
50
- for (const capability of node.task.capabilities ?? []) if ("mode" in capability && capability.mode == "independent") for (const action of capability.actions) add("code", action.action, action.connectionId);
51
- }
52
- if (task?.executor.kind == "agent") {
53
- for (const tool of task.executor.tools) add("agent", tool.action, tool.connectionId);
54
- const notification = task.executor.notification == null ? void 0 : document.tasks[task.executor.notification.taskId]?.executor;
55
- if (notification?.kind == "connector") add("notification", notification.action, notification.connectionId);
56
- }
57
- }
58
- return uses;
59
- }
60
- function removeConnectionUsage(content, connectionId) {
61
- const document = content.document;
62
- return {
63
- ...content,
64
- document: {
65
- ...document,
66
- tasks: Object.fromEntries(Object.entries(document.tasks).map(([id, task]) => {
67
- const executor = task.executor;
68
- if (executor.kind == "connector" && executor.connectionId == connectionId) {
69
- const { connectionId: _, ...next } = executor;
70
- return [id, {
71
- ...task,
72
- executor: next
73
- }];
74
- }
75
- if (executor.kind == "agent") return [id, {
76
- ...task,
77
- executor: {
78
- ...executor,
79
- tools: executor.tools.map((tool) => {
80
- if (tool.connectionId != connectionId) return tool;
81
- const { connectionId: _, ...next } = tool;
82
- return next;
83
- })
84
- }
85
- }];
86
- return [id, task];
87
- })),
88
- graph: clearNodeConnections(document.graph, connectionId),
89
- subflows: Object.fromEntries(Object.entries(document.subflows).map(([id, subflow]) => [id, {
90
- ...subflow,
91
- graph: clearNodeConnections(subflow.graph, connectionId)
92
- }]))
93
- }
94
- };
95
- }
96
- function clearNodeConnections(graph, connectionId) {
97
- return {
98
- ...graph,
99
- nodes: Object.fromEntries(Object.entries(graph.nodes).map(([id, node]) => {
100
- if ((node.kind == "poll" || node.kind == "integration") && node.connectionId == connectionId) {
101
- const { connectionId: _, ...remaining } = node;
102
- return [id, remaining];
103
- }
104
- if (node.kind != "task" || node.task == null) return [id, node];
105
- const capabilities = node.task.capabilities?.map((capability) => {
106
- if (!("mode" in capability) || capability.mode != "independent") return capability;
107
- return {
108
- ...capability,
109
- actions: capability.actions.map((action) => {
110
- if (action.connectionId != connectionId) return action;
111
- const { connectionId: _, ...remaining } = action;
112
- return remaining;
113
- })
114
- };
115
- });
116
- return [id, capabilities == null ? node : {
117
- ...node,
118
- task: {
119
- ...node.task,
120
- capabilities
121
- }
122
- }];
123
- }))
124
- };
125
- }
126
- //#endregion
127
- //#region src/base/common/json.ts
128
- function hasJsonShape(root) {
129
- if (root === null || typeof root == "boolean" || typeof root == "string") return true;
130
- if (typeof root == "number") return Number.isFinite(root);
131
- if (typeof root != "object") return false;
132
- const ancestors = /* @__PURE__ */ new Set();
133
- const pending = [];
134
- let value = root;
135
- traversal: while (true) {
136
- let keys;
137
- let arrayLength;
138
- if (Array.isArray(value)) {
139
- arrayLength = value.length;
140
- keys = Reflect.ownKeys(value);
141
- if (keys.length != arrayLength + 1) return false;
142
- } else {
143
- const prototype = Reflect.getPrototypeOf(value);
144
- if (prototype != Object.prototype && prototype != null) return false;
145
- keys = Reflect.ownKeys(value);
146
- arrayLength = void 0;
1
+ //#region ../../node_modules/.bun/dequal@2.0.3/node_modules/dequal/lite/index.mjs
2
+ var has = Object.prototype.hasOwnProperty;
3
+ function dequal(foo, bar) {
4
+ var ctor, len;
5
+ if (foo === bar) return true;
6
+ if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
7
+ if (ctor === Date) return foo.getTime() === bar.getTime();
8
+ if (ctor === RegExp) return foo.toString() === bar.toString();
9
+ if (ctor === Array) {
10
+ if ((len = foo.length) === bar.length) while (len-- && dequal(foo[len], bar[len]));
11
+ return len === -1;
147
12
  }
148
- ancestors.add(value);
149
- let index = 0;
150
- while (true) {
151
- if (index >= keys.length) {
152
- ancestors.delete(value);
153
- const parent = pending.pop();
154
- if (parent === void 0) return true;
155
- value = parent.value;
156
- keys = parent.keys;
157
- arrayLength = parent.arrayLength;
158
- index = parent.index;
159
- continue;
160
- }
161
- const key = keys[index++];
162
- if (arrayLength !== void 0) {
163
- if (key == "length") continue;
164
- if (typeof key != "string") return false;
165
- const arrayIndex = Number(key);
166
- if (!Number.isSafeInteger(arrayIndex) || arrayIndex < 0 || arrayIndex >= arrayLength || String(arrayIndex) != key) return false;
167
- } else if (typeof key != "string") return false;
168
- const descriptor = Reflect.getOwnPropertyDescriptor(value, key);
169
- if (descriptor?.enumerable != true || !Object.hasOwn(descriptor, "value")) return false;
170
- const child = descriptor.value;
171
- if (child === null || typeof child == "boolean" || typeof child == "string") continue;
172
- if (typeof child == "number") {
173
- if (!Number.isFinite(child)) return false;
174
- continue;
13
+ if (!ctor || typeof foo === "object") {
14
+ len = 0;
15
+ for (ctor in foo) {
16
+ if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
17
+ if (!(ctor in bar) || !dequal(foo[ctor], bar[ctor])) return false;
175
18
  }
176
- if (typeof child != "object" || ancestors.has(child)) return false;
177
- pending.push({
178
- value,
179
- keys,
180
- arrayLength,
181
- index
182
- });
183
- value = child;
184
- continue traversal;
19
+ return Object.keys(bar).length === len;
185
20
  }
186
21
  }
187
- }
188
- function isJsonObject(value) {
189
- try {
190
- return value != null && typeof value == "object" && !Array.isArray(value) && hasJsonShape(value);
191
- } catch {
192
- return false;
193
- }
22
+ return foo !== foo && bar !== bar;
194
23
  }
195
24
  //#endregion
196
25
  //#region ../../node_modules/.bun/@cfworker+json-schema@4.1.1/node_modules/@cfworker/json-schema/dist/esm/deep-compare-strict.js
@@ -9263,7 +9092,7 @@ var ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
9263
9092
  return required(ZodNonOptional, this, args[0]);
9264
9093
  }
9265
9094
  });
9266
- function object(shape, params) {
9095
+ function object$1(shape, params) {
9267
9096
  return new ZodObject({
9268
9097
  type: "object",
9269
9098
  shape: shape ?? {},
@@ -9574,11 +9403,11 @@ function checkJsonDepth(value, depth = 0) {
9574
9403
  }
9575
9404
  //#endregion
9576
9405
  //#region src/flow/common/triggerScheduleSchema.ts
9577
- var triggerScheduleSchema = array(union([object({
9406
+ var triggerScheduleSchema = array(union([object$1({
9578
9407
  type: literal("cron"),
9579
9408
  expression: string(),
9580
9409
  timezone: string()
9581
- }), object({
9410
+ }), object$1({
9582
9411
  type: literal("every"),
9583
9412
  unit: _enum([
9584
9413
  "day",
@@ -9604,40 +9433,40 @@ function webhookSupportsBody(method) {
9604
9433
  var text = string();
9605
9434
  var json = json$1();
9606
9435
  var strings = array(text);
9607
- var port = object({
9436
+ var port = object$1({
9608
9437
  description: text.optional(),
9609
9438
  jsonSchema: json,
9610
9439
  nullable: boolean(),
9611
9440
  handle: text
9612
9441
  });
9613
9442
  var input = port.extend({ value: json.optional() });
9614
- var group = object({
9443
+ var group = object$1({
9615
9444
  collapsed: boolean().optional(),
9616
9445
  group: text
9617
9446
  });
9618
- var nodeSource = object({
9447
+ var nodeSource = object$1({
9619
9448
  kind: literal("node"),
9620
9449
  nodeId: text,
9621
9450
  output: text,
9622
9451
  field: text.optional()
9623
9452
  });
9624
- var flowSource = object({
9453
+ var flowSource = object$1({
9625
9454
  kind: literal("flow"),
9626
9455
  input: text
9627
9456
  });
9628
9457
  var source = union([
9629
9458
  nodeSource,
9630
9459
  flowSource,
9631
- object({
9460
+ object$1({
9632
9461
  kind: literal("binding"),
9633
9462
  bindingId: text
9634
9463
  })
9635
9464
  ]);
9636
- var fixedInput = union([object({ kind: literal("unset") }), object({
9465
+ var fixedInput = union([object$1({ kind: literal("unset") }), object$1({
9637
9466
  kind: literal("value"),
9638
9467
  value: json
9639
9468
  })]);
9640
- var mapping = union([fixedInput, object({
9469
+ var mapping = union([fixedInput, object$1({
9641
9470
  kind: literal("sources"),
9642
9471
  sources: array(source)
9643
9472
  })]);
@@ -9678,40 +9507,58 @@ var capability = union([
9678
9507
  })).optional()
9679
9508
  })
9680
9509
  ]);
9681
- var inline = object({
9510
+ var inline = object$1({
9682
9511
  ...ports,
9683
9512
  name: text,
9684
9513
  moduleId: text,
9685
9514
  capabilities: array(capability).optional()
9686
9515
  });
9687
- var agentValue = union([object({
9516
+ var agentValue = union([object$1({
9688
9517
  kind: literal("value"),
9689
9518
  value: json
9690
- }), object({
9519
+ }), object$1({
9691
9520
  kind: literal("input"),
9692
9521
  input: text
9693
9522
  })]);
9694
- var agentInput$1 = union([agentValue, object({ kind: literal("model") })]);
9695
- var managed = object({
9523
+ var agentInput$1 = union([agentValue, object$1({ kind: literal("model") })]);
9524
+ var managed = object$1({
9696
9525
  ...ports,
9697
9526
  name: text,
9698
9527
  executor: union([
9699
- object({
9528
+ object$1({
9700
9529
  kind: literal("connector"),
9701
9530
  action: text,
9702
9531
  connectionId: text.optional()
9703
9532
  }),
9704
- object({
9533
+ object$1({
9534
+ kind: literal("openapi"),
9535
+ sourceUrl: text,
9536
+ method: text,
9537
+ path: text,
9538
+ serverUrl: text,
9539
+ document: json,
9540
+ auth: array(object$1({
9541
+ id: text,
9542
+ type: _enum([
9543
+ "bearer",
9544
+ "basic",
9545
+ "apiKey"
9546
+ ]),
9547
+ name: text.optional(),
9548
+ in: _enum(["header", "query"]).optional()
9549
+ }))
9550
+ }),
9551
+ object$1({
9705
9552
  kind: literal("llm"),
9706
9553
  mode: _enum(["chat", "json"])
9707
9554
  }),
9708
- object({
9555
+ object$1({
9709
9556
  kind: literal("agent"),
9710
9557
  code: boolean().optional(),
9711
9558
  model: text,
9712
9559
  prompt: text,
9713
9560
  maxRounds: number(),
9714
- tools: array(object({
9561
+ tools: array(object$1({
9715
9562
  id: text,
9716
9563
  name: text,
9717
9564
  description: text,
@@ -9720,7 +9567,7 @@ var managed = object({
9720
9567
  approval: boolean(),
9721
9568
  inputs: array(input.extend({ source: agentInput$1 }))
9722
9569
  })),
9723
- notification: object({
9570
+ notification: object$1({
9724
9571
  taskId: text,
9725
9572
  messageHandle: text,
9726
9573
  inputs: record(text, agentValue)
@@ -9728,20 +9575,20 @@ var managed = object({
9728
9575
  })
9729
9576
  ])
9730
9577
  });
9731
- var operand = union([object({
9578
+ var operand = union([object$1({
9732
9579
  kind: literal("value"),
9733
9580
  value: json.optional(),
9734
9581
  jsonSchema: json.optional()
9735
- }), object({
9582
+ }), object$1({
9736
9583
  kind: literal("source"),
9737
9584
  source
9738
9585
  })]);
9739
9586
  var condition = {
9740
9587
  matchMode: _enum(["first", "all"]),
9741
- cases: array(object({
9588
+ cases: array(object$1({
9742
9589
  description: text.optional(),
9743
9590
  output: text,
9744
- groups: array(object({ expressions: array(object({
9591
+ groups: array(object$1({ expressions: array(object$1({
9745
9592
  left: operand,
9746
9593
  operator: _enum([
9747
9594
  "!=",
@@ -9773,7 +9620,7 @@ var wait = {
9773
9620
  inputDefinitions: array(input),
9774
9621
  prompt: text
9775
9622
  };
9776
- var webhookOptions = object({
9623
+ var webhookOptions = object$1({
9777
9624
  allowedMethods: never().optional(),
9778
9625
  allowedOrigins: strings.optional(),
9779
9626
  noResponseBody: never().optional(),
@@ -9796,8 +9643,8 @@ var definition = {
9796
9643
  outputs: array(port).refine((definitions) => new Set(definitions.map((output) => output.handle)).size === definitions.length, "Duplicate Trigger output handle."),
9797
9644
  provider: text
9798
9645
  };
9799
- var endpoint = object({
9800
- body: object({
9646
+ var endpoint = object$1({
9647
+ body: object$1({
9801
9648
  allowArray: boolean(),
9802
9649
  allowEmpty: boolean(),
9803
9650
  formats: array(_enum([
@@ -9832,30 +9679,30 @@ var base = {
9832
9679
  timeoutMs: number().optional()
9833
9680
  };
9834
9681
  var node = union([
9835
- object({
9682
+ object$1({
9836
9683
  ...base,
9837
9684
  inputs: record(text, never()),
9838
9685
  kind: literal("condition"),
9839
9686
  ...condition
9840
9687
  }),
9841
- object({
9688
+ object$1({
9842
9689
  ...base,
9843
9690
  inputs: unknown().transform(() => ({})).default({}),
9844
9691
  kind: literal("value"),
9845
9692
  values: array(input)
9846
9693
  }),
9847
- object({
9694
+ object$1({
9848
9695
  ...base,
9849
9696
  kind: literal("subflow"),
9850
9697
  subflowId: text
9851
9698
  }),
9852
- object({
9699
+ object$1({
9853
9700
  ...base,
9854
9701
  kind: literal("task"),
9855
9702
  task: inline,
9856
9703
  additionalInputs: array(input).optional()
9857
9704
  }),
9858
- object({
9705
+ object$1({
9859
9706
  ...base,
9860
9707
  kind: literal("task"),
9861
9708
  taskId: text,
@@ -9871,7 +9718,7 @@ var node = union([
9871
9718
  kind: literal("wait"),
9872
9719
  ...wait
9873
9720
  }).omit({ timeoutMs: true }),
9874
- object({
9721
+ object$1({
9875
9722
  ...trigger,
9876
9723
  kind: literal("manual")
9877
9724
  }),
@@ -9880,44 +9727,44 @@ var node = union([
9880
9727
  kind: literal("error"),
9881
9728
  sourceFlowIds: sourceFlowIds.optional()
9882
9729
  }),
9883
- object({
9730
+ object$1({
9884
9731
  ...trigger,
9885
9732
  kind: literal("webhook"),
9886
9733
  ...webhook
9887
9734
  }),
9888
- object({
9735
+ object$1({
9889
9736
  ...trigger,
9890
9737
  kind: literal("cron"),
9891
9738
  cronTimes: triggerScheduleSchema
9892
9739
  }),
9893
- object({
9740
+ object$1({
9894
9741
  ...trigger,
9895
9742
  kind: literal("poll"),
9896
9743
  connectionId: text.min(1).optional(),
9897
9744
  config: record(text, fixedInput),
9898
- definition: object({
9745
+ definition: object$1({
9899
9746
  ...definition,
9900
9747
  type: literal("poll")
9901
9748
  }),
9902
9749
  pollTimes: triggerScheduleSchema
9903
9750
  }),
9904
- object({
9751
+ object$1({
9905
9752
  ...trigger,
9906
9753
  kind: literal("integration"),
9907
9754
  connectionId: text.min(1).optional(),
9908
9755
  config: record(text, fixedInput),
9909
- definition: object({
9756
+ definition: object$1({
9910
9757
  ...definition,
9911
9758
  type: literal("integration"),
9912
9759
  endpoint
9913
9760
  })
9914
9761
  })
9915
9762
  ]);
9916
- var target = union([object({ kind: literal("flow") }), object({
9763
+ var target = union([object$1({ kind: literal("flow") }), object$1({
9917
9764
  kind: literal("subflow"),
9918
9765
  id: text
9919
9766
  })]);
9920
- var edge = object({
9767
+ var edge = object$1({
9921
9768
  source: text,
9922
9769
  target: text,
9923
9770
  sourceHandle: text.optional()
@@ -9926,31 +9773,31 @@ var at = {
9926
9773
  nodeId: text,
9927
9774
  target
9928
9775
  };
9929
- var subflow = object({
9776
+ var subflow = object$1({
9930
9777
  name: text,
9931
9778
  inputs: array(input),
9932
9779
  outputs: array(port.extend({ sources: array(union([nodeSource, flowSource])) }))
9933
9780
  });
9934
- var graph = object({
9781
+ var graph = object$1({
9935
9782
  nodes: record(text, node),
9936
9783
  edges: array(edge).default([])
9937
9784
  });
9938
- var binding = object({
9785
+ var binding = object$1({
9939
9786
  kind: literal("variable"),
9940
9787
  target: text
9941
9788
  });
9942
- var module = object({
9789
+ var module = object$1({
9943
9790
  name: text,
9944
9791
  imports: strings,
9945
9792
  source: text
9946
9793
  });
9947
- var document = object({
9794
+ var document = object$1({
9948
9795
  bindings: record(text, binding),
9949
9796
  graph,
9950
9797
  subflows: record(text, subflow.extend({ graph })),
9951
9798
  tasks: record(text, managed)
9952
9799
  });
9953
- object({
9800
+ object$1({
9954
9801
  modelVersion: union([
9955
9802
  literal(2),
9956
9803
  literal(4),
@@ -9992,14 +9839,14 @@ var shapes = {
9992
9839
  },
9993
9840
  "graph.node.delete": at,
9994
9841
  "graph.node.field.set": union([
9995
- object({
9842
+ object$1({
9996
9843
  ...at,
9997
9844
  kind: literal("graph.node.field.set"),
9998
9845
  field: literal("connectionId"),
9999
9846
  before: text.min(1).optional(),
10000
9847
  value: text.min(1).optional()
10001
9848
  }),
10002
- object({
9849
+ object$1({
10003
9850
  ...at,
10004
9851
  kind: literal("graph.node.field.set"),
10005
9852
  field: _enum([
@@ -10010,14 +9857,14 @@ var shapes = {
10010
9857
  before: text.optional(),
10011
9858
  value: text.optional()
10012
9859
  }),
10013
- object({
9860
+ object$1({
10014
9861
  ...at,
10015
9862
  kind: literal("graph.node.field.set"),
10016
9863
  field: literal("maxExecutions"),
10017
9864
  before: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
10018
9865
  value: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional()
10019
9866
  }),
10020
- object({
9867
+ object$1({
10021
9868
  ...at,
10022
9869
  kind: literal("graph.node.field.set"),
10023
9870
  field: literal("timeoutMs"),
@@ -10038,8 +9885,8 @@ var shapes = {
10038
9885
  },
10039
9886
  "graph.node.condition.set": {
10040
9887
  ...at,
10041
- before: object(condition),
10042
- value: object(condition)
9888
+ before: object$1(condition),
9889
+ value: object$1(condition)
10043
9890
  },
10044
9891
  "graph.node.values.set": {
10045
9892
  ...at,
@@ -10048,20 +9895,20 @@ var shapes = {
10048
9895
  },
10049
9896
  "graph.node.resolution.set": {
10050
9897
  ...at,
10051
- target: object({ kind: literal("flow") }),
10052
- before: object(wait),
10053
- value: object(wait)
9898
+ target: object$1({ kind: literal("flow") }),
9899
+ before: object$1(wait),
9900
+ value: object$1(wait)
10054
9901
  },
10055
9902
  "graph.node.webhook.set": {
10056
9903
  ...at,
10057
- target: object({ kind: literal("flow") }),
10058
- before: object(webhook),
10059
- value: object(webhook)
9904
+ target: object$1({ kind: literal("flow") }),
9905
+ before: object$1(webhook),
9906
+ value: object$1(webhook)
10060
9907
  },
10061
9908
  "graph.node.task.ports.set": {
10062
9909
  ...at,
10063
- before: object(ports),
10064
- value: object(ports)
9910
+ before: object$1(ports),
9911
+ value: object$1(ports)
10065
9912
  },
10066
9913
  "graph.node.task.name.set": {
10067
9914
  ...at,
@@ -10121,6 +9968,11 @@ var shapes = {
10121
9968
  before: text.optional(),
10122
9969
  value: text.optional()
10123
9970
  },
9971
+ "task.openapi.set": {
9972
+ taskId: text,
9973
+ before: managed,
9974
+ value: managed
9975
+ },
10124
9976
  "task.agent.set": {
10125
9977
  taskId: text,
10126
9978
  before: managed,
@@ -10137,7 +9989,7 @@ var shapes = {
10137
9989
  value: text
10138
9990
  }
10139
9991
  };
10140
- array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object({
9992
+ array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object$1({
10141
9993
  kind: literal(kind),
10142
9994
  ...shape
10143
9995
  })])).values()])).min(1);
@@ -10551,6 +10403,557 @@ function hasRetiredRef(value) {
10551
10403
  return source.contentMediaType == "oomol/ref" || Object.values(source).some(hasRetiredRef);
10552
10404
  }
10553
10405
  //#endregion
10406
+ //#region src/openapi/common/openapi.ts
10407
+ var methods = [
10408
+ "get",
10409
+ "put",
10410
+ "post",
10411
+ "delete",
10412
+ "options",
10413
+ "head",
10414
+ "patch",
10415
+ "trace"
10416
+ ];
10417
+ function object(value) {
10418
+ if (value == null || typeof value != "object" || Array.isArray(value)) throw new Error("Expected an OpenAPI object.");
10419
+ return value;
10420
+ }
10421
+ function httpUrl(value, base) {
10422
+ const url = new URL(value, base);
10423
+ if (!["http:", "https:"].includes(url.protocol) || url.username || url.password || url.hash) throw new Error("An HTTP(S) URL without credentials or fragment is required.");
10424
+ return url.href;
10425
+ }
10426
+ function parseOpenApi(value) {
10427
+ const doc = object(value);
10428
+ if (typeof doc.openapi != "string" || !/^3\.[01]\.\d+$/.test(doc.openapi)) throw new Error("Only OpenAPI 3.0 and 3.1 JSON documents are supported.");
10429
+ object(doc.paths);
10430
+ return doc;
10431
+ }
10432
+ function pointer(doc, ref) {
10433
+ if (!ref.startsWith("#/")) throw new Error("External OpenAPI references are not supported.");
10434
+ let value = doc;
10435
+ for (const key of decodeURIComponent(ref.slice(2)).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~"))) {
10436
+ const source = object(value);
10437
+ if (!Object.hasOwn(source, key)) throw new Error("An OpenAPI reference is missing.");
10438
+ value = source[key];
10439
+ }
10440
+ return value;
10441
+ }
10442
+ function resolved(doc, value) {
10443
+ let result = object(value);
10444
+ const seen = /* @__PURE__ */ new Set();
10445
+ while (typeof result.$ref == "string") {
10446
+ if (seen.has(result.$ref)) throw new Error("Circular non-schema reference is unsupported.");
10447
+ seen.add(result.$ref);
10448
+ const { $ref, ...siblings } = result;
10449
+ result = {
10450
+ ...object(pointer(doc, $ref)),
10451
+ ...siblings
10452
+ };
10453
+ }
10454
+ return result;
10455
+ }
10456
+ function operation(doc, path, method) {
10457
+ const item = resolved(doc, object(doc.paths)[path]);
10458
+ if (!methods.includes(method) || item[method] == null) throw new Error("The selected operation is no longer available.");
10459
+ return {
10460
+ item,
10461
+ op: object(item[method])
10462
+ };
10463
+ }
10464
+ function servers(value, path, method) {
10465
+ const doc = parseOpenApi(value);
10466
+ const { item, op } = operation(doc, path, method);
10467
+ const entries = op.servers ?? item.servers ?? doc.servers;
10468
+ if (!Array.isArray(entries) || entries.length == 0) return [{ url: "/" }];
10469
+ return entries.map(object);
10470
+ }
10471
+ function snapshot(documentValue, path, method) {
10472
+ const doc = parseOpenApi(documentValue);
10473
+ const { item, op } = operation(doc, path, method);
10474
+ const security = op.security ?? doc.security ?? [];
10475
+ const result = {
10476
+ openapi: doc.openapi,
10477
+ paths: { [path]: {
10478
+ [method]: op,
10479
+ ...item.parameters == null ? {} : { parameters: item.parameters }
10480
+ } },
10481
+ servers: servers(doc, path, method),
10482
+ security
10483
+ };
10484
+ const visited = /* @__PURE__ */ new Set();
10485
+ function copy(ref) {
10486
+ if (visited.has(ref)) return;
10487
+ visited.add(ref);
10488
+ const value = pointer(doc, ref);
10489
+ const keys = decodeURIComponent(ref.slice(2)).split("/").map((part) => part.replace(/~1/g, "/").replace(/~0/g, "~"));
10490
+ if (keys.some((key) => [
10491
+ "__proto__",
10492
+ "constructor",
10493
+ "prototype"
10494
+ ].includes(key))) throw new Error("Unsupported reference key.");
10495
+ let target = result;
10496
+ for (const key of keys.slice(0, -1)) {
10497
+ if (!Object.hasOwn(target, key)) target[key] = {};
10498
+ target = object(target[key]);
10499
+ }
10500
+ target[keys.at(-1)] = structuredClone(value);
10501
+ visit(value);
10502
+ }
10503
+ function visit(value) {
10504
+ if (value == null || typeof value != "object") return;
10505
+ if (Array.isArray(value)) {
10506
+ value.forEach(visit);
10507
+ return;
10508
+ }
10509
+ if (typeof object(value).$ref == "string") copy(object(value).$ref);
10510
+ for (const [key, child] of Object.entries(value)) if (![
10511
+ "example",
10512
+ "examples",
10513
+ "default"
10514
+ ].includes(key)) visit(child);
10515
+ }
10516
+ visit(result);
10517
+ for (const entry of security) for (const name of Object.keys(object(entry))) copy(`#/components/securitySchemes/${name.replace(/~/g, "~0").replace(/\//g, "~1")}`);
10518
+ return structuredClone(result);
10519
+ }
10520
+ function schema$1(doc, schemaValue) {
10521
+ const defs = {};
10522
+ const ids = /* @__PURE__ */ new Map();
10523
+ function convert(value) {
10524
+ if (typeof value == "boolean") return value;
10525
+ const source = object(value);
10526
+ if (source.format == "binary" || source.$dynamicRef != null || source.$id != null) throw new Error("Binary and dynamically scoped schemas are unsupported.");
10527
+ const result = {};
10528
+ for (const [key, child] of Object.entries(source)) {
10529
+ if ([
10530
+ "nullable",
10531
+ "example",
10532
+ "xml",
10533
+ "discriminator",
10534
+ "__proto__"
10535
+ ].includes(key)) continue;
10536
+ if (key == "$ref") {
10537
+ if (typeof child != "string") throw new Error("Invalid schema reference.");
10538
+ let id = ids.get(child);
10539
+ if (id == null) {
10540
+ id = `s${ids.size}`;
10541
+ ids.set(child, id);
10542
+ defs[id] = convert(pointer(doc, child));
10543
+ }
10544
+ result.$ref = `#/$defs/${id}`;
10545
+ } else if ([
10546
+ "properties",
10547
+ "patternProperties",
10548
+ "$defs",
10549
+ "definitions",
10550
+ "dependentSchemas"
10551
+ ].includes(key)) result[key] = Object.fromEntries(Object.entries(object(child)).map(([name, childSchema]) => [name, convert(childSchema)]));
10552
+ else if ([
10553
+ "allOf",
10554
+ "anyOf",
10555
+ "oneOf",
10556
+ "prefixItems"
10557
+ ].includes(key)) {
10558
+ if (!Array.isArray(child)) throw new Error("Invalid schema composition.");
10559
+ result[key] = child.map(convert);
10560
+ } else if ([
10561
+ "items",
10562
+ "additionalProperties",
10563
+ "not",
10564
+ "if",
10565
+ "then",
10566
+ "else",
10567
+ "contains",
10568
+ "propertyNames",
10569
+ "unevaluatedProperties"
10570
+ ].includes(key)) result[key] = convert(child);
10571
+ else result[key] = child;
10572
+ }
10573
+ if (source.nullable === true) return { anyOf: [result, { type: "null" }] };
10574
+ for (const key of ["minimum", "maximum"]) {
10575
+ const exclusive = key == "minimum" ? "exclusiveMinimum" : "exclusiveMaximum";
10576
+ if (typeof result[exclusive] == "boolean") {
10577
+ if (result[exclusive] && typeof result[key] == "number") {
10578
+ result[exclusive] = result[key];
10579
+ delete result[key];
10580
+ } else delete result[exclusive];
10581
+ }
10582
+ }
10583
+ return result;
10584
+ }
10585
+ let converted = convert(schemaValue);
10586
+ if (typeof converted == "object" && converted != null && typeof object(converted).$ref == "string") {
10587
+ const id = String(object(converted).$ref).slice(8);
10588
+ const { $ref: _ref, ...siblings } = object(converted);
10589
+ converted = {
10590
+ ...object(defs[id]),
10591
+ ...siblings
10592
+ };
10593
+ }
10594
+ if (typeof converted == "boolean") return converted;
10595
+ return {
10596
+ $schema: "https://json-schema.org/draft/2020-12/schema",
10597
+ ...object(converted),
10598
+ ...Object.keys(defs).length ? { $defs: defs } : {}
10599
+ };
10600
+ }
10601
+ function parameters(config) {
10602
+ const doc = parseOpenApi(config.document);
10603
+ const { item, op } = operation(doc, config.path, config.method);
10604
+ const entries = /* @__PURE__ */ new Map();
10605
+ for (const value of [...item.parameters ?? [], ...op.parameters ?? []]) {
10606
+ const p = resolved(doc, value);
10607
+ if (![
10608
+ "path",
10609
+ "query",
10610
+ "header"
10611
+ ].includes(String(p.in)) || typeof p.name != "string" || p.content != null) throw new Error("Only schema-based path, query and header parameters are supported.");
10612
+ if (p.allowReserved === true) throw new Error("allowReserved parameters are unsupported.");
10613
+ if ((p.style ?? (p.in == "query" ? "form" : "simple")) != (p.in == "query" ? "form" : "simple")) throw new Error("Only form query and simple path/header serialization are supported.");
10614
+ entries.set(`${p.in}.${p.in == "header" ? p.name.toLowerCase() : p.name}`, p);
10615
+ }
10616
+ return [...entries.values()];
10617
+ }
10618
+ function jsonContent(doc, value) {
10619
+ const content = resolved(doc, value);
10620
+ const media = object(content.content);
10621
+ const mediaType = media["application/json"] != null ? "application/json" : Object.keys(media).find((key) => /^application\/.+\+json$/.test(key));
10622
+ const json = mediaType == null ? void 0 : media[mediaType];
10623
+ if (json == null) throw new Error("Only JSON request and response bodies are supported.");
10624
+ return {
10625
+ schema: schema$1(doc, object(json).schema ?? {}),
10626
+ required: content.required === true,
10627
+ mediaType
10628
+ };
10629
+ }
10630
+ function authHandles(auth) {
10631
+ return auth.flatMap((scheme) => scheme.type == "basic" ? [`auth.${scheme.id}.username`, `auth.${scheme.id}.password`] : [`auth.${scheme.id}.token`]);
10632
+ }
10633
+ function openApiTask(config, name = "OpenAPI") {
10634
+ if (!config.path) return {
10635
+ name,
10636
+ executor: config,
10637
+ inputs: [],
10638
+ outputs: []
10639
+ };
10640
+ const doc = parseOpenApi(config.document);
10641
+ const { op } = operation(doc, config.path, config.method);
10642
+ const params = parameters(config);
10643
+ const inputs = params.map((p) => {
10644
+ const jsonSchema = schema$1(doc, p.schema ?? {});
10645
+ const defaultValue = typeof jsonSchema == "boolean" ? void 0 : object(jsonSchema).default;
10646
+ return {
10647
+ handle: `${p.in}.${p.name}`,
10648
+ jsonSchema,
10649
+ nullable: p.required !== true && p.in != "path" || matchesSchema(null, jsonSchema),
10650
+ ...typeof p.description == "string" ? { description: p.description } : {},
10651
+ ...defaultValue === void 0 ? {} : { value: defaultValue }
10652
+ };
10653
+ });
10654
+ if (op.requestBody != null) {
10655
+ if (config.method == "get" || config.method == "head") throw new Error("GET and HEAD request bodies are unsupported.");
10656
+ const body = jsonContent(doc, op.requestBody);
10657
+ inputs.push({
10658
+ handle: "body",
10659
+ jsonSchema: body.schema,
10660
+ nullable: !body.required || matchesSchema(null, body.schema)
10661
+ });
10662
+ }
10663
+ const occupied = new Set(params.map((p) => `${p.in}.${p.in == "header" ? String(p.name).toLowerCase() : p.name}`));
10664
+ for (const auth of config.auth) {
10665
+ const location = auth.type == "apiKey" ? `${auth.in}.${auth.in == "header" ? auth.name?.toLowerCase() : auth.name}` : "header.authorization";
10666
+ if (occupied.has(location)) throw new Error("Authentication conflicts with a parameter or another security scheme.");
10667
+ if (auth.type == "apiKey" && (!auth.name || !["header", "query"].includes(auth.in ?? ""))) throw new Error("API Key requires a name and location.");
10668
+ occupied.add(location);
10669
+ }
10670
+ inputs.push(...authHandles(config.auth).map((handle) => ({
10671
+ handle,
10672
+ jsonSchema: { type: "string" },
10673
+ nullable: false
10674
+ })));
10675
+ const responses = object(op.responses);
10676
+ const schemas = [];
10677
+ for (const [status, response] of Object.entries(responses)) if (/^2\d\d$|^2XX$/.test(status) || status == "default") {
10678
+ const r = resolved(doc, response);
10679
+ if (r.content == null) schemas.push({ type: "null" });
10680
+ else {
10681
+ jsonContent(doc, r);
10682
+ for (const [mediaType, media] of Object.entries(object(r.content))) if (/^application\/(json|.+\+json)$/.test(mediaType)) schemas.push(schema$1(doc, object(media).schema ?? {}));
10683
+ }
10684
+ }
10685
+ if (!schemas.length) throw new Error("A successful JSON response definition is required.");
10686
+ return {
10687
+ name,
10688
+ executor: config,
10689
+ inputs,
10690
+ outputs: [
10691
+ {
10692
+ handle: "body",
10693
+ jsonSchema: schemas.length == 1 ? schemas[0] : {
10694
+ $schema: "https://json-schema.org/draft/2020-12/schema",
10695
+ anyOf: schemas.map((s, index) => inlineSchema(s, index))
10696
+ },
10697
+ nullable: config.method == "head" || schemas.some((item) => matchesSchema(null, item))
10698
+ },
10699
+ {
10700
+ handle: "statusCode",
10701
+ jsonSchema: { type: "integer" },
10702
+ nullable: false
10703
+ },
10704
+ {
10705
+ handle: "headers",
10706
+ jsonSchema: {
10707
+ type: "object",
10708
+ additionalProperties: { type: "string" }
10709
+ },
10710
+ nullable: false
10711
+ }
10712
+ ]
10713
+ };
10714
+ }
10715
+ function inlineSchema(value, index) {
10716
+ if (Array.isArray(value)) return value.map((item) => inlineSchema(item, index));
10717
+ if (value == null || typeof value != "object") return value;
10718
+ return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, key == "$ref" && typeof child == "string" && child.startsWith("#/") ? `#/anyOf/${index}/${child.slice(2)}` : inlineSchema(child, index)]));
10719
+ }
10720
+ /** The canvas validator and property panel share the same configuration contract. */
10721
+ function openApiFieldIssues(task) {
10722
+ if (task.executor.kind != "openapi") return [];
10723
+ const config = task.executor;
10724
+ let field = "sourceUrl";
10725
+ try {
10726
+ if (!config.sourceUrl.trim()) return [{
10727
+ field,
10728
+ message: "Enter an OpenAPI JSON document URL."
10729
+ }];
10730
+ httpUrl(config.sourceUrl);
10731
+ field = "operation";
10732
+ if (!config.path) return [{
10733
+ field,
10734
+ message: "Select an OpenAPI operation."
10735
+ }];
10736
+ field = "serverUrl";
10737
+ httpUrl(config.serverUrl);
10738
+ if (new URL(config.serverUrl).search) throw new Error("Server URLs must not contain a query string.");
10739
+ field = "operation";
10740
+ if (!dequal(config.document, snapshot(config.document, config.path, config.method))) return [{
10741
+ field,
10742
+ message: "Save only the selected operation and its dependencies."
10743
+ }];
10744
+ const expected = openApiTask(config, task.name);
10745
+ if (!dequal(expected.inputs, task.inputs) || !dequal(expected.outputs, task.outputs)) return [{
10746
+ field,
10747
+ message: "OpenAPI ports must match the saved operation."
10748
+ }];
10749
+ return [];
10750
+ } catch (error) {
10751
+ return [{
10752
+ field,
10753
+ message: error.message
10754
+ }];
10755
+ }
10756
+ }
10757
+ function openApiIssues(task) {
10758
+ return openApiFieldIssues(task).map((issue) => issue.message);
10759
+ }
10760
+ //#endregion
10761
+ //#region src/flow/common/promptTemplate.ts
10762
+ var promptReferencePattern = /\{\{\s*([^{}\s]+)\s*\}\}/g;
10763
+ function renderPrompt(template, input) {
10764
+ return template.replace(promptReferencePattern, (match, name) => {
10765
+ if (!Object.hasOwn(input, name)) return match;
10766
+ const value = input[name];
10767
+ return typeof value == "string" ? value : JSON.stringify(value);
10768
+ });
10769
+ }
10770
+ //#endregion
10771
+ //#region src/flow/common/connectionUsage.ts
10772
+ function connectionUsage(document) {
10773
+ const uses = [];
10774
+ const graphs = [{
10775
+ graph: document.graph,
10776
+ target: { kind: "flow" },
10777
+ name: ""
10778
+ }, ...Object.entries(document.subflows).map(([id, subflow]) => ({
10779
+ graph: subflow.graph,
10780
+ target: {
10781
+ kind: "subflow",
10782
+ id
10783
+ },
10784
+ name: subflow.name
10785
+ }))];
10786
+ for (const { graph, target, name: graphName } of graphs) for (const [nodeId, node] of Object.entries(graph.nodes)) {
10787
+ const task = node.kind == "task" && node.taskId != null ? document.tasks[node.taskId] : void 0;
10788
+ const name = [graphName, node.name ?? task?.name ?? nodeId].filter(Boolean).join(" / ");
10789
+ const add = (kind, actionId, connectionId) => {
10790
+ uses.push({
10791
+ kind,
10792
+ providerId: actionId.split(".")[0],
10793
+ actionId,
10794
+ connectionId,
10795
+ nodeId,
10796
+ name,
10797
+ target
10798
+ });
10799
+ };
10800
+ if (node.kind == "poll" || node.kind == "integration") uses.push({
10801
+ kind: "trigger",
10802
+ triggerId: node.definition.key,
10803
+ providerId: node.definition.provider,
10804
+ connectionId: node.connectionId,
10805
+ nodeId,
10806
+ name,
10807
+ target
10808
+ });
10809
+ if (task?.executor.kind == "connector") add("connector", task.executor.action, task.executor.connectionId);
10810
+ if (node.kind == "task" && node.task != null) {
10811
+ for (const capability of node.task.capabilities ?? []) if ("mode" in capability && capability.mode == "independent") for (const action of capability.actions) add("code", action.action, action.connectionId);
10812
+ }
10813
+ if (task?.executor.kind == "agent") {
10814
+ for (const tool of task.executor.tools) add("agent", tool.action, tool.connectionId);
10815
+ const notification = task.executor.notification == null ? void 0 : document.tasks[task.executor.notification.taskId]?.executor;
10816
+ if (notification?.kind == "connector") add("notification", notification.action, notification.connectionId);
10817
+ }
10818
+ }
10819
+ return uses;
10820
+ }
10821
+ function removeConnectionUsage(content, connectionId) {
10822
+ const document = content.document;
10823
+ return {
10824
+ ...content,
10825
+ document: {
10826
+ ...document,
10827
+ tasks: Object.fromEntries(Object.entries(document.tasks).map(([id, task]) => {
10828
+ const executor = task.executor;
10829
+ if (executor.kind == "connector" && executor.connectionId == connectionId) {
10830
+ const { connectionId: _, ...next } = executor;
10831
+ return [id, {
10832
+ ...task,
10833
+ executor: next
10834
+ }];
10835
+ }
10836
+ if (executor.kind == "agent") return [id, {
10837
+ ...task,
10838
+ executor: {
10839
+ ...executor,
10840
+ tools: executor.tools.map((tool) => {
10841
+ if (tool.connectionId != connectionId) return tool;
10842
+ const { connectionId: _, ...next } = tool;
10843
+ return next;
10844
+ })
10845
+ }
10846
+ }];
10847
+ return [id, task];
10848
+ })),
10849
+ graph: clearNodeConnections(document.graph, connectionId),
10850
+ subflows: Object.fromEntries(Object.entries(document.subflows).map(([id, subflow]) => [id, {
10851
+ ...subflow,
10852
+ graph: clearNodeConnections(subflow.graph, connectionId)
10853
+ }]))
10854
+ }
10855
+ };
10856
+ }
10857
+ function clearNodeConnections(graph, connectionId) {
10858
+ return {
10859
+ ...graph,
10860
+ nodes: Object.fromEntries(Object.entries(graph.nodes).map(([id, node]) => {
10861
+ if ((node.kind == "poll" || node.kind == "integration") && node.connectionId == connectionId) {
10862
+ const { connectionId: _, ...remaining } = node;
10863
+ return [id, remaining];
10864
+ }
10865
+ if (node.kind != "task" || node.task == null) return [id, node];
10866
+ const capabilities = node.task.capabilities?.map((capability) => {
10867
+ if (!("mode" in capability) || capability.mode != "independent") return capability;
10868
+ return {
10869
+ ...capability,
10870
+ actions: capability.actions.map((action) => {
10871
+ if (action.connectionId != connectionId) return action;
10872
+ const { connectionId: _, ...remaining } = action;
10873
+ return remaining;
10874
+ })
10875
+ };
10876
+ });
10877
+ return [id, capabilities == null ? node : {
10878
+ ...node,
10879
+ task: {
10880
+ ...node.task,
10881
+ capabilities
10882
+ }
10883
+ }];
10884
+ }))
10885
+ };
10886
+ }
10887
+ //#endregion
10888
+ //#region src/base/common/json.ts
10889
+ function hasJsonShape(root) {
10890
+ if (root === null || typeof root == "boolean" || typeof root == "string") return true;
10891
+ if (typeof root == "number") return Number.isFinite(root);
10892
+ if (typeof root != "object") return false;
10893
+ const ancestors = /* @__PURE__ */ new Set();
10894
+ const pending = [];
10895
+ let value = root;
10896
+ traversal: while (true) {
10897
+ let keys;
10898
+ let arrayLength;
10899
+ if (Array.isArray(value)) {
10900
+ arrayLength = value.length;
10901
+ keys = Reflect.ownKeys(value);
10902
+ if (keys.length != arrayLength + 1) return false;
10903
+ } else {
10904
+ const prototype = Reflect.getPrototypeOf(value);
10905
+ if (prototype != Object.prototype && prototype != null) return false;
10906
+ keys = Reflect.ownKeys(value);
10907
+ arrayLength = void 0;
10908
+ }
10909
+ ancestors.add(value);
10910
+ let index = 0;
10911
+ while (true) {
10912
+ if (index >= keys.length) {
10913
+ ancestors.delete(value);
10914
+ const parent = pending.pop();
10915
+ if (parent === void 0) return true;
10916
+ value = parent.value;
10917
+ keys = parent.keys;
10918
+ arrayLength = parent.arrayLength;
10919
+ index = parent.index;
10920
+ continue;
10921
+ }
10922
+ const key = keys[index++];
10923
+ if (arrayLength !== void 0) {
10924
+ if (key == "length") continue;
10925
+ if (typeof key != "string") return false;
10926
+ const arrayIndex = Number(key);
10927
+ if (!Number.isSafeInteger(arrayIndex) || arrayIndex < 0 || arrayIndex >= arrayLength || String(arrayIndex) != key) return false;
10928
+ } else if (typeof key != "string") return false;
10929
+ const descriptor = Reflect.getOwnPropertyDescriptor(value, key);
10930
+ if (descriptor?.enumerable != true || !Object.hasOwn(descriptor, "value")) return false;
10931
+ const child = descriptor.value;
10932
+ if (child === null || typeof child == "boolean" || typeof child == "string") continue;
10933
+ if (typeof child == "number") {
10934
+ if (!Number.isFinite(child)) return false;
10935
+ continue;
10936
+ }
10937
+ if (typeof child != "object" || ancestors.has(child)) return false;
10938
+ pending.push({
10939
+ value,
10940
+ keys,
10941
+ arrayLength,
10942
+ index
10943
+ });
10944
+ value = child;
10945
+ continue traversal;
10946
+ }
10947
+ }
10948
+ }
10949
+ function isJsonObject(value) {
10950
+ try {
10951
+ return value != null && typeof value == "object" && !Array.isArray(value) && hasJsonShape(value);
10952
+ } catch {
10953
+ return false;
10954
+ }
10955
+ }
10956
+ //#endregion
10554
10957
  //#region src/trigger/common/contract.ts
10555
10958
  var errorOutputs = [
10556
10959
  {
@@ -11671,7 +12074,7 @@ function validateResolution(nodeId, node, allowed, path, diagnostics) {
11671
12074
  function validateGraph(graph, document, flowInputs, allowTriggers, path, diagnostics) {
11672
12075
  const analysis = graphPaths(graph);
11673
12076
  const errorTriggers = Object.entries(graph.nodes).filter(([, node]) => node.kind == "error");
11674
- if (errorTriggers.length > 1) for (const [nodeId] of errorTriggers) diagnostics.push(graphDiagnostic("graph.error-trigger-duplicate", "A graph can contain only one Error Trigger.", `${path}/nodes/${nodeId}`));
12077
+ if (errorTriggers.length > 1) for (const [nodeId] of errorTriggers) diagnostics.push(graphDiagnostic("graph.error-trigger-duplicate", "A graph can contain only one Flow Error node.", `${path}/nodes/${nodeId}`));
11675
12078
  const manualTriggers = Object.entries(graph.nodes).filter(([, node]) => node.kind == "manual");
11676
12079
  if (manualTriggers.length > 1) for (const [nodeId] of manualTriggers) diagnostics.push(graphDiagnostic("graph.manual-trigger-duplicate", "A graph can contain only one manual Trigger.", `${path}/nodes/${nodeId}`));
11677
12080
  const seen = /* @__PURE__ */ new Set();
@@ -23642,6 +24045,26 @@ async function validateFlow(revision, engine) {
23642
24045
  for (const taskId of [...closure.dependencies.tasks].toSorted()) {
23643
24046
  const task = revision.document.tasks[taskId];
23644
24047
  if (task == null) continue;
24048
+ for (const message of openApiIssues(task)) checked.diagnostics.push({
24049
+ code: "openapi.config-invalid",
24050
+ column: 0,
24051
+ line: 1,
24052
+ message,
24053
+ path: `/document/tasks/${taskId}/executor`
24054
+ });
24055
+ if (task.executor.kind == "openapi") {
24056
+ const handles = authHandles(task.executor.auth);
24057
+ for (const [graphPath, graph] of graphs) for (const [nodeId, node] of Object.entries(graph.nodes)) if (node.kind == "task" && node.taskId == taskId) for (const handle of handles) {
24058
+ const mapping = node.inputs[handle];
24059
+ if (mapping?.kind != "sources" || mapping.sources.length == 0 || mapping.sources.some((source) => source.kind == "flow")) checked.diagnostics.push({
24060
+ code: "openapi.auth-source",
24061
+ column: 0,
24062
+ line: 1,
24063
+ message: "Authentication requires a deployment variable or upstream output.",
24064
+ path: `${graphPath}/nodes/${nodeId}/inputs/${handle}`
24065
+ });
24066
+ }
24067
+ }
23645
24068
  for (const message of agentConfigIssues(task, revision.document.tasks)) checked.diagnostics.push({
23646
24069
  code: "agent.config-invalid",
23647
24070
  column: 0,