@oomol-lab/open-flow 0.1.0-beta.61 → 0.1.0-beta.63

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 (55) hide show
  1. package/dist/browser/{createResourceDialog-D71fO68i.js → createResourceDialog-BAJXbzNH.js} +20 -7
  2. package/dist/browser/flow-authoring.js +8 -7
  3. package/dist/browser/flow-change-schema.d.ts +1 -0
  4. package/dist/browser/flow-change.d.ts +1 -0
  5. package/dist/browser/flow-change.js +8 -7
  6. package/dist/browser/{flowChanges-DSA0FxxN.js → flowChanges-DpZOQuJE.js} +3001 -2588
  7. package/dist/browser/{flowRunInputEditorStore-Dsxyfwae.js → flowRunInputEditorStore-B2Rw4VsT.js} +1 -1
  8. package/dist/browser/{flowWorkspace-0sUJ5JhQ.js → flowWorkspace-B7a5NNA_.js} +217 -83
  9. package/dist/browser/{icons-DVJvrj1H.js → icons-Db2Jb2iX.js} +2907 -2887
  10. package/dist/browser/preview.css +5 -6
  11. package/dist/browser/preview.js +889 -541
  12. package/dist/browser/{typeScriptSession-fXPMFGjW.js → typeScriptSession-D0bjYDeg.js} +1 -1
  13. package/dist/browser/ui.css +4 -5
  14. package/dist/browser/ui.js +2 -2
  15. package/dist/browser/{value-DL_poNiC.js → value-BADHeZ9I.js} +12 -1
  16. package/dist/browser/workbench-contract.d.ts +10 -0
  17. package/dist/browser/workbench.css +9 -26
  18. package/dist/browser/workbench.d.ts +5 -3
  19. package/dist/browser/workbench.js +272 -178
  20. package/dist/browser/{workbenchSelect-cr4-mKq3.js → workbenchSelect-C-jf6NIM.js} +1 -1
  21. package/dist/command/index.js +45 -44
  22. package/dist/common/authoring.d.ts +1 -1
  23. package/dist/common/authoringSchema.d.ts +1 -0
  24. package/dist/common/connector-action.d.ts +1 -0
  25. package/dist/common/connector-action.js +15 -12
  26. package/dist/common/control-api-conformance.js +1371 -1207
  27. package/dist/common/control-api-errors.d.ts +0 -4
  28. package/dist/common/control-api.d.ts +18 -11
  29. package/dist/common/control-api.js +2053 -2274
  30. package/dist/common/control-requests.d.ts +6 -0
  31. package/dist/common/control-requests.js +64 -33
  32. package/dist/common/decision.js +8 -7
  33. package/dist/common/flow-connectionUsage.d.ts +1 -0
  34. package/dist/common/flow-encoding.d.ts +1 -0
  35. package/dist/common/flow-encoding.js +202 -10
  36. package/dist/common/flow-semantics.js +64 -46
  37. package/dist/common/flow-workflowFile.d.ts +23 -0
  38. package/dist/common/integration-trigger.js +8 -7
  39. package/dist/common/liveDetails.d.ts +138 -0
  40. package/dist/common/localization.d.ts +1 -0
  41. package/dist/common/localization.js +12 -1
  42. package/dist/common/mcp.d.ts +55 -26
  43. package/dist/common/mcp.js +377 -245
  44. package/dist/common/openapi.js +8 -7
  45. package/dist/common/poll-trigger.js +8 -7
  46. package/dist/common/runtime-contract.js +1 -1
  47. package/dist/common/scheduler.d.ts +22 -2
  48. package/dist/common/scheduler.js +354 -83
  49. package/dist/common/trigger-config.d.ts +2 -0
  50. package/dist/common/webhook-trigger.js +8 -7
  51. package/dist/index.d.ts +2 -2
  52. package/package.json +1 -1
  53. package/skills/open-flow/SKILL.md +6 -3
  54. package/skills/open-flow/references/flow-authoring.md +48 -24
  55. package/dist/common/publicationResources.d.ts +0 -29
@@ -22,15 +22,6 @@ function dequal(foo, bar) {
22
22
  return foo !== foo && bar !== bar;
23
23
  }
24
24
  //#endregion
25
- //#region src/openapi/common/authBindings.ts
26
- /** Never allow credentials to enter a Revision as literal node inputs. */
27
- function assertOpenApiAuthBindings(document) {
28
- for (const node of Object.values(document.graph.nodes)) {
29
- if (node.kind != "task" || !("executor" in node.task) || node.task.executor.kind != "openapi") continue;
30
- for (const [handle, mapping] of Object.entries(node.inputs)) if (handle.startsWith("auth.") && mapping.kind == "value") throw new TypeError("OpenAPI authentication accepts deployment variables and upstream outputs only.");
31
- }
32
- }
33
- //#endregion
34
25
  //#region ../../node_modules/.bun/zod@4.6.5/node_modules/zod/v4/core/util.js
35
26
  function getEnumValues(entries) {
36
27
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
@@ -5699,27 +5690,6 @@ function preprocess(fn, schema) {
5699
5690
  out: schema
5700
5691
  });
5701
5692
  }
5702
- function checkJsonDepth(value, depth = 0) {
5703
- if (depth > 64) throw new TypeError("Value exceeds the maximum JSON depth.");
5704
- if (value != null && typeof value == "object") for (const child of Object.values(value)) checkJsonDepth(child, depth + 1);
5705
- }
5706
- //#endregion
5707
- //#region src/flow/common/triggerScheduleSchema.ts
5708
- var triggerScheduleSchema = array(union([object({
5709
- type: literal("cron"),
5710
- expression: string$1(),
5711
- timezone: string$1()
5712
- }), object({
5713
- type: literal("every"),
5714
- unit: _enum([
5715
- "day",
5716
- "hour",
5717
- "minute",
5718
- "month",
5719
- "week"
5720
- ]),
5721
- value: number()
5722
- })]));
5723
5693
  //#endregion
5724
5694
  //#region src/flow/common/webhookMethod.ts
