orcheo-canvas 0.0.1

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 (475) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +32 -0
  3. package/components.json +21 -0
  4. package/dist/assets/index-C8cjvUcR.js +772 -0
  5. package/dist/assets/index-D_Md8dhB.css +1 -0
  6. package/dist/favicon.drawio +83 -0
  7. package/dist/favicon.png +0 -0
  8. package/dist/favicon.svg +4 -0
  9. package/dist/index.html +19 -0
  10. package/eslint.config.js +28 -0
  11. package/index.html +18 -0
  12. package/package.json +165 -0
  13. package/postcss.config.js +6 -0
  14. package/public/favicon.drawio +83 -0
  15. package/public/favicon.png +0 -0
  16. package/public/favicon.svg +4 -0
  17. package/src/App.test.tsx +10 -0
  18. package/src/App.tsx +43 -0
  19. package/src/assets/react.svg +1 -0
  20. package/src/design-system/ui/accordion.tsx +57 -0
  21. package/src/design-system/ui/alert-dialog.tsx +141 -0
  22. package/src/design-system/ui/alert.tsx +59 -0
  23. package/src/design-system/ui/aspect-ratio.tsx +7 -0
  24. package/src/design-system/ui/avatar.tsx +50 -0
  25. package/src/design-system/ui/badge.tsx +37 -0
  26. package/src/design-system/ui/breadcrumb.tsx +115 -0
  27. package/src/design-system/ui/button.tsx +58 -0
  28. package/src/design-system/ui/calendar.tsx +76 -0
  29. package/src/design-system/ui/card.tsx +83 -0
  30. package/src/design-system/ui/carousel/carousel-context.ts +17 -0
  31. package/src/design-system/ui/carousel/carousel-navigation.tsx +65 -0
  32. package/src/design-system/ui/carousel/carousel-provider.tsx +18 -0
  33. package/src/design-system/ui/carousel/carousel-root.tsx +119 -0
  34. package/src/design-system/ui/carousel/carousel-slides.tsx +49 -0
  35. package/src/design-system/ui/carousel/types.ts +24 -0
  36. package/src/design-system/ui/carousel.tsx +6 -0
  37. package/src/design-system/ui/chart-context-shared.ts +27 -0
  38. package/src/design-system/ui/chart-context.tsx +81 -0
  39. package/src/design-system/ui/chart-legend.tsx +68 -0
  40. package/src/design-system/ui/chart-tooltip.tsx +164 -0
  41. package/src/design-system/ui/chart-utils.ts +39 -0
  42. package/src/design-system/ui/chart.tsx +3 -0
  43. package/src/design-system/ui/checkbox.tsx +30 -0
  44. package/src/design-system/ui/collapsible.tsx +11 -0
  45. package/src/design-system/ui/command.tsx +153 -0
  46. package/src/design-system/ui/context-menu.tsx +200 -0
  47. package/src/design-system/ui/dialog.tsx +122 -0
  48. package/src/design-system/ui/drawer.tsx +118 -0
  49. package/src/design-system/ui/dropdown-menu.tsx +201 -0
  50. package/src/design-system/ui/form.tsx +180 -0
  51. package/src/design-system/ui/hover-card.tsx +29 -0
  52. package/src/design-system/ui/input-otp.tsx +71 -0
  53. package/src/design-system/ui/input.tsx +22 -0
  54. package/src/design-system/ui/label.tsx +26 -0
  55. package/src/design-system/ui/menubar-content.tsx +85 -0
  56. package/src/design-system/ui/menubar-items.tsx +123 -0
  57. package/src/design-system/ui/menubar-root.tsx +60 -0
  58. package/src/design-system/ui/menubar.tsx +26 -0
  59. package/src/design-system/ui/navigation-menu.tsx +129 -0
  60. package/src/design-system/ui/pagination.tsx +117 -0
  61. package/src/design-system/ui/popover.tsx +33 -0
  62. package/src/design-system/ui/progress.tsx +28 -0
  63. package/src/design-system/ui/radio-group.tsx +44 -0
  64. package/src/design-system/ui/resizable.tsx +45 -0
  65. package/src/design-system/ui/scroll-area.tsx +48 -0
  66. package/src/design-system/ui/select.tsx +159 -0
  67. package/src/design-system/ui/separator.tsx +31 -0
  68. package/src/design-system/ui/sheet.tsx +140 -0
  69. package/src/design-system/ui/sidebar/constants.ts +6 -0
  70. package/src/design-system/ui/sidebar/sidebar-context.ts +15 -0
  71. package/src/design-system/ui/sidebar/sidebar-layout.tsx +216 -0
  72. package/src/design-system/ui/sidebar/sidebar-menu/index.ts +11 -0
  73. package/src/design-system/ui/sidebar/sidebar-menu/menu-action.tsx +35 -0
  74. package/src/design-system/ui/sidebar/sidebar-menu/menu-badge.tsx +28 -0
  75. package/src/design-system/ui/sidebar/sidebar-menu/menu-button-variants.ts +25 -0
  76. package/src/design-system/ui/sidebar/sidebar-menu/menu-button.tsx +73 -0
  77. package/src/design-system/ui/sidebar/sidebar-menu/menu-skeleton.tsx +45 -0
  78. package/src/design-system/ui/sidebar/sidebar-menu/menu-sub.tsx +61 -0
  79. package/src/design-system/ui/sidebar/sidebar-menu/menu.tsx +33 -0
  80. package/src/design-system/ui/sidebar/sidebar-provider.tsx +132 -0
  81. package/src/design-system/ui/sidebar/sidebar-structure.tsx +152 -0
  82. package/src/design-system/ui/sidebar/use-sidebar.ts +14 -0
  83. package/src/design-system/ui/sidebar.ts +35 -0
  84. package/src/design-system/ui/skeleton.tsx +15 -0
  85. package/src/design-system/ui/slider.tsx +28 -0
  86. package/src/design-system/ui/sonner.tsx +31 -0
  87. package/src/design-system/ui/switch.tsx +29 -0
  88. package/src/design-system/ui/table.tsx +120 -0
  89. package/src/design-system/ui/tabs.tsx +55 -0
  90. package/src/design-system/ui/textarea.tsx +22 -0
  91. package/src/design-system/ui/toast.tsx +129 -0
  92. package/src/design-system/ui/toaster.tsx +35 -0
  93. package/src/design-system/ui/toggle-group.tsx +61 -0
  94. package/src/design-system/ui/toggle.tsx +46 -0
  95. package/src/design-system/ui/tooltip.tsx +32 -0
  96. package/src/features/account/components/settings/appearance-settings-tab.tsx +70 -0
  97. package/src/features/account/components/settings/application-settings-tab.tsx +146 -0
  98. package/src/features/account/components/settings/notification-settings-tab.tsx +157 -0
  99. package/src/features/account/components/settings/team-billing-settings-tab.tsx +164 -0
  100. package/src/features/account/components/theme-settings.tsx +228 -0
  101. package/src/features/account/components/use-theme-preferences.ts +111 -0
  102. package/src/features/account/pages/profile/components/profile-api-keys-tab.tsx +59 -0
  103. package/src/features/account/pages/profile/components/profile-general-tab.tsx +125 -0
  104. package/src/features/account/pages/profile/components/profile-security-tab.tsx +114 -0
  105. package/src/features/account/pages/profile/types.ts +8 -0
  106. package/src/features/account/pages/profile.tsx +64 -0
  107. package/src/features/account/pages/settings.tsx +58 -0
  108. package/src/features/auth/components/auth-logos.tsx +61 -0
  109. package/src/features/auth/components/auth-page.tsx +213 -0
  110. package/src/features/auth/pages/login.tsx +5 -0
  111. package/src/features/auth/pages/signup.tsx +5 -0
  112. package/src/features/chatkit/components/canvas-chat-bubble.tsx +324 -0
  113. package/src/features/chatkit/components/chatkit-surface.tsx +18 -0
  114. package/src/features/chatkit/components/public-chat-error-boundary.tsx +74 -0
  115. package/src/features/chatkit/components/public-chat-widget.tsx +138 -0
  116. package/src/features/chatkit/lib/chatkit-client.test.ts +98 -0
  117. package/src/features/chatkit/lib/chatkit-client.ts +175 -0
  118. package/src/features/chatkit/lib/chatkit-theme.ts +20 -0
  119. package/src/features/chatkit/lib/telemetry.ts +29 -0
  120. package/src/features/chatkit/lib/workflow-session.ts +69 -0
  121. package/src/features/chatkit/pages/public-chat.tsx +391 -0
  122. package/src/features/shared/components/chat-input/attachment-preview.tsx +78 -0
  123. package/src/features/shared/components/chat-input/chat-input-types.ts +13 -0
  124. package/src/features/shared/components/chat-input/emoji-picker.tsx +106 -0
  125. package/src/features/shared/components/chat-input.tsx +234 -0
  126. package/src/features/shared/components/chat-interface-options.ts +305 -0
  127. package/src/features/shared/components/chat-interface.tsx +162 -0
  128. package/src/features/shared/components/chat-interface.types.ts +36 -0
  129. package/src/features/shared/components/chat-message-attachments.tsx +122 -0
  130. package/src/features/shared/components/chat-message-markdown.ts +33 -0
  131. package/src/features/shared/components/chat-message.tsx +128 -0
  132. package/src/features/shared/components/top-navigation/account-menu.tsx +101 -0
  133. package/src/features/shared/components/top-navigation/command-palette-button.tsx +78 -0
  134. package/src/features/shared/components/top-navigation/project-switcher.tsx +64 -0
  135. package/src/features/shared/components/top-navigation/top-navigation-types.ts +16 -0
  136. package/src/features/shared/components/top-navigation/use-window-width.ts +24 -0
  137. package/src/features/shared/components/top-navigation/workflow-breadcrumbs.tsx +107 -0
  138. package/src/features/shared/components/top-navigation.tsx +52 -0
  139. package/src/features/support/components/support-chat-callout.tsx +40 -0
  140. package/src/features/support/components/support-header.tsx +53 -0
  141. package/src/features/support/components/support-help-tabs.tsx +172 -0
  142. package/src/features/support/components/support-resources.tsx +157 -0
  143. package/src/features/support/pages/help-support.tsx +72 -0
  144. package/src/features/workflow/components/canvas/annotations-layer/annotation-composer.tsx +109 -0
  145. package/src/features/workflow/components/canvas/annotations-layer/annotation-item.tsx +141 -0
  146. package/src/features/workflow/components/canvas/annotations-layer/annotation-list.tsx +30 -0
  147. package/src/features/workflow/components/canvas/annotations-layer/types.ts +10 -0
  148. package/src/features/workflow/components/canvas/annotations-layer.tsx +99 -0
  149. package/src/features/workflow/components/canvas/breakpoints-layer.tsx +148 -0
  150. package/src/features/workflow/components/canvas/connection-validator.tsx +230 -0
  151. package/src/features/workflow/components/canvas/custom-edge.tsx +154 -0
  152. package/src/features/workflow/components/canvas/edge-hover-context.tsx +11 -0
  153. package/src/features/workflow/components/canvas/mini-map.tsx +111 -0
  154. package/src/features/workflow/components/canvas/split-pane.tsx +165 -0
  155. package/src/features/workflow/components/canvas/time-travel-debugger.tsx +164 -0
  156. package/src/features/workflow/components/canvas/time-travel-header.tsx +45 -0
  157. package/src/features/workflow/components/canvas/time-travel-playback-controls.tsx +174 -0
  158. package/src/features/workflow/components/canvas/time-travel-state-details.tsx +63 -0
  159. package/src/features/workflow/components/canvas/time-travel-timeline.tsx +80 -0
  160. package/src/features/workflow/components/canvas/time-travel-types.ts +18 -0
  161. package/src/features/workflow/components/canvas/workflow-context-menu.tsx +179 -0
  162. package/src/features/workflow/components/canvas/workflow-controls/action-control-group.tsx +219 -0
  163. package/src/features/workflow/components/canvas/workflow-controls/history-control-group.tsx +84 -0
  164. package/src/features/workflow/components/canvas/workflow-controls/types.ts +18 -0
  165. package/src/features/workflow/components/canvas/workflow-controls.tsx +50 -0
  166. package/src/features/workflow/components/canvas/workflow-flow.tsx +214 -0
  167. package/src/features/workflow/components/canvas/workflow-search.tsx +152 -0
  168. package/src/features/workflow/components/dialogs/add-credential-dialog.tsx +233 -0
  169. package/src/features/workflow/components/dialogs/add-notification-channel-dialog.tsx +230 -0
  170. package/src/features/workflow/components/dialogs/command-palette-items.tsx +77 -0
  171. package/src/features/workflow/components/dialogs/command-palette-types.ts +13 -0
  172. package/src/features/workflow/components/dialogs/command-palette-utils.ts +44 -0
  173. package/src/features/workflow/components/dialogs/command-palette.tsx +195 -0
  174. package/src/features/workflow/components/dialogs/credential-access-badge.tsx +44 -0
  175. package/src/features/workflow/components/dialogs/credential-status-badge.tsx +45 -0
  176. package/src/features/workflow/components/dialogs/credentials-table.tsx +234 -0
  177. package/src/features/workflow/components/dialogs/credentials-vault.tsx +63 -0
  178. package/src/features/workflow/components/dialogs/notification-channel-card.tsx +106 -0
  179. package/src/features/workflow/components/dialogs/notification-event-toggles.tsx +95 -0
  180. package/src/features/workflow/components/dialogs/notification-settings.tsx +108 -0
  181. package/src/features/workflow/components/dialogs/notification-settings.types.ts +34 -0
  182. package/src/features/workflow/components/dialogs/use-command-palette-navigation.ts +60 -0
  183. package/src/features/workflow/components/dialogs/user-role-management/invite-user-dialog.tsx +152 -0
  184. package/src/features/workflow/components/dialogs/user-role-management/role-badges.tsx +83 -0
  185. package/src/features/workflow/components/dialogs/user-role-management/user-role-table.tsx +188 -0
  186. package/src/features/workflow/components/dialogs/user-role-management/user-role-types.ts +20 -0
  187. package/src/features/workflow/components/dialogs/user-role-management.tsx +61 -0
  188. package/src/features/workflow/components/dialogs/version-control-dialog.tsx +232 -0
  189. package/src/features/workflow/components/layouts/sidebar-layout.tsx +208 -0
  190. package/src/features/workflow/components/layouts/use-sidebar-resize.ts +83 -0
  191. package/src/features/workflow/components/layouts/workflow-page-layout.tsx +69 -0
  192. package/src/features/workflow/components/nodes/chat-trigger-node.tsx +106 -0
  193. package/src/features/workflow/components/nodes/group-node.tsx +195 -0
  194. package/src/features/workflow/components/nodes/node-label.tsx +105 -0
  195. package/src/features/workflow/components/nodes/start-end-node.tsx +68 -0
  196. package/src/features/workflow/components/nodes/sticky-note-node.tsx +246 -0
  197. package/src/features/workflow/components/nodes/workflow-node-controls.tsx +91 -0
  198. package/src/features/workflow/components/nodes/workflow-node-handle-config.ts +22 -0
  199. package/src/features/workflow/components/nodes/workflow-node-handles.tsx +79 -0
  200. package/src/features/workflow/components/nodes/workflow-node-style.tsx +50 -0
  201. package/src/features/workflow/components/nodes/workflow-node.tsx +147 -0
  202. package/src/features/workflow/components/nodes/workflow-node.types.ts +32 -0
  203. package/src/features/workflow/components/panels/node-inspector/config-panel.tsx +130 -0
  204. package/src/features/workflow/components/panels/node-inspector/index.tsx +225 -0
  205. package/src/features/workflow/components/panels/node-inspector/input-panel.tsx +199 -0
  206. package/src/features/workflow/components/panels/node-inspector/live-data-unavailable.tsx +26 -0
  207. package/src/features/workflow/components/panels/node-inspector/node-inspector-layout.tsx +251 -0
  208. package/src/features/workflow/components/panels/node-inspector/output-panel.tsx +165 -0
  209. package/src/features/workflow/components/panels/node-inspector/schema-fields.ts +39 -0
  210. package/src/features/workflow/components/panels/node-inspector/types.ts +31 -0
  211. package/src/features/workflow/components/panels/node-inspector/use-node-tester.ts +209 -0
  212. package/src/features/workflow/components/panels/node-inspector/utils.ts +82 -0
  213. package/src/features/workflow/components/panels/rjsf-basic-widgets.tsx +21 -0
  214. package/src/features/workflow/components/panels/rjsf-condition-widgets.tsx +241 -0
  215. package/src/features/workflow/components/panels/rjsf-input-widgets.tsx +105 -0
  216. package/src/features/workflow/components/panels/rjsf-templates.tsx +146 -0
  217. package/src/features/workflow/components/panels/rjsf-text-widgets.tsx +139 -0
  218. package/src/features/workflow/components/panels/rjsf-theme.tsx +16 -0
  219. package/src/features/workflow/components/panels/schema-dnd.ts +79 -0
  220. package/src/features/workflow/components/panels/sidebar-node-item.tsx +42 -0
  221. package/src/features/workflow/components/panels/sidebar-nodes/actions.tsx +34 -0
  222. package/src/features/workflow/components/panels/sidebar-nodes/ai.tsx +40 -0
  223. package/src/features/workflow/components/panels/sidebar-nodes/data.tsx +53 -0
  224. package/src/features/workflow/components/panels/sidebar-nodes/index.ts +2 -0
  225. package/src/features/workflow/components/panels/sidebar-nodes/logic.tsx +127 -0
  226. package/src/features/workflow/components/panels/sidebar-nodes/node-categories.tsx +19 -0
  227. package/src/features/workflow/components/panels/sidebar-nodes/node-lists.ts +71 -0
  228. package/src/features/workflow/components/panels/sidebar-nodes/special.tsx +44 -0
  229. package/src/features/workflow/components/panels/sidebar-nodes/triggers.tsx +44 -0
  230. package/src/features/workflow/components/panels/sidebar-nodes/visualization.tsx +33 -0
  231. package/src/features/workflow/components/panels/sidebar-panel.tsx +243 -0
  232. package/src/features/workflow/components/panels/sidebar-panel.types.ts +73 -0
  233. package/src/features/workflow/components/panels/variable-inspector-table.tsx +99 -0
  234. package/src/features/workflow/components/panels/variable-inspector-tree.tsx +193 -0
  235. package/src/features/workflow/components/panels/variable-inspector-types.ts +3 -0
  236. package/src/features/workflow/components/panels/variable-inspector.tsx +189 -0
  237. package/src/features/workflow/components/panels/workflow-diff-dialog.tsx +207 -0
  238. package/src/features/workflow/components/panels/workflow-execution-details.tsx +118 -0
  239. package/src/features/workflow/components/panels/workflow-execution-history.hooks.ts +116 -0
  240. package/src/features/workflow/components/panels/workflow-execution-history.tsx +150 -0
  241. package/src/features/workflow/components/panels/workflow-execution-history.types.ts +53 -0
  242. package/src/features/workflow/components/panels/workflow-execution-history.utils.ts +195 -0
  243. package/src/features/workflow/components/panels/workflow-execution-sidebar.tsx +221 -0
  244. package/src/features/workflow/components/panels/workflow-governance-panel/subworkflow-list-card.tsx +147 -0
  245. package/src/features/workflow/components/panels/workflow-governance-panel/types.ts +26 -0
  246. package/src/features/workflow/components/panels/workflow-governance-panel/validation-section.tsx +126 -0
  247. package/src/features/workflow/components/panels/workflow-governance-panel.tsx +43 -0
  248. package/src/features/workflow/components/panels/workflow-history-filters.tsx +62 -0
  249. package/src/features/workflow/components/panels/workflow-history-footer.tsx +28 -0
  250. package/src/features/workflow/components/panels/workflow-history-header.tsx +47 -0
  251. package/src/features/workflow/components/panels/workflow-history-table.tsx +148 -0
  252. package/src/features/workflow/components/panels/workflow-history.tsx +150 -0
  253. package/src/features/workflow/components/panels/workflow-node-gallery-data/categories.ts +11 -0
  254. package/src/features/workflow/components/panels/workflow-node-gallery-data/items/actions.tsx +39 -0
  255. package/src/features/workflow/components/panels/workflow-node-gallery-data/items/ai.tsx +39 -0
  256. package/src/features/workflow/components/panels/workflow-node-gallery-data/items/data.tsx +55 -0
  257. package/src/features/workflow/components/panels/workflow-node-gallery-data/items/logic.tsx +39 -0
  258. package/src/features/workflow/components/panels/workflow-node-gallery-data/items/special.tsx +50 -0
  259. package/src/features/workflow/components/panels/workflow-node-gallery-data/items/triggers.tsx +71 -0
  260. package/src/features/workflow/components/panels/workflow-node-gallery-data/types.ts +9 -0
  261. package/src/features/workflow/components/panels/workflow-node-gallery-data.tsx +21 -0
  262. package/src/features/workflow/components/panels/workflow-node-gallery.tsx +86 -0
  263. package/src/features/workflow/components/panels/workflow-tabs.tsx +49 -0
  264. package/src/features/workflow/components/trace/agent-prism/Avatar.tsx +146 -0
  265. package/src/features/workflow/components/trace/agent-prism/Badge.tsx +95 -0
  266. package/src/features/workflow/components/trace/agent-prism/BrandLogo.tsx +102 -0
  267. package/src/features/workflow/components/trace/agent-prism/Button.tsx +124 -0
  268. package/src/features/workflow/components/trace/agent-prism/CollapseAndExpandControls.tsx +45 -0
  269. package/src/features/workflow/components/trace/agent-prism/CollapsibleSection.tsx +124 -0
  270. package/src/features/workflow/components/trace/agent-prism/CopyButton.tsx +63 -0
  271. package/src/features/workflow/components/trace/agent-prism/DetailsView/DetailsView.tsx +143 -0
  272. package/src/features/workflow/components/trace/agent-prism/DetailsView/DetailsViewAttributesTab.tsx +125 -0
  273. package/src/features/workflow/components/trace/agent-prism/DetailsView/DetailsViewContentViewer.tsx +51 -0
  274. package/src/features/workflow/components/trace/agent-prism/DetailsView/DetailsViewHeader.tsx +100 -0
  275. package/src/features/workflow/components/trace/agent-prism/DetailsView/DetailsViewHeaderActions.tsx +21 -0
  276. package/src/features/workflow/components/trace/agent-prism/DetailsView/DetailsViewInputOutputTab.tsx +126 -0
  277. package/src/features/workflow/components/trace/agent-prism/DetailsView/DetailsViewJsonOutput.tsx +30 -0
  278. package/src/features/workflow/components/trace/agent-prism/DetailsView/DetailsViewRawDataTab.tsx +31 -0
  279. package/src/features/workflow/components/trace/agent-prism/IconButton.tsx +75 -0
  280. package/src/features/workflow/components/trace/agent-prism/PriceBadge.tsx +14 -0
  281. package/src/features/workflow/components/trace/agent-prism/SearchInput.tsx +17 -0
  282. package/src/features/workflow/components/trace/agent-prism/SpanBadge.tsx +52 -0
  283. package/src/features/workflow/components/trace/agent-prism/SpanCard/SpanCard.tsx +480 -0
  284. package/src/features/workflow/components/trace/agent-prism/SpanCard/SpanCardBadges.tsx +23 -0
  285. package/src/features/workflow/components/trace/agent-prism/SpanCard/SpanCardConnector.tsx +36 -0
  286. package/src/features/workflow/components/trace/agent-prism/SpanCard/SpanCardTimeline.tsx +60 -0
  287. package/src/features/workflow/components/trace/agent-prism/SpanCard/SpanCardToggle.tsx +39 -0
  288. package/src/features/workflow/components/trace/agent-prism/SpanStatus.tsx +80 -0
  289. package/src/features/workflow/components/trace/agent-prism/TabSelector.tsx +35 -0
  290. package/src/features/workflow/components/trace/agent-prism/Tabs.tsx +140 -0
  291. package/src/features/workflow/components/trace/agent-prism/TextInput.tsx +143 -0
  292. package/src/features/workflow/components/trace/agent-prism/TimestampBadge.tsx +22 -0
  293. package/src/features/workflow/components/trace/agent-prism/TokensBadge.tsx +27 -0
  294. package/src/features/workflow/components/trace/agent-prism/TraceList/TraceList.tsx +87 -0
  295. package/src/features/workflow/components/trace/agent-prism/TraceList/TraceListItem.tsx +86 -0
  296. package/src/features/workflow/components/trace/agent-prism/TraceList/TraceListItemHeader.tsx +37 -0
  297. package/src/features/workflow/components/trace/agent-prism/TraceViewer/TraceViewer.test.tsx +183 -0
  298. package/src/features/workflow/components/trace/agent-prism/TraceViewer/TraceViewer.tsx +207 -0
  299. package/src/features/workflow/components/trace/agent-prism/TraceViewer/TraceViewerDesktopLayout.tsx +99 -0
  300. package/src/features/workflow/components/trace/agent-prism/TraceViewer/TraceViewerMobileLayout.tsx +103 -0
  301. package/src/features/workflow/components/trace/agent-prism/TraceViewer/TraceViewerPlaceholder.tsx +5 -0
  302. package/src/features/workflow/components/trace/agent-prism/TraceViewer/TraceViewerSearchAndControls.tsx +30 -0
  303. package/src/features/workflow/components/trace/agent-prism/TraceViewer/TraceViewerTreeViewContainer.tsx +76 -0
  304. package/src/features/workflow/components/trace/agent-prism/TraceViewer/useTraceSelection.ts +186 -0
  305. package/src/features/workflow/components/trace/agent-prism/TreeView.tsx +73 -0
  306. package/src/features/workflow/components/trace/agent-prism/index.ts +7 -0
  307. package/src/features/workflow/components/trace/agent-prism/shared.ts +170 -0
  308. package/src/features/workflow/components/trace/agent-prism/theme/index.js +97 -0
  309. package/src/features/workflow/components/trace/agent-prism/theme/index.ts +101 -0
  310. package/src/features/workflow/components/trace/agent-prism/theme/theme.css +247 -0
  311. package/src/features/workflow/data/node-types.ts +32 -0
  312. package/src/features/workflow/data/templates/feedly-digest.ts +120 -0
  313. package/src/features/workflow/data/templates/index.ts +30 -0
  314. package/src/features/workflow/data/templates/mongodb-session.ts +59 -0
  315. package/src/features/workflow/data/templates/python-task.ts +59 -0
  316. package/src/features/workflow/data/templates/quickstart-welcome.ts +65 -0
  317. package/src/features/workflow/data/templates/rss-monitor.ts +60 -0
  318. package/src/features/workflow/data/templates/slack-broadcast.ts +58 -0
  319. package/src/features/workflow/data/templates/telegram-broadcast.ts +76 -0
  320. package/src/features/workflow/data/templates/template-owner.ts +7 -0
  321. package/src/features/workflow/data/workflow-data.ts +13 -0
  322. package/src/features/workflow/data/workflow-types.ts +47 -0
  323. package/src/features/workflow/lib/graph-config/constants.ts +7 -0
  324. package/src/features/workflow/lib/graph-config/edge-processing.ts +147 -0
  325. package/src/features/workflow/lib/graph-config/name-mapping.ts +30 -0
  326. package/src/features/workflow/lib/graph-config/node-handlers/branching.ts +171 -0
  327. package/src/features/workflow/lib/graph-config/node-handlers/index.ts +16 -0
  328. package/src/features/workflow/lib/graph-config/node-handlers/integrations.ts +201 -0
  329. package/src/features/workflow/lib/graph-config/node-handlers/set-variable.ts +124 -0
  330. package/src/features/workflow/lib/graph-config/node-processing.ts +163 -0
  331. package/src/features/workflow/lib/graph-config/serialization.ts +31 -0
  332. package/src/features/workflow/lib/graph-config/terminal-connections.ts +37 -0
  333. package/src/features/workflow/lib/graph-config/types.ts +84 -0
  334. package/src/features/workflow/lib/graph-config/utils.ts +65 -0
  335. package/src/features/workflow/lib/graph-config/workload.ts +29 -0
  336. package/src/features/workflow/lib/graph-config.integration.logic.test.ts +168 -0
  337. package/src/features/workflow/lib/graph-config.integration.start-end.test.ts +68 -0
  338. package/src/features/workflow/lib/graph-config.integration.variables.test.ts +67 -0
  339. package/src/features/workflow/lib/graph-config.ts +80 -0
  340. package/src/features/workflow/lib/graph-utils.ts +193 -0
  341. package/src/features/workflow/lib/node-icons.tsx +183 -0
  342. package/src/features/workflow/lib/node-schemas/ai-nodes.ts +81 -0
  343. package/src/features/workflow/lib/node-schemas/base.ts +154 -0
  344. package/src/features/workflow/lib/node-schemas/condition-operators.ts +111 -0
  345. package/src/features/workflow/lib/node-schemas/index.ts +73 -0
  346. package/src/features/workflow/lib/node-schemas/integration-nodes.ts +153 -0
  347. package/src/features/workflow/lib/node-schemas/logic-nodes.ts +110 -0
  348. package/src/features/workflow/lib/node-schemas/state-nodes.ts +45 -0
  349. package/src/features/workflow/lib/node-schemas/trigger-nodes.ts +218 -0
  350. package/src/features/workflow/lib/node-schemas/ui.ts +88 -0
  351. package/src/features/workflow/lib/python-node.ts +23 -0
  352. package/src/features/workflow/lib/workflow-diff.ts +191 -0
  353. package/src/features/workflow/lib/workflow-execution-builders.ts +101 -0
  354. package/src/features/workflow/lib/workflow-execution-formatters.ts +145 -0
  355. package/src/features/workflow/lib/workflow-execution-storage.ts +60 -0
  356. package/src/features/workflow/lib/workflow-execution.types.ts +38 -0
  357. package/src/features/workflow/lib/workflow-storage-api.ts +122 -0
  358. package/src/features/workflow/lib/workflow-storage-helpers.ts +207 -0
  359. package/src/features/workflow/lib/workflow-storage-versioning.ts +71 -0
  360. package/src/features/workflow/lib/workflow-storage.constants.ts +21 -0
  361. package/src/features/workflow/lib/workflow-storage.list.integration.test.ts +70 -0
  362. package/src/features/workflow/lib/workflow-storage.sanitized-save.integration.test.ts +116 -0
  363. package/src/features/workflow/lib/workflow-storage.save.integration.test.ts +124 -0
  364. package/src/features/workflow/lib/workflow-storage.test-helpers.ts +29 -0
  365. package/src/features/workflow/lib/workflow-storage.ts +183 -0
  366. package/src/features/workflow/lib/workflow-storage.types.ts +76 -0
  367. package/src/features/workflow/pages/workflow-canvas/components/canvas-tab-content.tsx +157 -0
  368. package/src/features/workflow/pages/workflow-canvas/components/execution-tab-content.tsx +57 -0
  369. package/src/features/workflow/pages/workflow-canvas/components/readiness-tab-content.tsx +49 -0
  370. package/src/features/workflow/pages/workflow-canvas/components/settings-tab-content.tsx +160 -0
  371. package/src/features/workflow/pages/workflow-canvas/components/trace-tab-content.test.tsx +204 -0
  372. package/src/features/workflow/pages/workflow-canvas/components/trace-tab-content.tsx +202 -0
  373. package/src/features/workflow/pages/workflow-canvas/components/workflow-canvas-layout.tsx +179 -0
  374. package/src/features/workflow/pages/workflow-canvas/handlers/credentials.ts +158 -0
  375. package/src/features/workflow/pages/workflow-canvas/handlers/subworkflows.ts +227 -0
  376. package/src/features/workflow/pages/workflow-canvas/handlers/validation.ts +175 -0
  377. package/src/features/workflow/pages/workflow-canvas/helpers/clipboard.ts +85 -0
  378. package/src/features/workflow/pages/workflow-canvas/helpers/execution.ts +39 -0
  379. package/src/features/workflow/pages/workflow-canvas/helpers/id.ts +15 -0
  380. package/src/features/workflow/pages/workflow-canvas/helpers/node-identity.ts +157 -0
  381. package/src/features/workflow/pages/workflow-canvas/helpers/runtime-cache.ts +70 -0
  382. package/src/features/workflow/pages/workflow-canvas/helpers/sticky-notes.ts +52 -0
  383. package/src/features/workflow/pages/workflow-canvas/helpers/subworkflow-library.ts +12 -0
  384. package/src/features/workflow/pages/workflow-canvas/helpers/subworkflows/content-qa.ts +88 -0
  385. package/src/features/workflow/pages/workflow-canvas/helpers/subworkflows/customer-onboarding.ts +67 -0
  386. package/src/features/workflow/pages/workflow-canvas/helpers/subworkflows/incident-response.ts +88 -0
  387. package/src/features/workflow/pages/workflow-canvas/helpers/subworkflows/types.ts +9 -0
  388. package/src/features/workflow/pages/workflow-canvas/helpers/trace.ts +552 -0
  389. package/src/features/workflow/pages/workflow-canvas/helpers/transformers.ts +140 -0
  390. package/src/features/workflow/pages/workflow-canvas/helpers/types.ts +122 -0
  391. package/src/features/workflow/pages/workflow-canvas/helpers/validation.ts +57 -0
  392. package/src/features/workflow/pages/workflow-canvas/hooks/controller/build-layout-props.ts +229 -0
  393. package/src/features/workflow/pages/workflow-canvas/hooks/controller/use-workflow-canvas-controller.ts +26 -0
  394. package/src/features/workflow/pages/workflow-canvas/hooks/controller/use-workflow-canvas-core.ts +188 -0
  395. package/src/features/workflow/pages/workflow-canvas/hooks/controller/use-workflow-canvas-execution.ts +269 -0
  396. package/src/features/workflow/pages/workflow-canvas/hooks/controller/use-workflow-canvas-lifecycle.ts +44 -0
  397. package/src/features/workflow/pages/workflow-canvas/hooks/controller/use-workflow-canvas-resources.ts +92 -0
  398. package/src/features/workflow/pages/workflow-canvas/hooks/execution-canvas-updater.ts +79 -0
  399. package/src/features/workflow/pages/workflow-canvas/hooks/execution-log-helpers.ts +75 -0
  400. package/src/features/workflow/pages/workflow-canvas/hooks/execution-node-status.ts +46 -0
  401. package/src/features/workflow/pages/workflow-canvas/hooks/execution-record-updater.ts +118 -0
  402. package/src/features/workflow/pages/workflow-canvas/hooks/execution-record.ts +69 -0
  403. package/src/features/workflow/pages/workflow-canvas/hooks/execution-runtime-updates.ts +84 -0
  404. package/src/features/workflow/pages/workflow-canvas/hooks/node-factory.ts +166 -0
  405. package/src/features/workflow/pages/workflow-canvas/hooks/use-canvas-ui-state.ts +19 -0
  406. package/src/features/workflow/pages/workflow-canvas/hooks/use-decorated-nodes.ts +115 -0
  407. package/src/features/workflow/pages/workflow-canvas/hooks/use-execution-history-handlers.ts +187 -0
  408. package/src/features/workflow/pages/workflow-canvas/hooks/use-execution-trace.ts +302 -0
  409. package/src/features/workflow/pages/workflow-canvas/hooks/use-execution-updates.ts +143 -0
  410. package/src/features/workflow/pages/workflow-canvas/hooks/use-initial-fit-view.ts +27 -0
  411. package/src/features/workflow/pages/workflow-canvas/hooks/use-node-creation.ts +133 -0
  412. package/src/features/workflow/pages/workflow-canvas/hooks/use-node-inspector-handlers.ts +194 -0
  413. package/src/features/workflow/pages/workflow-canvas/hooks/use-pause-workflow.ts +95 -0
  414. package/src/features/workflow/pages/workflow-canvas/hooks/use-run-workflow.ts +139 -0
  415. package/src/features/workflow/pages/workflow-canvas/hooks/use-runtime-cache-sync.ts +52 -0
  416. package/src/features/workflow/pages/workflow-canvas/hooks/use-subworkflow-state.ts +47 -0
  417. package/src/features/workflow/pages/workflow-canvas/hooks/use-workflow-canvas-history.ts +233 -0
  418. package/src/features/workflow/pages/workflow-canvas/hooks/use-workflow-chat.ts +284 -0
  419. package/src/features/workflow/pages/workflow-canvas/hooks/use-workflow-clipboard.ts +218 -0
  420. package/src/features/workflow/pages/workflow-canvas/hooks/use-workflow-credentials.ts +139 -0
  421. package/src/features/workflow/pages/workflow-canvas/hooks/use-workflow-duplicate-nodes.ts +140 -0
  422. package/src/features/workflow/pages/workflow-canvas/hooks/use-workflow-execution-state.ts +20 -0
  423. package/src/features/workflow/pages/workflow-canvas/hooks/use-workflow-file-transfer.ts +203 -0
  424. package/src/features/workflow/pages/workflow-canvas/hooks/use-workflow-keybindings.ts +126 -0
  425. package/src/features/workflow/pages/workflow-canvas/hooks/use-workflow-loader.ts +174 -0
  426. package/src/features/workflow/pages/workflow-canvas/hooks/use-workflow-metadata-state.ts +28 -0
  427. package/src/features/workflow/pages/workflow-canvas/hooks/use-workflow-node-deletion.ts +167 -0
  428. package/src/features/workflow/pages/workflow-canvas/hooks/use-workflow-node-state.ts +89 -0
  429. package/src/features/workflow/pages/workflow-canvas/hooks/use-workflow-saver.ts +204 -0
  430. package/src/features/workflow/pages/workflow-canvas/hooks/use-workflow-search.ts +167 -0
  431. package/src/features/workflow/pages/workflow-canvas/hooks/use-workflow-sticky-notes.ts +89 -0
  432. package/src/features/workflow/pages/workflow-canvas/hooks/use-workflow-storage-listener.ts +51 -0
  433. package/src/features/workflow/pages/workflow-canvas/hooks/use-workflow-validation-state.ts +22 -0
  434. package/src/features/workflow/pages/workflow-canvas/hooks/workflow-clipboard-copy.ts +96 -0
  435. package/src/features/workflow/pages/workflow-canvas/hooks/workflow-clipboard-paste.ts +109 -0
  436. package/src/features/workflow/pages/workflow-canvas/hooks/workflow-runner-websocket.ts +146 -0
  437. package/src/features/workflow/pages/workflow-canvas.test.tsx +194 -0
  438. package/src/features/workflow/pages/workflow-canvas.tsx +23 -0
  439. package/src/features/workflow/pages/workflow-execution-details.tsx +194 -0
  440. package/src/features/workflow/pages/workflow-gallery/types.ts +21 -0
  441. package/src/features/workflow/pages/workflow-gallery/use-workflow-gallery-actions.ts +219 -0
  442. package/src/features/workflow/pages/workflow-gallery/use-workflow-gallery-state.ts +204 -0
  443. package/src/features/workflow/pages/workflow-gallery/use-workflow-gallery.ts +21 -0
  444. package/src/features/workflow/pages/workflow-gallery/workflow-card.tsx +222 -0
  445. package/src/features/workflow/pages/workflow-gallery/workflow-create-dialogs.tsx +114 -0
  446. package/src/features/workflow/pages/workflow-gallery/workflow-filter-popover.tsx +190 -0
  447. package/src/features/workflow/pages/workflow-gallery/workflow-gallery-header.tsx +134 -0
  448. package/src/features/workflow/pages/workflow-gallery/workflow-gallery-tabs.tsx +93 -0
  449. package/src/features/workflow/pages/workflow-gallery/workflow-thumbnail.tsx +82 -0
  450. package/src/features/workflow/pages/workflow-gallery.tsx +100 -0
  451. package/src/features/workflow/types/credential-vault.ts +36 -0
  452. package/src/hooks/use-color-scheme.ts +77 -0
  453. package/src/hooks/use-credential-vault.ts +245 -0
  454. package/src/hooks/use-mobile.tsx +21 -0
  455. package/src/hooks/use-toast.ts +182 -0
  456. package/src/index.css +95 -0
  457. package/src/lib/api.test.ts +135 -0
  458. package/src/lib/api.ts +45 -0
  459. package/src/lib/config.ts +84 -0
  460. package/src/lib/theme.ts +71 -0
  461. package/src/lib/utils.ts +6 -0
  462. package/src/main.tsx +24 -0
  463. package/src/setupTests.ts +5 -0
  464. package/src/test-utils/chatkit-stub.ts +15 -0
  465. package/src/testing/mocks/backend/credentials.ts +60 -0
  466. package/src/testing/mocks/backend/request-utils.ts +32 -0
  467. package/src/testing/mocks/backend/workflows.ts +235 -0
  468. package/src/testing/mocks/backend.ts +52 -0
  469. package/src/testing/mocks/chatkit.ts +14 -0
  470. package/src/vite-env.d.ts +10 -0
  471. package/tailwind.config.js +61 -0
  472. package/tsconfig.app.json +30 -0
  473. package/tsconfig.json +16 -0
  474. package/tsconfig.node.json +20 -0
  475. package/vite.config.ts +30 -0
