@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.
Files changed (270) hide show
  1. package/CHANGELOG.md +210 -0
  2. package/MIGRATION-2.0.md +173 -3
  3. package/README.md +5 -5
  4. package/dist/adapters/WorkflowAdapter.js +4 -5
  5. package/dist/adapters/agentspec/AgentSpecAdapter.js +3 -3
  6. package/dist/adapters/agentspec/defaultNodeTypes.js +9 -9
  7. package/dist/api/enhanced-client.js +6 -11
  8. package/dist/chat/batchFeedback.js +1 -1
  9. package/dist/chat/commandClassifier.d.ts +11 -0
  10. package/dist/chat/commandClassifier.js +20 -0
  11. package/dist/chat/historyBuilder.d.ts +39 -0
  12. package/dist/chat/historyBuilder.js +82 -0
  13. package/dist/chat/index.d.ts +2 -1
  14. package/dist/chat/index.js +2 -1
  15. package/dist/chat/responseParser.js +16 -12
  16. package/dist/commands/executor.js +51 -26
  17. package/dist/commands/parser.d.ts +12 -0
  18. package/dist/commands/parser.js +33 -6
  19. package/dist/commands/storeIntegration.svelte.js +11 -1
  20. package/dist/commands/types.js +5 -5
  21. package/dist/components/App.svelte +547 -386
  22. package/dist/components/App.svelte.d.ts +16 -8
  23. package/dist/components/Button.stories.svelte +65 -0
  24. package/dist/components/Button.stories.svelte.d.ts +19 -0
  25. package/dist/components/Button.svelte +62 -0
  26. package/dist/components/Button.svelte.d.ts +24 -0
  27. package/dist/components/CanvasIconButton.svelte +76 -0
  28. package/dist/components/CanvasIconButton.svelte.d.ts +18 -0
  29. package/dist/components/ConfigForm.svelte +194 -565
  30. package/dist/components/ConfigForm.svelte.d.ts +24 -7
  31. package/dist/components/ConfigModal.svelte +9 -1
  32. package/dist/components/ConfigPanel.svelte +234 -15
  33. package/dist/components/ConfigPanel.svelte.d.ts +6 -0
  34. package/dist/components/EditorStatusBar.stories.svelte +44 -0
  35. package/dist/components/EditorStatusBar.stories.svelte.d.ts +27 -0
  36. package/dist/components/EditorStatusBar.svelte +99 -0
  37. package/dist/components/EditorStatusBar.svelte.d.ts +15 -0
  38. package/dist/components/IconButton.svelte +80 -0
  39. package/dist/components/IconButton.svelte.d.ts +30 -0
  40. package/dist/components/Input.svelte +74 -0
  41. package/dist/components/Input.svelte.d.ts +17 -0
  42. package/dist/components/LogoWordmark.svelte +113 -0
  43. package/dist/components/LogoWordmark.svelte.d.ts +26 -0
  44. package/dist/components/Navbar.svelte +17 -63
  45. package/dist/components/Navbar.svelte.d.ts +3 -0
  46. package/dist/components/NodeSidebar.svelte +21 -126
  47. package/dist/components/NodeSwapPicker.svelte +12 -30
  48. package/dist/components/PipelineStatus.svelte +6 -1
  49. package/dist/components/PipelineStatus.svelte.d.ts +3 -0
  50. package/dist/components/PortMappingRow.svelte +0 -2
  51. package/dist/components/SchemaForm.svelte +4 -14
  52. package/dist/components/Select.svelte +53 -0
  53. package/dist/components/Select.svelte.d.ts +15 -0
  54. package/dist/components/SettingsModal.svelte +0 -5
  55. package/dist/components/SettingsPanel.svelte +33 -6
  56. package/dist/components/Textarea.svelte +39 -0
  57. package/dist/components/Textarea.svelte.d.ts +12 -0
  58. package/dist/components/ThemeToggle.svelte +15 -94
  59. package/dist/components/UniversalNode.svelte +36 -4
  60. package/dist/components/UniversalNode.svelte.d.ts +1 -1
  61. package/dist/components/WorkflowEditor.svelte +71 -54
  62. package/dist/components/WorkflowEditor.svelte.d.ts +21 -0
  63. package/dist/components/chat/AIChatPanel.svelte +49 -8
  64. package/dist/components/chat/CommandPreview.svelte +10 -1
  65. package/dist/components/console/ConsoleAutocomplete.svelte +1 -1
  66. package/dist/components/console/ConsoleInput.svelte +3 -3
  67. package/dist/components/console/ConsoleOutput.svelte +2 -2
  68. package/dist/components/form/FormArray.svelte +37 -173
  69. package/dist/components/form/FormAutocomplete.svelte +18 -15
  70. package/dist/components/form/FormCheckboxGroup.svelte +1 -5
  71. package/dist/components/form/FormCodeEditor.svelte +9 -7
  72. package/dist/components/form/FormField.svelte +18 -42
  73. package/dist/components/form/FormFieldLight.svelte +52 -48
  74. package/dist/components/form/FormFieldLight.svelte.d.ts +12 -0
  75. package/dist/components/form/FormFieldset.svelte +45 -11
  76. package/dist/components/form/FormMarkdownEditor.svelte +8 -5
  77. package/dist/components/form/FormNumberField.svelte +4 -36
  78. package/dist/components/form/FormPorts.svelte +280 -0
  79. package/dist/components/form/FormPorts.svelte.d.ts +13 -0
  80. package/dist/components/form/FormRangeField.svelte +63 -30
  81. package/dist/components/form/FormSelect.svelte +13 -75
  82. package/dist/components/form/FormTemplateEditor.svelte +6 -4
  83. package/dist/components/form/FormTextField.svelte +3 -35
  84. package/dist/components/form/FormTextarea.svelte +4 -39
  85. package/dist/components/form/FormToggle.svelte +27 -6
  86. package/dist/components/form/FormToggle.svelte.d.ts +5 -0
  87. package/dist/components/form/FormUISchemaRenderer.svelte +3 -1
  88. package/dist/components/form/resolveFieldType.d.ts +24 -0
  89. package/dist/components/form/resolveFieldType.js +55 -0
  90. package/dist/components/icons/CloseIcon.svelte +6 -0
  91. package/dist/components/icons/CloseIcon.svelte.d.ts +26 -0
  92. package/dist/components/icons/CommandLineIcon.svelte +15 -0
  93. package/dist/components/icons/CommandLineIcon.svelte.d.ts +26 -0
  94. package/dist/components/icons/MenuIcon.svelte +4 -0
  95. package/dist/components/icons/MenuIcon.svelte.d.ts +26 -0
  96. package/dist/components/icons/MenuOpenIcon.svelte +6 -0
  97. package/dist/components/icons/MenuOpenIcon.svelte.d.ts +26 -0
  98. package/dist/components/interrupt/ChoicePrompt.svelte +0 -10
  99. package/dist/components/interrupt/ConfirmationPrompt.svelte +0 -5
  100. package/dist/components/interrupt/InterruptBubble.svelte +11 -12
  101. package/dist/components/interrupt/ReviewPrompt.svelte +0 -20
  102. package/dist/components/interrupt/TextInputPrompt.svelte +0 -6
  103. package/dist/components/layouts/MainLayout.svelte +4 -5
  104. package/dist/components/nodes/AtomNode.svelte +62 -76
  105. package/dist/components/nodes/AtomNode.svelte.d.ts +1 -1
  106. package/dist/components/nodes/GatewayNode.svelte +117 -164
  107. package/dist/components/nodes/GatewayNode.svelte.d.ts +1 -1
  108. package/dist/components/nodes/IdeaNode.svelte +72 -98
  109. package/dist/components/nodes/IdeaNode.svelte.d.ts +8 -4
  110. package/dist/components/nodes/NodeConfigButton.svelte +86 -0
  111. package/dist/components/nodes/NodeConfigButton.svelte.d.ts +15 -0
  112. package/dist/components/nodes/NotesNode.svelte +76 -85
  113. package/dist/components/nodes/NotesNode.svelte.d.ts +8 -4
  114. package/dist/components/nodes/SimpleNode.svelte +59 -133
  115. package/dist/components/nodes/SimpleNode.svelte.d.ts +4 -4
  116. package/dist/components/nodes/SquareNode.svelte +110 -164
  117. package/dist/components/nodes/SquareNode.svelte.d.ts +4 -4
  118. package/dist/components/nodes/TerminalNode.svelte +62 -124
  119. package/dist/components/nodes/TerminalNode.svelte.d.ts +4 -4
  120. package/dist/components/nodes/ToolNode.svelte +92 -103
  121. package/dist/components/nodes/ToolNode.svelte.d.ts +6 -6
  122. package/dist/components/nodes/WorkflowNode.svelte +132 -191
  123. package/dist/components/nodes/WorkflowNode.svelte.d.ts +1 -1
  124. package/dist/components/playground/ChatInput.svelte +316 -27
  125. package/dist/components/playground/ChatInput.svelte.d.ts +31 -1
  126. package/dist/components/playground/ControlPanel.svelte +22 -0
  127. package/dist/components/playground/ControlPanel.svelte.d.ts +13 -0
  128. package/dist/components/playground/InputCollector.svelte +11 -48
  129. package/dist/components/playground/PipelineKanbanView.svelte +6 -4
  130. package/dist/components/playground/PipelineKanbanView.svelte.d.ts +2 -0
  131. package/dist/components/playground/PipelinePanel.svelte +20 -3
  132. package/dist/components/playground/PipelinePanel.svelte.d.ts +2 -0
  133. package/dist/components/playground/PipelineTableView.svelte +6 -4
  134. package/dist/components/playground/PipelineTableView.svelte.d.ts +2 -0
  135. package/dist/components/playground/Playground.svelte +292 -28
  136. package/dist/components/playground/Playground.svelte.d.ts +3 -0
  137. package/dist/components/playground/PlaygroundApp.svelte +6 -1
  138. package/dist/components/playground/PlaygroundApp.svelte.d.ts +3 -0
  139. package/dist/components/playground/PlaygroundModal.svelte +5 -0
  140. package/dist/components/playground/PlaygroundModal.svelte.d.ts +3 -0
  141. package/dist/components/playground/PlaygroundStudio.svelte +7 -6
  142. package/dist/components/playground/PlaygroundStudio.svelte.d.ts +3 -0
  143. package/dist/components/playground/pipelineViewUtils.svelte.d.ts +2 -1
  144. package/dist/components/playground/pipelineViewUtils.svelte.js +2 -2
  145. package/dist/components/surfaces/SurfaceOverlay.svelte +153 -0
  146. package/dist/components/surfaces/SurfaceOverlay.svelte.d.ts +14 -0
  147. package/dist/components/surfaces/TabbedSurface.svelte +133 -0
  148. package/dist/components/surfaces/TabbedSurface.svelte.d.ts +27 -0
  149. package/dist/config/endpoints.d.ts +71 -1
  150. package/dist/config/endpoints.js +46 -5
  151. package/dist/core/index.d.ts +2 -3
  152. package/dist/core/index.js +2 -6
  153. package/dist/display/index.d.ts +6 -1
  154. package/dist/display/index.js +9 -1
  155. package/dist/editor/index.d.ts +1 -1
  156. package/dist/editor/index.js +1 -1
  157. package/dist/form/full.d.ts +2 -1
  158. package/dist/form/full.js +4 -1
  159. package/dist/form/index.d.ts +0 -1
  160. package/dist/form/index.js +3 -2
  161. package/dist/helpers/workflowEditorHelper.d.ts +4 -2
  162. package/dist/helpers/workflowEditorHelper.js +8 -8
  163. package/dist/messages/defaults.d.ts +98 -0
  164. package/dist/messages/defaults.js +58 -1
  165. package/dist/messages/index.d.ts +1 -1
  166. package/dist/messages/index.js +1 -1
  167. package/dist/openapi/v1/openapi.yaml +35 -23
  168. package/dist/playground/commands/args.d.ts +32 -0
  169. package/dist/playground/commands/args.js +50 -0
  170. package/dist/playground/commands/dispatch.d.ts +143 -0
  171. package/dist/playground/commands/dispatch.js +162 -0
  172. package/dist/playground/commands/index.d.ts +14 -0
  173. package/dist/playground/commands/index.js +10 -0
  174. package/dist/playground/commands/parser.d.ts +38 -0
  175. package/dist/playground/commands/parser.js +163 -0
  176. package/dist/playground/commands/registry.d.ts +42 -0
  177. package/dist/playground/commands/registry.js +122 -0
  178. package/dist/playground/commands/suggest.d.ts +37 -0
  179. package/dist/playground/commands/suggest.js +46 -0
  180. package/dist/playground/commands/types.d.ts +111 -0
  181. package/dist/playground/commands/types.js +15 -0
  182. package/dist/playground/index.d.ts +21 -2
  183. package/dist/playground/index.js +27 -2
  184. package/dist/playground/mount.d.ts +19 -5
  185. package/dist/playground/mount.js +16 -8
  186. package/dist/playground/runAction.d.ts +48 -0
  187. package/dist/playground/runAction.js +31 -0
  188. package/dist/registry/builtinNodeTypes.d.ts +53 -0
  189. package/dist/registry/builtinNodeTypes.js +67 -0
  190. package/dist/registry/builtinNodes.d.ts +2 -39
  191. package/dist/registry/builtinNodes.js +6 -53
  192. package/dist/registry/nodeComponentRegistry.d.ts +2 -1
  193. package/dist/schemas/v1/workflow.schema.json +16 -14
  194. package/dist/services/agentSpecExecutionService.d.ts +0 -2
  195. package/dist/services/agentSpecExecutionService.js +0 -2
  196. package/dist/services/apiVariableService.js +12 -26
  197. package/dist/services/categoriesApi.js +3 -6
  198. package/dist/services/chatService.d.ts +4 -3
  199. package/dist/services/chatService.js +13 -18
  200. package/dist/services/dynamicSchemaService.d.ts +31 -4
  201. package/dist/services/dynamicSchemaService.js +62 -33
  202. package/dist/services/historyService.d.ts +30 -8
  203. package/dist/services/historyService.js +51 -15
  204. package/dist/services/interruptService.d.ts +7 -6
  205. package/dist/services/interruptService.js +19 -21
  206. package/dist/services/pipelineSignalService.d.ts +97 -0
  207. package/dist/services/pipelineSignalService.js +94 -0
  208. package/dist/services/playgroundService.d.ts +21 -8
  209. package/dist/services/playgroundService.js +45 -25
  210. package/dist/services/portConfigApi.js +3 -6
  211. package/dist/services/settingsService.d.ts +9 -4
  212. package/dist/services/settingsService.js +23 -12
  213. package/dist/services/workflowLaunchService.d.ts +74 -0
  214. package/dist/services/workflowLaunchService.js +74 -0
  215. package/dist/skins/drafter.d.ts +30 -0
  216. package/dist/skins/drafter.js +198 -0
  217. package/dist/skins/index.d.ts +2 -1
  218. package/dist/skins/index.js +4 -2
  219. package/dist/stores/apiContext.d.ts +11 -0
  220. package/dist/stores/apiContext.js +15 -0
  221. package/dist/stores/categoriesStore.svelte.js +0 -1
  222. package/dist/stores/historyStore.svelte.d.ts +17 -3
  223. package/dist/stores/historyStore.svelte.js +30 -3
  224. package/dist/stores/instanceContainer.svelte.js +5 -0
  225. package/dist/stores/playgroundStore.svelte.js +1 -3
  226. package/dist/stores/settingsStore.svelte.d.ts +13 -0
  227. package/dist/stores/settingsStore.svelte.js +32 -0
  228. package/dist/stores/workflowStore.svelte.d.ts +42 -5
  229. package/dist/stores/workflowStore.svelte.js +109 -32
  230. package/dist/styles/base.css +285 -14
  231. package/dist/styles/tokens.css +60 -2
  232. package/dist/svelte-app.d.ts +18 -1
  233. package/dist/svelte-app.js +75 -110
  234. package/dist/themes/drafter.d.ts +2 -0
  235. package/dist/themes/drafter.js +15 -0
  236. package/dist/themes/index.d.ts +2 -1
  237. package/dist/themes/index.js +8 -2
  238. package/dist/types/auth.d.ts +9 -51
  239. package/dist/types/auth.js +4 -54
  240. package/dist/types/chat.d.ts +5 -1
  241. package/dist/types/events.d.ts +18 -0
  242. package/dist/types/events.js +2 -1
  243. package/dist/types/index.d.ts +84 -29
  244. package/dist/types/index.js +0 -1
  245. package/dist/types/settings.d.ts +28 -1
  246. package/dist/types/settings.js +6 -3
  247. package/dist/types/skin.d.ts +1 -1
  248. package/dist/types/theme.d.ts +16 -2
  249. package/dist/types/uischema.d.ts +5 -0
  250. package/dist/utils/canvasSelection.d.ts +25 -0
  251. package/dist/utils/canvasSelection.js +37 -0
  252. package/dist/utils/colors.d.ts +27 -0
  253. package/dist/utils/colors.js +23 -0
  254. package/dist/utils/connections.js +20 -56
  255. package/dist/utils/edgeStyling.js +9 -5
  256. package/dist/utils/fetchWithAuth.d.ts +36 -15
  257. package/dist/utils/fetchWithAuth.js +53 -23
  258. package/dist/utils/nodeFormSchema.d.ts +51 -0
  259. package/dist/utils/nodeFormSchema.js +87 -0
  260. package/dist/utils/nodeIds.d.ts +1 -1
  261. package/dist/utils/nodeIds.js +1 -1
  262. package/dist/utils/nodeSwap.js +3 -6
  263. package/dist/utils/nodeTypes.js +1 -1
  264. package/dist/utils/portUtils.d.ts +47 -11
  265. package/dist/utils/portUtils.js +67 -14
  266. package/dist/utils/portal.d.ts +18 -0
  267. package/dist/utils/portal.js +34 -0
  268. package/dist/utils/schemaMerge.d.ts +25 -0
  269. package/dist/utils/schemaMerge.js +61 -0
  270. package/package.json +2 -1
