@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
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Playground Slash Command Parser
3
+ *
4
+ * Pure, synchronous, dependency-free: given composer input, decide whether it
5
+ * is a command, a message, or a typo. No network, no store, no config — so the
6
+ * escape rule and the command grammar can be tested in isolation.
7
+ *
8
+ * @module playground/commands/parser
9
+ */
10
+ import { COMMAND_NAMES } from './registry.js';
11
+ /**
12
+ * The escape sequence for a message that genuinely starts with a slash.
13
+ *
14
+ * `//deploy the thing` sends the literal text `/deploy the thing`. Exactly one
15
+ * leading slash is consumed, so `///x` sends `//x` — the rule composes rather
16
+ * than special-casing depth.
17
+ *
18
+ * This must stay decided and documented: once users have sent messages
19
+ * beginning with `/`, changing the escape silently rewrites their intent.
20
+ */
21
+ const ESCAPE_PREFIX = '//';
22
+ /** Longest command name, used to bound the typo search. */
23
+ const MAX_NAME_LENGTH = Math.max(...COMMAND_NAMES.map((n) => n.length));
24
+ /**
25
+ * Split a command body into tokens, keeping quoted runs together.
26
+ *
27
+ * Needed because launch arguments carry real prose — `/run --topic="Q2 revenue"`
28
+ * is one argument, not two. Both quote styles are accepted so a value can
29
+ * contain the other, and a quote may open mid-token (`--topic="a b"`) since
30
+ * that is how flags are naturally written.
31
+ *
32
+ * An unterminated quote runs to end of input rather than failing: the user is
33
+ * mid-typing, and refusing to parse would make the composer feel broken.
34
+ */
35
+ export function tokenize(body) {
36
+ const tokens = [];
37
+ let current = '';
38
+ let quote = null;
39
+ let started = false;
40
+ for (const char of body) {
41
+ if (quote) {
42
+ if (char === quote)
43
+ quote = null;
44
+ else
45
+ current += char;
46
+ continue;
47
+ }
48
+ if (char === '"' || char === "'") {
49
+ quote = char;
50
+ started = true;
51
+ continue;
52
+ }
53
+ if (/\s/.test(char)) {
54
+ if (started)
55
+ tokens.push(current);
56
+ current = '';
57
+ started = false;
58
+ continue;
59
+ }
60
+ current += char;
61
+ started = true;
62
+ }
63
+ if (started)
64
+ tokens.push(current);
65
+ return tokens;
66
+ }
67
+ /**
68
+ * Suggest commands for an unrecognised name.
69
+ *
70
+ * Deliberately conservative — prefix matches first, then single-edit
71
+ * neighbours. A wrong suggestion is worse than none: the user is one keystroke
72
+ * from running something they did not intend.
73
+ */
74
+ function suggest(name) {
75
+ const lower = name.toLowerCase();
76
+ if (!lower)
77
+ return [...COMMAND_NAMES];
78
+ const prefixed = COMMAND_NAMES.filter((n) => n.startsWith(lower));
79
+ if (prefixed.length > 0)
80
+ return prefixed;
81
+ if (lower.length > MAX_NAME_LENGTH + 2)
82
+ return [];
83
+ return COMMAND_NAMES.filter((n) => isSingleEditApart(lower, n));
84
+ }
85
+ /**
86
+ * True when `a` and `b` differ by at most one insertion, deletion,
87
+ * substitution, **or transposition of adjacent characters**.
88
+ *
89
+ * The transposition arm matters more than the rest: `/stpo` for `/stop` is the
90
+ * single most common way to mistype a short word, and plain Levenshtein scores
91
+ * it as two edits — so omitting it would leave the most likely typo
92
+ * unsuggested. This is Damerau-Levenshtein restricted to distance 1, which
93
+ * stays cheap and predictable for strings this short.
94
+ */
95
+ function isSingleEditApart(a, b) {
96
+ if (a === b)
97
+ return true;
98
+ const [shorter, longer] = a.length <= b.length ? [a, b] : [b, a];
99
+ if (longer.length - shorter.length > 1)
100
+ return false;
101
+ // Locate the first and last positions where the two disagree.
102
+ let head = 0;
103
+ while (head < shorter.length && shorter[head] === longer[head])
104
+ head++;
105
+ let tail = 0;
106
+ while (tail < shorter.length - head &&
107
+ shorter[shorter.length - 1 - tail] === longer[longer.length - 1 - tail]) {
108
+ tail++;
109
+ }
110
+ // Characters left unmatched in the middle of each string.
111
+ const shorterRemainder = shorter.length - head - tail;
112
+ const longerRemainder = longer.length - head - tail;
113
+ // One substitution (1/1), or one insertion/deletion (0/1).
114
+ if (longerRemainder <= 1 && shorterRemainder <= 1)
115
+ return true;
116
+ // One transposition: exactly two mismatched characters, equal lengths, swapped.
117
+ return (shorterRemainder === 2 &&
118
+ longerRemainder === 2 &&
119
+ shorter[head] === longer[head + 1] &&
120
+ shorter[head + 1] === longer[head]);
121
+ }
122
+ /**
123
+ * Parse composer input into a command, a message, or an unknown-command error.
124
+ *
125
+ * Unknown commands are **not** forwarded as messages. A typo like `/stpo` must
126
+ * not silently launch a pipeline with `/stpo` as its input — the whole point of
127
+ * the lane is that control traffic and pipeline data never cross.
128
+ */
129
+ export function parseSlashCommand(input) {
130
+ const trimmed = input.trim();
131
+ if (!trimmed)
132
+ return { kind: 'empty' };
133
+ if (trimmed.startsWith(ESCAPE_PREFIX)) {
134
+ return { kind: 'message', content: trimmed.slice(1) };
135
+ }
136
+ if (!trimmed.startsWith('/')) {
137
+ return { kind: 'message', content: trimmed };
138
+ }
139
+ const body = trimmed.slice(1);
140
+ const parts = tokenize(body);
141
+ const rawName = parts[0] ?? '';
142
+ const name = rawName.toLowerCase();
143
+ if (!isKnownCommand(name)) {
144
+ return { kind: 'unknown', name: rawName, suggestions: suggest(name) };
145
+ }
146
+ return {
147
+ kind: 'command',
148
+ command: { name, args: parts.slice(1), raw: trimmed }
149
+ };
150
+ }
151
+ /** Type guard narrowing an arbitrary string to a known command name. */
152
+ export function isKnownCommand(name) {
153
+ return COMMAND_NAMES.includes(name);
154
+ }
155
+ /**
156
+ * True when input would be routed to the control plane rather than sent as a
157
+ * message. Used by the composer to keep commands submittable while a run is in
158
+ * flight (when plain text is not).
159
+ */
160
+ export function isCommandInput(input) {
161
+ const result = parseSlashCommand(input);
162
+ return result.kind === 'command' || result.kind === 'unknown';
163
+ }
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Playground Slash Command Registry
3
+ *
4
+ * The single source of truth for which commands exist and when they are
5
+ * offered. Availability is derived from the *configured endpoints*, never from
6
+ * knowledge of a particular backend: FlowDrop ships as a standalone library and
7
+ * may be pointed at any API implementing the shape.
8
+ *
9
+ * @module playground/commands/registry
10
+ */
11
+ import type { EndpointConfig } from '../../config/endpoints.js';
12
+ import type { SlashCommandDescriptor, SlashCommandName } from './types.js';
13
+ /**
14
+ * Canonical command list. Order is the order shown by `/help`.
15
+ *
16
+ * Declared as a plain tuple so the parser can bound its typo search and the
17
+ * type system keeps {@link SlashCommandName} and this array in lockstep.
18
+ */
19
+ export declare const COMMAND_NAMES: readonly ["help", "run", "new", "stop", "reset", "delete", "pause", "resume", "cancel"];
20
+ /**
21
+ * Structure only — no display text. What each command *says* lives in
22
+ * `m().playground.commands.catalog` so it can be translated; what each command
23
+ * *is* lives here so pure logic never has to parse prose.
24
+ */
25
+ export declare const COMMAND_DESCRIPTORS: readonly SlashCommandDescriptor[];
26
+ /**
27
+ * Commands that act on a specific pipeline and cannot run without a resolved
28
+ * target. Distinct from session commands, which act on the conversation.
29
+ */
30
+ export declare const SIGNAL_COMMANDS: ReadonlySet<SlashCommandName>;
31
+ /** Look up a descriptor by name. */
32
+ export declare function getDescriptor(name: SlashCommandName): SlashCommandDescriptor | undefined;
33
+ /**
34
+ * The commands offerable against a given configuration.
35
+ *
36
+ * Callers should gate both the palette and dispatch on this: a command that is
37
+ * parseable but unavailable must report "not supported here", never issue a
38
+ * request to an endpoint that was never configured.
39
+ */
40
+ export declare function getAvailableCommands(config: EndpointConfig | null): SlashCommandDescriptor[];
41
+ /** True when the named command can run against this configuration. */
42
+ export declare function isCommandAvailable(name: SlashCommandName, config: EndpointConfig | null): boolean;
@@ -0,0 +1,122 @@
1
+ /**
2
+ * Playground Slash Command Registry
3
+ *
4
+ * The single source of truth for which commands exist and when they are
5
+ * offered. Availability is derived from the *configured endpoints*, never from
6
+ * knowledge of a particular backend: FlowDrop ships as a standalone library and
7
+ * may be pointed at any API implementing the shape.
8
+ *
9
+ * @module playground/commands/registry
10
+ */
11
+ /**
12
+ * Canonical command list. Order is the order shown by `/help`.
13
+ *
14
+ * Declared as a plain tuple so the parser can bound its typo search and the
15
+ * type system keeps {@link SlashCommandName} and this array in lockstep.
16
+ */
17
+ export const COMMAND_NAMES = [
18
+ 'help',
19
+ 'run',
20
+ 'new',
21
+ 'stop',
22
+ 'reset',
23
+ 'delete',
24
+ 'pause',
25
+ 'resume',
26
+ 'cancel'
27
+ ];
28
+ /**
29
+ * Availability predicates.
30
+ *
31
+ * `playground.stopExecution`, `createSession` and `deleteSession` are required
32
+ * keys in {@link EndpointConfig}, so their commands are available whenever a
33
+ * config exists at all. `resetSession` is optional — the one place where the
34
+ * "absence of an endpoint is absence of a command" rule currently bites.
35
+ */
36
+ const hasPlayground = (config) => config?.endpoints?.playground != null;
37
+ /**
38
+ * Signal commands exist only where the backend exposes a signal plane. The
39
+ * whole block is optional, so this is the coarsest form of the availability
40
+ * rule: no endpoints, no commands.
41
+ */
42
+ const hasSignals = (config) => config?.endpoints?.signals != null;
43
+ /**
44
+ * Structure only — no display text. What each command *says* lives in
45
+ * `m().playground.commands.catalog` so it can be translated; what each command
46
+ * *is* lives here so pure logic never has to parse prose.
47
+ */
48
+ export const COMMAND_DESCRIPTORS = [
49
+ {
50
+ name: 'help',
51
+ takesArgs: false,
52
+ // Needs no backend — it only describes what is already configured.
53
+ isAvailable: () => true
54
+ },
55
+ {
56
+ name: 'run',
57
+ takesArgs: true,
58
+ isAvailable: (config) => config?.endpoints?.workflows?.run != null
59
+ },
60
+ {
61
+ name: 'new',
62
+ takesArgs: false,
63
+ isAvailable: hasPlayground
64
+ },
65
+ {
66
+ name: 'stop',
67
+ takesArgs: false,
68
+ isAvailable: hasPlayground
69
+ },
70
+ {
71
+ name: 'reset',
72
+ takesArgs: false,
73
+ isAvailable: (config) => hasPlayground(config) && config?.endpoints.playground.resetSession != null
74
+ },
75
+ {
76
+ name: 'delete',
77
+ takesArgs: false,
78
+ isAvailable: hasPlayground
79
+ },
80
+ {
81
+ name: 'pause',
82
+ takesArgs: true,
83
+ isAvailable: hasSignals
84
+ },
85
+ {
86
+ name: 'resume',
87
+ takesArgs: true,
88
+ isAvailable: hasSignals
89
+ },
90
+ {
91
+ name: 'cancel',
92
+ takesArgs: true,
93
+ isAvailable: hasSignals
94
+ }
95
+ ];
96
+ /**
97
+ * Commands that act on a specific pipeline and cannot run without a resolved
98
+ * target. Distinct from session commands, which act on the conversation.
99
+ */
100
+ export const SIGNAL_COMMANDS = new Set([
101
+ 'pause',
102
+ 'resume',
103
+ 'cancel'
104
+ ]);
105
+ /** Look up a descriptor by name. */
106
+ export function getDescriptor(name) {
107
+ return COMMAND_DESCRIPTORS.find((d) => d.name === name);
108
+ }
109
+ /**
110
+ * The commands offerable against a given configuration.
111
+ *
112
+ * Callers should gate both the palette and dispatch on this: a command that is
113
+ * parseable but unavailable must report "not supported here", never issue a
114
+ * request to an endpoint that was never configured.
115
+ */
116
+ export function getAvailableCommands(config) {
117
+ return COMMAND_DESCRIPTORS.filter((d) => d.isAvailable(config));
118
+ }
119
+ /** True when the named command can run against this configuration. */
120
+ export function isCommandAvailable(name, config) {
121
+ return getDescriptor(name)?.isAvailable(config) ?? false;
122
+ }
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Command Completion
3
+ *
4
+ * Suggestions for the composer's `/` palette.
5
+ *
6
+ * Scope is deliberately narrow: **command names only**. Completing argument
7
+ * *values* would mean knowing a workflow's declared launch inputs, which live
8
+ * server-side — guessing them client-side would offer inputs the backend will
9
+ * reject. Names are the part this client can complete honestly.
10
+ *
11
+ * @module playground/commands/suggest
12
+ */
13
+ import type { EndpointConfig } from '../../config/endpoints.js';
14
+ import type { CommandLabels } from './types.js';
15
+ /**
16
+ * One completion. Shape matches the shared autocomplete listbox so the composer
17
+ * and the editor console present suggestions identically.
18
+ */
19
+ export interface CommandSuggestion {
20
+ /** Text that replaces the input when accepted. */
21
+ value: string;
22
+ /** Primary text — the usage line, which shows the argument shape. */
23
+ label: string;
24
+ /** Secondary text — what the command does. */
25
+ detail?: string;
26
+ }
27
+ /**
28
+ * Compute completions for the current composer input.
29
+ *
30
+ * Returns nothing unless the input is an unescaped `/` command still being
31
+ * named. In particular:
32
+ *
33
+ * - `hello` → nothing; this is a message, not a command.
34
+ * - `//st` → nothing; the escape means the user is writing literal text.
35
+ * - `/stop ` → nothing; the name is settled and arguments follow.
36
+ */
37
+ export declare function suggestCommands(input: string, config: EndpointConfig | null, labels: CommandLabels): CommandSuggestion[];
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Command Completion
3
+ *
4
+ * Suggestions for the composer's `/` palette.
5
+ *
6
+ * Scope is deliberately narrow: **command names only**. Completing argument
7
+ * *values* would mean knowing a workflow's declared launch inputs, which live
8
+ * server-side — guessing them client-side would offer inputs the backend will
9
+ * reject. Names are the part this client can complete honestly.
10
+ *
11
+ * @module playground/commands/suggest
12
+ */
13
+ import { getAvailableCommands } from './registry.js';
14
+ /**
15
+ * Compute completions for the current composer input.
16
+ *
17
+ * Returns nothing unless the input is an unescaped `/` command still being
18
+ * named. In particular:
19
+ *
20
+ * - `hello` → nothing; this is a message, not a command.
21
+ * - `//st` → nothing; the escape means the user is writing literal text.
22
+ * - `/stop ` → nothing; the name is settled and arguments follow.
23
+ */
24
+ export function suggestCommands(input, config, labels) {
25
+ // Leading whitespace is tolerated when sending, so tolerate it here too.
26
+ const trimmed = input.trimStart();
27
+ if (!trimmed.startsWith('/'))
28
+ return [];
29
+ // `//` is the escape for a literal leading slash — not a command.
30
+ if (trimmed.startsWith('//'))
31
+ return [];
32
+ const body = trimmed.slice(1);
33
+ // A space means the name is complete; we do not complete argument values.
34
+ if (/\s/.test(body))
35
+ return [];
36
+ const prefix = body.toLowerCase();
37
+ return getAvailableCommands(config)
38
+ .filter((d) => d.name.startsWith(prefix))
39
+ .map((d) => ({
40
+ // Commands that take arguments get a trailing space, so accepting the
41
+ // completion leaves the caret where the argument goes.
42
+ value: `/${d.name}${d.takesArgs ? ' ' : ''}`,
43
+ label: labels[d.name].usage,
44
+ detail: labels[d.name].summary
45
+ }));
46
+ }
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Playground Slash Command Types
3
+ *
4
+ * The composer's out-of-band control lane. A leading `/` routes input to the
5
+ * control plane instead of the pipeline, so plain text stops meaning exactly
6
+ * one thing ("launch a run with this as input").
7
+ *
8
+ * Deliberately separate from `$lib/commands` (the workflow-editing DSL): that
9
+ * grammar is bare-verb, synchronous, and targets the workflow store, while this
10
+ * one is slash-prefixed, asynchronous, and targets session/pipeline services.
11
+ * Sharing a union would force each executor to handle commands it cannot run.
12
+ *
13
+ * @module playground/commands/types
14
+ */
15
+ import type { EndpointConfig } from '../../config/endpoints.js';
16
+ /**
17
+ * Every member maps onto a door the backend already exposes; none invents
18
+ * behaviour. Adding a member here without a corresponding endpoint would break
19
+ * the rule that the client never mints a command the backend cannot honour.
20
+ *
21
+ * Two groups, deliberately distinguished:
22
+ *
23
+ * - **Session shell** (`new`, `delete`, `stop`, `reset`, `help`) — act on the
24
+ * session, which is a client-side conversation container.
25
+ * - **Pipeline signals** (`pause`, `resume`, `cancel`) — act on a *specific
26
+ * running pipeline*, and therefore need a resolved target.
27
+ */
28
+ export type SlashCommandName = 'stop' | 'reset' | 'new' | 'delete' | 'help' | 'run' | 'pause' | 'resume' | 'cancel';
29
+ /** A successfully parsed command. */
30
+ export interface SlashCommand {
31
+ /** Canonical, lower-cased command name. */
32
+ name: SlashCommandName;
33
+ /** Positional arguments, whitespace-separated, in source order. */
34
+ args: string[];
35
+ /** The raw input the command was parsed from, for logging and echo. */
36
+ raw: string;
37
+ }
38
+ /**
39
+ * Outcome of parsing composer input.
40
+ *
41
+ * `message` covers plain text *and* escaped input (`//foo` → `/foo`), so the
42
+ * caller never has to re-apply the escape rule.
43
+ */
44
+ export type ParseResult = {
45
+ kind: 'empty';
46
+ } | {
47
+ kind: 'message';
48
+ content: string;
49
+ } | {
50
+ kind: 'command';
51
+ command: SlashCommand;
52
+ } | {
53
+ kind: 'unknown';
54
+ name: string;
55
+ suggestions: SlashCommandName[];
56
+ };
57
+ /**
58
+ * Human-readable text for one command.
59
+ *
60
+ * Kept out of {@link SlashCommandDescriptor} and sourced from the messages
61
+ * module instead: every other user-facing string in the playground is
62
+ * overridable for translation, and the palette and `/help` should not be the
63
+ * two surfaces stuck in English.
64
+ */
65
+ export interface CommandLabel {
66
+ /** Short help text. Rendered by `/help` and as palette detail. */
67
+ summary: string;
68
+ /** Usage line, e.g. `/pause [reason]`. Rendered as the palette label. */
69
+ usage: string;
70
+ }
71
+ /** Labels for every command, keyed by name. See `m().playground.commands.catalog`. */
72
+ export type CommandLabels = Record<SlashCommandName, CommandLabel>;
73
+ /**
74
+ * Structural description of a command: what it is, not what it says.
75
+ *
76
+ * Carries only what logic branches on. Display text lives in
77
+ * {@link CommandLabels} so it can be translated without the registry — and so
78
+ * nothing has to infer behaviour by pattern-matching a display string.
79
+ */
80
+ export interface SlashCommandDescriptor {
81
+ name: SlashCommandName;
82
+ /**
83
+ * Whether the command accepts arguments.
84
+ *
85
+ * Drives the trailing space on an accepted completion, so the caret lands
86
+ * where the argument goes. Declared rather than sniffed out of the usage
87
+ * line: usage text is prose, and prose gets translated.
88
+ */
89
+ takesArgs: boolean;
90
+ /**
91
+ * Whether this command can run against the given endpoint configuration.
92
+ *
93
+ * This is the genericity contract: a command is offered only when the
94
+ * backend it needs is configured. A host pointing FlowDrop at a backend
95
+ * without session reset gets no `/reset`, rather than a command that 404s.
96
+ *
97
+ * Commands needing no backend (`/help`) return true unconditionally.
98
+ */
99
+ isAvailable: (config: EndpointConfig | null) => boolean;
100
+ }
101
+ /** Result of dispatching a command. Rendered as transient composer feedback. */
102
+ export type CommandOutcome = {
103
+ status: 'ok';
104
+ message?: string;
105
+ } | {
106
+ status: 'info';
107
+ message: string;
108
+ } | {
109
+ status: 'error';
110
+ message: string;
111
+ };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Playground Slash Command Types
3
+ *
4
+ * The composer's out-of-band control lane. A leading `/` routes input to the
5
+ * control plane instead of the pipeline, so plain text stops meaning exactly
6
+ * one thing ("launch a run with this as input").
7
+ *
8
+ * Deliberately separate from `$lib/commands` (the workflow-editing DSL): that
9
+ * grammar is bare-verb, synchronous, and targets the workflow store, while this
10
+ * one is slash-prefixed, asynchronous, and targets session/pipeline services.
11
+ * Sharing a union would force each executor to handle commands it cannot run.
12
+ *
13
+ * @module playground/commands/types
14
+ */
15
+ export {};
@@ -126,8 +126,20 @@ export { default as InputCollector } from '../components/playground/InputCollect
126
126
  export { default as ExecutionLogs } from '../components/playground/ExecutionLogs.svelte';
