@flowdrop/flowdrop 2.0.0-beta.10 → 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 +37 -0
- 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/parser.d.ts +12 -0
- package/dist/commands/parser.js +33 -6
- package/dist/components/ConfigForm.svelte +30 -6
- package/dist/components/SettingsPanel.svelte +9 -0
- package/dist/components/WorkflowEditor.svelte +5 -2
- package/dist/components/chat/AIChatPanel.svelte +42 -6
- package/dist/components/chat/CommandPreview.svelte +10 -1
- package/dist/components/form/FormPorts.svelte +21 -3
- package/dist/components/form/FormRangeField.svelte +5 -3
- package/dist/components/form/FormToggle.svelte +27 -2
- package/dist/components/form/FormToggle.svelte.d.ts +5 -0
- package/dist/components/playground/ChatInput.svelte +316 -26
- 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/Playground.svelte +217 -4
- package/dist/config/endpoints.d.ts +48 -1
- package/dist/config/endpoints.js +18 -5
- package/dist/messages/defaults.d.ts +98 -0
- package/dist/messages/defaults.js +58 -1
- 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 +19 -0
- package/dist/playground/index.js +25 -0
- package/dist/playground/runAction.d.ts +48 -0
- package/dist/playground/runAction.js +31 -0
- package/dist/services/pipelineSignalService.d.ts +97 -0
- package/dist/services/pipelineSignalService.js +94 -0
- package/dist/services/playgroundService.d.ts +12 -0
- package/dist/services/playgroundService.js +22 -0
- package/dist/services/workflowLaunchService.d.ts +74 -0
- package/dist/services/workflowLaunchService.js +74 -0
- package/dist/types/chat.d.ts +5 -1
- package/dist/types/settings.d.ts +11 -0
- package/dist/types/settings.js +2 -1
- package/dist/utils/canvasSelection.d.ts +25 -0
- package/dist/utils/canvasSelection.js +37 -0
- package/dist/utils/nodeFormSchema.d.ts +51 -0
- package/dist/utils/nodeFormSchema.js +87 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,41 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.0.0-beta.11] - 2026-07-31
|
|
11
|
+
|
|
12
|
+
Eleventh 2.0 beta, published under the npm `beta` dist-tag (`npm install @flowdrop/flowdrop@beta`). `latest` remains 1.15.0 until 2.0.0 GA. This release gives the playground an **operator control lane**: slash commands typed in the composer act on a session or on a running pipeline without entering the conversation as chat turns, and a run can now be started without fabricating a user message. It also stops the AI assistant re-arranging hand-made layouts unasked, tells it what actually happened to the commands it emitted, and fixes an empty config panel for node types that contribute no schema.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
|
|
16
|
+
- **Slash commands in the playground composer.** A leading `/` routes input to the control plane instead of the pipeline, so composer input stops meaning exactly one thing ("launch a run with this as input"). Ships `/help`, `/run`, `/new`, `/stop`, `/reset`, `/delete`, `/pause`, `/resume` and `/cancel`. Commands never become session messages — control traffic that entered the conversation would be replayed as chat input on the following turn — and their results render as transient composer feedback instead. Opt-in per surface via `enableCommands` (default `false`), because the lane is only safe where the send handler actually dispatches commands: a surface that forwards input straight to a backend would post `/stop` as literal text. `//` escapes a literal leading slash, consuming exactly one so the rule composes, and an unrecognised command reports itself as unknown with distance-1 suggestions rather than being forwarded as a message — a typo must not launch a run with `/stpo` as its input.
|
|
17
|
+
- **Pipeline signals — `pause`, `resume`, `cancel`.** Signals travel _into_ a running pipeline, the opposite direction from interrupts, which a node raises and awaits. Acceptance is not application: backends observe signals cooperatively between steps, so the in-flight step always finishes first and the new `PipelineSignalService` reports `accepted` rather than claiming the run is paused, leaving the status poll to report what actually happened. Refusals ("the run already finished", "not paused", "already pending") come back as typed results rather than thrown errors, since they are outcomes to render. New `signals` endpoint block, with its own group-level `baseUrl`.
|
|
18
|
+
- **Starting a run without posting a message.** New `WorkflowLaunchService` and a `workflows.run` endpoint. Sending a message to start a run fabricates a user turn that is indistinguishable downstream from something the user actually typed; hosts that wire `onRunWorkflow` get a RUN button and a `/run` command that launch instead. `/run --key=value` passes named inputs. A rejected launch distinguishes bad inputs (the caller's to fix) from an invalid workflow (an authoring problem), surfacing the backend's own per-field locators.
|
|
19
|
+
- **Command autocomplete palette.** Typing `/` offers the commands available against the current configuration, reusing the editor console's listbox so both surfaces look and behave alike. Completes command _names_ only — argument values would mean guessing a workflow's declared launch inputs, which live server-side, and offering inputs the backend then rejects.
|
|
20
|
+
- **Optional session reset endpoint.** `playground.resetSession` plus `PlaygroundService.resetSession()`, for returning a stuck session to idle.
|
|
21
|
+
- **`behavior.chatAllowLayoutChanges` (default `true`).** When off, `AIChatPanel` skips layout commands rather than executing them. See the layout fix below; the default preserves existing behaviour.
|
|
22
|
+
- **`hideLabel` on `FormToggle`.** Keeps the state text as the switch's accessible name without rendering it. Defaults to `false`, so every other toggle is unchanged.
|
|
23
|
+
|
|
24
|
+
Commands are available **only where their endpoint is configured** — a host pointed at a backend without session reset gets no `/reset`, rather than a command that 404s. Commands bind to endpoint _keys_, never to paths or to any one backend's vocabulary, so this works against any API implementing the shape.
|
|
25
|
+
|
|
26
|
+
### Fixed
|
|
27
|
+
|
|
28
|
+
- **The assistant re-arranged hand-made layouts unasked (#36).** Auto-beautify re-positions every node, so an unrequested `layout auto` / `layout beautify` destroyed a hand-crafted layout. The root cause was the prompt rather than the executor: the DSL prompt docs told the assistant to auto-arrange after building and to always end with `canvas fitview`. Both mandates are gone, layout commands are marked user-requested-only and must be emitted alone so they can be undone independently. Since the library cannot control how a remote backend renders those prompts, `chatAllowLayoutChanges` adds a local enforcement point.
|
|
29
|
+
- **Triple-quoted blocks swallowed every later command (#35).** The response _extractor_ only closed a `"""` block when a line was exactly `"""`; an assistant that put the closer at the end of a content line left the buffer open, collapsing 7 commands to 2 and consuming the closing fence and trailing prose. Both the extractor and the parser now track delimiter _parity_ (escaped `\"""` excluded), so a closer is valid inline or on its own line.
|
|
30
|
+
- **The assistant was never told what happened to its commands (#35).** `getHistory()` sent only the explanation, and approve/dismiss outcomes lived purely in UI state — which is what drove the duplicate-node loop on "try again". History now carries the raw response plus a per-command outcome report (APPLIED / FAILED / SKIPPED / DISMISSED / NOT APPLIED YET), read at send time so it is always current.
|
|
31
|
+
- **Node-level settings vanished for node types with no config schema (#34).** `ConfigForm` rendered its whole form inside one `{:else if configSchema}` branch, so a node whose type contributes no schema fell through to "No configuration options available" — taking the node-level settings the editor owns (port order and exposure) down with it. A reserved `ports` field is now composed into the node's effective schema, so a schema-less node with ports simply has a schema. No-op when a backend already serves a `ports` property, when there is no node, or when the node has no ports to configure. Nothing is persisted on panel open.
|
|
32
|
+
- **Port drags started a text selection in Safari (#37).** Dragging from a port handle text-selected content outside the canvas. xyflow sets `user-select: none`, but WebKit still _begins_ a selection drag from a mousedown on unselectable content, anchoring at the nearest selectable text; node and pane drags call `preventDefault()`, xyflow's `Handle` does not. A capture-phase `mousedown` on the canvas wrapper now suppresses the gesture for primary-button presses inside `.svelte-flow__handle` and re-applies the focus the default action would have moved.
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- **`CommandExecutionStatus` gains `'skipped'`.** A widened union: consumers switching exhaustively on it will need to handle the new member. A skip is a non-failure, so the rest of a batch still applies and no retry feedback is generated.
|
|
37
|
+
- **Port rows in the ports widget are more compact.** The written "Exposed"/"Hidden" label next to each switch reserved a label column and let long port names widen the row. The switch alone now carries the state; a hidden row's name and type badge are dimmed to stay legible, and both ellipsize with `title` attributes preserving the full text.
|
|
38
|
+
- **`buildEndpointUrl` accepts a base-URL override**, so a group of endpoints can sit under a different prefix from the rest of the config. Additive — existing three-argument calls are unchanged.
|
|
39
|
+
|
|
40
|
+
### Internal
|
|
41
|
+
|
|
42
|
+
- The range field's one-time step inference reads its initial value inside `untrack()`, making the read-once intent explicit and clearing a `state_referenced_locally` warning. No behaviour change.
|
|
43
|
+
- Restored the missing `## [2.0.0-beta.9]` heading below: that release's summary and its "Fixed" section had been absorbed into beta.10's section since the beta.10 release commit.
|
|
44
|
+
|
|
10
45
|
## [2.0.0-beta.10] - 2026-07-22
|
|
11
46
|
|
|
12
47
|
Tenth 2.0 beta, published under the npm `beta` dist-tag (`npm install @flowdrop/flowdrop@beta`). `latest` remains 1.15.0 until 2.0.0 GA. This release reworks how node-config edits are committed and how the undo stack records state, fixing two editor bugs (a Safari save failure and a multi-step undo that reverted more than one edit) and the freeze that the prior on-blur commit was working around. It also re-establishes the editor font on the standalone `ConfigModal` export.
|
|
@@ -22,6 +57,8 @@ Tenth 2.0 beta, published under the npm `beta` dist-tag (`npm install @flowdrop/
|
|
|
22
57
|
|
|
23
58
|
- **History commits now require the final state, and undo/redo finalize any open edit first.** Hardening follow-up to the #39 fix: `commitTransaction(finalWorkflow)` is now required (the pre-change `?? transactionSnapshot` fallback that could silently reintroduce the off-by-one is gone). The service no longer guesses at the live state to auto-commit a dangling transaction inside `undo()`/`redo()`; instead the state owners finalize first (a `HistoryStore` before-navigate hook wired to `finalizeNodeConfig()`, and command-dispatch undo/redo), and if the service still finds an open transaction it abandons it with a warning rather than committing wrong state. New shared `clearTransaction()` internally.
|
|
24
59
|
|
|
60
|
+
## [2.0.0-beta.9] - 2026-07-12
|
|
61
|
+
|
|
25
62
|
Ninth 2.0 beta, published under the npm `beta` dist-tag (`npm install @flowdrop/flowdrop@beta`). `latest` remains 1.15.0 until 2.0.0 GA. A follow-up fix to the relocatable surfaces shipped in beta.8: config surfaces hosted in the modal placement (and the config panel's pop-out) now keep the editor's font instead of falling back to the host page's default.
|
|
26
63
|
|
|
27
64
|
### Fixed
|
|
@@ -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);
|
|
@@ -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
|
}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
Features:
|
|
8
8
|
- Dynamic form generation from JSON Schema using modular form components
|
|
9
|
-
-
|
|
9
|
+
- Node-level settings the editor contributes for every node (port order +
|
|
10
|
+
exposure), rendered even when the node type declares no config schema
|
|
10
11
|
- Extensible architecture for complex schema types (array, object)
|
|
11
12
|
- Admin/Edit support for external configuration links and dynamic schema fetching
|
|
12
13
|
|
|
@@ -47,6 +48,7 @@
|
|
|
47
48
|
import { logger } from '../utils/logger.js';
|
|
48
49
|
import { mergeWithDefaults, cascadeClearAutocompleteDependents } from '../utils/formMerge.js';
|
|
49
50
|
import { applyFetchedSchema } from '../utils/schemaMerge.js';
|
|
51
|
+
import { PORTS_CONFIG_KEY, withPortsControl, withPortsField } from '../utils/nodeFormSchema.js';
|
|
50
52
|
|
|
51
53
|
interface Props {
|
|
52
54
|
/** Optional workflow node (if provided, schema and values are derived from it) */
|
|
@@ -175,10 +177,11 @@
|
|
|
175
177
|
});
|
|
176
178
|
|
|
177
179
|
/**
|
|
178
|
-
*
|
|
180
|
+
* The node type's own configuration schema: direct prop, node metadata, or a
|
|
181
|
+
* dynamically fetched one layered on top.
|
|
179
182
|
* Priority: fetchedDynamicSchema > direct schema prop > node metadata configSchema
|
|
180
183
|
*/
|
|
181
|
-
const
|
|
184
|
+
const typeConfigSchema = $derived.by<ConfigSchema | undefined>(() => {
|
|
182
185
|
const staticSchema = schema ?? (node?.data.metadata?.configSchema as ConfigSchema | undefined);
|
|
183
186
|
// A fetched dynamic schema is layered onto the static one per the endpoint's
|
|
184
187
|
// mergeStrategy/target (default 'replace' → fetched wins wholesale). With no
|
|
@@ -192,6 +195,22 @@
|
|
|
192
195
|
return staticSchema;
|
|
193
196
|
});
|
|
194
197
|
|
|
198
|
+
/**
|
|
199
|
+
* The schema the form actually renders: the node type's, plus the node-level
|
|
200
|
+
* fields the editor contributes for every node (the reserved `ports` widget).
|
|
201
|
+
*
|
|
202
|
+
* The injection is what keeps a node type that declares no `configSchema` from
|
|
203
|
+
* falling through to the empty state and losing its node-level settings with
|
|
204
|
+
* it (#34) — it now has a schema of exactly those settings. Purely a display
|
|
205
|
+
* concern: nothing is written to the node until the user edits a field.
|
|
206
|
+
*/
|
|
207
|
+
const configSchema = $derived(withPortsField(typeConfigSchema, node));
|
|
208
|
+
|
|
209
|
+
/** Whether the ports field above was contributed by us rather than authored. */
|
|
210
|
+
const portsFieldInjected = $derived(
|
|
211
|
+
configSchema !== typeConfigSchema && configSchema?.properties?.[PORTS_CONFIG_KEY] !== undefined
|
|
212
|
+
);
|
|
213
|
+
|
|
195
214
|
/**
|
|
196
215
|
* Get the UI schema for the active configSchema.
|
|
197
216
|
* Priority: direct uiSchema prop > fetched dynamic uiSchema > node metadata.
|
|
@@ -204,9 +223,14 @@
|
|
|
204
223
|
* uiSchema describing the schema it served.
|
|
205
224
|
*/
|
|
206
225
|
const configUISchema = $derived.by<UISchemaElement | undefined>(() => {
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
226
|
+
const authored = uiSchema
|
|
227
|
+
? uiSchema
|
|
228
|
+
: fetchedDynamicSchema && fetchedDynamicUiSchema
|
|
229
|
+
? fetchedDynamicUiSchema
|
|
230
|
+
: (node?.data.metadata?.uiSchema as UISchemaElement | undefined);
|
|
231
|
+
// An authored tree lists only the author's own controls, so the injected
|
|
232
|
+
// ports field needs a control of its own or it would never render.
|
|
233
|
+
return withPortsControl(authored, portsFieldInjected);
|
|
210
234
|
});
|
|
211
235
|
|
|
212
236
|
/**
|
|
@@ -273,6 +273,15 @@
|
|
|
273
273
|
title: 'AI Assistant Auto-retry',
|
|
274
274
|
description: 'Automatically ask the AI to self-correct when commands fail',
|
|
275
275
|
default: true
|
|
276
|
+
},
|
|
277
|
+
chatAllowLayoutChanges: {
|
|
278
|
+
type: 'boolean',
|
|
279
|
+
title: 'AI Assistant Layout Changes',
|
|
280
|
+
description:
|
|
281
|
+
'Let the AI assistant re-arrange node positions (layout auto / layout beautify). ' +
|
|
282
|
+
'Turn off to keep a hand-crafted layout — those commands are then skipped and ' +
|
|
283
|
+
'the rest of the batch still applies.',
|
|
284
|
+
default: true
|
|
276
285
|
}
|
|
277
286
|
}
|
|
278
287
|
},
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
import PortCoordinateTracker from './PortCoordinateTracker.svelte';
|
|
57
57
|
import { logger } from '../utils/logger.js';
|
|
58
58
|
import { validateWorkflowData } from '../utils/validation.js';
|
|
59
|
+
import { suppressPortDragSelection } from '../utils/canvasSelection.js';
|
|
59
60
|
import { createEditorStateMachine } from '../stores/editorStateMachine.svelte.js';
|
|
60
61
|
import CanvasIconButton from './CanvasIconButton.svelte';
|
|
61
62
|
import CommandLineIcon from './icons/CommandLineIcon.svelte';
|
|
@@ -887,8 +888,10 @@
|
|
|
887
888
|
<div class="flowdrop-workflow-editor">
|
|
888
889
|
<!-- Main Editor Area -->
|
|
889
890
|
<div class="flowdrop-workflow-editor__main">
|
|
890
|
-
<!-- Flow Canvas
|
|
891
|
-
|
|
891
|
+
<!-- Flow Canvas.
|
|
892
|
+
Capture-phase mousedown so dragging from a port never turns into a
|
|
893
|
+
WebKit text-selection drag — see suppressPortDragSelection. -->
|
|
894
|
+
<div class="flowdrop-canvas" onmousedowncapture={suppressPortDragSelection}>
|
|
892
895
|
<FlowDropZone ondrop={handleNodeDrop} onfiledrop={handleWorkflowFileDrop}>
|
|
893
896
|
{#key svelteFlowKey}
|
|
894
897
|
<SvelteFlow
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
import { getInstance } from '../../stores/getInstance.svelte.js';
|
|
8
8
|
import { getBehaviorSettings } from '../../stores/settingsStore.svelte.js';
|
|
9
9
|
import { extractCommands } from '../../chat/responseParser.js';
|
|
10
|
-
import {
|
|
10
|
+
import { buildApiHistory } from '../../chat/historyBuilder.js';
|
|
11
|
+
import { isMutatingCommand, isLayoutCommand } from '../../chat/commandClassifier.js';
|
|
11
12
|
import { parseCommand } from '../../commands/parser.js';
|
|
12
13
|
import { executeCommand } from '../../commands/index.js';
|
|
13
14
|
import { createStoreCommandContext } from '../../commands/storeIntegration.svelte.js';
|
|
@@ -29,12 +30,20 @@
|
|
|
29
30
|
interface DisplayMessage {
|
|
30
31
|
role: 'user' | 'assistant';
|
|
31
32
|
content: string;
|
|
33
|
+
/**
|
|
34
|
+
* The unmodified LLM response, kept when `content` is the explanation-only
|
|
35
|
+
* display text. Sent as history so the assistant sees the DSL it emitted
|
|
36
|
+
* (issue #35).
|
|
37
|
+
*/
|
|
38
|
+
rawContent?: string;
|
|
32
39
|
/** Set on auto-retry messages — renders as a muted notice, not a user bubble */
|
|
33
40
|
retryAttempt?: number;
|
|
34
41
|
/** Mutating commands awaiting approval */
|
|
35
42
|
commandPreview?: CommandPreviewItem[];
|
|
36
43
|
/** Results from auto-executed read-only commands */
|
|
37
44
|
readOnlyResults?: string[];
|
|
45
|
+
/** Set when the user dismissed this message's command preview */
|
|
46
|
+
commandsDismissed?: boolean;
|
|
38
47
|
}
|
|
39
48
|
|
|
40
49
|
interface Props {
|
|
@@ -93,9 +102,14 @@
|
|
|
93
102
|
// Helpers
|
|
94
103
|
// =========================================================================
|
|
95
104
|
|
|
96
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* Build conversation history from display messages for API requests.
|
|
107
|
+
*
|
|
108
|
+
* Read at send time, so each assistant entry reports the *current* status of
|
|
109
|
+
* the commands it emitted — applied, dismissed, failed or still pending.
|
|
110
|
+
*/
|
|
97
111
|
function getHistory(): ChatHistoryMessage[] {
|
|
98
|
-
return displayMessages
|
|
112
|
+
return buildApiHistory(displayMessages);
|
|
99
113
|
}
|
|
100
114
|
|
|
101
115
|
function getWorkflowState(): unknown {
|
|
@@ -169,7 +183,8 @@
|
|
|
169
183
|
|
|
170
184
|
const msg: DisplayMessage = {
|
|
171
185
|
role: 'assistant',
|
|
172
|
-
content: explanation || responseContent
|
|
186
|
+
content: explanation || responseContent,
|
|
187
|
+
rawContent: responseContent
|
|
173
188
|
};
|
|
174
189
|
|
|
175
190
|
if (readOnlyResults.length > 0) {
|
|
@@ -222,6 +237,12 @@
|
|
|
222
237
|
command: import('../../commands/types.js').Command;
|
|
223
238
|
}[] = [];
|
|
224
239
|
|
|
240
|
+
// Layout commands rewrite every node's position, so they wipe a hand-crafted
|
|
241
|
+
// arrangement. Honour the user's opt-out by skipping them instead of running
|
|
242
|
+
// them — a skip is not a failure, so the rest of the batch still applies and
|
|
243
|
+
// no retry feedback is sent (issue #36).
|
|
244
|
+
const allowLayoutChanges = getBehaviorSettings().chatAllowLayoutChanges;
|
|
245
|
+
|
|
225
246
|
for (const item of pendingItems) {
|
|
226
247
|
const parsed = parseCommand(item.raw);
|
|
227
248
|
if (!parsed.ok) {
|
|
@@ -231,11 +252,22 @@
|
|
|
231
252
|
parseErrors.push({ raw: item.raw, error: parsed.error });
|
|
232
253
|
continue;
|
|
233
254
|
}
|
|
255
|
+
if (!allowLayoutChanges && isLayoutCommand(parsed.command.type)) {
|
|
256
|
+
item.status = 'skipped';
|
|
257
|
+
item.result = t.commandPreview.layoutSkipped;
|
|
258
|
+
continue;
|
|
259
|
+
}
|
|
234
260
|
parsedCommands.push({ item, command: parsed.command });
|
|
235
261
|
}
|
|
236
262
|
|
|
237
263
|
const totalCount = parsedCommands.length;
|
|
238
264
|
|
|
265
|
+
// Everything was intentionally skipped (layout commands with layout changes
|
|
266
|
+
// off) — nothing failed, so there is nothing to report or retry.
|
|
267
|
+
if (totalCount === 0 && parseErrors.length === 0) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
|
|
239
271
|
// Nothing parseable to run — feed the parse errors straight back so the
|
|
240
272
|
// assistant can resend a corrected batch.
|
|
241
273
|
if (totalCount === 0) {
|
|
@@ -338,8 +370,12 @@
|
|
|
338
370
|
}
|
|
339
371
|
|
|
340
372
|
/** Dismiss a command preview without executing — CommandPreview shows its own cancelled state */
|
|
341
|
-
function handleCancelCommands(
|
|
342
|
-
//
|
|
373
|
+
function handleCancelCommands(messageIndex: number) {
|
|
374
|
+
// CommandPreview owns the "Dismissed" *display* via its resolvedAction state;
|
|
375
|
+
// the flag here is what tells the assistant, on the next turn, that these
|
|
376
|
+
// commands were rejected rather than still waiting (issue #35).
|
|
377
|
+
const msg = displayMessages[messageIndex];
|
|
378
|
+
if (msg) msg.commandsDismissed = true;
|
|
343
379
|
}
|
|
344
380
|
|
|
345
381
|
/** Append an error message to conversation history so the LLM can self-correct */
|
|
@@ -44,10 +44,12 @@
|
|
|
44
44
|
<Icon icon="mdi:check-circle" />
|
|
45
45
|
{:else if command.status === 'error'}
|
|
46
46
|
<Icon icon="mdi:alert-circle" />
|
|
47
|
+
{:else if command.status === 'skipped'}
|
|
48
|
+
<Icon icon="mdi:debug-step-over" />
|
|
47
49
|
{/if}
|
|
48
50
|
</span>
|
|
49
51
|
<pre class="command-preview__command">{command.raw}</pre>
|
|
50
|
-
{#if command.status === 'error' && command.result}
|
|
52
|
+
{#if (command.status === 'error' || command.status === 'skipped') && command.result}
|
|
51
53
|
<span class="command-preview__error">{command.result}</span>
|
|
52
54
|
{/if}
|
|
53
55
|
</div>
|
|
@@ -163,6 +165,13 @@
|
|
|
163
165
|
color: var(--fd-error);
|
|
164
166
|
}
|
|
165
167
|
|
|
168
|
+
/* Skipped isn't a failure — mute it instead of colouring it like an error. */
|
|
169
|
+
.command-preview__item--skipped .command-preview__status,
|
|
170
|
+
.command-preview__item--skipped .command-preview__command,
|
|
171
|
+
.command-preview__item--skipped .command-preview__error {
|
|
172
|
+
color: var(--fd-muted-foreground);
|
|
173
|
+
}
|
|
174
|
+
|
|
166
175
|
.command-preview__error {
|
|
167
176
|
display: block;
|
|
168
177
|
font-size: var(--fd-text-xs);
|