@flowdrop/flowdrop 2.0.0-beta.1 → 2.0.0-beta.11

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 (270) hide show
  1. package/CHANGELOG.md +210 -0
  2. package/MIGRATION-2.0.md +173 -3
  3. package/README.md +5 -5
  4. package/dist/adapters/WorkflowAdapter.js +4 -5
  5. package/dist/adapters/agentspec/AgentSpecAdapter.js +3 -3
  6. package/dist/adapters/agentspec/defaultNodeTypes.js +9 -9
  7. package/dist/api/enhanced-client.js +6 -11
  8. package/dist/chat/batchFeedback.js +1 -1
  9. package/dist/chat/commandClassifier.d.ts +11 -0
  10. package/dist/chat/commandClassifier.js +20 -0
  11. package/dist/chat/historyBuilder.d.ts +39 -0
  12. package/dist/chat/historyBuilder.js +82 -0
  13. package/dist/chat/index.d.ts +2 -1
  14. package/dist/chat/index.js +2 -1
  15. package/dist/chat/responseParser.js +16 -12
  16. package/dist/commands/executor.js +51 -26
  17. package/dist/commands/parser.d.ts +12 -0
  18. package/dist/commands/parser.js +33 -6
  19. package/dist/commands/storeIntegration.svelte.js +11 -1
  20. package/dist/commands/types.js +5 -5
  21. package/dist/components/App.svelte +547 -386
  22. package/dist/components/App.svelte.d.ts +16 -8
  23. package/dist/components/Button.stories.svelte +65 -0
  24. package/dist/components/Button.stories.svelte.d.ts +19 -0
  25. package/dist/components/Button.svelte +62 -0
  26. package/dist/components/Button.svelte.d.ts +24 -0
  27. package/dist/components/CanvasIconButton.svelte +76 -0
  28. package/dist/components/CanvasIconButton.svelte.d.ts +18 -0
  29. package/dist/components/ConfigForm.svelte +194 -565
  30. package/dist/components/ConfigForm.svelte.d.ts +24 -7
  31. package/dist/components/ConfigModal.svelte +9 -1
  32. package/dist/components/ConfigPanel.svelte +234 -15
  33. package/dist/components/ConfigPanel.svelte.d.ts +6 -0
  34. package/dist/components/EditorStatusBar.stories.svelte +44 -0
  35. package/dist/components/EditorStatusBar.stories.svelte.d.ts +27 -0
  36. package/dist/components/EditorStatusBar.svelte +99 -0
  37. package/dist/components/EditorStatusBar.svelte.d.ts +15 -0
  38. package/dist/components/IconButton.svelte +80 -0
  39. package/dist/components/IconButton.svelte.d.ts +30 -0
  40. package/dist/components/Input.svelte +74 -0
  41. package/dist/components/Input.svelte.d.ts +17 -0
  42. package/dist/components/LogoWordmark.svelte +113 -0
  43. package/dist/components/LogoWordmark.svelte.d.ts +26 -0
  44. package/dist/components/Navbar.svelte +17 -63
  45. package/dist/components/Navbar.svelte.d.ts +3 -0
  46. package/dist/components/NodeSidebar.svelte +21 -126
  47. package/dist/components/NodeSwapPicker.svelte +12 -30
  48. package/dist/components/PipelineStatus.svelte +6 -1
  49. package/dist/components/PipelineStatus.svelte.d.ts +3 -0
  50. package/dist/components/PortMappingRow.svelte +0 -2
  51. package/dist/components/SchemaForm.svelte +4 -14
  52. package/dist/components/Select.svelte +53 -0
  53. package/dist/components/Select.svelte.d.ts +15 -0
  54. package/dist/components/SettingsModal.svelte +0 -5
  55. package/dist/components/SettingsPanel.svelte +33 -6
  56. package/dist/components/Textarea.svelte +39 -0
  57. package/dist/components/Textarea.svelte.d.ts +12 -0
  58. package/dist/components/ThemeToggle.svelte +15 -94
  59. package/dist/components/UniversalNode.svelte +36 -4
  60. package/dist/components/UniversalNode.svelte.d.ts +1 -1
  61. package/dist/components/WorkflowEditor.svelte +71 -54
  62. package/dist/components/WorkflowEditor.svelte.d.ts +21 -0
  63. package/dist/components/chat/AIChatPanel.svelte +49 -8
  64. package/dist/components/chat/CommandPreview.svelte +10 -1
  65. package/dist/components/console/ConsoleAutocomplete.svelte +1 -1
  66. package/dist/components/console/ConsoleInput.svelte +3 -3
  67. package/dist/components/console/ConsoleOutput.svelte +2 -2
  68. package/dist/components/form/FormArray.svelte +37 -173
  69. package/dist/components/form/FormAutocomplete.svelte +18 -15
  70. package/dist/components/form/FormCheckboxGroup.svelte +1 -5
  71. package/dist/components/form/FormCodeEditor.svelte +9 -7
  72. package/dist/components/form/FormField.svelte +18 -42
  73. package/dist/components/form/FormFieldLight.svelte +52 -48
  74. package/dist/components/form/FormFieldLight.svelte.d.ts +12 -0
  75. package/dist/components/form/FormFieldset.svelte +45 -11
  76. package/dist/components/form/FormMarkdownEditor.svelte +8 -5
  77. package/dist/components/form/FormNumberField.svelte +4 -36
  78. package/dist/components/form/FormPorts.svelte +280 -0
  79. package/dist/components/form/FormPorts.svelte.d.ts +13 -0
  80. package/dist/components/form/FormRangeField.svelte +63 -30
  81. package/dist/components/form/FormSelect.svelte +13 -75
  82. package/dist/components/form/FormTemplateEditor.svelte +6 -4
  83. package/dist/components/form/FormTextField.svelte +3 -35
  84. package/dist/components/form/FormTextarea.svelte +4 -39
  85. package/dist/components/form/FormToggle.svelte +27 -6
  86. package/dist/components/form/FormToggle.svelte.d.ts +5 -0
  87. package/dist/components/form/FormUISchemaRenderer.svelte +3 -1
  88. package/dist/components/form/resolveFieldType.d.ts +24 -0
  89. package/dist/components/form/resolveFieldType.js +55 -0
  90. package/dist/components/icons/CloseIcon.svelte +6 -0
  91. package/dist/components/icons/CloseIcon.svelte.d.ts +26 -0
  92. package/dist/components/icons/CommandLineIcon.svelte +15 -0
  93. package/dist/components/icons/CommandLineIcon.svelte.d.ts +26 -0
  94. package/dist/components/icons/MenuIcon.svelte +4 -0
  95. package/dist/components/icons/MenuIcon.svelte.d.ts +26 -0
  96. package/dist/components/icons/MenuOpenIcon.svelte +6 -0
  97. package/dist/components/icons/MenuOpenIcon.svelte.d.ts +26 -0
  98. package/dist/components/interrupt/ChoicePrompt.svelte +0 -10
  99. package/dist/components/interrupt/ConfirmationPrompt.svelte +0 -5
  100. package/dist/components/interrupt/InterruptBubble.svelte +11 -12
  101. package/dist/components/interrupt/ReviewPrompt.svelte +0 -20
  102. package/dist/components/interrupt/TextInputPrompt.svelte +0 -6
  103. package/dist/components/layouts/MainLayout.svelte +4 -5
  104. package/dist/components/nodes/AtomNode.svelte +62 -76
  105. package/dist/components/nodes/AtomNode.svelte.d.ts +1 -1
  106. package/dist/components/nodes/GatewayNode.svelte +117 -164
  107. package/dist/components/nodes/GatewayNode.svelte.d.ts +1 -1
  108. package/dist/components/nodes/IdeaNode.svelte +72 -98
  109. package/dist/components/nodes/IdeaNode.svelte.d.ts +8 -4
  110. package/dist/components/nodes/NodeConfigButton.svelte +86 -0
  111. package/dist/components/nodes/NodeConfigButton.svelte.d.ts +15 -0
  112. package/dist/components/nodes/NotesNode.svelte +76 -85
  113. package/dist/components/nodes/NotesNode.svelte.d.ts +8 -4
  114. package/dist/components/nodes/SimpleNode.svelte +59 -133
  115. package/dist/components/nodes/SimpleNode.svelte.d.ts +4 -4
  116. package/dist/components/nodes/SquareNode.svelte +110 -164
  117. package/dist/components/nodes/SquareNode.svelte.d.ts +4 -4
  118. package/dist/components/nodes/TerminalNode.svelte +62 -124
  119. package/dist/components/nodes/TerminalNode.svelte.d.ts +4 -4
  120. package/dist/components/nodes/ToolNode.svelte +92 -103
  121. package/dist/components/nodes/ToolNode.svelte.d.ts +6 -6
  122. package/dist/components/nodes/WorkflowNode.svelte +132 -191
  123. package/dist/components/nodes/WorkflowNode.svelte.d.ts +1 -1
  124. package/dist/components/playground/ChatInput.svelte +316 -27
  125. package/dist/components/playground/ChatInput.svelte.d.ts +31 -1
  126. package/dist/components/playground/ControlPanel.svelte +22 -0
  127. package/dist/components/playground/ControlPanel.svelte.d.ts +13 -0
  128. package/dist/components/playground/InputCollector.svelte +11 -48
  129. package/dist/components/playground/PipelineKanbanView.svelte +6 -4
  130. package/dist/components/playground/PipelineKanbanView.svelte.d.ts +2 -0
  131. package/dist/components/playground/PipelinePanel.svelte +20 -3
  132. package/dist/components/playground/PipelinePanel.svelte.d.ts +2 -0
  133. package/dist/components/playground/PipelineTableView.svelte +6 -4
  134. package/dist/components/playground/PipelineTableView.svelte.d.ts +2 -0
  135. package/dist/components/playground/Playground.svelte +292 -28
  136. package/dist/components/playground/Playground.svelte.d.ts +3 -0
  137. package/dist/components/playground/PlaygroundApp.svelte +6 -1
  138. package/dist/components/playground/PlaygroundApp.svelte.d.ts +3 -0
  139. package/dist/components/playground/PlaygroundModal.svelte +5 -0
  140. package/dist/components/playground/PlaygroundModal.svelte.d.ts +3 -0
  141. package/dist/components/playground/PlaygroundStudio.svelte +7 -6
  142. package/dist/components/playground/PlaygroundStudio.svelte.d.ts +3 -0
  143. package/dist/components/playground/pipelineViewUtils.svelte.d.ts +2 -1
  144. package/dist/components/playground/pipelineViewUtils.svelte.js +2 -2
  145. package/dist/components/surfaces/SurfaceOverlay.svelte +153 -0
  146. package/dist/components/surfaces/SurfaceOverlay.svelte.d.ts +14 -0
  147. package/dist/components/surfaces/TabbedSurface.svelte +133 -0
  148. package/dist/components/surfaces/TabbedSurface.svelte.d.ts +27 -0
  149. package/dist/config/endpoints.d.ts +71 -1
  150. package/dist/config/endpoints.js +46 -5
  151. package/dist/core/index.d.ts +2 -3
  152. package/dist/core/index.js +2 -6
  153. package/dist/display/index.d.ts +6 -1
  154. package/dist/display/index.js +9 -1
  155. package/dist/editor/index.d.ts +1 -1
  156. package/dist/editor/index.js +1 -1
  157. package/dist/form/full.d.ts +2 -1
  158. package/dist/form/full.js +4 -1
  159. package/dist/form/index.d.ts +0 -1
  160. package/dist/form/index.js +3 -2
  161. package/dist/helpers/workflowEditorHelper.d.ts +4 -2
  162. package/dist/helpers/workflowEditorHelper.js +8 -8
  163. package/dist/messages/defaults.d.ts +98 -0
  164. package/dist/messages/defaults.js +58 -1
  165. package/dist/messages/index.d.ts +1 -1
  166. package/dist/messages/index.js +1 -1
  167. package/dist/openapi/v1/openapi.yaml +35 -23
  168. package/dist/playground/commands/args.d.ts +32 -0
  169. package/dist/playground/commands/args.js +50 -0
  170. package/dist/playground/commands/dispatch.d.ts +143 -0
  171. package/dist/playground/commands/dispatch.js +162 -0
  172. package/dist/playground/commands/index.d.ts +14 -0
  173. package/dist/playground/commands/index.js +10 -0
  174. package/dist/playground/commands/parser.d.ts +38 -0
  175. package/dist/playground/commands/parser.js +163 -0
  176. package/dist/playground/commands/registry.d.ts +42 -0
  177. package/dist/playground/commands/registry.js +122 -0
  178. package/dist/playground/commands/suggest.d.ts +37 -0
  179. package/dist/playground/commands/suggest.js +46 -0
  180. package/dist/playground/commands/types.d.ts +111 -0
  181. package/dist/playground/commands/types.js +15 -0
  182. package/dist/playground/index.d.ts +21 -2
  183. package/dist/playground/index.js +27 -2
  184. package/dist/playground/mount.d.ts +19 -5
  185. package/dist/playground/mount.js +16 -8
  186. package/dist/playground/runAction.d.ts +48 -0
  187. package/dist/playground/runAction.js +31 -0
  188. package/dist/registry/builtinNodeTypes.d.ts +53 -0
  189. package/dist/registry/builtinNodeTypes.js +67 -0
  190. package/dist/registry/builtinNodes.d.ts +2 -39
  191. package/dist/registry/builtinNodes.js +6 -53
  192. package/dist/registry/nodeComponentRegistry.d.ts +2 -1
  193. package/dist/schemas/v1/workflow.schema.json +16 -14
  194. package/dist/services/agentSpecExecutionService.d.ts +0 -2
  195. package/dist/services/agentSpecExecutionService.js +0 -2
  196. package/dist/services/apiVariableService.js +12 -26
  197. package/dist/services/categoriesApi.js +3 -6
  198. package/dist/services/chatService.d.ts +4 -3
  199. package/dist/services/chatService.js +13 -18
  200. package/dist/services/dynamicSchemaService.d.ts +31 -4
  201. package/dist/services/dynamicSchemaService.js +62 -33
  202. package/dist/services/historyService.d.ts +30 -8
  203. package/dist/services/historyService.js +51 -15
  204. package/dist/services/interruptService.d.ts +7 -6
  205. package/dist/services/interruptService.js +19 -21
  206. package/dist/services/pipelineSignalService.d.ts +97 -0
  207. package/dist/services/pipelineSignalService.js +94 -0
  208. package/dist/services/playgroundService.d.ts +21 -8
  209. package/dist/services/playgroundService.js +45 -25
  210. package/dist/services/portConfigApi.js +3 -6
  211. package/dist/services/settingsService.d.ts +9 -4
  212. package/dist/services/settingsService.js +23 -12
  213. package/dist/services/workflowLaunchService.d.ts +74 -0
  214. package/dist/services/workflowLaunchService.js +74 -0
  215. package/dist/skins/drafter.d.ts +30 -0
  216. package/dist/skins/drafter.js +198 -0
  217. package/dist/skins/index.d.ts +2 -1
  218. package/dist/skins/index.js +4 -2
  219. package/dist/stores/apiContext.d.ts +11 -0
  220. package/dist/stores/apiContext.js +15 -0
  221. package/dist/stores/categoriesStore.svelte.js +0 -1
  222. package/dist/stores/historyStore.svelte.d.ts +17 -3
  223. package/dist/stores/historyStore.svelte.js +30 -3
  224. package/dist/stores/instanceContainer.svelte.js +5 -0
  225. package/dist/stores/playgroundStore.svelte.js +1 -3
  226. package/dist/stores/settingsStore.svelte.d.ts +13 -0
  227. package/dist/stores/settingsStore.svelte.js +32 -0
  228. package/dist/stores/workflowStore.svelte.d.ts +42 -5
  229. package/dist/stores/workflowStore.svelte.js +109 -32
  230. package/dist/styles/base.css +285 -14
  231. package/dist/styles/tokens.css +60 -2
  232. package/dist/svelte-app.d.ts +18 -1
  233. package/dist/svelte-app.js +75 -110
  234. package/dist/themes/drafter.d.ts +2 -0
  235. package/dist/themes/drafter.js +15 -0
  236. package/dist/themes/index.d.ts +2 -1
  237. package/dist/themes/index.js +8 -2
  238. package/dist/types/auth.d.ts +9 -51
  239. package/dist/types/auth.js +4 -54
  240. package/dist/types/chat.d.ts +5 -1
  241. package/dist/types/events.d.ts +18 -0
  242. package/dist/types/events.js +2 -1
  243. package/dist/types/index.d.ts +84 -29
  244. package/dist/types/index.js +0 -1
  245. package/dist/types/settings.d.ts +28 -1
  246. package/dist/types/settings.js +6 -3
  247. package/dist/types/skin.d.ts +1 -1
  248. package/dist/types/theme.d.ts +16 -2
  249. package/dist/types/uischema.d.ts +5 -0
  250. package/dist/utils/canvasSelection.d.ts +25 -0
  251. package/dist/utils/canvasSelection.js +37 -0
  252. package/dist/utils/colors.d.ts +27 -0
  253. package/dist/utils/colors.js +23 -0
  254. package/dist/utils/connections.js +20 -56
  255. package/dist/utils/edgeStyling.js +9 -5
  256. package/dist/utils/fetchWithAuth.d.ts +36 -15
  257. package/dist/utils/fetchWithAuth.js +53 -23
  258. package/dist/utils/nodeFormSchema.d.ts +51 -0
  259. package/dist/utils/nodeFormSchema.js +87 -0
  260. package/dist/utils/nodeIds.d.ts +1 -1
  261. package/dist/utils/nodeIds.js +1 -1
  262. package/dist/utils/nodeSwap.js +3 -6
  263. package/dist/utils/nodeTypes.js +1 -1
  264. package/dist/utils/portUtils.d.ts +47 -11
  265. package/dist/utils/portUtils.js +67 -14
  266. package/dist/utils/portal.d.ts +18 -0
  267. package/dist/utils/portal.js +34 -0
  268. package/dist/utils/schemaMerge.d.ts +25 -0
  269. package/dist/utils/schemaMerge.js +61 -0
  270. package/package.json +2 -1