@@ -10,10 +10,18 @@
10
10
 
11
11
  <script lang="ts">
12
12
  import Icon from '@iconify/svelte';
13
- import { tick, untrack } from 'svelte';
13
+ import { tick } from 'svelte';
14
14
  import { hasEnableRunFlag } from '../../types/playground.js';
15
15
  import { getInstance } from '../../stores/getInstance.svelte.js';
16
16
  import { m } from '../../messages/index.js';
17
+ import {
18
+ isCommandInput,
19
+ suggestCommands,
20
+ type CommandOutcome,
21
+ type CommandSuggestion
22
+ } from '../../playground/commands/index.js';
23
+ import { resolveRunAction } from '../../playground/runAction.js';
24
+ import ConsoleAutocomplete from '../console/ConsoleAutocomplete.svelte';
17
25
 
18
26
  const fd = getInstance();
19
27
 
@@ -23,10 +31,39 @@
23
31
  showTextarea?: boolean;
24
32
  /** Show the Run button when textarea is hidden (default: true) */
25
33
  showRunButton?: boolean;
26
- /** Message sent when Run is clicked with textarea hidden */
34
+ /**
35
+ * Message sent when Run is clicked, for hosts that deliberately want the
36
+ * run to begin with a specific chat turn.
37
+ *
38
+ * Setting this opts *out* of {@link onRunWorkflow}: an explicitly
39
+ * configured message is a host's intentional choice and is honoured.
40
+ * Leaving it unset is what lets Run launch without fabricating a turn.
41
+ */
27
42
  predefinedMessage?: string;