5725
5695
  var webhookMethods = [
@@ -5729,677 +5699,112 @@ var webhookMethods = [
5729
5699
  "PATCH",
5730
5700
  "DELETE"
5731
5701
  ];
5732
- var text = string$1();
5733
- var json$3 = json$4();
5734
- var strings$1 = array(text);
5735
- var port$1 = object({
5736
- description: text.optional(),
5737
- jsonSchema: json$3,
5738
- nullable: boolean(),
5739
- handle: text
5740
- });
5741
- var input = port$1.extend({ value: json$3.optional() });
5742
- var group = object({
5743
- collapsed: boolean().optional(),
5744
- group: text
5745
- });
5746
- var source = union([object({
5747
- kind: literal("node"),
5748
- nodeId: text,
5749
- output: text,
5750
- field: text.optional()
5751
- }), object({
5752
- kind: literal("binding"),
5753
- bindingId: text
5754
- })]);
5755
- var fixedInput = union([object({ kind: literal("unset") }), object({
5756
- kind: literal("value"),
5757
- value: json$3
5758
- })]);
5759
- var mapping = union([fixedInput, object({
5760
- kind: literal("sources"),
5761
- sources: array(source)
5762
- })]);
5763
- var inputs = record$3(text, mapping);
5764
- var ports$1 = {
5765
- inputs: array(union([input, group])),
5766
- outputs: array(union([port$1, group]))
5767
- };
5768
- var capability = union([
5769
- strictObject({
5770
- kind: literal("connector"),
5771
- action: text,
5772
- connectionId: text.optional(),
5773
- connections: array(strictObject({
5774
- connectionId: text,
5775
- alias: text.optional()
5776
- }))
5777
- }),
5778
- strictObject({
5779
- kind: literal("connector"),
5780
- mode: literal("shared")
5781
- }),
5782
- strictObject({
5783
- kind: literal("connector"),
5784
- mode: literal("independent"),
5785
- actions: array(strictObject({
5786
- action: text,
5787
- connectionId: text.optional()
5788
- }))
5789
- }),
5790
- strictObject({
5791
- kind: literal("connector"),
5792
- actionHints: array(text).optional(),
5793
- connectionHints: array(strictObject({
5794
- action: text,
5795
- connectionId: text,
5796
- alias: text.optional()
5797
- })).optional()
5798
- })
5702
+ function webhookSupportsBody(method) {
5703
+ return method !== "GET";
5704
+ }
5705
+ //#endregion
5706
+ //#region src/openapi/common/authBindings.ts
5707
+ /** Never allow credentials to enter a Revision as literal node inputs. */
5708
+ function assertOpenApiAuthBindings(document) {
5709
+ for (const node of Object.values(document.graph.nodes)) {
5710
+ if (node.kind != "task" || !("executor" in node.task) || node.task.executor.kind != "openapi") continue;
5711
+ for (const [handle, mapping] of Object.entries(node.inputs)) if (handle.startsWith("auth.") && mapping.kind == "value") throw new TypeError("OpenAPI authentication accepts deployment variables and upstream outputs only.");
5712
+ }
5713
+ }
5714
+ //#endregion
5715
+ //#region src/flow/common/change.ts
5716
+ var schemaKeywords = /* @__PURE__ */ new Set([
5717
+ "const",
5718
+ "enum",
5719
+ "exclusiveMaximum",
5720
+ "exclusiveMinimum",
5721
+ "maximum",
5722
+ "maxItems",
5723
+ "maxLength",
5724
+ "maxProperties",
5725
+ "minimum",
5726
+ "minItems",
5727
+ "minLength",
5728
+ "minProperties",
5729
+ "multipleOf",
5730
+ "pattern",
5731
+ "required",
5732
+ "type"
5799
5733
  ]);
5800
- var inline = object({
5801
- ...ports$1,
5802
- name: text,
5803
- moduleId: text,
5804
- capabilities: array(capability).optional()
5734
+ function isSchemaKeyword(value) {
5735
+ return schemaKeywords.has(value);
5736
+ }
5737
+ //#endregion
5738
+ //#region src/json-schema-subset/utils.ts
5739
+ var nextId = 0;
5740
+ function createId() {
5741
+ const id = nextId;
5742
+ nextId += 1;
5743
+ return id;
5744
+ }
5745
+ function deepFreeze(target) {
5746
+ if (typeof target === "object" && target !== null && !Object.isFrozen(target)) {
5747
+ for (const key of Object.getOwnPropertyNames(target)) deepFreeze(Reflect.get(target, key));
5748
+ Object.freeze(target);
5749
+ }
5750
+ return target;
5751
+ }
5752
+ function pick(target, keys) {
5753
+ const newTarget = {};
5754
+ for (const key of keys) if (key in target) newTarget[key] = target[key];
5755
+ return newTarget;
5756
+ }
5757
+ function deepCopy(value) {
5758
+ if (typeof value !== "object" || value === null) return value;
5759
+ else if (Array.isArray(value)) {
5760
+ const array = [];
5761
+ for (const [i, element] of value.entries()) array[i] = deepCopy(element);
5762
+ return array;
5763
+ } else {
5764
+ const newObject = {};
5765
+ for (const key in value) newObject[key] = deepCopy(value[key]);
5766
+ return newObject;
5767
+ }
5768
+ }
5769
+ function isDeepEquals(value1, value2) {
5770
+ if (value1 === value2) return true;
5771
+ if (value1 === null) return false;
5772
+ if (typeof value1 !== "object") return false;
5773
+ if (typeof value1 !== typeof value2) return false;
5774
+ if (Array.isArray(value1)) {
5775
+ if (!Array.isArray(value2)) return false;
5776
+ if (value1.length !== value2.length) return false;
5777
+ for (const [i, value1Element] of value1.entries()) if (!isDeepEquals(value1Element, value2[i])) return false;
5778
+ } else {
5779
+ if (Array.isArray(value2)) return false;
5780
+ for (const key in value1) {
5781
+ if (!(key in value2)) return false;
5782
+ if (!isDeepEquals(value1[key], value2[key])) return false;
5783
+ }
5784
+ for (const key in value2) if (!(key in value1)) return false;
5785
+ }
5786
+ return true;
5787
+ }
5788
+ //#endregion
5789
+ //#region src/json-schema-subset/expression/result.ts
5790
+ var ExpressionSingleResult = Object.freeze({
5791
+ Equals: 0,
5792
+ Containing: 1,
5793
+ ContainedBy: 2,
5794
+ Rejection: 3,
5795
+ Intersection: 4
5805
5796
  });
5806
- var agentValue = union([object({
5807
- kind: literal("value"),
5808
- value: json$3
5809
- }), object({
5810
- kind: literal("input"),
5811
- input: text
5812
- })]);
5813
- var agentInput = union([agentValue, object({ kind: literal("model") })]);
5814
- var decisionQuestion = discriminatedUnion("type", [
5815
- strictObject({
5816
- name: text,
5817
- instructions: text,
5818
- type: literal("noul"),
5819
- criteria: strictObject({
5820
- true: text.optional(),
5821
- false: text.optional()
5822
- }).optional()
5823
- }),
5824
- strictObject({
5825
- name: text,
5826
- instructions: text,
5827
- type: literal("choice"),
5828
- criteria: array(strictObject({
5829
- name: text,
5830
- description: text
5831
- }))
5832
- }),
5833
- strictObject({
5834
- name: text,
5835
- instructions: text,
5836
- type: literal("score"),
5837
- criteria: strings$1
5838
- })
5839
- ]);
5840
- var managedFields = object({
5841
- ...ports$1,
5842
- name: text,
5843
- executor: union([
5844
- object({
5845
- kind: literal("connector"),
5846
- action: text,
5847
- connectionId: text.optional()
5848
- }),
5849
- object({
5850
- kind: literal("openapi"),
5851
- sourceUrl: text,
5852
- method: text,
5853
- path: text,
5854
- serverUrl: text,
5855
- document: json$3,
5856
- auth: array(object({
5857
- id: text,
5858
- type: _enum([
5859
- "bearer",
5860
- "basic",
5861
- "apiKey"
5862
- ]),
5863
- name: text.optional(),
5864
- in: _enum(["header", "query"]).optional()
5865
- }))
5866
- }),
5867
- strictObject({
5868
- kind: literal("decision"),
5869
- questions: array(decisionQuestion)
5870
- }),
5871
- object({
5872
- kind: literal("llm"),
5873
- mode: _enum(["chat", "json"])
5874
- }),
5875
- object({
5876
- kind: literal("agent"),
5877
- code: boolean().optional(),
5878
- model: text,
5879
- prompt: text,
5880
- maxRounds: number(),
5881
- tools: array(object({
5882
- id: text,
5883
- name: text,
5884
- description: text,
5885
- action: text,
5886
- connectionId: text.optional(),
5887
- approval: boolean(),
5888
- inputs: array(input.extend({ source: agentInput }))
5889
- })),
5890
- notification: object({
5891
- action: text,
5892
- connectionId: text.optional(),
5893
- inputDefinitions: array(input),
5894
- messageHandle: text,
5895
- inputs: record$3(text, agentValue)
5896
- }).optional()
5897
- })
5898
- ])
5899
- });
5900
- var managed = managedFields.transform(limitDecisionTask);
5901
- var operand$1 = union([object({
5902
- kind: literal("value"),
5903
- value: json$3.optional(),
5904
- jsonSchema: json$3.optional()
5905
- }), object({
5906
- kind: literal("source"),
5907
- source
5908
- })]);
5909
- var condition = {
5910
- matchMode: _enum(["first", "all"]),
5911
- cases: array(object({
5912
- description: text.optional(),
5913
- output: text,
5914
- groups: array(object({ expressions: array(object({
5915
- left: operand$1,
5916
- operator: _enum([
5917
- "!=",
5918
- "<",
5919
- "<=",
5920
- "==",
5921
- ">",
5922
- ">=",
5923
- "contains",
5924
- "endsWith",
5925
- "hasKey",
5926
- "hasValue",
5927
- "isEmpty",
5928
- "isFalse",
5929
- "isNotEmpty",
5930
- "isNotNull",
5931
- "isNull",
5932
- "isTrue",
5933
- "notContains",
5934
- "notHasKey",
5935
- "notHasValue",
5936
- "startsWith"
5937
- ]),
5938
- right: operand$1.optional()
5939
- })) }))
5940
- }))
5941
- };
5942
- var wait = {
5943
- inputDefinitions: array(input),
5944
- prompt: text
5945
- };
5946
- var webhookOptions = object({
5947
- allowedMethods: never().optional(),
5948
- allowedOrigins: strings$1.optional(),
5949
- noResponseBody: never().optional(),
5950
- responseData: text.optional(),
5951
- responseHeaders: record$3(text, text).optional(),
5952
- responseStatusCode: number().int().min(200).max(599).optional()
5953
- });
5954
- var webhook = {
5955
- bodyFields: array(input),
5956
- method: _enum(webhookMethods),
5957
- options: webhookOptions.optional()
5958
- };
5959
- var definition = {
5960
- configInputs: ports$1.inputs,
5961
- definitionVersion: literal(2),
5962
- description: text,
5963
- displayName: text,
5964
- key: text,
5965
- name: text,
5966
- outputs: array(port$1).refine((definitions) => new Set(definitions.map((output) => output.handle)).size === definitions.length, "Duplicate Trigger output handle."),
5967
- provider: text
5968
- };
5969
- var endpoint = object({
5970
- body: object({
5971
- allowArray: boolean(),
5972
- allowEmpty: boolean(),
5973
- formats: array(_enum([
5974
- "form",
5975
- "json",
5976
- "multipart",
5977
- "text"
5978
- ]))
5979
- }),
5980
- methods: array(_enum([
5981
- "DELETE",
5982
- "GET",
5983
- "HEAD",
5984
- "PATCH",
5985
- "POST",
5986
- "PUT"
5987
- ])),
5988
- successStatus: number()
5989
- });
5990
- var sourceFlowIds = array(text.min(1)).refine((ids) => new Set(ids).size === ids.length, "Duplicate source Flow ID.");
5991
- var trigger = {
5992
- name: text,
5993
- description: text.optional(),
5994
- icon: text.optional()
5995
- };
5996
- var base = {
5997
- maxExecutions: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
5998
- inputs,
5999
- name: text.optional(),
6000
- description: text.optional(),
6001
- icon: text.optional(),
6002
- timeoutMs: number().optional()
6003
- };
6004
- var node = union([
6005
- object({
6006
- ...base,
6007
- inputs: record$3(text, never()),
6008
- kind: literal("condition"),
6009
- ...condition
6010
- }),
6011
- object({
6012
- ...base,
6013
- inputs: unknown().transform(() => ({})).default({}),
6014
- kind: literal("value"),
6015
- values: array(input)
6016
- }),
6017
- object({
6018
- ...base,
6019
- kind: literal("task"),
6020
- task: union([inline, managed]),
6021
- additionalInputs: array(input).optional()
6022
- }),
6023
- strictObject({
6024
- ...base,
6025
- kind: literal("approval"),
6026
- ...wait
6027
- }).omit({ timeoutMs: true }),
6028
- strictObject({
6029
- ...base,
6030
- kind: literal("wait"),
6031
- ...wait
6032
- }).omit({ timeoutMs: true }),
6033
- object({
6034
- ...trigger,
6035
- kind: literal("manual")
6036
- }),
6037
- strictObject({
6038
- ...trigger,
6039
- kind: literal("error"),
6040
- sourceFlowIds: sourceFlowIds.optional()
6041
- }),
6042
- object({
6043
- ...trigger,
6044
- kind: literal("webhook"),
6045
- ...webhook
6046
- }),
6047
- object({
6048
- ...trigger,
6049
- kind: literal("cron"),
6050
- cronTimes: triggerScheduleSchema
6051
- }),
6052
- object({
6053
- ...trigger,
6054
- kind: literal("poll"),
6055
- connectionId: text.min(1).optional(),
6056
- config: record$3(text, fixedInput),
6057
- definition: object({
6058
- ...definition,
6059
- type: literal("poll")
6060
- }),
6061
- pollTimes: triggerScheduleSchema
6062
- }),
6063
- object({
6064
- ...trigger,
6065
- kind: literal("integration"),
6066
- connectionId: text.min(1).optional(),
6067
- config: record$3(text, fixedInput),
6068
- definition: object({
6069
- ...definition,
6070
- type: literal("integration"),
6071
- endpoint
6072
- })
6073
- })
6074
- ]);
6075
- /** Configuration schemas shared by the node authoring boundary. */
6076
- var authoringDefinitionSchemas = {
6077
- input,
6078
- port: port$1,
6079
- ports: ports$1,
6080
- condition: strictObject(condition),
6081
- wait: strictObject(wait),
6082
- webhook: strictObject(webhook),
6083
- schedule: triggerScheduleSchema,
6084
- capabilities: array(capability),
6085
- connector: managedFields.shape.executor.options[0].omit({ kind: true }).strict(),
6086
- openapi: managedFields.shape.executor.options[1].omit({ kind: true }).strict(),
6087
- decision: managedFields.shape.executor.options[2].omit({ kind: true }).strict(),
6088
- llm: managedFields.shape.executor.options[3].omit({ kind: true }).strict(),
6089
- agent: managedFields.shape.executor.options[4].omit({
6090
- kind: true,
6091
- notification: true
6092
- }).strict()
6093
- };
6094
- var edge = object({
6095
- source: text,
6096
- target: text,
6097
- sourceHandle: text.optional()
6098
- });
6099
- var at = {
6100
- nodeId: text,
6101
- target: never().optional()
6102
- };
6103
- var graph = object({
6104
- nodes: record$3(text, node),
6105
- edges: array(edge).default([])
6106
- });
6107
- var binding = object({
6108
- kind: literal("variable"),
6109
- target: text
6110
- });
6111
- var module = object({
6112
- name: text,
6113
- imports: strings$1,
6114
- source: text
6115
- });
6116
- var document = preprocess(rejectRetiredDefinitions, object({
6117
- bindings: record$3(text, binding),
6118
- graph
6119
- }));
6120
- var revision = object({
6121
- modelVersion: union([
6122
- literal(2),
6123
- literal(4),
6124
- literal(5),
6125
- literal(6)
6126
- ]),
6127
- document,
6128
- modules: record$3(text, module)
6129
- });
6130
- revision.extend({
6131
- kind: literal("open-flow-flow-revision"),
6132
- version: literal(1)
6133
- });
6134
- function rejectRetiredDefinitions(value) {
6135
- const candidate = record$2(value);
6136
- 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.");
6137
- if (Object.values(record$2(record$2(candidate.graph).nodes)).some((candidateNode) => Object.hasOwn(record$2(candidateNode), "taskId"))) throw new TypeError("Task references are no longer supported.");
6138
- const subflows = candidate.subflows;
6139
- 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.");
6140
- if (Object.values(record$2(record$2(candidate.graph).nodes)).some((candidateNode) => record$2(candidateNode).kind === "subflow")) throw new TypeError("Subflow nodes are no longer supported.");
6141
- return value;
6142
- }
6143
- function record$2(value) {
6144
- return value != null && typeof value == "object" && !Array.isArray(value) ? value : {};
6145
- }
6146
- function decodeRevisionContent(value) {
6147
- checkJsonDepth(value);
6148
- const content = revision.parse(value);
6149
- checkModelVersion(content);
6150
- assertOpenApiAuthBindings(content.document);
6151
- return content;
6152
- }
6153
- var shapes = {
6154
- "graph.trigger.sources.set": {
6155
- nodeId: text,
6156
- before: sourceFlowIds.optional(),
6157
- value: sourceFlowIds.optional()
6158
- },
6159
- "binding.create": {
6160
- bindingId: text,
6161
- binding
6162
- },
6163
- "binding.delete": { bindingId: text },
6164
- "binding.target.set": {
6165
- bindingId: text,
6166
- before: text,
6167
- value: text
6168
- },
6169
- "graph.edge.connect": {
6170
- edge,
6171
- target: never().optional()
6172
- },
6173
- "graph.edge.disconnect": {
6174
- edge,
6175
- target: never().optional()
6176
- },
6177
- "graph.node.create": {
6178
- ...at,
6179
- node
6180
- },
6181
- "graph.node.replace": {
6182
- ...at,
6183
- before: node,
6184
- node
6185
- },
6186
- "graph.node.delete": at,
6187
- "graph.node.field.set": union([
6188
- object({
6189
- ...at,
6190
- kind: literal("graph.node.field.set"),
6191
- field: literal("connectionId"),
6192
- before: text.min(1).optional(),
6193
- value: text.min(1).optional()
6194
- }),
6195
- object({
6196
- ...at,
6197
- kind: literal("graph.node.field.set"),
6198
- field: _enum([
6199
- "description",
6200
- "icon",
6201
- "name"
6202
- ]),
6203
- before: text.optional(),
6204
- value: text.optional()
6205
- }),
6206
- object({
6207
- ...at,
6208
- kind: literal("graph.node.field.set"),
6209
- field: literal("maxExecutions"),
6210
- before: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
6211
- value: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional()
6212
- }),
6213
- object({
6214
- ...at,
6215
- kind: literal("graph.node.field.set"),
6216
- field: literal("timeoutMs"),
6217
- before: number().optional(),
6218
- value: number().optional()
6219
- })
6220
- ]),
6221
- "graph.node.input.set": {
6222
- ...at,
6223
- handle: text,
6224
- before: mapping.optional(),
6225
- value: mapping.optional()
6226
- },
6227
- "graph.node.additional-inputs.set": {
6228
- ...at,
6229
- before: array(input).optional(),
6230
- value: array(input).optional()
6231
- },
6232
- "graph.node.condition.set": {
6233
- ...at,
6234
- before: object(condition),
6235
- value: object(condition)
6236
- },
6237
- "graph.node.values.set": {
6238
- ...at,
6239
- before: array(input),
6240
- value: array(input)
6241
- },
6242
- "graph.node.resolution.set": {
6243
- ...at,
6244
- before: object(wait),
6245
- value: object(wait)
6246
- },
6247
- "graph.node.webhook.set": {
6248
- ...at,
6249
- before: object(webhook),
6250
- value: object(webhook)
6251
- },
6252
- "graph.node.task.ports.set": {
6253
- ...at,
6254
- before: object(ports$1),
6255
- value: object(ports$1)
6256
- },
6257
- "graph.node.task.name.set": {
6258
- ...at,
6259
- before: text,
6260
- value: text
6261
- },
6262
- "graph.node.task.capabilities.set": {
6263
- ...at,
6264
- before: array(capability).optional(),
6265
- value: array(capability).optional()
6266
- },
6267
- "graph.trigger.config.set": {
6268
- nodeId: text,
6269
- name: text,
6270
- before: fixedInput.optional(),
6271
- value: fixedInput.optional()
6272
- },
6273
- "graph.trigger.schedule.set": {
6274
- nodeId: text,
6275
- before: triggerScheduleSchema,
6276
- value: triggerScheduleSchema
6277
- },
6278
- "module.create": {
6279
- moduleId: text,
6280
- module
6281
- },
6282
- "module.delete": { moduleId: text },
6283
- "module.rename": {
6284
- moduleId: text,
6285
- before: text,
6286
- name: text
6287
- },
6288
- "module.source.replace": {
6289
- moduleId: text,
6290
- beforeImports: strings$1,
6291
- beforeSource: text,
6292
- imports: strings$1,
6293
- source: text
6294
- },
6295
- "graph.node.task.set": {
6296
- ...at,
6297
- before: union([inline, managed]),
6298
- value: union([inline, managed])
6299
- }
6300
- };
6301
- array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object({
6302
- kind: literal(kind),
6303
- ...shape
6304
- })])).values()])).min(1);
6305
- function checkModelVersion(content) {
6306
- if (content.modelVersion < 6 && Object.values(content.document.graph.nodes).some((candidateNode) => candidateNode.kind == "task" && "executor" in candidateNode.task)) throw new TypeError("Node-owned managed Tasks require Flow model version 6.");
6307
- if (content.modelVersion < 5 && Object.values(content.document.graph.nodes).some((itemNode) => itemNode.kind == "error")) throw new TypeError("Error workflows require Flow model version 5.");
6308
- }
6309
- //#endregion
6310
- //#region src/flow/common/change.ts
6311
- var schemaKeywords = /* @__PURE__ */ new Set([
6312
- "const",
6313
- "enum",
6314
- "exclusiveMaximum",
6315
- "exclusiveMinimum",
6316
- "maximum",
6317
- "maxItems",
6318
- "maxLength",
6319
- "maxProperties",
6320
- "minimum",
6321
- "minItems",
6322
- "minLength",
6323
- "minProperties",
6324
- "multipleOf",
6325
- "pattern",
6326
- "required",
6327
- "type"
6328
- ]);
6329
- function isSchemaKeyword(value) {
6330
- return schemaKeywords.has(value);
6331
- }
6332
- //#endregion
6333
- //#region src/json-schema-subset/utils.ts
6334
- var nextId = 0;
6335
- function createId() {
6336
- const id = nextId;
6337
- nextId += 1;
6338
- return id;
6339
- }
6340
- function deepFreeze(target) {
6341
- if (typeof target === "object" && target !== null && !Object.isFrozen(target)) {
6342
- for (const key of Object.getOwnPropertyNames(target)) deepFreeze(Reflect.get(target, key));
6343
- Object.freeze(target);
6344
- }
6345
- return target;
6346
- }
6347
- function pick(target, keys) {
6348
- const newTarget = {};
6349
- for (const key of keys) if (key in target) newTarget[key] = target[key];
6350
- return newTarget;
6351
- }
6352
- function deepCopy(value) {
6353
- if (typeof value !== "object" || value === null) return value;
6354
- else if (Array.isArray(value)) {
6355
- const array = [];
6356
- for (const [i, element] of value.entries()) array[i] = deepCopy(element);
6357
- return array;
6358
- } else {
6359
- const newObject = {};
6360
- for (const key in value) newObject[key] = deepCopy(value[key]);
6361
- return newObject;
6362
- }
6363
- }
6364
- function isDeepEquals(value1, value2) {
6365
- if (value1 === value2) return true;
6366
- if (value1 === null) return false;
6367
- if (typeof value1 !== "object") return false;
6368
- if (typeof value1 !== typeof value2) return false;
6369
- if (Array.isArray(value1)) {
6370
- if (!Array.isArray(value2)) return false;
6371
- if (value1.length !== value2.length) return false;
6372
- for (const [i, value1Element] of value1.entries()) if (!isDeepEquals(value1Element, value2[i])) return false;
6373
- } else {
6374
- if (Array.isArray(value2)) return false;
6375
- for (const key in value1) {
6376
- if (!(key in value2)) return false;
6377
- if (!isDeepEquals(value1[key], value2[key])) return false;
6378
- }
6379
- for (const key in value2) if (!(key in value1)) return false;
6380
- }
6381
- return true;
6382
- }
6383
- //#endregion
6384
- //#region src/json-schema-subset/expression/result.ts
6385
- var ExpressionSingleResult = Object.freeze({
6386
- Equals: 0,
6387
- Containing: 1,
6388
- ContainedBy: 2,
6389
- Rejection: 3,
6390
- Intersection: 4
6391
- });
6392
- var ExpressionEquals = toExpression(ExpressionSingleResult.Equals);
6393
- var ExpressionContaining = toExpression(ExpressionSingleResult.Containing);
6394
- var ExpressionContainedBy = toExpression(ExpressionSingleResult.ContainedBy);
6395
- var ExpressionRejection = toExpression(ExpressionSingleResult.Rejection);
6396
- var ExpressionIntersection = toExpression(ExpressionSingleResult.Intersection);
6397
- var ExpressionMaskList = deepFreeze([
6398
- [ExpressionSingleResult.Equals, ExpressionEquals],
6399
- [ExpressionSingleResult.Containing, ExpressionContaining],
6400
- [ExpressionSingleResult.ContainedBy, ExpressionContainedBy],
6401
- [ExpressionSingleResult.Rejection, ExpressionRejection],
6402
- [ExpressionSingleResult.Intersection, ExpressionIntersection]
5797
+ var ExpressionEquals = toExpression(ExpressionSingleResult.Equals);
5798
+ var ExpressionContaining = toExpression(ExpressionSingleResult.Containing);
5799
+ var ExpressionContainedBy = toExpression(ExpressionSingleResult.ContainedBy);
5800
+ var ExpressionRejection = toExpression(ExpressionSingleResult.Rejection);
5801
+ var ExpressionIntersection = toExpression(ExpressionSingleResult.Intersection);
5802
+ var ExpressionMaskList = deepFreeze([
5803
+ [ExpressionSingleResult.Equals, ExpressionEquals],
5804
+ [ExpressionSingleResult.Containing, ExpressionContaining],
5805
+ [ExpressionSingleResult.ContainedBy, ExpressionContainedBy],
5806
+ [ExpressionSingleResult.Rejection, ExpressionRejection],
5807
+ [ExpressionSingleResult.Intersection, ExpressionIntersection]
6403
5808
  ]);
6404
5809
  var ExpressionAny = (() => {
6405
5810
  let expression = 0;
@@ -7279,10 +6684,10 @@ function compileEnumAndConst(context, enumList, constValue, schema) {
7279
6684
  }
7280
6685
  if (compiledEnum.length === 0) recordWarn(context, "all of elements from list is rejected by currently schema object", "enum");
7281
6686
  }
7282
- if (constValue && valid(schema, constValue) === ValidResult.Invalid) isNever = true;
6687
+ if (constValue !== void 0 && valid(schema, constValue) === ValidResult.Invalid) isNever = true;
7283
6688
  if (compiledEnum) {
7284
6689
  if (compiledEnum.length === 0) isNever = true;
7285
- else if (constValue) {
6690
+ else if (constValue !== void 0) {
7286
6691
  let foundEquals = false;
7287
6692
  for (const enumValue of compiledEnum) if (isDeepEquals(enumValue, constValue)) {
7288
6693
  foundEquals = true;
@@ -7295,7 +6700,7 @@ function compileEnumAndConst(context, enumList, constValue, schema) {
7295
6700
  const compiledSchema = {};
7296
6701
  if (schema.type) compiledSchema.type = schema.type;
7297
6702
  if (compiledEnum) compiledSchema.enum = compiledEnum;
7298
- if (constValue) compiledSchema.const = wrapCompiledValue(deepCopy(constValue));
6703
+ if (constValue !== void 0) compiledSchema.const = wrapCompiledValue(deepCopy(constValue));
7299
6704
  return wrapCompiledSchema(kind, compiledSchema, context.delegate, context.path);
7300
6705
  }
7301
6706
  //#endregion
@@ -7690,7 +7095,7 @@ function compileSchema(context, schema) {
7690
7095
  let targetSchema = schema;
7691
7096
  let shouldHandleEnumAndConst = false;
7692
7097
  const { enum: enumList, const: constValue } = schema;
7693
- if (enumList || constValue) {
7098
+ if (enumList || constValue !== void 0) {
7694
7099
  const { enum: _0, const: _1, ...rest } = schema;
7695
7100
  targetSchema = rest;
7696
7101
  shouldHandleEnumAndConst = true;
@@ -8280,7 +7685,7 @@ function schemaEqualsChecker(extendsContext) {
8280
7685
  }
8281
7686
  function isValueEquals(value1, value2) {
8282
7687
  if (value1 === value2) return true;
8283
- if (value1 === null) return false;
7688
+ if (value1 === null || value2 === null) return false;
8284
7689
  if (typeof value1 !== "object") return false;
8285
7690
  if (typeof value1 !== typeof value2) return false;
8286
7691
  if (isCompiledSchema(value1) && isCompiledSchema(value2)) return isCompiledSchemaEquals(value1, value2);
@@ -8846,7 +8251,7 @@ function findMismatchPath(source, target) {
8846
8251
  if ((sourceSchema.maxProperties ?? Number.POSITIVE_INFINITY) > (targetSchema.maxProperties ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxProperties"];
8847
8252
  break;
8848
8253
  }
8849
- case CompiledKind.EnumOrConst: return [...targetPath, targetSchema.const == null ? "enum" : "const"];
8254
+ case CompiledKind.EnumOrConst: return [...targetPath, targetSchema.const === void 0 ? "enum" : "const"];
8850
8255
  }
8851
8256
  return targetPath;
8852
8257
  }
@@ -8895,285 +8300,884 @@ var ExtendsContext = class ExtendsContext {
8895
8300
  }
8896
8301
  }
8897
8302
  };
8898
- //#endregion
8899
- //#region src/json-schema-subset/preprocessing.ts
8900
- function preprocessSchema(schema, compile, printWarnLog = false) {
8901
- const schemaResult = compile(schema);
8902
- if (Array.isArray(schemaResult)) {
8903
- const errorItems = [];
8904
- collectWithPathPrefix(errorItems, schemaResult, "$");
8905
- throw new SchemaError(errorItems);
8906
- }
8907
- const { schema: compiledSchema, warns } = schemaResult;
8908
- if (printWarnLog && warns.length > 0) {
8909
- console.warn(`found ${warns.length} warns after compile schema`);
8910
- for (const warn of warns) console.warn(stringifySchemaError(warn));
8911
- }
8912
- return compiledSchema;
8913
- }
8914
- function preprocessSchemasPair(schema1, schema2, compile, printWarnLog = false) {
8915
- const schemaResult1 = compile(schema1);
8916
- const schemaResult2 = compile(schema2);
8917
- if (Array.isArray(schemaResult1) || Array.isArray(schemaResult2)) {
8918
- const errorItems = [];
8919
- if (Array.isArray(schemaResult1)) collectWithPathPrefix(errorItems, schemaResult1, "$1");
8920
- if (Array.isArray(schemaResult2)) collectWithPathPrefix(errorItems, schemaResult2, "$2");
8921
- throw new SchemaError(errorItems);
8922
- }
8923
- const { schema: compiledSchema1, warns: superWarns } = schemaResult1;
8924
- const { schema: compiledSchema2, warns: subWarns } = schemaResult2;
8925
- if (printWarnLog) {
8926
- if (superWarns.length > 0) console.warn(`found ${superWarns.length} warns after compile superSchema`);
8927
- for (const warn of superWarns) console.warn(stringifySchemaError(warn));
8928
- if (subWarns.length > 0) console.warn(`found ${subWarns.length} warns after compile subSchema`);
8929
- for (const warn of subWarns) console.warn(stringifySchemaError(warn));
8930
- }
8931
- return [compiledSchema1, compiledSchema2];
8932
- }
8933
- function collectWithPathPrefix(errorItems, compiledItems, prefix) {
8934
- for (const compiledItem of compiledItems) {
8935
- const replacedItem = {
8936
- ...compiledItem,
8937
- path: [prefix, ...compiledItem.path]
8938
- };
8939
- errorItems.push(replacedItem);
8940
- }
8941
- }
8942
- //#endregion
8943
- //#region src/json-schema-subset/global.ts
8944
- var SubsetCompareResult = Object.freeze({
8945
- True: 0,
8946
- False: 1,
8947
- Unknown: 2
8303
+ //#endregion
8304
+ //#region src/json-schema-subset/preprocessing.ts
8305
+ function preprocessSchema(schema, compile, printWarnLog = false) {
8306
+ const schemaResult = compile(schema);
8307
+ if (Array.isArray(schemaResult)) {
8308
+ const errorItems = [];
8309
+ collectWithPathPrefix(errorItems, schemaResult, "$");
8310
+ throw new SchemaError(errorItems);
8311
+ }
8312
+ const { schema: compiledSchema, warns } = schemaResult;
8313
+ if (printWarnLog && warns.length > 0) {
8314
+ console.warn(`found ${warns.length} warns after compile schema`);
8315
+ for (const warn of warns) console.warn(stringifySchemaError(warn));
8316
+ }
8317
+ return compiledSchema;
8318
+ }
8319
+ function preprocessSchemasPair(schema1, schema2, compile, printWarnLog = false) {
8320
+ const schemaResult1 = compile(schema1);
8321
+ const schemaResult2 = compile(schema2);
8322
+ if (Array.isArray(schemaResult1) || Array.isArray(schemaResult2)) {
8323
+ const errorItems = [];
8324
+ if (Array.isArray(schemaResult1)) collectWithPathPrefix(errorItems, schemaResult1, "$1");
8325
+ if (Array.isArray(schemaResult2)) collectWithPathPrefix(errorItems, schemaResult2, "$2");
8326
+ throw new SchemaError(errorItems);
8327
+ }
8328
+ const { schema: compiledSchema1, warns: superWarns } = schemaResult1;
8329
+ const { schema: compiledSchema2, warns: subWarns } = schemaResult2;
8330
+ if (printWarnLog) {
8331
+ if (superWarns.length > 0) console.warn(`found ${superWarns.length} warns after compile superSchema`);
8332
+ for (const warn of superWarns) console.warn(stringifySchemaError(warn));
8333
+ if (subWarns.length > 0) console.warn(`found ${subWarns.length} warns after compile subSchema`);
8334
+ for (const warn of subWarns) console.warn(stringifySchemaError(warn));
8335
+ }
8336
+ return [compiledSchema1, compiledSchema2];
8337
+ }
8338
+ function collectWithPathPrefix(errorItems, compiledItems, prefix) {
8339
+ for (const compiledItem of compiledItems) {
8340
+ const replacedItem = {
8341
+ ...compiledItem,
8342
+ path: [prefix, ...compiledItem.path]
8343
+ };
8344
+ errorItems.push(replacedItem);
8345
+ }
8346
+ }
8347
+ //#endregion
8348
+ //#region src/json-schema-subset/global.ts
8349
+ var SubsetCompareResult = Object.freeze({
8350
+ True: 0,
8351
+ False: 1,
8352
+ Unknown: 2
8353
+ });
8354
+ function makeSubsetCompare({ extendsSchemaClasses, delegate } = {}) {
8355
+ const extendsContext = new ExtendsContext(extendsSchemaClasses);
8356
+ return Object.freeze({
8357
+ compile: (schema, payload, printWarnLog) => {
8358
+ const compiler = (candidate) => compile(candidate, extendsContext, payload, delegate);
8359
+ return preprocessSchema(schema, compiler, printWarnLog);
8360
+ },
8361
+ isSubset: (superSchema, subSchema, printWarnLog = false) => {
8362
+ const compiler = (candidate) => compile(candidate, extendsContext, void 0, delegate);
8363
+ const [schema1, schema2] = preprocessSchemasPair(superSchema, subSchema, compiler, printWarnLog);
8364
+ const { errorPath, expression } = checkWithResult(extendsContext, schema1, schema2);
8365
+ const foundTrueExpression = hasEquals(expression) || hasContainedBy(expression);
8366
+ const foundFalseExpression = hasContaining(expression) || hasIntersection(expression) || hasRejection(expression);
8367
+ if (foundTrueExpression && !foundFalseExpression) return { result: SubsetCompareResult.True };
8368
+ if (!foundTrueExpression && foundFalseExpression) return {
8369
+ errorPath,
8370
+ result: SubsetCompareResult.False
8371
+ };
8372
+ return { result: SubsetCompareResult.Unknown };
8373
+ }
8374
+ });
8375
+ }
8376
+ //#endregion
8377
+ //#region ../../node_modules/.bun/@wopjs+cast@0.1.16/node_modules/@wopjs/cast/dist/index.mjs
8378
+ var isString = (x) => typeof x === "string";
8379
+ var isArray = Array.isArray;
8380
+ var isObject = (x) => x !== null && typeof x === "object";
8381
+ var isPlainObject = (x) => isObject(x) && !isArray(x);
8382
+ var toPlainObject = (x) => isPlainObject(x) ? x : void 0;
8383
+ //#endregion
8384
+ //#region src/flow/common/schemaComparer.ts
8385
+ function isStringLikeSchema(value) {
8386
+ return toPlainObject(value)?.type === "string";
8387
+ }
8388
+ function assertSchemaCompareContext(value) {
8389
+ const context = toPlainObject(value);
8390
+ const error = toPlainObject(context?.error);
8391
+ if (context == null || error == null || context.packageId != null && !isString(context.packageId) || error.message != null && !isString(error.message)) throw new TypeError("Invalid schema comparison context.");
8392
+ }
8393
+ function parseSchemaCompareContext(value) {
8394
+ if (value == null) return { error: {} };
8395
+ assertSchemaCompareContext(value);
8396
+ return value;
8397
+ }
8398
+ var SpecialSchema = class SpecialSchema {
8399
+ static setError(fromSchema, toSchema, message) {
8400
+ if (fromSchema instanceof SpecialSchema) fromSchema.context.error.message = message;
8401
+ else if (toSchema instanceof SpecialSchema) toSchema.context.error.message = message;
8402
+ }
8403
+ constructor(id, value, context) {
8404
+ this.id = id;
8405
+ this.value = value;
8406
+ this.context = parseSchemaCompareContext(context);
8407
+ }
8408
+ compare(other) {
8409
+ if (isCompiledSchema(other) && getKind(other) === CompiledKind.Any) return [ExpressionSingleResult.ContainedBy];
8410
+ return this.compareImpl(other);
8411
+ }
8412
+ };
8413
+ var SingleSelectSchema = class SingleSelectSchema extends SpecialSchema {
8414
+ static isMatch(value) {
8415
+ const enumValues = toPlainObject(value)?.enum;
8416
+ return Array.isArray(enumValues) && enumValues.every((v) => isString(v));
8417
+ }
8418
+ constructor(id, value, context) {
8419
+ if (!SingleSelectSchema.isMatch(value)) throw new TypeError("Invalid single-select schema.");
8420
+ super(id, value, context);
8421
+ }
8422
+ compareImpl(other) {
8423
+ if (isStringLikeSchema(other)) return [ExpressionSingleResult.ContainedBy];
8424
+ if (other instanceof SingleSelectSchema) {
8425
+ const f = new Set(this.value.enum);
8426
+ let result = ExpressionSingleResult.Equals;
8427
+ for (const v of other.value.enum) {
8428
+ if (!f.has(v)) result = ExpressionSingleResult.ContainedBy;
8429
+ f.delete(v);
8430
+ }
8431
+ if (f.size === 0) return [result];
8432
+ if (f.size === this.value.enum.length) return [ExpressionSingleResult.Rejection];
8433
+ return [ExpressionSingleResult.Intersection];
8434
+ }
8435
+ return [ExpressionSingleResult.Rejection];
8436
+ }
8437
+ equals(other) {
8438
+ if (other instanceof SingleSelectSchema) {
8439
+ const f = new Set(this.value.enum);
8440
+ for (const v of other.value.enum) {
8441
+ if (!f.has(v)) return false;
8442
+ f.delete(v);
8443
+ }
8444
+ return f.size === 0;
8445
+ }
8446
+ return false;
8447
+ }
8448
+ };
8449
+ var BinarySchema = class BinarySchema extends SpecialSchema {
8450
+ static isMatch(value) {
8451
+ return toPlainObject(value)?.contentMediaType === "oomol/bin";
8452
+ }
8453
+ constructor(id, value, context) {
8454
+ if (!BinarySchema.isMatch(value)) throw new TypeError("Invalid binary schema.");
8455
+ super(id, value, context);
8456
+ }
8457
+ compareImpl(other) {
8458
+ if (other instanceof BinarySchema) return [ExpressionSingleResult.Equals];
8459
+ else {
8460
+ SpecialSchema.setError(this, other, "edgeError.binDiffType");
8461
+ return [ExpressionSingleResult.Rejection];
8462
+ }
8463
+ }
8464
+ equals(other) {
8465
+ return other instanceof BinarySchema;
8466
+ }
8467
+ };
8468
+ var ArtifactSchema = class ArtifactSchema extends SpecialSchema {
8469
+ static isMatch(value) {
8470
+ return toPlainObject(value)?.contentMediaType === "oomol/artifact";
8471
+ }
8472
+ constructor(id, value, context) {
8473
+ if (!ArtifactSchema.isMatch(value)) throw new TypeError("Invalid Artifact schema.");
8474
+ super(id, value, context);
8475
+ }
8476
+ compareImpl(other) {
8477
+ if (other instanceof ArtifactSchema) return [ExpressionSingleResult.Equals];
8478
+ SpecialSchema.setError(this, other, "edgeError.artifactDiffType");
8479
+ return [ExpressionSingleResult.Rejection];
8480
+ }
8481
+ equals(other) {
8482
+ return other instanceof ArtifactSchema;
8483
+ }
8484
+ };
8485
+ function createSchemaComparer() {
8486
+ return makeSubsetCompare({ extendsSchemaClasses: [
8487
+ SingleSelectSchema,
8488
+ BinarySchema,
8489
+ ArtifactSchema
8490
+ ] });
8491
+ }
8492
+ createSchemaComparer();
8493
+ //#endregion
8494
+ //#region src/decision/common/decision.ts
8495
+ var decisionLimits = {
8496
+ choice: 255,
8497
+ score: 10
8498
+ };
8499
+ /** Ordered prefixes are shared by authoring, schemas, validation, and execution. */
8500
+ function limitDecisionQuestion(question) {
8501
+ if (question.type === "noul" || question.criteria.length <= decisionLimits[question.type]) return question;
8502
+ if (question.type === "choice") return {
8503
+ ...question,
8504
+ criteria: question.criteria.slice(0, decisionLimits.choice)
8505
+ };
8506
+ return {
8507
+ ...question,
8508
+ criteria: question.criteria.slice(0, decisionLimits.score)
8509
+ };
8510
+ }
8511
+ function limitDecisionQuestions(questions) {
8512
+ const limited = questions.map(limitDecisionQuestion);
8513
+ return limited.every((question, i) => question === questions[i]) ? questions : limited;
8514
+ }
8515
+ /** Loading an oversized task also updates its previously generated output schemas. */
8516
+ function limitDecisionTask(task) {
8517
+ if (task.executor.kind !== "decision") return task;
8518
+ const original = task.executor.questions;
8519
+ const questions = limitDecisionQuestions(original);
8520
+ if (questions === original) return task;
8521
+ const outputs = task.outputs.map((port) => {
8522
+ if (!("handle" in port)) return port;
8523
+ const index = original.findIndex((question) => question.name === port.handle);
8524
+ if (index < 0 || original[index] === questions[index] || !dequal(port.jsonSchema, answerSchema(original[index]))) return port;
8525
+ return {
8526
+ ...port,
8527
+ jsonSchema: decisionAnswerSchema(questions[index])
8528
+ };
8529
+ });
8530
+ return {
8531
+ ...task,
8532
+ executor: {
8533
+ ...task.executor,
8534
+ questions
8535
+ },
8536
+ outputs
8537
+ };
8538
+ }
8539
+ var probability = {
8540
+ type: "number",
8541
+ minimum: 0,
8542
+ maximum: 1
8543
+ };
8544
+ function decisionAnswerSchema(question) {
8545
+ return answerSchema(limitDecisionQuestion(question));
8546
+ }
8547
+ function answerSchema(question) {
8548
+ const properties = { type: { const: question.type } };
8549
+ if (question.type === "noul") properties.noul = probability;
8550
+ else {
8551
+ const keys = question.type === "choice" ? question.criteria.map((item) => item.name) : question.criteria.map((_, index) => String(index));
8552
+ properties.confidence = probability;
8553
+ properties.probabilities = {
8554
+ type: "object",
8555
+ properties: Object.fromEntries(keys.map((key) => [key, probability])),
8556
+ required: keys,
8557
+ additionalProperties: false
8558
+ };
8559
+ if (question.type === "choice") properties.choice = {
8560
+ type: "string",
8561
+ ...keys.length ? { enum: keys } : {}
8562
+ };
8563
+ else {
8564
+ properties.score = {
8565
+ type: "number",
8566
+ minimum: 0,
8567
+ maximum: Math.max(0, keys.length - 1)
8568
+ };
8569
+ properties.legend = {
8570
+ type: "object",
8571
+ properties: Object.fromEntries(keys.map((key) => [key, { type: "string" }])),
8572
+ required: keys,
8573
+ additionalProperties: false
8574
+ };
8575
+ }
8576
+ }
8577
+ return {
8578
+ type: "object",
8579
+ properties,
8580
+ required: Object.keys(properties)
8581
+ };
8582
+ }
8583
+ function checkJsonDepth(value, depth = 0) {
8584
+ if (depth > 64) throw new TypeError("Value exceeds the maximum JSON depth.");
8585
+ if (value != null && typeof value == "object") for (const child of Object.values(value)) checkJsonDepth(child, depth + 1);
8586
+ }
8587
+ //#endregion
8588
+ //#region src/flow/common/triggerScheduleSchema.ts
8589
+ var triggerScheduleSchema = array(union([object({
8590
+ type: literal("cron"),
8591
+ expression: string$1(),
8592
+ timezone: string$1()
8593
+ }), object({
8594
+ type: literal("every"),
8595
+ unit: _enum([
8596
+ "day",
8597
+ "hour",
8598
+ "minute",
8599
+ "month",
8600
+ "week"
8601
+ ]),
8602
+ value: number()
8603
+ })]));
8604
+ var text = string$1();
8605
+ var json$3 = json$4();
8606
+ var strings$1 = array(text);
8607
+ var port$1 = object({
8608
+ description: text.optional(),
8609
+ jsonSchema: json$3,
8610
+ nullable: boolean(),
8611
+ handle: text
8612
+ });
8613
+ var input = port$1.extend({ value: json$3.optional() });
8614
+ var group = object({
8615
+ collapsed: boolean().optional(),
8616
+ group: text
8617
+ });
8618
+ var source = union([object({
8619
+ kind: literal("node"),
8620
+ nodeId: text,
8621
+ output: text,
8622
+ field: text.optional()
8623
+ }), object({
8624
+ kind: literal("binding"),
8625
+ bindingId: text
8626
+ })]);
8627
+ var fixedInput = union([object({ kind: literal("unset") }), object({
8628
+ kind: literal("value"),
8629
+ value: json$3
8630
+ })]);
8631
+ var mapping = union([fixedInput, object({
8632
+ kind: literal("sources"),
8633
+ sources: array(source)
8634
+ })]);
8635
+ var inputs = record$3(text, mapping);
8636
+ var ports$1 = {
8637
+ inputs: array(union([input, group])),
8638
+ outputs: array(union([port$1, group]))
8639
+ };
8640
+ var capability = union([
8641
+ strictObject({
8642
+ kind: literal("connector"),
8643
+ action: text,
8644
+ connectionId: text.optional(),
8645
+ connections: array(strictObject({
8646
+ connectionId: text,
8647
+ alias: text.optional()
8648
+ }))
8649
+ }),
8650
+ strictObject({
8651
+ kind: literal("connector"),
8652
+ mode: literal("shared")
8653
+ }),
8654
+ strictObject({
8655
+ kind: literal("connector"),
8656
+ mode: literal("independent"),
8657
+ actions: array(strictObject({
8658
+ action: text,
8659
+ connectionId: text.optional()
8660
+ }))
8661
+ }),
8662
+ strictObject({
8663
+ kind: literal("connector"),
8664
+ actionHints: array(text).optional(),
8665
+ connectionHints: array(strictObject({
8666
+ action: text,
8667
+ connectionId: text,
8668
+ alias: text.optional()
8669
+ })).optional()
8670
+ })
8671
+ ]);
8672
+ var inline = object({
8673
+ ...ports$1,
8674
+ name: text,
8675
+ moduleId: text,
8676
+ capabilities: array(capability).optional()
8677
+ });
8678
+ var agentValue = union([object({
8679
+ kind: literal("value"),
8680
+ value: json$3
8681
+ }), object({
8682
+ kind: literal("input"),
8683
+ input: text
8684
+ })]);
8685
+ var agentInput = union([agentValue, object({ kind: literal("model") })]);
8686
+ var decisionQuestion = discriminatedUnion("type", [
8687
+ strictObject({
8688
+ name: text,
8689
+ instructions: text,
8690
+ type: literal("noul"),
8691
+ criteria: strictObject({
8692
+ true: text.optional(),
8693
+ false: text.optional()
8694
+ }).optional()
8695
+ }),
8696
+ strictObject({
8697
+ name: text,
8698
+ instructions: text,
8699
+ type: literal("choice"),
8700
+ criteria: array(strictObject({
8701
+ name: text,
8702
+ description: text
8703
+ }))
8704
+ }),
8705
+ strictObject({
8706
+ name: text,
8707
+ instructions: text,
8708
+ type: literal("score"),
8709
+ criteria: strings$1
8710
+ })
8711
+ ]);
8712
+ var managedFields = object({
8713
+ ...ports$1,
8714
+ name: text,
8715
+ executor: union([
8716
+ object({
8717
+ kind: literal("connector"),
8718
+ action: text,
8719
+ connectionId: text.optional(),
8720
+ outputMode: literal("value").optional()
8721
+ }),
8722
+ object({
8723
+ kind: literal("openapi"),
8724
+ sourceUrl: text,
8725
+ method: text,
8726
+ path: text,
8727
+ serverUrl: text,
8728
+ document: json$3,
8729
+ auth: array(object({
8730
+ id: text,
8731
+ type: _enum([
8732
+ "bearer",
8733
+ "basic",
8734
+ "apiKey"
8735
+ ]),
8736
+ name: text.optional(),
8737
+ in: _enum(["header", "query"]).optional()
8738
+ }))
8739
+ }),
8740
+ strictObject({
8741
+ kind: literal("decision"),
8742
+ questions: array(decisionQuestion)
8743
+ }),
8744
+ object({
8745
+ kind: literal("llm"),
8746
+ mode: _enum(["chat", "json"])
8747
+ }),
8748
+ object({
8749
+ kind: literal("agent"),
8750
+ code: boolean().optional(),
8751
+ model: text,
8752
+ prompt: text,
8753
+ maxRounds: number(),
8754
+ tools: array(object({
8755
+ id: text,
8756
+ name: text,
8757
+ description: text,
8758
+ action: text,
8759
+ connectionId: text.optional(),
8760
+ approval: boolean(),
8761
+ inputs: array(input.extend({ source: agentInput }))
8762
+ })),
8763
+ notification: object({
8764
+ action: text,
8765
+ connectionId: text.optional(),
8766
+ inputDefinitions: array(input),
8767
+ messageHandle: text,
8768
+ inputs: record$3(text, agentValue)
8769
+ }).optional()
8770
+ })
8771
+ ])
8772
+ });
8773
+ var managed = managedFields.transform(limitDecisionTask);
8774
+ var operand$1 = union([object({
8775
+ kind: literal("value"),
8776
+ value: json$3.optional(),
8777
+ jsonSchema: json$3.optional()
8778
+ }), object({
8779
+ kind: literal("source"),
8780
+ source
8781
+ })]);
8782
+ var condition = {
8783
+ matchMode: _enum(["first", "all"]),
8784
+ cases: array(object({
8785
+ description: text.optional(),
8786
+ output: text,
8787
+ groups: array(object({ expressions: array(object({
8788
+ left: operand$1,
8789
+ operator: _enum([
8790
+ "!=",
8791
+ "<",
8792
+ "<=",
8793
+ "==",
8794
+ ">",
8795
+ ">=",
8796
+ "contains",
8797
+ "endsWith",
8798
+ "hasKey",
8799
+ "hasValue",
8800
+ "isEmpty",
8801
+ "isFalse",
8802
+ "isNotEmpty",
8803
+ "isNotNull",
8804
+ "isNull",
8805
+ "isTrue",
8806
+ "notContains",
8807
+ "notHasKey",
8808
+ "notHasValue",
8809
+ "startsWith"
8810
+ ]),
8811
+ right: operand$1.optional()
8812
+ })) }))
8813
+ }))
8814
+ };
8815
+ var wait = {
8816
+ inputDefinitions: array(input),
8817
+ prompt: text
8818
+ };
8819
+ var webhookOptions = object({
8820
+ allowedMethods: never().optional(),
8821
+ allowedOrigins: strings$1.optional(),
8822
+ noResponseBody: never().optional(),
8823
+ responseData: text.optional(),
8824
+ responseHeaders: record$3(text, text).optional(),
8825
+ responseStatusCode: number().int().min(200).max(599).optional()
8948
8826
  });
8949
- function makeSubsetCompare({ extendsSchemaClasses, delegate } = {}) {
8950
- const extendsContext = new ExtendsContext(extendsSchemaClasses);
8951
- return Object.freeze({
8952
- compile: (schema, payload, printWarnLog) => {
8953
- const compiler = (candidate) => compile(candidate, extendsContext, payload, delegate);
8954
- return preprocessSchema(schema, compiler, printWarnLog);
8955
- },
8956
- isSubset: (superSchema, subSchema, printWarnLog = false) => {
8957
- const compiler = (candidate) => compile(candidate, extendsContext, void 0, delegate);
8958
- const [schema1, schema2] = preprocessSchemasPair(superSchema, subSchema, compiler, printWarnLog);
8959
- const { errorPath, expression } = checkWithResult(extendsContext, schema1, schema2);
8960
- const foundTrueExpression = hasEquals(expression) || hasContainedBy(expression);
8961
- const foundFalseExpression = hasContaining(expression) || hasIntersection(expression) || hasRejection(expression);
8962
- if (foundTrueExpression && !foundFalseExpression) return { result: SubsetCompareResult.True };
8963
- if (!foundTrueExpression && foundFalseExpression) return {
8964
- errorPath,
8965
- result: SubsetCompareResult.False
8966
- };
8967
- return { result: SubsetCompareResult.Unknown };
8968
- }
8969
- });
8970
- }
8971
- //#endregion
8972
- //#region ../../node_modules/.bun/@wopjs+cast@0.1.16/node_modules/@wopjs/cast/dist/index.mjs
8973
- var isString = (x) => typeof x === "string";
8974
- var isArray = Array.isArray;
8975
- var isObject = (x) => x !== null && typeof x === "object";
8976
- var isPlainObject = (x) => isObject(x) && !isArray(x);
8977
- var toPlainObject = (x) => isPlainObject(x) ? x : void 0;
8978
- //#endregion
8979
- //#region src/flow/common/schemaComparer.ts
8980
- function isStringLikeSchema(value) {
8981
- return toPlainObject(value)?.type === "string";
8827
+ var webhook = {
8828
+ bodyFields: array(input),
8829
+ method: _enum(webhookMethods),
8830
+ options: webhookOptions.optional()
8831
+ };
8832
+ var definition = {
8833
+ configInputs: ports$1.inputs,
8834
+ definitionVersion: literal(2),
8835
+ description: text,
8836
+ displayName: text,
8837
+ key: text,
8838
+ name: text,
8839
+ outputs: array(port$1).refine((definitions) => new Set(definitions.map((output) => output.handle)).size === definitions.length, "Duplicate Trigger output handle."),
8840
+ provider: text
8841
+ };
8842
+ var endpoint = object({
8843
+ body: object({
8844
+ allowArray: boolean(),
8845
+ allowEmpty: boolean(),
8846
+ formats: array(_enum([
8847
+ "form",
8848
+ "json",
8849
+ "multipart",
8850
+ "text"
8851
+ ]))
8852
+ }),
8853
+ methods: array(_enum([
8854
+ "DELETE",
8855
+ "GET",
8856
+ "HEAD",
8857
+ "PATCH",
8858
+ "POST",
8859
+ "PUT"
8860
+ ])),
8861
+ successStatus: number()
8862
+ });
8863
+ var sourceFlowIds = array(text.min(1)).refine((ids) => new Set(ids).size === ids.length, "Duplicate source Flow ID.");
8864
+ var trigger = {
8865
+ name: text,
8866
+ description: text.optional(),
8867
+ icon: text.optional()
8868
+ };
8869
+ var base = {
8870
+ maxExecutions: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
8871
+ inputs,
8872
+ name: text.optional(),
8873
+ description: text.optional(),
8874
+ icon: text.optional(),
8875
+ timeoutMs: number().optional()
8876
+ };
8877
+ var node = union([
8878
+ object({
8879
+ ...base,
8880
+ inputs: record$3(text, never()),
8881
+ kind: literal("condition"),
8882
+ ...condition
8883
+ }),
8884
+ object({
8885
+ ...base,
8886
+ inputs: unknown().transform(() => ({})).default({}),
8887
+ kind: literal("value"),
8888
+ values: array(input)
8889
+ }),
8890
+ object({
8891
+ ...base,
8892
+ kind: literal("task"),
8893
+ task: union([inline, managed]),
8894
+ additionalInputs: array(input).optional()
8895
+ }),
8896
+ strictObject({
8897
+ ...base,
8898
+ kind: literal("approval"),
8899
+ ...wait
8900
+ }).omit({ timeoutMs: true }),
8901
+ strictObject({
8902
+ ...base,
8903
+ kind: literal("wait"),
8904
+ ...wait
8905
+ }).omit({ timeoutMs: true }),
8906
+ object({
8907
+ ...trigger,
8908
+ kind: literal("manual")
8909
+ }),
8910
+ strictObject({
8911
+ ...trigger,
8912
+ kind: literal("error"),
8913
+ sourceFlowIds: sourceFlowIds.optional()
8914
+ }),
8915
+ object({
8916
+ ...trigger,
8917
+ kind: literal("webhook"),
8918
+ ...webhook
8919
+ }),
8920
+ object({
8921
+ ...trigger,
8922
+ kind: literal("cron"),
8923
+ cronTimes: triggerScheduleSchema
8924
+ }),
8925
+ object({
8926
+ ...trigger,
8927
+ kind: literal("poll"),
8928
+ connectionId: text.min(1).optional(),
8929
+ config: record$3(text, fixedInput),
8930
+ definition: object({
8931
+ ...definition,
8932
+ type: literal("poll")
8933
+ }),
8934
+ pollTimes: triggerScheduleSchema
8935
+ }),
8936
+ object({
8937
+ ...trigger,
8938
+ kind: literal("integration"),
8939
+ connectionId: text.min(1).optional(),
8940
+ config: record$3(text, fixedInput),
8941
+ definition: object({
8942
+ ...definition,
8943
+ type: literal("integration"),
8944
+ endpoint
8945
+ })
8946
+ })
8947
+ ]);
8948
+ /** Configuration schemas shared by the node authoring boundary. */
8949
+ var authoringDefinitionSchemas = {
8950
+ input,
8951
+ port: port$1,
8952
+ ports: ports$1,
8953
+ condition: strictObject(condition),
8954
+ wait: strictObject(wait),
8955
+ webhook: strictObject(webhook),
8956
+ schedule: triggerScheduleSchema,
8957
+ capabilities: array(capability),
8958
+ connector: managedFields.shape.executor.options[0].omit({ kind: true }).strict(),
8959
+ openapi: managedFields.shape.executor.options[1].omit({ kind: true }).strict(),
8960
+ decision: managedFields.shape.executor.options[2].omit({ kind: true }).strict(),
8961
+ llm: managedFields.shape.executor.options[3].omit({ kind: true }).strict(),
8962
+ agent: managedFields.shape.executor.options[4].omit({
8963
+ kind: true,
8964
+ notification: true
8965
+ }).strict()
8966
+ };
8967
+ var edge = object({
8968
+ source: text,
8969
+ target: text,
8970
+ sourceHandle: text.optional()
8971
+ });
8972
+ var at = {
8973
+ nodeId: text,
8974
+ target: never().optional()
8975
+ };
8976
+ var graph = object({
8977
+ nodes: record$3(text, node),
8978
+ edges: array(edge).default([])
8979
+ });
8980
+ var binding$1 = object({
8981
+ kind: literal("variable"),
8982
+ target: text
8983
+ });
8984
+ var module = object({
8985
+ name: text,
8986
+ imports: strings$1,
8987
+ source: text
8988
+ });
8989
+ var document = preprocess(rejectRetiredDefinitions, object({
8990
+ bindings: record$3(text, binding$1),
8991
+ graph
8992
+ }));
8993
+ var revision = object({
8994
+ modelVersion: union([
8995
+ literal(2),
8996
+ literal(4),
8997
+ literal(5),
8998
+ literal(6)
8999
+ ]),
9000
+ document,
9001
+ modules: record$3(text, module)
9002
+ });
9003
+ revision.extend({
9004
+ kind: literal("open-flow-flow-revision"),
9005
+ version: literal(1)
9006
+ });
9007
+ function rejectRetiredDefinitions(value) {
9008
+ const candidate = record$2(value);
9009
+ 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.");
9010
+ if (Object.values(record$2(record$2(candidate.graph).nodes)).some((candidateNode) => Object.hasOwn(record$2(candidateNode), "taskId"))) throw new TypeError("Task references are no longer supported.");
9011
+ const subflows = candidate.subflows;
9012
+ 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.");
9013
+ if (Object.values(record$2(record$2(candidate.graph).nodes)).some((candidateNode) => record$2(candidateNode).kind === "subflow")) throw new TypeError("Subflow nodes are no longer supported.");
9014
+ return value;
8982
9015
  }
8983
- function assertSchemaCompareContext(value) {
8984
- const context = toPlainObject(value);
8985
- const error = toPlainObject(context?.error);
8986
- if (context == null || error == null || context.packageId != null && !isString(context.packageId) || error.message != null && !isString(error.message)) throw new TypeError("Invalid schema comparison context.");
9016
+ function record$2(value) {
9017
+ return value != null && typeof value == "object" && !Array.isArray(value) ? value : {};
8987
9018
  }
8988
- function parseSchemaCompareContext(value) {
8989
- if (value == null) return { error: {} };
8990
- assertSchemaCompareContext(value);
8991
- return value;
9019
+ function decodeRevisionContent(value) {
9020
+ checkJsonDepth(value);
9021
+ const content = revision.parse(value);
9022
+ checkModelVersion(content);
9023
+ assertOpenApiAuthBindings(content.document);
9024
+ return content;
8992
9025
  }
8993
- var SpecialSchema = class SpecialSchema {
8994
- static setError(fromSchema, toSchema, message) {
8995
- if (fromSchema instanceof SpecialSchema) fromSchema.context.error.message = message;
8996
- else if (toSchema instanceof SpecialSchema) toSchema.context.error.message = message;
8997
- }
8998
- constructor(id, value, context) {
8999
- this.id = id;
9000
- this.value = value;
9001
- this.context = parseSchemaCompareContext(context);
9002
- }
9003
- compare(other) {
9004
- if (isCompiledSchema(other) && getKind(other) === CompiledKind.Any) return [ExpressionSingleResult.ContainedBy];
9005
- return this.compareImpl(other);
9006
- }
9007
- };
9008
- var SingleSelectSchema = class SingleSelectSchema extends SpecialSchema {
9009
- static isMatch(value) {
9010
- const enumValues = toPlainObject(value)?.enum;
9011
- return Array.isArray(enumValues) && enumValues.every((v) => isString(v));
9012
- }
9013
- constructor(id, value, context) {
9014
- if (!SingleSelectSchema.isMatch(value)) throw new TypeError("Invalid single-select schema.");
9015
- super(id, value, context);
9016
- }
9017
- compareImpl(other) {
9018
- if (isStringLikeSchema(other)) return [ExpressionSingleResult.ContainedBy];
9019
- if (other instanceof SingleSelectSchema) {
9020
- const f = new Set(this.value.enum);
9021
- let result = ExpressionSingleResult.Equals;
9022
- for (const v of other.value.enum) {
9023
- if (!f.has(v)) result = ExpressionSingleResult.ContainedBy;
9024
- f.delete(v);
9025
- }
9026
- if (f.size === 0) return [result];
9027
- if (f.size === this.value.enum.length) return [ExpressionSingleResult.Rejection];
9028
- return [ExpressionSingleResult.Intersection];
9029
- }
9030
- return [ExpressionSingleResult.Rejection];
9031
- }
9032
- equals(other) {
9033
- if (other instanceof SingleSelectSchema) {
9034
- const f = new Set(this.value.enum);
9035
- for (const v of other.value.enum) {
9036
- if (!f.has(v)) return false;
9037
- f.delete(v);
9038
- }
9039
- return f.size === 0;
9040
- }
9041
- return false;
9042
- }
9043
- };
9044
- var BinarySchema = class BinarySchema extends SpecialSchema {
9045
- static isMatch(value) {
9046
- return toPlainObject(value)?.contentMediaType === "oomol/bin";
9047
- }
9048
- constructor(id, value, context) {
9049
- if (!BinarySchema.isMatch(value)) throw new TypeError("Invalid binary schema.");
9050
- super(id, value, context);
9051
- }
9052
- compareImpl(other) {
9053
- if (other instanceof BinarySchema) return [ExpressionSingleResult.Equals];
9054
- else {
9055
- SpecialSchema.setError(this, other, "edgeError.binDiffType");
9056
- return [ExpressionSingleResult.Rejection];
9057
- }
9058
- }
9059
- equals(other) {
9060
- return other instanceof BinarySchema;
9061
- }
9062
- };
9063
- var ArtifactSchema = class ArtifactSchema extends SpecialSchema {
9064
- static isMatch(value) {
9065
- return toPlainObject(value)?.contentMediaType === "oomol/artifact";
9066
- }
9067
- constructor(id, value, context) {
9068
- if (!ArtifactSchema.isMatch(value)) throw new TypeError("Invalid Artifact schema.");
9069
- super(id, value, context);
9070
- }
9071
- compareImpl(other) {
9072
- if (other instanceof ArtifactSchema) return [ExpressionSingleResult.Equals];
9073
- SpecialSchema.setError(this, other, "edgeError.artifactDiffType");
9074
- return [ExpressionSingleResult.Rejection];
9075
- }
9076
- equals(other) {
9077
- return other instanceof ArtifactSchema;
9026
+ var shapes = {
9027
+ "graph.trigger.sources.set": {
9028
+ nodeId: text,
9029
+ before: sourceFlowIds.optional(),
9030
+ value: sourceFlowIds.optional()
9031
+ },
9032
+ "binding.create": {
9033
+ bindingId: text,
9034
+ binding: binding$1
9035
+ },
9036
+ "binding.delete": { bindingId: text },
9037
+ "binding.target.set": {
9038
+ bindingId: text,
9039
+ before: text,
9040
+ value: text
9041
+ },
9042
+ "graph.edge.connect": {
9043
+ edge,
9044
+ target: never().optional()
9045
+ },
9046
+ "graph.edge.disconnect": {
9047
+ edge,
9048
+ target: never().optional()
9049
+ },
9050
+ "graph.node.create": {
9051
+ ...at,
9052
+ node
9053
+ },
9054
+ "graph.node.replace": {
9055
+ ...at,
9056
+ before: node,
9057
+ node
9058
+ },
9059
+ "graph.node.delete": at,
9060
+ "graph.node.field.set": union([
9061
+ object({
9062
+ ...at,
9063
+ kind: literal("graph.node.field.set"),
9064
+ field: literal("connectionId"),
9065
+ before: text.min(1).optional(),
9066
+ value: text.min(1).optional()
9067
+ }),
9068
+ object({
9069
+ ...at,
9070
+ kind: literal("graph.node.field.set"),
9071
+ field: _enum([
9072
+ "description",
9073
+ "icon",
9074
+ "name"
9075
+ ]),
9076
+ before: text.optional(),
9077
+ value: text.optional()
9078
+ }),
9079
+ object({
9080
+ ...at,
9081
+ kind: literal("graph.node.field.set"),
9082
+ field: literal("maxExecutions"),
9083
+ before: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional(),
9084
+ value: number().int().positive().max(Number.MAX_SAFE_INTEGER).optional()
9085
+ }),
9086
+ object({
9087
+ ...at,
9088
+ kind: literal("graph.node.field.set"),
9089
+ field: literal("timeoutMs"),
9090
+ before: number().optional(),
9091
+ value: number().optional()
9092
+ })
9093
+ ]),
9094
+ "graph.node.input.set": {
9095
+ ...at,
9096
+ handle: text,
9097
+ before: mapping.optional(),
9098
+ value: mapping.optional()
9099
+ },
9100
+ "graph.node.additional-inputs.set": {
9101
+ ...at,
9102
+ before: array(input).optional(),
9103
+ value: array(input).optional()
9104
+ },
9105
+ "graph.node.condition.set": {
9106
+ ...at,
9107
+ before: object(condition),
9108
+ value: object(condition)
9109
+ },
9110
+ "graph.node.values.set": {
9111
+ ...at,
9112
+ before: array(input),
9113
+ value: array(input)
9114
+ },
9115
+ "graph.node.resolution.set": {
9116
+ ...at,
9117
+ before: object(wait),
9118
+ value: object(wait)
9119
+ },
9120
+ "graph.node.webhook.set": {
9121
+ ...at,
9122
+ before: object(webhook),
9123
+ value: object(webhook)
9124
+ },
9125
+ "graph.node.task.ports.set": {
9126
+ ...at,
9127
+ before: object(ports$1),
9128
+ value: object(ports$1)
9129
+ },
9130
+ "graph.node.task.name.set": {
9131
+ ...at,
9132
+ before: text,
9133
+ value: text
9134
+ },
9135
+ "graph.node.task.capabilities.set": {
9136
+ ...at,
9137
+ before: array(capability).optional(),
9138
+ value: array(capability).optional()
9139
+ },
9140
+ "graph.trigger.config.set": {
9141
+ nodeId: text,
9142
+ name: text,
9143
+ before: fixedInput.optional(),
9144
+ value: fixedInput.optional()
9145
+ },
9146
+ "graph.trigger.schedule.set": {
9147
+ nodeId: text,
9148
+ before: triggerScheduleSchema,
9149
+ value: triggerScheduleSchema
9150
+ },
9151
+ "module.create": {
9152
+ moduleId: text,
9153
+ module
9154
+ },
9155
+ "module.delete": { moduleId: text },
9156
+ "module.rename": {
9157
+ moduleId: text,
9158
+ before: text,
9159
+ name: text
9160
+ },
9161
+ "module.source.replace": {
9162
+ moduleId: text,
9163
+ beforeImports: strings$1,
9164
+ beforeSource: text,
9165
+ imports: strings$1,
9166
+ source: text
9167
+ },
9168
+ "graph.node.task.set": {
9169
+ ...at,
9170
+ before: union([inline, managed]),
9171
+ value: union([inline, managed])
9078
9172
  }
9079
9173
  };
9080
- function createSchemaComparer() {
9081
- return makeSubsetCompare({ extendsSchemaClasses: [
9082
- SingleSelectSchema,
9083
- BinarySchema,
9084
- ArtifactSchema
9085
- ] });
9086
- }
9087
- createSchemaComparer();
9088
- //#endregion
9089
- //#region src/decision/common/decision.ts
9090
- var decisionLimits = {
9091
- choice: 255,
9092
- score: 10
9093
- };
9094
- /** Ordered prefixes are shared by authoring, schemas, validation, and execution. */
9095
- function limitDecisionQuestion(question) {
9096
- if (question.type === "noul" || question.criteria.length <= decisionLimits[question.type]) return question;
9097
- if (question.type === "choice") return {
9098
- ...question,
9099
- criteria: question.criteria.slice(0, decisionLimits.choice)
9100
- };
9101
- return {
9102
- ...question,
9103
- criteria: question.criteria.slice(0, decisionLimits.score)
9104
- };
9105
- }
9106
- function limitDecisionQuestions(questions) {
9107
- const limited = questions.map(limitDecisionQuestion);
9108
- return limited.every((question, i) => question === questions[i]) ? questions : limited;
9109
- }
9110
- /** Loading an oversized task also updates its previously generated output schemas. */
9111
- function limitDecisionTask(task) {
9112
- if (task.executor.kind !== "decision") return task;
9113
- const original = task.executor.questions;
9114
- const questions = limitDecisionQuestions(original);
9115
- if (questions === original) return task;
9116
- const outputs = task.outputs.map((port) => {
9117
- if (!("handle" in port)) return port;
9118
- const index = original.findIndex((question) => question.name === port.handle);
9119
- if (index < 0 || original[index] === questions[index] || !dequal(port.jsonSchema, answerSchema(original[index]))) return port;
9120
- return {
9121
- ...port,
9122
- jsonSchema: decisionAnswerSchema(questions[index])
9123
- };
9124
- });
9125
- return {
9126
- ...task,
9127
- executor: {
9128
- ...task.executor,
9129
- questions
9130
- },
9131
- outputs
9132
- };
9133
- }
9134
- var probability = {
9135
- type: "number",
9136
- minimum: 0,
9137
- maximum: 1
9138
- };
9139
- function decisionAnswerSchema(question) {
9140
- return answerSchema(limitDecisionQuestion(question));
9141
- }
9142
- function answerSchema(question) {
9143
- const properties = { type: { const: question.type } };
9144
- if (question.type === "noul") properties.noul = probability;
9145
- else {
9146
- const keys = question.type === "choice" ? question.criteria.map((item) => item.name) : question.criteria.map((_, index) => String(index));
9147
- properties.confidence = probability;
9148
- properties.probabilities = {
9149
- type: "object",
9150
- properties: Object.fromEntries(keys.map((key) => [key, probability])),
9151
- required: keys,
9152
- additionalProperties: false
9153
- };
9154
- if (question.type === "choice") properties.choice = {
9155
- type: "string",
9156
- ...keys.length ? { enum: keys } : {}
9157
- };
9158
- else {
9159
- properties.score = {
9160
- type: "number",
9161
- minimum: 0,
9162
- maximum: Math.max(0, keys.length - 1)
9163
- };
9164
- properties.legend = {
9165
- type: "object",
9166
- properties: Object.fromEntries(keys.map((key) => [key, { type: "string" }])),
9167
- required: keys,
9168
- additionalProperties: false
9169
- };
9170
- }
9171
- }
9172
- return {
9173
- type: "object",
9174
- properties,
9175
- required: Object.keys(properties)
9176
- };
9174
+ array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, shape instanceof ZodType ? shape : object({
9175
+ kind: literal(kind),
9176
+ ...shape
9177
+ })])).values()])).min(1);
9178
+ function checkModelVersion(content) {
9179
+ if (content.modelVersion < 6 && Object.values(content.document.graph.nodes).some((candidateNode) => candidateNode.kind == "task" && "executor" in candidateNode.task)) throw new TypeError("Node-owned managed Tasks require Flow model version 6.");
9180
+ if (content.modelVersion < 5 && Object.values(content.document.graph.nodes).some((itemNode) => itemNode.kind == "error")) throw new TypeError("Error workflows require Flow model version 5.");
9177
9181
  }
9178
9182
  //#endregion
9179
9183
  //#region src/control/common/authoringLlm.ts
@@ -9195,7 +9199,7 @@ var authenticationSchema = union([
9195
9199
  in: _enum(["header", "query"])
9196
9200
  })
9197
9201
  ]);
9198
- strictObject({
9202
+ var authoringOpenApiSchema = strictObject({
9199
9203
  sourceUrl: string$1().min(1),
9200
9204
  path: string$1().min(1),
9201
9205
  method: string$1().min(1),
@@ -9292,36 +9296,53 @@ var when = union([
9292
9296
  all,
9293
9297
  strictObject({ any: array(union([expression, all])) })
9294
9298
  ]);
9295
- strictObject({}), strictObject({ sourceFlowIds: array(id$1).optional() }), authoringDefinitionSchemas.webhook.omit({ bodyFields: true }).extend({ body: inputFields }).strict(), strictObject({ schedule: authoringDefinitionSchemas.schedule }), strictObject({
9296
- key: id$1,
9297
- connectionId: id$1.optional(),
9298
- schedule: authoringDefinitionSchemas.schedule
9299
- }), strictObject({
9300
- key: id$1,
9301
- connectionId: id$1.optional()
9302
- }), strictObject({
9303
- inputs: inputFields,
9304
- outputs: outputFields,
9305
- capabilities: authoringDefinitionSchemas.capabilities.optional()
9306
- }), authoringDefinitionSchemas.connector.strict(), authoringDefinitionSchemas.agent.omit({
9307
- prompt: true,
9308
- tools: true
9309
- }).extend({
9310
- inputs: inputFields,
9311
- resultSchema: json$2.describe("JSON schema of the final result. Defaults to text. The tool manages the output definition; references can omit port."),
9312
- tools: array(agentTool),
9313
- notification: notification.optional()
9314
- }).strict(), authoringLlmConfiguration.extend({ inputs: inputFields }), authoringDefinitionSchemas.decision, strictObject({
9315
- match: _enum(["first", "all"]),
9316
- branches: array(strictObject({
9317
- name: id$1,
9318
- description: string$1().optional(),
9319
- when
9320
- }))
9321
- }), strictObject({
9322
- values: patch,
9323
- outputs: outputFields
9324
- }), strictObject({ inputs: inputFields }), strictObject({ inputs: inputFields });
9299
+ var authoringConfigurations = {
9300
+ manual: strictObject({}),
9301
+ error: strictObject({ sourceFlowIds: array(id$1).optional() }),
9302
+ webhook: authoringDefinitionSchemas.webhook.omit({ bodyFields: true }).extend({ body: inputFields }).strict(),
9303
+ cron: strictObject({ schedule: authoringDefinitionSchemas.schedule }),
9304
+ poll: strictObject({
9305
+ key: id$1,
9306
+ connectionId: id$1.optional(),
9307
+ schedule: authoringDefinitionSchemas.schedule
9308
+ }),
9309
+ integration: strictObject({
9310
+ key: id$1,
9311
+ connectionId: id$1.optional()
9312
+ }),
9313
+ code: strictObject({
9314
+ inputs: inputFields,
9315
+ outputs: outputFields,
9316
+ capabilities: authoringDefinitionSchemas.capabilities.optional()
9317
+ }),
9318
+ connector: authoringDefinitionSchemas.connector.omit({ outputMode: true }).strict(),
9319
+ openapi: authoringOpenApiSchema,
9320
+ agent: authoringDefinitionSchemas.agent.omit({
9321
+ prompt: true,
9322
+ tools: true
9323
+ }).extend({
9324
+ inputs: inputFields,
9325
+ resultSchema: json$2.describe("JSON schema of the final result. Defaults to text. The tool manages the output definition; references can omit port."),
9326
+ tools: array(agentTool),
9327
+ notification: notification.optional()
9328
+ }).strict(),
9329
+ llm: authoringLlmConfiguration.extend({ inputs: inputFields }),
9330
+ decision: authoringDefinitionSchemas.decision,
9331
+ condition: strictObject({
9332
+ match: _enum(["first", "all"]),
9333
+ branches: array(strictObject({
9334
+ name: id$1,
9335
+ description: string$1().optional(),
9336
+ when
9337
+ }))
9338
+ }),
9339
+ value: strictObject({
9340
+ values: patch,
9341
+ outputs: outputFields
9342
+ }),
9343
+ wait: strictObject({ inputs: inputFields }),
9344
+ approval: strictObject({ inputs: inputFields })
9345
+ };
9325
9346
  var updates = strictObject({
9326
9347
  name: id$1.optional(),
9327
9348
  description: string$1().optional(),
@@ -9501,7 +9522,6 @@ var controlErrorCode = {
9501
9522
  publicationConflict: "publication.conflict",
9502
9523
  publicationNotFound: "publication.not-found",
9503
9524
  publicationUnsupported: "publication.unsupported",
9504
- resourceNotFound: "resource.not-found",
9505
9525
  publishOperationNotFound: "publication.operation-not-found",
9506
9526
  routeNotFound: "route.not-found",
9507
9527
  runConflict: "run.conflict",
@@ -9518,7 +9538,7 @@ var controlErrorCode = {
9518
9538
  variableLimitReached: "variable.limit-reached",
9519
9539
  variableNotFound: "variable.not-found"
9520
9540
  };
9521
- controlErrorCode.eventSourceInvalid, controlErrorCode.eventSourceIdentityUnavailable, controlErrorCode.eventSourceNotFound, controlErrorCode.eventSourceConflict, controlErrorCode.authenticationRequired, controlErrorCode.authorizationDenied, controlErrorCode.bindingUnresolved, controlErrorCode.connectorActionNotFound, controlErrorCode.connectorAccessConflict, controlErrorCode.connectorAccessInvalid, controlErrorCode.connectorAccessRequired, controlErrorCode.connectorAccessUnsupported, controlErrorCode.connectorUnconfigured, controlErrorCode.connectorUnavailable, controlErrorCode.connectorConsoleUnconfigured, controlErrorCode.engineUnavailable, controlErrorCode.engineUnsupported, controlErrorCode.flowInvalid, controlErrorCode.flowRepairRequired, controlErrorCode.flowUpgradeRequired, controlErrorCode.flowNotFound, controlErrorCode.flowBusy, controlErrorCode.flowConflict, controlErrorCode.flowPresentationConflict, controlErrorCode.flowRevisionConflict, controlErrorCode.liveConflict, controlErrorCode.liveNotFound, controlErrorCode.pageInvalidCursor, controlErrorCode.publicationConflict, controlErrorCode.publicationNotFound, controlErrorCode.publicationUnsupported, controlErrorCode.resourceNotFound, controlErrorCode.publishOperationNotFound, controlErrorCode.routeNotFound, controlErrorCode.runConflict, controlErrorCode.runEventsExpired, controlErrorCode.runInvalid, controlErrorCode.runNotFound, controlErrorCode.runNotTerminal, controlErrorCode.runOverloaded, controlErrorCode.runWaitNotFound, controlErrorCode.triggerKeyInvalid, controlErrorCode.triggerKeyNotFound, controlErrorCode.triggerNotFound, controlErrorCode.variableInvalid, controlErrorCode.variableLimitReached, controlErrorCode.variableNotFound;
9541
+ controlErrorCode.eventSourceInvalid, controlErrorCode.eventSourceIdentityUnavailable, controlErrorCode.eventSourceNotFound, controlErrorCode.eventSourceConflict, controlErrorCode.authenticationRequired, controlErrorCode.authorizationDenied, controlErrorCode.bindingUnresolved, controlErrorCode.connectorActionNotFound, controlErrorCode.connectorAccessConflict, controlErrorCode.connectorAccessInvalid, controlErrorCode.connectorAccessRequired, controlErrorCode.connectorAccessUnsupported, controlErrorCode.connectorUnconfigured, controlErrorCode.connectorUnavailable, controlErrorCode.connectorConsoleUnconfigured, controlErrorCode.engineUnavailable, controlErrorCode.engineUnsupported, controlErrorCode.flowInvalid, controlErrorCode.flowRepairRequired, controlErrorCode.flowUpgradeRequired, controlErrorCode.flowNotFound, controlErrorCode.flowBusy, controlErrorCode.flowConflict, controlErrorCode.flowPresentationConflict, controlErrorCode.flowRevisionConflict, controlErrorCode.liveConflict, controlErrorCode.liveNotFound, controlErrorCode.pageInvalidCursor, controlErrorCode.publicationConflict, controlErrorCode.publicationNotFound, controlErrorCode.publicationUnsupported, controlErrorCode.publishOperationNotFound, controlErrorCode.routeNotFound, controlErrorCode.runConflict, controlErrorCode.runEventsExpired, controlErrorCode.runInvalid, controlErrorCode.runNotFound, controlErrorCode.runNotTerminal, controlErrorCode.runOverloaded, controlErrorCode.runWaitNotFound, controlErrorCode.triggerKeyInvalid, controlErrorCode.triggerKeyNotFound, controlErrorCode.triggerNotFound, controlErrorCode.variableInvalid, controlErrorCode.variableLimitReached, controlErrorCode.variableNotFound;
9522
9542
  var ApiError = class extends Error {
9523
9543
  constructor(status, code, message, details) {
9524
9544
  super(message);
@@ -9562,11 +9582,147 @@ function jsonValue(value) {
9562
9582
  if (typeof value == "number" && Number.isFinite(value)) return value;
9563
9583
  if (Array.isArray(value)) return value.map(jsonValue);
9564
9584
  const source = record$1(value);
9565
- return Object.fromEntries(Object.entries(source).map(([key, item]) => [key, jsonValue(item)]));
9585
+ return Object.fromEntries(Object.entries(source).map(([key, item]) => [key, jsonValue(item)]));
9586
+ }
9587
+ function optionalString(value) {
9588
+ if (value == null) return;
9589
+ return string(value);
9590
+ }
9591
+ //#endregion
9592
+ //#region src/control/common/publicationDecoders.ts
9593
+ function publication(value) {
9594
+ const source = record$1(value);
9595
+ const liveEnd = source.liveEnd == null ? void 0 : record$1(source.liveEnd);
9596
+ if (liveEnd != null && typeof liveEnd.enabled != "boolean") return invalidResponse();
9597
+ const operation = source.operation;
9598
+ const sourcePublicationId = source.sourcePublicationId;
9599
+ if (source.version != 1) return invalidResponse();
9600
+ if (operation != "publish" && operation != "rollback") return invalidResponse();
9601
+ if (sourcePublicationId != null && typeof sourcePublicationId != "string") return invalidResponse();
9602
+ return {
9603
+ ...liveEnd == null ? {} : { liveEnd: {
9604
+ enabled: liveEnd.enabled,
9605
+ endedAt: string(liveEnd.endedAt)
9606
+ } },
9607
+ actorId: string(source.actorId),
9608
+ closureDigest: string(source.closureDigest),
9609
+ createdAt: string(source.createdAt),
9610
+ engineContract: string(source.engineContract),
9611
+ flowId: string(source.flowId),
9612
+ modelVersion: integer(source.modelVersion),
9613
+ operation,
9614
+ publicationId: string(source.publicationId),
9615
+ sharedAccessDigest: string(source.sharedAccessDigest),
9616
+ revisionDigest: string(source.revisionDigest),
9617
+ revisionId: string(source.revisionId),
9618
+ ...sourcePublicationId == null ? {} : { sourcePublicationId },
9619
+ version: 1
9620
+ };
9621
+ }
9622
+ function publishOperation(value) {
9623
+ const source = record$1(value);
9624
+ const status = source.status;
9625
+ const common = {
9626
+ createdAt: string(source.createdAt),
9627
+ flowId: string(source.flowId),
9628
+ operationId: string(source.operationId),
9629
+ revisionId: string(source.revisionId),
9630
+ updatedAt: string(source.updatedAt),
9631
+ version: 1
9632
+ };
9633
+ if (source.version != 1) return invalidResponse();
9634
+ switch (status) {
9635
+ case "pending":
9636
+ exact(source, [
9637
+ "createdAt",
9638
+ "flowId",
9639
+ "operationId",
9640
+ "revisionId",
9641
+ "status",
9642
+ "updatedAt",
9643
+ "version"
9644
+ ]);
9645
+ return {
9646
+ ...common,
9647
+ status
9648
+ };
9649
+ case "succeeded":
9650
+ exact(source, [
9651
+ "createdAt",
9652
+ "flowId",
9653
+ "operationId",
9654
+ "publicationId",
9655
+ "revisionId",
9656
+ "status",
9657
+ "updatedAt",
9658
+ "version"
9659
+ ]);
9660
+ return {
9661
+ ...common,
9662
+ publicationId: string(source.publicationId),
9663
+ status
9664
+ };
9665
+ case "failed": {
9666
+ exact(source, [
9667
+ "createdAt",
9668
+ "flowId",
9669
+ "issue",
9670
+ "operationId",
9671
+ "revisionId",
9672
+ "status",
9673
+ "updatedAt",
9674
+ "version"
9675
+ ]);
9676
+ const issue = record$1(source.issue);
9677
+ const nodeId = issue.nodeId;
9678
+ exact(issue, [
9679
+ "code",
9680
+ "message",
9681
+ ...nodeId == null ? [] : ["nodeId"]
9682
+ ]);
9683
+ return {
9684
+ ...common,
9685
+ issue: {
9686
+ code: string(issue.code),
9687
+ message: string(issue.message),
9688
+ ...nodeId == null ? {} : { nodeId: string(nodeId) }
9689
+ },
9690
+ status
9691
+ };
9692
+ }
9693
+ default: return invalidResponse();
9694
+ }
9695
+ }
9696
+ function live(value) {
9697
+ const source = record$1(value);
9698
+ const status = source.status;
9699
+ const candidate = source.publication;
9700
+ if (source.version != 1 || typeof source.hasUnpublishedChanges != "boolean") return invalidResponse();
9701
+ if (status != "not-published" && status != "runnable" && status != "suspended") return invalidResponse();
9702
+ if (status == "not-published" && candidate !== null) return invalidResponse();
9703
+ if (status != "not-published" && candidate === null) return invalidResponse();
9704
+ return {
9705
+ flowId: string(source.flowId),
9706
+ hasUnpublishedChanges: source.hasUnpublishedChanges,
9707
+ publication: candidate === null ? null : publication(candidate),
9708
+ revision: integer(source.revision),
9709
+ status,
9710
+ version: 1
9711
+ };
9566
9712
  }
9567
- function optionalString(value) {
9568
- if (value == null) return;
9569
- return string(value);
9713
+ function publicationPage(value) {
9714
+ const source = record$1(value);
9715
+ const nextCursor = source.nextCursor;
9716
+ const total = source.total;
9717
+ if (source.version != 1 || !Array.isArray(source.publications)) return invalidResponse();
9718
+ if (nextCursor != null && typeof nextCursor != "string") return invalidResponse();
9719
+ if (total != null && !Number.isSafeInteger(total)) return invalidResponse();
9720
+ return {
9721
+ ...nextCursor == null ? {} : { nextCursor },
9722
+ publications: source.publications.map(publication),
9723
+ ...total == null ? {} : { total },
9724
+ version: 1
9725
+ };
9570
9726
  }
9571
9727
  //#endregion
9572
9728
  //#region src/trigger/common/configSchema.ts
@@ -9751,54 +9907,99 @@ function pollTriggerTestResult(value) {
9751
9907
  };
9752
9908
  }
9753
9909
  //#endregion
9754
- //#region src/control/common/publicationResources.ts
9755
- function context(source) {
9756
- if (source.version != 1 || source.status != "live" && source.status != "historical") return invalidResponse();
9757
- if (source.status == "live" ? typeof source.enabled != "boolean" : source.enabled !== void 0) return invalidResponse();
9758
- return {
9759
- flowId: string(source.flowId),
9760
- publicationId: string(source.publicationId),
9761
- revisionId: string(source.revisionId),
9762
- status: source.status,
9763
- ...source.enabled == null ? {} : { enabled: source.enabled },
9764
- version: 1
9765
- };
9766
- }
9767
- function resource(value, scope) {
9768
- const source = record$1(value);
9769
- const type = source.type;
9770
- if (source.kind != "trigger" || type != "webhook" && type != "cron" && type != "poll" && type != "integration" && type != "error") return invalidResponse();
9771
- if (source.description != null && typeof source.description != "string") return invalidResponse();
9772
- const resourceId = string(source.resourceId);
9773
- const runtime = source.runtime == null ? void 0 : triggerBinding(source.runtime);
9774
- if (runtime != null && (scope.status != "live" || runtime.flowId != scope.flowId || runtime.currentPublicationId != scope.publicationId || runtime.currentRevisionId != scope.revisionId || runtime.triggerNodeId != resourceId || runtime.kind != type)) return invalidResponse();
9775
- return {
9776
- resourceId,
9777
- kind: "trigger",
9778
- type,
9779
- name: string(source.name),
9780
- ...source.description == null ? {} : { description: source.description },
9781
- config: jsonValue(source.config),
9782
- inputs: jsonValue(source.inputs),
9783
- ...runtime == null ? {} : { runtime }
9784
- };
9785
- }
9786
- function decodePublicationResources(value) {
9910
+ //#region src/control/common/liveDetails.ts
9911
+ var metadata = {
9912
+ nodeId: string$1().min(1),
9913
+ name: string$1(),
9914
+ description: string$1().optional()
9915
+ };
9916
+ var binding = unknown().transform(triggerBinding);
9917
+ var provider = {
9918
+ provider: string$1().min(1),
9919
+ inputs: record$3(string$1(), discriminatedUnion("kind", [strictObject({
9920
+ kind: literal("value"),
9921
+ value: json$4()
9922
+ }), strictObject({ kind: literal("unset") })]))
9923
+ };
9924
+ var entrySchema = discriminatedUnion("type", [
9925
+ strictObject({
9926
+ ...metadata,
9927
+ type: literal("manual"),
9928
+ config: authoringConfigurations.manual
9929
+ }),
9930
+ strictObject({
9931
+ ...metadata,
9932
+ type: literal("webhook"),
9933
+ config: authoringConfigurations.webhook,
9934
+ binding
9935
+ }),
9936
+ strictObject({
9937
+ ...metadata,
9938
+ type: literal("cron"),
9939
+ config: authoringConfigurations.cron,
9940
+ binding
9941
+ }),
9942
+ strictObject({
9943
+ ...metadata,
9944
+ type: literal("error"),
9945
+ config: authoringConfigurations.error,
9946
+ binding
9947
+ }),
9948
+ strictObject({
9949
+ ...metadata,
9950
+ ...provider,
9951
+ type: literal("poll"),
9952
+ config: authoringConfigurations.poll,
9953
+ binding
9954
+ }),
9955
+ strictObject({
9956
+ ...metadata,
9957
+ ...provider,
9958
+ type: literal("integration"),
9959
+ config: authoringConfigurations.integration,
9960
+ binding
9961
+ })
9962
+ ]);
9963
+ function decodeLiveDetails(value) {
9787
9964
  const source = record$1(value);
9788
- const scope = context(source);
9789
- if (!Array.isArray(source.resources)) return invalidResponse();
9965
+ const flowId = string(source.flowId);
9966
+ if (source.version != 1 || !Array.isArray(source.entries)) return invalidResponse();
9967
+ if (source.publication === null) {
9968
+ if (source.status != "not-published" || source.entries.length != 0 || Object.hasOwn(source, "enabled")) return invalidResponse();
9969
+ return {
9970
+ flowId,
9971
+ publication: null,
9972
+ status: "not-published",
9973
+ entries: [],
9974
+ version: 1
9975
+ };
9976
+ }
9977
+ const current = publication(source.publication);
9978
+ const status = source.status;
9979
+ if (current.flowId != flowId || typeof source.enabled != "boolean") return invalidResponse();
9980
+ if (status != "runnable" && status != "suspended") return invalidResponse();
9981
+ if (!source.enabled && source.status == "runnable") return invalidResponse();
9790
9982
  return {
9791
- ...scope,
9792
- resources: source.resources.map((item) => resource(item, scope))
9983
+ flowId,
9984
+ publication: current,
9985
+ status,
9986
+ enabled: source.enabled,
9987
+ entries: decodeEntries(source.entries, current),
9988
+ version: 1
9793
9989
  };
9794
9990
  }
9795
- function decodePublicationResource(value) {
9796
- const source = record$1(value);
9797
- const scope = context(source);
9798
- return {
9799
- ...scope,
9800
- resource: resource(source.resource, scope)
9801
- };
9991
+ /** Both producers and consumers enforce the same published-entry invariants. */
9992
+ function decodeEntries(values, current) {
9993
+ const parsed = array(entrySchema).safeParse(values);
9994
+ if (!parsed.success) return invalidResponse();
9995
+ const ids = /* @__PURE__ */ new Set();
9996
+ for (const entry of parsed.data) {
9997
+ if (ids.has(entry.nodeId)) return invalidResponse();
9998
+ ids.add(entry.nodeId);
9999
+ if (entry.type != "manual" && (entry.binding.flowId != current.flowId || entry.binding.triggerNodeId != entry.nodeId || entry.binding.kind != entry.type || entry.binding.currentPublicationId != current.publicationId || entry.binding.currentRevisionId != current.revisionId)) return invalidResponse();
10000
+ if (entry.type == "webhook" && (!entry.binding.endpointUrl || !webhookSupportsBody(entry.config.method) && Object.keys(entry.config.body).length > 0)) return invalidResponse();
10001
+ }
10002
+ return parsed.data;
9802
10003
  }
9803
10004
  //#endregion
9804
10005
  //#region src/control/common/providerIconSprite.ts
@@ -9834,6 +10035,24 @@ function providerIconAppearance(metadata, position) {
9834
10035
  }
9835
10036
  };
9836
10037
  }
10038
+ //#endregion
10039
+ //#region src/flow/common/workflowFile.ts
10040
+ var envelope = strictObject({
10041
+ kind: literal("open-flow-workflow"),
10042
+ version: literal(1),
10043
+ name: string$1().optional(),
10044
+ content: unknown(),
10045
+ presentation: record$3(string$1(), json$4()).optional()
10046
+ });
10047
+ /** Structural decoding only: incomplete drafts are supported, repair is never attempted. */
10048
+ function decodeWorkflowFile(value) {
10049
+ checkJsonDepth(value, -1);
10050
+ const file = envelope.parse(value);
10051
+ return {
10052
+ ...file,
10053
+ content: decodeRevisionContent(file.content)
10054
+ };
10055
+ }
9837
10056
  new TextEncoder();
9838
10057
  //#endregion
9839
10058
  //#region src/control/common/providerAccess.ts
@@ -10633,142 +10852,6 @@ function variableReferences(input) {
10633
10852
  };
10634
10853
  }
10635
10854
  //#endregion
10636
- //#region src/control/common/publicationDecoders.ts
10637
- function publication(value) {
10638
- const source = record$1(value);
10639
- const liveEnd = source.liveEnd == null ? void 0 : record$1(source.liveEnd);
10640
- if (liveEnd != null && typeof liveEnd.enabled != "boolean") return invalidResponse();
10641
- const operation = source.operation;
10642
- const sourcePublicationId = source.sourcePublicationId;
10643
- if (source.version != 1) return invalidResponse();
10644
- if (operation != "publish" && operation != "rollback") return invalidResponse();
10645
- if (sourcePublicationId != null && typeof sourcePublicationId != "string") return invalidResponse();
10646
- return {
10647
- ...liveEnd == null ? {} : { liveEnd: {
10648
- enabled: liveEnd.enabled,
10649
- endedAt: string(liveEnd.endedAt)
10650
- } },
10651
- actorId: string(source.actorId),
10652
- closureDigest: string(source.closureDigest),
10653
- createdAt: string(source.createdAt),
10654
- engineContract: string(source.engineContract),
10655
- flowId: string(source.flowId),
10656
- modelVersion: integer(source.modelVersion),
10657
- operation,
10658
- publicationId: string(source.publicationId),
10659
- sharedAccessDigest: string(source.sharedAccessDigest),
10660
- revisionDigest: string(source.revisionDigest),
10661
- revisionId: string(source.revisionId),
10662
- ...sourcePublicationId == null ? {} : { sourcePublicationId },
10663
- version: 1
10664
- };
10665
- }
10666
- function publishOperation(value) {
10667
- const source = record$1(value);
10668
- const status = source.status;
10669
- const common = {
10670
- createdAt: string(source.createdAt),
10671
- flowId: string(source.flowId),
10672
- operationId: string(source.operationId),
10673
- revisionId: string(source.revisionId),
10674
- updatedAt: string(source.updatedAt),
10675
- version: 1
10676
- };
10677
- if (source.version != 1) return invalidResponse();
10678
- switch (status) {
10679
- case "pending":
10680
- exact(source, [
10681
- "createdAt",
10682
- "flowId",
10683
- "operationId",
10684
- "revisionId",
10685
- "status",
10686
- "updatedAt",
10687
- "version"
10688
- ]);
10689
- return {
10690
- ...common,
10691
- status
10692
- };
10693
- case "succeeded":
10694
- exact(source, [
10695
- "createdAt",
10696
- "flowId",
10697
- "operationId",
10698
- "publicationId",
10699
- "revisionId",
10700
- "status",
10701
- "updatedAt",
10702
- "version"
10703
- ]);
10704
- return {
10705
- ...common,
10706
- publicationId: string(source.publicationId),
10707
- status
10708
- };
10709
- case "failed": {
10710
- exact(source, [
10711
- "createdAt",
10712
- "flowId",
10713
- "issue",
10714
- "operationId",
10715
- "revisionId",
10716
- "status",
10717
- "updatedAt",
10718
- "version"
10719
- ]);
10720
- const issue = record$1(source.issue);
10721
- const nodeId = issue.nodeId;
10722
- exact(issue, [
10723
- "code",
10724
- "message",
10725
- ...nodeId == null ? [] : ["nodeId"]
10726
- ]);
10727
- return {
10728
- ...common,
10729
- issue: {
10730
- code: string(issue.code),
10731
- message: string(issue.message),
10732
- ...nodeId == null ? {} : { nodeId: string(nodeId) }
10733
- },
10734
- status
10735
- };
10736
- }
10737
- default: return invalidResponse();
10738
- }
10739
- }
10740
- function live(value) {
10741
- const source = record$1(value);
10742
- const status = source.status;
10743
- const candidate = source.publication;
10744
- if (source.version != 1 || typeof source.hasUnpublishedChanges != "boolean") return invalidResponse();
10745
- if (status != "not-published" && status != "runnable" && status != "suspended") return invalidResponse();
10746
- if (status == "not-published" && candidate !== null) return invalidResponse();
10747
- if (status != "not-published" && candidate === null) return invalidResponse();
10748
- return {
10749
- flowId: string(source.flowId),
10750
- hasUnpublishedChanges: source.hasUnpublishedChanges,
10751
- publication: candidate === null ? null : publication(candidate),
10752
- revision: integer(source.revision),
10753
- status,
10754
- version: 1
10755
- };
10756
- }
10757
- function publicationPage(value) {
10758
- const source = record$1(value);
10759
- const nextCursor = source.nextCursor;
10760
- const total = source.total;
10761
- if (source.version != 1 || !Array.isArray(source.publications)) return invalidResponse();
10762
- if (nextCursor != null && typeof nextCursor != "string") return invalidResponse();
10763
- if (total != null && !Number.isSafeInteger(total)) return invalidResponse();
10764
- return {
10765
- ...nextCursor == null ? {} : { nextCursor },
10766
- publications: source.publications.map(publication),
10767
- ...total == null ? {} : { total },
10768
- version: 1
10769
- };
10770
- }
10771
- //#endregion
10772
10855
  //#region src/control/common/revisionDecoders.ts
10773
10856
  function revisionMetadata(value) {
10774
10857
  const source = record$1(value);
@@ -11354,6 +11437,26 @@ var ControlClient = class {
11354
11437
  exact(source, ["version"]);
11355
11438
  if (source.version != 1) return invalidResponse();
11356
11439
  }
11440
+ async exportFlow(flowId) {
11441
+ const value = await this.request(`/v1/flows/${segment(flowId)}/export`);
11442
+ try {
11443
+ return decodeWorkflowFile(value);
11444
+ } catch {
11445
+ return invalidResponse();
11446
+ }
11447
+ }
11448
+ async importFlow(file, options = {}) {
11449
+ return flow(await this.request("/v1/flows/import", {
11450
+ method: "POST",
11451
+ headers: { "Idempotency-Key": options.idempotencyKey ?? `flow-${randomId()}` },
11452
+ body: JSON.stringify({
11453
+ file,
11454
+ name: options.name,
11455
+ teamId: options.teamId,
11456
+ version: 1
11457
+ })
11458
+ }));
11459
+ }
11357
11460
  async createFlow(name, idempotencyKey = `flow-${randomId()}`, teamId) {
11358
11461
  return flow(await this.request("/v1/flows", {
11359
11462
  body: JSON.stringify({
@@ -11707,21 +11810,14 @@ var ControlClient = class {
11707
11810
  method: "POST"
11708
11811
  }));
11709
11812
  }
11813
+ async getLiveDetails(flowId, signal) {
11814
+ const details = decodeLiveDetails(await this.request(`/v1/flows/${segment(flowId)}/live/details`, { signal }));
11815
+ if (details.flowId != flowId) return invalidResponse();
11816
+ return details;
11817
+ }
11710
11818
  async getLive(flowId, signal) {
11711
11819
  return live(await this.request(`/v1/flows/${segment(flowId)}/live`, { signal }));
11712
11820
  }
11713
- async listPublicationResources(flowId, publicationId) {
11714
- const query = publicationId == null ? "" : `?publicationId=${encodeURIComponent(publicationId)}`;
11715
- const result = decodePublicationResources(await this.request(`/v1/flows/${segment(flowId)}/resources${query}`));
11716
- if (result.flowId != flowId || publicationId != null && result.publicationId != publicationId) return invalidResponse();
11717
- return result;
11718
- }
11719
- async getPublicationResource(flowId, resourceId, publicationId) {
11720
- const query = publicationId == null ? "" : `?publicationId=${encodeURIComponent(publicationId)}`;
11721
- const result = decodePublicationResource(await this.request(`/v1/flows/${segment(flowId)}/resources/${segment(resourceId)}${query}`));
11722
- if (result.flowId != flowId || result.resource.resourceId != resourceId || publicationId != null && result.publicationId != publicationId) return invalidResponse();
11723
- return result;
11724
- }
11725
11821
  async listPublications(flowId, options = {}, signal) {
11726
11822
  const parameters = new URLSearchParams();
11727
11823
  if (options.cursor != null) parameters.set("cursor", options.cursor);
@@ -12050,6 +12146,66 @@ function liveRunRequest(harness, publicationId, key) {
12050
12146
  });
12051
12147
  }
12052
12148
  var controlApiConformanceCases = [
12149
+ {
12150
+ name: "imports workflow files atomically and exports a new unpublished draft with its Presentation",
12151
+ async verify(harness) {
12152
+ const api = new ControlClient((url, init) => harness.request(new Request(new URL(url, harness.origin), init)));
12153
+ const file = {
12154
+ kind: "open-flow-workflow",
12155
+ version: 1,
12156
+ name: "Portable flow",
12157
+ content: {
12158
+ modelVersion: 6,
12159
+ modules: {},
12160
+ document: {
12161
+ bindings: {},
12162
+ graph: {
12163
+ nodes: { start: {
12164
+ kind: "manual",
12165
+ name: "Start"
12166
+ } },
12167
+ edges: []
12168
+ }
12169
+ }
12170
+ },
12171
+ presentation: { viewport: {
12172
+ x: 10,
12173
+ y: 20,
12174
+ zoom: 1
12175
+ } }
12176
+ };
12177
+ const idempotencyKey = crypto.randomUUID();
12178
+ const created = await api.importFlow(file, { idempotencyKey });
12179
+ equal(dequal(await api.importFlow(file, { idempotencyKey }), created), true, "Import retry must return the same Flow.");
12180
+ equal(dequal(await api.exportFlow(created.flowId), file), true, "Export must retain the graph and Presentation.");
12181
+ const editor = await api.getEditor(created.flowId);
12182
+ equal(editor.live.publication == null, true, "Import must not publish.");
12183
+ equal(editor.draft.parentRevisionId == null, true, "Import must create an initial Revision.");
12184
+ equal(dequal(editor.presentation.value, file.presentation), true, "Import must atomically save Presentation.");
12185
+ await error(await request(harness, "/v1/flows/import", {
12186
+ method: "POST",
12187
+ headers: { "idempotency-key": idempotencyKey },
12188
+ body: JSON.stringify({
12189
+ file,
12190
+ name: "Changed",
12191
+ version: 1
12192
+ })
12193
+ }), 409, "flow.conflict", "Reject changed import retry");
12194
+ const before = await api.listFlows();
12195
+ await error(await request(harness, "/v1/flows/import", {
12196
+ method: "POST",
12197
+ headers: { "idempotency-key": crypto.randomUUID() },
12198
+ body: JSON.stringify({
12199
+ file: {
12200
+ ...file,
12201
+ version: 99
12202
+ },
12203
+ version: 1
12204
+ })
12205
+ }), 400, "flow.invalid", "Reject unsupported file");
12206
+ equal(dequal((await api.listFlows()).flows, before.flows), true, "Rejected import left an empty Flow.");
12207
+ }
12208
+ },
12053
12209
  {
12054
12210
  name: "authors nodes atomically with public views, fixed reads and replay before CAS",
12055
12211
  async verify(harness) {
@@ -13007,12 +13163,20 @@ var triggerControlApiConformanceCases = [{
13007
13163
  equal(binding.currentPublicationId, publicationId, "Trigger Publication");
13008
13164
  equal(binding.operatorState, void 0, "No individual Trigger control state");
13009
13165
  }
13166
+ const online = await client(harness).getLiveDetails(flowId);
13167
+ equal(online.publication?.publicationId, publicationId, "Online Publication");
13168
+ equal(online.entries.map((entry) => entry.type), ["cron", "webhook"], "Online entries");
13169
+ const onlineWebhook = online.entries.find((entry) => entry.type == "webhook");
13170
+ if (onlineWebhook?.type != "webhook") fail("Missing online Webhook.");
13171
+ equal(onlineWebhook.config.method, "POST", "Online request method");
13172
+ equal(onlineWebhook.config.body, {}, "Online request fields");
13010
13173
  const webhookPath = `${base}/webhook`;
13011
13174
  const endpointUrl = requiredString(record((await json(await request(harness, webhookPath), 200, "Read Webhook")).binding, "Webhook").endpointUrl, "Webhook endpoint");
13012
13175
  for (const action of ["pause", "resume"]) equal((await request(harness, `${webhookPath}/${action}`, {
13013
13176
  body: JSON.stringify({ version: 1 }),
13014
13177
  method: "POST"
13015
13178
  })).status, 404, "Individual Trigger control is unavailable");
13179
+ equal(onlineWebhook.binding.endpointUrl, endpointUrl, "Online endpoint shares binding authority");
13016
13180
  const enable = (enabled) => request(harness, `/v1/flows/${flowId}/enabled`, {
13017
13181
  method: "PUT",
13018
13182
  body: JSON.stringify({