@loopstack/loopstack-studio 0.23.1 → 0.25.0

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 (147) hide show
  1. package/dist/api/config.js +3 -3
  2. package/dist/api/index.js +10 -12
  3. package/dist/api/processor.js +1 -1
  4. package/dist/api/secrets.js +16 -0
  5. package/dist/api/workflows.js +7 -1
  6. package/dist/components/dynamic-form/ArrayController.js +68 -64
  7. package/dist/components/dynamic-form/CodeContent.js +3 -3
  8. package/dist/components/dynamic-form/Form.js +46 -40
  9. package/dist/components/dynamic-form/FormElement.js +1 -1
  10. package/dist/components/dynamic-form/FormElementHeader.js +2 -2
  11. package/dist/components/dynamic-form/ObjectController.js +24 -21
  12. package/dist/components/dynamic-form/fields/BaseFieldWrapper.js +1 -1
  13. package/dist/components/dynamic-form/fields/CodeViewField.js +36 -36
  14. package/dist/components/dynamic-form/fields/InputField.js +20 -19
  15. package/dist/components/dynamic-form/fields/RadioField.js +18 -18
  16. package/dist/components/dynamic-form/fields/SelectField.js +19 -19
  17. package/dist/components/dynamic-form/fields/TextareaField.js +17 -17
  18. package/dist/components/feedback/LoadingCentered.js +1 -1
  19. package/dist/components/layout/MainLayout.js +18 -31
  20. package/dist/components/layout/StudioSidebar.js +169 -109
  21. package/dist/components/loopstack-elements/link.js +77 -76
  22. package/dist/components/loopstack-elements/tool.js +171 -0
  23. package/dist/components/page/PageBreadcrumbs.js +79 -32
  24. package/dist/components/ui-widgets/UiActions.js +10 -4
  25. package/dist/components/ui-widgets/widgets/ButtonFullWidth.js +8 -6
  26. package/dist/components/ui-widgets/widgets/SubmitButton.js +8 -6
  27. package/dist/features/code-explorer/components/FileContentViewer.js +92 -100
  28. package/dist/features/dashboard/RunItem.js +1 -1
  29. package/dist/features/debug/components/ConfigFlowViewer.js +2 -2
  30. package/dist/features/debug/components/{PipelineDebugHeader.js → WorkflowDebugHeader.js} +5 -5
  31. package/dist/features/debug/components/{PipelineDebugLegend.js → WorkflowDebugLegend.js} +2 -2
  32. package/dist/features/debug/components/{PipelineFlowViewer.js → WorkflowFlowViewer.js} +9 -9
  33. package/dist/features/debug/components/workflow-flow/WorkflowGraph.js +46 -0
  34. package/dist/features/debug/index.js +2 -2
  35. package/dist/features/debug/lib/flow-utils.js +142 -150
  36. package/dist/features/documents/DocumentRenderer.js +66 -30
  37. package/dist/features/documents/components/DocumentItem.js +2 -2
  38. package/dist/features/documents/components/DocumentList.js +18 -11
  39. package/dist/features/documents/document-details/DocumentDetails.js +4 -4
  40. package/dist/features/documents/renderers/AiMessage.js +12 -12
  41. package/dist/features/documents/renderers/ChoicesRenderer.js +92 -0
  42. package/dist/features/documents/renderers/ClaudeMessage.js +1 -1
  43. package/dist/features/documents/renderers/ConfirmPromptRenderer.js +56 -0
  44. package/dist/features/documents/renderers/DocumentFormRenderer.js +95 -65
  45. package/dist/features/documents/renderers/LinkMessageRenderer.js +8 -10
  46. package/dist/features/documents/renderers/SecretInputRenderer.js +87 -0
  47. package/dist/features/documents/renderers/TextPromptRenderer.js +57 -0
  48. package/dist/features/documents/renderers/useDocumentTransition.js +30 -0
  49. package/dist/features/oauth/OAuthPromptRenderer.js +20 -20
  50. package/dist/features/runs/Runs.js +8 -8
  51. package/dist/features/workbench/Workbench.js +35 -35
  52. package/dist/features/workbench/WorkflowItem.js +10 -9
  53. package/dist/features/workbench/WorkflowList.js +56 -73
  54. package/dist/features/workbench/components/NewRunDialog.js +18 -18
  55. package/dist/features/workbench/components/WorkbenchFilesPanel.js +33 -26
  56. package/dist/features/workbench/components/WorkbenchFloatingPanel.js +13 -44
  57. package/dist/features/workbench/components/WorkbenchFlowPanel.js +27 -29
  58. package/dist/features/workbench/components/WorkbenchIconSidebar.js +17 -17
  59. package/dist/features/workbench/components/WorkbenchPreviewPanel.js +2 -2
  60. package/dist/features/workbench/components/WorkbenchSecretsPanel.js +182 -0
  61. package/dist/features/workbench/components/WorkbenchSettingsModal.js +16 -41
  62. package/dist/features/workbench/components/WorkflowForms.js +14 -13
  63. package/dist/features/workbench/components/WorkflowHistoryItem.js +60 -81
  64. package/dist/features/workbench/components/{PipelineHistoryList.js → WorkflowHistoryList.js} +5 -5
  65. package/dist/features/workbench/components/buttons/WorkflowButtons.js +56 -54
  66. package/dist/features/workbench/hooks/useWorkflowData.js +10 -10
  67. package/dist/features/workbench/hooks/useWorkflowListState.js +8 -45
  68. package/dist/features/workbench/index.js +2 -3
  69. package/dist/features/workbench/providers/RemoteFileExplorerProvider.js +132 -117
  70. package/dist/features/workbench/providers/ScrollProvider.js +2 -2
  71. package/dist/features/workbench/providers/WorkbenchLayoutProvider.js +4 -4
  72. package/dist/features/workspaces/Workspaces.js +1 -1
  73. package/dist/features/workspaces/components/CreateWorkspace.js +12 -12
  74. package/dist/features/workspaces/components/ExecutionTimeline.js +22 -21
  75. package/dist/features/workspaces/components/{NewPipelineRunDialog.js → NewWorkflowRunDialog.js} +6 -6
  76. package/dist/features/workspaces/components/{PipelineForm.js → WorkflowRunForm.js} +31 -31
  77. package/dist/features/workspaces/components/WorkspaceHomePage.js +11 -11
  78. package/dist/features/workspaces/components/{pipeline-form → workflow-form}/ArgumentsView.js +1 -1
  79. package/dist/features/workspaces/components/{pipeline-form → workflow-form}/SelectionView.js +16 -16
  80. package/dist/hooks/index.js +3 -3
  81. package/dist/hooks/query-keys.js +34 -68
  82. package/dist/hooks/useConfig.js +5 -5
  83. package/dist/hooks/useProcessor.js +5 -5
  84. package/dist/hooks/useSecrets.js +69 -0
  85. package/dist/hooks/useWorkflows.js +155 -68
  86. package/dist/index.d.ts +158 -116
  87. package/dist/index.js +5 -5
  88. package/dist/packages/contracts/dist/enums/index.js +11 -12
  89. package/dist/packages/contracts/dist/enums/workflow-state.enum.js +1 -1
  90. package/dist/pages/DashboardPage.js +87 -35
  91. package/dist/pages/DebugWorkflowDetailsPage.js +8 -8
  92. package/dist/pages/DebugWorkflowsPage.js +10 -10
  93. package/dist/pages/EmbedWorkbenchPage.js +39 -45
  94. package/dist/pages/PreviewWorkbenchPage.js +130 -255
  95. package/dist/pages/RunsListPage.js +1 -1
  96. package/dist/pages/StudioLandingPage.js +13 -13
  97. package/dist/pages/WorkbenchPage.js +6 -6
  98. package/dist/pages/WorkflowDebugPage.js +114 -0
  99. package/dist/pages/WorkspacePage.js +4 -2
  100. package/dist/providers/InvalidationEventsProvider.js +19 -19
  101. package/dist/providers/SseProvider.js +0 -1
  102. package/dist/routing/LocalRouter.js +14 -17
  103. package/dist/types/ai.types.js +13 -0
  104. package/package.json +2 -3
  105. package/dist/api/namespaces.js +0 -7
  106. package/dist/api/pipelines.js +0 -13
  107. package/dist/components/ai-elements/tool.js +0 -158
  108. package/dist/features/debug/components/pipeline-flow/WorkflowGraph.js +0 -41
  109. package/dist/features/workbench/NavigationItems.js +0 -52
  110. package/dist/features/workbench/WorkbenchNavigation.js +0 -38
  111. package/dist/features/workbench/components/NavigationItem.js +0 -68
  112. package/dist/features/workbench/hooks/useIntersectionObserver.js +0 -44
  113. package/dist/hooks/useNamespaceTree.js +0 -27
  114. package/dist/hooks/useNamespaces.js +0 -25
  115. package/dist/hooks/usePipelines.js +0 -161
  116. package/dist/node_modules/@ai-sdk/provider/dist/index.js +0 -65
  117. package/dist/node_modules/@ai-sdk/provider-utils/dist/index.js +0 -1008
  118. package/dist/node_modules/ai/dist/index.js +0 -1083
  119. package/dist/node_modules/zod/v3/ZodError.js +0 -79
  120. package/dist/node_modules/zod/v3/errors.js +0 -6
  121. package/dist/node_modules/zod/v3/helpers/errorUtil.js +0 -5
  122. package/dist/node_modules/zod/v3/helpers/parseUtil.js +0 -90
  123. package/dist/node_modules/zod/v3/helpers/util.js +0 -72
  124. package/dist/node_modules/zod/v3/locales/en.js +0 -58
  125. package/dist/node_modules/zod/v3/types.js +0 -2425
  126. package/dist/node_modules/zod/v4/classic/errors.js +0 -21
  127. package/dist/node_modules/zod/v4/classic/iso.js +0 -29
  128. package/dist/node_modules/zod/v4/classic/parse.js +0 -4
  129. package/dist/node_modules/zod/v4/classic/schemas.js +0 -392
  130. package/dist/node_modules/zod/v4/core/api.js +0 -532
  131. package/dist/node_modules/zod/v4/core/checks.js +0 -283
  132. package/dist/node_modules/zod/v4/core/core.js +0 -44
  133. package/dist/node_modules/zod/v4/core/doc.js +0 -21
  134. package/dist/node_modules/zod/v4/core/errors.js +0 -40
  135. package/dist/node_modules/zod/v4/core/json-schema-processors.js +0 -305
  136. package/dist/node_modules/zod/v4/core/parse.js +0 -66
  137. package/dist/node_modules/zod/v4/core/regexes.js +0 -28
  138. package/dist/node_modules/zod/v4/core/registries.js +0 -38
  139. package/dist/node_modules/zod/v4/core/schemas.js +0 -863
  140. package/dist/node_modules/zod/v4/core/to-json-schema.js +0 -220
  141. package/dist/node_modules/zod/v4/core/util.js +0 -267
  142. package/dist/node_modules/zod/v4/core/versions.js +0 -6
  143. package/dist/packages/contracts/dist/enums/pipeline-state.js +0 -10
  144. package/dist/pages/PipelineDebugPage.js +0 -115
  145. /package/dist/features/debug/components/{pipeline-flow → workflow-flow}/StateNode.js +0 -0
  146. /package/dist/features/debug/components/{pipeline-flow → workflow-flow}/WorkflowTransitionEdge.js +0 -0
  147. /package/dist/features/workspaces/components/{pipeline-form → workflow-form}/HeaderSection.js +0 -0