28
43
  onSendMessage?: (content: string) => void;
29
44
  onStopExecution?: () => void;
45
+ /**
46
+ * Start a run without posting a chat message.
47
+ *
48
+ * Preferred over `onSendMessage` for the Run button. Sending a message to
49
+ * start a run fabricates a user turn that enters the conversation and is
50
+ * replayed as input on the following turn — indistinguishable downstream
51
+ * from something the user actually typed. Hosts that provide this get a Run
52
+ * button that launches instead.
53
+ */
54
+ onRunWorkflow?: () => void;
55
+ /**
56
+ * Enable the slash-command lane (default: false).
57
+ *
58
+ * Opt-in because the lane is only safe where the `onSendMessage` handler
59
+ * actually dispatches commands. A surface that forwards input straight to a
60
+ * backend (ChatPanel) would post `/stop` as literal text — faking a command
61
+ * that nothing implements.
62
+ */
63
+ enableCommands?: boolean;
64
+ /** Transient result of the last slash command. Never a session message. */
65
+ commandFeedback?: CommandOutcome | null;
66
+ onDismissCommandFeedback?: () => void;
30
67
  }
31
68
 
32
69
  let {
@@ -35,13 +72,19 @@
35
72
  showRunButton = true,
36
73
  predefinedMessage,
37
74
  onSendMessage,
38
- onStopExecution
75
+ onStopExecution,
76
+ onRunWorkflow,
77
+ enableCommands = false,
78
+ commandFeedback = null,
79
+ onDismissCommandFeedback
39
80
  }: Props = $props();
