@oomol-lab/open-flow 0.1.0-beta.50 → 0.1.0-beta.52

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 (44) hide show
  1. package/dist/browser/{createResourceDialog-CSltk-qY.js → createResourceDialog-BsaBMf7_.js} +2 -1
  2. package/dist/browser/flow-authoring-node.d.ts +3 -1
  3. package/dist/browser/flow-authoring.js +82 -3
  4. package/dist/browser/flow-change-schema.d.ts +1 -1
  5. package/dist/browser/flow-change.d.ts +15 -2
  6. package/dist/browser/flow-change.js +81 -3
  7. package/dist/browser/{flowChanges-DbYrpHnS.js → flowChanges-DtraMpva.js} +3858 -1921
  8. package/dist/browser/{flowWorkspace-CjwpbVBR.js → flowWorkspace-DLgti4Lk.js} +1353 -513
  9. package/dist/browser/{workbenchSelect-oVujN2z6.js → icons-0s-Q_3lp.js} +92 -35
  10. package/dist/browser/licenses.md +204 -0
  11. package/dist/browser/preview.css +302 -179
  12. package/dist/browser/preview.js +4829 -2198
  13. package/dist/browser/theme.css +2 -0
  14. package/dist/browser/ui-hostNavigationActions.d.ts +13 -0
  15. package/dist/browser/ui-hostTooltip.d.ts +8 -0
  16. package/dist/browser/ui-logo.d.ts +5 -0
  17. package/dist/browser/ui.css +102 -8
  18. package/dist/browser/ui.d.ts +3 -0
  19. package/dist/browser/ui.js +176 -11
  20. package/dist/browser/workbench-contract.d.ts +5 -11
  21. package/dist/browser/workbench.css +366 -200
  22. package/dist/browser/workbench.d.ts +1 -1
  23. package/dist/browser/workbench.js +1154 -379
  24. package/dist/browser/workbenchSelect-BqUPacsr.js +31 -0
  25. package/dist/common/authoringExamples.d.ts +4 -2
  26. package/dist/common/control-api-conformance.js +129 -11
  27. package/dist/common/control-api.d.ts +38 -5
  28. package/dist/common/control-api.js +198 -12
  29. package/dist/common/control-requests.d.ts +4 -0
  30. package/dist/common/control-requests.js +1320 -67
  31. package/dist/common/flow-encoding.js +64 -5
  32. package/dist/common/flow-semantics.js +823 -316
  33. package/dist/common/integration-trigger.js +39 -1
  34. package/dist/common/mcp.js +129 -11
  35. package/dist/common/openapi.d.ts +53 -0
  36. package/dist/common/openapi.js +10390 -0
  37. package/dist/common/poll-trigger.js +39 -1
  38. package/dist/common/provider-triggers.js +39 -1
  39. package/dist/common/run-events.js +26 -1
  40. package/dist/common/scheduler.d.ts +4 -1
  41. package/dist/common/scheduler.js +122 -6
  42. package/dist/common/trigger-contract.d.ts +2 -0
  43. package/dist/common/webhook-trigger.js +39 -1
  44. package/package.json +5 -1
@@ -9369,6 +9369,24 @@ var managed = object({
9369
9369
  action: text,
9370
9370
  connectionId: text.optional()
9371
9371
  }),
9372
+ object({
9373
+ kind: literal("openapi"),
9374
+ sourceUrl: text,
9375
+ method: text,
9376
+ path: text,
9377
+ serverUrl: text,
9378
+ document: json,
9379
+ auth: array(object({
9380
+ id: text,
9381
+ type: _enum([
9382
+ "bearer",
9383
+ "basic",
9384
+ "apiKey"
9385
+ ]),
9386
+ name: text.optional(),
9387
+ in: _enum(["header", "query"]).optional()
9388
+ }))
9389
+ }),
9372
9390
  object({
9373
9391
  kind: literal("llm"),
9374
9392
  mode: _enum(["chat", "json"])
@@ -9485,6 +9503,7 @@ var endpoint = object({
9485
9503
  ])),
9486
9504
  successStatus: number()
9487
9505
  });
