@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
@@ -162,6 +162,12 @@ export declare const controlRequests: {
162
162
  version: 1;
163
163
  expectedRevision: number;
164
164
  };
165
+ importFlow: (value: unknown) => {
166
+ file: JsonValue;
167
+ name?: string | undefined;
168
+ teamId?: string | undefined;
169
+ version: 1;
170
+ };
165
171
  createFlow: (value: unknown) => {
166
172
  name: string;
167
173
  teamId?: string | undefined;
@@ -8360,10 +8360,10 @@ function compileEnumAndConst(context, enumList, constValue, schema) {
8360
8360
  }
8361
8361
  if (compiledEnum.length === 0) recordWarn(context, "all of elements from list is rejected by currently schema object", "enum");
8362
8362
  }
8363
- if (constValue && valid(schema, constValue) === ValidResult.Invalid) isNever = true;
8363
+ if (constValue !== void 0 && valid(schema, constValue) === ValidResult.Invalid) isNever = true;
8364
8364
  if (compiledEnum) {
8365
8365
  if (compiledEnum.length === 0) isNever = true;
8366
- else if (constValue) {
8366
+ else if (constValue !== void 0) {
8367
8367
  let foundEquals = false;
8368
8368
  for (const enumValue of compiledEnum) if (isDeepEquals(enumValue, constValue)) {
8369
8369
  foundEquals = true;
@@ -8376,7 +8376,7 @@ function compileEnumAndConst(context, enumList, constValue, schema) {
8376
8376
  const compiledSchema = {};
8377
8377
  if (schema.type) compiledSchema.type = schema.type;
8378
8378
  if (compiledEnum) compiledSchema.enum = compiledEnum;
8379
- if (constValue) compiledSchema.const = wrapCompiledValue(deepCopy(constValue));
8379
+ if (constValue !== void 0) compiledSchema.const = wrapCompiledValue(deepCopy(constValue));
8380
8380
  return wrapCompiledSchema(kind, compiledSchema, context.delegate, context.path);
8381
8381
  }
8382
8382
  //#endregion
@@ -8771,7 +8771,7 @@ function compileSchema(context, schema) {
8771
8771
  let targetSchema = schema;
8772
8772
  let shouldHandleEnumAndConst = false;
8773
8773
  const { enum: enumList, const: constValue } = schema;
8774
- if (enumList || constValue) {
8774
+ if (enumList || constValue !== void 0) {
8775
8775
  const { enum: _0, const: _1, ...rest } = schema;
8776
8776
  targetSchema = rest;
8777
8777
  shouldHandleEnumAndConst = true;
@@ -9361,7 +9361,7 @@ function schemaEqualsChecker(extendsContext) {
9361
9361
  }
9362
9362
  function isValueEquals(value1, value2) {
9363
9363
  if (value1 === value2) return true;
9364
- if (value1 === null) return false;
9364
+ if (value1 === null || value2 === null) return false;
9365
9365
  if (typeof value1 !== "object") return false;
9366
9366
  if (typeof value1 !== typeof value2) return false;
9367
9367
  if (isCompiledSchema(value1) && isCompiledSchema(value2)) return isCompiledSchemaEquals(value1, value2);
@@ -9927,7 +9927,7 @@ function findMismatchPath(source, target) {
9927
9927
  if ((sourceSchema.maxProperties ?? Number.POSITIVE_INFINITY) > (targetSchema.maxProperties ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxProperties"];
9928
9928
  break;
9929
9929
  }
9930
- case CompiledKind.EnumOrConst: return [...targetPath, targetSchema.const == null ? "enum" : "const"];
9930
+ case CompiledKind.EnumOrConst: return [...targetPath, targetSchema.const === void 0 ? "enum" : "const"];
9931
9931
  }
9932
9932
  return targetPath;
9933
9933
  }
@@ -10464,7 +10464,8 @@ var managedFields = object$1({
10464
10464
  object$1({
10465
10465
  kind: literal("connector"),
10466
10466
  action: text$1,
10467
- connectionId: text$1.optional()
10467
+ connectionId: text$1.optional(),
10468
+ outputMode: literal("value").optional()
10468
10469
  }),
10469
10470
  object$1({
10470
10471
  kind: literal("openapi"),
@@ -11613,7 +11614,7 @@ var authoringConfigurations = {
11613
11614
  outputs: outputFields,
11614
11615
  capabilities: authoringDefinitionSchemas.capabilities.optional()
11615
11616
  }),
11616
- connector: authoringDefinitionSchemas.connector.strict(),
11617
+ connector: authoringDefinitionSchemas.connector.omit({ outputMode: true }).strict(),
11617
11618
  openapi: authoringOpenApiSchema,
11618
11619
  agent: authoringDefinitionSchemas.agent.omit({
11619
11620
  prompt: true,
@@ -12019,6 +12020,13 @@ var authoringSearchResponse = object$1({
12019
12020
  version: literal(1)
12020
12021
  });
12021
12022
  //#endregion
12023
+ //#region src/connector/common/actionSchema.ts
12024
+ function connectorOutputMode(schema) {
12025
+ const root = toPlainObject(schema);
12026
+ const properties = toPlainObject(root?.properties);
12027
+ return properties != null && Object.keys(properties).length > 0 || root?.type == "object" && root.additionalProperties === false ? "fields" : "value";
12028
+ }
12029
+ //#endregion
12022
12030
  //#region src/trigger/common/contract.ts
12023
12031
  var errorOutputs = [
12024
12032
  {
@@ -12814,6 +12822,27 @@ async function prepareAgentTools(tools, previous, action, id) {
12814
12822
  return prepared;
12815
12823
  }
12816
12824
  //#endregion
12825
+ //#region src/control/common/authoringTriggers.ts
12826
+ /** Shared business configuration for authoring and published entry inspection. */
12827
+ function triggerConfiguration(node) {
12828
+ switch (node.kind) {
12829
+ case "manual": return {};
12830
+ case "webhook": return {
12831
+ body: fieldsView(node.bodyFields),
12832
+ method: node.method,
12833
+ ...node.options == null ? {} : { options: node.options }
12834
+ };
12835
+ case "cron": return { schedule: node.cronTimes };
12836
+ case "error": return node.sourceFlowIds == null ? {} : { sourceFlowIds: node.sourceFlowIds };
12837
+ case "poll":
12838
+ case "integration": return {
12839
+ key: node.definition.key,
12840
+ ...node.connectionId == null ? {} : { connectionId: node.connectionId },
12841
+ ...node.kind == "poll" ? { schedule: node.pollTimes } : {}
12842
+ };
12843
+ }
12844
+ }
12845
+ //#endregion
12817
12846
  //#region src/control/common/authoring.ts
12818
12847
  var record = (value) => value != null && typeof value == "object" && !Array.isArray(value) ? value : {};
12819
12848
  var json$2 = (value) => JSON.parse(JSON.stringify(value));
@@ -12899,6 +12928,9 @@ function authoringNode(content, ref) {
12899
12928
  const { inputDefinitions: _definitions, ...noticeSettings } = notification;
12900
12929
  config.notification = noticeSettings;
12901
12930
  }
12931
+ } else if (task.executor.kind == "connector") {
12932
+ const { kind: _kind, outputMode: _outputMode, ...settings } = task.executor;
12933
+ config = settings;
12902
12934
  } else if (task.executor.kind == "llm") config = {
12903
12935
  ...llmConfigurationView(task),
12904
12936
  inputs: fieldsView([...task.inputs, ...node.kind == "task" ? node.additionalInputs ?? [] : []].filter((port) => !("handle" in port) || !llmReservedInputs.includes(port.handle)))
@@ -12926,25 +12958,12 @@ function authoringNode(content, ref) {
12926
12958
  config = { inputs: fieldsView(node.inputDefinitions) };
12927
12959
  texts.prompt = node.prompt;
12928
12960
  break;
12961
+ case "manual":
12929
12962
  case "webhook":
12930
- config = {
12931
- body: fieldsView(node.bodyFields),
12932
- method: node.method,
12933
- ...node.options == null ? {} : { options: node.options }
12934
- };
12935
- break;
12936
12963
  case "cron":
12937
- config = { schedule: node.cronTimes };
12938
- break;
12939
12964
  case "error":
12940
- config = node.sourceFlowIds == null ? {} : { sourceFlowIds: node.sourceFlowIds };
12941
- break;
12942
12965
  case "poll":
12943
- case "integration": config = {
12944
- key: node.definition.key,
12945
- ...node.connectionId == null ? {} : { connectionId: node.connectionId },
12946
- ...node.kind == "poll" ? { schedule: node.pollTimes } : {}
12947
- };
12966
+ case "integration": config = triggerConfiguration(node);
12948
12967
  }
12949
12968
  const edges = authoringEdges(content.document.graph.edges);
12950
12969
  return {
@@ -13160,7 +13179,8 @@ async function compileAuthoring(base, request, host) {
13160
13179
  executor: {
13161
13180
  kind: "connector",
13162
13181
  action: action.actionId,
13163
- ...config.connectionId == null ? {} : { connectionId: String(config.connectionId) }
13182
+ ...config.connectionId == null ? {} : { connectionId: String(config.connectionId) },
13183
+ ...action.outputSchema !== void 0 && connectorOutputMode(action.outputSchema) == "value" ? { outputMode: "value" } : {}
13164
13184
  },
13165
13185
  inputs: Object.entries(action.inputs).map(([handle, port]) => Object.assign({ handle }, port)),
13166
13186
  outputs: Object.entries(action.outputs).map(([handle, port]) => Object.assign({ handle }, port))
@@ -13228,15 +13248,19 @@ async function compileAuthoring(base, request, host) {
13228
13248
  } else if (node.kind == "task" && "executor" in node.task) {
13229
13249
  const before = node.task;
13230
13250
  let task;
13231
- if (type == "connector") task = config.action == (before.executor.kind == "connector" ? before.executor.action : "") ? {
13232
- ...before,
13233
- name: String(update.name),
13234
- executor: {
13235
- kind: "connector",
13236
- ...config
13237
- }
13238
- } : await connectorTask(config, String(update.name));
13239
- else if (type == "decision") task = decisionTask(config.questions, String(update.name));
13251
+ if (type == "connector") {
13252
+ if (before.executor.kind == "connector" && config.action == before.executor.action) {
13253
+ const { connectionId: _connectionId, ...executor } = before.executor;
13254
+ task = {
13255
+ ...before,
13256
+ name: String(update.name),
13257
+ executor: {
13258
+ ...executor,
13259
+ ...config
13260
+ }
13261
+ };
13262
+ } else task = await connectorTask(config, String(update.name));
13263
+ } else if (type == "decision") task = decisionTask(config.questions, String(update.name));
13240
13264
  else if (type == "openapi") task = await prepareOpenApiTask(config, before, (url) => host.openapi(url), String(update.name), {
13241
13265
  authentication: explicit("authentication"),
13242
13266
  serverUrl: explicit("serverUrl")
@@ -14000,6 +14024,12 @@ var schemas = {
14000
14024
  createEventSource: createEventSourceSchema,
14001
14025
  updateEventSource: updateEventSourceSchema,
14002
14026
  eventSourceRevision: eventSourceRevisionSchema,
14027
+ importFlow: strictObject({
14028
+ file: json,
14029
+ name: flowName.optional(),
14030
+ teamId: id.optional(),
14031
+ version
14032
+ }),
14003
14033
  createFlow: strictObject({
14004
14034
  name: flowName,
14005
14035
  teamId: id.optional(),
@@ -14102,6 +14132,7 @@ var controlRequests = {
14102
14132
  createEventSource: decoder(schemas.createEventSource),
14103
14133
  updateEventSource: decoder(schemas.updateEventSource),
14104
14134
  eventSourceRevision: decoder(schemas.eventSourceRevision),
14135
+ importFlow: decoder(schemas.importFlow),
14105
14136
  createFlow: decoder(schemas.createFlow),
14106
14137
  renameFlow: decoder(schemas.renameFlow),
14107
14138
  changeDraft(value) {
@@ -6711,7 +6711,8 @@ var managedFields = object({
6711
6711
  object({
6712
6712
  kind: literal("connector"),
6713
6713
  action: text,
6714
- connectionId: text.optional()
6714
+ connectionId: text.optional(),
6715
+ outputMode: literal("value").optional()
6715
6716
  }),
6716
6717
  object({
6717
6718
  kind: literal("openapi"),
@@ -8096,10 +8097,10 @@ function compileEnumAndConst(context, enumList, constValue, schema) {
8096
8097
  }
8097
8098
  if (compiledEnum.length === 0) recordWarn(context, "all of elements from list is rejected by currently schema object", "enum");
8098
8099
  }
8099
- if (constValue && valid(schema, constValue) === ValidResult.Invalid) isNever = true;
8100
+ if (constValue !== void 0 && valid(schema, constValue) === ValidResult.Invalid) isNever = true;
8100
8101
  if (compiledEnum) {
8101
8102
  if (compiledEnum.length === 0) isNever = true;
8102
- else if (constValue) {
8103
+ else if (constValue !== void 0) {
8103
8104
  let foundEquals = false;
8104
8105
  for (const enumValue of compiledEnum) if (isDeepEquals(enumValue, constValue)) {
8105
8106
  foundEquals = true;
@@ -8112,7 +8113,7 @@ function compileEnumAndConst(context, enumList, constValue, schema) {
8112
8113
  const compiledSchema = {};
8113
8114
  if (schema.type) compiledSchema.type = schema.type;
8114
8115
  if (compiledEnum) compiledSchema.enum = compiledEnum;
8115
- if (constValue) compiledSchema.const = wrapCompiledValue(deepCopy(constValue));
8116
+ if (constValue !== void 0) compiledSchema.const = wrapCompiledValue(deepCopy(constValue));
8116
8117
  return wrapCompiledSchema(kind, compiledSchema, context.delegate, context.path);
8117
8118
  }
8118
8119
  //#endregion
@@ -8507,7 +8508,7 @@ function compileSchema(context, schema) {
8507
8508
  let targetSchema = schema;
8508
8509
  let shouldHandleEnumAndConst = false;
8509
8510
  const { enum: enumList, const: constValue } = schema;
8510
- if (enumList || constValue) {
8511
+ if (enumList || constValue !== void 0) {
8511
8512
  const { enum: _0, const: _1, ...rest } = schema;
8512
8513
  targetSchema = rest;
8513
8514
  shouldHandleEnumAndConst = true;
@@ -9097,7 +9098,7 @@ function schemaEqualsChecker(extendsContext) {
9097
9098
  }
9098
9099
  function isValueEquals(value1, value2) {
9099
9100
  if (value1 === value2) return true;
9100
- if (value1 === null) return false;
9101
+ if (value1 === null || value2 === null) return false;
9101
9102
  if (typeof value1 !== "object") return false;
9102
9103
  if (typeof value1 !== typeof value2) return false;
9103
9104
  if (isCompiledSchema(value1) && isCompiledSchema(value2)) return isCompiledSchemaEquals(value1, value2);
@@ -9663,7 +9664,7 @@ function findMismatchPath(source, target) {
9663
9664
  if ((sourceSchema.maxProperties ?? Number.POSITIVE_INFINITY) > (targetSchema.maxProperties ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxProperties"];
9664
9665
  break;
9665
9666
  }
9666
- case CompiledKind.EnumOrConst: return [...targetPath, targetSchema.const == null ? "enum" : "const"];
9667
+ case CompiledKind.EnumOrConst: return [...targetPath, targetSchema.const === void 0 ? "enum" : "const"];
9667
9668
  }
9668
9669
  return targetPath;
9669
9670
  }
@@ -10,3 +10,4 @@ export interface ConnectionUsage {
10
10
  }
11
11
  export declare function connectionUsage(document: FlowDocument): readonly ConnectionUsage[];
12
12
  export declare function removeConnectionUsage(content: RevisionContent, connectionId: string): RevisionContent;
13
+ export declare function clearNodeConnections(graph: FlowDocument['graph'], connectionId?: string): FlowDocument['graph'];
@@ -1,4 +1,5 @@
1
1
  import type { CodeModule, FlowDocument, Graph, Group, InputPort, JsonValue, ManagedTaskDefinition, Port, RevisionContent, TriggerNode } from '@oomol-lab/open-flow/flow-change';
2
+ export * from './flow-workflowFile.js';
2
3
  export { maxJsonDepth } from './flow-json.js';
3
4
  export { decodeFlowDocument, decodeRevisionContent } from '../browser/flow-change-schema.js';
4
5
  export declare function canonicalJsonBytes(value: JsonValue): Uint8Array;
@@ -6649,10 +6649,10 @@ function compileEnumAndConst(context, enumList, constValue, schema) {
6649
6649
  }
6650
6650
  if (compiledEnum.length === 0) recordWarn(context, "all of elements from list is rejected by currently schema object", "enum");
6651
6651
  }
6652
- if (constValue && valid(schema, constValue) === ValidResult.Invalid) isNever = true;
6652
+ if (constValue !== void 0 && valid(schema, constValue) === ValidResult.Invalid) isNever = true;
6653
6653
  if (compiledEnum) {
6654
6654
  if (compiledEnum.length === 0) isNever = true;
6655
- else if (constValue) {
6655
+ else if (constValue !== void 0) {
6656
6656
  let foundEquals = false;
6657
6657
  for (const enumValue of compiledEnum) if (isDeepEquals(enumValue, constValue)) {
6658
6658
  foundEquals = true;
@@ -6665,7 +6665,7 @@ function compileEnumAndConst(context, enumList, constValue, schema) {
6665
6665
  const compiledSchema = {};
6666
6666
  if (schema.type) compiledSchema.type = schema.type;
6667
6667
  if (compiledEnum) compiledSchema.enum = compiledEnum;
6668
- if (constValue) compiledSchema.const = wrapCompiledValue(deepCopy(constValue));
6668
+ if (constValue !== void 0) compiledSchema.const = wrapCompiledValue(deepCopy(constValue));
6669
6669
  return wrapCompiledSchema(kind, compiledSchema, context.delegate, context.path);
6670
6670
  }
6671
6671
  //#endregion
@@ -7060,7 +7060,7 @@ function compileSchema(context, schema) {
7060
7060
  let targetSchema = schema;
7061
7061
  let shouldHandleEnumAndConst = false;
7062
7062
  const { enum: enumList, const: constValue } = schema;
7063
- if (enumList || constValue) {
7063
+ if (enumList || constValue !== void 0) {
7064
7064
  const { enum: _0, const: _1, ...rest } = schema;
7065
7065
  targetSchema = rest;
7066
7066
  shouldHandleEnumAndConst = true;
@@ -7650,7 +7650,7 @@ function schemaEqualsChecker(extendsContext) {
7650
7650
  }
7651
7651
  function isValueEquals(value1, value2) {
7652
7652
  if (value1 === value2) return true;
7653
- if (value1 === null) return false;
7653
+ if (value1 === null || value2 === null) return false;
7654
7654
  if (typeof value1 !== "object") return false;
7655
7655
  if (typeof value1 !== typeof value2) return false;
7656
7656
  if (isCompiledSchema(value1) && isCompiledSchema(value2)) return isCompiledSchemaEquals(value1, value2);
@@ -8216,7 +8216,7 @@ function findMismatchPath(source, target) {
8216
8216
  if ((sourceSchema.maxProperties ?? Number.POSITIVE_INFINITY) > (targetSchema.maxProperties ?? Number.POSITIVE_INFINITY)) return [...targetPath, "maxProperties"];
8217
8217
  break;
8218
8218
  }
8219
- case CompiledKind.EnumOrConst: return [...targetPath, targetSchema.const == null ? "enum" : "const"];
8219
+ case CompiledKind.EnumOrConst: return [...targetPath, targetSchema.const === void 0 ? "enum" : "const"];
8220
8220
  }
8221
8221
  return targetPath;
8222
8222
  }
@@ -8693,7 +8693,8 @@ var managedFields = object({
8693
8693
  object({
8694
8694
  kind: literal("connector"),
8695
8695
  action: text,
8696
- connectionId: text.optional()
8696
+ connectionId: text.optional(),
8697
+ outputMode: literal("value").optional()
8697
8698
  }),
8698
8699
  object({
8699
8700
  kind: literal("openapi"),
@@ -8961,7 +8962,7 @@ var revision = object({
8961
8962
  document,
8962
8963
  modules: record$1(text, module)
8963
8964
  });
8964
- var envelope = revision.extend({
8965
+ var envelope$1 = revision.extend({
8965
8966
  kind: literal("open-flow-flow-revision"),
8966
8967
  version: literal(1)
8967
8968
  });
@@ -9186,7 +9187,7 @@ function decodeRevisionEnvelope(value) {
9186
9187
  ...revisionSource,
9187
9188
  document: upgradeLegacyDocument(revisionSource.document)
9188
9189
  } : value;
9189
- const content = envelope.parse(candidate);
9190
+ const content = envelope$1.parse(candidate);
9190
9191
  checkModelVersion(content);
9191
9192
  assertOpenApiAuthBindings(content.document);
9192
9193
  return {
@@ -9352,6 +9353,197 @@ function checkModelVersion(content) {
9352
9353
  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.");
9353
9354
  }
9354
9355
  //#endregion
9356
+ //#region src/flow/common/condition.ts
9357
+ function clearConditionBinding(operand) {
9358
+ return operand.kind == "source" && operand.source.kind == "binding" ? { kind: "value" } : operand;
9359
+ }
9360
+ function clearConditionBindings(node) {
9361
+ return {
9362
+ ...node,
9363
+ cases: node.cases.map((item) => ({
9364
+ ...item,
9365
+ groups: item.groups.map((group) => ({
9366
+ ...group,
9367
+ expressions: group.expressions.map((expression) => ({
9368
+ ...expression,
9369
+ left: clearConditionBinding(expression.left),
9370
+ ...expression.right == null ? {} : { right: clearConditionBinding(expression.right) }
9371
+ }))
9372
+ }))
9373
+ }))
9374
+ };
9375
+ }
9376
+ //#endregion
9377
+ //#region src/trigger/common/config.ts
9378
+ /** Deployment-bound selections owned by the Trigger configuration contract. */
9379
+ function clearTriggerExternalConfig(key, config) {
9380
+ const fields = key == "feishu_app_bot.on_event" ? [
9381
+ "sourceId",
9382
+ "eventTypes",
9383
+ "resource",
9384
+ "chatIds"
9385
+ ] : key == "linear.on_issue_changed" ? ["teamId", "stateIds"] : [];
9386
+ return {
9387
+ ...config,
9388
+ ...Object.fromEntries(fields.map((field) => [field, { kind: "unset" }]))
9389
+ };
9390
+ }
9391
+ //#endregion
9392
+ //#region src/flow/common/connectionUsage.ts
9393
+ function clearNodeConnections(graph, connectionId) {
9394
+ return {
9395
+ ...graph,
9396
+ nodes: Object.fromEntries(Object.entries(graph.nodes).map(([id, node]) => {
9397
+ if ((node.kind == "poll" || node.kind == "integration") && (connectionId == null || node.connectionId == connectionId)) {
9398
+ const { connectionId: _, ...remaining } = node;
9399
+ return [id, remaining];
9400
+ }
9401
+ if (node.kind != "task") return [id, node];
9402
+ if ("executor" in node.task) {
9403
+ const executor = node.task.executor;
9404
+ const clear = (value) => {
9405
+ if (connectionId != null && value.connectionId != connectionId) return value;
9406
+ const { connectionId: _, ...rest } = value;
9407
+ return rest;
9408
+ };
9409
+ if (executor.kind == "connector") return [id, {
9410
+ ...node,
9411
+ task: {
9412
+ ...node.task,
9413
+ executor: clear(executor)
9414
+ }
9415
+ }];
9416
+ if (executor.kind == "agent") return [id, {
9417
+ ...node,
9418
+ task: {
9419
+ ...node.task,
9420
+ executor: {
9421
+ ...executor,
9422
+ tools: executor.tools.map(clear),
9423
+ ...executor.notification == null ? {} : { notification: clear(executor.notification) }
9424
+ }
9425
+ }
9426
+ }];
9427
+ return [id, node];
9428
+ }
9429
+ const capabilities = node.task.capabilities?.map((capability) => {
9430
+ if (!("mode" in capability)) {
9431
+ if ("action" in capability) {
9432
+ const { connectionId: selected, ...rest } = capability;
9433
+ return {
9434
+ ...rest,
9435
+ connections: capability.connections.filter((item) => connectionId != null && item.connectionId != connectionId),
9436
+ ...selected != null && connectionId != null && selected != connectionId ? { connectionId: selected } : {}
9437
+ };
9438
+ }
9439
+ return {
9440
+ ...capability,
9441
+ ...connectionId == null && (capability.connectionHints?.length ?? 0) > 0 ? { actionHints: [.../* @__PURE__ */ new Set([...capability.actionHints ?? [], ...capability.connectionHints.map((hint) => hint.action)])] } : {},
9442
+ ...capability.connectionHints == null ? {} : { connectionHints: capability.connectionHints.filter((item) => connectionId != null && item.connectionId != connectionId) }
9443
+ };
9444
+ }
9445
+ if (capability.mode != "independent") return capability;
9446
+ return {
9447
+ ...capability,
9448
+ actions: capability.actions.map((action) => {
9449
+ if (connectionId != null && action.connectionId != connectionId) return action;
9450
+ const { connectionId: _, ...remaining } = action;
9451
+ return remaining;
9452
+ })
9453
+ };
9454
+ });
9455
+ return [id, capabilities == null ? node : {
9456
+ ...node,
9457
+ task: {
9458
+ ...node.task,
9459
+ capabilities
9460
+ }
9461
+ }];
9462
+ }))
9463
+ };
9464
+ }
9465
+ //#endregion
9466
+ //#region src/flow/common/workflowFile.ts
9467
+ var envelope = strictObject({
9468
+ kind: literal("open-flow-workflow"),
9469
+ version: literal(1),
9470
+ name: string().optional(),
9471
+ content: unknown(),
9472
+ presentation: record$1(string(), json$1()).optional()
9473
+ });
9474
+ /** Structural decoding only: incomplete drafts are supported, repair is never attempted. */
9475
+ function decodeWorkflowFile(value) {
9476
+ checkJsonDepth(value, -1);
9477
+ const file = envelope.parse(value);
9478
+ return {
9479
+ ...file,
9480
+ content: decodeRevisionContent(file.content)
9481
+ };
9482
+ }
9483
+ function parseWorkflowFile(text) {
9484
+ return decodeWorkflowFile(JSON.parse(text));
9485
+ }
9486
+ function cleanInput(input) {
9487
+ if (input.kind != "sources" || !input.sources.some((source) => source.kind == "binding")) return input;
9488
+ const sources = input.sources.filter((source) => source.kind != "binding");
9489
+ return sources.length == 0 ? { kind: "unset" } : {
9490
+ kind: "sources",
9491
+ sources
9492
+ };
9493
+ }
9494
+ /** Clear only owned structured references, never strings in code or business values. */
9495
+ function cleanWorkflowFile(value) {
9496
+ const file = decodeWorkflowFile(value);
9497
+ const original = file.content.document.graph;
9498
+ const graph = clearNodeConnections(original);
9499
+ const nodes = Object.fromEntries(Object.entries(graph.nodes).map(([id, source]) => {
9500
+ let node = source;
9501
+ if ("inputs" in node) node = {
9502
+ ...node,
9503
+ inputs: Object.fromEntries(Object.entries(node.inputs).map(([key, input]) => [key, cleanInput(input)]))
9504
+ };
9505
+ if (node.kind == "condition") node = clearConditionBindings(node);
9506
+ if (node.kind == "error" && node.sourceFlowIds != null) node = {
9507
+ ...node,
9508
+ sourceFlowIds: []
9509
+ };
9510
+ if (node.kind == "poll" || node.kind == "integration") node = {
9511
+ ...node,
9512
+ config: clearTriggerExternalConfig(node.definition.key, node.config)
9513
+ };
9514
+ return [id, node];
9515
+ }));
9516
+ return {
9517
+ file: {
9518
+ ...file,
9519
+ content: {
9520
+ ...file.content,
9521
+ document: {
9522
+ ...file.content.document,
9523
+ bindings: {},
9524
+ graph: {
9525
+ ...graph,
9526
+ nodes
9527
+ }
9528
+ }
9529
+ }
9530
+ },
9531
+ summary: {
9532
+ changedNodeIds: Object.keys(nodes).filter((id) => !dequal(nodes[id], original.nodes[id])),
9533
+ removedBindings: Object.keys(file.content.document.bindings).length
9534
+ }
9535
+ };
9536
+ }
9537
+ function encodeWorkflowFile(file) {
9538
+ return `${JSON.stringify(cleanWorkflowFile(file).file, null, 2)}\n`;
9539
+ }
9540
+ function workflowFileName(name) {
9541
+ return `${name.replace(/[<>:"/\\|?*\u0000-\u001f]/g, "_").replace(/[. ]+$/g, "") || "workflow"}.openflow.json`;
9542
+ }
9543
+ function workflowNameFromFile(name) {
9544
+ return name.replace(/(?:\.openflow)?\.json$/i, "");
9545
+ }
9546
+ //#endregion
9355
9547
  //#region src/flow/common/encoding.ts
9356
9548
  var encoder = new TextEncoder();
9357
9549
  function canonicalText(value) {
@@ -9700,4 +9892,4 @@ function repairRevision(bytes) {
9700
9892
  return repairRevisionEnvelope(revisionValue(bytes));
9701
9893
  }
9702
9894
  //#endregion
9703
- export { canonicalDocument, canonicalGraph, canonicalJsonBytes, canonicalModule, canonicalPorts, canonicalRevisionGraph, canonicalTask, decodeFlowDocument, decodeRevision, decodeRevisionContent, digestBytes, encodeRevision, maxJsonDepth, repairRevision, revisionRepairKind, triggerRuntimeJson };
9895
+ export { canonicalDocument, canonicalGraph, canonicalJsonBytes, canonicalModule, canonicalPorts, canonicalRevisionGraph, canonicalTask, cleanWorkflowFile, decodeFlowDocument, decodeRevision, decodeRevisionContent, decodeWorkflowFile, digestBytes, encodeRevision, encodeWorkflowFile, maxJsonDepth, parseWorkflowFile, repairRevision, revisionRepairKind, triggerRuntimeJson, workflowFileName, workflowNameFromFile };