@d34dman/flowdrop 0.0.37 → 0.0.39

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 (50) hide show
  1. package/LICENSE +21 -0
  2. package/dist/components/NodeSidebar.svelte +1 -0
  3. package/dist/components/form/FormCodeEditor.svelte +6 -1
  4. package/dist/components/interrupt/ChoicePrompt.svelte +389 -0
  5. package/dist/components/interrupt/ChoicePrompt.svelte.d.ts +21 -0
  6. package/dist/components/interrupt/ConfirmationPrompt.svelte +280 -0
  7. package/dist/components/interrupt/ConfirmationPrompt.svelte.d.ts +23 -0
  8. package/dist/components/interrupt/FormPrompt.svelte +223 -0
  9. package/dist/components/interrupt/FormPrompt.svelte.d.ts +21 -0
  10. package/dist/components/interrupt/InterruptBubble.svelte +621 -0
  11. package/dist/components/interrupt/InterruptBubble.svelte.d.ts +16 -0
  12. package/dist/components/interrupt/TextInputPrompt.svelte +333 -0
  13. package/dist/components/interrupt/TextInputPrompt.svelte.d.ts +21 -0
  14. package/dist/components/interrupt/index.d.ts +13 -0
  15. package/dist/components/interrupt/index.js +15 -0
  16. package/dist/components/nodes/GatewayNode.svelte +1 -3
  17. package/dist/components/nodes/IdeaNode.svelte +30 -35
  18. package/dist/components/nodes/IdeaNode.svelte.d.ts +1 -1
  19. package/dist/components/nodes/SimpleNode.svelte +1 -3
  20. package/dist/components/nodes/TerminalNode.svelte +1 -3
  21. package/dist/components/nodes/ToolNode.svelte +2 -2
  22. package/dist/components/nodes/WorkflowNode.svelte +1 -3
  23. package/dist/components/playground/ChatPanel.svelte +144 -7
  24. package/dist/components/playground/ChatPanel.svelte.d.ts +2 -0
  25. package/dist/components/playground/MessageBubble.svelte +1 -3
  26. package/dist/components/playground/Playground.svelte +50 -5
  27. package/dist/components/playground/PlaygroundModal.svelte +8 -7
  28. package/dist/components/playground/PlaygroundModal.svelte.d.ts +3 -3
  29. package/dist/config/endpoints.d.ts +12 -0
  30. package/dist/config/endpoints.js +7 -0
  31. package/dist/playground/index.d.ts +5 -0
  32. package/dist/playground/index.js +21 -0
  33. package/dist/playground/mount.d.ts +3 -3
  34. package/dist/playground/mount.js +30 -22
  35. package/dist/services/interruptService.d.ts +133 -0
  36. package/dist/services/interruptService.js +279 -0
  37. package/dist/stores/interruptStore.d.ts +200 -0
  38. package/dist/stores/interruptStore.js +424 -0
  39. package/dist/stores/playgroundStore.d.ts +11 -1
  40. package/dist/stores/playgroundStore.js +34 -0
  41. package/dist/styles/base.css +89 -0
  42. package/dist/types/index.d.ts +1 -1
  43. package/dist/types/interrupt.d.ts +305 -0
  44. package/dist/types/interrupt.js +126 -0
  45. package/dist/types/interruptState.d.ts +211 -0
  46. package/dist/types/interruptState.js +308 -0
  47. package/dist/utils/colors.js +1 -0
  48. package/dist/utils/connections.js +2 -2
  49. package/dist/utils/icons.js +1 -0
  50. package/package.json +1 -1
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Shibin Das (d34dman)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -137,6 +137,7 @@
137
137
  */