9506
+ var sourceFlowIds = array(text.min(1)).refine((ids) => new Set(ids).size === ids.length, "Duplicate source Flow ID.");
9488
9507
  var trigger = {
9489
9508
  name: text,
9490
9509
  description: text.optional(),
@@ -9542,6 +9561,11 @@ var node = union([
9542
9561
  ...trigger,
9543
9562
  kind: literal("manual")
9544
9563
  }),
9564
+ strictObject({
9565
+ ...trigger,
9566
+ kind: literal("error"),
9567
+ sourceFlowIds: sourceFlowIds.optional()
9568
+ }),
9545
9569
  object({
9546
9570
  ...trigger,
9547
9571
  kind: literal("webhook"),
@@ -9613,7 +9637,11 @@ var document = object({
9613
9637
  tasks: record$1(text, managed)
9614
9638
  });
9615
9639
  object({
9616
- modelVersion: union([literal(2), literal(4)]),
9640
+ modelVersion: union([
9641
+ literal(2),
9642
+ literal(4),
9643
+ literal(5)
9644
+ ]),
9617
9645
  document,
9618
9646
  modules: record$1(text, module)
9619
9647
  }).extend({
@@ -9621,6 +9649,11 @@ object({
9621
9649
  version: literal(1)
9622
9650
  });
9623
9651
  var shapes = {
9652
+ "graph.trigger.sources.set": {
9653
+ nodeId: text,
9654
+ before: sourceFlowIds.optional(),
9655
+ value: sourceFlowIds.optional()
9656
+ },
9624
9657
  "binding.create": {
9625
9658
  bindingId: text,
9626
9659
  binding
@@ -9774,6 +9807,11 @@ var shapes = {
9774
9807
  before: text.optional(),
9775
9808
  value: text.optional()
9776
9809
  },
9810
+ "task.openapi.set": {
9811
+ taskId: text,
9812
+ before: managed,
9813
+ value: managed
9814
+ },
9777
9815
  "task.agent.set": {
9778
9816
  taskId: text,
9779
9817
  before: managed,
@@ -5877,6 +5877,15 @@ var runStatuses = [
5877
5877
  //#region src/execution/common/wait.ts
5878
5878
  /** Shared by decision entry points, the editor, and durable decision storage. */
5879
5879
  var waitCommentSchema = string$1().trim().refine((value) => [...value].length <= 2e3, "Wait comment must contain at most 2,000 Unicode code points.").nullable().optional();
5880
+ //#endregion
5881
+ //#region src/openapi/common/authBindings.ts
5882
+ /** Never allow credentials to enter a Revision as literal node inputs. */
5883
+ function assertOpenApiAuthBindings(document) {
5884
+ for (const graph of [document.graph, ...Object.values(document.subflows).map((subflow) => subflow.graph)]) for (const node of Object.values(graph.nodes)) {
5885
+ if (node.kind != "task" || node.taskId == null || document.tasks[node.taskId]?.executor.kind != "openapi") continue;
5886
+ for (const [handle, mapping] of Object.entries(node.inputs)) if (handle.startsWith("auth.") && (mapping.kind == "value" || mapping.kind == "sources" && mapping.sources.some((source) => source.kind == "flow"))) throw new TypeError("OpenAPI authentication accepts deployment variables and upstream outputs only.");
5887
+ }
5888
+ }
5880
5889
  function checkJsonDepth(value, depth = 0) {
5881
5890
  if (depth > 64) throw new TypeError("Value exceeds the maximum JSON depth.");
5882
5891
  if (value != null && typeof value == "object") for (const child of Object.values(value)) checkJsonDepth(child, depth + 1);
@@ -6007,6 +6016,24 @@ var managed = object({
6007
6016
  action: text,
6008
6017
  connectionId: text.optional()
6009
6018
  }),
6019
+ object({
6020
+ kind: literal("openapi"),
6021
+ sourceUrl: text,
6022
+ method: text,
6023
+ path: text,
6024
+ serverUrl: text,
6025
+ document: json$2,
6026
+ auth: array(object({
6027
+ id: text,
6028
+ type: _enum([
6029
+ "bearer",
6030
+ "basic",
6031
+ "apiKey"
6032
+ ]),
6033
+ name: text.optional(),
6034
+ in: _enum(["header", "query"]).optional()
6035
+ }))
6036
+ }),
6010
6037
  object({
6011
6038
  kind: literal("llm"),
6012
6039
  mode: _enum(["chat", "json"])
@@ -6123,6 +6150,7 @@ var endpoint = object({
6123
6150
  ])),
6124
6151
  successStatus: number()
6125
6152
  });
6153
+ var sourceFlowIds = array(text.min(1)).refine((ids) => new Set(ids).size === ids.length, "Duplicate source Flow ID.");
6126
6154
  var trigger = {
6127
6155
  name: text,
6128
6156
  description: text.optional(),
@@ -6180,6 +6208,11 @@ var node = union([
6180
6208
  ...trigger,
6181
6209
  kind: literal("manual")
6182
6210
  }),
6211
+ strictObject({
6212
+ ...trigger,
6213
+ kind: literal("error"),
6214
+ sourceFlowIds: sourceFlowIds.optional()
6215
+ }),
6183
6216
  object({
6184
6217
  ...trigger,
6185
6218
  kind: literal("webhook"),
@@ -6251,7 +6284,11 @@ var document = object({
6251
6284
  tasks: record$1(text, managed)
6252
6285
  });
6253
6286
  var revision = object({
6254
- modelVersion: union([literal(2), literal(4)]),
6287
+ modelVersion: union([
6288
+ literal(2),
6289
+ literal(4),
6290
+ literal(5)
6291
+ ]),
6255
6292
  document,
6256
6293
  modules: record$1(text, module)
6257
6294
  });
@@ -6261,9 +6298,17 @@ revision.extend({
6261
6298
  });
6262
6299
  function decodeRevisionContent(value) {
6263
6300
  checkJsonDepth(value);
6264
- return revision.parse(value);
6301
+ const content = revision.parse(value);
6302
+ checkErrorModelVersion(content);
6303
+ assertOpenApiAuthBindings(content.document);
6304
+ return content;
6265
6305
  }
6266
6306
  var shapes = {
6307
+ "graph.trigger.sources.set": {
6308
+ nodeId: text,
6309
+ before: sourceFlowIds.optional(),
6310
+ value: sourceFlowIds.optional()
6311
+ },
6267
6312
  "binding.create": {
6268
6313
  bindingId: text,
6269
6314
  binding
@@ -6417,6 +6462,11 @@ var shapes = {
6417
6462
  before: text.optional(),
6418
6463
  value: text.optional()
6419
6464
  },
6465
+ "task.openapi.set": {
6466
+ taskId: text,
6467
+ before: managed,
6468
+ value: managed
6469
+ },
6420
6470
  "task.agent.set": {
6421
6471
  taskId: text,
6422
6472
  before: managed,
@@ -6437,6 +6487,9 @@ array(union([...new Map(Object.entries(shapes).map(([kind, shape]) => [kind, sha
6437
6487
  kind: literal(kind),
6438
6488
  ...shape
6439
6489
  })])).values()])).min(1);
6490
+ function checkErrorModelVersion(content) {
6491
+ if (content.modelVersion < 5 && [content.document.graph, ...Object.values(content.document.subflows).map((item) => item.graph)].some((item) => Object.values(item.nodes).some((itemNode) => itemNode.kind == "error"))) throw new TypeError("Error workflows require Flow model version 5.");
6492
+ }
6440
6493
  //#endregion
6441
6494
  //#region src/flow/common/change.ts
6442
6495
  var schemaKeywords = /* @__PURE__ */ new Set([
@@ -9840,6 +9893,7 @@ function triggerKey(value) {
9840
9893
  };
9841
9894
  }
9842
9895
  var triggerKinds = /* @__PURE__ */ new Set([
9896
+ "error",
9843
9897
  "cron",
9844
9898
  "integration",
9845
9899
  "poll",
@@ -10172,6 +10226,7 @@ function flow$1(value) {
10172
10226
  revisionId: string(target.revisionId)
10173
10227
  } },
10174
10228
  createdAt: string(source.createdAt),
10229
+ ...source.connectorTeamId == null ? {} : { connectorTeamId: string(source.connectorTeamId) },
10175
10230
  draftRevisionId: string(source.draftRevisionId),
10176
10231
  flowId: string(source.flowId),
10177
10232
  name: string(source.name),
@@ -10216,6 +10271,17 @@ function variable(value) {
10216
10271
  version: 1
10217
10272
  };
10218
10273
  }
10274
+ function errorListener(value) {
10275
+ const source = record(value);
10276
+ if (typeof source.enabled != "boolean") return invalidResponse();
10277
+ return {
10278
+ flowId: string(source.flowId),
10279
+ flowName: string(source.flowName),
10280
+ nodeId: string(source.nodeId),
10281
+ nodeName: string(source.nodeName),
10282
+ enabled: source.enabled
10283
+ };
10284
+ }
10219
10285
  //#endregion
10220
10286
  //#region src/control/common/publicationDecoders.ts
10221
10287
  function publication(value) {
@@ -10474,6 +10540,7 @@ function runDetails(value) {
10474
10540
  };
10475
10541
  const details = {
10476
10542
  ...summary,
10543
+ ...errorHandling(source),
10477
10544
  closureDigest: string(source.closureDigest),
10478
10545
  engineContract: string(source.engineContract),
10479
10546
  engineDigest: string(source.engineDigest),
@@ -10573,10 +10640,7 @@ function runResult(value) {
10573
10640
  const error = record(source.error);
10574
10641
  return {
10575
10642
  ...base,
10576
- error: {
10577
- code: string(error.code),
10578
- message: string(error.message)
10579
- },
10643
+ error: runFailure(error),
10580
10644
  status: "failed"
10581
10645
  };
10582
10646
  }
@@ -10584,15 +10648,52 @@ function runResult(value) {
10584
10648
  const error = record(source.error);
10585
10649
  return {
10586
10650
  ...base,
10587
- error: {
10588
- code: string(error.code),
10589
- message: string(error.message)
10590
- },
10651
+ error: runFailure(error),
10591
10652
  status: "indeterminate"
10592
10653
  };
10593
10654
  }
10594
10655
  return invalidResponse();
10595
10656
  }
10657
+ function errorHandling(source) {
10658
+ const errorSource = source.errorSource == null ? void 0 : record(source.errorSource);
10659
+ if (source.errorDispatches != null && !Array.isArray(source.errorDispatches)) return invalidResponse();
10660
+ return {
10661
+ ...errorSource == null ? {} : { errorSource: {
10662
+ flowId: string(errorSource.flowId),
10663
+ runId: string(errorSource.runId)
10664
+ } },
10665
+ ...source.errorDispatches == null ? {} : { errorDispatches: source.errorDispatches.map((value) => {
10666
+ const dispatch = record(value);
10667
+ const flowId = string(dispatch.flowId);
10668
+ switch (dispatch.status) {
10669
+ case "pending": return {
10670
+ status: "pending",
10671
+ flowId
10672
+ };
10673
+ case "dispatched": return {
10674
+ status: "dispatched",
10675
+ flowId,
10676
+ runId: string(dispatch.runId)
10677
+ };
10678
+ case "failed": return {
10679
+ status: "failed",
10680
+ flowId,
10681
+ message: string(dispatch.message)
10682
+ };
10683
+ default: return invalidResponse();
10684
+ }
10685
+ }) }
10686
+ };
10687
+ }
10688
+ function runFailure(error) {
10689
+ return {
10690
+ code: string(error.code),
10691
+ message: string(error.message),
10692
+ ...error.nodeId === void 0 ? {} : { nodeId: string(error.nodeId) },
10693
+ ...error.jobId === void 0 ? {} : { jobId: string(error.jobId) },
10694
+ ...error.path === void 0 ? {} : { path: (Array.isArray(error.path) ? error.path : invalidResponse()).map(string) }
10695
+ };
10696
+ }
10596
10697
  //#endregion
10597
10698
  //#region src/control/common/random.ts
10598
10699
  function randomId() {
@@ -10707,7 +10808,7 @@ function decodeRunEvent(value) {
10707
10808
  switch (kind) {
10708
10809
  case "node.started": {
10709
10810
  const nodeKind = payload.nodeKind;
10710
- if (nodeKind !== void 0 && nodeKind !== "approval" && nodeKind !== "condition" && nodeKind !== "connector" && nodeKind !== "javascript" && nodeKind !== "llm" && nodeKind !== "agent" && nodeKind !== "subflow" && nodeKind !== "value" && nodeKind !== "wait") return invalidResponse();
10811
+ if (nodeKind !== void 0 && nodeKind !== "approval" && nodeKind !== "condition" && nodeKind !== "connector" && nodeKind !== "javascript" && nodeKind !== "openapi" && nodeKind !== "llm" && nodeKind !== "agent" && nodeKind !== "subflow" && nodeKind !== "value" && nodeKind !== "wait") return invalidResponse();
10711
10812
  return {
10712
10813
  ...base,
10713
10814
  kind,
@@ -10816,6 +10917,18 @@ var ControlClient = class {
10816
10917
  constructor(requestControl) {
10817
10918
  this.requestControl = requestControl;
10818
10919
  }
10920
+ async loadOpenApiDocument(url, signal) {
10921
+ const result = record(await this.request("/v1/openapi/document", {
10922
+ method: "POST",
10923
+ body: JSON.stringify({
10924
+ url,
10925
+ version: 1
10926
+ }),
10927
+ signal
10928
+ }));
10929
+ if (result.version != 1) return invalidResponse();
10930
+ return jsonValue(result.document);
10931
+ }
10819
10932
  async listFlows(options = {}) {
10820
10933
  const parameters = new URLSearchParams();
10821
10934
  if (options.cursor != null) parameters.set("cursor", options.cursor);
@@ -10891,6 +11004,11 @@ var ControlClient = class {
10891
11004
  async getFlow(flowId) {
10892
11005
  return flow$1(await this.request(`/v1/flows/${segment(flowId)}`));
10893
11006
  }
11007
+ async getErrorListeners(flowId, signal) {
11008
+ const source = record(await this.request(`/v1/flows/${segment(flowId)}/error-listeners`, { signal }));
11009
+ if (source.version != 1 || !Array.isArray(source.listeners)) return invalidResponse();
11010
+ return source.listeners.map(errorListener);
11011
+ }
10894
11012
  async renameFlow(flowId, name) {
10895
11013
  return flow$1(await this.request(`/v1/flows/${segment(flowId)}`, {
10896
11014
  body: JSON.stringify({
@@ -0,0 +1,53 @@
1
+ import type { JsonValue, ManagedTaskDefinition } from '../browser/flow-change.js';
2
+ type ObjectValue = {
3
+ [key: string]: JsonValue;
4
+ };
5
+ export interface OpenApiAuth {
6
+ readonly id: string;
7
+ readonly type: 'bearer' | 'basic' | 'apiKey';
8
+ readonly name?: string;
9
+ readonly in?: 'header' | 'query';
10
+ }
11
+ export interface OpenApiExecutor {
12
+ readonly kind: 'openapi';
13
+ readonly sourceUrl: string;
14
+ readonly method: string;
15
+ readonly path: string;
16
+ readonly serverUrl: string;
17
+ readonly document: JsonValue;
18
+ readonly auth: readonly OpenApiAuth[];
19
+ }
20
+ export interface OpenApiOperation {
21
+ readonly method: string;
22
+ readonly path: string;
23
+ readonly label: string;
24
+ readonly tag: string;
25
+ }
26
+ export declare function object(value: unknown): ObjectValue;
27
+ export declare function httpUrl(value: string, base?: string): string;
28
+ export declare function parseOpenApi(value: unknown): ObjectValue;
29
+ export declare function listOperations(documentValue: JsonValue): OpenApiOperation[];
30
+ export declare function servers(value: JsonValue, path: string, method: string): readonly ObjectValue[];
31
+ export declare function serverAddress(server: ObjectValue, sourceUrl: string, variables?: Readonly<Record<string, string>>): string;
32
+ export declare function securityOptions(value: JsonValue, path: string, method: string): readonly {
33
+ label: string;
34
+ auth?: readonly OpenApiAuth[];
35
+ error?: string;
36
+ }[];
37
+ export declare function snapshot(documentValue: JsonValue, path: string, method: string): JsonValue;
38
+ export declare function authHandles(auth: readonly OpenApiAuth[]): string[];
39
+ export declare function openApiTask(config: OpenApiExecutor, name?: string): ManagedTaskDefinition;
40
+ export interface OpenApiFieldIssue {
41
+ readonly field: 'sourceUrl' | 'operation' | 'serverUrl';
42
+ readonly message: string;
43
+ }
44
+ /** The canvas validator and property panel share the same configuration contract. */
45
+ export declare function openApiFieldIssues(task: ManagedTaskDefinition): OpenApiFieldIssue[];
46
+ export declare function openApiIssues(task: ManagedTaskDefinition): string[];
47
+ export declare function selectOperation(value: JsonValue, sourceUrl: string, path: string, method: string): OpenApiExecutor;
48
+ export declare function buildRequest(config: OpenApiExecutor, input: Readonly<Record<string, JsonValue>>): {
49
+ url: string;
50
+ init: RequestInit;
51
+ };
52
+ export declare function parseResponse(config: OpenApiExecutor, status: number, headers: Headers, text: string): Record<string, JsonValue>;
53
+ export {};