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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +1 -1
  2. package/dist/browser/{createResourceDialog-BsaBMf7_.js → createResourceDialog-Btjes3wD.js} +3 -3
  3. package/dist/browser/{main-BPABKzwN.js → dist-BFmpkX4P.js} +9 -1
  4. package/dist/browser/flow-authoring-edge.d.ts +3 -3
  5. package/dist/browser/flow-authoring-node.d.ts +29 -44
  6. package/dist/browser/flow-authoring.d.ts +1 -1
  7. package/dist/browser/flow-authoring.js +418 -12018
  8. package/dist/browser/flow-change-schema.d.ts +1 -1
  9. package/dist/browser/flow-change.d.ts +15 -100
  10. package/dist/browser/flow-change.js +3175 -383
  11. package/dist/browser/{flowChanges-CcscgZsW.js → flowChanges-BxutPLYO.js} +23382 -27177
  12. package/dist/browser/{flowWorkspace-CoT_ewLX.js → flowWorkspace-Dg4mqfa6.js} +3307 -595
  13. package/dist/browser/{icons-0s-Q_3lp.js → icons-p2A9zs8t.js} +4403 -354
  14. package/dist/browser/lib-DrKav3HG.js +11403 -0
  15. package/dist/browser/{markdownContent-D3FFc-u_.js → markdownContent-frwDfQQU.js} +1 -2
  16. package/dist/browser/preview.css +375 -322
  17. package/dist/browser/preview.js +16796 -13483
  18. package/dist/browser/theme.css +1 -0
  19. package/dist/browser/ui-idTooltip.d.ts +11 -0
  20. package/dist/browser/ui.css +30 -0
  21. package/dist/browser/ui.d.ts +5 -0
  22. package/dist/browser/ui.js +87 -4
  23. package/dist/browser/workbench.css +375 -322
  24. package/dist/browser/workbench.js +213 -414
  25. package/dist/browser/{workbenchSelect-BqUPacsr.js → workbenchSelect-LRp_Xjeq.js} +1 -1
  26. package/dist/common/authoringExamples.d.ts +3 -2
  27. package/dist/common/control-api-conformance.js +3686 -3594
  28. package/dist/common/control-api.d.ts +6 -6
  29. package/dist/common/control-api.js +3760 -3645
  30. package/dist/common/control-requests.js +2382 -3118
  31. package/dist/common/decision.d.ts +47 -0
  32. package/dist/common/decision.js +10109 -0
  33. package/dist/common/flow-agent.d.ts +1 -1
  34. package/dist/common/flow-connectionUsage.d.ts +1 -2
  35. package/dist/common/flow-encoding.d.ts +2 -4
  36. package/dist/common/flow-encoding.js +3206 -286
  37. package/dist/common/flow-graph.d.ts +10 -10
  38. package/dist/common/flow-semantics.d.ts +4 -9
  39. package/dist/common/flow-semantics.js +9200 -9132
  40. package/dist/common/flowInspection.d.ts +3 -21
  41. package/dist/common/integration-trigger.js +6251 -6094
  42. package/dist/common/mcp.d.ts +0 -1
  43. package/dist/common/mcp.js +3729 -3627
  44. package/dist/common/openapi.js +6402 -6245
  45. package/dist/common/poll-trigger.js +6433 -6252
  46. package/dist/common/run-events.js +1 -1
  47. package/dist/common/runtime-contract.d.ts +8 -0
  48. package/dist/common/scheduler.d.ts +3 -9
  49. package/dist/common/scheduler.js +3263 -3153
  50. package/dist/common/webhook-trigger.js +6402 -6245
  51. package/package.json +5 -1
  52. package/dist/browser/dist-BDBTOgS5.js +0 -9
@@ -1,8 +1,7 @@
1
- import { $t as InputGroup, At as flowDependencies, Bn as inputValue, Bt as followWorkbenchLink, Ct as resetInputValues, Dn as allConnectorConnectionsQuery, Dt as setTriggerConnection, En as randomId, Et as setInputSources, F as deriveAddNodeOptions, G as resourceValue, Gn as providerIconAppearance, H as CacheResource, Hn as jsonValue, Ht as Popover, K as designerGraph, Kn as ApiError, Kt as PopoverTitle, L as feishuResourceKind, Mn as sampleErrorOutputs, Nn as triggerOutputDefinitions, Ot as updateTriggerConfig, P as addNodeIntent, Pn as isJsonObject, R as supportsFeishuChatFilter, Rn as connection, St as repairNodeNames, Tn as WorkbenchClient, Tt as setConnectorConnection, Un as record, Ut as PopoverContent, V as scopedValue, Vn as invalidResponse, Vt as Switch, W as resourceData, Wn as string, X as providerIcon, Yn as IconThemeContext, _ as updateTaskAdditionalInputs, _t as setComment, a as deleteSelection, an as EmptyHeader, at as Latest, b as updateWebhook, bt as setNodePositions, c as setInputVariable, cn as EventSourcesPage, d as updateNodeIcon, dn as createI18n, dt as actionWithConnections, en as InputGroupAddon, f as updateNodeName, ft as connectionCatalog, g as updateTask, gt as restoreCanvasPresentation, h as updateSubflow, ht as removeComments, i as createResource, in as EmptyDescription, it as revisionView, kn as decodeTriggerCatalog, kt as updateTriggerSchedule, l as updateCondition, m as updateResolution, mt as commentIds, nn as Empty, o as nameCreatedNodes, on as EmptyMedia, ot as deriveInspectorDiagnostics, p as updateNodeSettings, pt as canvasPresentationChange, qn as controlErrorCode, qt as PopoverTrigger, r as applyFlowChanges, rn as EmptyContent, s as setInputValue, sn as EmptyTitle, st as diagnosticItems, t as addNode, tn as InputGroupInput, tt as RunStore, u as updateNodeDescription, v as updateTaskPorts, vt as setFlowViewport, wn as errorNotice, wt as setCodeActions, xt as targetPresentation, y as updateValue, yt as setNodeContentHidden, z as combineSources, zn as connectorActionMetadata, zt as IdTooltip } from "./flowChanges-CcscgZsW.js";
1
+ import { $ as RunStore, $t as InputGroupInput, An as sampleErrorOutputs, At as setCodeActions, B as CacheResource, Bn as jsonValue, Bt as PopoverContent, Cn as WorkbenchClient, Ct as restoreCanvasPresentation, Dn as decodeTriggerCatalog, Dt as setNodePositions, Et as setNodeContentHidden, F as feishuResourceKind, Fn as connection, Ft as updateTriggerSchedule, Gt as PopoverTrigger, H as resourceData, Hn as string, I as supportsFeishuChatFilter, In as connectorActionMetadata, It as IdTooltip, J as providerIcon, Kn as IconThemeContext, L as combineSources, Ln as inputValue, Lt as followWorkbenchLink, M as addNodeIntent, Mn as isJsonObject, Mt as setInputSources, N as deriveAddNodeOptions, Nt as setTriggerConnection, Ot as repairNodeNames, Pt as updateTriggerConfig, Qt as InputGroupAddon, Rn as providerIconAppearance, Rt as Switch, Sn as errorNotice, St as removeComments, Tn as allConnectorConnectionsQuery, Tt as setFlowViewport, U as resourceValue, Un as ApiError, Vn as record, W as designerGraph, Wn as controlErrorCode, Wt as PopoverTitle, Zt as InputGroup, _ as updateValue, _t as actionWithConnections, a as nameCreatedNodes, an as EmptyTitle, bt as commentIds, c as updateCondition, d as updateNodeName, dt as Latest, en as Empty, f as updateNodeSettings, ft as deriveInspectorDiagnostics, g as updateTaskPorts, h as updateTaskAdditionalInputs, i as deleteSelection, in as EmptyMedia, jn as triggerOutputDefinitions, jt as setConnectorConnection, kt as resetInputValues, l as updateNodeDescription, ln as createI18n, m as updateTask, nn as EmptyDescription, nt as revisionView, o as setInputValue, on as EventSourcesPage, p as updateResolution, pt as diagnosticItems, r as applyFlowChanges, rn as EmptyHeader, s as setInputVariable, t as addNode, tn as EmptyContent, u as updateNodeIcon, v as updateWebhook, vt as connectionCatalog, wn as randomId, wt as setComment, xt as flowPresentation, yt as canvasPresentationChange, z as scopedValue, zn as invalidResponse, zt as Popover } from "./flowChanges-BxutPLYO.js";
2
2
  import { a as derive, i as compute, l as val } from "./dist-bO8nvHFH.js";
3
- import { a as useVal, i as useTranslate, r as useLang, t as I18nProvider } from "./main-BPABKzwN.js";
4
- import { C as FieldError, D as applyFlowChanges$1, E as FlowChangeError, I as mapConditionSources, Ir as cn, K as dequal$1, L as nodeInputMappings, N as resourceNameIssue, Pr as Button, T as FieldLabel, a as DialogDescription, b as Spinner, c as DialogTitle, d as TooltipContent, i as DialogContent, jn as Input, n as Dialog, o as DialogFooter, p as TooltipTrigger, r as DialogClose, s as DialogHeader, t as Icon, u as Tooltip, w as FieldGroup, x as Field } from "./icons-0s-Q_3lp.js";
5
- import { a as toPlainObject } from "./dist-BDBTOgS5.js";
3
+ import { a as toPlainObject, c as useLang, l as useTranslate, o as I18nProvider, u as useVal } from "./dist-BFmpkX4P.js";
4
+ import { D as FlowChangeError, E as FieldLabel, L as mapConditionSources, O as applyFlowChanges$1, P as resourceNameIssue, R as nodeInputMappings, S as Field, T as FieldGroup, a as DialogDescription, c as DialogTitle, d as TooltipContent, gi as Button, i as DialogContent, ir as Input, it as dequal$1, n as Dialog, o as DialogFooter, p as TooltipTrigger, r as DialogClose, s as DialogHeader, t as Icon, u as Tooltip, vi as cn, w as FieldError, x as Spinner } from "./icons-p2A9zs8t.js";
6
5
  import { c as isUiLanguage, d as uiLanguages, l as resolveUiLanguage, u as uiLanguageNames } from "./value-DL_poNiC.js";
7
6
  import { Suspense, lazy, useEffect, useRef, useState } from "react";
8
7
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
@@ -107,17 +106,6 @@ var NavigationStore = class {
107
106
  if (change == this.#change) this.#syncing = false;
108
107
  }
109
108
  }
