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

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 (228) hide show
  1. package/CHANGELOG.md +173 -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/commands/executor.js +51 -26
  9. package/dist/commands/storeIntegration.svelte.js +11 -1
  10. package/dist/commands/types.js +5 -5
  11. package/dist/components/App.svelte +547 -386
  12. package/dist/components/App.svelte.d.ts +16 -8
  13. package/dist/components/Button.stories.svelte +65 -0
  14. package/dist/components/Button.stories.svelte.d.ts +19 -0
  15. package/dist/components/Button.svelte +62 -0
  16. package/dist/components/Button.svelte.d.ts +24 -0
  17. package/dist/components/CanvasIconButton.svelte +76 -0
  18. package/dist/components/CanvasIconButton.svelte.d.ts +18 -0
  19. package/dist/components/ConfigForm.svelte +167 -562
  20. package/dist/components/ConfigForm.svelte.d.ts +24 -7
  21. package/dist/components/ConfigModal.svelte +9 -1
  22. package/dist/components/ConfigPanel.svelte +234 -15
  23. package/dist/components/ConfigPanel.svelte.d.ts +6 -0
  24. package/dist/components/EditorStatusBar.stories.svelte +44 -0
  25. package/dist/components/EditorStatusBar.stories.svelte.d.ts +27 -0
  26. package/dist/components/EditorStatusBar.svelte +99 -0
  27. package/dist/components/EditorStatusBar.svelte.d.ts +15 -0
  28. package/dist/components/IconButton.svelte +80 -0
  29. package/dist/components/IconButton.svelte.d.ts +30 -0
  30. package/dist/components/Input.svelte +74 -0
  31. package/dist/components/Input.svelte.d.ts +17 -0
  32. package/dist/components/LogoWordmark.svelte +113 -0
  33. package/dist/components/LogoWordmark.svelte.d.ts +26 -0
  34. package/dist/components/Navbar.svelte +17 -63
  35. package/dist/components/Navbar.svelte.d.ts +3 -0
  36. package/dist/components/NodeSidebar.svelte +21 -126
  37. package/dist/components/NodeSwapPicker.svelte +12 -30
  38. package/dist/components/PipelineStatus.svelte +6 -1
  39. package/dist/components/PipelineStatus.svelte.d.ts +3 -0
  40. package/dist/components/PortMappingRow.svelte +0 -2
  41. package/dist/components/SchemaForm.svelte +4 -14
  42. package/dist/components/Select.svelte +53 -0
  43. package/dist/components/Select.svelte.d.ts +15 -0
  44. package/dist/components/SettingsModal.svelte +0 -5
  45. package/dist/components/SettingsPanel.svelte +24 -6
  46. package/dist/components/Textarea.svelte +39 -0
  47. package/dist/components/Textarea.svelte.d.ts +12 -0
  48. package/dist/components/ThemeToggle.svelte +15 -94
  49. package/dist/components/UniversalNode.svelte +36 -4
  50. package/dist/components/UniversalNode.svelte.d.ts +1 -1
  51. package/dist/components/WorkflowEditor.svelte +66 -52
  52. package/dist/components/WorkflowEditor.svelte.d.ts +21 -0
  53. package/dist/components/chat/AIChatPanel.svelte +7 -2
  54. package/dist/components/console/ConsoleAutocomplete.svelte +1 -1
  55. package/dist/components/console/ConsoleInput.svelte +3 -3
  56. package/dist/components/console/ConsoleOutput.svelte +2 -2
  57. package/dist/components/form/FormArray.svelte +37 -173
  58. package/dist/components/form/FormAutocomplete.svelte +18 -15
  59. package/dist/components/form/FormCheckboxGroup.svelte +1 -5
  60. package/dist/components/form/FormCodeEditor.svelte +9 -7
  61. package/dist/components/form/FormField.svelte +18 -42
  62. package/dist/components/form/FormFieldLight.svelte +52 -48
  63. package/dist/components/form/FormFieldLight.svelte.d.ts +12 -0
  64. package/dist/components/form/FormFieldset.svelte +45 -11
  65. package/dist/components/form/FormMarkdownEditor.svelte +8 -5
  66. package/dist/components/form/FormNumberField.svelte +4 -36
  67. package/dist/components/form/FormPorts.svelte +262 -0
  68. package/dist/components/form/FormPorts.svelte.d.ts +13 -0
  69. package/dist/components/form/FormRangeField.svelte +61 -30
  70. package/dist/components/form/FormSelect.svelte +13 -75
  71. package/dist/components/form/FormTemplateEditor.svelte +6 -4
  72. package/dist/components/form/FormTextField.svelte +3 -35
  73. package/dist/components/form/FormTextarea.svelte +4 -39
  74. package/dist/components/form/FormToggle.svelte +0 -4
  75. package/dist/components/form/FormUISchemaRenderer.svelte +3 -1
  76. package/dist/components/form/resolveFieldType.d.ts +24 -0
  77. package/dist/components/form/resolveFieldType.js +55 -0
  78. package/dist/components/icons/CloseIcon.svelte +6 -0
  79. package/dist/components/icons/CloseIcon.svelte.d.ts +26 -0
  80. package/dist/components/icons/CommandLineIcon.svelte +15 -0
  81. package/dist/components/icons/CommandLineIcon.svelte.d.ts +26 -0
  82. package/dist/components/icons/MenuIcon.svelte +4 -0
  83. package/dist/components/icons/MenuIcon.svelte.d.ts +26 -0
  84. package/dist/components/icons/MenuOpenIcon.svelte +6 -0
  85. package/dist/components/icons/MenuOpenIcon.svelte.d.ts +26 -0
  86. package/dist/components/interrupt/ChoicePrompt.svelte +0 -10
  87. package/dist/components/interrupt/ConfirmationPrompt.svelte +0 -5
  88. package/dist/components/interrupt/InterruptBubble.svelte +11 -12
  89. package/dist/components/interrupt/ReviewPrompt.svelte +0 -20
  90. package/dist/components/interrupt/TextInputPrompt.svelte +0 -6
  91. package/dist/components/layouts/MainLayout.svelte +4 -5
  92. package/dist/components/nodes/AtomNode.svelte +62 -76
  93. package/dist/components/nodes/AtomNode.svelte.d.ts +1 -1
  94. package/dist/components/nodes/GatewayNode.svelte +117 -164
  95. package/dist/components/nodes/GatewayNode.svelte.d.ts +1 -1
  96. package/dist/components/nodes/IdeaNode.svelte +72 -98
  97. package/dist/components/nodes/IdeaNode.svelte.d.ts +8 -4
  98. package/dist/components/nodes/NodeConfigButton.svelte +86 -0
  99. package/dist/components/nodes/NodeConfigButton.svelte.d.ts +15 -0
  100. package/dist/components/nodes/NotesNode.svelte +76 -85
  101. package/dist/components/nodes/NotesNode.svelte.d.ts +8 -4
  102. package/dist/components/nodes/SimpleNode.svelte +59 -133
  103. package/dist/components/nodes/SimpleNode.svelte.d.ts +4 -4
  104. package/dist/components/nodes/SquareNode.svelte +110 -164
  105. package/dist/components/nodes/SquareNode.svelte.d.ts +4 -4
  106. package/dist/components/nodes/TerminalNode.svelte +62 -124
  107. package/dist/components/nodes/TerminalNode.svelte.d.ts +4 -4
  108. package/dist/components/nodes/ToolNode.svelte +92 -103
  109. package/dist/components/nodes/ToolNode.svelte.d.ts +6 -6
  110. package/dist/components/nodes/WorkflowNode.svelte +132 -191
  111. package/dist/components/nodes/WorkflowNode.svelte.d.ts +1 -1
  112. package/dist/components/playground/ChatInput.svelte +0 -1
  113. package/dist/components/playground/InputCollector.svelte +11 -48
  114. package/dist/components/playground/PipelineKanbanView.svelte +6 -4
  115. package/dist/components/playground/PipelineKanbanView.svelte.d.ts +2 -0
  116. package/dist/components/playground/PipelinePanel.svelte +20 -3
  117. package/dist/components/playground/PipelinePanel.svelte.d.ts +2 -0
  118. package/dist/components/playground/PipelineTableView.svelte +6 -4
  119. package/dist/components/playground/PipelineTableView.svelte.d.ts +2 -0
  120. package/dist/components/playground/Playground.svelte +76 -25
  121. package/dist/components/playground/Playground.svelte.d.ts +3 -0
  122. package/dist/components/playground/PlaygroundApp.svelte +6 -1
  123. package/dist/components/playground/PlaygroundApp.svelte.d.ts +3 -0
  124. package/dist/components/playground/PlaygroundModal.svelte +5 -0
  125. package/dist/components/playground/PlaygroundModal.svelte.d.ts +3 -0
  126. package/dist/components/playground/PlaygroundStudio.svelte +7 -6
  127. package/dist/components/playground/PlaygroundStudio.svelte.d.ts +3 -0
  128. package/dist/components/playground/pipelineViewUtils.svelte.d.ts +2 -1
  129. package/dist/components/playground/pipelineViewUtils.svelte.js +2 -2
  130. package/dist/components/surfaces/SurfaceOverlay.svelte +153 -0
  131. package/dist/components/surfaces/SurfaceOverlay.svelte.d.ts +14 -0
  132. package/dist/components/surfaces/TabbedSurface.svelte +133 -0
  133. package/dist/components/surfaces/TabbedSurface.svelte.d.ts +27 -0
  134. package/dist/config/endpoints.d.ts +23 -0
  135. package/dist/config/endpoints.js +28 -0
  136. package/dist/core/index.d.ts +2 -3
  137. package/dist/core/index.js +2 -6
  138. package/dist/display/index.d.ts +6 -1
  139. package/dist/display/index.js +9 -1
  140. package/dist/editor/index.d.ts +1 -1
  141. package/dist/editor/index.js +1 -1
  142. package/dist/form/full.d.ts +2 -1
  143. package/dist/form/full.js +4 -1
  144. package/dist/form/index.d.ts +0 -1
  145. package/dist/form/index.js +3 -2
  146. package/dist/helpers/workflowEditorHelper.d.ts +4 -2
  147. package/dist/helpers/workflowEditorHelper.js +8 -8
  148. package/dist/messages/index.d.ts +1 -1
  149. package/dist/messages/index.js +1 -1
  150. package/dist/openapi/v1/openapi.yaml +35 -23
  151. package/dist/playground/index.d.ts +2 -2
  152. package/dist/playground/index.js +2 -2
  153. package/dist/playground/mount.d.ts +19 -5
  154. package/dist/playground/mount.js +16 -8
  155. package/dist/registry/builtinNodeTypes.d.ts +53 -0
  156. package/dist/registry/builtinNodeTypes.js +67 -0
  157. package/dist/registry/builtinNodes.d.ts +2 -39
  158. package/dist/registry/builtinNodes.js +6 -53
  159. package/dist/registry/nodeComponentRegistry.d.ts +2 -1
  160. package/dist/schemas/v1/workflow.schema.json +16 -14
  161. package/dist/services/agentSpecExecutionService.d.ts +0 -2
  162. package/dist/services/agentSpecExecutionService.js +0 -2
  163. package/dist/services/apiVariableService.js +12 -26
  164. package/dist/services/categoriesApi.js +3 -6
  165. package/dist/services/chatService.d.ts +4 -3
  166. package/dist/services/chatService.js +13 -18
  167. package/dist/services/dynamicSchemaService.d.ts +31 -4
  168. package/dist/services/dynamicSchemaService.js +62 -33
  169. package/dist/services/historyService.d.ts +30 -8
  170. package/dist/services/historyService.js +51 -15
  171. package/dist/services/interruptService.d.ts +7 -6
  172. package/dist/services/interruptService.js +19 -21
  173. package/dist/services/playgroundService.d.ts +9 -8
  174. package/dist/services/playgroundService.js +23 -25
  175. package/dist/services/portConfigApi.js +3 -6
  176. package/dist/services/settingsService.d.ts +9 -4
  177. package/dist/services/settingsService.js +23 -12
  178. package/dist/skins/drafter.d.ts +30 -0
  179. package/dist/skins/drafter.js +198 -0
  180. package/dist/skins/index.d.ts +2 -1
  181. package/dist/skins/index.js +4 -2
  182. package/dist/stores/apiContext.d.ts +11 -0
  183. package/dist/stores/apiContext.js +15 -0
  184. package/dist/stores/categoriesStore.svelte.js +0 -1
  185. package/dist/stores/historyStore.svelte.d.ts +17 -3
  186. package/dist/stores/historyStore.svelte.js +30 -3
  187. package/dist/stores/instanceContainer.svelte.js +5 -0
  188. package/dist/stores/playgroundStore.svelte.js +1 -3
  189. package/dist/stores/settingsStore.svelte.d.ts +13 -0
  190. package/dist/stores/settingsStore.svelte.js +32 -0
  191. package/dist/stores/workflowStore.svelte.d.ts +42 -5
  192. package/dist/stores/workflowStore.svelte.js +109 -32
  193. package/dist/styles/base.css +285 -14
  194. package/dist/styles/tokens.css +60 -2
  195. package/dist/svelte-app.d.ts +18 -1
  196. package/dist/svelte-app.js +75 -110
  197. package/dist/themes/drafter.d.ts +2 -0
  198. package/dist/themes/drafter.js +15 -0
  199. package/dist/themes/index.d.ts +2 -1
  200. package/dist/themes/index.js +8 -2
  201. package/dist/types/auth.d.ts +9 -51
  202. package/dist/types/auth.js +4 -54
  203. package/dist/types/events.d.ts +18 -0
  204. package/dist/types/events.js +2 -1
  205. package/dist/types/index.d.ts +84 -29
  206. package/dist/types/index.js +0 -1
  207. package/dist/types/settings.d.ts +17 -1
  208. package/dist/types/settings.js +4 -2
  209. package/dist/types/skin.d.ts +1 -1
  210. package/dist/types/theme.d.ts +16 -2
  211. package/dist/types/uischema.d.ts +5 -0
  212. package/dist/utils/colors.d.ts +27 -0
  213. package/dist/utils/colors.js +23 -0
  214. package/dist/utils/connections.js +20 -56
  215. package/dist/utils/edgeStyling.js +9 -5
  216. package/dist/utils/fetchWithAuth.d.ts +36 -15
  217. package/dist/utils/fetchWithAuth.js +53 -23
  218. package/dist/utils/nodeIds.d.ts +1 -1
  219. package/dist/utils/nodeIds.js +1 -1
  220. package/dist/utils/nodeSwap.js +3 -6
  221. package/dist/utils/nodeTypes.js +1 -1
  222. package/dist/utils/portUtils.d.ts +47 -11
  223. package/dist/utils/portUtils.js +67 -14
  224. package/dist/utils/portal.d.ts +18 -0
  225. package/dist/utils/portal.js +34 -0
  226. package/dist/utils/schemaMerge.d.ts +25 -0
  227. package/dist/utils/schemaMerge.js +61 -0
  228. package/package.json +2 -1
