@flowdrop/flowdrop 1.15.0 → 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.
- package/CHANGELOG.md +648 -0
- package/MIGRATION-2.0.md +642 -0
- package/README.md +28 -28
- package/dist/adapters/WorkflowAdapter.d.ts +1 -1
- package/dist/adapters/WorkflowAdapter.js +18 -13
- package/dist/adapters/agentspec/AgentSpecAdapter.js +10 -10
- package/dist/adapters/agentspec/defaultNodeTypes.js +9 -9
- package/dist/api/enhanced-client.js +6 -11
- package/dist/chat/batchFeedback.d.ts +39 -0
- package/dist/chat/batchFeedback.js +51 -0
- package/dist/commands/executor.js +66 -27
- package/dist/commands/storeIntegration.svelte.d.ts +4 -1
- package/dist/commands/storeIntegration.svelte.js +36 -21
- package/dist/commands/types.d.ts +2 -0
- package/dist/commands/types.js +5 -5
- package/dist/components/App.svelte +696 -565
- package/dist/components/App.svelte.d.ts +63 -16
- 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 +181 -552
- package/dist/components/ConfigForm.svelte.d.ts +24 -7
- package/dist/components/ConfigModal.svelte +16 -3
- package/dist/components/ConfigPanel.svelte +234 -15
- package/dist/components/ConfigPanel.svelte.d.ts +6 -0
- package/dist/components/ConnectionLine.svelte +4 -2
- 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 +78 -64
- package/dist/components/Navbar.svelte.d.ts +3 -0
- package/dist/components/NodeSidebar.svelte +48 -171
- package/dist/components/NodeStatusOverlay.svelte +94 -6
- package/dist/components/NodeSwapPicker.svelte +22 -38
- package/dist/components/PipelineStatus.svelte +22 -68
- package/dist/components/PipelineStatus.svelte.d.ts +3 -0
- package/dist/components/PortCoordinateTracker.svelte +5 -6
- package/dist/components/PortMappingRow.svelte +0 -2
- package/dist/components/SchemaForm.stories.svelte +1 -3
- package/dist/components/SchemaForm.svelte +22 -39
- package/dist/components/SchemaForm.svelte.d.ts +0 -8
- package/dist/components/Select.svelte +53 -0
- package/dist/components/Select.svelte.d.ts +15 -0
- package/dist/components/SettingsModal.svelte +8 -8
- package/dist/components/SettingsPanel.svelte +44 -10
- package/dist/components/SwapMappingEditor.svelte +67 -49
- package/dist/components/SwapMappingEditor.svelte.d.ts +0 -2
- 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 +45 -11
- package/dist/components/UniversalNode.svelte.d.ts +1 -1
- package/dist/components/WorkflowEditor.svelte +183 -162
- package/dist/components/WorkflowEditor.svelte.d.ts +39 -10
- package/dist/components/chat/AIChatPanel.svelte +99 -90
- package/dist/components/chat/AIChatPanel.svelte.d.ts +0 -4
- package/dist/components/chat/CommandPreview.svelte +2 -1
- package/dist/components/console/CommandConsole.svelte +7 -5
- package/dist/components/console/ConsoleAutocomplete.svelte +11 -12
- package/dist/components/console/ConsoleAutocomplete.svelte.d.ts +6 -0
- package/dist/components/console/ConsoleInput.svelte +18 -9
- package/dist/components/console/ConsoleOutput.svelte +4 -3
- package/dist/components/form/FormArray.svelte +42 -182
- package/dist/components/form/FormArray.svelte.d.ts +2 -1
- package/dist/components/form/FormAutocomplete.svelte +26 -21
- package/dist/components/form/FormCheckboxGroup.svelte +1 -5
- package/dist/components/form/FormCodeEditor.svelte +9 -7
- package/dist/components/form/FormField.svelte +22 -44
- package/dist/components/form/FormFieldLight.svelte +56 -50
- package/dist/components/form/FormFieldLight.svelte.d.ts +12 -0
- package/dist/components/form/FormFieldset.svelte +45 -11
- package/dist/components/form/FormMarkdownEditor.svelte +17 -9
- package/dist/components/form/FormNumberField.svelte +4 -36
- package/dist/components/form/FormPorts.svelte +262 -0
- package/dist/components/form/FormPorts.svelte.d.ts +13 -0
- package/dist/components/form/FormRangeField.svelte +62 -30
- package/dist/components/form/FormSelect.svelte +13 -75
- package/dist/components/form/FormTemplateEditor.svelte +17 -7
- package/dist/components/form/FormTextField.svelte +3 -35
- package/dist/components/form/FormTextarea.svelte +4 -39
- package/dist/components/form/FormToggle.svelte +5 -16
- package/dist/components/form/FormToggle.svelte.d.ts +4 -2
- 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/form/templateAutocomplete.js +1 -5
- package/dist/components/form/types.d.ts +1 -14
- 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/FormPrompt.svelte +3 -2
- package/dist/components/interrupt/InterruptBubble.svelte +25 -27
- package/dist/components/interrupt/ReviewPrompt.svelte +10 -23
- package/dist/components/interrupt/TextInputPrompt.svelte +2 -7
- package/dist/components/layouts/MainLayout.svelte +24 -18
- package/dist/components/layouts/MainLayout.svelte.d.ts +4 -0
- package/dist/components/nodes/AtomNode.svelte +70 -72
- package/dist/components/nodes/AtomNode.svelte.d.ts +1 -1
- package/dist/components/nodes/GatewayNode.svelte +134 -172
- package/dist/components/nodes/GatewayNode.svelte.d.ts +1 -1
- package/dist/components/nodes/IdeaNode.svelte +79 -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 +68 -137
- package/dist/components/nodes/SimpleNode.svelte.d.ts +4 -4
- package/dist/components/nodes/SquareNode.svelte +122 -169
- package/dist/components/nodes/SquareNode.svelte.d.ts +4 -4
- package/dist/components/nodes/TerminalNode.svelte +70 -127
- package/dist/components/nodes/TerminalNode.svelte.d.ts +4 -4
- package/dist/components/nodes/ToolNode.svelte +99 -104
- package/dist/components/nodes/ToolNode.svelte.d.ts +6 -6
- package/dist/components/nodes/WorkflowNode.svelte +145 -195
- package/dist/components/nodes/WorkflowNode.svelte.d.ts +1 -1
- package/dist/components/playground/ChatInput.svelte +11 -15
- package/dist/components/playground/ChatPanel.svelte +6 -49
- package/dist/components/playground/ChatPanel.svelte.d.ts +0 -14
- package/dist/components/playground/ControlPanel.svelte +134 -123
- package/dist/components/playground/ControlPanel.svelte.d.ts +3 -0
- package/dist/components/playground/ExecutionLogs.svelte +11 -9
- package/dist/components/playground/InputCollector.svelte +22 -57
- package/dist/components/playground/MessageStream.svelte +17 -23
- package/dist/components/playground/PipelineKanbanView.svelte +69 -8
- package/dist/components/playground/PipelineKanbanView.svelte.d.ts +2 -0
- package/dist/components/playground/PipelinePanel.svelte +31 -8
- package/dist/components/playground/PipelinePanel.svelte.d.ts +2 -0
- package/dist/components/playground/PipelineTableView.svelte +188 -44
- package/dist/components/playground/PipelineTableView.svelte.d.ts +2 -0
- package/dist/components/playground/Playground.svelte +154 -105
- package/dist/components/playground/Playground.svelte.d.ts +5 -0
- package/dist/components/playground/PlaygroundApp.svelte +12 -2
- package/dist/components/playground/PlaygroundApp.svelte.d.ts +6 -0
- package/dist/components/playground/PlaygroundModal.svelte +18 -3
- package/dist/components/playground/PlaygroundModal.svelte.d.ts +6 -0
- package/dist/components/playground/PlaygroundStudio.svelte +40 -37
- package/dist/components/playground/PlaygroundStudio.svelte.d.ts +6 -0
- package/dist/components/playground/SessionManager.svelte +9 -12
- package/dist/components/playground/pipelineViewUtils.svelte.d.ts +30 -1
- package/dist/components/playground/pipelineViewUtils.svelte.js +40 -3
- 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 +23 -7
- package/dist/config/endpoints.js +30 -10
- package/dist/core/index.d.ts +6 -7
- package/dist/core/index.js +8 -12
- package/dist/display/index.d.ts +6 -3
- package/dist/display/index.js +7 -5
- package/dist/editor/index.d.ts +20 -21
- package/dist/editor/index.js +26 -36
- package/dist/form/code.d.ts +25 -15
- package/dist/form/code.js +44 -41
- package/dist/form/fieldRegistry.d.ts +17 -13
- package/dist/form/fieldRegistry.js +32 -12
- package/dist/form/full.d.ts +19 -14
- package/dist/form/full.js +26 -28
- package/dist/form/index.d.ts +3 -4
- package/dist/form/index.js +6 -5
- package/dist/form/markdown.d.ts +13 -8
- package/dist/form/markdown.js +22 -23
- package/dist/helpers/proximityConnect.d.ts +3 -2
- package/dist/helpers/proximityConnect.js +2 -5
- package/dist/helpers/workflowEditorHelper.d.ts +14 -5
- package/dist/helpers/workflowEditorHelper.js +32 -30
- package/dist/index.d.ts +28 -24
- package/dist/index.js +27 -50
- package/dist/messages/defaults.d.ts +2 -5
- package/dist/messages/defaults.js +3 -6
- package/dist/messages/index.d.ts +1 -2
- package/dist/messages/index.js +1 -2
- package/dist/mocks/app-forms.d.ts +6 -2
- package/dist/mocks/app-forms.js +11 -4
- package/dist/openapi/v1/openapi.yaml +38 -26
- package/dist/playground/index.d.ts +4 -5
- package/dist/playground/index.js +4 -32
- package/dist/playground/mount.d.ts +34 -5
- package/dist/playground/mount.js +58 -24
- package/dist/registry/{BaseRegistry.d.ts → BaseRegistry.svelte.d.ts} +22 -1
- package/dist/registry/{BaseRegistry.js → BaseRegistry.svelte.js} +37 -1
- package/dist/registry/builtinFormats.d.ts +9 -18
- package/dist/registry/builtinFormats.js +9 -39
- package/dist/registry/builtinNodeTypes.d.ts +53 -0
- package/dist/registry/builtinNodeTypes.js +67 -0
- package/dist/registry/builtinNodes.d.ts +2 -64
- package/dist/registry/builtinNodes.js +7 -103
- package/dist/registry/index.d.ts +3 -4
- package/dist/registry/index.js +4 -6
- package/dist/registry/nodeComponentRegistry.d.ts +184 -16
- package/dist/registry/nodeComponentRegistry.js +235 -17
- package/dist/registry/workflowFormatRegistry.d.ts +14 -9
- package/dist/registry/workflowFormatRegistry.js +24 -8
- package/dist/{schema → schemas}/index.d.ts +2 -2
- package/dist/{schema → schemas}/index.js +2 -2
- package/dist/schemas/v1/workflow.schema.json +19 -17
- package/dist/services/agentSpecExecutionService.d.ts +0 -2
- package/dist/services/agentSpecExecutionService.js +0 -3
- package/dist/services/apiVariableService.d.ts +2 -1
- package/dist/services/apiVariableService.js +16 -47
- package/dist/services/autoSaveService.d.ts +7 -0
- package/dist/services/autoSaveService.js +6 -4
- package/dist/services/categoriesApi.js +3 -6
- package/dist/services/chatService.d.ts +9 -4
- package/dist/services/chatService.js +23 -28
- package/dist/services/draftStorage.d.ts +129 -13
- package/dist/services/draftStorage.js +185 -37
- package/dist/services/dynamicSchemaService.d.ts +33 -5
- package/dist/services/dynamicSchemaService.js +67 -55
- package/dist/services/globalSave.d.ts +13 -12
- package/dist/services/globalSave.js +29 -51
- package/dist/services/historyService.d.ts +39 -11
- package/dist/services/historyService.js +60 -18
- package/dist/services/interruptService.d.ts +15 -9
- package/dist/services/interruptService.js +35 -37
- package/dist/services/nodeExecutionService.d.ts +18 -3
- package/dist/services/nodeExecutionService.js +71 -45
- package/dist/services/playgroundService.d.ts +16 -10
- package/dist/services/playgroundService.js +42 -43
- 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/variableService.d.ts +2 -1
- package/dist/services/variableService.js +2 -2
- package/dist/services/workflowStorage.js +6 -6
- 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 +56 -0
- package/dist/stores/apiContext.js +80 -0
- package/dist/stores/categoriesStore.svelte.d.ts +28 -23
- package/dist/stores/categoriesStore.svelte.js +69 -64
- package/dist/stores/getInstance.svelte.d.ts +39 -0
- package/dist/stores/getInstance.svelte.js +65 -0
- package/dist/stores/historyStore.svelte.d.ts +89 -91
- package/dist/stores/historyStore.svelte.js +159 -158
- package/dist/stores/instanceContainer.svelte.d.ts +111 -0
- package/dist/stores/instanceContainer.svelte.js +119 -0
- package/dist/stores/interruptStore.svelte.d.ts +112 -82
- package/dist/stores/interruptStore.svelte.js +253 -226
- package/dist/stores/pipelinePanelStore.svelte.d.ts +27 -3
- package/dist/stores/pipelinePanelStore.svelte.js +61 -14
- package/dist/stores/playgroundStore.svelte.d.ts +169 -222
- package/dist/stores/playgroundStore.svelte.js +513 -580
- package/dist/stores/portCoordinateStore.svelte.d.ts +57 -51
- package/dist/stores/portCoordinateStore.svelte.js +109 -98
- package/dist/stores/settingsStore.svelte.d.ts +17 -1
- package/dist/stores/settingsStore.svelte.js +79 -12
- package/dist/stores/workflowStore.svelte.d.ts +212 -210
- package/dist/stores/workflowStore.svelte.js +527 -502
- package/dist/stories/EdgeDecorator.svelte +5 -2
- package/dist/stories/NodeDecorator.svelte +5 -3
- package/dist/styles/base.css +285 -14
- package/dist/styles/tokens.css +60 -2
- package/dist/svelte-app.d.ts +78 -11
- package/dist/svelte-app.js +210 -141
- 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/events.d.ts +24 -3
- package/dist/types/events.js +2 -1
- package/dist/types/index.d.ts +117 -32
- package/dist/types/index.js +0 -1
- package/dist/types/navbar.d.ts +7 -0
- package/dist/types/playground.d.ts +18 -3
- package/dist/types/settings.d.ts +30 -1
- package/dist/types/settings.js +5 -2
- 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/colors.d.ts +74 -21
- package/dist/utils/colors.js +92 -68
- package/dist/utils/connections.d.ts +9 -15
- package/dist/utils/connections.js +33 -88
- package/dist/utils/duration.d.ts +13 -0
- package/dist/utils/duration.js +45 -0
- 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/icons.d.ts +5 -2
- package/dist/utils/icons.js +6 -5
- package/dist/utils/nodeIds.d.ts +1 -1
- package/dist/utils/nodeIds.js +1 -1
- package/dist/utils/nodeSwap.d.ts +6 -2
- package/dist/utils/nodeSwap.js +62 -129
- package/dist/utils/nodeTypes.d.ts +17 -8
- package/dist/utils/nodeTypes.js +27 -20
- package/dist/utils/performanceUtils.js +7 -0
- 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 +7 -5
- package/dist/messages/deprecation.d.ts +0 -20
- package/dist/messages/deprecation.js +0 -33
- package/dist/registry/plugin.d.ts +0 -215
- package/dist/registry/plugin.js +0 -249
- package/dist/services/api.d.ts +0 -129
- package/dist/services/api.js +0 -217
package/README.md
CHANGED
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
</p>
|
|
24
24
|
|
|
25
25
|
<p align="center">
|
|
26
|
-
<a href="https://
|
|
26
|
+
<a href="https://flowdrop.mintlify.app/docs/quickstart">Quickstart</a> •
|
|
27
27
|
<a href="#features">Features</a> •
|
|
28
28
|
<a href="#integration">Integration</a> •
|
|
29
|
-
<a href="https://
|
|
29
|
+
<a href="https://flowdrop.mintlify.app">Docs</a>
|
|
30
30
|
</p>
|
|
31
31
|
|
|
32
32
|
<p align="center">
|
|
@@ -50,7 +50,7 @@ No vendor lock-in. No data leaving your walls. No surprise bills.
|
|
|
50
50
|
npm install @flowdrop/flowdrop
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
-
> **Note:** FlowDrop supports **
|
|
53
|
+
> **Note:** FlowDrop supports **multiple editor instances per page** — each mount gets its own isolated state container. See [Architecture Notes](#architecture-notes) for details.
|
|
54
54
|
|
|
55
55
|
You get a production-ready workflow UI. You keep full control of everything else.
|
|
56
56
|
|
|
@@ -58,11 +58,11 @@ You get a production-ready workflow UI. You keep full control of everything else
|
|
|
58
58
|
|
|
59
59
|
```svelte
|
|
60
60
|
<script lang="ts">
|
|
61
|
-
import {
|
|
61
|
+
import { App } from '@flowdrop/flowdrop';
|
|
62
62
|
import '@flowdrop/flowdrop/styles/base.css';
|
|
63
63
|
</script>
|
|
64
64
|
|
|
65
|
-
<
|
|
65
|
+
<App />
|
|
66
66
|
```
|
|
67
67
|
|
|
68
68
|
**5 lines. One fully-functional workflow editor.**
|
|
@@ -80,7 +80,7 @@ You get a production-ready workflow UI. You keep full control of everything else
|
|
|
80
80
|
|
|
81
81
|
## Architecture Notes
|
|
82
82
|
|
|
83
|
-
- **
|
|
83
|
+
- **Multiple instances per page.** Each mount gets its own `FlowDropInstance` state container (workflow, undo/redo history, playground sessions, registries, API context, drafts), so editors on the same page are fully isolated. In 2.0 there are no module-level store APIs — resolve state with `getInstance()` inside the component tree or the mount handle's `.instance` outside it. The first mount without an `instanceId` becomes the page-default instance; pass `instanceId` to additional mounts to scope their draft/panel storage keys. Theme and settings remain page-global by design.
|
|
84
84
|
- **Svelte 5 required.** FlowDrop uses Svelte 5 runes (`$state`, `$derived`, `$effect`) throughout. Svelte 4 is not supported.
|
|
85
85
|
- **Modern browsers only.** The library targets ES2020+ and does not include polyfills for older browsers.
|
|
86
86
|
|
|
@@ -112,12 +112,12 @@ FlowDrop includes a theme system with built-in light/dark support:
|
|
|
112
112
|
|
|
113
113
|
```svelte
|
|
114
114
|
<script lang="ts">
|
|
115
|
-
import {
|
|
115
|
+
import { App } from '@flowdrop/flowdrop';
|
|
116
116
|
import '@flowdrop/flowdrop/styles';
|
|
117
117
|
</script>
|
|
118
118
|
|
|
119
119
|
<!-- Built-in themes: 'default' or 'minimal' -->
|
|
120
|
-
<
|
|
120
|
+
<App theme="minimal" />
|
|
121
121
|
```
|
|
122
122
|
|
|
123
123
|
Themes bundle a visual skin (CSS token palette) with behavioral UI defaults. You can also pass a custom theme object with your own skin tokens for full control over the light and dark palettes.
|
|
@@ -136,29 +136,29 @@ const app = await mountFlowDropApp(container, {
|
|
|
136
136
|
Every user-facing string flows through a typed `Messages` tree. Pass a callback to override any subset:
|
|
137
137
|
|
|
138
138
|
```svelte
|
|
139
|
-
<
|
|
139
|
+
<App messages={() => ({ form: { schema: { save: 'Apply' } } })} />
|
|
140
140
|
```
|
|
141
141
|
|
|
142
|
-
Wire the callback to your i18n library (paraglide-js, sveltekit-i18n, etc.) — locale changes propagate automatically. See the [i18n & Custom Messages guide](https://
|
|
142
|
+
Wire the callback to your i18n library (paraglide-js, sveltekit-i18n, etc.) — locale changes propagate automatically. See the [i18n & Custom Messages guide](https://flowdrop.mintlify.app/guides/i18n) for the full shape and a paraglide-js worked example.
|
|
143
143
|
|
|
144
144
|
## Sub-Module Exports
|
|
145
145
|
|
|
146
146
|
FlowDrop provides tree-shakeable sub-module exports so you can import only what you need:
|
|
147
147
|
|
|
148
|
-
| Export Path | Contents
|
|
149
|
-
| ---------------------------------- |
|
|
150
|
-
| `@flowdrop/flowdrop` |
|
|
151
|
-
| `@flowdrop/flowdrop/core` | Types and utilities only (no heavy dependencies)
|
|
152
|
-
| `@flowdrop/flowdrop/editor` | WorkflowEditor, stores, services
|
|
153
|
-
| `@flowdrop/flowdrop/form` | SchemaForm, form fields, registry
|
|
154
|
-
| `@flowdrop/flowdrop/form/code` | Code editor field (CodeMirror)
|
|
155
|
-
| `@flowdrop/flowdrop/form/markdown` | Markdown editor field
|
|
156
|
-
| `@flowdrop/flowdrop/display` | MarkdownDisplay component
|
|
157
|
-
| `@flowdrop/flowdrop/playground` | Playground components and services
|
|
158
|
-
| `@flowdrop/flowdrop/settings` | SettingsPanel, stores, services
|
|
159
|
-
| `@flowdrop/flowdrop/styles` | Base CSS stylesheet
|
|
160
|
-
| `@flowdrop/flowdrop/schema` | Workflow JSON schema
|
|
161
|
-
| `@flowdrop/flowdrop/openapi` | OpenAPI spec (YAML) for the FlowDrop backend API
|
|
148
|
+
| Export Path | Contents |
|
|
149
|
+
| ---------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
|
|
150
|
+
| `@flowdrop/flowdrop` | Slim front door: `App`, mount functions, `createFlowDropInstance`, `getInstance`, auth providers, core bootstrap types |
|
|
151
|
+
| `@flowdrop/flowdrop/core` | Types and utilities only (no heavy dependencies) |
|
|
152
|
+
| `@flowdrop/flowdrop/editor` | WorkflowEditor, stores, services |
|
|
153
|
+
| `@flowdrop/flowdrop/form` | SchemaForm, form fields, registry |
|
|
154
|
+
| `@flowdrop/flowdrop/form/code` | Code editor field (CodeMirror) |
|
|
155
|
+
| `@flowdrop/flowdrop/form/markdown` | Markdown editor field |
|
|
156
|
+
| `@flowdrop/flowdrop/display` | MarkdownDisplay component |
|
|
157
|
+
| `@flowdrop/flowdrop/playground` | Playground components and services |
|
|
158
|
+
| `@flowdrop/flowdrop/settings` | SettingsPanel, stores, services |
|
|
159
|
+
| `@flowdrop/flowdrop/styles` | Base CSS stylesheet |
|
|
160
|
+
| `@flowdrop/flowdrop/schema` | Workflow JSON schema |
|
|
161
|
+
| `@flowdrop/flowdrop/openapi` | OpenAPI spec (YAML) for the FlowDrop backend API |
|
|
162
162
|
|
|
163
163
|
### OpenAPI spec
|
|
164
164
|
|
|
@@ -170,12 +170,12 @@ The full OpenAPI spec for the FlowDrop backend API ships with the package, versi
|
|
|
170
170
|
|
|
171
171
|
```svelte
|
|
172
172
|
<script>
|
|
173
|
-
import { WorkflowEditor, NodeSidebar } from '@flowdrop/flowdrop';
|
|
173
|
+
import { WorkflowEditor, NodeSidebar } from '@flowdrop/flowdrop/editor';
|
|
174
174
|
</script>
|
|
175
175
|
|
|
176
176
|
<div class="flex h-screen">
|
|
177
177
|
<NodeSidebar {nodes} />
|
|
178
|
-
<WorkflowEditor
|
|
178
|
+
<WorkflowEditor />
|
|
179
179
|
</div>
|
|
180
180
|
```
|
|
181
181
|
|
|
@@ -283,8 +283,8 @@ Runtime configuration means you build once and deploy to staging, production, or
|
|
|
283
283
|
|
|
284
284
|
| Resource | Description |
|
|
285
285
|
| -------------------------------------------------------------------------------------------- | ------------------------ |
|
|
286
|
-
| [QUICK_START.md](https://
|
|
287
|
-
| [API Documentation](https://
|
|
286
|
+
| [QUICK_START.md](https://flowdrop.mintlify.app/docs/quickstart) | Get running in 5 minutes |
|
|
287
|
+
| [API Documentation](https://flowdrop.mintlify.app/api-reference/introduction) | REST API specification |
|
|
288
288
|
| [CHANGELOG.md](https://github.com/flowdrop-io/flowdrop/blob/main/libs/flowdrop/CHANGELOG.md) | Version history |
|
|
289
289
|
|
|
290
290
|
## Development
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* - External applications that want to integrate with FlowDrop
|
|
14
14
|
* - Systems that need to generate or modify workflows programmatically
|
|
15
15
|
*/
|
|
16
|
+
import { WORKFLOW_SCHEMA_VERSION } from '../schemas/index.js';
|
|
16
17
|
import { v4 as uuidv4 } from 'uuid';
|
|
17
18
|
import { generateNodeId } from '../utils/nodeIds.js';
|
|
18
19
|
/**
|
|
@@ -35,7 +36,7 @@ export class WorkflowAdapter {
|
|
|
35
36
|
nodes: [],
|
|
36
37
|
edges: [],
|
|
37
38
|
metadata: {
|
|
38
|
-
|
|
39
|
+
schemaVersion: '1.0.0',
|
|
39
40
|
createdAt: new Date().toISOString(),
|
|
40
41
|
updatedAt: new Date().toISOString()
|
|
41
42
|
}
|
|
@@ -45,7 +46,7 @@ export class WorkflowAdapter {
|
|
|
45
46
|
* Add a node to a workflow
|
|
46
47
|
*/
|
|
47
48
|
addNode(workflow, nodeType, position, config) {
|
|
48
|
-
const metadata = this.nodeTypes.find((nt) => nt.
|
|
49
|
+
const metadata = this.nodeTypes.find((nt) => nt.node_type_id === nodeType);
|
|
49
50
|
if (!metadata) {
|
|
50
51
|
throw new Error(`Node type '${nodeType}' not found`);
|
|
51
52
|
}
|
|
@@ -222,13 +223,14 @@ export class WorkflowAdapter {
|
|
|
222
223
|
if (!validation.valid) {
|
|
223
224
|
throw new Error(`Invalid workflow: ${validation.errors.join(', ')}`);
|
|
224
225
|
}
|
|
225
|
-
// Update metadata
|
|
226
|
+
// Update metadata — heal legacy 1.x `version` key into `schemaVersion`.
|
|
227
|
+
const incoming = workflow.metadata;
|
|
226
228
|
workflow.metadata = {
|
|
227
|
-
|
|
228
|
-
createdAt:
|
|
229
|
+
schemaVersion: incoming?.schemaVersion || incoming?.version || '1.0.0',
|
|
230
|
+
createdAt: incoming?.createdAt || new Date().toISOString(),
|
|
229
231
|
updatedAt: new Date().toISOString(),
|
|
230
|
-
author:
|
|
231
|
-
tags:
|
|
232
|
+
author: incoming?.author,
|
|
233
|
+
tags: incoming?.tags
|
|
232
234
|
};
|
|
233
235
|
return workflow;
|
|
234
236
|
}
|
|
@@ -246,7 +248,7 @@ export class WorkflowAdapter {
|
|
|
246
248
|
description: svelteFlowWorkflow.description,
|
|
247
249
|
nodes: svelteFlowWorkflow.nodes.map((node) => ({
|
|
248
250
|
id: node.id,
|
|
249
|
-
type: node.data.metadata.
|
|
251
|
+
type: node.data.metadata.node_type_id,
|
|
250
252
|
position: node.position,
|
|
251
253
|
data: {
|
|
252
254
|
label: node.data.label,
|
|
@@ -280,8 +282,7 @@ export class WorkflowAdapter {
|
|
|
280
282
|
data: {
|
|
281
283
|
label: node.data.label,
|
|
282
284
|
config: node.data.config,
|
|
283
|
-
metadata: node.data.metadata
|
|
284
|
-
nodeId: node.id
|
|
285
|
+
metadata: node.data.metadata
|
|
285
286
|
}
|
|
286
287
|
})),
|
|
287
288
|
edges: workflow.edges.map((edge) => ({
|
|
@@ -291,7 +292,11 @@ export class WorkflowAdapter {
|
|
|
291
292
|
sourceHandle: edge.sourceHandle,
|
|
292
293
|
targetHandle: edge.targetHandle
|
|
293
294
|
})),
|
|
294
|
-
metadata: workflow.metadata
|
|
295
|
+
metadata: workflow.metadata ?? {
|
|
296
|
+
schemaVersion: WORKFLOW_SCHEMA_VERSION,
|
|
297
|
+
createdAt: new Date().toISOString(),
|
|
298
|
+
updatedAt: new Date().toISOString()
|
|
299
|
+
}
|
|
295
300
|
};
|
|
296
301
|
}
|
|
297
302
|
/**
|
|
@@ -320,7 +325,7 @@ export class WorkflowAdapter {
|
|
|
320
325
|
const nodeTypeCounts = new Map();
|
|
321
326
|
cloned.nodes.forEach((node) => {
|
|
322
327
|
const oldId = node.id;
|
|
323
|
-
const nodeTypeId = node.data.metadata.
|
|
328
|
+
const nodeTypeId = node.data.metadata.node_type_id;
|
|
324
329
|
// Get the current count for this node type
|
|
325
330
|
const currentCount = nodeTypeCounts.get(nodeTypeId) || 0;
|
|
326
331
|
const newCount = currentCount + 1;
|
|
@@ -337,7 +342,7 @@ export class WorkflowAdapter {
|
|
|
337
342
|
cloned.id = uuidv4();
|
|
338
343
|
cloned.name = newName || `${workflow.name} (Copy)`;
|
|
339
344
|
cloned.metadata = {
|
|
340
|
-
|
|
345
|
+
schemaVersion: cloned.metadata?.schemaVersion || '1.0.0',
|
|
341
346
|
createdAt: new Date().toISOString(),
|
|
342
347
|
updatedAt: new Date().toISOString(),
|
|
343
348
|
author: cloned.metadata?.author,
|
|
@@ -13,7 +13,7 @@ import { getComponentTypeDefaults, extractComponentType, AGENTSPEC_NAMESPACE } f
|
|
|
13
13
|
import { computeAutoLayout } from './autoLayout.js';
|
|
14
14
|
import { v4 as uuidv4 } from 'uuid';
|
|
15
15
|
import { logger } from '../../utils/logger.js';
|
|
16
|
-
import { buildHandleId, extractPortId
|
|
16
|
+
import { buildHandleId, extractPortId } from '../../utils/handleIds.js';
|
|
17
17
|
// ============================================================================
|
|
18
18
|
// Property ↔ Port Conversion
|
|
19
19
|
// ============================================================================
|
|
@@ -138,7 +138,7 @@ export class AgentSpecAdapter {
|
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
// Find start node
|
|
141
|
-
const startNodeName = this.findStartNodeName(agentSpecNodes
|
|
141
|
+
const startNodeName = this.findStartNodeName(agentSpecNodes);
|
|
142
142
|
return {
|
|
143
143
|
component_type: 'flow',
|
|
144
144
|
name: workflow.name,
|
|
@@ -149,7 +149,7 @@ export class AgentSpecAdapter {
|
|
|
149
149
|
data_flow_connections: dataFlowEdges.length > 0 ? dataFlowEdges : null,
|
|
150
150
|
metadata: {
|
|
151
151
|
'flowdrop:workflow_id': workflow.id,
|
|
152
|
-
'flowdrop:version': workflow.metadata?.
|
|
152
|
+
'flowdrop:version': workflow.metadata?.schemaVersion,
|
|
153
153
|
...(workflow.metadata?.author ? { 'flowdrop:author': workflow.metadata.author } : {}),
|
|
154
154
|
...(workflow.metadata?.tags ? { 'flowdrop:tags': workflow.metadata.tags } : {})
|
|
155
155
|
}
|
|
@@ -196,7 +196,7 @@ export class AgentSpecAdapter {
|
|
|
196
196
|
const edges = [];
|
|
197
197
|
// Control-flow edges → trigger port connections
|
|
198
198
|
for (const cfEdge of agentSpecFlow.control_flow_connections) {
|
|
199
|
-
const edge = this.convertFromControlFlowEdge(cfEdge, nameToNodeId
|
|
199
|
+
const edge = this.convertFromControlFlowEdge(cfEdge, nameToNodeId);
|
|
200
200
|
if (edge)
|
|
201
201
|
edges.push(edge);
|
|
202
202
|
}
|
|
@@ -215,7 +215,7 @@ export class AgentSpecAdapter {
|
|
|
215
215
|
nodes,
|
|
216
216
|
edges,
|
|
217
217
|
metadata: {
|
|
218
|
-
|
|
218
|
+
schemaVersion: agentSpecFlow.metadata?.['flowdrop:version'] || '1.0.0',
|
|
219
219
|
createdAt: new Date().toISOString(),
|
|
220
220
|
updatedAt: new Date().toISOString(),
|
|
221
221
|
author: agentSpecFlow.metadata?.['flowdrop:author'],
|
|
@@ -266,7 +266,7 @@ export class AgentSpecAdapter {
|
|
|
266
266
|
metadata: {
|
|
267
267
|
'flowdrop:position': node.position,
|
|
268
268
|
'flowdrop:node_id': node.id,
|
|
269
|
-
'flowdrop:node_type_id': node.data.metadata.
|
|
269
|
+
'flowdrop:node_type_id': node.data.metadata.node_type_id
|
|
270
270
|
}
|
|
271
271
|
};
|
|
272
272
|
// Add type-specific attributes from config
|
|
@@ -362,7 +362,7 @@ export class AgentSpecAdapter {
|
|
|
362
362
|
return ext;
|
|
363
363
|
}
|
|
364
364
|
// Infer from FlowDrop node type ID
|
|
365
|
-
const fromId = extractComponentType(node.data.metadata.
|
|
365
|
+
const fromId = extractComponentType(node.data.metadata.node_type_id);
|
|
366
366
|
if (fromId)
|
|
367
367
|
return fromId;
|
|
368
368
|
// Infer from FlowDrop visual type + category
|
|
@@ -404,7 +404,7 @@ export class AgentSpecAdapter {
|
|
|
404
404
|
const nodeTypeId = asNode.metadata?.['flowdrop:node_type_id'] ||
|
|
405
405
|
`${AGENTSPEC_NAMESPACE}.${asNode.component_type}`;
|
|
406
406
|
const metadata = {
|
|
407
|
-
|
|
407
|
+
node_type_id: nodeTypeId,
|
|
408
408
|
name: defaults.defaultName,
|
|
409
409
|
type: defaults.visualType,
|
|
410
410
|
description: asNode.description || defaults.defaultDescription,
|
|
@@ -578,7 +578,7 @@ export class AgentSpecAdapter {
|
|
|
578
578
|
/**
|
|
579
579
|
* Convert an Agent Spec ControlFlowEdge to a FlowDrop edge.
|
|
580
580
|
*/
|
|
581
|
-
convertFromControlFlowEdge(cfEdge, nameToNodeId
|
|
581
|
+
convertFromControlFlowEdge(cfEdge, nameToNodeId) {
|
|
582
582
|
const sourceId = nameToNodeId.get(cfEdge.from_node);
|
|
583
583
|
const targetId = nameToNodeId.get(cfEdge.to_node);
|
|
584
584
|
if (!sourceId || !targetId)
|
|
@@ -615,7 +615,7 @@ export class AgentSpecAdapter {
|
|
|
615
615
|
/**
|
|
616
616
|
* Find the start node name from converted Agent Spec nodes.
|
|
617
617
|
*/
|
|
618
|
-
findStartNodeName(nodes
|
|
618
|
+
findStartNodeName(nodes) {
|
|
619
619
|
// Look for an explicit start_node
|
|
620
620
|
const startNode = nodes.find((n) => n.component_type === 'start_node');
|
|
621
621
|
if (startNode)
|
|
@@ -30,7 +30,7 @@ function buildRegistry() {
|
|
|
30
30
|
registry.set('start_node', {
|
|
31
31
|
componentType: 'start_node',
|
|
32
32
|
metadata: {
|
|
33
|
-
|
|
33
|
+
node_type_id: `${AGENTSPEC_NS}.start_node`,
|
|
34
34
|
name: 'Start',
|
|
35
35
|
type: 'terminal',
|
|
36
36
|
description: 'Flow entry point. Defines the initial inputs for the flow.',
|
|
@@ -55,7 +55,7 @@ function buildRegistry() {
|
|
|
55
55
|
registry.set('end_node', {
|
|
56
56
|
componentType: 'end_node',
|
|
57
57
|
metadata: {
|
|
58
|
-
|
|
58
|
+
node_type_id: `${AGENTSPEC_NS}.end_node`,
|
|
59
59
|
name: 'End',
|
|
60
60
|
type: 'terminal',
|
|
61
61
|
description: 'Flow exit point. Defines the final outputs of the flow.',
|
|
@@ -80,7 +80,7 @@ function buildRegistry() {
|
|
|
80
80
|
registry.set('llm_node', {
|
|
81
81
|
componentType: 'llm_node',
|
|
82
82
|
metadata: {
|
|
83
|
-
|
|
83
|
+
node_type_id: `${AGENTSPEC_NS}.llm_node`,
|
|
84
84
|
name: 'LLM',
|
|
85
85
|
type: 'default',
|
|
86
86
|
description: 'Generate text using a large language model with configurable prompts.',
|
|
@@ -145,7 +145,7 @@ function buildRegistry() {
|
|
|
145
145
|
registry.set('branching_node', {
|
|
146
146
|
componentType: 'branching_node',
|
|
147
147
|
metadata: {
|
|
148
|
-
|
|
148
|
+
node_type_id: `${AGENTSPEC_NS}.branching_node`,
|
|
149
149
|
name: 'Branch',
|
|
150
150
|
type: 'gateway',
|
|
151
151
|
description: 'Route execution to different paths based on conditions.',
|
|
@@ -213,7 +213,7 @@ function buildRegistry() {
|
|
|
213
213
|
registry.set('tool_node', {
|
|
214
214
|
componentType: 'tool_node',
|
|
215
215
|
metadata: {
|
|
216
|
-
|
|
216
|
+
node_type_id: `${AGENTSPEC_NS}.tool_node`,
|
|
217
217
|
name: 'Tool',
|
|
218
218
|
type: 'tool',
|
|
219
219
|
description: 'Execute a tool function with inputs and receive outputs.',
|
|
@@ -271,7 +271,7 @@ function buildRegistry() {
|
|
|
271
271
|
registry.set('api_node', {
|
|
272
272
|
componentType: 'api_node',
|
|
273
273
|
metadata: {
|
|
274
|
-
|
|
274
|
+
node_type_id: `${AGENTSPEC_NS}.api_node`,
|
|
275
275
|
name: 'API Call',
|
|
276
276
|
type: 'default',
|
|
277
277
|
description: 'Make an HTTP API call with configurable endpoint, method, and headers.',
|
|
@@ -342,7 +342,7 @@ function buildRegistry() {
|
|
|
342
342
|
registry.set('agent_node', {
|
|
343
343
|
componentType: 'agent_node',
|
|
344
344
|
metadata: {
|
|
345
|
-
|
|
345
|
+
node_type_id: `${AGENTSPEC_NS}.agent_node`,
|
|
346
346
|
name: 'Agent',
|
|
347
347
|
type: 'default',
|
|
348
348
|
description: 'Run a multi-round agent conversation within the flow.',
|
|
@@ -400,7 +400,7 @@ function buildRegistry() {
|
|
|
400
400
|
registry.set('flow_node', {
|
|
401
401
|
componentType: 'flow_node',
|
|
402
402
|
metadata: {
|
|
403
|
-
|
|
403
|
+
node_type_id: `${AGENTSPEC_NS}.flow_node`,
|
|
404
404
|
name: 'Sub-Flow',
|
|
405
405
|
type: 'simple',
|
|
406
406
|
description: 'Execute another flow as a sub-routine within this flow.',
|
|
@@ -451,7 +451,7 @@ function buildRegistry() {
|
|
|
451
451
|
registry.set('map_node', {
|
|
452
452
|
componentType: 'map_node',
|
|
453
453
|
metadata: {
|
|
454
|
-
|
|
454
|
+
node_type_id: `${AGENTSPEC_NS}.map_node`,
|
|
455
455
|
name: 'Map',
|
|
456
456
|
type: 'default',
|
|
457
457
|
description: 'Apply a flow or operation to each item in a collection (map-reduce).',
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @module api/enhanced-client
|
|
7
7
|
*/
|
|
8
|
-
import { buildEndpointUrl, getEndpointMethod,
|
|
8
|
+
import { buildEndpointUrl, getEndpointMethod, getRequestHeaders } from '../config/endpoints.js';
|
|
9
9
|
import { NoAuthProvider } from '../types/auth.js';
|
|
10
10
|
import { getApiSettings } from '../stores/settingsStore.svelte.js';
|
|
11
11
|
import { logger } from '../utils/logger.js';
|
|
@@ -56,15 +56,12 @@ export class EnhancedFlowDropApiClient {
|
|
|
56
56
|
async request(endpointKey, endpointPath, params, options = {}, operation = 'API request') {
|
|
57
57
|
const url = buildEndpointUrl(this.config, endpointPath, params);
|
|
58
58
|
const method = options.method ?? getEndpointMethod(this.config, endpointKey);
|
|
59
|
-
const configHeaders = getEndpointHeaders(this.config, endpointKey);
|
|
60
59
|
// Get user settings for timeout and retry
|
|
61
60
|
const userApiSettings = getApiSettings();
|
|
62
|
-
//
|
|
63
|
-
|
|
64
|
-
// Merge headers: config headers < auth headers < request-specific headers
|
|
61
|
+
// Merge headers via the shared path: static endpoint headers < auth headers
|
|
62
|
+
// < request-specific headers.
|
|
65
63
|
const headers = {
|
|
66
|
-
...
|
|
67
|
-
...authHeaders,
|
|
64
|
+
...(await getRequestHeaders(this.config, endpointKey, this.authProvider)),
|
|
68
65
|
...options.headers
|
|
69
66
|
};
|
|
70
67
|
// Create AbortController for timeout
|
|
@@ -93,11 +90,9 @@ export class EnhancedFlowDropApiClient {
|
|
|
93
90
|
if (this.authProvider.onUnauthorized) {
|
|
94
91
|
const refreshed = await this.authProvider.onUnauthorized();
|
|
95
92
|
if (refreshed && attempt < maxAttempts) {
|
|
96
|
-
//
|
|
97
|
-
const newAuthHeaders = await this.authProvider.getAuthHeaders();
|
|
93
|
+
// Rebuild headers via the shared path to pick up the fresh token.
|
|
98
94
|
fetchConfig.headers = {
|
|
99
|
-
...
|
|
100
|
-
...newAuthHeaders,
|
|
95
|
+
...(await getRequestHeaders(this.config, endpointKey, this.authProvider)),
|
|
101
96
|
...options.headers
|
|
102
97
|
};
|
|
103
98
|
continue; // Retry with new headers
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Batch retry feedback for the AI Assistant.
|
|
3
|
+
*
|
|
4
|
+
* When a batch of DSL commands finishes with failures — some couldn't be
|
|
5
|
+
* parsed, or one failed to execute and the batch rolled back — the assistant
|
|
6
|
+
* needs concrete, specific feedback to self-correct. This module builds that
|
|
7
|
+
* message.
|
|
8
|
+
*
|
|
9
|
+
* Specificity is the point: the parse-error feedback names the offending text
|
|
10
|
+
* and the exact parser reason. The old generic "provide corrected commands"
|
|
11
|
+
* ask is what made auto-retry on parse errors loop on the same malformed shape
|
|
12
|
+
* — so it was disabled. Pinpointing the failure makes re-enabling it safe.
|
|
13
|
+
*
|
|
14
|
+
* @module chat/batchFeedback
|
|
15
|
+
*/
|
|
16
|
+
/** A command that could not be parsed, with the reason and its raw text. */
|
|
17
|
+
export interface ParseFailure {
|
|
18
|
+
raw: string;
|
|
19
|
+
error: string;
|
|
20
|
+
}
|
|
21
|
+
/** Summary of how a batch finished, used to build retry feedback. */
|
|
22
|
+
export interface BatchOutcome {
|
|
23
|
+
/** Number of commands that executed successfully before stopping. */
|
|
24
|
+
completedCount: number;
|
|
25
|
+
/** Error from the first command that failed to execute, if any. */
|
|
26
|
+
executionError?: string;
|
|
27
|
+
/** Whether the executed commands were rolled back (atomic execution failure). */
|
|
28
|
+
rolledBack: boolean;
|
|
29
|
+
/** Commands that could not be parsed and were skipped. */
|
|
30
|
+
parseErrors: ParseFailure[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Build feedback for the assistant after a batch finished with failures.
|
|
34
|
+
*
|
|
35
|
+
* Pinpoints *what* went wrong — the specific parser error and offending text
|
|
36
|
+
* for unparseable commands, and/or the execution error — so the assistant has
|
|
37
|
+
* a concrete, different target to correct.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildRetryFeedback(outcome: BatchOutcome): string;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Batch retry feedback for the AI Assistant.
|
|
3
|
+
*
|
|
4
|
+
* When a batch of DSL commands finishes with failures — some couldn't be
|
|
5
|
+
* parsed, or one failed to execute and the batch rolled back — the assistant
|
|
6
|
+
* needs concrete, specific feedback to self-correct. This module builds that
|
|
7
|
+
* message.
|
|
8
|
+
*
|
|
9
|
+
* Specificity is the point: the parse-error feedback names the offending text
|
|
10
|
+
* and the exact parser reason. The old generic "provide corrected commands"
|
|
11
|
+
* ask is what made auto-retry on parse errors loop on the same malformed shape
|
|
12
|
+
* — so it was disabled. Pinpointing the failure makes re-enabling it safe.
|
|
13
|
+
*
|
|
14
|
+
* @module chat/batchFeedback
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* Build feedback for the assistant after a batch finished with failures.
|
|
18
|
+
*
|
|
19
|
+
* Pinpoints *what* went wrong — the specific parser error and offending text
|
|
20
|
+
* for unparseable commands, and/or the execution error — so the assistant has
|
|
21
|
+
* a concrete, different target to correct.
|
|
22
|
+
*/
|
|
23
|
+
export function buildRetryFeedback(outcome) {
|
|
24
|
+
const { completedCount, executionError, rolledBack, parseErrors } = outcome;
|
|
25
|
+
const lines = [];
|
|
26
|
+
if (executionError) {
|
|
27
|
+
lines.push(`A command failed to execute: ${executionError}`);
|
|
28
|
+
lines.push(rolledBack && completedCount > 0
|
|
29
|
+
? `The ${completedCount} command(s) that had succeeded were rolled back, so no changes were applied.`
|
|
30
|
+
: 'No changes were applied.');
|
|
31
|
+
}
|
|
32
|
+
else if (completedCount > 0) {
|
|
33
|
+
lines.push(`${completedCount} command(s) were applied successfully.`);
|
|
34
|
+
}
|
|
35
|
+
if (parseErrors.length > 0) {
|
|
36
|
+
lines.push(`\n${parseErrors.length} command(s) could not be parsed and were skipped:`);
|
|
37
|
+
for (const pe of parseErrors) {
|
|
38
|
+
const firstLine = pe.raw.split('\n')[0];
|
|
39
|
+
const preview = pe.raw.includes('\n') ? `${firstLine} …` : firstLine;
|
|
40
|
+
lines.push(` • ${preview}\n reason: ${pe.error}`);
|
|
41
|
+
}
|
|
42
|
+
lines.push('\nNote: multiline values must close with """ on its own line.');
|
|
43
|
+
}
|
|
44
|
+
if (rolledBack) {
|
|
45
|
+
lines.push('\nPlease re-send the full corrected batch to achieve the original goal.');
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
lines.push('\nThe successful changes are reflected in the current workflow state. Re-send only corrected versions of the skipped command(s).');
|
|
49
|
+
}
|
|
50
|
+
return lines.join('\n');
|
|
51
|
+
}
|