127
127
  export { default as MessageBubble } from '../components/playground/MessageBubble.svelte';
128
128
  export { InterruptBubble, ConfirmationPrompt, ChoicePrompt, TextInputPrompt, FormPrompt, ReviewPrompt } from '../components/interrupt/index.js';
129
- export { PlaygroundService, playgroundService } from '../services/playgroundService.js';
130
- export { InterruptService, interruptService } from '../services/interruptService.js';
129
+ export { PlaygroundService } from '../services/playgroundService.js';
130
+ export { InterruptService } from '../services/interruptService.js';
131
+ /**
132
+ * Launching a run is its own verb, distinct from posting a message. Exported so
133
+ * hosts can build a RUN affordance that starts a run without fabricating a
134
+ * chat turn.
135
+ */
136
+ export { WorkflowLaunchService, workflowLaunchService, type LaunchResult, type LaunchOptions, type LaunchInputError } from '../services/workflowLaunchService.js';
137
+ /**
138
+ * Signals travel *into* a running pipeline, the opposite direction from
139
+ * interrupts. Exported so hosts can drive pause/resume/cancel from their own
140
+ * chrome rather than only through the composer's command lane.
141
+ */
142
+ export { PipelineSignalService, pipelineSignalService, type SignalType, type SignalResult, type SignalRefusal, type SendSignalOptions } from '../services/pipelineSignalService.js';
131
143
  export { PlaygroundStore } from '../stores/playgroundStore.svelte.js';