@@ -2,9 +2,9 @@
2
2
  * Core types for the Workflow Library
3
3
  */
4
4
  import type { Component } from 'svelte';
5
- import type { Node, Edge, XYPosition } from '@xyflow/svelte';
6
- import { ConnectionLineType } from '@xyflow/svelte';
5
+ import type { Node, Edge, XYPosition, ConnectionLineType } from '@xyflow/svelte';
7
6
  import type { EndpointConfig } from '../config/endpoints.js';
7
+ import type { AuthProvider } from './auth.js';
8
8
  /**
9
9
  * Built-in node categories that ship with FlowDrop.
10
10
  * These categories have predefined icons, colors, and display names.
@@ -117,12 +117,57 @@ export interface NodePort {
117
117
  required?: boolean;
118
118
  description?: string;
119
119
  defaultValue?: unknown;
120
+ /**
121
+ * Whether this port is exposed when the instance sets no explicit exposure
122
+ * for it. Defaults to `true` (a missing flag reads as exposed). Reserved ports
123
+ * that ship hidden until an author opts in (e.g. the `error` output) carry
124
+ * `false`. The instance's `ports` config can override it per port. See
125
+ * `.claude/plans/exposed-ports.md`.
126
+ */
127
+ exposedByDefault?: boolean;
128
+ /**
129
+ * Default sort weight for the port's render position, ascending; ties break
130
+ * on declaration order. Author-declared ports default to `0`. Reserved ports
131
+ * (the `error` output and `trigger`/`tool` control ports) need no value — the
132
+ * library sinks them to the bottom automatically (see
133
+ * `RESERVED_PORT_DISPLAY_ORDER`); set this only to override that. Cosmetic
134
+ * only. The instance's `ports` config order overrides it.
135
+ */
136
+ displayOrder?: number;
120
137
  /**
121
138
  * Optional JSON Schema describing the structure of data on this port.
122
139
  * Used for template variable autocomplete to drill into nested properties.
123
140
  */
