@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
|
@@ -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
|
|
@@ -39,7 +39,7 @@ export function buildRetryFeedback(outcome) {
|
|
|
39
39
|
const preview = pe.raw.includes('\n') ? `${firstLine} …` : firstLine;
|
|
40
40
|
lines.push(` • ${preview}\n reason: ${pe.error}`);
|
|
41
41
|
}
|
|
42
|
-
lines.push('\nNote: multiline
|
|
42
|
+
lines.push('\nNote: a multiline value must be closed by a matching """ (on its own line or at the end of the last content line). Escape a literal triple-quote inside the value as \\""".');
|
|
43
43
|
}
|
|
44
44
|
if (rolledBack) {
|
|
45
45
|
lines.push('\nPlease re-send the full corrected batch to achieve the original goal.');
|
|
@@ -17,3 +17,14 @@
|
|
|
17
17
|
* @returns true if the command modifies workflow state, false if read-only
|
|
18
18
|
*/
|
|
19
19
|
export declare function isMutatingCommand(commandType: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Determine whether a DSL command type re-arranges existing node positions.
|
|
22
|
+
*
|
|
23
|
+
* Used by the AI panel to honour the `chatAllowLayoutChanges` behaviour setting:
|
|
24
|
+
* when layout changes are disallowed, these commands are skipped instead of
|
|
25
|
+
* executed so a hand-crafted layout survives an assistant batch (issue #36).
|
|
26
|
+
*
|
|
27
|
+
* @param commandType - The command type string (e.g., "beautify_layout")
|
|
28
|
+
* @returns true if the command repositions existing nodes
|
|
29
|
+
*/
|
|
30
|
+
export declare function isLayoutCommand(commandType: string): boolean;
|
|
@@ -28,3 +28,23 @@ const READ_ONLY_COMMANDS = new Set([
|
|
|
28
28
|
export function isMutatingCommand(commandType) {
|
|
29
29
|
return !READ_ONLY_COMMANDS.has(commandType);
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Commands that rewrite the position of *existing* nodes.
|
|
33
|
+
*
|
|
34
|
+
* Viewport commands (`canvas fitview`, zoom, pan) are deliberately absent —
|
|
35
|
+
* they only move the camera and leave the stored arrangement intact.
|
|
36
|
+
*/
|
|
37
|
+
const LAYOUT_COMMANDS = new Set(['auto_layout', 'beautify_layout']);
|
|
38
|
+
/**
|
|
39
|
+
* Determine whether a DSL command type re-arranges existing node positions.
|
|
40
|
+
*
|
|
41
|
+
* Used by the AI panel to honour the `chatAllowLayoutChanges` behaviour setting:
|
|
42
|
+
* when layout changes are disallowed, these commands are skipped instead of
|
|
43
|
+
* executed so a hand-crafted layout survives an assistant batch (issue #36).
|
|
44
|
+
*
|
|
45
|
+
* @param commandType - The command type string (e.g., "beautify_layout")
|
|
46
|
+
* @returns true if the command repositions existing nodes
|
|
47
|
+
*/
|
|
48
|
+
export function isLayoutCommand(commandType) {
|
|
49
|
+
return LAYOUT_COMMANDS.has(commandType);
|
|
50
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation history builder for the AI Assistant.
|
|
3
|
+
*
|
|
4
|
+
* The panel's chat log is tuned for humans: the assistant bubble shows only the
|
|
5
|
+
* explanation (the ```flowdrop block is lifted out into the command preview),
|
|
6
|
+
* and whether the user applied or dismissed that preview lives in UI state.
|
|
7
|
+
* Sending that log verbatim to the backend hides two things from the assistant
|
|
8
|
+
* on the next turn — the commands it emitted, and what became of them. It then
|
|
9
|
+
* has to guess whether its previous change landed, and re-emits `add …` for
|
|
10
|
+
* nodes that already exist (issue #35).
|
|
11
|
+
*
|
|
12
|
+
* This module rebuilds the log into API history: the assistant's *raw* response
|
|
13
|
+
* plus an explicit outcome report for every command it emitted.
|
|
14
|
+
*
|
|
15
|
+
* @module chat/historyBuilder
|
|
16
|
+
*/
|
|
17
|
+
import type { ChatHistoryMessage, ChatMessageRole, CommandPreviewItem } from '../types/chat.js';
|
|
18
|
+
/** One entry of the panel's chat log, as far as history building cares. */
|
|
19
|
+
export interface ChatLogEntry {
|
|
20
|
+
role: ChatMessageRole;
|
|
21
|
+
/** What the bubble displays — explanation only for assistant messages. */
|
|
22
|
+
content: string;
|
|
23
|
+
/** The unmodified LLM response, when it differs from {@link content}. */
|
|
24
|
+
rawContent?: string;
|
|
25
|
+
/** Commands extracted from this response, with their live status. */
|
|
26
|
+
commandPreview?: CommandPreviewItem[];
|
|
27
|
+
/** Results of read-only commands auto-executed for this response. */
|
|
28
|
+
readOnlyResults?: string[];
|
|
29
|
+
/** Set when the user dismissed the preview instead of applying it. */
|
|
30
|
+
commandsDismissed?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Convert the panel's chat log into the history sent to the chat endpoint.
|
|
34
|
+
*
|
|
35
|
+
* Assistant entries carry their raw response (so the assistant sees the DSL it
|
|
36
|
+
* emitted) followed by an outcome report for each command in it. User entries
|
|
37
|
+
* pass through unchanged.
|
|
38
|
+
*/
|
|
39
|
+
export declare function buildApiHistory(log: ChatLogEntry[]): ChatHistoryMessage[];
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Conversation history builder for the AI Assistant.
|
|
3
|
+
*
|
|
4
|
+
* The panel's chat log is tuned for humans: the assistant bubble shows only the
|
|
5
|
+
* explanation (the ```flowdrop block is lifted out into the command preview),
|
|
6
|
+
* and whether the user applied or dismissed that preview lives in UI state.
|
|
7
|
+
* Sending that log verbatim to the backend hides two things from the assistant
|
|
8
|
+
* on the next turn — the commands it emitted, and what became of them. It then
|
|
9
|
+
* has to guess whether its previous change landed, and re-emits `add …` for
|
|
10
|
+
* nodes that already exist (issue #35).
|
|
11
|
+
*
|
|
12
|
+
* This module rebuilds the log into API history: the assistant's *raw* response
|
|
13
|
+
* plus an explicit outcome report for every command it emitted.
|
|
14
|
+
*
|
|
15
|
+
* @module chat/historyBuilder
|
|
16
|
+
*/
|
|
17
|
+
/** Longest command echo in an outcome line before it is elided. */
|
|
18
|
+
const MAX_COMMAND_ECHO = 160;
|
|
19
|
+
/** Collapse a (possibly multiline) command to one readable line. */
|
|
20
|
+
function echoCommand(raw) {
|
|
21
|
+
const flat = raw.replace(/\s+/g, ' ').trim();
|
|
22
|
+
return flat.length > MAX_COMMAND_ECHO ? `${flat.slice(0, MAX_COMMAND_ECHO)} …` : flat;
|
|
23
|
+
}
|
|
24
|
+
/** Describe what happened to a single previewed command. */
|
|
25
|
+
function describeOutcome(item, dismissed) {
|
|
26
|
+
const echo = echoCommand(item.raw);
|
|
27
|
+
const reason = item.result ? ` — ${item.result}` : '';
|
|
28
|
+
switch (item.status) {
|
|
29
|
+
case 'success':
|
|
30
|
+
return `APPLIED: ${echo}`;
|
|
31
|
+
case 'error':
|
|
32
|
+
return `FAILED, not applied: ${echo}${reason}`;
|
|
33
|
+
case 'skipped':
|
|
34
|
+
return `SKIPPED, not applied: ${echo}${reason}`;
|
|
35
|
+
// 'pending' / 'executing' — the user never resolved the preview, or is
|
|
36
|
+
// resolving it right now. Either way nothing is committed yet.
|
|
37
|
+
default:
|
|
38
|
+
return dismissed
|
|
39
|
+
? `DISMISSED by the user, not applied: ${echo}`
|
|
40
|
+
: `NOT APPLIED YET (awaiting the user's approval): ${echo}`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Build the outcome report appended to an assistant message in API history.
|
|
45
|
+
*
|
|
46
|
+
* Returns an empty string when the message emitted no commands.
|
|
47
|
+
*/
|
|
48
|
+
function buildOutcomeReport(entry) {
|
|
49
|
+
const sections = [];
|
|
50
|
+
if (entry.commandPreview && entry.commandPreview.length > 0) {
|
|
51
|
+
const dismissed = entry.commandsDismissed === true;
|
|
52
|
+
sections.push([
|
|
53
|
+
'[command outcomes — authoritative. The workflow state in this request already',
|
|
54
|
+
'includes every APPLIED command; re-sending one would duplicate it. Only commands',
|
|
55
|
+
'marked not applied still need to be sent.]'
|
|
56
|
+
].join('\n'));
|
|
57
|
+
for (const item of entry.commandPreview) {
|
|
58
|
+
sections.push(describeOutcome(item, dismissed));
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (entry.readOnlyResults && entry.readOnlyResults.length > 0) {
|
|
62
|
+
sections.push('[read-only command results]');
|
|
63
|
+
sections.push(...entry.readOnlyResults);
|
|
64
|
+
}
|
|
65
|
+
return sections.length > 0 ? `\n\n${sections.join('\n')}` : '';
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Convert the panel's chat log into the history sent to the chat endpoint.
|
|
69
|
+
*
|
|
70
|
+
* Assistant entries carry their raw response (so the assistant sees the DSL it
|
|
71
|
+
* emitted) followed by an outcome report for each command in it. User entries
|
|
72
|
+
* pass through unchanged.
|
|
73
|
+
*/
|
|
74
|
+
export function buildApiHistory(log) {
|
|
75
|
+
return log.map((entry) => {
|
|
76
|
+
if (entry.role !== 'assistant') {
|
|
77
|
+
return { role: entry.role, content: entry.content };
|
|
78
|
+
}
|
|
79
|
+
const base = entry.rawContent ?? entry.content;
|
|
80
|
+
return { role: entry.role, content: `${base}${buildOutcomeReport(entry)}` };
|
|
81
|
+
});
|
|
82
|
+
}
|
package/dist/chat/index.d.ts
CHANGED
|
@@ -23,5 +23,6 @@
|
|
|
23
23
|
export { default as AIChatPanel } from '../components/chat/AIChatPanel.svelte';
|
|
24
24
|
export { default as CommandPreview } from '../components/chat/CommandPreview.svelte';
|
|
25
25
|
export { extractCommands } from './responseParser.js';
|
|
26
|
-
export { isMutatingCommand } from './commandClassifier.js';
|
|
26
|
+
export { isMutatingCommand, isLayoutCommand } from './commandClassifier.js';
|
|
27
|
+
export { buildApiHistory, type ChatLogEntry } from './historyBuilder.js';
|
|
27
28
|
export type { ChatMessageRole, ChatHistoryMessage, ChatRequest, ChatResponse, ExtractedCommands, CommandExecutionStatus, CommandPreviewItem } from '../types/chat.js';
|
package/dist/chat/index.js
CHANGED
|
@@ -29,4 +29,5 @@ export { default as CommandPreview } from '../components/chat/CommandPreview.sve
|
|
|
29
29
|
// Chat Utilities
|
|
30
30
|
// ============================================================================
|
|
31
31
|
export { extractCommands } from './responseParser.js';
|
|
32
|
-
export { isMutatingCommand } from './commandClassifier.js';
|
|
32
|
+
export { isMutatingCommand, isLayoutCommand } from './commandClassifier.js';
|
|
33
|
+
export { buildApiHistory } from './historyBuilder.js';
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* @module chat/responseParser
|
|
9
9
|
*/
|
|
10
|
+
import { countTripleQuotes } from '../commands/parser.js';
|
|
10
11
|
/**
|
|
11
12
|
* Extract DSL commands from an LLM response string.
|
|
12
13
|
*
|
|
@@ -25,22 +26,25 @@ export function extractCommands(llmResponse) {
|
|
|
25
26
|
let isFlowdropBlock = false;
|
|
26
27
|
let currentExplanation = [];
|
|
27
28
|
let multilineBuffer = null;
|
|
29
|
+
// Running count of unescaped """ delimiters seen since the buffer opened.
|
|
30
|
+
// The block is closed when the count is even again (issue #35).
|
|
31
|
+
let multilineDelimiters = 0;
|
|
28
32
|
for (const line of lines) {
|
|
29
33
|
const trimmed = line.trim();
|
|
30
34
|
// Handle multiline buffer FIRST — prevents code fences inside """...""" from
|
|
31
35
|
// closing the outer flowdrop block or being misinterpreted as control lines.
|
|
32
36
|
if (multilineBuffer !== null) {
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
//
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
multilineBuffer.push(line); // preserve raw indentation inside value
|
|
38
|
+
multilineDelimiters += countTripleQuotes(trimmed);
|
|
39
|
+
// Delimiters balance out — the value ended on this line. Parity (rather
|
|
40
|
+
// than "the line is exactly \"\"\"") lets the closer sit at the end of a
|
|
41
|
+
// content line, which is how LLMs actually write it
|
|
42
|
+
// (`set n.1:t """line one\nline two"""`), while a content line carrying a
|
|
43
|
+
// balanced pair (`Use Python """docstrings"""`) keeps the block open.
|
|
44
|
+
if (multilineDelimiters % 2 === 0) {
|
|
38
45
|
commands.push(multilineBuffer.join('\n'));
|
|
39
46
|
multilineBuffer = null;
|
|
40
47
|
}
|
|
41
|
-
else {
|
|
42
|
-
multilineBuffer.push(line); // preserve raw indentation inside value
|
|
43
|
-
}
|
|
44
48
|
continue;
|
|
45
49
|
}
|
|
46
50
|
// Check for code block fence opening/closing
|
|
@@ -68,12 +72,12 @@ export function extractCommands(llmResponse) {
|
|
|
68
72
|
if (trimmed === '' || trimmed.startsWith('#') || trimmed.startsWith('//')) {
|
|
69
73
|
continue;
|
|
70
74
|
}
|
|
71
|
-
//
|
|
75
|
+
// An odd number of unescaped """ leaves a value open at end of line —
|
|
72
76
|
// start accumulating a multiline value block
|
|
73
|
-
const
|
|
74
|
-
if (
|
|
75
|
-
// Opening triple-quote with no closing on this line — start buffer
|
|
77
|
+
const delimiters = countTripleQuotes(trimmed);
|
|
78
|
+
if (delimiters % 2 === 1) {
|
|
76
79
|
multilineBuffer = [trimmed];
|
|
80
|
+
multilineDelimiters = delimiters;
|
|
77
81
|
continue;
|
|
78
82
|
}
|
|
79
83
|
commands.push(trimmed);
|
|
@@ -76,7 +76,7 @@ function executeAddNode(command, context) {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
const position = command.position ?? computeAutoPosition(workflow.nodes);
|
|
79
|
-
const nodeId = generateNodeId(metadata.
|
|
79
|
+
const nodeId = generateNodeId(metadata.node_type_id, workflow.nodes);
|
|
80
80
|
const config = extractConfigDefaults(metadata.configSchema);
|
|
81
81
|
const node = {
|
|
82
82
|
id: nodeId,
|
|
@@ -86,8 +86,7 @@ function executeAddNode(command, context) {
|
|
|
86
86
|
data: {
|
|
87
87
|
label: metadata.name,
|
|
88
88
|
config,
|
|
89
|
-
metadata
|
|
90
|
-
nodeId
|
|
89
|
+
metadata
|
|
91
90
|
}
|
|
92
91
|
};
|
|
93
92
|
context.dispatch.addNode(node);
|
|
@@ -357,7 +356,7 @@ function executeInfo(command, context) {
|
|
|
357
356
|
const resultData = {
|
|
358
357
|
nodeId: shortId,
|
|
359
358
|
label: node.data.label ?? metadata?.name ?? '',
|
|
360
|
-
type: metadata?.
|
|
359
|
+
type: metadata?.node_type_id ? toShortTypeId(metadata.node_type_id) : '',
|
|
361
360
|
position: node.position,
|
|
362
361
|
config: node.data.config ?? {},
|
|
363
362
|
inputs,
|
|
@@ -379,38 +378,49 @@ function executeInfo(command, context) {
|
|
|
379
378
|
*/
|
|
380
379
|
function findPort(node, portId, preferDirection) {
|
|
381
380
|
const metadata = node.data?.metadata;
|
|
382
|
-
|
|
381
|
+
const config = node.data?.config;
|
|
382
|
+
if (!metadata && !config)
|
|
383
383
|
return null;
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
if (
|
|
390
|
-
return
|
|
391
|
-
|
|
392
|
-
|
|
384
|
+
// Resolve an output port from static metadata or config-driven ports. The
|
|
385
|
+
// latter are not in metadata.outputs: gateway branches live in config.branches
|
|
386
|
+
// and user-defined handles live in config.dynamicOutputs (both keyed by name).
|
|
387
|
+
const resolveOutput = () => {
|
|
388
|
+
const meta = metadata?.outputs?.find((p) => p.id === portId);
|
|
389
|
+
if (meta)
|
|
390
|
+
return meta;
|
|
391
|
+
const branch = config?.branches?.find((b) => b.name === portId);
|
|
392
|
+
if (branch)
|
|
393
|
+
return { id: portId, name: branch.label ?? portId, dataType: 'trigger' };
|
|
394
|
+
const dynamic = config?.dynamicOutputs?.find((p) => p.name === portId);
|
|
395
|
+
if (dynamic)
|
|
396
|
+
return { id: portId, name: dynamic.label ?? portId, dataType: dynamic.dataType };
|
|
397
|
+
return null;
|
|
398
|
+
};
|
|
399
|
+
// Resolve an input port from static metadata or config.dynamicInputs.
|
|
400
|
+
const resolveInput = () => {
|
|
401
|
+
const meta = metadata?.inputs?.find((p) => p.id === portId);
|
|
402
|
+
if (meta)
|
|
403
|
+
return meta;
|
|
404
|
+
const dynamic = config?.dynamicInputs?.find((p) => p.name === portId);
|
|
405
|
+
if (dynamic)
|
|
406
|
+
return { id: portId, name: dynamic.label ?? portId, dataType: dynamic.dataType };
|
|
407
|
+
return null;
|
|
408
|
+
};
|
|
409
|
+
const outputPort = resolveOutput();
|
|
410
|
+
const inputPort = resolveInput();
|
|
411
|
+
if (preferDirection === 'input') {
|
|
393
412
|
if (inputPort)
|
|
394
413
|
return { port: inputPort, direction: 'input' };
|
|
395
414
|
if (outputPort)
|
|
396
415
|
return { port: outputPort, direction: 'output' };
|
|
397
416
|
}
|
|
398
417
|
else {
|
|
418
|
+
// Default and explicit 'output' both prefer the output port first.
|
|
399
419
|
if (outputPort)
|
|
400
420
|
return { port: outputPort, direction: 'output' };
|
|
401
421
|
if (inputPort)
|
|
402
422
|
return { port: inputPort, direction: 'input' };
|
|
403
423
|
}
|
|
404
|
-
// Gateway nodes have dynamic branch ports stored in config.branches, not metadata.outputs
|
|
405
|
-
if (metadata.type === 'gateway') {
|
|
406
|
-
const branches = node.data.config?.branches;
|
|
407
|
-
if (branches?.some((b) => b.name === portId)) {
|
|
408
|
-
return {
|
|
409
|
-
port: { id: portId, name: portId, dataType: 'trigger' },
|
|
410
|
-
direction: 'output'
|
|
411
|
-
};
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
424
|
return null;
|
|
415
425
|
}
|
|
416
426
|
function executeConnect(command, context) {
|
|
@@ -484,6 +494,21 @@ function executeConnect(command, context) {
|
|
|
484
494
|
const targetHandle = buildHandleId(targetNode.id, 'input', command.targetPort);
|
|
485
495
|
// Generate edge ID
|
|
486
496
|
const edgeId = `${sourceNode.id}-${sourceHandle}-${targetNode.id}-${targetHandle}`;
|
|
497
|
+
// Idempotency guard: re-applying the same connection (e.g. a second
|
|
498
|
+
// AI-assistant Apply that re-emits an existing edge) must not append a
|
|
499
|
+
// duplicate. Two edges sharing an id crash the canvas with Svelte's
|
|
500
|
+
// `each_key_duplicate`. Treat an existing identical connection as a no-op.
|
|
501
|
+
const alreadyConnected = workflow.edges.some((e) => e.id === edgeId ||
|
|
502
|
+
(e.source === sourceNode.id &&
|
|
503
|
+
e.target === targetNode.id &&
|
|
504
|
+
e.sourceHandle === sourceHandle &&
|
|
505
|
+
e.targetHandle === targetHandle));
|
|
506
|
+
if (alreadyConnected) {
|
|
507
|
+
return {
|
|
508
|
+
ok: true,
|
|
509
|
+
message: `Already connected ${toShortId(sourceNode.id)}:${command.sourcePort} → ${toShortId(targetNode.id)}:${command.targetPort}`
|
|
510
|
+
};
|
|
511
|
+
}
|
|
487
512
|
// Build edge
|
|
488
513
|
const edge = {
|
|
489
514
|
id: edgeId,
|
|
@@ -578,7 +603,7 @@ function executeListNodes(context) {
|
|
|
578
603
|
const nodes = workflow.nodes.map((n) => ({
|
|
579
604
|
nodeId: toShortId(n.id),
|
|
580
605
|
label: n.data.label ?? n.data.metadata?.name ?? '',
|
|
581
|
-
type: n.data.metadata?.
|
|
606
|
+
type: n.data.metadata?.node_type_id ? toShortTypeId(n.data.metadata.node_type_id) : ''
|
|
582
607
|
}));
|
|
583
608
|
const resultData = { nodes };
|
|
584
609
|
return {
|
|
@@ -610,7 +635,7 @@ function executeListEdges(context) {
|
|
|
610
635
|
}
|
|
611
636
|
function executeListTypes(context) {
|
|
612
637
|
const types = context.nodeTypes.map((m) => ({
|
|
613
|
-
typeId: toShortTypeId(m.
|
|
638
|
+
typeId: toShortTypeId(m.node_type_id),
|
|
614
639
|
name: m.name,
|
|
615
640
|
category: m.category
|
|
616
641
|
}));
|
|
@@ -7,6 +7,18 @@
|
|
|
7
7
|
* @module commands/parser
|
|
8
8
|
*/
|
|
9
9
|
import type { ParseResult } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Count the `"""` delimiters in a string, ignoring escaped ones.
|
|
12
|
+
*
|
|
13
|
+
* `\"""` is the escape for a literal triple-quote inside a value (unescaped
|
|
14
|
+
* when the value is parsed), so it is content, not a delimiter. Occurrences are
|
|
15
|
+
* counted non-overlapping, left to right — an odd total means a value was left
|
|
16
|
+
* open.
|
|
17
|
+
*
|
|
18
|
+
* Shared with the chat response parser, which uses the same parity rule to
|
|
19
|
+
* decide where a multiline value ends.
|
|
20
|
+
*/
|
|
21
|
+
export declare function countTripleQuotes(input: string): number;
|
|
10
22
|
/**
|
|
11
23
|
* Parse a command string into a typed Command object.
|
|
12
24
|
*
|
package/dist/commands/parser.js
CHANGED
|
@@ -6,6 +6,33 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @module commands/parser
|
|
8
8
|
*/
|
|
9
|
+
/**
|
|
10
|
+
* Count the `"""` delimiters in a string, ignoring escaped ones.
|
|
11
|
+
*
|
|
12
|
+
* `\"""` is the escape for a literal triple-quote inside a value (unescaped
|
|
13
|
+
* when the value is parsed), so it is content, not a delimiter. Occurrences are
|
|
14
|
+
* counted non-overlapping, left to right — an odd total means a value was left
|
|
15
|
+
* open.
|
|
16
|
+
*
|
|
17
|
+
* Shared with the chat response parser, which uses the same parity rule to
|
|
18
|
+
* decide where a multiline value ends.
|
|
19
|
+
*/
|
|
20
|
+
export function countTripleQuotes(input) {
|
|
21
|
+
let count = 0;
|
|
22
|
+
let i = 0;
|
|
23
|
+
while (i <= input.length - 3) {
|
|
24
|
+
if (input.startsWith('"""', i)) {
|
|
25
|
+
if (i === 0 || input[i - 1] !== '\\') {
|
|
26
|
+
count++;
|
|
27
|
+
}
|
|
28
|
+
i += 3;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
i++;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return count;
|
|
35
|
+
}
|
|
9
36
|
/**
|
|
10
37
|
* Parse a coordinate pair like "200,300" or "-50, 100"
|
|
11
38
|
*/
|
|
@@ -260,14 +287,14 @@ export function parseCommand(input) {
|
|
|
260
287
|
return { ok: false, error: 'Empty command', input };
|
|
261
288
|
}
|
|
262
289
|
// Detect an unclosed multiline """ block — common when a low-quality LLM
|
|
263
|
-
// omits the closing """
|
|
264
|
-
//
|
|
265
|
-
//
|
|
266
|
-
//
|
|
267
|
-
if (trimmed
|
|
290
|
+
// omits the closing """. Delimiters come in pairs (escaped `\"""` excluded),
|
|
291
|
+
// so an odd count means a value was left open, whether it was opened on its
|
|
292
|
+
// own line or inline after the key. Surface a clear error instead of falling
|
|
293
|
+
// through to a generic "Invalid syntax".
|
|
294
|
+
if (countTripleQuotes(trimmed) % 2 === 1) {
|
|
268
295
|
return {
|
|
269
296
|
ok: false,
|
|
270
|
-
error: 'Unclosed """ block —
|
|
297
|
+
error: 'Unclosed """ block — no matching closing """',
|
|
271
298
|
input
|
|
272
299
|
};
|
|
273
300
|
}
|
|
@@ -32,6 +32,8 @@ export function createStoreCommandContext(nodeTypes, onUIAction, instance) {
|
|
|
32
32
|
removeEdge: (edgeId) => actions.removeEdge(edgeId),
|
|
33
33
|
batchUpdate: (updates) => actions.batchUpdate(updates),
|
|
34
34
|
undo: () => {
|
|
35
|
+
// Flush a pending edit session into a committed step before undoing it.
|
|
36
|
+
actions.finalizeNodeConfig();
|
|
35
37
|
const previousState = history.undo();
|
|
36
38
|
if (previousState) {
|
|
37
39
|
actions.restoreFromHistory(previousState);
|
|
@@ -40,6 +42,7 @@ export function createStoreCommandContext(nodeTypes, onUIAction, instance) {
|
|
|
40
42
|
return false;
|
|
41
43
|
},
|
|
42
44
|
redo: () => {
|
|
45
|
+
actions.finalizeNodeConfig();
|
|
43
46
|
const nextState = history.redo();
|
|
44
47
|
if (nextState) {
|
|
45
48
|
actions.restoreFromHistory(nextState);
|
|
@@ -53,7 +56,14 @@ export function createStoreCommandContext(nodeTypes, onUIAction, instance) {
|
|
|
53
56
|
history.startTransaction(currentWorkflow, description);
|
|
54
57
|
}
|
|
55
58
|
},
|
|
56
|
-
|
|
59
|
+
// Commit the transaction's post-change (current) state so one undo reverts
|
|
60
|
+
// the whole batch and redo restores its result (issue #39).
|
|
61
|
+
commitTransaction: () => {
|
|
62
|
+
const currentWorkflow = readWorkflow();
|
|
63
|
+
if (currentWorkflow) {
|
|
64
|
+
history.commitTransaction(currentWorkflow);
|
|
65
|
+
}
|
|
66
|
+
},
|
|
57
67
|
cancelTransaction: () => {
|
|
58
68
|
const snapshot = history.cancelTransaction();
|
|
59
69
|
if (snapshot) {
|
package/dist/commands/types.js
CHANGED
|
@@ -24,18 +24,18 @@ export function buildTypeMap(nodeTypes) {
|
|
|
24
24
|
const shortIdCounts = new Map();
|
|
25
25
|
// First pass: register full IDs and count short ID occurrences
|
|
26
26
|
for (const metadata of nodeTypes) {
|
|
27
|
-
map.set(metadata.
|
|
28
|
-
const dotIndex = metadata.
|
|
27
|
+
map.set(metadata.node_type_id, metadata);
|
|
28
|
+
const dotIndex = metadata.node_type_id.indexOf('.');
|
|
29
29
|
if (dotIndex !== -1) {
|
|
30
|
-
const shortId = metadata.
|
|
30
|
+
const shortId = metadata.node_type_id.substring(dotIndex + 1);
|
|
31
31
|
shortIdCounts.set(shortId, (shortIdCounts.get(shortId) ?? 0) + 1);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
// Second pass: register unique short IDs
|
|
35
35
|
for (const metadata of nodeTypes) {
|
|
36
|
-
const dotIndex = metadata.
|
|
36
|
+
const dotIndex = metadata.node_type_id.indexOf('.');
|
|
37
37
|
if (dotIndex !== -1) {
|
|
38
|
-
const shortId = metadata.
|
|
38
|
+
const shortId = metadata.node_type_id.substring(dotIndex + 1);
|
|
39
39
|
if (shortIdCounts.get(shortId) === 1) {
|
|
40
40
|
map.set(shortId, metadata);
|
|
41
41
|
}
|