@@ -0,0 +1,175 @@
1
+ import { buildBackendHttpUrl } from "@/lib/config";
2
+
3
+ export interface PublicChatHttpError {
4
+ status: number;
5
+ message: string;
6
+ code?: string;
7
+ }
8
+
9
+ interface PublicChatFetchOptions {
10
+ workflowId: string;
11
+ backendBaseUrl?: string;
12
+ onHttpError?: (error: PublicChatHttpError) => void;
13
+ metadata?: Record<string, unknown>;
14
+ }
15
+
16
+ type RuntimeConfig = {
17
+ chatkitDomainKey?: unknown;
18
+ };
19
+
20
+ const safeString = (value: unknown): string | undefined => {
21
+ if (typeof value === "string" && value.trim()) {
22
+ return value.trim();
23
+ }
24
+ return undefined;
25
+ };
26
+
27
+ const DEFAULT_DOMAIN_KEY =
28
+ safeString(import.meta.env?.VITE_ORCHEO_CHATKIT_DEFAULT_DOMAIN_KEY) ??
29
+ "domain_pk_localhost_dev";
30
+
31
+ const getRuntimeDomainKey = (): string | undefined => {
32
+ if (typeof window === "undefined") {
33
+ return undefined;
34
+ }
35
+ const runtimeConfig = (
36
+ window as typeof window & {
37
+ __ORCHEO_CONFIG__?: RuntimeConfig;
38
+ }
39
+ ).__ORCHEO_CONFIG__;
40
+ return safeString(runtimeConfig?.chatkitDomainKey);
41
+ };
42
+
43
+ const parseErrorPayload = async (
44
+ response: Response,
45
+ ): Promise<Pick<PublicChatHttpError, "message" | "code">> => {
46
+ try {
47
+ const body = await response.json();
48
+ if (!body) {
49
+ return {
50
+ message: response.statusText || "ChatKit request failed.",
51
+ };
52
+ }
53
+ if (typeof body === "string") {
54
+ return { message: body };
55
+ }
56
+ if (typeof body === "object") {
57
+ const detail =
58
+ (("detail" in body ? body.detail : undefined) as Record<
59
+ string,
60
+ unknown
61
+ >) ?? (body as Record<string, unknown>);
62
+ const message =
63
+ safeString(detail?.message) ??
64
+ safeString((body as Record<string, unknown>).message);
65
+ const code =
66
+ safeString(detail?.code) ??
67
+ safeString((body as Record<string, unknown>).code);
68
+ return {
69
+ message:
70
+ message ??
71
+ (response.statusText ||
72
+ "ChatKit request failed. Please retry shortly."),
73
+ code,
74
+ };
75
+ }
76
+ return {
77
+ message: response.statusText || "ChatKit request failed.",
78
+ };
79
+ } catch {
80
+ return {
81
+ message: response.statusText || "ChatKit request failed.",
82
+ };
83
+ }
84
+ };
85
+
86
+ export const getChatKitDomainKey = (): string => {
87
+ const fromEnv = safeString(import.meta.env?.VITE_ORCHEO_CHATKIT_DOMAIN_KEY);
88
+ const fromRuntime = getRuntimeDomainKey();
89
+ return fromEnv ?? fromRuntime ?? DEFAULT_DOMAIN_KEY;
90
+ };
91
+
92
+ export const buildPublicChatFetch = ({
93
+ workflowId,
94
+ backendBaseUrl,
95
+ onHttpError,
96
+ metadata,
97
+ }: PublicChatFetchOptions): typeof fetch => {
98
+ const baseFetch = window.fetch.bind(window);
99
+ const resolvedUrl = buildBackendHttpUrl("/api/chatkit", backendBaseUrl);
100
+
101
+ const emitError = async (response: Response) => {
102
+ if (!onHttpError) {
103
+ return;
104
+ }
105
+ const detail = await parseErrorPayload(response);
106
+ onHttpError({
107
+ status: response.status,
108
+ message: detail.message,
109
+ code: detail.code,
110
+ });
111
+ };
112
+
113
+ return async (input: RequestInfo | URL, init: RequestInit = {}) => {
114
+ const nextInit: RequestInit = {
115
+ ...init,
116
+ credentials: "include",
117
+ };
118
+ // Ensure OAuth HttpOnly cookies are sent with every ChatKit request.
119
+
120
+ const headers = new Headers(nextInit.headers ?? {});
121
+ const contentType = headers.get("Content-Type") ?? "";
122
+ const expectsJson = contentType.includes("application/json");
123
+ const stringBody = typeof nextInit.body === "string";
124
+
125
+ const augmentPayload = (serialized: string | null) => {
126
+ if (!serialized) {
127
+ return JSON.stringify({
128
+ workflow_id: workflowId,
129
+ metadata: {
130
+ ...(metadata ?? {}),
131
+ workflow_id: workflowId,
132
+ },
133
+ });
134
+ }
135
+ try {
136
+ const payload = JSON.parse(serialized);
137
+ if (payload && typeof payload === "object") {
138
+ if (!payload.workflow_id) {
139
+ payload.workflow_id = workflowId;
140
+ }
141
+ const payloadMetadata =
142
+ payload.metadata && typeof payload.metadata === "object"
143
+ ? { ...(payload.metadata as Record<string, unknown>) }
144
+ : {};
145
+ if (metadata) {
146
+ Object.assign(payloadMetadata, metadata);
147
+ }
148
+ payloadMetadata.workflow_id = workflowId;
149
+ payload.metadata = payloadMetadata;
150
+ }
151
+ return JSON.stringify(payload);
152
+ } catch {
153
+ return serialized;
154
+ }
155
+ };
156
+
157
+ if (expectsJson || stringBody || !nextInit.body) {
158
+ nextInit.body = augmentPayload(
159
+ stringBody ? (nextInit.body as string) : null,
160
+ );
161
+ headers.set("Content-Type", "application/json");
162
+ }
163
+
164
+ nextInit.headers = headers;
165
+
166
+ const requestInfo = input ?? resolvedUrl;
167
+ const response = await baseFetch(requestInfo, nextInit);
168
+
169
+ if (!response.ok) {
170
+ await emitError(response.clone());
171
+ }
172
+
173
+ return response;
174
+ };
175
+ };
@@ -0,0 +1,20 @@
1
+ import type { UseChatKitOptions } from "@openai/chatkit-react";
2
+ import type { ColorScheme } from "@/hooks/use-color-scheme";
3
+
4
+ export const buildChatTheme = (
5
+ scheme: ColorScheme,
6
+ ): NonNullable<UseChatKitOptions["theme"]> => ({
7
+ colorScheme: scheme,
8
+ color: {
9
+ grayscale: {
10
+ hue: 220,
11
+ tint: 6,
12
+ shade: scheme === "dark" ? -1 : -4,
13
+ },
14
+ accent: {
15
+ primary: scheme === "dark" ? "#f1f5f9" : "#0f172a",
16
+ level: 1,
17
+ },
18
+ },
19
+ radius: "round",
20
+ });
@@ -0,0 +1,29 @@
1
+ type ChatTelemetryEvent =
2
+ | "canvas.chat.open"
3
+ | "canvas.chat.close"
4
+ | "canvas.chat.session.success"
5
+ | "canvas.chat.session.failure";
6
+
7
+ const buildDetail = (detail?: Record<string, unknown>) => ({
8
+ timestamp: new Date().toISOString(),
9
+ ...(detail ?? {}),
10
+ });
11
+
12
+ export function recordChatTelemetry(
13
+ event: ChatTelemetryEvent,
14
+ detail?: Record<string, unknown>,
15
+ ) {
16
+ if (typeof window !== "undefined") {
17
+ window.dispatchEvent(
18
+ new CustomEvent("chatkit:telemetry", {
19
+ detail: { event, ...buildDetail(detail) },
20
+ }),
21
+ );
22
+ }
23
+
24
+ if (process.env.NODE_ENV !== "production") {
25
+ console.info(`[telemetry] ${event}`, buildDetail(detail));
26
+ }
27
+ }
28
+
29
+ export type { ChatTelemetryEvent };
@@ -0,0 +1,69 @@
1
+ import { buildBackendHttpUrl } from "@/lib/config";
2
+
3
+ interface WorkflowSessionResponse {
4
+ client_secret?: string;
5
+ clientSecret?: string;
6
+ expires_at?: string;
7
+ expiresAt?: string;
8
+ }
9
+
10
+ export interface WorkflowChatSession {
11
+ clientSecret: string;
12
+ expiresAt: number | null;
13
+ }
14
+
15
+ const parseErrorDetail = async (response: Response): Promise<string> => {
16
+ try {
17
+ const payload = (await response.json()) as Record<string, unknown>;
18
+ if (typeof payload?.detail === "object" && payload.detail !== null) {
19
+ const detail = payload.detail as Record<string, unknown>;
20
+ const message =
21
+ typeof detail.message === "string" ? detail.message : null;
22
+ if (message) {
23
+ return message;
24
+ }
25
+ }
26
+ if (typeof payload.message === "string") {
27
+ return payload.message;
28
+ }
29
+ } catch {
30
+ // Ignore JSON parse errors and fall through to status text.
31
+ }
32
+ return response.statusText || "ChatKit session request failed.";
33
+ };
34
+
35
+ export async function requestWorkflowChatSession(
36
+ workflowId: string,
37
+ backendBaseUrl?: string | null,
38
+ ): Promise<WorkflowChatSession> {
39
+ const url = buildBackendHttpUrl(
40
+ `/api/workflows/${workflowId}/chatkit/session`,
41
+ backendBaseUrl ?? undefined,
42
+ );
43
+ const response = await fetch(url, {
44
+ method: "POST",
45
+ headers: {
46
+ "Content-Type": "application/json",
47
+ },
48
+ credentials: "include",
49
+ });
50
+
51
+ if (!response.ok) {
52
+ const message = await parseErrorDetail(response);
53
+ throw new Error(message);
54
+ }
55
+
56
+ const payload = (await response.json()) as WorkflowSessionResponse;
57
+ const secret = payload.client_secret ?? payload.clientSecret;
58
+ if (!secret) {
59
+ throw new Error("ChatKit session response missing client secret.");
60
+ }
61
+
62
+ const expiresRaw = payload.expires_at ?? payload.expiresAt;
63
+ const expiresAt = expiresRaw ? new Date(expiresRaw).getTime() : null;
64
+
65
+ return {
66
+ clientSecret: secret,
67
+ expiresAt,
68
+ };
69
+ }
@@ -0,0 +1,391 @@
1
+ import { useCallback, useEffect, useMemo, useState } from "react";
2
+ import type { ReactNode } from "react";
3
+ import { Monitor, Moon, Sun } from "lucide-react";
4
+ import { Link, useParams } from "react-router-dom";
5
+ import { Alert, AlertDescription, AlertTitle } from "@/design-system/ui/alert";
6
+ import { Button } from "@/design-system/ui/button";
7
+ import { Skeleton } from "@/design-system/ui/skeleton";
8
+ import { ToggleGroup, ToggleGroupItem } from "@/design-system/ui/toggle-group";
9
+ import { getBackendBaseUrl } from "@/lib/config";
10
+ import { cn } from "@/lib/utils";
11
+ import type { Theme } from "@/lib/theme";
12
+ import { useThemePreferences } from "@features/account/components/use-theme-preferences";
13
+ import {
14
+ ApiRequestError,
15
+ fetchWorkflow,
16
+ } from "@features/workflow/lib/workflow-storage-api";
17
+ import type { ApiWorkflow } from "@features/workflow/lib/workflow-storage.types";
18
+ import { PublicChatWidget } from "@features/chatkit/components/public-chat-widget";
19
+ import { PublicChatErrorBoundary } from "@features/chatkit/components/public-chat-error-boundary";
20
+ import type { PublicChatHttpError } from "@features/chatkit/lib/chatkit-client";
21
+
22
+ type ColorScheme = "light" | "dark";
23
+
24
+ type WorkflowState =
25
+ | { status: "loading" }
26
+ | { status: "error"; message: string }
27
+ | { status: "ready"; workflow: ApiWorkflow };
28
+
29
+ const sanitizeWorkflowNameForEmail = (value: string): string =>
30
+ value
31
+ .replace(/[\r\n]+/g, " ")
32
+ .replace(/[<>]/g, "")
33
+ .trim();
34
+
35
+ export default function PublicChatPage() {
36
+ const { workflowId } = useParams<{ workflowId: string }>();
37
+ const [workflowState, setWorkflowState] = useState<WorkflowState>({
38
+ status: workflowId ? "loading" : "error",
39
+ ...(workflowId ? {} : { message: "Workflow identifier missing from URL." }),
40
+ });
41
+ const [chatError, setChatError] = useState<PublicChatHttpError | null>(null);
42
+ const [rateLimitError, setRateLimitError] =
43
+ useState<PublicChatHttpError | null>(null);
44
+ const [isChatReady, setIsChatReady] = useState(false);
45
+ const [systemColorScheme, setSystemColorScheme] = useState<ColorScheme>(() =>
46
+ typeof window !== "undefined" &&
47
+ window.matchMedia("(prefers-color-scheme: dark)").matches
48
+ ? "dark"
49
+ : "light",
50
+ );
51
+ const { theme, setTheme } = useThemePreferences({});
52
+ const backendBaseUrl = useMemo(() => getBackendBaseUrl(), []);
53
+
54
+ useEffect(() => {
55
+ setChatError(null);
56
+ setRateLimitError(null);
57
+ setIsChatReady(false);
58
+ }, [workflowId]);
59
+
60
+ useEffect(() => {
61
+ if (!workflowId) {
62
+ return;
63
+ }
64
+ let cancelled = false;
65
+ setWorkflowState({ status: "loading" });
66
+
67
+ fetchWorkflow(workflowId)
68
+ .then((workflow) => {
69
+ if (cancelled) {
70
+ return;
71
+ }
72
+ if (!workflow) {
73
+ setWorkflowState({
74
+ status: "error",
75
+ message: "This workflow does not exist or is no longer available.",
76
+ });
77
+ return;
78
+ }
79
+ if (!workflow.is_public) {
80
+ setWorkflowState({
81
+ status: "error",
82
+ message:
83
+ "This workflow is private. Ask the owner to republish it before trying again.",
84
+ });
85
+ return;
86
+ }
87
+ setWorkflowState({ status: "ready", workflow });
88
+ })
89
+ .catch((error: unknown) => {
90
+ if (cancelled) {
91
+ return;
92
+ }
93
+ if (error instanceof ApiRequestError) {
94
+ const message =
95
+ error.status >= 500
96
+ ? "The workflow service is unavailable. Please try again later."
97
+ : "Unable to load workflow metadata.";
98
+ setWorkflowState({ status: "error", message });
99
+ return;
100
+ }
101
+ setWorkflowState({
102
+ status: "error",
103
+ message: "Unexpected error while loading workflow metadata.",
104
+ });
105
+ });
106
+
107
+ return () => {
108
+ cancelled = true;
109
+ };
110
+ }, [workflowId]);
111
+
112
+ const contactHref = useMemo(() => {
113
+ if (workflowState.status !== "ready") {
114
+ return "mailto:?subject=Orcheo%20workflow%20access";
115
+ }
116
+ const sanitizedName = sanitizeWorkflowNameForEmail(
117
+ workflowState.workflow.name,
118
+ );
119
+ const subject = encodeURIComponent(`Request access to ${sanitizedName}`);
120
+ const link = typeof window !== "undefined" ? window.location.href : "";
121
+ const body = encodeURIComponent(
122
+ `Hi,%0A%0ACould you confirm access for workflow "${sanitizedName}" (${workflowState.workflow.id})?%0A%0ALink: ${link}%0A`,
123
+ );
124
+ return `mailto:?subject=${subject}&body=${body}`;
125
+ }, [workflowState]);
126
+
127
+ const handleErrorBoundaryReset = useCallback(() => {
128
+ setChatError(null);
129
+ setRateLimitError(null);
130
+ setIsChatReady(false);
131
+ }, []);
132
+
133
+ const handleChatHttpError = (error: PublicChatHttpError) => {
134
+ if (error.status === 429 || error.code?.startsWith("chatkit.rate_limit")) {
135
+ setRateLimitError(error);
136
+ return;
137
+ }
138
+ if (error.code === "chatkit.auth.oauth_required") {
139
+ setChatError({
140
+ ...error,
141
+ message:
142
+ "OAuth login is required before this workflow can be used. Sign in and try again.",
143
+ });
144
+ setIsChatReady(false);
145
+ return;
146
+ }
147
+ if (error.status === 401 || error.status === 403) {
148
+ setChatError({
149
+ ...error,
150
+ message:
151
+ "You do not have access to this workflow yet. Ask the owner to confirm it is still published.",
152
+ });
153
+ setIsChatReady(false);
154
+ return;
155
+ }
156
+ setChatError({
157
+ ...error,
158
+ message:
159
+ error.message ||
160
+ "ChatKit could not start this conversation. Please try again shortly.",
161
+ });
162
+ setIsChatReady(false);
163
+ };
164
+
165
+ const resolvedColorScheme: ColorScheme =
166
+ theme === "system" ? systemColorScheme : theme;
167
+
168
+ useEffect(() => {
169
+ if (typeof window === "undefined") {
170
+ return;
171
+ }
172
+ const media = window.matchMedia("(prefers-color-scheme: dark)");
173
+ const handleChange = (event: MediaQueryListEvent) => {
174
+ setSystemColorScheme(event.matches ? "dark" : "light");
175
+ };
176
+ if (typeof media.addEventListener === "function") {
177
+ media.addEventListener("change", handleChange);
178
+ } else {
179
+ media.addListener(handleChange);
180
+ }
181
+ return () => {
182
+ if (typeof media.removeEventListener === "function") {
183
+ media.removeEventListener("change", handleChange);
184
+ } else {
185
+ media.removeListener(handleChange);
186
+ }
187
+ };
188
+ }, []);
189
+
190
+ const handleThemeRequest = useCallback(
191
+ (requestedScheme: ColorScheme) => {
192
+ setTheme(requestedScheme);
193
+ },
194
+ [setTheme],
195
+ );
196
+
197
+ const renderChatColumn = () => {
198
+ const currentWorkflowName =
199
+ workflowState.status === "ready"
200
+ ? workflowState.workflow.name
201
+ : "this workflow";
202
+
203
+ const renderBody = () => {
204
+ if (workflowState.status === "loading") {
205
+ return (
206
+ <div className="space-y-4">
207
+ <Skeleton className="h-10 w-40 rounded-full" />
208
+ <Skeleton className="h-[520px] w-full rounded-3xl" />
209
+ </div>
210
+ );
211
+ }
212
+
213
+ if (workflowState.status === "error") {
214
+ return (
215
+ <div className="rounded-3xl border border-slate-200/80 bg-white/70 p-6 text-slate-900 shadow-sm dark:border-slate-800/60 dark:bg-slate-950/40 dark:text-white">
216
+ <p className="text-lg font-semibold">Chat unavailable</p>
217
+ <p className="mt-2 text-sm text-slate-600 dark:text-slate-300">
218
+ We cannot open a ChatKit session until the workflow loads.
219
+ </p>
220
+ <Button asChild variant="secondary" className="mt-4">
221
+ <Link to="/">Return home</Link>
222
+ </Button>
223
+ </div>
224
+ );
225
+ }
226
+
227
+ return (
228
+ <div className="space-y-4">
229
+ {rateLimitError && (
230
+ <Alert className="border-amber-500/50 bg-amber-500/[0.08] text-amber-100">
231
+ <AlertTitle>Slow down for a moment</AlertTitle>
232
+ <AlertDescription>
233
+ {rateLimitError.message ||
234
+ "Too many requests were sent for this workflow. Please wait before retrying."}
235
+ </AlertDescription>
236
+ <div className="mt-3">
237
+ <Button
238
+ size="sm"
239
+ variant="outline"
240
+ className="border-amber-400/60 text-amber-100"
241
+ onClick={() => setRateLimitError(null)}
242
+ >
243
+ Dismiss
244
+ </Button>
245
+ </div>
246
+ </Alert>
247
+ )}
248
+
249
+ {chatError ? (
250
+ <div className="space-y-4 rounded-3xl border border-red-500/40 bg-red-500/10 p-6 text-center">
251
+ <p className="font-medium text-red-100">{chatError.message}</p>
252
+ <div className="flex flex-wrap justify-center gap-3">
253
+ <Button asChild variant="outline">
254
+ <a href={contactHref}>Contact owner</a>
255
+ </Button>
256
+ </div>
257
+ </div>
258
+ ) : (
259
+ <div className="relative min-h-[520px]">
260
+ {!isChatReady && (
261
+ <div className="absolute inset-0 flex flex-col gap-4 rounded-3xl bg-white/90 p-6 shadow-sm dark:bg-slate-950/80">
262
+ <Skeleton className="h-10 w-1/2 self-center" />
263
+ <Skeleton className="h-full w-full" />
264
+ </div>
265
+ )}
266
+ <div
267
+ className={cn(
268
+ "h-[520px] w-full",
269
+ isChatReady ? "opacity-100" : "opacity-0",
270
+ "transition-opacity duration-200",
271
+ )}
272
+ >
273
+ <PublicChatWidget
274
+ key={workflowState.workflow.id}
275
+ workflowId={workflowState.workflow.id}
276
+ workflowName={workflowState.workflow.name}
277
+ backendBaseUrl={backendBaseUrl}
278
+ onHttpError={handleChatHttpError}
279
+ onReady={() => setIsChatReady(true)}
280
+ colorScheme={resolvedColorScheme}
281
+ onThemeRequest={handleThemeRequest}
282
+ />
283
+ </div>
284
+ </div>
285
+ )}
286
+ </div>
287
+ );
288
+ };
289
+
290
+ return (
291
+ <div className="space-y-6">
292
+ <div className="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
293
+ <div className="space-y-2">
294
+ <p className="text-3xl font-semibold text-slate-900 dark:text-white">
295
+ Chat with “{currentWorkflowName}”
296
+ </p>
297
+ <p className="text-base text-slate-600 dark:text-slate-300">
298
+ Chat sessions open automatically for published workflows unless
299
+ the owner requires OAuth login.
300
+ </p>
301
+ </div>
302
+ <ThemeToggleButtonGroup value={theme} onChange={setTheme} />
303
+ </div>
304
+ {renderBody()}
305
+ </div>
306
+ );
307
+ };
308
+
309
+ return (
310
+ <PublicChatErrorBoundary onReset={handleErrorBoundaryReset}>
311
+ <div className="h-screen overflow-hidden bg-white text-slate-900 dark:bg-slate-950 dark:text-white">
312
+ <div className="mx-auto flex h-full max-w-6xl flex-col px-4 py-6 lg:py-8">
313
+ <div className="flex flex-1 items-center justify-center">
314
+ <div className="w-full max-w-3xl">{renderChatColumn()}</div>
315
+ </div>
316
+ </div>
317
+ </div>
318
+ </PublicChatErrorBoundary>
319
+ );
320
+ }
321
+
322
+ const THEME_OPTIONS: Array<{
323
+ icon: ReactNode;
324
+ label: string;
325
+ value: Theme;
326
+ }> = [
327
+ {
328
+ value: "light",
329
+ label: "Light",
330
+ icon: <Sun className="h-4 w-4" />,
331
+ },
332
+ {
333
+ value: "dark",
334
+ label: "Dark",
335
+ icon: <Moon className="h-4 w-4" />,
336
+ },
337
+ {
338
+ value: "system",
339
+ label: "System",
340
+ icon: <Monitor className="h-4 w-4" />,
341
+ },
342
+ ];
343
+
344
+ const isThemeValue = (value: string): value is Theme =>
345
+ THEME_OPTIONS.some((option) => option.value === value);
346
+
347
+ interface ThemeToggleButtonGroupProps {
348
+ className?: string;
349
+ value: Theme;
350
+ onChange: (theme: Theme) => void;
351
+ }
352
+
353
+ function ThemeToggleButtonGroup({
354
+ className,
355
+ value,
356
+ onChange,
357
+ }: ThemeToggleButtonGroupProps) {
358
+ const handleThemeChange = (value: string) => {
359
+ if (!value || !isThemeValue(value)) {
360
+ return;
361
+ }
362
+ onChange(value);
363
+ };
364
+
365
+ return (
366
+ <ToggleGroup
367
+ type="single"
368
+ value={value}
369
+ onValueChange={handleThemeChange}
370
+ aria-label="Select display theme"
371
+ className={cn(
372
+ "rounded-full border border-slate-200 bg-white/90 px-1 py-1 shadow-[inset_0_-1px_4px_rgba(15,23,42,0.12)] backdrop-blur-sm dark:border-slate-800 dark:bg-slate-950/70",
373
+ className,
374
+ )}
375
+ variant="default"
376
+ size="default"
377
+ >
378
+ {THEME_OPTIONS.map((option) => (
379
+ <ToggleGroupItem
380
+ key={option.value}
381
+ value={option.value}
382
+ aria-label={`Use ${option.label.toLowerCase()} theme`}
383
+ className="h-9 w-9 rounded-full border border-transparent p-0 text-slate-400 transition-all hover:bg-transparent hover:text-slate-900 dark:text-slate-400 dark:hover:text-white data-[state=on]:border-slate-900/20 data-[state=on]:bg-slate-900 data-[state=on]:text-white data-[state=on]:shadow-[0_4px_12px_rgba(15,23,42,0.3)] dark:data-[state=on]:border-white/30 dark:data-[state=on]:bg-white dark:data-[state=on]:text-slate-900"
384
+ >
385
+ {option.icon}
386
+ <span className="sr-only">{option.label}</span>
387
+ </ToggleGroupItem>
388
+ ))}
389
+ </ToggleGroup>
390
+ );
391
+ }