124
141
  schema?: OutputSchema | InputSchema;
125
142
  }
143
+ /**
144
+ * One entry in a {@link PortsConfig} direction list: a port id, with display
145
+ * order encoded by its position and an optional exposure override.
146
+ */
147
+ export interface PortConfigEntry {
148
+ id: string;
149
+ /**
150
+ * Explicit exposure for this port. Stored only when it diverges from the
151
+ * port's metadata `exposedByDefault`. In v2 exposure is semantic: a
152
+ * not-exposed port is hidden on the canvas, not wireable, and not
153
+ * runtime-overridable.
154
+ */
155
+ exposed?: boolean;
156
+ }
157
+ /**
158
+ * Per-instance port order + exposure, stored in `data.config.ports`.
159
+ *
160
+ * A per-direction ordered list of the node's ports: array index encodes display
161
+ * order relative to the metadata default, and the optional `exposed` flag
162
+ * overrides the port's `exposedByDefault`. A port the author never touched is
163
+ * absent from the list; an untouched node stores no `ports` key at all. Order
164
+ * is cosmetic (the engine ignores it); exposure is semantic. See
165
+ * `.claude/plans/exposed-ports.md`.
166
+ */
167
+ export interface PortsConfig {
168
+ inputs?: PortConfigEntry[];
169
+ outputs?: PortConfigEntry[];
170
+ }
126
171
  /**
127
172
  * Absolute position of a port handle in canvas space.
128
173
  * Used by proximity connect and other features that need port positions.
@@ -327,7 +372,7 @@ export interface AutocompleteConfig {
327
372
  * method: "GET",
328
373
  * headers: { "X-Custom-Header": "value" },
329
374
  * parameterMapping: {
330
- * nodeTypeId: "metadata.id",
375
+ * nodeTypeId: "metadata.node_type_id",
331
376
  * instanceId: "id"
332
377
  * }
333
378
  * };
@@ -352,7 +397,7 @@ export interface DynamicSchemaEndpoint {
352
397
  /**
353
398
  * Maps template variables to their source paths.
354
399
  * Keys are variable names used in the URL, values are dot-notation paths
355
- * to resolve from the node context (e.g., "metadata.id", "config.apiKey", "id")
400
+ * to resolve from the node context (e.g., "metadata.node_type_id", "config.apiKey", "id")
356
401
  */