40
81
 
41
82
  const actions = $derived(m().playground.actions);
42
83
  const chat = $derived(m().playground.chat);
43
84
  const states = $derived(m().playground.states);
44
85
 
86
+ const commandMessages = $derived(m().playground.commands);
87
+
45
88
  const resolvedPlaceholder = $derived(placeholder ?? chat.placeholder);
46
89
  const resolvedPredefinedMessage = $derived(predefinedMessage ?? chat.predefinedRun);
47
90
 
@@ -57,29 +100,104 @@
57
100
  let inputValue = $state('');
58
101
  let inputField: HTMLTextAreaElement | undefined = $state();
59
102
 
60
- // Count of enableRun messages seen so far — plain let, not $state.
61
- // Written with untrack to make the bookkeeping intent explicit.
103
+ /**
104
+ * Whether the current input is control traffic rather than pipeline data.
105
+ *
106
+ * Used only to relax the send gate (see {@link canSubmit}). Note that this
107
+ * does *not* make commands typable during a run: the textarea is disabled
108
+ * while `isExecuting`, and stopping a run is the Stop button's job.
109
+ */
110
+ const inputIsCommand = $derived(enableCommands && isCommandInput(inputValue));
111
+
112
+ // Unique per instance so two playgrounds on one page don't collide, and
113
+ // shared with the listbox so aria-controls/activedescendant stay consistent.
114
+ const uid = $props.id();
115
+ const listboxId = `${uid}-command-palette-listbox`;
116
+
117
+ /**
118
+ * Command palette state.
119
+ *
120
+ * `dismissed` is separate from "no suggestions": pressing Escape must keep the
121
+ * palette shut while the user keeps typing the same command, and only a fresh
122
+ * edit that changes the completion set should bring it back.
123
+ */
124
+ let paletteDismissed = $state(false);
125
+
126
+ const paletteSuggestions = $derived(
127
+ enableCommands ? suggestCommands(inputValue, fd.api.config, commandMessages.catalog) : []
128
+ );
129
+ const paletteVisible = $derived(!paletteDismissed && paletteSuggestions.length > 0);
130
+
131
+ /**
132
+ * Where the user has moved the highlight, and where it actually lands.
133
+ *
134
+ * Clamped on read rather than corrected in an effect: effects run *after* the
135
+ * DOM updates, so a list that narrows under typing would render one frame
136
+ * with `aria-activedescendant` pointing at an option that no longer exists.
137
+ */
138
+ let paletteCursor = $state(0);
139
+ const paletteIndex = $derived(
140
+ paletteSuggestions.length === 0 ? 0 : Math.min(paletteCursor, paletteSuggestions.length - 1)
141
+ );
142
+
143
+ /**
144
+ * Match the textarea's height to its content, capped.
145
+ *
146
+ * Called from every path that changes `inputValue`, not just typing — the
147
+ * height is a function of the content, so anything that sets the content owes
148
+ * it an update.
149
+ */
150
+ function resizeTextarea(): void {
151
+ if (!inputField) return;
152
+ inputField.style.height = 'auto';
153
+ inputField.style.height = `${Math.min(inputField.scrollHeight, 120)}px`;
154
+ }
155
+
156
+ function acceptSuggestion(suggestion: CommandSuggestion): void {
157
+ inputValue = suggestion.value;
158
+ paletteDismissed = true;
159
+ paletteCursor = 0;
160
+ tick().then(() => {
161
+ resizeTextarea();
162
+ inputField?.focus({ preventScroll: true });
163
+ });
164
+ }
165
+
166
+ /**
167
+ * Commands bypass the send gate; plain text still respects it.
168
+ *
169
+ * This matters for states that are not "executing" but still refuse messages
170
+ * — `awaiting_input` most of all, where the textarea is live but
171
+ * `canSendMessage` is false, so without this a command could be typed and
172
+ * never submitted. Execution itself needs no special case: the button chain
173
+ * already swaps Send for Stop while a run is in flight.
174
+ */
175
+ const canSubmit = $derived(
176
+ inputValue.trim().length > 0 && (inputIsCommand || fd.playground.canSendMessage)
177
+ );
178
+
179
+ // Count of enableRun messages seen so far. A plain `let`, not `$state`: it is
180
+ // bookkeeping for the effects below, never read during render. Because it is
181
+ // not reactive, writing to it inside an effect creates no dependency and
182
+ // needs no `untrack`.
62
183
  let seenEnableRunCount = 0;