132
144
  export type { PlaygroundSession, PlaygroundMessage, PlaygroundInputField, PlaygroundMessageRequest, PlaygroundMessagesResult, PlaygroundConfig, PlaygroundMode, PlaygroundSessionStatus, PlaygroundMessageRole, PlaygroundMessageLevel, PlaygroundMessageMetadata, PlaygroundApiResponse, PlaygroundSessionsResponse, PlaygroundSessionResponse, PlaygroundMessageResponse, PlaygroundMessagesApiResponse, PlaygroundExecution } from '../types/playground.js';
133
145
  export { isChatInputNode, CHAT_INPUT_PATTERNS, defaultShouldStopPolling, defaultIsTerminalStatus, DEFAULT_STOP_POLLING_STATUSES, DEFAULT_TERMINAL_STATUSES } from '../types/playground.js';
@@ -138,3 +150,10 @@ export type { InterruptWithState } from '../stores/interruptStore.svelte.js';
138
150
  export { mountPlayground, unmountPlayground, mountPlaygroundStudio, mountPlaygroundApp, type PlaygroundMountOptions, type PlaygroundStudioMountOptions, type PlaygroundAppMountOptions, type MountedPlayground } from './mount.js';
139
151
  export type { PipelineViewDef, PipelineViewProps } from '../types/index.js';