357
402
  parameterMapping?: Record<string, string>;
358
403
  /**
@@ -370,6 +415,35 @@ export interface DynamicSchemaEndpoint {
370
415
  * @default true
371
416
  */
372
417
  cacheSchema?: boolean;
418
+ /**
419
+ * How the fetched schema combines with the node's static schema
420
+ * (the direct `schema` prop or `metadata.configSchema`).
421
+ *
422
+ * - `"replace"` (default): the fetched schema is used as-is and the static
423
+ * schema is ignored. This is the historical behaviour.
424
+ * - `"merge"`: the fetched schema is layered onto the static schema —
425
+ * properties are merged (fetched wins per key) and `required` is unioned —
426
+ * so the endpoint only has to return the fields it actually drives.
427
+ *
428
+ * When there is no static schema to combine with, both strategies behave
429
+ * identically: the fetched schema is the form.
430
+ *
431
+ * @default "replace"
432
+ */
433
+ mergeStrategy?: 'replace' | 'merge';
434
+ /**
435
+ * Restricts the fetched schema to a region of the static schema instead of
436
+ * the whole form. A dot-path of property keys descending through nested
437
+ * object `properties` (e.g. `"advanced"` or `"advanced.retry"`); the fetched
438
+ * schema is spliced in at that location and every other field stays static.
439
+ *
440
+ * Use this to make just one section (or one field) server-driven while
441
+ * authoring the rest of the form locally. `mergeStrategy` then decides whether
442
+ * the fetched schema replaces or merges into the property at that path.
443
+ *
444
+ * When omitted, the fetch applies at the form root (per `mergeStrategy`).
445
+ */
446
+ target?: string;
373
447
  }
374
448
  /**
375
449
  * External edit link configuration
@@ -381,7 +455,7 @@ export interface DynamicSchemaEndpoint {
381
455
  * url: "https://admin.example.com/nodes/{nodeTypeId}/edit/{instanceId}",
382
456
  * label: "Configure in Admin Panel",
383
457
  * parameterMapping: {
384
- * nodeTypeId: "metadata.id",
458
+ * nodeTypeId: "metadata.node_type_id",
385
459
  * instanceId: "id"
386
460
  * },
387
461
  * openInNewTab: true
@@ -408,7 +482,7 @@ export interface ExternalEditLink {
408
482
  /**
409
483
  * Maps template variables to their source paths.
410
484
  * Keys are variable names used in the URL, values are dot-notation paths
411
- * to resolve from the node context (e.g., "metadata.id", "config.apiKey", "id")
485
+ * to resolve from the node context (e.g., "metadata.node_type_id", "config.apiKey", "id")
412
486
  */
413
487
  parameterMapping?: Record<string, string>;
414
488
  /**
@@ -529,27 +603,8 @@ export interface AtomUIConfig {
529
603
  maxWidth?: number;
530
604
  }
531
605
  export interface NodeUIExtensions {
532
- /** Show/hide unconnected handles (ports) to reduce visual noise */
533
- hideUnconnectedHandles?: boolean;
534
606
  /** Display/behavior config for minimalist atom nodes (Constant, Cast, …) */
535
607
  atom?: AtomUIConfig;
536
- /**
537
- * Visual-only port display order (no effect on execution).
538
- * Arrays of port IDs in the desired render order.
539
- * Ports not listed appear at the end in metadata order.
540
- */
541
- portOrder?: {
542
- inputs?: string[];
543
- outputs?: string[];
544
- };
545
- /**
546
- * Manually hidden ports (visual only, no effect on execution).
547
- * Required ports cannot be added here — enforced in the UI.
548
- */
549
- hiddenPorts?: {
550
- inputs?: string[];
551
- outputs?: string[];
552
- };
553
608
  /** Custom styles or theme overrides */
554
609
  style?: Record<string, unknown>;
555
610
  /** Any other UI-specific settings */