63
184
 
64
185
  $effect(() => {
65
- const count = fd.playground.messages.filter((m) => hasEnableRunFlag(m.metadata)).length;
186
+ const count = fd.playground.messages.filter((msg) => hasEnableRunFlag(msg.metadata)).length;
66
187
  if (count > seenEnableRunCount) {
67
- untrack(() => {
68
- seenEnableRunCount = count;
69
- });
188
+ seenEnableRunCount = count;
70
189
  runEnabled = true;
71
190
  }
72
191
  });
73
192
 
74
193
  $effect(() => {
75
194
  if (fd.playground.currentSession?.id) {
76
- untrack(() => {
77
- seenEnableRunCount = 0;
78
- });
195
+ seenEnableRunCount = 0;
79
196
  runEnabled = true;
80
197
  }
81
198
  });
82
199
 
200
+ // Same rationale as `seenEnableRunCount`: plain `let`, no `untrack` needed.
83
201
  let wasExecuting = false;
84
202
 
85
203
  /** Auto-focus input when execution completes */
@@ -88,28 +206,66 @@
88
206
  if (wasExecuting && !nowExecuting && inputField) {
89
207
  tick().then(() => inputField?.focus({ preventScroll: true }));
90
208
  }
91
- untrack(() => {
92
- wasExecuting = nowExecuting;
93
- });
209
+ wasExecuting = nowExecuting;
94
210
  });
95
211
 
96
212
  function handleSend(): void {
97
213
  const trimmedValue = inputValue.trim();
98
- if (!trimmedValue || !fd.playground.canSendMessage) return;
214
+ if (!canSubmit) return;
99
215
 
216
+ onDismissCommandFeedback?.();
100
217
  onSendMessage?.(trimmedValue);
101
218
  inputValue = '';
102
219
 
103
- if (inputField) {
104
- inputField.style.height = 'auto';
105
- }
106
-
107
220
  tick().then(() => {
221
+ resizeTextarea();
108
222
  inputField?.focus({ preventScroll: true });
109
223
  });
110
224
  }
111
225
 