110
- async createSubflow(name) {
111
- const change = ++this.#change;
112
- this.#syncing = true;
113
- try {
114
- const created = await this.#store.workspace.createResource(name);
115
- if (created && change == this.#change) this.#write("design", false);
116
- return created;
117
- } finally {
118
- if (change == this.#change) this.#syncing = false;
119
- }
120
- }
121
109
  async selectFlow(flow) {
122
110
  const change = ++this.#change;
123
111
  this.#syncing = true;
@@ -129,7 +117,7 @@ var NavigationStore = class {
129
117
  }
130
118
  }
131
119
  openMainFlow() {
132
- if (this.#store.workspace.selectTarget({ kind: "flow" })) this.#write("design", false);
120
+ this.#write("design", false);
133
121
  }
134
122
  async openFlows() {
135
123
  const change = ++this.#change;
@@ -196,7 +184,7 @@ function Skeleton({ className, ...props }) {
196
184
  }
197
185
  //#endregion
198
186
  //#region src/workbench/browser/runtime/shell/resourceBrowser.tsx
199
- var CreateResourceDialog = lazy(() => import("./createResourceDialog-BsaBMf7_.js"));
187
+ var CreateResourceDialog = lazy(() => import("./createResourceDialog-Btjes3wD.js"));
200
188
  var flowIdTooltipAlignOffset = 44;
201
189
  var renamePopoverAlignOffset = -12;
202
190
  var renamePopoverVerticalShift = 8;
@@ -874,25 +862,20 @@ var customRandom = (alphabet, defaultSize, getRandom) => {
874
862
  var customAlphabet = (alphabet, size = 21) => customRandom(alphabet, size | 0, random);
875
863
  //#endregion
876
864
  //#region src/flow/common/edgeChanges.ts
877
- function connect(content, target, edge) {
878
- if (graph(content, target)?.edges.some((candidate) => dequal$1(candidate, edge))) return [];
865
+ function connect(content, edge) {
866
+ if (content.document.graph?.edges.some((candidate) => dequal$1(candidate, edge))) return [];
879
867
  return [{
880
868
  edge,
881
- kind: "graph.edge.connect",
882
- target
869
+ kind: "graph.edge.connect"
883
870
  }];
884
871
  }
885
- function disconnect(content, target, edge) {
886
- if (!graph(content, target)?.edges.some((candidate) => dequal$1(candidate, edge))) return [];
872
+ function disconnect(content, edge) {
873
+ if (!content.document.graph?.edges.some((candidate) => dequal$1(candidate, edge))) return [];
887
874
  return [{
888
875
  edge,
889
- kind: "graph.edge.disconnect",
890
- target
876
+ kind: "graph.edge.disconnect"
891
877
  }];
892
878
  }
893
- function graph(content, target) {
894
- return target.kind == "flow" ? content.document.graph : content.document.subflows[target.id]?.graph;
895
- }
896
879
  //#endregion
897
880
  //#region src/flow/common/moduleChanges.ts
898
881
  async function imports(source) {
@@ -926,11 +909,11 @@ function replaceSource(moduleId, beforeSource, beforeImports, source, moduleImpo
926
909
  var createAuthoringId = customAlphabet("23456789abcdefghjkmnpqrstuvwxyz", 10);
927
910
  //#endregion
928
911
  //#region src/workbench/browser/runtime/editor/triggerDiagnosticPresentation.ts
929
- function presentTriggerDiagnostics(items, revision, target, displays, language, t) {
930
- if (revision == null || target == null) return items;
912
+ function presentTriggerDiagnostics(items, revision, displays, language, t) {
913
+ if (revision == null) return items;
931
914
  return items.map((item) => {
932
915
  if (item.diagnostic.code != "trigger.config-incomplete" || item.location == null) return item;
933
- const node = revision.node(target, item.location.nodeId)?.node;
916
+ const node = revision.node(item.location.nodeId)?.node;
934
917
  if (node?.kind != "integration" && node?.kind != "poll") return item;
935
918
  const labels = displays?.[node.definition.key]?.configInputLabels;
936
919
  const names = item.diagnostic.fields?.map((field) => labels?.[field]);
@@ -1072,7 +1055,7 @@ var PublicationStore = class {
1072
1055
  }
1073
1056
  });
1074
1057
  if (!warm && operation?.status == "pending") {
1075
- const flow = this.#workspace.$.targetFlow.value;
1058
+ const flow = this.#workspace.$.flow.value;
1076
1059
  this.#observe(target, operation, this.#operation.begin(), flow?.flowId == target.flowId ? flow.name : target.flowId);
1077
1060
  }
1078
1061
  } catch (error) {
@@ -1118,7 +1101,7 @@ var PublicationStore = class {
1118
1101
  async publish() {
1119
1102
  const flowId = this.#workspace.$.flowId.value;
1120
1103
  if (!await this.#workspace.saveModuleEditor() || flowId != this.#workspace.$.flowId.value) return false;
1121
- const flow = this.#workspace.$.targetFlow.value;
1104
+ const flow = this.#workspace.$.flow.value;
1122
1105
  const draft = this.#workspace.$.draft.value;
1123
1106
  if (flow == null || draft == null || this.#state.value.changingTriggerId != null || this.#state.value.publishing || this.#state.value.rollingBackPublicationId != null) return false;
1124
1107
  const target = { flowId: flow.flowId };
@@ -1483,7 +1466,7 @@ var PublicationStore = class {
1483
1466
  //#region src/workbench/browser/runtime/runs/runRequestStore.ts
1484
1467
  var initialState$5 = { starting: false };
1485
1468
  function inputSpec(draft, triggerId) {
1486
- const trigger = revisionView(draft).graph({ kind: "flow" })?.nodes[triggerId];
1469
+ const trigger = revisionView(draft).graph()?.nodes[triggerId];
1487
1470
  if (trigger == null || "inputs" in trigger || trigger.kind == "manual" || trigger.kind == "cron") return void 0;
1488
1471
  const definitions = triggerOutputDefinitions(trigger);
1489
1472
  return definitions.length === 0 ? void 0 : {
@@ -1507,7 +1490,7 @@ async function inputEditor(spec, language, values) {
1507
1490
  return editor;
1508
1491
  }
1509
1492
  function testOutputs(revision, triggerId) {
1510
- const node = revisionView(revision).graph({ kind: "flow" })?.nodes[triggerId];
1493
+ const node = revisionView(revision).graph()?.nodes[triggerId];
1511
1494
  if (node?.kind == "error") return sampleErrorOutputs;
1512
1495
  return node?.kind === "cron" ? { scheduledAt: (/* @__PURE__ */ new Date()).toISOString() } : {};
1513
1496
  }
@@ -1659,7 +1642,7 @@ var RunRequestStore = class {
1659
1642
  submitting: void 0
1660
1643
  });
1661
1644
  this.#disposeInputRequest(previous);
1662
- const graph = revisionView(revision).graph({ kind: "flow" });
1645
+ const graph = revisionView(revision).graph();
1663
1646
  const triggers = Object.entries(graph?.nodes ?? {}).flatMap(([nodeId, node]) => "inputs" in node ? [] : [{
1664
1647
  nodeId,
1665
1648
  title: node.name
@@ -3410,36 +3393,31 @@ function providerOption(provider, t) {
3410
3393
  serviceId: provider.serviceId
3411
3394
  };
3412
3395
  }
3413
- function connectorTarget(selection, revision) {
3396
+ function connectorTarget(selection) {
3414
3397
  if (selection == null) return;
3415
- const taskId = selection.kind == "task" && selection.node.task == null ? selection.node.taskId : void 0;
3416
- if (taskId == null) return;
3417
- const task = selection.kind == "task" ? selection.definition : revision?.task(taskId);
3398
+ const task = selection.kind == "task" ? selection.definition : void 0;
3418
3399
  if (task == null || !("executor" in task) || task.executor.kind != "connector") return;
3419
3400
  return {
3420
3401
  actionId: task.executor.action,
3421
3402
  connectionId: task.executor.connectionId,
3422
- nodeId: selection.id,
3423
- taskId
3403
+ nodeId: selection.id
3424
3404
  };
3425
3405
  }
3426
3406
  function connectionDiagnostics(revision, actions, catalogs) {
3427
3407
  if (revision == null) return [];
3428
3408
  const diagnostics = [];
3429
- for (const taskId of [...flowDependencies(revision.revision.content).tasks].toSorted()) {
3430
- const task = revision.task(taskId);
3431
- if (task?.executor.kind != "connector") continue;
3432
- const action = actions[task.executor.action];
3409
+ for (const { nodeId, actionId, connectionId } of revision.connectorNodes()) {
3410
+ const action = actions[actionId];
3433
3411
  if (action?.authenticated != true) continue;
3434
- const connection = task.executor.connectionId == null ? void 0 : catalogs[action.serviceId]?.byId.get(task.executor.connectionId);
3435
- if (task.executor.connectionId != null && (catalogs[action.serviceId] == null || connection?.status == "active")) continue;
3412
+ const connection = connectionId == null ? void 0 : catalogs[action.serviceId]?.byId.get(connectionId);
3413
+ if (connectionId != null && (catalogs[action.serviceId] == null || connection?.status == "active")) continue;
3436
3414
  diagnostics.push({
3437
3415
  code: "task.connector-connection-required",
3438
3416
  column: 0,
3439
3417
  line: 1,
3440
- message: `Connector Task "${taskId}" requires an active Connection.`,
3441
- path: `/document/tasks/${taskId}/executor/connectionId`,
3442
- values: { taskId }
3418
+ message: `Connector Task "${nodeId}" requires an active Connection.`,
3419
+ path: `/document/graph/nodes/${nodeId}/task/executor/connectionId`,
3420
+ values: { nodeId }
3443
3421
  });
3444
3422
  }
3445
3423
  return diagnostics;
@@ -3551,7 +3529,7 @@ var ConnectorStore = class {
3551
3529
  }));
3552
3530
  });
3553
3531
  this.#selected = compute((get) => {
3554
- const target = connectorTarget(get(workspace.$.selection), get(workspace.$.revision));
3532
+ const target = connectorTarget(get(workspace.$.selection));
3555
3533
  const state = get(this.#state);
3556
3534
  if (target == null) return { authorizationPending: false };
3557
3535
  const action = get(actions)[target.actionId];
@@ -3649,7 +3627,7 @@ var ConnectorStore = class {
3649
3627
  if (this.#disposed) return;
3650
3628
  const current = this.#refresh.begin();
3651
3629
  const flowId = this.#workspace.$.flowId.value;
3652
- const target = connectorTarget(this.#workspace.$.selection.value, this.#workspace.$.revision.value);
3630
+ const target = connectorTarget(this.#workspace.$.selection.value);
3653
3631
  if (flowId == null || target == null) {
3654
3632
  if (this.#state.value.actionLoading != null || this.#state.value.connectionLoading != null) this.#set({
3655
3633
  actionLoading: void 0,
@@ -3719,8 +3697,8 @@ var ConnectorStore = class {
3719
3697
  if (!this.#disposed) this.#setNotice(errorNotice(error, this.#i18n.t));
3720
3698
  }
3721
3699
  }
3722
- async setConnection(taskId, connectionId) {
3723
- return await this.#workspace.setConnectorConnection(taskId, connectionId);
3700
+ async setConnection(nodeId, connectionId) {
3701
+ return await this.#workspace.setConnectorConnection(nodeId, connectionId);
3724
3702
  }
3725
3703
  async refreshAfterAuthorization() {
3726
3704
  if (this.#disposed || this.#authorization == null) return;
@@ -3762,8 +3740,9 @@ var ConnectorStore = class {
3762
3740
  const authorization = this.#authorization?.serviceId == serviceId ? this.#authorization : void 0;
3763
3741
  const created = authorization == null ? [] : catalog.active.filter((connection) => !authorization.connectionIds.has(connection.connectionId));
3764
3742
  const connection = created.length == 1 ? created[0] : catalog.preferred;
3765
- const task = this.#workspace.$.revision.value?.task(target.taskId);
3766
- if (connection != null && this.#workspace.$.selectedNodeIds.value.includes(target.nodeId) && task != null && "executor" in task && task.executor.kind == "connector" && task.executor.connectionId == null) await this.#workspace.setConnectorConnection(target.taskId, connection.connectionId);
3743
+ const selected = this.#workspace.$.revision.value?.node(target.nodeId);
3744
+ const task = selected?.kind == "task" ? selected.definition : void 0;
3745
+ if (connection != null && this.#workspace.$.selectedNodeIds.value.includes(target.nodeId) && task != null && "executor" in task && task.executor.kind == "connector" && task.executor.connectionId == null) await this.#workspace.setConnectorConnection(target.nodeId, connection.connectionId);
3767
3746
  }
3768
3747
  #remember(source, ids) {
3769
3748
  if (ids.some((id) => !source.value.includes(id))) source.set([.../* @__PURE__ */ new Set([...source.value, ...ids])]);
@@ -3784,7 +3763,7 @@ var ConnectorStore = class {
3784
3763
  const flowId = this.#workspace.$.flowId.value;
3785
3764
  const revision = this.#workspace.$.revision.value;
3786
3765
  if (flowId == null || revision == null) return;
3787
- if (Object.values(revision.graph({ kind: "flow" })?.nodes ?? {}).some((node) => node.kind == "integration" || node.kind == "poll")) this.data.providers.get(flowId, this.#language);
3766
+ if (Object.values(revision.graph()?.nodes ?? {}).some((node) => node.kind == "integration" || node.kind == "poll")) this.data.providers.get(flowId, this.#language);
3788
3767
  const missing = [...revision.connectorActionIds].filter((actionId) => this.$.actions.value[actionId] == null && !this.#loadingActions.has(actionId));
3789
3768
  if (missing.length > 0) {
3790
3769
  for (const actionId of missing) this.#loadingActions.add(actionId);
@@ -3800,10 +3779,8 @@ var ConnectorStore = class {
3800
3779
  }
3801
3780
  if (!this.#isCurrent(current, flowId)) return;
3802
3781
  const services = /* @__PURE__ */ new Set();
3803
- for (const taskId of flowDependencies(revision.revision.content).tasks) {
3804
- const task = revision.task(taskId);
3805
- if (task?.executor.kind != "connector") continue;
3806
- const action = this.$.actions.value[task.executor.action];
3782
+ for (const { actionId } of revision.connectorNodes()) {
3783
+ const action = this.$.actions.value[actionId];
3807
3784
  if (action?.authenticated == true) services.add(action.serviceId);
3808
3785
  }
3809
3786
  await Promise.all([...services].map((serviceId) => this.#loadCatalog(flowId, serviceId, false, current)));
@@ -3975,7 +3952,7 @@ var TriggerStore = class {
3975
3952
  return scopedValue(signal, (get) => {
3976
3953
  const state = get(source);
3977
3954
  get(this.#i18n.t$);
3978
- const enabled = get(this.#workspace.$.flowId) != null && get(this.#workspace.$.target)?.kind == "flow";
3955
+ const enabled = get(this.#workspace.$.flowId) != null && get(this.#workspace.$.draft) != null;
3979
3956
  const catalog = state.data;
3980
3957
  const definitions = catalog?.definitions.filter((item) => !query || [
3981
3958
  catalog.display[item.key]?.displayName,
@@ -4071,18 +4048,16 @@ function inverseFlowChanges(content, operations) {
4071
4048
  case "graph.node.create":
4072
4049
  restore.push({
4073
4050
  kind: "graph.node.delete",
4074
- nodeId: operation.nodeId,
4075
- target: operation.target
4051
+ nodeId: operation.nodeId
4076
4052
  });
4077
4053
  break;
4078
4054
  case "graph.node.delete": {
4079
- const { target, nodeId } = operation;
4080
- const graph = target.kind == "flow" ? current.document.graph : current.document.subflows[target.id].graph;
4081
- const nextGraph = target.kind == "flow" ? after.document.graph : after.document.subflows[target.id].graph;
4055
+ const { nodeId } = operation;
4056
+ const graph = current.document.graph;
4057
+ const nextGraph = after.document.graph;
4082
4058
  restore.push({
4083
4059
  kind: "graph.node.create",
4084
4060
  nodeId,
4085
- target,
4086
4061
  node: graph.nodes[nodeId]
4087
4062
  });
4088
4063
  for (const [id, node] of Object.entries(nextGraph.nodes)) {
@@ -4090,7 +4065,6 @@ function inverseFlowChanges(content, operations) {
4090
4065
  if (!("inputs" in node) || !("inputs" in previous)) continue;
4091
4066
  for (const handle of /* @__PURE__ */ new Set([...Object.keys(previous.inputs), ...Object.keys(node.inputs)])) if (!dequal$1(node.inputs[handle], previous.inputs[handle])) restore.push({
4092
4067
  kind: "graph.node.input.set",
4093
- target,
4094
4068
  nodeId: id,
4095
4069
  handle,
4096
4070
  before: node.inputs[handle],
@@ -4099,24 +4073,12 @@ function inverseFlowChanges(content, operations) {
4099
4073
  }
4100
4074
  for (const edge of nextGraph.edges) restore.push({
4101
4075
  kind: "graph.edge.disconnect",
4102
- target,
4103
4076
  edge
4104
4077
  });
4105
4078
  for (const edge of graph.edges) restore.push({
4106
4079
  kind: "graph.edge.connect",
4107
- target,
4108
4080
  edge
4109
4081
  });
4110
- if (target.kind == "subflow") {
4111
- const { graph: _beforeGraph, ...definition } = current.document.subflows[target.id];
4112
- const { graph: _afterGraph, ...before } = after.document.subflows[target.id];
4113
- if (!dequal$1(before, definition)) restore.push({
4114
- kind: "subflow.definition.set",
4115
- subflowId: target.id,
4116
- before,
4117
- definition
4118
- });
4119
- }
4120
4082
  break;
4121
4083
  }
4122
4084
  case "graph.edge.connect":
@@ -4126,17 +4088,14 @@ function inverseFlowChanges(content, operations) {
4126
4088
  });
4127
4089
  break;
4128
4090
  case "graph.edge.disconnect": {
4129
- const { target } = operation;
4130
- const graph = target.kind == "flow" ? current.document.graph : current.document.subflows[target.id].graph;
4131
- const next = target.kind == "flow" ? after.document.graph : after.document.subflows[target.id].graph;
4091
+ const graph = current.document.graph;
4092
+ const next = after.document.graph;
4132
4093
  restore.push(...next.edges.map((edge) => ({
4133
4094
  kind: "graph.edge.disconnect",
4134
- target,
4135
4095
  edge
4136
4096
  })));
4137
4097
  restore.push(...graph.edges.map((edge) => ({
4138
4098
  kind: "graph.edge.connect",
4139
- target,
4140
4099
  edge
4141
4100
  })));
4142
4101
  break;
@@ -4167,27 +4126,13 @@ function inverseFlowChanges(content, operations) {
4167
4126
  binding: current.document.bindings[operation.bindingId]
4168
4127
  });
4169
4128
  break;
4170
- case "task.create":
4171
- restore.push({
4172
- kind: "task.delete",
4173
- taskId: operation.taskId
4174
- });
4175
- break;
4176
- case "task.delete":
4177
- restore.push({
4178
- kind: "task.create",
4179
- taskId: operation.taskId,
4180
- task: current.document.tasks[operation.taskId]
4181
- });
4182
- break;
4183
4129
  case "graph.node.input.set": {
4184
- const beforeGraph = operation.target.kind === "flow" ? current.document.graph : current.document.subflows[operation.target.id].graph;
4185
- const afterGraph = operation.target.kind === "flow" ? after.document.graph : after.document.subflows[operation.target.id].graph;
4130
+ const beforeGraph = current.document.graph;
4131
+ const afterGraph = after.document.graph;
4186
4132
  const beforeNode = beforeGraph.nodes[operation.nodeId];
4187
4133
  const afterNode = afterGraph.nodes[operation.nodeId];
4188
4134
  if (beforeNode.kind === "condition" && afterNode.kind === "condition") restore.push({
4189
4135
  kind: "graph.node.condition.set",
4190
- target: operation.target,
4191
4136
  nodeId: operation.nodeId,
4192
4137
  before: {
4193
4138
  cases: afterNode.cases,
@@ -4296,42 +4241,13 @@ function inverseFlowChanges(content, operations) {
4296
4241
  value: operation.before
4297
4242
  });
4298
4243
  break;
4299
- case "task.connector.connection.set":
4300
- restore.push({
4301
- ...operation,
4302
- before: operation.value,
4303
- value: operation.before
4304
- });
4305
- break;
4306
- case "task.openapi.set":
4307
- case "task.agent.set":
4308
- restore.push({
4309
- ...operation,
4310
- before: operation.value,
4311
- value: operation.before
4312
- });
4313
- break;
4314
- case "task.llm.mode.set":
4244
+ case "graph.node.task.set":
4315
4245
  restore.push({
4316
4246
  ...operation,
4317
4247
  before: operation.value,
4318
4248
  value: operation.before
4319
4249
  });
4320
4250
  break;
4321
- case "task.name.set":
4322
- restore.push({
4323
- ...operation,
4324
- before: operation.value,
4325
- value: operation.before
4326
- });
4327
- break;
4328
- case "subflow.definition.set":
4329
- restore.push({
4330
- ...operation,
4331
- before: operation.definition,
4332
- definition: operation.before
4333
- });
4334
- break;
4335
4251
  default: throw new Error(`Unsupported canvas history operation: ${operation.kind}`);
4336
4252
  }
4337
4253
  groups.push(restore);
@@ -4341,11 +4257,11 @@ function inverseFlowChanges(content, operations) {
4341
4257
  }
4342
4258
  //#endregion
4343
4259
  //#region src/workbench/browser/runtime/editor/nodeClipboard.ts
4344
- function copyNodes(revision, target, nodeIds) {
4345
- const nodes = revision.graph(target)?.nodes ?? {};
4260
+ function copyNodes(revision, nodeIds) {
4261
+ const nodes = revision.graph()?.nodes ?? {};
4346
4262
  const copied = Object.fromEntries(nodeIds.flatMap((nodeId) => nodes[nodeId] == null ? [] : [[nodeId, nodes[nodeId]]]));
4347
4263
  return {
4348
- edges: (revision.graph(target)?.edges ?? []).filter((edge) => copied[edge.source] != null && copied[edge.target] != null),
4264
+ edges: (revision.graph()?.edges ?? []).filter((edge) => copied[edge.source] != null && copied[edge.target] != null),
4349
4265
  bindings: Object.fromEntries(Object.values(copied).flatMap((node) => {
4350
4266
  if (!("inputs" in node)) return [];
4351
4267
  return Object.values(nodeInputMappings(node)).flatMap((mapping) => mapping.kind == "sources" ? mapping.sources.flatMap((source) => {
@@ -4355,22 +4271,17 @@ function copyNodes(revision, target, nodeIds) {
4355
4271
  }) : []);
4356
4272
  })),
4357
4273
  modules: Object.fromEntries(Object.values(copied).flatMap((node) => {
4358
- if (node.kind != "task" || node.task == null) return [];
4274
+ if (node.kind != "task" || !("moduleId" in node.task)) return [];
4359
4275
  const module = revision.revision.content.modules[node.task.moduleId];
4360
4276
  return module == null ? [] : [[node.task.moduleId, module]];
4361
4277
  })),
4362
4278
  nodes: copied
4363
4279
  };
4364
4280
  }
4365
- function pasteNodes(revision, target, clipboard, identity) {
4366
- if (revision.graph(target) == null) return {
4367
- changes: [],
4368
- nodeIds: [],
4369
- sourceIds: []
4370
- };
4371
- const hasErrorTrigger = Object.values(revision.graph(target)?.nodes ?? {}).some((node) => node.kind === "error");
4372
- const hasManualTrigger = Object.values(revision.graph(target)?.nodes ?? {}).some((node) => node.kind === "manual");
4373
- const entries = Object.entries(clipboard.nodes).filter(([, node]) => (target.kind == "flow" || "inputs" in node) && (node.kind !== "manual" || !hasManualTrigger) && (node.kind !== "error" || !hasErrorTrigger) && (node.kind != "task" || node.task == null || clipboard.modules[node.task.moduleId] != null));
4281
+ function pasteNodes(revision, clipboard, identity) {
4282
+ const hasErrorTrigger = Object.values(revision.graph()?.nodes ?? {}).some((node) => node.kind === "error");
4283
+ const hasManualTrigger = Object.values(revision.graph()?.nodes ?? {}).some((node) => node.kind === "manual");
4284
+ const entries = Object.entries(clipboard.nodes).filter(([, node]) => (node.kind !== "manual" || !hasManualTrigger) && (node.kind !== "error" || !hasErrorTrigger) && (node.kind != "task" || !("moduleId" in node.task) || clipboard.modules[node.task.moduleId] != null));
4374
4285
  const sourceIds = entries.map(([sourceId]) => sourceId);
4375
4286
  const ids = new Map(sourceIds.map((sourceId) => [sourceId, identity()]));
4376
4287
  const operations = [];
@@ -4400,8 +4311,7 @@ function pasteNodes(revision, target, clipboard, identity) {
4400
4311
  operations.push({
4401
4312
  kind: "graph.node.create",
4402
4313
  node,
4403
- nodeId,
4404
- target
4314
+ nodeId
4405
4315
  });
4406
4316
  continue;
4407
4317
  }
@@ -4451,7 +4361,7 @@ function pasteNodes(revision, target, clipboard, identity) {
4451
4361
  ...source,
4452
4362
  bindingId: bindingIds.get(source.bindingId) ?? source.bindingId
4453
4363
  } : source);
4454
- if (node.kind == "task" && node.task != null) {
4364
+ if (node.kind == "task" && "moduleId" in node.task) {
4455
4365
  const moduleId = nodeId;
4456
4366
  const module = clipboard.modules[node.task.moduleId];
4457
4367
  operations.push({
@@ -4476,8 +4386,7 @@ function pasteNodes(revision, target, clipboard, identity) {
4476
4386
  operations.push({
4477
4387
  kind: "graph.node.create",
4478
4388
  node: copy,
4479
- nodeId,
4480
- target
4389
+ nodeId
4481
4390
  });
4482
4391
  }
4483
4392
  for (const edge of clipboard.edges) {
@@ -4485,7 +4394,6 @@ function pasteNodes(revision, target, clipboard, identity) {
4485
4394
  const destination = ids.get(edge.target);
4486
4395
  if (source != null && destination != null) operations.push({
4487
4396
  kind: "graph.edge.connect",
4488
- target,
4489
4397
  edge: {
4490
4398
  ...edge,
4491
4399
  source,
@@ -4494,7 +4402,7 @@ function pasteNodes(revision, target, clipboard, identity) {
4494
4402
  });
4495
4403
  }
4496
4404
  return {
4497
- changes: nameCreatedNodes(revision, target, operations),
4405
+ changes: nameCreatedNodes(revision, operations),
4498
4406
  nodeIds: [...ids.values()],
4499
4407
  sourceIds
4500
4408
  };
@@ -4596,26 +4504,22 @@ function mergeChanges(before, after) {
4596
4504
  const first = before[0];
4597
4505
  const last = after[0];
4598
4506
  if (first?.kind == "graph.node.field.set" && last?.kind == "graph.node.field.set") {
4599
- if (first.nodeId != last.nodeId || first.field != last.field || first.target.kind != last.target.kind) return;
4600
- if (first.target.kind == "subflow" && (last.target.kind != "subflow" || first.target.id != last.target.id)) return;
4507
+ if (first.nodeId != last.nodeId || first.field != last.field) return;
4601
4508
  return [{
4602
4509
  before: first.before,
4603
4510
  field: last.field,
4604
4511
  kind: last.kind,
4605
4512
  nodeId: last.nodeId,
4606
- target: last.target,
4607
4513
  value: last.value
4608
4514
  }];
4609
4515
  }
4610
4516
  if (first?.kind == "graph.node.input.set" && last?.kind == "graph.node.input.set") {
4611
- if (first.nodeId != last.nodeId || first.handle != last.handle || first.target.kind != last.target.kind) return;
4612
- if (first.target.kind == "subflow" && (last.target.kind != "subflow" || first.target.id != last.target.id)) return;
4517
+ if (first.nodeId != last.nodeId || first.handle != last.handle) return;
4613
4518
  return [{
4614
4519
  before: first.before,
4615
4520
  handle: last.handle,
4616
4521
  kind: last.kind,
4617
4522
  nodeId: last.nodeId,
4618
- target: last.target,
4619
4523
  value: last.value
4620
4524
  }];
4621
4525
  }
@@ -5220,9 +5124,9 @@ function moduleEditorStatus(draft, editor) {
5220
5124
  if (module == null) return "failed";
5221
5125
  return editor.source == module.source ? "saved" : "dirty";
5222
5126
  }
5223
- function selectedModuleEditor(revision, target, nodeIds) {
5224
- if (revision == null || target == null || nodeIds.length != 1) return;
5225
- const node = revision.node(target, nodeIds[0]);
5127
+ function selectedModuleEditor(revision, nodeIds) {
5128
+ if (revision == null || nodeIds.length != 1) return;
5129
+ const node = revision.node(nodeIds[0]);
5226
5130
  if (node?.kind != "task" || node.definition == null || !("moduleId" in node.definition) || node.module == null) return;
5227
5131
  return {
5228
5132
  moduleId: node.definition.moduleId,
@@ -5230,7 +5134,6 @@ function selectedModuleEditor(revision, target, nodeIds) {
5230
5134
  };
5231
5135
  }
5232
5136
  var WorkspaceModel = class {
5233
- #revisionContext;
5234
5137
  #state = val(initialState);
5235
5138
  #catalogValues;
5236
5139
  constructor(i18n, flows) {
@@ -5253,28 +5156,23 @@ var WorkspaceModel = class {
5253
5156
  const live = derive(this.#state, (state) => state.live);
5254
5157
  const revision = derive(this.#state, (state) => state.draft == null ? void 0 : revisionView(state.draft));
5255
5158
  const selectedNodeIds = derive(this.#state, (state) => state.selectedNodeIds);
5256
- const target = derive(this.#state, (state) => state.target);
5257
5159
  const workspaceLoadFailed = derive(this.#state, (state) => state.workspaceLoadFailed);
5258
5160
  const workspaceLoadProblem = derive(this.#state, (state) => state.workspaceLoadProblem);
5259
5161
  const workspaceLoading = derive(this.#state, (state) => state.workspaceLoading);
5260
5162
  const workspaceRepairing = derive(this.#state, (state) => state.workspaceRepairing);
5261
- this.#revisionContext = derive(this.#state, (state) => ({
5262
- revision: state.draft == null ? void 0 : revisionView(state.draft),
5263
- target: state.target
5264
- }), { equal: (next, previous) => next.revision === previous.revision && next.target === previous.target });
5265
5163
  const selection = derive(this.#state, (state) => {
5266
- if (state.draft == null || state.target == null || state.selectedNodeIds.length != 1) return;
5267
- return revisionView(state.draft).selection(state.target, state.selectedNodeIds[0]);
5164
+ if (state.draft == null || state.selectedNodeIds.length != 1) return;
5165
+ return revisionView(state.draft).selection(state.selectedNodeIds[0]);
5268
5166
  });
5269
5167
  this.$ = {
5270
5168
  addNodeOptions: compute((get) => {
5271
- const { revision: currentRevision, target: currentTarget } = get(this.#revisionContext);
5272
- return deriveAddNodeOptions(currentRevision?.revision, currentTarget, get(i18n.t$));
5169
+ const currentRevision = get(revision);
5170
+ return deriveAddNodeOptions(currentRevision?.revision, get(i18n.t$));
5273
5171
  }),
5274
5172
  busy,
5275
5173
  checkLoading,
5276
5174
  diagnosticFocus,
5277
- diagnosticItems: derive(this.#state, (state) => diagnosticItems(state.draft == null ? void 0 : revisionView(state.draft), state.target, state.diagnostics)),
5175
+ diagnosticItems: derive(this.#state, (state) => diagnosticItems(state.draft == null ? void 0 : revisionView(state.draft), state.diagnostics)),
5278
5176
  diagnostics,
5279
5177
  draft,
5280
5178
  flow: compute((get) => {
@@ -5290,7 +5188,7 @@ var WorkspaceModel = class {
5290
5188
  flowRefreshing: flows.$.refreshing,
5291
5189
  flowTotal: flows.$.total,
5292
5190
  flows: flows.$.flows,
5293
- inspectorDiagnostics: derive(this.#state, (state) => deriveInspectorDiagnostics(state.draft == null ? void 0 : revisionView(state.draft), state.target, state.diagnostics, selection.value)),
5191
+ inspectorDiagnostics: derive(this.#state, (state) => deriveInspectorDiagnostics(state.draft == null ? void 0 : revisionView(state.draft), state.diagnostics, selection.value)),
5294
5192
  live,
5295
5193
  moduleEditor,
5296
5194
  nodeFocus,
@@ -5299,14 +5197,6 @@ var WorkspaceModel = class {
5299
5197
  selection,
5300
5198
  selectedNodeIds,
5301
5199
  status: derive(this.#state, status),
5302
- target,
5303
- targetFlow: compute((get) => get(target)?.kind == "flow" ? get(flows.$.flows).find((flow) => flow.flowId == get(flowId)) : void 0),
5304
- targetName: derive(this.#state, (state) => {
5305
- if (state.target == null) return;
5306
- if (state.target.kind == "flow") return flows.flow(state.flowId ?? "")?.name;
5307
- if (state.draft == null) return state.target.id;
5308
- return revisionView(state.draft).subflow(state.target.id)?.name ?? state.target.id;
5309
- }),
5310
5200
  workspaceLoadFailed,
5311
5201
  workspaceLoadProblem,
5312
5202
  workspaceLoading,
@@ -5325,7 +5215,6 @@ var WorkspaceModel = class {
5325
5215
  }
5326
5216
  dispose() {
5327
5217
  for (const value of Object.values(this.$)) if (!this.#catalogValues.has(value)) value.dispose();
5328
- this.#revisionContext.dispose();
5329
5218
  this.#state.dispose();
5330
5219
  }
5331
5220
  };
@@ -5346,10 +5235,6 @@ var deletionMessageKeys = {
5346
5235
  conditionGroup: "history.deleted.conditionGroup",
5347
5236
  webhookBody: "history.deleted.webhookBody"
5348
5237
  };
5349
- function reconcileTarget(revision, target) {
5350
- if (target == null) return;
5351
- return target.kind == "flow" || revision.subflow(target.id) != null ? target : { kind: "flow" };
5352
- }
5353
5238
  var WorkspaceStore = class {
5354
5239
  #client;
5355
5240
  #draftChanges;
@@ -5403,7 +5288,7 @@ var WorkspaceStore = class {
5403
5288
  beforeChange: (manageBusy) => {
5404
5289
  if (manageBusy) this.#set({ busy: "designer" });
5405
5290
  },
5406
- check: () => void this.#checkTarget(),
5291
+ check: () => void this.#checkDraft(),
5407
5292
  current: (context) => this.#isDraftChangeCurrent(context),
5408
5293
  finishChanges: () => {
5409
5294
  if (!this.#disposed && this.#model.value.busy == "designer") this.#set({ busy: void 0 });
@@ -5491,7 +5376,6 @@ var WorkspaceStore = class {
5491
5376
  presentation: void 0,
5492
5377
  flowId,
5493
5378
  selectedNodeIds: [],
5494
- target: flowId == null ? void 0 : { kind: "flow" },
5495
5379
  workspaceLoadFailed: false,
5496
5380
  workspaceLoadProblem: void 0,
5497
5381
  workspaceLoading: flowId != null,
@@ -5527,7 +5411,6 @@ var WorkspaceStore = class {
5527
5411
  draft,
5528
5412
  live,
5529
5413
  presentation,
5530
- target: { kind: "flow" },
5531
5414
  workspaceLoadFailed: false,
5532
5415
  workspaceLoadProblem: void 0,
5533
5416
  workspaceLoading: false
@@ -5591,27 +5474,12 @@ var WorkspaceStore = class {
5591
5474
  if (current() && this.#model.value.flowId == flowId) this.#setNotice(errorNotice(error, this.#i18n.t));
5592
5475
  }
5593
5476
  }
5594
- selectTarget(target) {
5595
- if (this.#history.applying) return false;
5596
- if (!dequal$1(target, this.#model.value.target)) this.#history.clear();
5597
- this.#modules.flush();
5598
- this.#set({
5599
- diagnosticFocus: void 0,
5600
- diagnostics: void 0,
5601
- moduleEditor: void 0,
5602
- nodeFocus: void 0,
5603
- selectedNodeIds: [],
5604
- target
5605
- });
5606
- this.#checkTarget();
5607
- return true;
5608
- }
5609
5477
  selectNodes(nodeIds) {
5610
5478
  if (nodeIds.length == this.#model.value.selectedNodeIds.length && nodeIds.every((nodeId, index) => nodeId == this.#model.value.selectedNodeIds[index])) return true;
5611
5479
  this.#modules.flush();
5612
5480
  this.#set({
5613
5481
  diagnosticFocus: void 0,
5614
- moduleEditor: selectedModuleEditor(this.#model.value.draft == null ? void 0 : revisionView(this.#model.value.draft), this.#model.value.target, nodeIds),
5482
+ moduleEditor: selectedModuleEditor(this.#model.value.draft == null ? void 0 : revisionView(this.#model.value.draft), nodeIds),
5615
5483
  nodeFocus: void 0,
5616
5484
  selectedNodeIds: nodeIds
5617
5485
  });
@@ -5655,24 +5523,6 @@ var WorkspaceStore = class {
5655
5523
  this.#set({ busy: void 0 });
5656
5524
  }
5657
5525
  }
5658
- async createResource(name) {
5659
- if (!await this.saveModuleEditor()) return false;
5660
- if (this.#model.value.draft == null) return false;
5661
- const id = this.#identity();
5662
- this.#set({ busy: "resource" });
5663
- const changed = await this.#changeDraft(createResource(id, name), false);
5664
- this.#set({ busy: void 0 });
5665
- if (changed == null) return false;
5666
- this.selectTarget({
5667
- id,
5668
- kind: "subflow"
5669
- });
5670
- this.#setNotice({
5671
- kind: "success",
5672
- message: this.#i18n.t("notice.createdInDraft", { name })
5673
- });
5674
- return true;
5675
- }
5676
5526
  async renameFlow(flowId, name) {
5677
5527
  const flow = this.#flows.flow(flowId);
5678
5528
  const nextName = name.trim();
@@ -5697,12 +5547,11 @@ var WorkspaceStore = class {
5697
5547
  async addNode(option, position, connection) {
5698
5548
  if (!await this.saveModuleEditor()) return;
5699
5549
  const draft = this.#model.value.draft;
5700
- const target = this.#model.value.target;
5701
- if (draft == null || target == null) return;
5550
+ if (draft == null) return;
5702
5551
  const nodeId = this.#identity();
5703
- if (option.kind == "comment") return await this.#addComment(target, nodeId, position);
5552
+ if (option.kind == "comment") return await this.#addComment(nodeId, position);
5704
5553
  const revision = revisionView(draft);
5705
- let intent = addNodeIntent(option, revision, target, this.#i18n.t);
5554
+ let intent = addNodeIntent(option, revision, this.#i18n.t);
5706
5555
  if (intent == null) return;
5707
5556
  if (intent.kind == "provider-trigger" && intent.connectionId == null) {
5708
5557
  try {
@@ -5715,17 +5564,17 @@ var WorkspaceStore = class {
5715
5564
  } catch (error) {
5716
5565
  if (!this.#disposed && this.#model.value.draft == draft) this.#setNotice(errorNotice(error, this.#i18n.t));
5717
5566
  }
5718
- if (this.#disposed || this.#model.value.draft != draft || this.#model.value.target != target) return;
5567
+ if (this.#disposed || this.#model.value.draft != draft) return;
5719
5568
  }
5720
5569
  const edge = connection?.(nodeId);
5721
- const nodeChanges = addNode(revision, target, nodeId, intent, this.#identity);
5570
+ const nodeChanges = addNode(revision, nodeId, intent);
5722
5571
  if (nodeChanges == null) return;
5723
- const changes = edge == null ? nodeChanges : [...nodeChanges, ...connect(applyFlowChanges(draft, nodeChanges).content, target, {
5572
+ const changes = edge == null ? nodeChanges : [...nodeChanges, ...connect(applyFlowChanges(draft, nodeChanges).content, {
5724
5573
  source: edge.source,
5725
5574
  target: edge.target,
5726
5575
  ...edge.sourceHandle.startsWith("$branch:") ? { sourceHandle: edge.sourceHandle.slice(8) } : {}
5727
5576
  })];
5728
- if (!await this.#canvasChange("add", 1, changes, (value) => setNodePositions(value, target, { [nodeId]: position }), [nodeId])) return;
5577
+ if (!await this.#canvasChange("add", 1, changes, (value) => setNodePositions(value, { [nodeId]: position }), [nodeId])) return;
5729
5578
  if (this.#disposed) return;
5730
5579
  this.#set({ nodeFocus: {
5731
5580
  nodeId,
@@ -5735,9 +5584,8 @@ var WorkspaceStore = class {
5735
5584
  }
5736
5585
  async connect(edge) {
5737
5586
  const revision = this.$.revision.value;
5738
- const target = this.#model.value.target;
5739
- if (revision == null || target == null) return;
5740
- const changes = connect(revision.revision.content, target, {
5587
+ if (revision == null) return;
5588
+ const changes = connect(revision.revision.content, {
5741
5589
  source: edge.source,
5742
5590
  target: edge.target,
5743
5591
  ...edge.sourceHandle.startsWith("$branch:") ? { sourceHandle: edge.sourceHandle.slice(8) } : {}
@@ -5746,9 +5594,8 @@ var WorkspaceStore = class {
5746
5594
  }
5747
5595
  async disconnect(edge) {
5748
5596
  const revision = this.$.revision.value;
5749
- const target = this.#model.value.target;
5750
- if (revision == null || target == null) return;
5751
- const changes = disconnect(revision.revision.content, target, {
5597
+ if (revision == null) return;
5598
+ const changes = disconnect(revision.revision.content, {
5752
5599
  source: edge.source,
5753
5600
  target: edge.target,
5754
5601
  ...edge.sourceHandle.startsWith("$branch:") ? { sourceHandle: edge.sourceHandle.slice(8) } : {}
@@ -5758,22 +5605,20 @@ var WorkspaceStore = class {
5758
5605
  async deleteSelectedNodes() {
5759
5606
  if (!await this.saveModuleEditor()) return;
5760
5607
  const revision = this.$.revision.value;
5761
- const target = this.#model.value.target;
5762
- if (revision == null || target == null || this.#model.value.selectedNodeIds.length == 0) return;
5608
+ if (revision == null || this.#model.value.selectedNodeIds.length == 0) return;
5763
5609
  const selectedNodeIds = [...this.#model.value.selectedNodeIds];
5764
- const comments = commentIds(this.#model.value.presentation?.value ?? {}, target);
5610
+ const comments = commentIds(this.#model.value.presentation?.value ?? {});
5765
5611
  const commentNodes = new Set(this.#model.value.selectedNodeIds.filter((nodeId) => comments.has(nodeId)));
5766
- const changes = deleteSelection(revision, target, this.#model.value.selectedNodeIds);
5612
+ const changes = deleteSelection(revision, this.#model.value.selectedNodeIds);
5767
5613
  await this.#canvasChange("delete", this.#model.value.selectedNodeIds.length, changes, (value) => {
5768
- let next = commentNodes.size == 0 ? value : removeComments(value, target, commentNodes);
5769
- for (const nodeId of selectedNodeIds) next = setNodeContentHidden(next, target, nodeId, false);
5614
+ let next = commentNodes.size == 0 ? value : removeComments(value, commentNodes);
5615
+ for (const nodeId of selectedNodeIds) next = setNodeContentHidden(next, nodeId, false);
5770
5616
  return next;
5771
5617
  }, []);
5772
5618
  }
5773
5619
  copySelectedNodes() {
5774
5620
  const revision = this.$.revision.value;
5775
- const target = this.#model.value.target;
5776
- if (revision == null || target == null || this.#model.value.selectedNodeIds.length == 0) return;
5621
+ if (revision == null || this.#model.value.selectedNodeIds.length == 0) return;
5777
5622
  const selected = new Set(this.#model.value.selectedNodeIds);
5778
5623
  this.#clipboard = {
5779
5624
  hiddenNodeIds: this.#designer().nodes.flatMap((node) => node.contentHidden && selected.has(node.id) ? [node.id] : []),
@@ -5783,16 +5628,15 @@ var WorkspaceStore = class {
5783
5628
  sourceId: node.id,
5784
5629
  title: node.title
5785
5630
  }] : []),
5786
- nodes: copyNodes(revision, target, this.#model.value.selectedNodeIds)
5631
+ nodes: copyNodes(revision, this.#model.value.selectedNodeIds)
5787
5632
  };
5788
5633
  }
5789
5634
  async pasteNodes(sourcePositions, offset = PASTE_OFFSET) {
5790
5635
  if (!await this.saveModuleEditor()) return;
5791
5636
  const revision = this.$.revision.value;
5792
- const target = this.#model.value.target;
5793
- if (revision == null || target == null || this.#clipboard == null) return;
5637
+ if (revision == null || this.#clipboard == null) return;
5794
5638
  const hiddenNodeIds = new Set(this.#clipboard.hiddenNodeIds);
5795
- const pasted = pasteNodes(revision, target, this.#clipboard.nodes, this.#identity);
5639
+ const pasted = pasteNodes(revision, this.#clipboard.nodes, this.#identity);
5796
5640
  const comments = this.#clipboard.comments.map((comment) => ({
5797
5641
  ...comment,
5798
5642
  nodeId: this.#identity()
@@ -5815,11 +5659,11 @@ var WorkspaceStore = class {
5815
5659
  }];
5816
5660
  }));
5817
5661
  await this.#canvasChange("paste", added.size, pasted.changes, (value) => {
5818
- let next = setNodePositions(value, target, positions);
5819
- for (const [index, sourceId] of pasted.sourceIds.entries()) if (hiddenNodeIds.has(sourceId)) next = setNodeContentHidden(next, target, pasted.nodeIds[index], true);
5662
+ let next = setNodePositions(value, positions);
5663
+ for (const [index, sourceId] of pasted.sourceIds.entries()) if (hiddenNodeIds.has(sourceId)) next = setNodeContentHidden(next, pasted.nodeIds[index], true);
5820
5664
  for (const comment of comments) {
5821
- if (hiddenNodeIds.has(comment.sourceId)) next = setNodeContentHidden(next, target, comment.nodeId, true);
5822
- next = setComment(next, target, comment.nodeId, {
5665
+ if (hiddenNodeIds.has(comment.sourceId)) next = setNodeContentHidden(next, comment.nodeId, true);
5666
+ next = setComment(next, comment.nodeId, {
5823
5667
  content: comment.content,
5824
5668
  position: {
5825
5669
  x: comment.position.x + offset.x * step,
@@ -5836,7 +5680,7 @@ var WorkspaceStore = class {
5836
5680
  await this.pasteNodes(positions, offset);
5837
5681
  }
5838
5682
  async saveErrorSources(nodeId, value) {
5839
- const node = this.$.revision.value?.graph({ kind: "flow" })?.nodes[nodeId];
5683
+ const node = this.$.revision.value?.graph()?.nodes[nodeId];
5840
5684
  if (node?.kind != "error" || dequal$1(node.sourceFlowIds ?? [], value)) return false;
5841
5685
  return await this.#editDraft([{
5842
5686
  kind: "graph.trigger.sources.set",
@@ -5847,50 +5691,43 @@ var WorkspaceStore = class {
5847
5691
  }
5848
5692
  async saveNodeSettings(nodeId, settings) {
5849
5693
  const revision = this.$.revision.value;
5850
- const target = this.#model.value.target;
5851
- if (revision == null || target == null) return false;
5852
- const changes = updateNodeSettings(revision, target, nodeId, settings);
5694
+ if (revision == null) return false;
5695
+ const changes = updateNodeSettings(revision, nodeId, settings);
5853
5696
  return changes != null && await this.#editDraft(changes) != null;
5854
5697
  }
5855
5698
  async saveNodeDescription(nodeId, description) {
5856
5699
  const revision = this.$.revision.value;
5857
- const target = this.#model.value.target;
5858
- if (revision == null || target == null) return false;
5859
- const changes = updateNodeDescription(revision, target, nodeId, description);
5700
+ if (revision == null) return false;
5701
+ const changes = updateNodeDescription(revision, nodeId, description);
5860
5702
  return changes != null && await this.#editDraft(changes) != null;
5861
5703
  }
5862
5704
  async saveNodeIcon(nodeId, icon) {
5863
5705
  const revision = this.$.revision.value;
5864
- const target = this.#model.value.target;
5865
- if (revision == null || target == null) return false;
5866
- const changes = updateNodeIcon(revision, target, nodeId, icon);
5706
+ if (revision == null) return false;
5707
+ const changes = updateNodeIcon(revision, nodeId, icon);
5867
5708
  return changes != null && await this.#editDraft(changes) != null;
5868
5709
  }
5869
5710
  async saveNodeTitle(nodeId, title) {
5870
5711
  const revision = this.$.revision.value;
5871
- const target = this.#model.value.target;
5872
- if (revision == null || target == null) return false;
5873
- const changes = updateNodeName(revision, target, nodeId, title);
5712
+ if (revision == null) return false;
5713
+ const changes = updateNodeName(revision, nodeId, title);
5874
5714
  return changes != null && await this.#editDraft(changes) != null;
5875
5715
  }
5876
5716
  async setInputValue(nodeId, handle, value, deletion) {
5877
5717
  const revision = this.$.revision.value;
5878
- const target = this.#model.value.target;
5879
- if (revision == null || target == null) return false;
5880
- const changes = setInputValue(revision, target, nodeId, handle, value);
5718
+ if (revision == null) return false;
5719
+ const changes = setInputValue(revision, nodeId, handle, value);
5881
5720
  return changes != null && await this.#editDraft(changes, deletion) != null;
5882
5721
  }
5883
5722
  async resetInputs(nodeId, handles) {
5884
5723
  const revision = this.$.revision.value;
5885
- const target = this.#model.value.target;
5886
- if (revision == null || target == null) return false;
5887
- return await this.#editDraft(resetInputValues(revision.revision.content, target, nodeId, handles)) != null;
5724
+ if (revision == null) return false;
5725
+ return await this.#editDraft(resetInputValues(revision.revision.content, nodeId, handles)) != null;
5888
5726
  }
5889
5727
  async resetTriggerConfig(triggerId, names) {
5890
5728
  const revision = this.$.revision.value;
5891
- const target = this.#model.value.target;
5892
- if (revision == null || target?.kind !== "flow") return false;
5893
- const trigger = revision.graph(target)?.nodes[triggerId];
5729
+ if (revision == null) return false;
5730
+ const trigger = revision.graph()?.nodes[triggerId];
5894
5731
  if (trigger?.kind !== "poll" && trigger?.kind !== "integration") return false;
5895
5732
  const changes = (names == null ? Object.entries(trigger.config) : names.flatMap((name) => Object.hasOwn(trigger.config, name) ? [[name, trigger.config[name]]] : [])).map(([name, before]) => ({
5896
5733
  kind: "graph.trigger.config.set",
@@ -5903,53 +5740,46 @@ var WorkspaceStore = class {
5903
5740
  }
5904
5741
  async setInputSource(nodeId, handle, source) {
5905
5742
  const revision = this.$.revision.value;
5906
- const target = this.#model.value.target;
5907
- if (revision == null || target == null) return false;
5908
- return await this.#editDraft(setInputSources(revision.revision.content, target, nodeId, handle, [{
5743
+ if (revision == null) return false;
5744
+ return await this.#editDraft(setInputSources(revision.revision.content, nodeId, handle, [{
5909
5745
  kind: "node",
5910
5746
  ...source
5911
5747
  }])) != null;
5912
5748
  }
5913
5749
  async setInputVariable(nodeId, handle, name) {
5914
5750
  const revision = this.$.revision.value;
5915
- const target = this.#model.value.target;
5916
- if (revision == null || target == null) return false;
5917
- const changes = name == null ? setInputValue(revision, target, nodeId, handle, void 0) : setInputVariable(revision, target, nodeId, handle, name, this.#identity());
5751
+ if (revision == null) return false;
5752
+ const changes = name == null ? setInputValue(revision, nodeId, handle, void 0) : setInputVariable(revision, nodeId, handle, name, this.#identity());
5918
5753
  return changes != null && await this.#editDraft(changes) != null;
5919
5754
  }
5920
5755
  async saveCondition(nodeId, settings, deletion) {
5921
5756
  const revision = this.$.revision.value;
5922
- const target = this.#model.value.target;
5923
- if (revision == null || target == null) return false;
5924
- const changes = updateCondition(revision, target, nodeId, settings);
5757
+ if (revision == null) return false;
5758
+ const changes = updateCondition(revision, nodeId, settings);
5925
5759
  return changes != null && await this.#editDraft(changes, deletion) != null;
5926
5760
  }
5927
5761
  async saveValue(nodeId, values, deletion) {
5928
5762
  const revision = this.$.revision.value;
5929
- const target = this.#model.value.target;
5930
- if (revision == null || target == null) return false;
5931
- const changes = updateValue(revision, target, nodeId, values);
5763
+ if (revision == null) return false;
5764
+ const changes = updateValue(revision, nodeId, values);
5932
5765
  return changes != null && await this.#editDraft(changes, deletion) != null;
5933
5766
  }
5934
5767
  async saveResolution(nodeId, settings, deletion, values) {
5935
5768
  const revision = this.$.revision.value;
5936
- const target = this.#model.value.target;
5937
- if (revision == null || target?.kind != "flow") return false;
5938
- const changes = updateResolution(revision, target, nodeId, settings, values);
5769
+ if (revision == null) return false;
5770
+ const changes = updateResolution(revision, nodeId, settings, values);
5939
5771
  return changes != null && await this.#editDraft(changes, deletion) != null;
5940
5772
  }
5941
5773
  async saveNodeContentHidden(nodeId, hidden) {
5942
- const target = this.#model.value.target;
5943
5774
  const node = this.#designer().nodes.find((candidate) => candidate.id == nodeId);
5944
- if (target == null || node == null || node.kind == "condition") return;
5945
- await this.#canvasChange("edit", 1, [], (value) => setNodeContentHidden(value, target, nodeId, hidden));
5775
+ if (node == null || node.kind == "condition") return;
5776
+ await this.#canvasChange("edit", 1, [], (value) => setNodeContentHidden(value, nodeId, hidden));
5946
5777
  }
5947
5778
  async saveComment(nodeId, comment) {
5948
- const target = this.#model.value.target;
5949
- if (target == null) return;
5779
+ if (this.#model.value.draft == null) return;
5950
5780
  const position = this.#designer().nodes.find((node) => node.id == nodeId)?.position;
5951
5781
  if (position == null) return;
5952
- await this.#canvasChange("edit", 1, [], (value) => setComment(value, target, nodeId, {
5782
+ await this.#canvasChange("edit", 1, [], (value) => setComment(value, nodeId, {
5953
5783
  ...comment,
5954
5784
  position
5955
5785
  }));
@@ -5957,38 +5787,34 @@ var WorkspaceStore = class {
5957
5787
  loadOpenApiDocument(url, signal) {
5958
5788
  return this.#client.loadOpenApiDocument(url, signal);
5959
5789
  }
5960
- async saveTaskSettings(nodeId, settings) {
5790
+ async saveTaskSettings(nodeId, settings, deletion) {
5961
5791
  const revision = this.$.revision.value;
5962
- const target = this.#model.value.target;
5963
- if (revision == null || target == null) return false;
5964
- const changes = updateTask(revision, target, nodeId, settings);
5965
- return changes != null && await this.#editDraft(changes) != null;
5792
+ if (revision == null) return false;
5793
+ const changes = updateTask(revision, nodeId, settings);
5794
+ return changes != null && await this.#editDraft(changes, deletion) != null;
5966
5795
  }
5967
5796
  async saveTaskPorts(nodeId, ports, deletion, values) {
5968
5797
  const revision = this.$.revision.value;
5969
- const target = this.#model.value.target;
5970
- if (revision == null || target == null) return false;
5971
- const changes = updateTaskPorts(revision, target, nodeId, ports, values);
5798
+ if (revision == null) return false;
5799
+ const changes = updateTaskPorts(revision, nodeId, ports, values);
5972
5800
  return changes != null && await this.#editDraft(changes, deletion) != null;
5973
5801
  }
5974
5802
  async saveTaskAdditionalInputs(nodeId, inputs, deletion, values) {
5975
5803
  const revision = this.$.revision.value;
5976
- const target = this.#model.value.target;
5977
- if (revision == null || target == null) return false;
5978
- const changes = updateTaskAdditionalInputs(revision, target, nodeId, inputs, values);
5804
+ if (revision == null) return false;
5805
+ const changes = updateTaskAdditionalInputs(revision, nodeId, inputs, values);
5979
5806
  return changes != null && await this.#editDraft(changes, deletion) != null;
5980
5807
  }
5981
- async setConnectorConnection(taskId, connectionId) {
5808
+ async setConnectorConnection(nodeId, connectionId) {
5982
5809
  const revision = this.$.revision.value;
5983
5810
  if (revision == null) return false;
5984
- const changes = setConnectorConnection(revision.revision.content, taskId, connectionId);
5811
+ const changes = setConnectorConnection(revision.revision.content, nodeId, connectionId);
5985
5812
  return changes != null && await this.#editDraft(changes) != null;
5986
5813
  }
5987
5814
  async setCodeActions(nodeId, capabilities) {
5988
5815
  const revision = this.$.revision.value;
5989
- const target = this.#model.value.target;
5990
- if (revision == null || target == null) return false;
5991
- const changes = setCodeActions(revision.revision.content, target, nodeId, capabilities);
5816
+ if (revision == null) return false;
5817
+ const changes = setCodeActions(revision.revision.content, nodeId, capabilities);
5992
5818
  return changes == null || await this.#editDraft(changes) != null;
5993
5819
  }
5994
5820
  get eventSourceClient() {
@@ -6001,19 +5827,18 @@ var WorkspaceStore = class {
6001
5827
  }
6002
5828
  async setTriggerEventSource(triggerId, source) {
6003
5829
  const revision = this.$.revision.value;
6004
- const target = this.#model.value.target;
6005
- if (revision == null || target?.kind != "flow") return false;
6006
- const trigger = revision.graph(target)?.nodes[triggerId];
5830
+ if (revision == null) return false;
5831
+ const trigger = revision.graph()?.nodes[triggerId];
6007
5832
  if (trigger?.kind != "integration" || trigger.definition.key != "feishu_app_bot.on_event" || source.provider != trigger.definition.provider) return false;
6008
- const connectionChanges = setTriggerConnection(revision.revision.content, target, triggerId, source.connectionId);
5833
+ const connectionChanges = setTriggerConnection(revision.revision.content, triggerId, source.connectionId);
6009
5834
  if (connectionChanges == null) return false;
6010
5835
  const changed = inputValue(trigger.config.sourceId, void 0) != source.sourceId;
6011
5836
  return await this.#editDraft([
6012
5837
  ...connectionChanges,
6013
- ...updateTriggerConfig(revision.revision.content, target, triggerId, "sourceId", source.sourceId) ?? [],
6014
- ...changed ? updateTriggerConfig(revision.revision.content, target, triggerId, "eventTypes", void 0) ?? [] : [],
6015
- ...changed ? updateTriggerConfig(revision.revision.content, target, triggerId, "resource", void 0) ?? [] : [],
6016
- ...changed ? updateTriggerConfig(revision.revision.content, target, triggerId, "chatIds", void 0) ?? [] : []
5838
+ ...updateTriggerConfig(revision.revision.content, triggerId, "sourceId", source.sourceId) ?? [],
5839
+ ...changed ? updateTriggerConfig(revision.revision.content, triggerId, "eventTypes", void 0) ?? [] : [],
5840
+ ...changed ? updateTriggerConfig(revision.revision.content, triggerId, "resource", void 0) ?? [] : [],
5841
+ ...changed ? updateTriggerConfig(revision.revision.content, triggerId, "chatIds", void 0) ?? [] : []
6017
5842
  ]) != null;
6018
5843
  }
6019
5844
  async loadTriggerConfigOptions(triggerId, field, signal) {
@@ -6026,50 +5851,40 @@ var WorkspaceStore = class {
6026
5851
  }
6027
5852
  async saveTriggerConfig(triggerId, name, value) {
6028
5853
  const revision = this.$.revision.value;
6029
- const target = this.#model.value.target;
6030
- if (revision == null || target?.kind != "flow") return false;
6031
- let changes = updateTriggerConfig(revision.revision.content, target, triggerId, name, value);
5854
+ if (revision == null) return false;
5855
+ let changes = updateTriggerConfig(revision.revision.content, triggerId, name, value);
6032
5856
  if (changes == null) return false;
6033
- const trigger = revision.graph(target)?.nodes[triggerId];
5857
+ const trigger = revision.graph()?.nodes[triggerId];
6034
5858
  if (changes.length > 0 && trigger?.kind == "integration" && trigger.definition.key == "feishu_app_bot.on_event" && name == "eventTypes") {
6035
5859
  const events = Array.isArray(value) ? value.filter((item) => typeof item == "string") : [];
6036
- if (!supportsFeishuChatFilter(events)) changes = [...changes, ...updateTriggerConfig(revision.revision.content, target, triggerId, "chatIds", void 0) ?? []];
5860
+ if (!supportsFeishuChatFilter(events)) changes = [...changes, ...updateTriggerConfig(revision.revision.content, triggerId, "chatIds", void 0) ?? []];
6037
5861
  const resource = inputValue(trigger.config.resource, void 0);
6038
- if (isJsonObject(resource) && resource.kind != feishuResourceKind(events)) changes = [...changes, ...updateTriggerConfig(revision.revision.content, target, triggerId, "resource", void 0) ?? []];
5862
+ if (isJsonObject(resource) && resource.kind != feishuResourceKind(events)) changes = [...changes, ...updateTriggerConfig(revision.revision.content, triggerId, "resource", void 0) ?? []];
6039
5863
  }
6040
- if (changes.length > 0 && trigger?.kind == "poll" && trigger.definition.key == "linear.on_issue_changed" && name == "teamId") return await this.#editDraft([...changes, ...updateTriggerConfig(revision.revision.content, target, triggerId, "stateIds", void 0) ?? []]) != null;
5864
+ if (changes.length > 0 && trigger?.kind == "poll" && trigger.definition.key == "linear.on_issue_changed" && name == "teamId") return await this.#editDraft([...changes, ...updateTriggerConfig(revision.revision.content, triggerId, "stateIds", void 0) ?? []]) != null;
6041
5865
  return await this.#editDraft(changes) != null;
6042
5866
  }
6043
5867
  async saveTriggerSchedule(triggerId, schedule) {
6044
5868
  const revision = this.$.revision.value;
6045
- const target = this.#model.value.target;
6046
- if (revision == null || target?.kind != "flow") return false;
6047
- const changes = updateTriggerSchedule(revision.revision.content, target, triggerId, schedule);
5869
+ if (revision == null) return false;
5870
+ const changes = updateTriggerSchedule(revision.revision.content, triggerId, schedule);
6048
5871
  return changes != null && await this.#editDraft(changes) != null;
6049
5872
  }
6050
5873
  async saveWebhook(triggerId, settings, deletion) {
6051
5874
  const revision = this.$.revision.value;
6052
- const target = this.#model.value.target;
6053
- if (revision == null || target?.kind != "flow") return false;
6054
- const changes = updateWebhook(revision, target, triggerId, settings);
5875
+ if (revision == null) return false;
5876
+ const changes = updateWebhook(revision, triggerId, settings);
6055
5877
  return changes != null && await this.#editDraft(changes, deletion) != null;
6056
5878
  }
6057
5879
  async setTriggerConnection(triggerId, connectionId) {
6058
5880
  const revision = this.$.revision.value;
6059
- const target = this.#model.value.target;
6060
- if (revision == null || target?.kind != "flow") return false;
6061
- const changes = setTriggerConnection(revision.revision.content, target, triggerId, connectionId);
5881
+ if (revision == null) return false;
5882
+ const changes = setTriggerConnection(revision.revision.content, triggerId, connectionId);
6062
5883
  if (changes == null) return false;
6063
- const trigger = revision.graph(target)?.nodes[triggerId];
6064
- if (changes.length > 0 && trigger?.kind == "poll" && trigger.definition.key == "linear.on_issue_changed") return await this.#editDraft([...changes, ...["teamId", "stateIds"].flatMap((field) => updateTriggerConfig(revision.revision.content, target, triggerId, field, void 0) ?? [])]) != null;
5884
+ const trigger = revision.graph()?.nodes[triggerId];
5885
+ if (changes.length > 0 && trigger?.kind == "poll" && trigger.definition.key == "linear.on_issue_changed") return await this.#editDraft([...changes, ...["teamId", "stateIds"].flatMap((field) => updateTriggerConfig(revision.revision.content, triggerId, field, void 0) ?? [])]) != null;
6065
5886
  return await this.#editDraft(changes) != null;
6066
5887
  }
6067
- async saveSubflowSettings(subflowId, settings) {
6068
- const revision = this.$.revision.value;
6069
- if (revision == null) return false;
6070
- const changes = updateSubflow(revision, subflowId, settings);
6071
- return changes != null && await this.#editDraft(changes) != null;
6072
- }
6073
5888
  updateModuleSource(source) {
6074
5889
  const editor = this.#model.value.moduleEditor;
6075
5890
  if (this.#history.applying || this.#history.failed || editor == null || editor.source == source) return;
@@ -6091,17 +5906,15 @@ var WorkspaceStore = class {
6091
5906
  return this.#modules.saveModuleEditor();
6092
5907
  }
6093
5908
  async moveNodes(positions) {
6094
- const target = this.#model.value.target;
6095
- if (target == null) return;
6096
- await this.#canvasChange("move", Object.keys(positions).length, [], (value) => setNodePositions(value, target, positions));
5909
+ if (this.#model.value.draft == null) return;
5910
+ await this.#canvasChange("move", Object.keys(positions).length, [], (value) => setNodePositions(value, positions));
6097
5911
  }
6098
5912
  async moveViewport(viewport) {
6099
- const target = this.#model.value.target;
6100
- if (target == null) return;
6101
- await this.#changePresentation((value) => setFlowViewport(value, target, viewport), true);
5913
+ if (this.#model.value.draft == null) return;
5914
+ await this.#changePresentation((value) => setFlowViewport(value, viewport), true);
6102
5915
  }
6103
5916
  async check() {
6104
- await this.#checkTarget();
5917
+ await this.#checkDraft();
6105
5918
  }
6106
5919
  async refreshFlows() {
6107
5920
  await this.reloadFlows();
@@ -6111,9 +5924,8 @@ var WorkspaceStore = class {
6111
5924
  }
6112
5925
  locateNode(nodeId, { preserveSelection = false } = {}) {
6113
5926
  const revision = this.$.revision.value;
6114
- const target = this.#model.value.target;
6115
- if (revision == null || target == null) return false;
6116
- if (revision.node(target, nodeId) == null && !commentIds(this.#model.value.presentation?.value ?? {}, target).has(nodeId)) return false;
5927
+ if (revision == null) return false;
5928
+ if (revision.node(nodeId) == null && !commentIds(this.#model.value.presentation?.value ?? {}).has(nodeId)) return false;
6117
5929
  if (!preserveSelection && !this.selectNodes([nodeId])) return false;
6118
5930
  this.#set({ nodeFocus: {
6119
5931
  nodeId,
@@ -6130,13 +5942,13 @@ var WorkspaceStore = class {
6130
5942
  } });
6131
5943
  return true;
6132
5944
  }
6133
- async #addComment(target, nodeId, position) {
5945
+ async #addComment(nodeId, position) {
6134
5946
  const number = Math.max(0, ...this.#designer().nodes.flatMap((node) => {
6135
5947
  if (node.kind != "comment") return [];
6136
5948
  const match = /#(\d+)$/.exec(node.title);
6137
5949
  return match == null ? [] : [Number(match[1])];
6138
5950
  }));
6139
- if (!await this.#canvasChange("add", 1, [], (value) => setComment(value, target, nodeId, {
5951
+ if (!await this.#canvasChange("add", 1, [], (value) => setComment(value, nodeId, {
6140
5952
  content: "",
6141
5953
  position,
6142
5954
  title: this.#i18n.t("addNode.commentName", { number: number + 1 })
@@ -6201,17 +6013,17 @@ var WorkspaceStore = class {
6201
6013
  if (draft == null) return;
6202
6014
  const repairs = repairNodeNames(draft.content);
6203
6015
  if (repairs.length == 0) {
6204
- this.#checkTarget();
6016
+ this.#checkDraft();
6205
6017
  return;
6206
6018
  }
6207
6019
  if (await this.#changeDraft(repairs, false) != null || !current()) return;
6208
6020
  if (this.#model.value.draft?.revisionId == draft.revisionId) break;
6209
6021
  }
6210
- if (current()) this.#checkTarget();
6022
+ if (current()) this.#checkDraft();
6211
6023
  }
6212
6024
  #applyDraft(draft, origin) {
6213
6025
  const previousDraft = this.#model.value.draft;
6214
- const { revision, selectedNodeIds, target } = this.#reconcileRevision(draft);
6026
+ const { revision, selectedNodeIds } = this.#reconcileRevision(draft);
6215
6027
  const editor = this.#model.value.moduleEditor;
6216
6028
  const keepEditor = editor != null && (origin == "external" || previousDraft != null) && moduleEditorStatus(previousDraft, editor) != "saved";
6217
6029
  let moduleEditor;
@@ -6219,12 +6031,11 @@ var WorkspaceStore = class {
6219
6031
  ...editor,
6220
6032
  phase: "failed"
6221
6033
  } : editor;
6222
- else moduleEditor = selectedModuleEditor(revision, target, selectedNodeIds);
6034
+ else moduleEditor = selectedModuleEditor(revision, selectedNodeIds);
6223
6035
  this.#set({
6224
6036
  draft,
6225
6037
  moduleEditor,
6226
- selectedNodeIds,
6227
- target
6038
+ selectedNodeIds
6228
6039
  });
6229
6040
  return keepEditor;
6230
6041
  }
@@ -6255,10 +6066,10 @@ var WorkspaceStore = class {
6255
6066
  }
6256
6067
  async #canvasChange(action, count, changes, update, selection = this.#model.value.selectedNodeIds, deletion) {
6257
6068
  if (this.#disposed || this.#history.applying || this.#history.failed) return false;
6258
- const { draft, target, presentation, selectedNodeIds } = this.#model.value;
6259
- if (draft == null || target == null || presentation == null) return false;
6069
+ const { draft, presentation, selectedNodeIds } = this.#model.value;
6070
+ if (draft == null || presentation == null) return false;
6260
6071
  const next = update?.(presentation.value) ?? presentation.value;
6261
- const presentationChange = canvasPresentationChange(presentation.value, next, target);
6072
+ const presentationChange = canvasPresentationChange(presentation.value, next);
6262
6073
  if (dequal$1(applyFlowChanges(draft, changes).content, draft.content) && presentationChange.nodeIds.length == 0) return true;
6263
6074
  const generation = this.#history.generation;
6264
6075
  const inverse = inverseFlowChanges(draft.content, changes);
@@ -6266,7 +6077,6 @@ var WorkspaceStore = class {
6266
6077
  const entry = {
6267
6078
  action,
6268
6079
  count,
6269
- target,
6270
6080
  forward: changes,
6271
6081
  inverse,
6272
6082
  presentation: presentationChange,
@@ -6311,7 +6121,7 @@ var WorkspaceStore = class {
6311
6121
  this.#history.applying = true;
6312
6122
  this.#history.publish();
6313
6123
  try {
6314
- const [draft, presentation] = await Promise.all([this.#changeDraft(redo ? entry.forward : entry.inverse, true, "canvas"), this.#changePresentation((value) => restoreCanvasPresentation(value, entry.target, entry.presentation, redo), true)]);
6124
+ const [draft, presentation] = await Promise.all([this.#changeDraft(redo ? entry.forward : entry.inverse, true, "canvas"), this.#changePresentation((value) => restoreCanvasPresentation(value, entry.presentation, redo), true)]);
6315
6125
  if (draft != null && presentation && generation == this.#history.generation) {
6316
6126
  this.selectNodes(redo ? entry.afterSelection : entry.beforeSelection);
6317
6127
  this.#history.complete(redo);
@@ -6347,7 +6157,7 @@ var WorkspaceStore = class {
6347
6157
  kind: "error",
6348
6158
  message: this.#i18n.t("history.resynced")
6349
6159
  });
6350
- this.#checkTarget();
6160
+ this.#checkDraft();
6351
6161
  } catch {
6352
6162
  if (current() && !this.#disposed) this.#setNotice({
6353
6163
  kind: "error",
@@ -6361,13 +6171,12 @@ var WorkspaceStore = class {
6361
6171
  });
6362
6172
  return this.#historyRecovery;
6363
6173
  }
6364
- async #checkTarget() {
6174
+ async #checkDraft() {
6365
6175
  if (this.#disposed) return;
6366
6176
  const flowId = this.#model.value.flowId;
6367
6177
  const draft = this.#model.value.draft;
6368
- const target = this.#model.value.target;
6369
- if (flowId == null || draft == null || target == null) {
6370
- if (target == null) this.#set({
6178
+ if (flowId == null || draft == null) {
6179
+ if (this.#model.value.draft == null) this.#set({
6371
6180
  checkLoading: false,
6372
6181
  diagnostics: void 0
6373
6182
  });
@@ -6437,7 +6246,7 @@ var WorkspaceStore = class {
6437
6246
  kind: preserveModuleEditor ? "error" : "success",
6438
6247
  message: this.#i18n.t(preserveModuleEditor ? "notice.moduleUpdated" : "notice.draftUpdated")
6439
6248
  });
6440
- this.#checkTarget();
6249
+ this.#checkDraft();
6441
6250
  return true;
6442
6251
  } catch (error) {
6443
6252
  if (reportError && this.#isDraftChangeCurrent(context)) this.#setNotice(errorNotice(error, this.#i18n.t));
@@ -6446,15 +6255,13 @@ var WorkspaceStore = class {
6446
6255
  }
6447
6256
  #designer() {
6448
6257
  const state = this.#model.value;
6449
- return designerGraph(state.draft, state.target, state.presentation?.value, state.diagnostics?.diagnostics, {}, {}, this.#i18n.t);
6258
+ return designerGraph(state.draft, state.presentation?.value, state.diagnostics?.diagnostics, {}, {}, this.#i18n.t);
6450
6259
  }
6451
6260
  #reconcileRevision(draft) {
6452
6261
  const revision = revisionView(draft);
6453
- const target = reconcileTarget(revision, this.#model.value.target);
6454
6262
  return {
6455
6263
  revision,
6456
- selectedNodeIds: this.#model.value.selectedNodeIds.filter((nodeId) => target != null && revision.selection(target, nodeId) != null),
6457
- target
6264
+ selectedNodeIds: this.#model.value.selectedNodeIds.filter((nodeId) => revision.selection(nodeId) != null)
6458
6265
  };
6459
6266
  }
6460
6267
  #isDraftChangeCurrent(context) {
@@ -6474,11 +6281,11 @@ var WorkspaceStore = class {
6474
6281
  function indexNodes(designer) {
6475
6282
  return new Map(designer.nodes.map((node) => [node.id, node]));
6476
6283
  }
6477
- function designerRevisionInputs(draft, target) {
6478
- return draft == null || target == null ? [] : revisionView(draft).designerInputs(target);
6284
+ function designerRevisionInputs(draft) {
6285
+ return draft == null ? [] : revisionView(draft).designerInputs();
6479
6286
  }
6480
- function indexRunEventNodes(draft, target, run, events, nodes) {
6481
- if (draft == null || target?.kind != "flow" || run?.revisionId != draft.revisionId || run.flowId != draft.flowId) return /* @__PURE__ */ new Map();
6287
+ function indexRunEventNodes(draft, run, events, nodes) {
6288
+ if (draft == null || run?.revisionId != draft.revisionId || run.flowId != draft.flowId) return /* @__PURE__ */ new Map();
6482
6289
  const scopeId = events.find((event) => event.kind == "run.started" && event.payload.flowId == draft.flowId)?.payload.scopeId;
6483
6290
  if (typeof scopeId != "string") return /* @__PURE__ */ new Map();
6484
6291
  return new Map(events.flatMap((event) => {
@@ -6572,15 +6379,14 @@ var WorkbenchStore = class {
6572
6379
  valid: false
6573
6380
  };
6574
6381
  });
6575
- const designerCache = /* @__PURE__ */ new Map();
6382
+ let designerCache;
6576
6383
  let designerFlowId;
6577
6384
  const designer = compute((get) => {
6578
6385
  const draft = get(this.workspace.$.draft);
6579
6386
  if (designerFlowId != draft?.flowId) {
6580
- designerCache.clear();
6387
+ designerCache = void 0;
6581
6388
  designerFlowId = draft?.flowId;
6582
6389
  }
6583
- const target = get(this.workspace.$.target);
6584
6390
  const presentation = get(this.workspace.$.presentation)?.value;
6585
6391
  const designerDiagnostics = get(diagnostics)?.diagnostics ?? get(this.connectors.$.diagnostics);
6586
6392
  const providerEntries = draft == null ? void 0 : get(resourceData(this.workspace.catalogs.providers.get(draft.flowId, i18n.lang)));
@@ -6590,10 +6396,9 @@ var WorkbenchStore = class {
6590
6396
  const t = get(i18n.t$);
6591
6397
  const run = get(this.runs.$.run);
6592
6398
  const events = get(this.runs.$.events);
6593
- const key = target == null ? "" : target.kind == "flow" ? "flow" : `subflow:${target.id}`;
6594
6399
  const inputs = [
6595
- ...designerRevisionInputs(draft, target),
6596
- presentation == null || target == null ? void 0 : targetPresentation(presentation, target),
6400
+ ...designerRevisionInputs(draft),
6401
+ presentation == null ? void 0 : flowPresentation(presentation),
6597
6402
  designerDiagnostics,
6598
6403
  actions,
6599
6404
  providerEntries,
@@ -6603,24 +6408,23 @@ var WorkbenchStore = class {
6603
6408
  events,
6604
6409
  ...run == null ? [] : [draft?.revisionId]
6605
6410
  ];
6606
- const cached = designerCache.get(key);
6411
+ const cached = designerCache;
6607
6412
  if (cached != null && cached.inputs.length == inputs.length && cached.inputs.every((input, index) => input === inputs[index])) return cached.graph;
6608
- const graph = designerGraph(draft, target, presentation, designerDiagnostics, actions, catalogs, t, run, events, providerCatalog);
6609
- designerCache.set(key, {
6413
+ const graph = designerGraph(draft, presentation, designerDiagnostics, actions, catalogs, t, run, events, providerCatalog);
6414
+ designerCache = {
6610
6415
  graph,
6611
6416
  inputs
6612
- });
6417
+ };
6613
6418
  return graph;
6614
6419
  });
6615
6420
  const designerNodeById = derive(designer, indexNodes);
6616
6421
  this.$ = {
6617
6422
  connectorSetupPending: compute((get) => {
6618
6423
  const flowId = get(this.workspace.$.flowId);
6619
- const target = get(this.workspace.$.target);
6620
6424
  const selection = get(this.workspace.$.selection);
6621
6425
  if (selection?.kind != "task" || selection.definition == null || !("executor" in selection.definition) || selection.definition.executor.kind != "connector") return false;
6622
6426
  const actionId = selection.definition.executor.action;
6623
- return get(this.#connectorSetups).some((setup) => setup.flowId == flowId && dequal(setup.target, target) && setup.actionId == actionId && (setup.nodeId == null || setup.nodeId == selection.id));
6427
+ return get(this.#connectorSetups).some((setup) => setup.flowId == flowId && setup.actionId == actionId && (setup.nodeId == null || setup.nodeId == selection.id));
6624
6428
  }),
6625
6429
  busy: compute((get) => {
6626
6430
  const workspaceBusy = get(this.workspace.$.busy);
@@ -6633,15 +6437,14 @@ var WorkbenchStore = class {
6633
6437
  }),
6634
6438
  diagnosticItems: compute((get) => {
6635
6439
  const revision = get(this.workspace.$.revision);
6636
- const target = get(this.workspace.$.target);
6637
- return presentTriggerDiagnostics(diagnosticItems(revision, target, get(diagnostics)), revision, target, get(this.triggers.catalog.state).data?.display, resolveUiLanguage([i18n.lang]), get(i18n.t$));
6440
+ return presentTriggerDiagnostics(diagnosticItems(revision, get(diagnostics)), revision, get(this.triggers.catalog.state).data?.display, resolveUiLanguage([i18n.lang]), get(i18n.t$));
6638
6441
  }),
6639
6442
  diagnostics,
6640
6443
  designer,
6641
6444
  designerNodeById,
6642
6445
  sourceNodeIcons: derive(designer, (graph) => Object.fromEntries(graph.nodes.flatMap((node) => "icon" in node ? [[node.id, node.icon]] : [])), { equal: dequal }),
6643
6446
  notice: this.#notice,
6644
- runEventNodes: compute((get) => indexRunEventNodes(get(this.workspace.$.draft), get(this.workspace.$.target), get(this.runs.$.run), get(this.runs.$.events), get(designerNodeById))),
6447
+ runEventNodes: compute((get) => indexRunEventNodes(get(this.workspace.$.draft), get(this.runs.$.run), get(this.runs.$.events), get(designerNodeById))),
6645
6448
  selectedDesignerNode: compute((get) => {
6646
6449
  const selected = get(this.workspace.$.selectedNodeIds);
6647
6450
  return selected.length == 1 ? get(designerNodeById).get(selected[0]) : void 0;
@@ -6770,7 +6573,6 @@ var WorkbenchStore = class {
6770
6573
  return;
6771
6574
  }
6772
6575
  const flowId = this.workspace.$.flowId.value;
6773
- const target = this.workspace.$.target.value;
6774
6576
  if (option.kind == "connector") {
6775
6577
  const { defaultConnection: _defaultConnection, ...metadata } = option.connector;
6776
6578
  option = {
@@ -6778,9 +6580,8 @@ var WorkbenchStore = class {
6778
6580
  connector: metadata
6779
6581
  };
6780
6582
  }
6781
- const setup = option.kind == "connector" && flowId != null && target != null ? {
6583
+ const setup = option.kind == "connector" && flowId != null ? {
6782
6584
  flowId,
6783
- target,
6784
6585
  actionId: option.connector.actionId,
6785
6586
  nodeId: void 0
6786
6587
  } : void 0;
@@ -6792,7 +6593,7 @@ var WorkbenchStore = class {
6792
6593
  if (nodeId != null && option.kind == "connector" && setup != null) {
6793
6594
  setup.nodeId = nodeId;
6794
6595
  this.#connectorSetups.set([...this.#connectorSetups.value]);
6795
- this.#configureAddedConnector(setup.flowId, setup.target, nodeId, option.connector).finally(finishSetup);
6596
+ this.#configureAddedConnector(setup.flowId, nodeId, option.connector).finally(finishSetup);
6796
6597
  finishSetup = void 0;
6797
6598
  }
6798
6599
  if (nodeId != null && option.kind == "trigger") this.triggers.refresh();
@@ -6804,17 +6605,17 @@ var WorkbenchStore = class {
6804
6605
  finishSetup?.();
6805
6606
  }
6806
6607
  }
6807
- async #configureAddedConnector(flowId, target, nodeId, action) {
6608
+ async #configureAddedConnector(flowId, nodeId, action) {
6808
6609
  try {
6809
6610
  if (this.#disposed || flowId != this.workspace.$.flowId.value) return;
6810
6611
  const prepared = await this.prepareConnectorAction(action);
6811
6612
  if (prepared == null || this.#disposed || flowId != this.workspace.$.flowId.value) return;
6812
- const node = this.workspace.$.revision.value?.node(target, nodeId);
6813
- if (node?.kind != "task" || node.node.task != null) return;
6814
- const executor = this.workspace.$.revision.value?.task(node.node.taskId)?.executor;
6613
+ const node = this.workspace.$.revision.value?.node(nodeId);
6614
+ if (node?.kind != "task" || "moduleId" in node.node.task) return;
6615
+ const executor = "executor" in node.node.task ? node.node.task.executor : void 0;
6815
6616
  if (executor?.kind != "connector" || executor.action != action.actionId || executor.connectionId != null) return;
6816
6617
  const connection = prepared.action.defaultConnection;
6817
- if (connection != null) await this.workspace.setConnectorConnection(node.node.taskId, connection.connectionId);
6618
+ if (connection != null) await this.workspace.setConnectorConnection(node.id, connection.connectionId);
6818
6619
  if (!this.#disposed && flowId == this.workspace.$.flowId.value) await this.connectors.refresh();
6819
6620
  } catch (error) {
6820
6621
  if (!this.#disposed && flowId == this.workspace.$.flowId.value) this.#notice.set(errorNotice(error, this.#i18n.t));
@@ -6891,7 +6692,7 @@ var WorkbenchStore = class {
6891
6692
  async requestDraftRun(triggerId) {
6892
6693
  const flowId = this.workspace.$.flowId.value;
6893
6694
  if (!await this.workspace.saveDraft() || this.#disposed || flowId != this.workspace.$.flowId.value) return "unavailable";
6894
- const flow = this.workspace.$.targetFlow.value;
6695
+ const flow = this.workspace.$.flow.value;
6895
6696
  const draft = this.workspace.$.draft.value;
6896
6697
  if (flow == null || draft == null) return "unavailable";
6897
6698
  return await this.runRequests.requestDraft(flow, draft, triggerId);
@@ -6899,24 +6700,22 @@ var WorkbenchStore = class {
6899
6700
  async editDraftRunInputs(triggerId) {
6900
6701
  const flowId = this.workspace.$.flowId.value;
6901
6702
  if (!await this.workspace.saveDraft() || this.#disposed || flowId != this.workspace.$.flowId.value) return "unavailable";
6902
- const flow = this.workspace.$.targetFlow.value;
6703
+ const flow = this.workspace.$.flow.value;
6903
6704
  const draft = this.workspace.$.draft.value;
6904
6705
  if (flow == null || draft == null) return "unavailable";
6905
6706
  return await this.runRequests.editDraft(flow, draft, triggerId);
6906
6707
  }
6907
6708
  async requestLiveRun() {
6908
- const flow = this.workspace.$.targetFlow.value;
6709
+ const flow = this.workspace.$.flow.value;
6909
6710
  if (flow == null) return "unavailable";
6910
6711
  return await this.runRequests.requestLive(flow);
6911
6712
  }
6912
6713
  async #followExternalRun(client, event) {
6913
- const target = this.workspace.$.target.value;
6914
- if (this.#disposed || this.runRequests.$.submitting.value != null || target?.kind != "flow" || this.workspace.$.flowId.value != event.flowId) return;
6714
+ if (this.#disposed || this.runRequests.$.submitting.value != null || this.workspace.$.flowId.value != event.flowId) return;
6915
6715
  const current = this.#externalRuns.begin();
6916
6716
  try {
6917
6717
  const run = await client.getRun(event.runId);
6918
- const latestTarget = this.workspace.$.target.value;
6919
- if (!current() || this.#disposed || latestTarget?.kind != "flow" || this.workspace.$.flowId.value != event.flowId || run.flowId != event.flowId || run.runId != event.runId) return;
6718
+ if (!current() || this.#disposed || this.workspace.$.flowId.value != event.flowId || run.flowId != event.flowId || run.runId != event.runId) return;
6920
6719
  this.runs.followExternal(run);
6921
6720
  } catch {
6922
6721
  return;
@@ -6925,7 +6724,7 @@ var WorkbenchStore = class {
6925
6724
  };
6926
6725
  //#endregion
6927
6726
  //#region src/workbench/browser/runtime/openFlowWorkbench.tsx
6928
- var FlowWorkspace = lazy(() => import("./flowWorkspace-CoT_ewLX.js"));
6727
+ var FlowWorkspace = lazy(() => import("./flowWorkspace-Dg4mqfa6.js"));
6929
6728
  function OpenFlowSessionGate({ action, description, error, onSubmit, onTokenChange, pending = false, title, token, tokenLabel }) {
6930
6729
  const hasToken = token != null && tokenLabel != null && onTokenChange != null;
6931
6730
  const tokenValue = token ?? "";