@@ -563,7 +618,6 @@ export interface NodeUIExtensions {
563
618
  * ```typescript
564
619
  * const extensions: NodeExtensions = {
565
620
  * ui: {
566
- * hideUnconnectedHandles: true,
567
621
  * style: { opacity: 0.8 }
568
622
  * },
569
623
  * "myapp:analytics": {
@@ -602,7 +656,8 @@ export interface NodeExtensions {
602
656
  * Node configuration metadata
603
657
  */
604
658
  export interface NodeMetadata {
605
- id: string;
659
+ /** The node type entity id — the runtime's resolution anchor. */
660
+ node_type_id: string;
606
661
  name: string;
607
662
  type?: NodeType;
608
663
  /**
@@ -1132,8 +1187,6 @@ export interface WorkflowNode extends Node {
1132
1187
  isProcessing?: boolean;
1133
1188
  /** Error message if the node execution failed */
1134
1189
  error?: string;
1135
- /** Alternative node identifier */
1136
- nodeId?: string;
1137
1190
  /** Node execution tracking information */
1138
1191
  executionInfo?: NodeExecutionInfo;
1139
1192
  /**
@@ -1231,6 +1284,8 @@ export interface PipelineViewProps {
1231
1284
  pipelineId: string | null;
1232
1285
  workflow: Workflow;
1233
1286
  endpointConfig: EndpointConfig;
1287
+ /** Auth provider for building authenticated API clients in custom views. */
1288
+ authProvider?: AuthProvider;
1234
1289
  refreshTrigger?: number;
1235
1290
  }
1236
1291
  /** A custom view injected into the PipelinePanel view switcher. */
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * Core types for the Workflow Library
3
3
  */
4
- import { ConnectionLineType } from '@xyflow/svelte';
5
4
  /**
6
5
  * Default workflow format used when none is specified.
7
6
  */
@@ -45,6 +45,18 @@ export interface EditorSettings {
45
45
  /** Distance threshold in pixels for proximity connect */
46
46
  proximityConnectDistance: number;
47
47
  }
48
+ /**
49
+ * Where an auxiliary surface (config panel, console/chat) is hosted.
50
+ *
51
+ * - `sidebar` — the right rail.
52
+ * - `modal` — a centered overlay floating above the canvas.
53
+ * - `below` — the bottom panel.
54
+ *
55
+ * Surfaces routed to the same host coexist as tabs. Modelled as one enum per
56
+ * surface (rather than a boolean per host) so invalid combinations — two hosts
57
+ * at once, or none — are unrepresentable.
58
+ */
59
+ export type SurfacePlacement = 'sidebar' | 'modal' | 'below';
48
60
  /**
49
61
  * UI layout and display settings
50
62
  */
@@ -56,13 +68,17 @@ export interface UISettings {
56
68
  /** Enable compact mode for denser UI */
57
69
  compactMode: boolean;
58
70
  /** Active theme name — overridden by the theme prop when explicitly provided */
59
- theme: 'default' | 'minimal';
71
+ theme: 'default' | 'minimal' | 'drafter';
60
72
  /** Whether the command console panel is open */
61
73
  consoleOpen: boolean;
62
74
  /** Height of the command console panel in pixels */
63
75
  consoleHeight: number;
64
76
  /** Active tab in the bottom panel */
65
77
  bottomPanelTab: 'console' | 'chat';
78
+ /** Where the node/workflow configuration panel is hosted. Default `sidebar`. */
79
+ configPlacement: SurfacePlacement;
80
+ /** Where the console / AI Assistant group is hosted. Default `below`. */
81
+ consolePlacement: SurfacePlacement;
66
82
  }
67
83
  /**
68
84
  * Application behavior and automation settings
@@ -37,7 +37,7 @@ export const SETTINGS_CATEGORY_ICONS = {
37
37
  * Default theme settings
38
38
  */
39
39
  export const DEFAULT_THEME_SETTINGS = {
40
- preference: 'dark'
40
+ preference: 'light'
41
41
  };
42
42
  /**
43
43
  * Default editor settings
@@ -62,7 +62,9 @@ export const DEFAULT_UI_SETTINGS = {
62
62
  theme: 'default',
63
63
  consoleOpen: false,
64
64
  consoleHeight: 300,
65
- bottomPanelTab: 'console'
65
+ bottomPanelTab: 'console',
66
+ configPlacement: 'sidebar',
67
+ consolePlacement: 'below'
66
68
  };
67
69
  /**
68
70
  * Default behavior settings
@@ -28,4 +28,4 @@ export interface FlowDropSkin {
28
28
  /** CSS token overrides injected as [data-theme='dark'] rules — active in dark mode only */
29
29
  darkTokens?: FlowDropSkinTokens;
30
30
  }
31
- export type FlowDropSkinName = 'default' | 'slate';
31
+ export type FlowDropSkinName = 'default' | 'slate' | 'drafter';
@@ -1,4 +1,14 @@
1
1
  import type { FlowDropSkin } from './skin.js';
2
+ /**
3
+ * Canvas background grid pattern. Mirrors xyflow's BackgroundVariant values:
4
+ * 'dots' — a square grid of dots (the default)
5
+ * 'lines' — a square grid of solid lines (a "blueprint" / drafter look)
6
+ * 'cross' — small plus-marks at each grid intersection
7
+ *
8
+ * The grid's color is driven separately by the `--fd-grid-pattern-color` token,
9
+ * so any skin can recolor whichever variant a theme chooses.
10
+ */
11
+ export type FlowDropGridVariant = 'dots' | 'lines' | 'cross';
2
12
  /**
3
13
  * Behavioral configuration bundled with a theme.
4
14
  * These are initial-state flags, not CSS — they control runtime defaults.
@@ -10,11 +20,15 @@ export interface FlowDropThemeConfig {
10
20
  /** Whether category <details> accordion sections start open in card mode. Defaults to false. */
11
21
  categoriesDefaultOpen?: boolean;
12
22
  };
23
+ canvas?: {
24
+ /** Background grid pattern applied when this theme is selected. Defaults to 'dots'. */
25
+ grid?: FlowDropGridVariant;
26
+ };
13
27
  }
14
28
  /**
15
29
  * A FlowDrop theme bundles a visual skin (CSS tokens) with UI config (behavioral defaults).
16
30
  *
17
- * Built-in themes: 'default' | 'minimal'
31
+ * Built-in themes: 'default' | 'minimal' | 'drafter'
18
32
  *
19
33
  * @example
20
34
  * // Use a built-in theme by name
@@ -32,4 +46,4 @@ export interface FlowDropTheme {
32
46
  /** Behavioral configuration defaults */
33
47
  config?: FlowDropThemeConfig;
34
48
  }
35
- export type FlowDropThemeName = 'default' | 'minimal';
49
+ export type FlowDropThemeName = 'default' | 'minimal' | 'drafter';
@@ -124,6 +124,11 @@ export interface UISchemaGroup extends UISchemaElementBase {
124
124
  * @default true
125
125
  */
126
126
  defaultOpen?: boolean;
127
+ /**
128
+ * Optional Iconify icon name shown in the group's header bar.
129
+ * Falls back to a neutral default when omitted.
130
+ */
131
+ icon?: string;
127
132
  }
128
133
  /**
129
134
  * Union type of all supported UISchema elements.
@@ -241,6 +241,33 @@ export declare function getPortBackgroundColor(checker: PortCompatibilityChecker
241
241
  * @returns CSS color value for the port border
242
242
  */
243
243
  export declare function getPortBorderColor(checker: PortCompatibilityChecker, dataType: string): string;
244
+ /**
245
+ * Whether a port is the reserved `error` output port.
246
+ *
247
+ * The reserved error output carries an arbitrary data type (json) but should
248
+ * read as an error affordance (red) wherever it surfaces. See
249
+ * `.claude/plans/exposed-ports.md`.
250
+ */
251
+ export declare function isErrorPort(port: {
252
+ id: string;
253
+ type?: string;
254
+ }): boolean;
255
+ /**
256
+ * Port colour token: red for the reserved error output, else its data type.
257
+ */
258
+ export declare function getPortColorToken(checker: PortCompatibilityChecker, port: {
259
+ id: string;
260
+ type?: string;
261
+ dataType: string;
262
+ }): string;
263
+ /**
264
+ * Port background tint, honouring the reserved error port's red affordance.
265
+ */
266
+ export declare function getPortBackgroundColorForPort(checker: PortCompatibilityChecker, port: {
267
+ id: string;
268
+ type?: string;
269
+ dataType: string;
270
+ }, opacity?: number): string;
244
271
  /**
245
272
  * Convert RGB components to hex color string
246
273
  * @param r - Red component (0-255)
@@ -429,6 +429,29 @@ export function getPortBackgroundColor(checker, dataType, opacity = 25) {
429
429
  export function getPortBorderColor(checker, dataType) {
430
430
  return getDataTypeColorToken(checker, dataType);
431
431
  }
432
+ /**
433
+ * Whether a port is the reserved `error` output port.
434
+ *
435
+ * The reserved error output carries an arbitrary data type (json) but should
436
+ * read as an error affordance (red) wherever it surfaces. See
437
+ * `.claude/plans/exposed-ports.md`.
438
+ */
439
+ export function isErrorPort(port) {
440
+ return port.id === 'error' && port.type !== 'input';
441
+ }
442
+ /**
443
+ * Port colour token: red for the reserved error output, else its data type.
444
+ */
445
+ export function getPortColorToken(checker, port) {
446
+ return isErrorPort(port) ? 'var(--fd-node-red)' : getDataTypeColorToken(checker, port.dataType);
447
+ }
448
+ /**
449
+ * Port background tint, honouring the reserved error port's red affordance.
450
+ */
451
+ export function getPortBackgroundColorForPort(checker, port, opacity = 25) {
452
+ const colorToken = getPortColorToken(checker, port);
453
+ return `color-mix(in srgb, ${colorToken} ${opacity}%, transparent)`;
454
+ }
432
455
  /**
433
456
  * Convert RGB components to hex color string
434
457
  * @param r - Red component (0-255)
@@ -119,7 +119,7 @@ export class PortCompatibilityChecker {
119
119
  * Get all possible connections from a source node to target nodes
120
120
  */
121
121
  export function getPossibleConnections(checker, sourceNode, targetNodes, nodeTypes) {
122
- const sourceMetadata = nodeTypes.find((nt) => nt.id === sourceNode.data.metadata.id);
122
+ const sourceMetadata = nodeTypes.find((nt) => nt.node_type_id === sourceNode.data.metadata.node_type_id);
123
123
  if (!sourceMetadata)
124
124
  return [];
125
125
  const possibleConnections = [];
@@ -129,7 +129,7 @@ export function getPossibleConnections(checker, sourceNode, targetNodes, nodeTyp
129
129
  for (const targetNode of targetNodes) {
130
130
  if (targetNode.id === sourceNode.id)
131
131
  continue; // Skip self-connection
132
- const targetMetadata = nodeTypes.find((nt) => nt.id === targetNode.data.metadata.id);
132
+ const targetMetadata = nodeTypes.find((nt) => nt.node_type_id === targetNode.data.metadata.node_type_id);
133
133
  if (!targetMetadata)
134
134
  continue;
135
135
  // Get all input ports from target node
@@ -170,8 +170,8 @@ export function validateConnection(checker, sourceNodeId, sourcePortId, targetNo
170
170
  return { valid: false, error: 'Cannot connect node to itself' };
171
171
  }
172
172
  // Get node metadata
173
- const sourceMetadata = nodeTypes.find((nt) => nt.id === sourceNode.data.metadata.id);
174
- const targetMetadata = nodeTypes.find((nt) => nt.id === targetNode.data.metadata.id);
173
+ const sourceMetadata = nodeTypes.find((nt) => nt.node_type_id === sourceNode.data.metadata.node_type_id);
174
+ const targetMetadata = nodeTypes.find((nt) => nt.node_type_id === targetNode.data.metadata.node_type_id);
175
175
  if (!sourceMetadata || !targetMetadata) {
176
176
  return { valid: false, error: 'Node metadata not found' };
177
177
  }
@@ -200,14 +200,14 @@ export function getConnectionSuggestions(checker, nodeId, nodes, nodeTypes) {
200
200
  const node = nodes.find((n) => n.id === nodeId);
201
201
  if (!node)
202
202
  return [];
203
- const metadata = nodeTypes.find((nt) => nt.id === node.data.metadata.id);
203
+ const metadata = nodeTypes.find((nt) => nt.node_type_id === node.data.metadata.node_type_id);
204
204
  if (!metadata)
205
205
  return [];
206
206
  const suggestions = [];
207
207
  // Get all other nodes
208
208
  const otherNodes = nodes.filter((n) => n.id !== nodeId);
209
209
  for (const otherNode of otherNodes) {
210
- const otherMetadata = nodeTypes.find((nt) => nt.id === otherNode.data.metadata.id);
210
+ const otherMetadata = nodeTypes.find((nt) => nt.node_type_id === otherNode.data.metadata.node_type_id);
211
211
  if (!otherMetadata)
212
212
  continue;
213
213
  // Check outputs from other nodes to inputs of current node
@@ -253,8 +253,17 @@ export function getConnectionSuggestions(checker, nodeId, nodes, nodeTypes) {
253
253
  * @returns True if any cycle exists in the workflow
254
254
  */
255
255
  export function hasCycles(nodes, edges) {
256
- // Build adjacency map once (O(E)) so the DFS inner loop is O(1) per lookup
257
- // instead of scanning all edges on every recursive call (which was O(V*E)).
256
+ return detectCycles(nodes, edges);
257
+ }
258
+ /**
259
+ * Detect whether a directed graph contains a cycle, using DFS over a pre-built
260
+ * adjacency map (O(E) build, O(1) per neighbour lookup — avoids the O(V*E) of
261
+ * re-scanning every edge on each recursive call).
262
+ *
263
+ * Shared by `hasCycles` (all edges) and `hasInvalidCycles` (loopback edges
264
+ * pre-filtered out by the caller).
265
+ */
266
+ function detectCycles(nodes, edges) {
258
267
  const adjacencyMap = new Map();
259
268
  for (const node of nodes) {
260
269
  adjacencyMap.set(node.id, []);
@@ -274,7 +283,6 @@ export function hasCycles(nodes, edges) {
274
283
  return false;
275
284
  visited.add(nodeId);
276
285
  recursionStack.add(nodeId);
277
- // Use pre-built adjacency map instead of filtering all edges each call
278
286
  const neighbors = adjacencyMap.get(nodeId) || [];
279
287
  for (const target of neighbors) {
280
288
  if (hasCycleUtil(target))
@@ -283,7 +291,6 @@ export function hasCycles(nodes, edges) {
283
291
  recursionStack.delete(nodeId);
284
292
  return false;
285
293
  }
286
- // Check each node
287
294
  for (const node of nodes) {
288
295
  if (!visited.has(node.id)) {
289
296
  if (hasCycleUtil(node.id))
@@ -309,53 +316,10 @@ export function hasCycles(nodes, edges) {
309
316
  * ```
310
317
  */
311
318
  export function hasInvalidCycles(nodes, edges) {
312
- // Filter out loopback edges - these create valid cycles for loop iteration
319
+ // Filter out loopback edges - these create valid cycles for loop iteration,
320
+ // then reuse the shared detector over the remaining edges.
313
321
  const nonLoopbackEdges = edges.filter((edge) => !isLoopbackEdge(edge));
314
- // Build adjacency map from non-loopback edges once (O(E)) so the DFS inner
315
- // loop is O(1) per lookup instead of scanning all edges on every recursive
316
- // call (which was O(V*E)).
317
- const adjacencyMap = new Map();
318
- for (const node of nodes) {
319
- adjacencyMap.set(node.id, []);
320
- }
321
- for (const edge of nonLoopbackEdges) {
322
- const neighbors = adjacencyMap.get(edge.source);
323
- if (neighbors) {
324
- neighbors.push(edge.target);
325
- }
326
- }
327
- // Check for cycles using only non-loopback edges
328
- const visited = new Set();
329
- const recursionStack = new Set();
330
- /**
331
- * DFS utility to detect cycles in the graph
332
- * @param nodeId - Current node being visited
333
- * @returns True if a cycle is found from this node
334
- */
335
- function hasCycleUtil(nodeId) {
336
- if (recursionStack.has(nodeId))
337
- return true;
338
- if (visited.has(nodeId))
339
- return false;
340
- visited.add(nodeId);
341
- recursionStack.add(nodeId);
342
- // Use pre-built adjacency map instead of filtering all edges each call
343
- const neighbors = adjacencyMap.get(nodeId) || [];
344
- for (const target of neighbors) {
345
- if (hasCycleUtil(target))
346
- return true;
347
- }
348
- recursionStack.delete(nodeId);
349
- return false;
350
- }
351
- // Check each node for cycles
352
- for (const node of nodes) {
353
- if (!visited.has(node.id)) {
354
- if (hasCycleUtil(node.id))
355
- return true;
356
- }
357
- }
358
- return false;
322
+ return detectCycles(nodes, nonLoopbackEdges);
359
323
  }
360
324
  /**
361
325
  * Get the execution order for a workflow (topological sort)
@@ -5,10 +5,14 @@
5
5
  * visual styling to workflow edges based on source port data types.
6
6
  * Used by both the visual editor and the command DSL system.
7
7
  */
8
- import { MarkerType } from '@xyflow/svelte';
9
8
  import { extractPortId } from '../utils/handleIds.js';
10
9
  import { isLoopbackEdge } from '../utils/connections.js';
11
10
  import { EDGE_MARKER_SIZES } from '../config/constants.js';
11
+ // xyflow's `MarkerType.ArrowClosed`, inlined as its literal value. This module
12
+ // is shared with the headless command DSL (reachable from `@flowdrop/flowdrop/core`),
13
+ // so it must NOT carry a runtime import of @xyflow/svelte — a type-only import
14
+ // plus this constant keeps the marker type-safe without the dependency.
15
+ const ARROW_CLOSED_MARKER = 'arrowclosed';
12
16
  /**
13
17
  * Check if a port ID matches a dynamic branch in a Gateway node.
14
18
  * Gateway nodes store branches in config.branches array.
@@ -101,7 +105,7 @@ export function applyConnectionStyling(edge, sourceNode, targetNode) {
101
105
  'stroke: var(--fd-edge-loopback); stroke-dasharray: var(--fd-edge-loopback-dasharray); stroke-width: var(--fd-edge-loopback-width); opacity: var(--fd-edge-loopback-opacity);';
102
106
  edge.class = 'flowdrop--edge--loopback';
103
107
  edge.markerEnd = {
104
- type: MarkerType.ArrowClosed,
108
+ type: ARROW_CLOSED_MARKER,
105
109
  ...EDGE_MARKER_SIZES.loopback,
106
110
  color: 'var(--fd-edge-loopback)'
107
111
  };
@@ -110,7 +114,7 @@ export function applyConnectionStyling(edge, sourceNode, targetNode) {
110
114
  edge.style = 'stroke: var(--fd-edge-trigger); stroke-width: var(--fd-edge-trigger-width);';
111
115
  edge.class = 'flowdrop--edge--trigger';
112
116
  edge.markerEnd = {
113
- type: MarkerType.ArrowClosed,
117
+ type: ARROW_CLOSED_MARKER,
114
118
  ...EDGE_MARKER_SIZES.trigger,
115
119
  color: 'var(--fd-edge-trigger)'
116
120
  };
@@ -119,7 +123,7 @@ export function applyConnectionStyling(edge, sourceNode, targetNode) {
119
123
  edge.style = 'stroke: var(--fd-edge-tool); stroke-dasharray: 5 3;';
120
124
  edge.class = 'flowdrop--edge--tool';
121
125
  edge.markerEnd = {
122
- type: MarkerType.ArrowClosed,
126
+ type: ARROW_CLOSED_MARKER,
123
127
  ...EDGE_MARKER_SIZES.tool,
124
128
  color: 'var(--fd-edge-tool)'
125
129
  };
@@ -129,7 +133,7 @@ export function applyConnectionStyling(edge, sourceNode, targetNode) {
129
133
  edge.style = 'stroke: var(--fd-edge-data);';
130
134
  edge.class = 'flowdrop--edge--data';
131
135
  edge.markerEnd = {
132
- type: MarkerType.ArrowClosed,
136
+ type: ARROW_CLOSED_MARKER,
133
137
  ...EDGE_MARKER_SIZES.data,
134
138
  color: 'var(--fd-edge-data)'
135
139
  };
@@ -1,25 +1,46 @@
1
1
  /**
2
- * Fetch authentication utilities
2
+ * Authenticated fetch
3
3
  *
4
- * Shared logic for building HTTP headers with authentication.
5
- * Used by components that make authenticated API requests (e.g., FormAutocomplete).
4
+ * The single fetch path for FlowDrop's per-instance services. It builds request
5
+ * headers (static endpoint headers + the {@link AuthProvider}'s headers + any
6
+ * caller headers) and uniformly applies the auth lifecycle: on `401` it invokes
7
+ * `onUnauthorized()` and — if that reports a successful refresh — retries the
8
+ * request once with freshly fetched headers; on `403` it invokes
9
+ * `onForbidden()`. Callers receive the raw {@link Response} and keep their own
10
+ * status/parse handling.
11
+ *
12
+ * Routing every service through this helper means a configured `AuthProvider`
13
+ * authenticates *and* refreshes consistently — matching the behaviour the typed
14
+ * workflow/node API gets from {@link EnhancedFlowDropApiClient}.
6
15
  *
7
16
  * @module utils/fetchWithAuth
8
17
  */
18
+ import type { EndpointConfig } from '../config/endpoints.js';
9
19
  import type { AuthProvider } from '../types/auth.js';
10
20
  /**
11
- * Build fetch headers with optional authentication
12
- *
13
- * Constructs standard JSON request headers and merges in authentication
14
- * headers from the provided AuthProvider, if available.
21
+ * Options describing how to authenticate and where the base headers come from.
15
22
  *
16
- * @param authProvider - Optional auth provider to get headers from
17
- * @returns Promise resolving to a complete headers object
23
+ * Provide `config` + `endpointKey` to source static endpoint headers (the usual
24
+ * case for endpoint-keyed services), or `baseHeaders` for ad-hoc requests that
25
+ * are not tied to a configured endpoint (e.g. a user-configured autocomplete
26
+ * URL). When neither is given the request carries only JSON defaults plus auth.
27
+ */
28
+ export interface AuthenticatedFetchOptions {
29
+ /** Auth provider supplying `Authorization` etc. and 401/403 lifecycle hooks. */
30
+ authProvider?: AuthProvider;
31
+ /** Endpoint configuration, used with `endpointKey` to look up static headers. */
32
+ config?: EndpointConfig;
33
+ /** Endpoint key identifying which static headers to apply. */
34
+ endpointKey?: string;
35
+ /** Base headers for requests not tied to a configured endpoint. */
36
+ baseHeaders?: Record<string, string>;
37
+ }
38
+ /**
39
+ * Perform an authenticated fetch with consistent 401/403 handling.
18
40
  *
19
- * @example
20
- * ```typescript
21
- * const headers = await buildFetchHeaders(authProvider);
22
- * const response = await fetch(url, { headers });
23
- * ```
41
+ * @param url - The fully-resolved request URL
42
+ * @param init - Standard fetch options (method, body, signal, headers, …)
43
+ * @param opts - Auth provider and header source
44
+ * @returns The raw {@link Response}; callers handle `.ok`/parsing themselves
24
45
  */
25
- export declare function buildFetchHeaders(authProvider?: AuthProvider): Promise<Record<string, string>>;
46
+ export declare function authenticatedFetch(url: string, init?: RequestInit, opts?: AuthenticatedFetchOptions): Promise<Response>;