@@ -11,7 +11,7 @@ function RunItem(a) {
11
11
  paused: "bg-yellow-50 text-yellow-900 border-yellow-200",
12
12
  pending: "bg-muted text-muted-foreground border-border"
13
13
  }[s.status] || "bg-muted text-muted-foreground border-border", d;
14
- o[0] !== l || o[1] !== s.id ? (d = l.getPipeline(s.id), o[0] = l, o[1] = s.id, o[2] = d) : d = o[2];
14
+ o[0] !== l || o[1] !== s.id ? (d = l.getWorkflow(s.id), o[0] = l, o[1] = s.id, o[2] = d) : d = o[2];
15
15
  let f = s.id, p = s.run ?? s.index ?? "?", m = s.title ? `(${s.title})` : "", h;
16
16
  o[3] !== p || o[4] !== m ? (h = /* @__PURE__ */ jsxs("h3", {
17
17
  className: "text-foreground group-hover:text-primary truncate font-semibold transition-colors",
@@ -1,8 +1,8 @@
1
1
  import { Background, BackgroundVariant, Controls, index, useEdgesState, useNodesState, useReactFlow } from "../../../node_modules/@xyflow/react/dist/esm/index.js";
2
2
  /* empty css */
3
- import StateNode_default from "./pipeline-flow/StateNode.js";
3
+ import StateNode_default from "./workflow-flow/StateNode.js";
4
4
  import { buildWorkflowGraph } from "../lib/flow-utils.js";
5
- import WorkflowTransitionEdge_default from "./pipeline-flow/WorkflowTransitionEdge.js";
5
+ import WorkflowTransitionEdge_default from "./workflow-flow/WorkflowTransitionEdge.js";
6
6
  import { c } from "react/compiler-runtime";
7
7
  import React, { useEffect, useRef } from "react";
8
8
  import { jsx, jsxs } from "react/jsx-runtime";
@@ -1,9 +1,9 @@
1
1
  import { Button } from "../../../components/ui/button.js";
2
- import PipelineDebugLegend_default from "./PipelineDebugLegend.js";
2
+ import WorkflowDebugLegend_default from "./WorkflowDebugLegend.js";
3
3
  import { c } from "react/compiler-runtime";
4
4
  import { jsx, jsxs } from "react/jsx-runtime";
5
5
  import { ArrowLeft } from "lucide-react";
6
- var PipelineDebugHeader_default = (o) => {
6
+ var WorkflowDebugHeader_default = (o) => {
7
7
  let s = c(16), { title: l, runNumber: u, onBack: d } = o, f;
8
8
  s[0] === Symbol.for("react.memo_cache_sentinel") ? (f = /* @__PURE__ */ jsx(ArrowLeft, { className: "h-4 w-4" }), s[0] = f) : f = s[0];
9
9
  let p;
@@ -22,7 +22,7 @@ var PipelineDebugHeader_default = (o) => {
22
22
  let h = u && `· Run #${u}`, g;
23
23
  s[5] === h ? g = s[6] : (g = /* @__PURE__ */ jsxs("p", {
24
24
  className: "text-muted-foreground text-xs font-medium tracking-wider uppercase",
25
- children: ["Pipeline Flow Visualization ", h]
25
+ children: ["Workflow Flow Visualization ", h]
26
26
  }), s[5] = h, s[6] = g);
27
27
  let _;
28
28
  s[7] !== m || s[8] !== g ? (_ = /* @__PURE__ */ jsxs("div", {
@@ -37,7 +37,7 @@ var PipelineDebugHeader_default = (o) => {
37
37
  let y;
38
38
  s[13] === Symbol.for("react.memo_cache_sentinel") ? (y = /* @__PURE__ */ jsx("div", {
39
39
  className: "hidden items-center gap-6 sm:flex",
40
- children: /* @__PURE__ */ jsx(PipelineDebugLegend_default, {})
40
+ children: /* @__PURE__ */ jsx(WorkflowDebugLegend_default, {})
41
41
  }), s[13] = y) : y = s[13];
42
42
  let b;
43
43
  return s[14] === v ? b = s[15] : (b = /* @__PURE__ */ jsxs("div", {
@@ -45,4 +45,4 @@ var PipelineDebugHeader_default = (o) => {
45
45
  children: [v, y]
46
46
  }), s[14] = v, s[15] = b), b;
47
47
  };
48
- export { PipelineDebugHeader_default as default };
48
+ export { WorkflowDebugHeader_default as default };
@@ -1,7 +1,7 @@
1
1
  import { c } from "react/compiler-runtime";
2
2
  import React from "react";
3
3
  import { jsx, jsxs } from "react/jsx-runtime";
4
- var PipelineDebugLegend_default = () => {
4
+ var WorkflowDebugLegend_default = () => {
5
5
  let r = c(7), i;
6
6
  r[0] === Symbol.for("react.memo_cache_sentinel") ? (i = /* @__PURE__ */ jsxs("div", {
7
7
  className: "flex items-center gap-2",
@@ -65,4 +65,4 @@ var PipelineDebugLegend_default = () => {
65
65
  ]
66
66
  }), r[6] = d) : d = r[6], d;
67
67
  };
68
- export { PipelineDebugLegend_default as default };
68
+ export { WorkflowDebugLegend_default as default };
@@ -1,15 +1,15 @@
1
- import { usePipeline } from "../../../hooks/usePipelines.js";
1
+ import { useWorkflow } from "../../../hooks/useWorkflows.js";
2
2
  import { Background, BackgroundVariant, Controls, index, useEdgesState, useNodesState, useReactFlow } from "../../../node_modules/@xyflow/react/dist/esm/index.js";
3
3
  /* empty css */
4
- import StateNode_default from "./pipeline-flow/StateNode.js";
5
- import WorkflowGraph_default from "./pipeline-flow/WorkflowGraph.js";
6
- import WorkflowTransitionEdge_default from "./pipeline-flow/WorkflowTransitionEdge.js";
4
+ import StateNode_default from "./workflow-flow/StateNode.js";
5
+ import WorkflowGraph_default from "./workflow-flow/WorkflowGraph.js";
6
+ import WorkflowTransitionEdge_default from "./workflow-flow/WorkflowTransitionEdge.js";
7
7
  import { c } from "react/compiler-runtime";
8
8
  import React, { useCallback, useEffect, useRef, useState } from "react";
9
9
  import { jsx, jsxs } from "react/jsx-runtime";
10
10
  import { Loader2 } from "lucide-react";
11
- var nodeTypes = { stateNode: StateNode_default }, edgeTypes = { workflowTransition: WorkflowTransitionEdge_default }, PipelineFlowViewer_default = (b) => {
12
- let x = c(29), { pipelineId: S, workflows: C, pipelineConfig: w, direction: T } = b, E = T === void 0 ? "LR" : T, { data: D } = usePipeline(S), O;
11
+ var nodeTypes = { stateNode: StateNode_default }, edgeTypes = { workflowTransition: WorkflowTransitionEdge_default }, WorkflowFlowViewer_default = (b) => {
12
+ let x = c(29), { workflowId: S, workflows: C, workflowConfig: w, direction: T } = b, E = T === void 0 ? "LR" : T, { data: D } = useWorkflow(S), O;
13
13
  x[0] === Symbol.for("react.memo_cache_sentinel") ? (O = [], x[0] = O) : O = x[0];
14
14
  let [k, A, j] = useNodesState(O), M;
15
15
  x[1] === Symbol.for("react.memo_cache_sentinel") ? (M = [], x[1] = M) : M = x[1];
@@ -65,9 +65,9 @@ var nodeTypes = { stateNode: StateNode_default }, edgeTypes = { workflowTransiti
65
65
  }
66
66
  let X;
67
67
  x[15] !== E || x[16] !== q || x[17] !== D || x[18] !== w || x[19] !== C ? (X = D && C.map((e) => /* @__PURE__ */ jsx(WorkflowGraph_default, {
68
- pipeline: D,
68
+ parentWorkflow: D,
69
69
  workflow: e,
70
- pipelineConfig: w,
70
+ workflowConfig: w,
71
71
  onGraphReady: q,
72
72
  onLoadingChange: G,
73
73
  direction: E
@@ -107,4 +107,4 @@ var nodeTypes = { stateNode: StateNode_default }, edgeTypes = { workflowTransiti
107
107
  function _temp(e) {
108
108
  return e;
109
109
  }
110
- export { PipelineFlowViewer_default as default };
110
+ export { WorkflowFlowViewer_default as default };
@@ -0,0 +1,46 @@
1
+ import { useWorkflow, useWorkflowCheckpoints } from "../../../../hooks/useWorkflows.js";
2
+ import { buildWorkflowGraph, getTransitions } from "../../lib/flow-utils.js";
3
+ import { c } from "react/compiler-runtime";
4
+ import React, { useEffect, useRef } from "react";
5
+ function countTransitions(e) {
6
+ return e ? getTransitions(e).length : 0;
7
+ }
8
+ var WorkflowGraph_default = (l) => {
9
+ let u = c(24), { parentWorkflow: d, workflow: f, workflowConfig: p, onGraphReady: m, onLoadingChange: h, direction: g } = l, _ = g === void 0 ? "LR" : g, v = useWorkflow(f.id), y = v.data, b = useWorkflowCheckpoints(f.id), x;
10
+ u[0] === b.data ? x = u[1] : (x = b.data ?? [], u[0] = b.data, u[1] = x);
11
+ let S = x, C = useRef(null), w = v.isLoading || b.isLoading, T, E;
12
+ u[2] !== w || u[3] !== h || u[4] !== f.id ? (T = () => {
13
+ h(f.id, w);
14
+ }, E = [
15
+ f.id,
16
+ w,
17
+ h
18
+ ], u[2] = w, u[3] = h, u[4] = f.id, u[5] = T, u[6] = E) : (T = u[5], E = u[6]), useEffect(T, E);
19
+ let D;
20
+ u[7] !== S || u[8] !== _ || u[9] !== w || u[10] !== m || u[11] !== d || u[12] !== f.id || u[13] !== p || u[14] !== y ? (D = () => {
21
+ if (w) return;
22
+ let e = p ? getTransitions(p) : [], a = JSON.stringify({
23
+ p: countTransitions(d),
24
+ w: countTransitions(y),
25
+ c: e.length,
26
+ checkpoints: S.length,
27
+ place: y?.place
28
+ });
29
+ if (a !== C.current) {
30
+ C.current = a;
31
+ let { nodes: o, edges: s } = buildWorkflowGraph(d, y, f.id, e, _, !1, S);
32
+ m(f.id, o, s);
33
+ }
34
+ }, u[7] = S, u[8] = _, u[9] = w, u[10] = m, u[11] = d, u[12] = f.id, u[13] = p, u[14] = y, u[15] = D) : D = u[15];
35
+ let O;
36
+ return u[16] !== S || u[17] !== w || u[18] !== m || u[19] !== d || u[20] !== f || u[21] !== p || u[22] !== y ? (O = [
37
+ d,
38
+ f,
39
+ y,
40
+ S,
41
+ p,
42
+ m,
43
+ w
44
+ ], u[16] = S, u[17] = w, u[18] = m, u[19] = d, u[20] = f, u[21] = p, u[22] = y, u[23] = O) : O = u[23], useEffect(D, O), null;
45
+ };
46
+ export { WorkflowGraph_default as default };
@@ -1,3 +1,3 @@
1
- import PipelineFlowViewer_default from "./components/PipelineFlowViewer.js";
2
- import PipelineDebugHeader_default from "./components/PipelineDebugHeader.js";
1
+ import WorkflowFlowViewer_default from "./components/WorkflowFlowViewer.js";
2
+ import WorkflowDebugHeader_default from "./components/WorkflowDebugHeader.js";
3
3
  import ConfigFlowViewer_default from "./components/ConfigFlowViewer.js";
@@ -8,59 +8,59 @@ var NODE_WIDTH = 130, NODE_HEIGHT = 70, CONDITION_OPERATORS = {
8
8
  ge: ">=",
9
9
  le: "<="
10
10
  };
11
- function getLayoutedElements(e, d, f = "LR") {
12
- let p = new dagre_esm_default.graphlib.Graph().setDefaultEdgeLabel(() => ({}));
13
- p.setGraph({
14
- rankdir: f,
11
+ function getLayoutedElements(e, u, d = "LR") {
12
+ let f = new dagre_esm_default.graphlib.Graph().setDefaultEdgeLabel(() => ({}));
13
+ f.setGraph({
14
+ rankdir: d,
15
15
  nodesep: 100,
16
16
  ranksep: 200
17
17
  });
18
- for (let s of e) p.setNode(s.id, {
18
+ for (let o of e) f.setNode(o.id, {
19
19
  width: NODE_WIDTH,
20
20
  height: NODE_HEIGHT
21
21
  });
22
- for (let e of d) p.setEdge(e.source, e.target);
23
- return dagre_esm_default.layout(p), {
22
+ for (let e of u) f.setEdge(e.source, e.target);
23
+ return dagre_esm_default.layout(f), {
24
24
  nodes: e.map((e) => {
25
- let c = p.node(e.id);
25
+ let s = f.node(e.id);
26
26
  return {
27
27
  ...e,
28
- targetPosition: f === "LR" ? Position.Left : Position.Top,
29
- sourcePosition: f === "LR" ? Position.Right : Position.Bottom,
28
+ targetPosition: d === "LR" ? Position.Left : Position.Top,
29
+ sourcePosition: d === "LR" ? Position.Right : Position.Bottom,
30
30
  position: {
31
- x: c.x - NODE_WIDTH / 2,
32
- y: c.y - NODE_HEIGHT / 2
31
+ x: s.x - NODE_WIDTH / 2,
32
+ y: s.y - NODE_HEIGHT / 2
33
33
  }
34
34
  };
35
35
  }),
36
- edges: d
36
+ edges: u
37
37
  };
38
38
  }
39
- function getTransitions(e, s = /* @__PURE__ */ new Set()) {
40
- if (!e || typeof e != "object" || s.has(e)) return [];
39
+ function getTransitions(e, o = /* @__PURE__ */ new Set()) {
40
+ if (!e || typeof e != "object" || o.has(e)) return [];
41
41
  try {
42
- s.add(e);
42
+ o.add(e);
43
43
  } catch {
44
44
  return [];
45
45
  }
46
- let c = e;
47
- if (Array.isArray(c.transitions)) return c.transitions;
48
- if (c.definition) {
49
- let e = getTransitions(c.definition, s);
46
+ let s = e;
47
+ if (Array.isArray(s.transitions)) return s.transitions;
48
+ if (s.definition) {
49
+ let e = getTransitions(s.definition, o);
50
50
  if (e.length > 0) return e;
51
51
  }
52
- if (c.specification) {
53
- let e = getTransitions(c.specification, s);
52
+ if (s.specification) {
53
+ let e = getTransitions(s.specification, o);
54
54
  if (e.length > 0) return e;
55
55
  }
56
- for (let e in c) {
56
+ for (let e in s) {
57
57
  if (e === "history" || e === "data") continue;
58
- let l = c[e];
59
- if (l && typeof l == "object") {
60
- let e = getTransitions(l, s);
58
+ let c = s[e];
59
+ if (c && typeof c == "object") {
60
+ let e = getTransitions(c, o);
61
61
  if (e.length > 0) return e;
62
- } else if (typeof l == "string" && l.includes("\"transitions\":")) try {
63
- let e = getTransitions(JSON.parse(l), s);
62
+ } else if (typeof c == "string" && c.includes("\"transitions\":")) try {
63
+ let e = getTransitions(JSON.parse(c), o);
64
64
  if (e.length > 0) return e;
65
65
  } catch {}
66
66
  }
@@ -68,125 +68,117 @@ function getTransitions(e, s = /* @__PURE__ */ new Set()) {
68
68
  }
69
69
  function formatCondition(e) {
70
70
  if (!e) return "";
71
- let s = e.replace(/\{\{|\}\}/g, "").trim(), c = s.split(/\s+/);
72
- if (c.length === 3) {
73
- let [e, s, l] = c, u = CONDITION_OPERATORS[e];
74
- if (u) return `${s} ${u} ${l}`;
71
+ let o = e.replace(/\{\{|\}\}/g, "").trim(), s = o.split(/\s+/);
72
+ if (s.length === 3) {
73
+ let [e, o, c] = s, l = CONDITION_OPERATORS[e];
74
+ if (l) return `${o} ${l} ${c}`;
75
75
  }
76
- return s;
76
+ return o;
77
77
  }
78
- function buildWorkflowGraph(e, s, c, l = [], u, d = !1) {
79
- let p = collectTransitions(e, s, l), m = extractHistory(s), h = collectStates(p, m), x = buildExecutedMap(m), S = resolveTransitions(p, m), C = findEndStates(h, S), w = findVisitedStates(m), T = computeStateRanks(S), E = buildNodes(h, {
80
- workflowId: c,
81
- currentPlace: s?.place,
82
- endStates: C,
83
- visitedStates: w,
84
- visitCounts: buildVisitCounts(m),
85
- direction: u,
86
- forceVisible: d
87
- }), D = buildEdges(S, {
88
- workflowId: c,
89
- executedMap: x,
90
- stateRanks: T,
91
- forceVisible: d
78
+ function buildWorkflowGraph(e, o, s, c = [], l, u = !1, f = []) {
79
+ let p = collectTransitions(e, o, c), m = collectStates(p, f), b = buildExecutedMap(f), x = resolveTransitions(p, f), S = findEndStates(m, x), C = findVisitedStates(f), w = computeStateRanks(x), T = buildNodes(m, {
80
+ workflowId: s,
81
+ currentPlace: o?.place,
82
+ endStates: S,
83
+ visitedStates: C,
84
+ visitCounts: buildVisitCounts(f),
85
+ direction: l,
86
+ forceVisible: u
87
+ }), E = buildEdges(x, {
88
+ workflowId: s,
89
+ executedMap: b,
90
+ stateRanks: w,
91
+ forceVisible: u
92
92
  });
93
- return E.length > 1 ? getLayoutedElements(E, D, u) : {
94
- nodes: E,
95
- edges: D
93
+ return T.length > 1 ? getLayoutedElements(T, E, l) : {
94
+ nodes: T,
95
+ edges: E
96
96
  };
97
97
  }
98
- function collectTransitions(e, s, c) {
99
- let l = [...c];
100
- e && l.push(...getTransitions(e)), s && l.push(...getTransitions(s));
101
- let u = /* @__PURE__ */ new Set();
102
- return l.filter((e) => {
103
- let s = Array.isArray(e.from) ? e.from.join(",") : e.from, c = `${e.id}-${s}-${e.to}`;
104
- return u.has(c) ? !1 : (u.add(c), !0);
98
+ function collectTransitions(e, o, s) {
99
+ let c = [...s];
100
+ e && c.push(...getTransitions(e)), o && c.push(...getTransitions(o));
101
+ let l = /* @__PURE__ */ new Set();
102
+ return c.filter((e) => {
103
+ let o = Array.isArray(e.from) ? e.from.join(",") : e.from, s = `${e.id}-${o}-${e.to}`;
104
+ return l.has(s) ? !1 : (l.add(s), !0);
105
105
  });
106
106
  }
107
- function extractHistory(e) {
108
- return e?.history ?? [];
109
- }
110
- function collectStates(e, s) {
111
- let c = new Set(["start"]);
112
- for (let s of e) {
113
- let e = Array.isArray(s.from) ? s.from : [s.from];
114
- for (let s of e) c.add(s ?? "start");
115
- c.add(s.to);
107
+ function collectStates(e, o) {
108
+ let s = new Set(["start"]);
109
+ for (let o of e) {
110
+ let e = Array.isArray(o.from) ? o.from : [o.from];
111
+ for (let o of e) s.add(o ?? "start");
112
+ s.add(o.to);
116
113
  }
117
- for (let e of s) e.data?.place && c.add(e.data.place), e.data?.transition && (c.add(e.data.transition.from ?? "start"), c.add(e.data.transition.to));
118
- return c;
114
+ for (let e of o) e.place && s.add(e.place), e.transitionFrom && s.add(e.transitionFrom);
115
+ return s;
119
116
  }
120
117
  function buildVisitCounts(e) {
121
- let s = new Map([["start", 1]]);
122
- for (let c of e) {
123
- let e = c.data?.place;
124
- e && s.set(e, (s.get(e) ?? 0) + 1);
125
- }
126
- return s;
118
+ let o = new Map([["start", 1]]);
119
+ for (let s of e) s.place && o.set(s.place, (o.get(s.place) ?? 0) + 1);
120
+ return o;
127
121
  }
128
122
  function buildExecutedMap(e) {
129
- let s = /* @__PURE__ */ new Map();
130
- for (let c of e) {
131
- let e = c.data?.transition;
132
- if (!e) continue;
133
- let l = `${e.from ?? "start"}->${e.to}:${e.id}`;
134
- s.set(l, (s.get(l) ?? 0) + 1);
123
+ let o = /* @__PURE__ */ new Map();
124
+ for (let s of e) {
125
+ if (!s.transitionId) continue;
126
+ let e = `${s.transitionFrom ?? "start"}->${s.place}:${s.transitionId}`;
127
+ o.set(e, (o.get(e) ?? 0) + 1);
135
128
  }
136
- return s;
129
+ return o;
137
130
  }
138
- function resolveTransitions(e, s) {
139
- let c = [];
140
- for (let s of e) {
141
- let e = Array.isArray(s.from) ? s.from : [s.from], l = s;
142
- for (let u of e) c.push({
143
- id: s.id,
144
- from: u ?? "start",
145
- to: s.to,
146
- condition: l.if ?? l.condition,
147
- trigger: s.trigger,
148
- call: s.call
131
+ function resolveTransitions(e, o) {
132
+ let s = [];
133
+ for (let o of e) {
134
+ let e = Array.isArray(o.from) ? o.from : [o.from], c = o;
135
+ for (let l of e) s.push({
136
+ id: o.id,
137
+ from: l ?? "start",
138
+ to: o.to,
139
+ condition: c.if ?? c.condition,
140
+ trigger: o.trigger,
141
+ call: o.call
149
142
  });
150
143
  }
151
- for (let e of s) {
152
- let s = e.data?.transition;
153
- if (!s?.id) continue;
154
- let l = s.from ?? "start";
155
- c.some((e) => e.from === l && e.to === s.to && e.id === s.id) || c.push({
156
- id: s.id,
157
- from: l,
158
- to: s.to
144
+ for (let e of o) {
145
+ if (!e.transitionId) continue;
146
+ let o = e.transitionFrom ?? "start";
147
+ s.some((s) => s.from === o && s.to === e.place && s.id === e.transitionId) || s.push({
148
+ id: e.transitionId,
149
+ from: o,
150
+ to: e.place
159
151
  });
160
152
  }
161
- return c;
153
+ return s;
162
154
  }
163
- function findEndStates(e, s) {
164
- let c = new Set(s.map((e) => e.from)), l = /* @__PURE__ */ new Set();
165
- for (let s of e) !c.has(s) && s !== "start" && l.add(s);
166
- return l;
155
+ function findEndStates(e, o) {
156
+ let s = new Set(o.map((e) => e.from)), c = /* @__PURE__ */ new Set();
157
+ for (let o of e) !s.has(o) && o !== "start" && c.add(o);
158
+ return c;
167
159
  }
168
160
  function findVisitedStates(e) {
169
- let s = new Set(["start"]);
170
- for (let c of e) c.data?.place && s.add(c.data.place), c.data?.transition?.to && s.add(c.data.transition.to);
171
- return s;
161
+ let o = new Set(["start"]);
162
+ for (let s of e) s.place && o.add(s.place);
163
+ return o;
172
164
  }
173
165
  function computeStateRanks(e) {
174
- let s = /* @__PURE__ */ new Map();
175
- for (let c of e) {
176
- if (c.from === c.to) continue;
177
- let e = s.get(c.from) ?? [];
178
- e.push(c.to), s.set(c.from, e);
166
+ let o = /* @__PURE__ */ new Map();
167
+ for (let s of e) {
168
+ if (s.from === s.to) continue;
169
+ let e = o.get(s.from) ?? [];
170
+ e.push(s.to), o.set(s.from, e);
179
171
  }
180
- let c = new Map([["start", 0]]), l = ["start"];
181
- for (; l.length > 0;) {
182
- let e = l.shift(), u = c.get(e);
183
- for (let d of s.get(e) ?? []) c.has(d) || (c.set(d, u + 1), l.push(d));
172
+ let s = new Map([["start", 0]]), c = ["start"];
173
+ for (; c.length > 0;) {
174
+ let e = c.shift(), l = s.get(e);
175
+ for (let u of o.get(e) ?? []) s.has(u) || (s.set(u, l + 1), c.push(u));
184
176
  }
185
- return c;
177
+ return s;
186
178
  }
187
- function buildNodes(e, s) {
179
+ function buildNodes(e, o) {
188
180
  return Array.from(e).map((e) => ({
189
- id: `${s.workflowId}-${e}`,
181
+ id: `${o.workflowId}-${e}`,
190
182
  type: "stateNode",
191
183
  position: {
192
184
  x: 0,
@@ -195,53 +187,53 @@ function buildNodes(e, s) {
195
187
  data: {
196
188
  label: e,
197
189
  isStart: e === "start",
198
- isEnd: s.endStates.has(e),
199
- isCurrent: e === s.currentPlace,
200
- isVisited: s.visitedStates.has(e),
201
- visitCount: s.visitCounts.get(e) ?? 0,
202
- direction: s.direction,
203
- forceVisible: s.forceVisible
190
+ isEnd: o.endStates.has(e),
191
+ isCurrent: e === o.currentPlace,
192
+ isVisited: o.visitedStates.has(e),
193
+ visitCount: o.visitCounts.get(e) ?? 0,
194
+ direction: o.direction,
195
+ forceVisible: o.forceVisible
204
196
  }
205
197
  }));
206
198
  }
207
- function buildEdges(s, c) {
208
- let l = /* @__PURE__ */ new Set(), u = [], d = 0;
209
- for (let f of s) {
210
- let s = `${f.from}->${f.to}:${f.id}`;
211
- if (l.has(s)) continue;
212
- l.add(s);
213
- let p = c.executedMap.has(s), m = f.trigger === "onEntry", h = f.from === f.to, g = c.stateRanks.get(f.from) ?? 0, _ = c.stateRanks.get(f.to) ?? 0, v = !h && _ <= g, y = p ? "var(--primary)" : "var(--muted-foreground)", b = {
214
- ...f,
215
- isExecuted: p,
216
- isSelfLoop: h,
217
- isBackEdge: v,
218
- forceVisible: c.forceVisible
199
+ function buildEdges(o, s) {
200
+ let c = /* @__PURE__ */ new Set(), l = [], u = 0;
201
+ for (let d of o) {
202
+ let o = `${d.from}->${d.to}:${d.id}`;
203
+ if (c.has(o)) continue;
204
+ c.add(o);
205
+ let f = s.executedMap.has(o), p = d.trigger === "onEntry", m = d.from === d.to, h = s.stateRanks.get(d.from) ?? 0, g = s.stateRanks.get(d.to) ?? 0, _ = !m && g <= h, v = f ? "var(--primary)" : "var(--muted-foreground)", y = {
206
+ ...d,
207
+ isExecuted: f,
208
+ isSelfLoop: m,
209
+ isBackEdge: _,
210
+ forceVisible: s.forceVisible
219
211
  };
220
- u.push({
221
- id: `edge-${c.workflowId}-${d++}`,
222
- source: `${c.workflowId}-${f.from}`,
223
- target: `${c.workflowId}-${f.to}`,
224
- ...v && {
212
+ l.push({
213
+ id: `edge-${s.workflowId}-${u++}`,
214
+ source: `${s.workflowId}-${d.from}`,
215
+ target: `${s.workflowId}-${d.to}`,
216
+ ..._ && {
225
217
  sourceHandle: "bottom-source",
226
218
  targetHandle: "bottom-target"
227
219
  },
228
220
  type: "workflowTransition",
229
221
  animated: !1,
230
222
  style: {
231
- strokeWidth: p ? 2.5 : 1.5,
232
- stroke: y,
233
- strokeDasharray: m ? "4,4" : p ? void 0 : "5,5",
234
- opacity: p || c.forceVisible ? 1 : .3
223
+ strokeWidth: f ? 2.5 : 1.5,
224
+ stroke: v,
225
+ strokeDasharray: p ? "4,4" : f ? void 0 : "5,5",
226
+ opacity: f || s.forceVisible ? 1 : .3
235
227
  },
236
228
  markerEnd: {
237
229
  type: MarkerType.ArrowClosed,
238
230
  width: 18,
239
231
  height: 18,
240
- color: y
232
+ color: v
241
233
  },
242
- data: b
234
+ data: y
243
235
  });
244
236
  }
245
- return u;
237
+ return l;
246
238
  }
247
239
  export { buildWorkflowGraph, formatCondition, getTransitions };