@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.
- package/CHANGELOG.md +210 -0
- package/MIGRATION-2.0.md +173 -3
- package/README.md +5 -5
- package/dist/adapters/WorkflowAdapter.js +4 -5
- package/dist/adapters/agentspec/AgentSpecAdapter.js +3 -3
- package/dist/adapters/agentspec/defaultNodeTypes.js +9 -9
- package/dist/api/enhanced-client.js +6 -11
- package/dist/chat/batchFeedback.js +1 -1
- package/dist/chat/commandClassifier.d.ts +11 -0
- package/dist/chat/commandClassifier.js +20 -0
- package/dist/chat/historyBuilder.d.ts +39 -0
- package/dist/chat/historyBuilder.js +82 -0
- package/dist/chat/index.d.ts +2 -1
- package/dist/chat/index.js +2 -1
- package/dist/chat/responseParser.js +16 -12
- package/dist/commands/executor.js +51 -26
- package/dist/commands/parser.d.ts +12 -0
- package/dist/commands/parser.js +33 -6
- package/dist/commands/storeIntegration.svelte.js +11 -1
- package/dist/commands/types.js +5 -5
- package/dist/components/App.svelte +547 -386
- package/dist/components/App.svelte.d.ts +16 -8
- package/dist/components/Button.stories.svelte +65 -0
- package/dist/components/Button.stories.svelte.d.ts +19 -0
- package/dist/components/Button.svelte +62 -0
- package/dist/components/Button.svelte.d.ts +24 -0
- package/dist/components/CanvasIconButton.svelte +76 -0
- package/dist/components/CanvasIconButton.svelte.d.ts +18 -0
- package/dist/components/ConfigForm.svelte +194 -565
- package/dist/components/ConfigForm.svelte.d.ts +24 -7
- package/dist/components/ConfigModal.svelte +9 -1
- package/dist/components/ConfigPanel.svelte +234 -15
- package/dist/components/ConfigPanel.svelte.d.ts +6 -0
- package/dist/components/EditorStatusBar.stories.svelte +44 -0
- package/dist/components/EditorStatusBar.stories.svelte.d.ts +27 -0
- package/dist/components/EditorStatusBar.svelte +99 -0
- package/dist/components/EditorStatusBar.svelte.d.ts +15 -0
- package/dist/components/IconButton.svelte +80 -0
- package/dist/components/IconButton.svelte.d.ts +30 -0
- package/dist/components/Input.svelte +74 -0
- package/dist/components/Input.svelte.d.ts +17 -0
- package/dist/components/LogoWordmark.svelte +113 -0
- package/dist/components/LogoWordmark.svelte.d.ts +26 -0
- package/dist/components/Navbar.svelte +17 -63
- package/dist/components/Navbar.svelte.d.ts +3 -0
- package/dist/components/NodeSidebar.svelte +21 -126
- package/dist/components/NodeSwapPicker.svelte +12 -30
- package/dist/components/PipelineStatus.svelte +6 -1
- package/dist/components/PipelineStatus.svelte.d.ts +3 -0
- package/dist/components/PortMappingRow.svelte +0 -2
- package/dist/components/SchemaForm.svelte +4 -14
- package/dist/components/Select.svelte +53 -0
- package/dist/components/Select.svelte.d.ts +15 -0
- package/dist/components/SettingsModal.svelte +0 -5
- package/dist/components/SettingsPanel.svelte +33 -6
- package/dist/components/Textarea.svelte +39 -0
- package/dist/components/Textarea.svelte.d.ts +12 -0
- package/dist/components/ThemeToggle.svelte +15 -94
- package/dist/components/UniversalNode.svelte +36 -4
- package/dist/components/UniversalNode.svelte.d.ts +1 -1
- package/dist/components/WorkflowEditor.svelte +71 -54
- package/dist/components/WorkflowEditor.svelte.d.ts +21 -0
- package/dist/components/chat/AIChatPanel.svelte +49 -8
- package/dist/components/chat/CommandPreview.svelte +10 -1
- package/dist/components/console/ConsoleAutocomplete.svelte +1 -1
- package/dist/components/console/ConsoleInput.svelte +3 -3
- package/dist/components/console/ConsoleOutput.svelte +2 -2
- package/dist/components/form/FormArray.svelte +37 -173
- package/dist/components/form/FormAutocomplete.svelte +18 -15
- package/dist/components/form/FormCheckboxGroup.svelte +1 -5
- package/dist/components/form/FormCodeEditor.svelte +9 -7
- package/dist/components/form/FormField.svelte +18 -42
- package/dist/components/form/FormFieldLight.svelte +52 -48
- package/dist/components/form/FormFieldLight.svelte.d.ts +12 -0
- package/dist/components/form/FormFieldset.svelte +45 -11
- package/dist/components/form/FormMarkdownEditor.svelte +8 -5
- package/dist/components/form/FormNumberField.svelte +4 -36
- package/dist/components/form/FormPorts.svelte +280 -0
- package/dist/components/form/FormPorts.svelte.d.ts +13 -0
- package/dist/components/form/FormRangeField.svelte +63 -30
- package/dist/components/form/FormSelect.svelte +13 -75
- package/dist/components/form/FormTemplateEditor.svelte +6 -4
- package/dist/components/form/FormTextField.svelte +3 -35
- package/dist/components/form/FormTextarea.svelte +4 -39
- package/dist/components/form/FormToggle.svelte +27 -6
- package/dist/components/form/FormToggle.svelte.d.ts +5 -0
- package/dist/components/form/FormUISchemaRenderer.svelte +3 -1
- package/dist/components/form/resolveFieldType.d.ts +24 -0
- package/dist/components/form/resolveFieldType.js +55 -0
- package/dist/components/icons/CloseIcon.svelte +6 -0
- package/dist/components/icons/CloseIcon.svelte.d.ts +26 -0
- package/dist/components/icons/CommandLineIcon.svelte +15 -0
- package/dist/components/icons/CommandLineIcon.svelte.d.ts +26 -0
- package/dist/components/icons/MenuIcon.svelte +4 -0
- package/dist/components/icons/MenuIcon.svelte.d.ts +26 -0
- package/dist/components/icons/MenuOpenIcon.svelte +6 -0
- package/dist/components/icons/MenuOpenIcon.svelte.d.ts +26 -0
- package/dist/components/interrupt/ChoicePrompt.svelte +0 -10
- package/dist/components/interrupt/ConfirmationPrompt.svelte +0 -5
- package/dist/components/interrupt/InterruptBubble.svelte +11 -12
- package/dist/components/interrupt/ReviewPrompt.svelte +0 -20
- package/dist/components/interrupt/TextInputPrompt.svelte +0 -6
- package/dist/components/layouts/MainLayout.svelte +4 -5
- package/dist/components/nodes/AtomNode.svelte +62 -76
- package/dist/components/nodes/AtomNode.svelte.d.ts +1 -1
- package/dist/components/nodes/GatewayNode.svelte +117 -164
- package/dist/components/nodes/GatewayNode.svelte.d.ts +1 -1
- package/dist/components/nodes/IdeaNode.svelte +72 -98
- package/dist/components/nodes/IdeaNode.svelte.d.ts +8 -4
- package/dist/components/nodes/NodeConfigButton.svelte +86 -0
- package/dist/components/nodes/NodeConfigButton.svelte.d.ts +15 -0
- package/dist/components/nodes/NotesNode.svelte +76 -85
- package/dist/components/nodes/NotesNode.svelte.d.ts +8 -4
- package/dist/components/nodes/SimpleNode.svelte +59 -133
- package/dist/components/nodes/SimpleNode.svelte.d.ts +4 -4
- package/dist/components/nodes/SquareNode.svelte +110 -164
- package/dist/components/nodes/SquareNode.svelte.d.ts +4 -4
- package/dist/components/nodes/TerminalNode.svelte +62 -124
- package/dist/components/nodes/TerminalNode.svelte.d.ts +4 -4
- package/dist/components/nodes/ToolNode.svelte +92 -103
- package/dist/components/nodes/ToolNode.svelte.d.ts +6 -6
- package/dist/components/nodes/WorkflowNode.svelte +132 -191
- package/dist/components/nodes/WorkflowNode.svelte.d.ts +1 -1
- package/dist/components/playground/ChatInput.svelte +316 -27
- package/dist/components/playground/ChatInput.svelte.d.ts +31 -1
- package/dist/components/playground/ControlPanel.svelte +22 -0
- package/dist/components/playground/ControlPanel.svelte.d.ts +13 -0
- package/dist/components/playground/InputCollector.svelte +11 -48
- package/dist/components/playground/PipelineKanbanView.svelte +6 -4
- package/dist/components/playground/PipelineKanbanView.svelte.d.ts +2 -0
- package/dist/components/playground/PipelinePanel.svelte +20 -3
- package/dist/components/playground/PipelinePanel.svelte.d.ts +2 -0
- package/dist/components/playground/PipelineTableView.svelte +6 -4
- package/dist/components/playground/PipelineTableView.svelte.d.ts +2 -0
- package/dist/components/playground/Playground.svelte +292 -28
- package/dist/components/playground/Playground.svelte.d.ts +3 -0
- package/dist/components/playground/PlaygroundApp.svelte +6 -1
- package/dist/components/playground/PlaygroundApp.svelte.d.ts +3 -0
- package/dist/components/playground/PlaygroundModal.svelte +5 -0
- package/dist/components/playground/PlaygroundModal.svelte.d.ts +3 -0
- package/dist/components/playground/PlaygroundStudio.svelte +7 -6
- package/dist/components/playground/PlaygroundStudio.svelte.d.ts +3 -0
- package/dist/components/playground/pipelineViewUtils.svelte.d.ts +2 -1
- package/dist/components/playground/pipelineViewUtils.svelte.js +2 -2
- package/dist/components/surfaces/SurfaceOverlay.svelte +153 -0
- package/dist/components/surfaces/SurfaceOverlay.svelte.d.ts +14 -0
- package/dist/components/surfaces/TabbedSurface.svelte +133 -0
- package/dist/components/surfaces/TabbedSurface.svelte.d.ts +27 -0
- package/dist/config/endpoints.d.ts +71 -1
- package/dist/config/endpoints.js +46 -5
- package/dist/core/index.d.ts +2 -3
- package/dist/core/index.js +2 -6
- package/dist/display/index.d.ts +6 -1
- package/dist/display/index.js +9 -1
- package/dist/editor/index.d.ts +1 -1
- package/dist/editor/index.js +1 -1
- package/dist/form/full.d.ts +2 -1
- package/dist/form/full.js +4 -1
- package/dist/form/index.d.ts +0 -1
- package/dist/form/index.js +3 -2
- package/dist/helpers/workflowEditorHelper.d.ts +4 -2
- package/dist/helpers/workflowEditorHelper.js +8 -8
- package/dist/messages/defaults.d.ts +98 -0
- package/dist/messages/defaults.js +58 -1
- package/dist/messages/index.d.ts +1 -1
- package/dist/messages/index.js +1 -1
- package/dist/openapi/v1/openapi.yaml +35 -23
- package/dist/playground/commands/args.d.ts +32 -0
- package/dist/playground/commands/args.js +50 -0
- package/dist/playground/commands/dispatch.d.ts +143 -0
- package/dist/playground/commands/dispatch.js +162 -0
- package/dist/playground/commands/index.d.ts +14 -0
- package/dist/playground/commands/index.js +10 -0
- package/dist/playground/commands/parser.d.ts +38 -0
- package/dist/playground/commands/parser.js +163 -0
- package/dist/playground/commands/registry.d.ts +42 -0
- package/dist/playground/commands/registry.js +122 -0
- package/dist/playground/commands/suggest.d.ts +37 -0
- package/dist/playground/commands/suggest.js +46 -0
- package/dist/playground/commands/types.d.ts +111 -0
- package/dist/playground/commands/types.js +15 -0
- package/dist/playground/index.d.ts +21 -2
- package/dist/playground/index.js +27 -2
- package/dist/playground/mount.d.ts +19 -5
- package/dist/playground/mount.js +16 -8
- package/dist/playground/runAction.d.ts +48 -0
- package/dist/playground/runAction.js +31 -0
- package/dist/registry/builtinNodeTypes.d.ts +53 -0
- package/dist/registry/builtinNodeTypes.js +67 -0
- package/dist/registry/builtinNodes.d.ts +2 -39
- package/dist/registry/builtinNodes.js +6 -53
- package/dist/registry/nodeComponentRegistry.d.ts +2 -1
- package/dist/schemas/v1/workflow.schema.json +16 -14
- package/dist/services/agentSpecExecutionService.d.ts +0 -2
- package/dist/services/agentSpecExecutionService.js +0 -2
- package/dist/services/apiVariableService.js +12 -26
- package/dist/services/categoriesApi.js +3 -6
- package/dist/services/chatService.d.ts +4 -3
- package/dist/services/chatService.js +13 -18
- package/dist/services/dynamicSchemaService.d.ts +31 -4
- package/dist/services/dynamicSchemaService.js +62 -33
- package/dist/services/historyService.d.ts +30 -8
- package/dist/services/historyService.js +51 -15
- package/dist/services/interruptService.d.ts +7 -6
- package/dist/services/interruptService.js +19 -21
- package/dist/services/pipelineSignalService.d.ts +97 -0
- package/dist/services/pipelineSignalService.js +94 -0
- package/dist/services/playgroundService.d.ts +21 -8
- package/dist/services/playgroundService.js +45 -25
- package/dist/services/portConfigApi.js +3 -6
- package/dist/services/settingsService.d.ts +9 -4
- package/dist/services/settingsService.js +23 -12
- package/dist/services/workflowLaunchService.d.ts +74 -0
- package/dist/services/workflowLaunchService.js +74 -0
- package/dist/skins/drafter.d.ts +30 -0
- package/dist/skins/drafter.js +198 -0
- package/dist/skins/index.d.ts +2 -1
- package/dist/skins/index.js +4 -2
- package/dist/stores/apiContext.d.ts +11 -0
- package/dist/stores/apiContext.js +15 -0
- package/dist/stores/categoriesStore.svelte.js +0 -1
- package/dist/stores/historyStore.svelte.d.ts +17 -3
- package/dist/stores/historyStore.svelte.js +30 -3
- package/dist/stores/instanceContainer.svelte.js +5 -0
- package/dist/stores/playgroundStore.svelte.js +1 -3
- package/dist/stores/settingsStore.svelte.d.ts +13 -0
- package/dist/stores/settingsStore.svelte.js +32 -0
- package/dist/stores/workflowStore.svelte.d.ts +42 -5
- package/dist/stores/workflowStore.svelte.js +109 -32
- package/dist/styles/base.css +285 -14
- package/dist/styles/tokens.css +60 -2
- package/dist/svelte-app.d.ts +18 -1
- package/dist/svelte-app.js +75 -110
- package/dist/themes/drafter.d.ts +2 -0
- package/dist/themes/drafter.js +15 -0
- package/dist/themes/index.d.ts +2 -1
- package/dist/themes/index.js +8 -2
- package/dist/types/auth.d.ts +9 -51
- package/dist/types/auth.js +4 -54
- package/dist/types/chat.d.ts +5 -1
- package/dist/types/events.d.ts +18 -0
- package/dist/types/events.js +2 -1
- package/dist/types/index.d.ts +84 -29
- package/dist/types/index.js +0 -1
- package/dist/types/settings.d.ts +28 -1
- package/dist/types/settings.js +6 -3
- package/dist/types/skin.d.ts +1 -1
- package/dist/types/theme.d.ts +16 -2
- package/dist/types/uischema.d.ts +5 -0
- package/dist/utils/canvasSelection.d.ts +25 -0
- package/dist/utils/canvasSelection.js +37 -0
- package/dist/utils/colors.d.ts +27 -0
- package/dist/utils/colors.js +23 -0
- package/dist/utils/connections.js +20 -56
- package/dist/utils/edgeStyling.js +9 -5
- package/dist/utils/fetchWithAuth.d.ts +36 -15
- package/dist/utils/fetchWithAuth.js +53 -23
- package/dist/utils/nodeFormSchema.d.ts +51 -0
- package/dist/utils/nodeFormSchema.js +87 -0
- package/dist/utils/nodeIds.d.ts +1 -1
- package/dist/utils/nodeIds.js +1 -1
- package/dist/utils/nodeSwap.js +3 -6
- package/dist/utils/nodeTypes.js +1 -1
- package/dist/utils/portUtils.d.ts +47 -11
- package/dist/utils/portUtils.js +67 -14
- package/dist/utils/portal.d.ts +18 -0
- package/dist/utils/portal.js +34 -0
- package/dist/utils/schemaMerge.d.ts +25 -0
- package/dist/utils/schemaMerge.js +61 -0
- package/package.json +2 -1
package/dist/types/events.js
CHANGED
package/dist/types/index.d.ts
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
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. */
|
package/dist/types/index.js
CHANGED
package/dist/types/settings.d.ts
CHANGED
|
@@ -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
|
|
@@ -91,6 +107,17 @@ export interface BehaviorSettings {
|
|
|
91
107
|
confirmDelete: boolean;
|
|
92
108
|
/** Automatically re-submit batch failures to the AI for self-correction */
|
|
93
109
|
chatAutoRetry: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Allow the AI assistant's commands to reposition nodes
|
|
112
|
+
* (`layout auto`, `layout beautify`).
|
|
113
|
+
*
|
|
114
|
+
* Turn off to protect a hand-crafted layout: those commands are then skipped
|
|
115
|
+
* (not failed) when a batch is applied, so the rest of the change set still
|
|
116
|
+
* lands. Positioning nodes explicitly via `add ... at <x>,<y>` and viewport
|
|
117
|
+
* commands (`canvas fitview`) are unaffected — they don't overwrite the
|
|
118
|
+
* arrangement of existing nodes.
|
|
119
|
+
*/
|
|
120
|
+
chatAllowLayoutChanges: boolean;
|
|
94
121
|
}
|
|
95
122
|
/**
|
|
96
123
|
* API connection and request settings
|
package/dist/types/settings.js
CHANGED
|
@@ -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: '
|
|
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
|
|
@@ -73,7 +75,8 @@ export const DEFAULT_BEHAVIOR_SETTINGS = {
|
|
|
73
75
|
storeDraftsInBrowser: true,
|
|
74
76
|
undoHistoryLimit: 50,
|
|
75
77
|
confirmDelete: false,
|
|
76
|
-
chatAutoRetry: true
|
|
78
|
+
chatAutoRetry: true,
|
|
79
|
+
chatAllowLayoutChanges: true
|
|
77
80
|
};
|
|
78
81
|
/**
|
|
79
82
|
* Default API settings
|
package/dist/types/skin.d.ts
CHANGED
|
@@ -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';
|
package/dist/types/theme.d.ts
CHANGED
|
@@ -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';
|
package/dist/types/uischema.d.ts
CHANGED
|
@@ -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.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canvas Selection Utilities
|
|
3
|
+
*
|
|
4
|
+
* Keeps canvas pointer gestures from turning into browser text-selection drags.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Suppress the text-selection drag a port handle mousedown would otherwise start.
|
|
8
|
+
*
|
|
9
|
+
* All canvas chrome is `user-select: none` (xyflow sets it on the node, pane and
|
|
10
|
+
* viewport), but WebKit still begins a selection drag from a mousedown on
|
|
11
|
+
* unselectable content: it anchors at the nearest selectable text *outside* the
|
|
12
|
+
* canvas — sidebar, toolbar, status bar or the surrounding host page — and
|
|
13
|
+
* extends it as the pointer moves, so drawing a connection paints a selection
|
|
14
|
+
* across the app (#37). Chromium and Firefox never start the gesture.
|
|
15
|
+
*
|
|
16
|
+
* Only handles need this: xyflow already suppresses the default for node drags
|
|
17
|
+
* (d3-drag) and pane drags. Handles are the one canvas drag started from a plain
|
|
18
|
+
* mousedown handler, so we suppress the default here — nothing in the connect
|
|
19
|
+
* flow depends on it, since xyflow tracks the drag on its own pointer listeners.
|
|
20
|
+
* The default action also moves focus, so re-apply it to keep the focus ring
|
|
21
|
+
* (`.svelte-flow__handle:focus` in base.css) behaving as before.
|
|
22
|
+
*
|
|
23
|
+
* Bind in the capture phase so xyflow's handle handler still receives the event.
|
|
24
|
+
*/
|
|
25
|
+
export declare function suppressPortDragSelection(event: MouseEvent): void;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canvas Selection Utilities
|
|
3
|
+
*
|
|
4
|
+
* Keeps canvas pointer gestures from turning into browser text-selection drags.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Suppress the text-selection drag a port handle mousedown would otherwise start.
|
|
8
|
+
*
|
|
9
|
+
* All canvas chrome is `user-select: none` (xyflow sets it on the node, pane and
|
|
10
|
+
* viewport), but WebKit still begins a selection drag from a mousedown on
|
|
11
|
+
* unselectable content: it anchors at the nearest selectable text *outside* the
|
|
12
|
+
* canvas — sidebar, toolbar, status bar or the surrounding host page — and
|
|
13
|
+
* extends it as the pointer moves, so drawing a connection paints a selection
|
|
14
|
+
* across the app (#37). Chromium and Firefox never start the gesture.
|
|
15
|
+
*
|
|
16
|
+
* Only handles need this: xyflow already suppresses the default for node drags
|
|
17
|
+
* (d3-drag) and pane drags. Handles are the one canvas drag started from a plain
|
|
18
|
+
* mousedown handler, so we suppress the default here — nothing in the connect
|
|
19
|
+
* flow depends on it, since xyflow tracks the drag on its own pointer listeners.
|
|
20
|
+
* The default action also moves focus, so re-apply it to keep the focus ring
|
|
21
|
+
* (`.svelte-flow__handle:focus` in base.css) behaving as before.
|
|
22
|
+
*
|
|
23
|
+
* Bind in the capture phase so xyflow's handle handler still receives the event.
|
|
24
|
+
*/
|
|
25
|
+
export function suppressPortDragSelection(event) {
|
|
26
|
+
// Primary button only — other buttons never start a selection.
|
|
27
|
+
if (event.button !== 0)
|
|
28
|
+
return;
|
|
29
|
+
const target = event.target;
|
|
30
|
+
if (typeof target?.closest !== 'function')
|
|
31
|
+
return;
|
|
32
|
+
const handle = target.closest('.svelte-flow__handle');
|
|
33
|
+
if (!handle)
|
|
34
|
+
return;
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
handle.focus();
|
|
37
|
+
}
|
package/dist/utils/colors.d.ts
CHANGED
|
@@ -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)
|
package/dist/utils/colors.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
174
|
-
const targetMetadata = nodeTypes.find((nt) => nt.
|
|
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.
|
|
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.
|
|
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
|
-
|
|
257
|
-
|
|
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
|
-
|
|
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)
|