@@ -7,7 +7,8 @@
7
7
  * @module services/playgroundService
8
8
  */
9
9
  import { defaultShouldStopPolling } from '../types/playground.js';
10
- import { buildEndpointUrl, getEndpointHeaders } from '../config/endpoints.js';
10
+ import { buildEndpointUrl } from '../config/endpoints.js';
11
+ import { authenticatedFetch } from '../utils/fetchWithAuth.js';
11
12
  import { logger } from '../utils/logger.js';
12
13
  /**
13
14
  * Default polling interval in milliseconds
@@ -64,14 +65,11 @@ export class PlaygroundService {
64
65
  * @param options - Fetch options
65
66
  * @returns The parsed JSON response
66
67
  */
67
- async request(config, url, options = {}) {
68
- const headers = getEndpointHeaders(config, 'playground');
69
- const response = await fetch(url, {
70
- ...options,
71
- headers: {
72
- ...headers,
73
- ...options.headers
74
- }
68
+ async request(config, url, options = {}, authProvider) {
69
+ const response = await authenticatedFetch(url, options, {
70
+ config,
71
+ endpointKey: 'playground',
72
+ authProvider
75
73
  });
76
74
  if (!response.ok) {
77
75
  const errorData = await response.json().catch(() => ({}));
@@ -92,7 +90,7 @@ export class PlaygroundService {
92
90
  * @param options - Optional pagination parameters
93
91
  * @returns Array of playground sessions
94
92
  */
95
- async listSessions(endpointConfig, workflowId, options) {
93
+ async listSessions(endpointConfig, workflowId, options, authProvider) {
96
94
  const config = this.getConfig(endpointConfig);
97
95
  let url = buildEndpointUrl(config, config.endpoints.playground.listSessions, {
98
96
  id: workflowId
@@ -109,7 +107,7 @@ export class PlaygroundService {
109
107
  if (queryString) {
110
108
  url = `${url}?${queryString}`;
111
109
  }
112
- const response = await this.request(config, url);
110
+ const response = await this.request(config, url, {}, authProvider);
113
111
  return response.data ?? [];
114
112
  }
115
113
  /**
@@ -120,7 +118,7 @@ export class PlaygroundService {
120
118
  * @param metadata - Optional session metadata
121
119
  * @returns The created session
122
120
  */
123
- async createSession(endpointConfig, workflowId, name, metadata) {
121
+ async createSession(endpointConfig, workflowId, name, metadata, authProvider) {
124
122
  const config = this.getConfig(endpointConfig);
125
123
  const url = buildEndpointUrl(config, config.endpoints.playground.createSession, {
126
124
  id: workflowId
@@ -128,7 +126,7 @@ export class PlaygroundService {
128
126
  const response = await this.request(config, url, {
129
127
  method: 'POST',
130
128
  body: JSON.stringify({ name, metadata })
131
- });
129
+ }, authProvider);
132
130
  if (!response.data) {
133
131
  throw new Error('Failed to create session: No data returned');
134
132
  }
@@ -140,12 +138,12 @@ export class PlaygroundService {
140
138
  * @param sessionId - The session UUID
141
139
  * @returns The session details
142
140
  */
143
- async getSession(endpointConfig, sessionId) {
141
+ async getSession(endpointConfig, sessionId, authProvider) {
144
142
  const config = this.getConfig(endpointConfig);
145
143
  const url = buildEndpointUrl(config, config.endpoints.playground.getSession, {
146
144
  sessionId
147
145
  });
148
- const response = await this.request(config, url);
146
+ const response = await this.request(config, url, {}, authProvider);
149
147
  if (!response.data) {
150
148
  throw new Error('Session not found');
151
149
  }
@@ -156,14 +154,14 @@ export class PlaygroundService {
156
154
  *
157
155
  * @param sessionId - The session UUID
158
156
  */
159
- async deleteSession(endpointConfig, sessionId) {
157
+ async deleteSession(endpointConfig, sessionId, authProvider) {
160
158
  const config = this.getConfig(endpointConfig);
161
159
  const url = buildEndpointUrl(config, config.endpoints.playground.deleteSession, {
162
160
  sessionId
163
161
  });
164
162
  await this.request(config, url, {
165
163
  method: 'DELETE'
166
- });
164
+ }, authProvider);
167
165
  }
168
166
  // =========================================================================
169
167
  // Message Handling
@@ -181,7 +179,7 @@ export class PlaygroundService {
181
179
  * @param options - Pagination options
182
180
  * @returns Messages and session status
183
181
  */
184
- async getMessages(endpointConfig, sessionId, options = {}) {
182
+ async getMessages(endpointConfig, sessionId, options = {}, authProvider) {
185
183
  const config = this.getConfig(endpointConfig);
186
184
  let url = buildEndpointUrl(config, config.endpoints.playground.getMessages, {
187
185
  sessionId
@@ -203,7 +201,7 @@ export class PlaygroundService {
203
201
  if (queryString) {
204
202
  url = `${url}?${queryString}`;
205
203
  }
206
- return this.request(config, url);
204
+ return this.request(config, url, {}, authProvider);
207
205
  }
208
206
  /**
209
207
  * Send a message to a playground session
@@ -213,7 +211,7 @@ export class PlaygroundService {
213
211
  * @param inputs - Optional additional inputs for workflow nodes
214
212
  * @returns The created message
215
213
  */
216
- async sendMessage(endpointConfig, sessionId, content, inputs) {
214
+ async sendMessage(endpointConfig, sessionId, content, inputs, authProvider) {
217
215
  const config = this.getConfig(endpointConfig);
218
216
  const url = buildEndpointUrl(config, config.endpoints.playground.sendMessage, {
219
217
  sessionId
@@ -225,7 +223,7 @@ export class PlaygroundService {
225
223
  const response = await this.request(config, url, {
226
224
  method: 'POST',
227
225
  body: JSON.stringify(requestBody)
228
- });
226
+ }, authProvider);
229
227
  if (!response.data) {
230
228
  throw new Error('Failed to send message: No data returned');
231
229
  }
@@ -236,14 +234,36 @@ export class PlaygroundService {
236
234
  *
237
235
  * @param sessionId - The session UUID
238
236
  */
239
- async stopExecution(endpointConfig, sessionId) {
237
+ async stopExecution(endpointConfig, sessionId, authProvider) {
240
238
  const config = this.getConfig(endpointConfig);
241
239
  const url = buildEndpointUrl(config, config.endpoints.playground.stopExecution, {
242
240
  sessionId
243
241
  });
244
242
  await this.request(config, url, {
245
243
  method: 'POST'
246
- });
244
+ }, authProvider);
245
+ }
246
+ /**
247
+ * Reset a stuck session to idle, cancelling pending messages and clearing
248
+ * interrupt state.
249
+ *
250
+ * The endpoint is optional in {@link EndpointConfig} — a backend that cannot
251
+ * reset omits it. Callers should check availability first (the slash-command
252
+ * registry does); calling without a configured endpoint throws rather than
253
+ * silently hitting a wrong URL.
254
+ *
255
+ * @param sessionId - The session UUID
256
+ */
257
+ async resetSession(endpointConfig, sessionId, authProvider) {
258
+ const config = this.getConfig(endpointConfig);
259
+ const endpoint = config.endpoints.playground.resetSession;
260
+ if (!endpoint) {
261
+ throw new Error('Session reset is not supported by this backend');
262
+ }
263
+ const url = buildEndpointUrl(config, endpoint, { sessionId });
264
+ await this.request(config, url, {
265
+ method: 'POST'
266
+ }, authProvider);
247
267
  }
248
268
  // =========================================================================
249
269
  // Polling
@@ -257,7 +277,7 @@ export class PlaygroundService {
257
277
  * @param shouldStopPolling - Optional override for stop conditions (default: defaultShouldStopPolling)
258
278
  * @param initialSequenceNumber - Optional sequence number to seed polling from (avoids re-fetching already loaded messages)
259
279
  */
260
- startPolling(endpointConfig, sessionId, callback, interval = DEFAULT_POLLING_INTERVAL, shouldStopPolling, initialSequenceNumber) {
280
+ startPolling(endpointConfig, sessionId, callback, interval = DEFAULT_POLLING_INTERVAL, shouldStopPolling, initialSequenceNumber, authProvider) {
261
281
  // Stop any existing polling
262
282
  this.stopPolling();
263
283
  this.pollingSessionId = sessionId;
@@ -271,7 +291,7 @@ export class PlaygroundService {
271
291
  try {
272
292
  const response = await this.getMessages(endpointConfig, sessionId, {
273
293
  since: this.lastSequenceNumber ?? undefined
274
- });
294
+ }, authProvider);
275
295
  // Update last sequence number cursor
276
296
  if (response.data && response.data.length > 0) {
277
297
  const lastMessage = response.data[response.data.length - 1];
@@ -2,7 +2,8 @@
2
2
  * Port Configuration API Service
3
3
  * Handles fetching port configuration from the backend
4
4
  */
5
- import { buildEndpointUrl, getEndpointHeaders } from '../config/endpoints.js';
5
+ import { buildEndpointUrl } from '../config/endpoints.js';
6
+ import { authenticatedFetch } from '../utils/fetchWithAuth.js';
6
7
  import { DEFAULT_PORT_CONFIG } from '../config/defaultPortConfig.js';
7
8
  import { logger } from '../utils/logger.js';
8
9
  /**
@@ -11,11 +12,7 @@ import { logger } from '../utils/logger.js';
11
12
  export async function fetchPortConfig(endpointConfig, authProvider) {
12
13
  try {
13
14
  const url = buildEndpointUrl(endpointConfig, endpointConfig.endpoints.portConfig);
14
- const configHeaders = getEndpointHeaders(endpointConfig, 'portConfig');
15
- const authHeaders = authProvider ? await authProvider.getAuthHeaders() : {};
16
- const response = await fetch(url, {
17
- headers: { ...configHeaders, ...authHeaders }
18
- });
15
+ const response = await authenticatedFetch(url, {}, { config: endpointConfig, endpointKey: 'portConfig', authProvider });
19
16
  if (!response.ok) {
20
17
  throw new Error(`HTTP ${response.status}: ${response.statusText}`);
21
18
  }
@@ -9,12 +9,15 @@
9
9
  */
10
10
  import type { FlowDropSettings, PartialSettings } from '../types/settings.js';
11
11
  import type { EndpointConfig } from '../config/endpoints.js';
12
+ import type { AuthProvider } from '../types/auth.js';
12
13
  /**
13
- * Set the endpoint configuration for settings API calls
14
+ * Set the endpoint configuration (and optional auth provider) for settings API
15
+ * calls.
14
16
  *
15
17
  * @param config - Endpoint configuration
18
+ * @param provider - Optional auth provider supplying request auth headers
16
19
  */
17
- export declare function setSettingsEndpointConfig(config: EndpointConfig): void;
20
+ export declare function setSettingsEndpointConfig(config: EndpointConfig, provider?: AuthProvider): void;
18
21
  /**
19
22
  * Get the current endpoint configuration
20
23
  *
@@ -62,8 +65,9 @@ export declare class SettingsService {
62
65
  * Create a new settings service instance
63
66
  *
64
67
  * @param config - Endpoint configuration
68
+ * @param authProvider - Optional auth provider applied to settings requests
65
69
  */
66
- constructor(config: EndpointConfig);
70
+ constructor(config: EndpointConfig, authProvider?: AuthProvider);
67
71
  /**
68
72
  * Get user preferences from the backend
69
73
  *
@@ -87,6 +91,7 @@ export declare class SettingsService {
87
91
  * Create a settings service instance
88
92
  *
89
93
  * @param config - Endpoint configuration
94
+ * @param authProvider - Optional auth provider applied to settings requests
90
95
  * @returns SettingsService instance
91
96
  */
92
- export declare function createSettingsService(config: EndpointConfig): SettingsService;
97
+ export declare function createSettingsService(config: EndpointConfig, authProvider?: AuthProvider): SettingsService;
@@ -7,7 +7,8 @@
7
7
  *
8
8
  * @module services/settingsService
9
9
  */
10
- import { buildEndpointUrl, getEndpointHeaders } from '../config/endpoints.js';
10
+ import { buildEndpointUrl } from '../config/endpoints.js';
11
+ import { authenticatedFetch } from '../utils/fetchWithAuth.js';
11
12
  // =========================================================================
12
13
  // Configuration
13
14
  // =========================================================================
@@ -16,12 +17,20 @@ import { buildEndpointUrl, getEndpointHeaders } from '../config/endpoints.js';
16
17
  */
17
18
  let endpointConfig = null;
18
19
  /**
19
- * Set the endpoint configuration for settings API calls
20
+ * Auth provider reference, applied to every settings request so the backend
21
+ * sync path authenticates consistently with the rest of the library.
22
+ */
23
+ let authProvider;
24
+ /**
25
+ * Set the endpoint configuration (and optional auth provider) for settings API
26
+ * calls.
20
27
  *
21
28
  * @param config - Endpoint configuration
29
+ * @param provider - Optional auth provider supplying request auth headers
22
30
  */
23
- export function setSettingsEndpointConfig(config) {
31
+ export function setSettingsEndpointConfig(config, provider) {
24
32
  endpointConfig = config;
33
+ authProvider = provider;
25
34
  }
26
35
  /**
27
36
  * Get the current endpoint configuration
@@ -47,10 +56,10 @@ async function settingsRequest(endpointKey, endpointPath, options = {}) {
47
56
  throw new Error('Endpoint configuration not set. Call setSettingsEndpointConfig() first.');
48
57
  }
49
58
  const url = buildEndpointUrl(endpointConfig, endpointPath);
50
- const headers = getEndpointHeaders(endpointConfig, endpointKey);
51
- const response = await fetch(url, {
52
- headers,
53
- ...options
59
+ const response = await authenticatedFetch(url, options, {
60
+ config: endpointConfig,
61
+ endpointKey,
62
+ authProvider
54
63
  });
55
64
  // Check if response is JSON
56
65
  const contentType = response.headers.get('content-type');
@@ -151,11 +160,12 @@ export class SettingsService {
151
160
  * Create a new settings service instance
152
161
  *
153
162
  * @param config - Endpoint configuration
163
+ * @param authProvider - Optional auth provider applied to settings requests
154
164
  */
155
- constructor(config) {
165
+ constructor(config, authProvider) {
156
166
  this.config = config;
157
- // Also set the module-level config
158
- setSettingsEndpointConfig(config);
167
+ // Also set the module-level config + auth provider
168
+ setSettingsEndpointConfig(config, authProvider);
159
169
  }
160
170
  /**
161
171
  * Get user preferences from the backend
@@ -189,8 +199,9 @@ export class SettingsService {
189
199
  * Create a settings service instance
190
200
  *
191
201
  * @param config - Endpoint configuration
202
+ * @param authProvider - Optional auth provider applied to settings requests
192
203
  * @returns SettingsService instance
193
204
  */
194
- export function createSettingsService(config) {
195
- return new SettingsService(config);
205
+ export function createSettingsService(config, authProvider) {
206
+ return new SettingsService(config, authProvider);
196
207
  }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Workflow Launch Service
3
+ *
4
+ * Starts a workflow run with named inputs — the explicit verb for "run this",
5
+ * as opposed to posting a chat message and relying on a run starting as a side
6
+ * effect.
7
+ *
8
+ * Why this matters beyond tidiness: launching by message fabricates a user turn
9
+ * that enters the conversation and is fed back as input on the next turn. A
10
+ * launch has no message, so nothing is fabricated.
11
+ *
12
+ * Like {@link pipelineSignalService}, this returns a typed result rather than
13
+ * throwing — invalid inputs and an invalid stored workflow are expected
14
+ * outcomes with distinct, per-field presentation, not exceptional ones.
15
+ *
16
+ * @module services/workflowLaunchService
17
+ */
18
+ import type { EndpointConfig } from '../config/endpoints.js';
19
+ import type { AuthProvider } from '../types/auth.js';
20
+ /** A single per-input validation failure reported by the backend. */
21
+ export interface LaunchInputError {
22
+ /** Machine-readable error code. */
23
+ code: string;
24
+ /** Human-readable explanation. */
25
+ message: string;
26
+ /** Which input the error belongs to, when the backend can attribute it. */
27
+ locator?: string;
28
+ }
29
+ export type LaunchResult =
30
+ /** The run was created. `status` is the backend's own lifecycle value. */
31
+ {
32
+ status: 'launched';
33
+ pipelineId: string;
34
+ runStatus?: string;
35
+ queued?: boolean;
36
+ }
37
+ /** Inputs were refused — unknown key, wrong type, missing required. */
38
+ | {
39
+ status: 'invalid-input';
40
+ message: string;
41
+ }
42
+ /**
43
+ * The *stored workflow* is structurally invalid, with per-error locators.
44
+ * Distinct from bad inputs: nothing the caller passed is at fault.
45
+ */
46
+ | {
47
+ status: 'invalid-workflow';
48
+ message: string;
49
+ errors: LaunchInputError[];
50
+ } | {
51
+ status: 'failed';
52
+ message: string;
53
+ } | {
54
+ status: 'unsupported';
55
+ };
56
+ export interface LaunchOptions {
57
+ /** Named inputs, resolved server-side against the workflow's declared manifest. */
58
+ inputs?: Record<string, unknown>;
59
+ /** Attribute the run to a session, so its messages land in that conversation. */
60
+ sessionId?: string;
61
+ }
62
+ declare class WorkflowLaunchService {
63
+ /** True when this configuration exposes an explicit launch verb. */
64
+ isSupported(config: EndpointConfig | null): boolean;
65
+ /**
66
+ * Launch a workflow run.
67
+ *
68
+ * An empty `inputs` is meaningful and supported — it means "run with no
69
+ * inputs", which is a legitimate thing to want and is why this verb exists.
70
+ */
71
+ launch(config: EndpointConfig | null, workflowId: string, options?: LaunchOptions, authProvider?: AuthProvider): Promise<LaunchResult>;
72
+ }
73
+ export declare const workflowLaunchService: WorkflowLaunchService;
74
+ export { WorkflowLaunchService };
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Workflow Launch Service
3
+ *
4
+ * Starts a workflow run with named inputs — the explicit verb for "run this",
5
+ * as opposed to posting a chat message and relying on a run starting as a side
6
+ * effect.
7
+ *
8
+ * Why this matters beyond tidiness: launching by message fabricates a user turn
9
+ * that enters the conversation and is fed back as input on the next turn. A
10
+ * launch has no message, so nothing is fabricated.
11
+ *
12
+ * Like {@link pipelineSignalService}, this returns a typed result rather than
13
+ * throwing — invalid inputs and an invalid stored workflow are expected
14
+ * outcomes with distinct, per-field presentation, not exceptional ones.
15
+ *
16
+ * @module services/workflowLaunchService
17
+ */
18
+ import { buildEndpointUrl } from '../config/endpoints.js';
19
+ import { authenticatedFetch } from '../utils/fetchWithAuth.js';
20
+ import { logger } from '../utils/logger.js';
21
+ class WorkflowLaunchService {
22
+ /** True when this configuration exposes an explicit launch verb. */
23
+ isSupported(config) {
24
+ return config?.endpoints?.workflows?.run != null;
25
+ }
26
+ /**
27
+ * Launch a workflow run.
28
+ *
29
+ * An empty `inputs` is meaningful and supported — it means "run with no
30
+ * inputs", which is a legitimate thing to want and is why this verb exists.
31
+ */
32
+ async launch(config, workflowId, options = {}, authProvider) {
33
+ const endpoint = config?.endpoints?.workflows?.run;
34
+ if (!config || !endpoint)
35
+ return { status: 'unsupported' };
36
+ const url = buildEndpointUrl(config, endpoint, { workflowId });
37
+ const body = {};
38
+ if (options.inputs && Object.keys(options.inputs).length > 0)
39
+ body.inputs = options.inputs;
40
+ if (options.sessionId)
41
+ body.sessionId = options.sessionId;
42
+ const response = await authenticatedFetch(url, {
43
+ method: 'POST',
44
+ headers: { 'Content-Type': 'application/json' },
45
+ body: JSON.stringify(body)
46
+ }, { config, endpointKey: 'workflows', authProvider });
47
+ const payload = (await response.json().catch(() => ({})));
48
+ if (response.ok) {
49
+ const pipelineId = payload.data?.pipelineId;
50
+ if (!pipelineId) {
51
+ return { status: 'failed', message: 'Launch succeeded but returned no pipeline id' };
52
+ }
53
+ return {
54
+ status: 'launched',
55
+ pipelineId,
56
+ runStatus: payload.data?.status,
57
+ queued: payload.data?.queued
58
+ };
59
+ }
60
+ const message = payload.error ?? payload.message ?? `HTTP ${response.status}: ${response.statusText}`;
61
+ logger.warn(`Workflow launch refused for ${workflowId}:`, message);
62
+ // 422 carries per-error locators for a structurally invalid stored
63
+ // definition — a different problem from the caller passing bad inputs.
64
+ if (response.status === 422) {
65
+ return { status: 'invalid-workflow', message, errors: payload.details ?? [] };
66
+ }
67
+ if (response.status === 400) {
68
+ return { status: 'invalid-input', message };
69
+ }
70
+ return { status: 'failed', message };
71
+ }
72
+ }
73
+ export const workflowLaunchService = new WorkflowLaunchService();
74
+ export { WorkflowLaunchService };
@@ -0,0 +1,30 @@
1
+ import type { FlowDropSkin } from '../types/skin';
2
+ /**
3
+ * Drafter — a fresh, modern "drafting workspace" skin for the whole editor
4
+ * environment (see ref-image.png): a fresh white shell around a mint/aqua
5
+ * canvas with soft cyan/teal technical grid lines, crisp engineering geometry
6
+ * and clean teal-ink text — not a neutral admin UI and not an all-cyan shell.
7
+ *
8
+ * Unlike a canvas-only skin, Drafter themes the entire shell so it reads as one
9
+ * designed environment:
10
+ * - App chrome (navbar, sidebars, inspector, status bars, form fields) stays
11
+ * white/near-white for a clean fresh product feel.
12
+ * - The mint/aqua personality lives in the canvas, node glass, focus rings,
13
+ * selected states and small technical accents.
14
+ * - Disabled/read-only surfaces use quiet light grey so state remains obvious.
15
+ * - Borders are mostly neutral hairlines; strong/focus borders + node outlines
16
+ * are teal/cyan ink (--fd-ring / --fd-border-strong / --fd-node-border).
17
+ * - Focus rings are cyan (--fd-ring), not the default blue.
18
+ * - Nodes are frosted glass with a faint inner highlight; the minimap + zoom
19
+ * controls share the same vocabulary.
20
+ * - Note/instruction cards read as cool annotations (translucent tint + slate
21
+ * ink border), never as a filled "success" card.
22
+ * - Emerald/green is reserved for primary actions, selection and live edges
23
+ * (--fd-primary) — it is not used for every outline.
24
+ *
25
+ * Data-type port colors and category icon colors are left untouched so they keep
26
+ * their full color against the draft surface. The square grid is rendered by
27
+ * WorkflowEditor via config.canvas.grid = 'lines'; --fd-grid-pattern-color
28
+ * colors it. Ships light + dark variants.
29
+ */
30
+ export declare const drafterSkin: FlowDropSkin;