138
138
  function getCategoryDisplayName(category: NodeCategory): string {
139
139
  const names: Record<NodeCategory, string> = {
140
+ triggers: 'Triggers',
140
141
  inputs: 'Inputs',
141
142
  outputs: 'Outputs',
142
143
  prompts: 'Prompts',
@@ -16,7 +16,12 @@
16
16
 
17
17
  <script lang="ts">
18
18
  import { onMount, onDestroy } from 'svelte';
19
- import { EditorView, lineNumbers, highlightActiveLineGutter, drawSelection } from '@codemirror/view';
19
+ import {
20
+ EditorView,
21
+ lineNumbers,
22
+ highlightActiveLineGutter,
23
+ drawSelection
24
+ } from '@codemirror/view';
20
25
  import { EditorState } from '@codemirror/state';
21
26
  import { history, historyKeymap } from '@codemirror/commands';
22
27
  import { highlightSpecialChars, highlightActiveLine } from '@codemirror/view';
@@ -0,0 +1,389 @@
1
+ <!--
2
+ ChoicePrompt Component
3
+
4
+ Renders a selection prompt for choice-type interrupts.
5
+ Supports single selection (radio buttons) and multiple selection (checkboxes).
6
+ Shows the selected options when resolved.
7
+ Styled with BEM syntax.
8
+ -->
9
+
10
+ <script lang="ts">
11
+ import Icon from '@iconify/svelte';
12
+ import type { ChoiceConfig, InterruptChoice } from '../../types/interrupt.js';
13
+
14
+ /**
15
+ * Component props
16
+ */
17
+ interface Props {
18
+ /** Choice configuration from the interrupt */
19
+ config: ChoiceConfig;
20
+ /** Whether this interrupt has been resolved */
21
+ isResolved: boolean;
22
+ /** The resolved value(s) if resolved */
23
+ resolvedValue?: string | string[];
24
+ /** Whether the form is currently submitting */
25
+ isSubmitting: boolean;
26
+ /** Error message if submission failed */
27
+ error?: string;
28
+ /** Callback when user submits selection */
29
+ onSubmit: (value: string | string[]) => void;
30
+ }
31
+
32
+ let { config, isResolved, resolvedValue, isSubmitting, error, onSubmit }: Props = $props();
33
+
34
+ /** Local state for selected values */
35
+ let selectedValues = $state<Set<string>>(new Set());
36
+
37
+ /** Whether multiple selection is enabled */
38
+ const isMultiple = $derived(config.multiple ?? false);
39
+
40
+ /** Minimum selections required */
41
+ const minSelections = $derived(config.minSelections ?? (isMultiple ? 0 : 1));
42
+
43
+ /** Maximum selections allowed */
44
+ const maxSelections = $derived(config.maxSelections ?? (isMultiple ? config.options.length : 1));
45
+
46
+ /** Check if submit is valid */
47
+ const isValidSelection = $derived(
48
+ selectedValues.size >= minSelections && selectedValues.size <= maxSelections
49
+ );
50
+
51
+ /** Check if an option was selected in resolved state */
52
+ function isOptionResolved(option: InterruptChoice): boolean {
53
+ if (!isResolved || resolvedValue === undefined) return false;
54
+ if (Array.isArray(resolvedValue)) {
55
+ return resolvedValue.includes(option.value);
56
+ }
57
+ return resolvedValue === option.value;
58
+ }
59
+
60
+ /**
61
+ * Handle option selection/deselection
62
+ */
63
+ function handleOptionChange(option: InterruptChoice, checked: boolean): void {
64
+ if (isResolved || isSubmitting) return;
65
+
66
+ const newSelected = new Set(selectedValues);
67
+
68
+ if (isMultiple) {
69
+ if (checked) {
70
+ // Check max selections
71
+ if (newSelected.size < maxSelections) {
72
+ newSelected.add(option.value);
73
+ }
74
+ } else {
75
+ newSelected.delete(option.value);
76
+ }
77
+ } else {
78
+ // Single selection - clear and set
79
+ newSelected.clear();
80
+ if (checked) {
81
+ newSelected.add(option.value);
82
+ }
83
+ }
84
+
85
+ selectedValues = newSelected;
86
+ }
87
+
88
+ /**
89
+ * Handle form submission
90
+ */
91
+ function handleSubmit(): void {
92
+ if (!isValidSelection || isResolved || isSubmitting) return;
93
+
94
+ const values = Array.from(selectedValues);
95
+ if (isMultiple) {
96
+ onSubmit(values);
97
+ } else {
98
+ onSubmit(values[0] ?? '');
99
+ }
100
+ }
101
+ </script>
102
+
103
+ <div
104
+ class="choice-prompt"
105
+ class:choice-prompt--resolved={isResolved}
106
+ class:choice-prompt--submitting={isSubmitting}
107
+ >
108
+ <!-- Message -->
109
+ <p class="choice-prompt__message">{config.message}</p>
110
+
111
+ <!-- Error message -->
112
+ {#if error}
113
+ <div class="choice-prompt__error">
114
+ <Icon icon="mdi:alert-circle" />
115
+ <span>{error}</span>
116
+ </div>
117
+ {/if}
118
+
119
+ <!-- Options -->
120
+ <div class="choice-prompt__options" role={isMultiple ? 'group' : 'radiogroup'}>
121
+ {#each config.options as option (option.value)}
122
+ {@const isChecked = isResolved ? isOptionResolved(option) : selectedValues.has(option.value)}
123
+ <label
124
+ class="choice-prompt__option"
125
+ class:choice-prompt__option--selected={isChecked}
126
+ class:choice-prompt__option--resolved={isResolved && isChecked}
127
+ >
128
+ <input
129
+ type={isMultiple ? 'checkbox' : 'radio'}
130
+ name="choice-option"
131
+ value={option.value}
132
+ checked={isChecked}
133
+ disabled={isResolved || isSubmitting}
134
+ onchange={(e) => handleOptionChange(option, (e.target as HTMLInputElement).checked)}
135
+ class="choice-prompt__input"
136
+ />
137
+ <span class="choice-prompt__checkmark">
138
+ {#if isChecked}
139
+ <Icon icon={isMultiple ? 'mdi:checkbox-marked' : 'mdi:radiobox-marked'} />
140
+ {:else}
141
+ <Icon icon={isMultiple ? 'mdi:checkbox-blank-outline' : 'mdi:radiobox-blank'} />
142
+ {/if}
143
+ </span>
144
+ <span class="choice-prompt__option-content">
145
+ <span class="choice-prompt__option-label">{option.label}</span>
146
+ {#if option.description}
147
+ <span class="choice-prompt__option-description">{option.description}</span>
148
+ {/if}
149
+ </span>
150
+ </label>
151
+ {/each}
152
+ </div>
153
+
154
+ <!-- Selection info for multiple -->
155
+ {#if isMultiple && !isResolved}
156
+ <div class="choice-prompt__info">
157
+ <span>
158
+ {selectedValues.size} of {config.options.length} selected
159
+ {#if minSelections > 0}
160
+ (min: {minSelections})
161
+ {/if}
162
+ {#if maxSelections < config.options.length}
163
+ (max: {maxSelections})
164
+ {/if}
165
+ </span>
166
+ </div>
167
+ {/if}
168
+
169
+ <!-- Submit button (only for explicit submission) -->
170
+ {#if !isResolved}
171
+ <div class="choice-prompt__actions">
172
+ <button
173
+ type="button"
174
+ class="choice-prompt__submit"
175
+ onclick={handleSubmit}
176
+ disabled={!isValidSelection || isSubmitting}
177
+ >
178
+ {#if isSubmitting}
179
+ <span class="choice-prompt__spinner"></span>
180
+ {:else}
181
+ <Icon icon="mdi:check" />
182
+ {/if}
183
+ <span>Submit</span>
184
+ </button>
185
+ </div>
186
+ {/if}
187
+
188
+ <!-- Resolved indicator -->
189
+ {#if isResolved}
190
+ <div class="choice-prompt__resolved-badge">
191
+ <Icon icon="mdi:check-circle" />
192
+ <span>Response submitted</span>
193
+ </div>
194
+ {/if}
195
+ </div>
196
+
197
+ <style>
198
+ /* Uses design tokens from base.css: --flowdrop-interrupt-*, --color-ref-* */
199
+ .choice-prompt {
200
+ display: flex;
201
+ flex-direction: column;
202
+ gap: 0.75rem;
203
+ }
204
+
205
+ .choice-prompt--resolved {
206
+ opacity: 0.85;
207
+ }
208
+
209
+ .choice-prompt--submitting {
210
+ pointer-events: none;
211
+ }
212
+
213
+ .choice-prompt__message {
214
+ margin: 0;
215
+ font-size: 0.9375rem;
216
+ line-height: 1.5;
217
+ color: var(--color-ref-gray-800, #1f2937);
218
+ }
219
+
220
+ .choice-prompt__error {
221
+ display: flex;
222
+ align-items: center;
223
+ gap: 0.375rem;
224
+ padding: 0.5rem 0.75rem;
225
+ background-color: var(--color-ref-red-50, #fef2f2);
226
+ border-radius: 0.375rem;
227
+ color: var(--color-ref-red-600, #dc2626);
228
+ font-size: 0.8125rem;
229
+ }
230
+
231
+ .choice-prompt__options {
232
+ display: flex;
233
+ flex-direction: column;
234
+ gap: 0.5rem;
235
+ }
236
+
237
+ .choice-prompt__option {
238
+ display: flex;
239
+ align-items: flex-start;
240
+ gap: 0.75rem;
241
+ padding: 0.75rem 1rem;
242
+ background-color: var(--color-ref-gray-50, #f9fafb);
243
+ border: 1px solid var(--color-ref-gray-200, #e5e7eb);
244
+ border-radius: 0.5rem;
245
+ cursor: pointer;
246
+ transition: all 0.15s ease;
247
+ }
248
+
249
+ .choice-prompt__option:hover:not(.choice-prompt--resolved .choice-prompt__option) {
250
+ background-color: var(--color-ref-gray-100, #f3f4f6);
251
+ border-color: var(--color-ref-gray-300, #d1d5db);
252
+ }
253
+
254
+ .choice-prompt__option--selected {
255
+ background-color: var(--color-ref-blue-50, #eff6ff);
256
+ border-color: var(--flowdrop-interrupt-completed-border);
257
+ }
258
+
259
+ .choice-prompt__option--selected:hover:not(.choice-prompt--resolved .choice-prompt__option) {
260
+ background-color: var(--color-ref-blue-100, #dbeafe);
261
+ }
262
+
263
+ /* Resolved option - neutral blue theme */
264
+ .choice-prompt__option--resolved {
265
+ background-color: var(--color-ref-blue-50, #eff6ff);
266
+ border-color: var(--flowdrop-interrupt-completed-border);
267
+ cursor: default;
268
+ }
269
+
270
+ .choice-prompt--resolved .choice-prompt__option:not(.choice-prompt__option--resolved) {
271
+ opacity: var(--flowdrop-interrupt-not-selected-opacity);
272
+ cursor: default;
273
+ }
274
+
275
+ .choice-prompt__input {
276
+ position: absolute;
277
+ opacity: 0;
278
+ width: 0;
279
+ height: 0;
280
+ }
281
+
282
+ .choice-prompt__checkmark {
283
+ flex-shrink: 0;
284
+ font-size: 1.25rem;
285
+ color: var(--color-ref-gray-400, #9ca3af);
286
+ display: flex;
287
+ align-items: center;
288
+ justify-content: center;
289
+ }
290
+
291
+ .choice-prompt__option--selected .choice-prompt__checkmark {
292
+ color: var(--flowdrop-interrupt-completed-border);
293
+ }
294
+
295
+ .choice-prompt__option--resolved .choice-prompt__checkmark {
296
+ color: var(--flowdrop-interrupt-completed-border);
297
+ }
298
+
299
+ .choice-prompt__option-content {
300
+ display: flex;
301
+ flex-direction: column;
302
+ gap: 0.125rem;
303
+ }
304
+
305
+ .choice-prompt__option-label {
306
+ font-size: 0.875rem;
307
+ font-weight: 500;
308
+ color: var(--color-ref-gray-800, #1f2937);
309
+ }
310
+
311
+ .choice-prompt__option-description {
312
+ font-size: 0.8125rem;
313
+ color: var(--color-ref-gray-500, #6b7280);
314
+ line-height: 1.4;
315
+ }
316
+
317
+ .choice-prompt__info {
318
+ font-size: 0.75rem;
319
+ color: var(--color-ref-gray-500, #6b7280);
320
+ padding-left: 0.25rem;
321
+ }
322
+
323
+ .choice-prompt__actions {
324
+ display: flex;
325
+ gap: 0.75rem;
326
+ margin-top: 0.25rem;
327
+ }
328
+
329
+ .choice-prompt__submit {
330
+ display: inline-flex;
331
+ align-items: center;
332
+ justify-content: center;
333
+ gap: 0.5rem;
334
+ padding: 0.625rem 1.25rem;
335
+ border-radius: 0.5rem;
336
+ font-size: 0.875rem;
337
+ font-weight: 600;
338
+ font-family: inherit;
339
+ cursor: pointer;
340
+ transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
341
+ border: none;
342
+ min-height: 2.5rem;
343
+ background: var(--flowdrop-interrupt-btn-primary-bg);
344
+ color: #ffffff;
345
+ box-shadow: 0 1px 3px var(--flowdrop-interrupt-btn-primary-shadow);
346
+ }
347
+
348
+ .choice-prompt__submit:hover:not(:disabled) {
349
+ background: var(--flowdrop-interrupt-btn-primary-bg-hover);
350
+ box-shadow: 0 4px 12px var(--flowdrop-interrupt-btn-primary-shadow);
351
+ transform: translateY(-1px);
352
+ }
353
+
354
+ .choice-prompt__submit:disabled {
355
+ opacity: 0.5;
356
+ cursor: not-allowed;
357
+ transform: none;
358
+ box-shadow: none;
359
+ }
360
+
361
+ .choice-prompt__spinner {
362
+ width: 1rem;
363
+ height: 1rem;
364
+ border: 2px solid rgba(255, 255, 255, 0.3);
365
+ border-top-color: #ffffff;
366
+ border-radius: 50%;
367
+ animation: choice-spin 0.6s linear infinite;
368
+ }
369
+
370
+ @keyframes choice-spin {
371
+ to {
372
+ transform: rotate(360deg);
373
+ }
374
+ }
375
+
376
+ /* Resolved badge - neutral blue theme */
377
+ .choice-prompt__resolved-badge {
378
+ display: inline-flex;
379
+ align-items: center;
380
+ gap: 0.375rem;
381
+ padding: 0.375rem 0.75rem;
382
+ background-color: var(--flowdrop-interrupt-badge-completed-bg);
383
+ border-radius: 9999px;
384
+ color: var(--flowdrop-interrupt-badge-completed-text);
385
+ font-size: 0.75rem;
386
+ font-weight: 500;
387
+ align-self: flex-start;
388
+ }
389
+ </style>
@@ -0,0 +1,21 @@
1
+ import type { ChoiceConfig } from '../../types/interrupt.js';
2
+ /**
3
+ * Component props
4
+ */
5
+ interface Props {
6
+ /** Choice configuration from the interrupt */
7
+ config: ChoiceConfig;
8
+ /** Whether this interrupt has been resolved */
9
+ isResolved: boolean;
10
+ /** The resolved value(s) if resolved */
11
+ resolvedValue?: string | string[];
12
+ /** Whether the form is currently submitting */
13
+ isSubmitting: boolean;
14
+ /** Error message if submission failed */
15
+ error?: string;
16
+ /** Callback when user submits selection */
17
+ onSubmit: (value: string | string[]) => void;
18
+ }
19
+ declare const ChoicePrompt: import("svelte").Component<Props, {}, "">;
20
+ type ChoicePrompt = ReturnType<typeof ChoicePrompt>;
21
+ export default ChoicePrompt;