140
152
  export { createEndpointConfig, defaultEndpointConfig, buildEndpointUrl, type EndpointConfig } from '../config/endpoints.js';
153
+ /**
154
+ * The composer's out-of-band control lane. Exported so hosts can inspect what
155
+ * is available against their configuration (`getAvailableCommands`) or reuse
156
+ * the parser — including its escape rule — in their own surfaces.
157
+ */
158
+ export { resolveRunAction, type RunAction, type ResolveRunActionOptions } from './runAction.js';
159
+ export { parseSlashCommand, isKnownCommand, isCommandInput, dispatchCommand, COMMAND_NAMES, COMMAND_DESCRIPTORS, getDescriptor, getAvailableCommands, isCommandAvailable, type SlashCommand, type SlashCommandName, type SlashCommandDescriptor, type CommandLabel, type CommandLabels, type ParseResult, type CommandOutcome, type CommandHandlers, type CommandContext, type CommandMessages } from './commands/index.js';
@@ -135,11 +135,26 @@ export { InterruptBubble, ConfirmationPrompt, ChoicePrompt, TextInputPrompt, For
135
135
  // ============================================================================
136
136
  // Playground Service
137
137
  // ============================================================================
138
- export { PlaygroundService, playgroundService } from '../services/playgroundService.js';
138
+ export { PlaygroundService } from '../services/playgroundService.js';
139
139
  // ============================================================================
140
140
  // Interrupt Service (Human-in-the-Loop)
141
141
  // ============================================================================
142
- export { InterruptService, interruptService } from '../services/interruptService.js';
142
+ export { InterruptService } from '../services/interruptService.js';
143
+ // ============================================================================
144
+ // Pipeline Signal Service (operator control)
145
+ // ============================================================================
146
+ /**
147
+ * Launching a run is its own verb, distinct from posting a message. Exported so
148
+ * hosts can build a RUN affordance that starts a run without fabricating a
149
+ * chat turn.
150
+ */
151
+ export { WorkflowLaunchService, workflowLaunchService } from '../services/workflowLaunchService.js';
152
+ /**
153
+ * Signals travel *into* a running pipeline, the opposite direction from
154
+ * interrupts. Exported so hosts can drive pause/resume/cancel from their own
155
+ * chrome rather than only through the composer's command lane.
156
+ */
157
+ export { PipelineSignalService, pipelineSignalService } from '../services/pipelineSignalService.js';
143
158
  // ============================================================================
144
159
  // Playground Store
145
160
  // ============================================================================
@@ -158,3 +173,13 @@ export { mountPlayground, unmountPlayground, mountPlaygroundStudio, mountPlaygro
158
173
  // Endpoint Configuration (re-exported for convenience)
159
174
  // ============================================================================
160
175
  export { createEndpointConfig, defaultEndpointConfig, buildEndpointUrl } from '../config/endpoints.js';
176
+ // ============================================================================
177
+ // Slash Commands
178
+ // ============================================================================
179
+ /**
180
+ * The composer's out-of-band control lane. Exported so hosts can inspect what
181
+ * is available against their configuration (`getAvailableCommands`) or reuse
182
+ * the parser — including its escape rule — in their own surfaces.
183
+ */
184
+ export { resolveRunAction } from './runAction.js';
185
+ export { parseSlashCommand, isKnownCommand, isCommandInput, dispatchCommand, COMMAND_NAMES, COMMAND_DESCRIPTORS, getDescriptor, getAvailableCommands, isCommandAvailable } from './commands/index.js';