112
226
  function handleKeydown(event: KeyboardEvent): void {
227
+ // The palette owns navigation keys while it is open, mirroring the editor
228
+ // console so the two surfaces behave identically.
229
+ if (paletteVisible) {
230
+ if (event.key === 'ArrowUp') {
231
+ event.preventDefault();
232
+ paletteCursor = paletteIndex > 0 ? paletteIndex - 1 : paletteSuggestions.length - 1;
233
+ return;
234
+ }
235
+ if (event.key === 'ArrowDown') {
236
+ event.preventDefault();
237
+ paletteCursor = paletteIndex < paletteSuggestions.length - 1 ? paletteIndex + 1 : 0;
238
+ return;
239
+ }
240
+ if (event.key === 'Tab') {
241
+ event.preventDefault();
242
+ acceptSuggestion(paletteSuggestions[paletteIndex]);
243
+ return;
244
+ }
245
+ if (event.key === 'Escape') {
246
+ event.preventDefault();
247
+ // Escape must not reach an ancestor here: PlaygroundModal closes on
248
+ // Escape, so without this, dismissing the palette would also close the
249
+ // whole playground.
250
+ event.stopPropagation();
251
+ paletteDismissed = true;
252
+ return;
253
+ }
254
+ if (event.key === 'Enter' && !event.shiftKey) {
255
+ event.preventDefault();
256
+ const suggestion = paletteSuggestions[paletteIndex];
257
+ // Compare trimmed: a completion for an argument-taking command differs
258
+ // from a fully typed name only by its trailing space, and `/run` +
259
+ // Enter should start a run rather than silently insert a space.
260
+ if (suggestion.value.trim() !== inputValue.trim()) {
261
+ acceptSuggestion(suggestion);
262
+ return;
263
+ }
264
+ handleSend();
265
+ return;
266
+ }
267
+ }
268
+
113
269
  if (event.key === 'Enter' && !event.shiftKey) {
114
270
  event.preventDefault();
115
271
  handleSend();
@@ -123,14 +279,33 @@
123
279
  function handleRun(): void {
124
280
  if (fd.playground.isExecuting || !runEnabled) return;
125
281
  runEnabled = false;
126
- onSendMessage?.(resolvedPredefinedMessage);
282
+
283
+ const action = resolveRunAction({
284
+ canLaunch: onRunWorkflow != null,
285
+ predefinedMessage,
286
+ defaultMessage: resolvedPredefinedMessage
287
+ });
288
+
289
+ if (action.kind === 'launch') {
290
+ onRunWorkflow?.();
291
+ return;
292
+ }
293
+
294
+ onSendMessage?.(action.content);
127
295
  }
128
296
 
129
297
  function handleInput(): void {
130
- if (inputField) {
131
- inputField.style.height = 'auto';
132
- inputField.style.height = `${Math.min(inputField.scrollHeight, 120)}px`;
133
- }
298
+ // Typing re-opens the palette: a dismissal applies to the text it was
299
+ // dismissed on, not to the rest of the session.
300
+ paletteDismissed = false;
301
+ // ...and restarts the highlight at the top, as the editor console does.
302
+ // Without this the cursor survives a narrowing list: highlight the third
303
+ // entry, type one more character, and you are now pointed at whatever
304
+ // happens to be third in the *new* list, which is not what you were aiming
305
+ // at. Clamping keeps it in range; only resetting keeps it meaningful.
306
+ paletteCursor = 0;
307
+
308
+ resizeTextarea();
134
309
  }
135
310
  </script>
136
311
 
@@ -141,9 +316,60 @@
141
316
  <span>{states.viewOnlyHelp}</span>
142
317
  </div>
143
318
  {:else}
319
+ <!--
320
+ The live region is always present and only its *contents* come and go.
321
+ A region inserted with its text already in place is usually announced by
322
+ nothing at all — screen readers watch established regions for changes.
323
+
324
+ One fixed politeness, too, rather than swapping role between `status` and
325
+ `alert`: the `{#if}` reuses this node, and role changes on a live node are
326
+ not reliably re-evaluated. Severity is carried visually instead.
327
+ -->
328
+ <div class="chat-input__command-feedback-region" role="status" aria-live="polite">
329
+ {#if commandFeedback}
330
+ <div
331
+ class="chat-input__command-feedback chat-input__command-feedback--{commandFeedback.status}"
332
+ >
333
+ <span class="chat-input__command-feedback-text">{commandFeedback.message}</span>
334
+ <button
335
+ type="button"
336
+ class="chat-input__command-feedback-dismiss"
337
+ onclick={() => onDismissCommandFeedback?.()}
338
+ aria-label={commandMessages.dismiss}
339
+ >
340
+ <Icon icon="mdi:close" />
341
+ </button>
342
+ </div>
343
+ {/if}
344
+ </div>
144
345
  <div class="chat-input__container" class:chat-input__container--run-only={!showTextarea}>
145
346
  {#if showTextarea}
146
347
  <div class="chat-input__wrapper">
348
+ {#if enableCommands}
349
+ <ConsoleAutocomplete
350
+ suggestions={paletteSuggestions}
351
+ visible={paletteVisible}
352
+ selectedIndex={paletteIndex}
353
+ onAccept={acceptSuggestion}
354
+ {listboxId}
355
+ />
356
+ {/if}
357
+ <!--
358
+ `role="combobox"` on a <textarea> is a deliberate, non-conforming
359
+ choice, recorded here so it is not "fixed" by guesswork later.
360
+
361
+ ARIA in HTML permits no role on <textarea> other than its implicit
362
+ `textbox`, and the ARIA 1.2 combobox pattern assumes a single-line
363
+ input. But there is no conforming pattern for "multi-line composer
364
+ with completions", and the strictly-valid alternative — implicit
365
+ `textbox` plus `aria-activedescendant`, dropping `aria-expanded`
366
+ (which `textbox` does not support) — leaves no way to announce that
367
+ the palette opened at all.
368
+
369
+ We take the announcement over the conformance, which is what
370
+ comparable chat composers ship. Revisit if ARIA gains a real pattern
371
+ for this, or if testing shows a screen reader handles it badly.
372
+ -->
147
373
  <textarea
148
374
  bind:this={inputField}
149
375
  bind:value={inputValue}
@@ -153,6 +379,14 @@
153
379
  disabled={fd.playground.isExecuting || !fd.playground.currentSession}
154
380
  onkeydown={handleKeydown}
155
381
  oninput={handleInput}
382
+ onblur={() => (paletteDismissed = true)}
383
+ autocomplete="off"
384
+ role={enableCommands ? 'combobox' : undefined}
385
+ aria-expanded={enableCommands ? paletteVisible : undefined}
386
+ aria-controls={enableCommands ? listboxId : undefined}
387
+ aria-activedescendant={paletteVisible
388
+ ? `${listboxId}-option-${paletteIndex}`
389
+ : undefined}
156
390
  ></textarea>
157
391
  </div>
158
392
  {/if}
@@ -173,7 +407,7 @@
173
407
  type="button"
174
408
  class="chat-input__send-btn"
175
409
  onclick={handleSend}
176
- disabled={!inputValue.trim() || !fd.playground.canSendMessage}
410
+ disabled={!canSubmit}
177
411
  title={actions.sendTitle}
178
412
  aria-label={actions.sendTitle}
179
413
  >
@@ -217,10 +451,66 @@
217
451
  justify-content: flex-end;
218
452
  }
219
453
 
454
+ .chat-input__command-feedback {
455
+ display: flex;
456
+ align-items: flex-start;
457
+ gap: var(--fd-space-sm);
458
+ max-width: 760px;
459
+ margin: 0 auto var(--fd-space-sm);
460
+ padding: var(--fd-space-sm) var(--fd-space-md);
461
+ border-radius: var(--fd-radius-md);
462
+ font-size: var(--fd-font-size-sm);
463
+ line-height: 1.4;
464
+ }
465
+
466
+ .chat-input__command-feedback-text {
467
+ flex: 1;
468
+ /* /help returns a newline-separated list — keep its shape. */
469
+ white-space: pre-wrap;
470
+ }
471
+
472
+ /*
473
+ * Status tokens, not literals: `--fd-*-muted` is a translucent tint that is
474
+ * redefined for dark mode, so these follow the theme. Hardcoded pastels do
475
+ * not, and rendered as bright blocks on a dark UI.
476
+ */
477
+ .chat-input__command-feedback--ok {
478
+ background-color: var(--fd-success-muted);
479
+ color: var(--fd-success);
480
+ }
481
+
482
+ .chat-input__command-feedback--info {
483
+ background-color: var(--fd-info-muted);
484
+ color: var(--fd-info);
485
+ }
486
+
487
+ .chat-input__command-feedback--error {
488
+ background-color: var(--fd-error-muted);
489
+ color: var(--fd-error);
490
+ }
491
+
492
+ .chat-input__command-feedback-dismiss {
493
+ flex-shrink: 0;
494
+ display: flex;
495
+ align-items: center;
496
+ background: none;
497
+ border: none;
498
+ padding: 0;
499
+ cursor: pointer;
500
+ color: inherit;
501
+ opacity: 0.7;
502
+ }
503
+
504
+ .chat-input__command-feedback-dismiss:hover {
505
+ opacity: 1;
506
+ }
507
+
220
508
  .chat-input__wrapper {
221
509
  flex: 1;
222
510
  display: flex;
223
511
  align-items: flex-end;
512
+ /* Positioning context for the command palette, which sits above the input. */
513
+ position: relative;
224
514
  background-color: var(--fd-background);
225
515
  border: 1px solid var(--fd-border);
226
516
  border-radius: var(--fd-radius-xl);
@@ -232,7 +522,6 @@
232
522
 
233
523
  .chat-input__wrapper:focus-within {
234
524
  border-color: var(--fd-primary);
235
- box-shadow: 0 0 0 3px var(--fd-primary-muted);
236
525
  }
237
526
 
238
527
  .chat-input__textarea {
@@ -1,13 +1,43 @@
1
+ import { type CommandOutcome } from '../../playground/commands/index.js';
1
2
  interface Props {
2
3
  placeholder?: string;
3
4
  /** Show the textarea (default: true). When false, only the Run button is shown. */
4
5
  showTextarea?: boolean;
5
6
  /** Show the Run button when textarea is hidden (default: true) */
6
7
  showRunButton?: boolean;
7
- /** Message sent when Run is clicked with textarea hidden */
8
+ /**
9
+ * Message sent when Run is clicked, for hosts that deliberately want the
10
+ * run to begin with a specific chat turn.
11
+ *
12
+ * Setting this opts *out* of {@link onRunWorkflow}: an explicitly
13
+ * configured message is a host's intentional choice and is honoured.
14
+ * Leaving it unset is what lets Run launch without fabricating a turn.
15
+ */
8
16
  predefinedMessage?: string;
9
17
  onSendMessage?: (content: string) => void;
10
18
  onStopExecution?: () => void;
19
+ /**
20
+ * Start a run without posting a chat message.
21
+ *
22
+ * Preferred over `onSendMessage` for the Run button. Sending a message to
23
+ * start a run fabricates a user turn that enters the conversation and is
24
+ * replayed as input on the following turn — indistinguishable downstream
25
+ * from something the user actually typed. Hosts that provide this get a Run
26
+ * button that launches instead.
27
+ */
28
+ onRunWorkflow?: () => void;
29
+ /**
30
+ * Enable the slash-command lane (default: false).
31
+ *
32
+ * Opt-in because the lane is only safe where the `onSendMessage` handler
33
+ * actually dispatches commands. A surface that forwards input straight to a
34
+ * backend (ChatPanel) would post `/stop` as literal text — faking a command
35
+ * that nothing implements.
36
+ */
37
+ enableCommands?: boolean;
38
+ /** Transient result of the last slash command. Never a session message. */
39
+ commandFeedback?: CommandOutcome | null;
40
+ onDismissCommandFeedback?: () => void;
11
41
  }
12
42
  declare const ChatInput: import("svelte").Component<Props, {}, "">;
13
43
  type ChatInput = ReturnType<typeof ChatInput>;
@@ -12,6 +12,7 @@
12
12
  import ChatInput from './ChatInput.svelte';
13
13
  import { getInstance } from '../../stores/getInstance.svelte.js';
14
14
  import { m } from '../../messages/index.js';
15
+ import type { CommandOutcome } from '../../playground/commands/index.js';
15
16
 
16
17
  const fd = getInstance();
17
18
 
@@ -24,6 +25,19 @@
24
25
  // Orchestration
25
26
  onSendMessage: (content: string) => void;
26
27
  onStopExecution: () => void;
28
+ /** Start a run without posting a chat message. See ChatInput. */
29
+ onRunWorkflow?: () => void;
30
+ /**
31
+ * Enable the slash-command lane (default: false).
32
+ *
33
+ * Only safe when `onSendMessage` dispatches commands rather than forwarding
34
+ * them to the backend as text — Playground opts in; a host wiring
35
+ * ControlPanel to its own handler should not.
36
+ */
37
+ enableCommands?: boolean;
38
+ // Slash-command feedback (transient; never a session message)
39
+ commandFeedback?: CommandOutcome | null;
40
+ onDismissCommandFeedback?: () => void;
27
41
  // Header actions
28
42
  onTogglePanel?: () => void;
29
43
  isPipelinePanelOpen?: boolean;
@@ -48,6 +62,10 @@
48
62
  onSessionNavigate,
49
63
  onSendMessage,
50
64
  onStopExecution,
65
+ onRunWorkflow,
66
+ enableCommands = false,
67
+ commandFeedback = null,
68
+ onDismissCommandFeedback,
51
69
  onTogglePanel,
52
70
  isPipelinePanelOpen = false,
53
71
  onRefresh,
@@ -256,6 +274,10 @@
256
274
  {predefinedMessage}
257
275
  {onSendMessage}
258
276
  {onStopExecution}
277
+ {onRunWorkflow}
278
+ {enableCommands}
279
+ {commandFeedback}
280
+ {onDismissCommandFeedback}
259
281
  />
260
282
  </section>
261
283
 
@@ -1,3 +1,4 @@
1
+ import type { CommandOutcome } from '../../playground/commands/index.js';
1
2
  interface Props {
2
3
  onCreateSession: () => void;
3
4
  onSelectSession: (id: string) => void;
@@ -5,6 +6,18 @@ interface Props {
5
6
  onSessionNavigate?: (id: string) => void;
6
7
  onSendMessage: (content: string) => void;
7
8
  onStopExecution: () => void;
9
+ /** Start a run without posting a chat message. See ChatInput. */
10
+ onRunWorkflow?: () => void;
11
+ /**
12
+ * Enable the slash-command lane (default: false).
13
+ *
14
+ * Only safe when `onSendMessage` dispatches commands rather than forwarding
15
+ * them to the backend as text — Playground opts in; a host wiring
16
+ * ControlPanel to its own handler should not.
17
+ */
18
+ enableCommands?: boolean;
19
+ commandFeedback?: CommandOutcome | null;
20
+ onDismissCommandFeedback?: () => void;
8
21
  onTogglePanel?: () => void;
9
22
  isPipelinePanelOpen?: boolean;
10
23
  onRefresh: () => void;
@@ -8,6 +8,9 @@
8
8
 
9
9
  <script lang="ts">
10
10
  import Icon from '@iconify/svelte';
11
+ import Input from '../Input.svelte';
12
+ import Select from '../Select.svelte';
13
+ import Textarea from '../Textarea.svelte';
11
14
  import { slide } from 'svelte/transition';
12
15
  import type { PlaygroundInputField } from '../../types/playground.js';
13
16
  import { getInstance } from '../../stores/getInstance.svelte.js';
@@ -171,9 +174,8 @@
171
174
 
172
175
  {#if hasEnumOptions(field)}
173
176
  <!-- Select for enum fields -->
174
- <select
177
+ <Select
175
178
  id="input-{field.nodeId}-{field.fieldId}"
176
- class="input-collector__select"
177
179
  value={getValue(field)}
178
180
  onchange={(e) => updateValue(field, e.currentTarget.value)}
179
181
  >
@@ -181,17 +183,16 @@
181
183
  {#each field.schema?.enum ?? [] as option (option)}
182
184
  <option value={String(option)}>{option}</option>
183
185
  {/each}
184
- </select>
186
+ </Select>
185
187
  {:else if getInputType(field) === 'textarea'}
186
188
  <!-- Textarea for multiline -->
187
- <textarea
189
+ <Textarea
188
190
  id="input-{field.nodeId}-{field.fieldId}"
189
- class="input-collector__textarea"
190
191
  placeholder={field.schema?.description ?? `Enter ${field.label}`}
191
192
  value={String(getValue(field) ?? '')}
192
193
  oninput={(e) => updateValue(field, e.currentTarget.value)}
193
- rows="3"
194
- ></textarea>
194
+ rows={3}
195
+ />
195
196
  {:else if getInputType(field) === 'checkbox'}
196
197
  <!-- Checkbox for boolean -->
197
198
  <label class="input-collector__checkbox-wrapper">
@@ -208,10 +209,10 @@
208
209
  </label>
209
210
  {:else if getInputType(field) === 'number'}
210
211
  <!-- Number input -->
211
- <input
212
+ <Input
212
213
  id="input-{field.nodeId}-{field.fieldId}"
213
214
  type="number"
214
- class="input-collector__input"
215
+ class="flowdrop-input--numeric"
215
216
  placeholder={field.schema?.description ?? `Enter ${field.label}`}
216
217
  value={Number(getValue(field) ?? 0)}
217
218
  min={field.schema?.minimum}
@@ -220,10 +221,9 @@
220
221
  />
221
222
  {:else}
222
223
  <!-- Text input (default) -->
223
- <input
224
+ <Input
224
225
  id="input-{field.nodeId}-{field.fieldId}"
225
226
  type="text"
226
- class="input-collector__input"
227
227
  placeholder={field.schema?.description ?? `Enter ${field.label}`}
228
228
  value={String(getValue(field) ?? '')}
229
229
  oninput={(e) => updateValue(field, e.currentTarget.value)}
@@ -351,43 +351,6 @@
351
351
  color: var(--fd-error);
352
352
  }
353
353
 
354
- .input-collector__input,
355
- .input-collector__select,
356
- .input-collector__textarea {
357
- padding: var(--fd-space-xs) var(--fd-space-md);
358
- border: 1px solid var(--fd-border);
359
- border-radius: var(--fd-radius-lg);
360
- font-size: var(--fd-text-sm);
361
- font-family: inherit;
362
- color: var(--fd-foreground);
363
- background-color: var(--fd-background);
364
- transition:
365
- border-color var(--fd-transition-normal),
366
- box-shadow var(--fd-transition-normal);
367
- }
368
-
369
- .input-collector__input:focus,
370
- .input-collector__select:focus,
371
- .input-collector__textarea:focus {
372
- outline: none;
373
- border-color: var(--fd-primary);
374
- box-shadow: 0 0 0 3px var(--fd-primary-muted);
375
- }
376
-
377
- .input-collector__input::placeholder,
378
- .input-collector__textarea::placeholder {
379
- color: var(--fd-muted-foreground);
380
- }
381
-
382
- .input-collector__textarea {
383
- resize: vertical;
384
- min-height: 80px;
385
- }
386
-
387
- .input-collector__select {
388
- cursor: pointer;
389
- }
390
-
391
354
  .input-collector__checkbox-wrapper {
392
355
  display: flex;
393
356
  align-items: center;