@flowdrop/flowdrop 2.4.0 → 2.6.0

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 (57) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/chat/commandClassifier.d.ts +17 -0
  3. package/dist/chat/commandClassifier.js +29 -0
  4. package/dist/chat/index.d.ts +1 -1
  5. package/dist/chat/index.js +1 -1
  6. package/dist/components/App.svelte +8 -0
  7. package/dist/components/BindablePortListbox.svelte +426 -0
  8. package/dist/components/BindablePortListbox.svelte.d.ts +23 -0
  9. package/dist/components/WorkflowInterfaceEditor.svelte +142 -36
  10. package/dist/components/WorkflowInterfaceEditor.svelte.d.ts +8 -0
  11. package/dist/components/WorkflowInterfaceEntryCard.svelte +537 -294
  12. package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +6 -3
  13. package/dist/components/WorkflowInterfaceEntryComposer.svelte +331 -0
  14. package/dist/components/WorkflowInterfaceEntryComposer.svelte.d.ts +19 -0
  15. package/dist/config/defaultPortConfig.js +27 -9
  16. package/dist/messages/context.d.ts +6 -0
  17. package/dist/messages/context.js +8 -0
  18. package/dist/messages/defaults.d.ts +45 -2
  19. package/dist/messages/defaults.js +36 -3
  20. package/dist/messages/index.d.ts +1 -1
  21. package/dist/messages/index.js +1 -1
  22. package/dist/openapi/v1/openapi.yaml +14 -1
  23. package/dist/schemas/v1/workflow.schema.json +9 -2
  24. package/dist/stores/instanceContainer.svelte.d.ts +26 -0
  25. package/dist/stores/instanceContainer.svelte.js +24 -0
  26. package/dist/stories/WebMCPFakeAgent.svelte +229 -0
  27. package/dist/stories/WebMCPFakeAgent.svelte.d.ts +10 -0
  28. package/dist/styles/base.css +4 -2
  29. package/dist/styles/tokens.css +20 -0
  30. package/dist/svelte-app.d.ts +20 -0
  31. package/dist/svelte-app.js +49 -1
  32. package/dist/types/index.d.ts +26 -1
  33. package/dist/utils/focus.d.ts +18 -0
  34. package/dist/utils/focus.js +24 -0
  35. package/dist/utils/whenWorkflowLoaded.svelte.d.ts +17 -0
  36. package/dist/utils/whenWorkflowLoaded.svelte.js +42 -0
  37. package/dist/utils/workflowInterface.d.ts +47 -3
  38. package/dist/utils/workflowInterface.js +84 -9
  39. package/dist/webmcp/WebMCP.stories.svelte +101 -0
  40. package/dist/webmcp/WebMCP.stories.svelte.d.ts +18 -0
  41. package/dist/webmcp/WebMCPConfirm.svelte +170 -0
  42. package/dist/webmcp/WebMCPConfirm.svelte.d.ts +11 -0
  43. package/dist/webmcp/descriptors.d.ts +59 -0
  44. package/dist/webmcp/descriptors.js +464 -0
  45. package/dist/webmcp/fake.d.ts +23 -0
  46. package/dist/webmcp/fake.js +42 -0
  47. package/dist/webmcp/gate.d.ts +40 -0
  48. package/dist/webmcp/gate.js +92 -0
  49. package/dist/webmcp/index.d.ts +34 -0
  50. package/dist/webmcp/index.js +31 -0
  51. package/dist/webmcp/register.d.ts +33 -0
  52. package/dist/webmcp/register.js +267 -0
  53. package/dist/webmcp/types.d.ts +166 -0
  54. package/dist/webmcp/types.js +23 -0
  55. package/dist/webmcp/validate.d.ts +32 -0
  56. package/dist/webmcp/validate.js +118 -0
  57. package/package.json +6 -1
@@ -28,8 +28,10 @@
28
28
  import Icon from '@iconify/svelte';
29
29
  import { m } from '../messages/index.js';
30
30
  import WorkflowInterfaceEntryCard from './WorkflowInterfaceEntryCard.svelte';
31
+ import WorkflowInterfaceEntryComposer from './WorkflowInterfaceEntryComposer.svelte';
31
32
  import { buildHandleId } from '../utils/handleIds.js';
32
33
  import { DEFAULT_PORT_CONFIG } from '../config/defaultPortConfig.js';
34
+ import { PortCompatibilityChecker } from '../utils/connections.js';
33
35
  import type {
34
36
  PortDataTypeConfig,
35
37
  Workflow,
@@ -37,10 +39,12 @@
37
39
  WorkflowInterfaceEntry
38
40
  } from '../types/index.js';
39
41
  import {
40
- listBindablePorts,
42
+ entryFromBindablePort,
43
+ rankBindablePorts,
41
44
  resolveInterface,
42
45
  validateWorkflowInterface,
43
46
  type InterfaceIssue,
47
+ type RankedBindablePort,
44
48
  type ResolvedInterfaceEntry
45
49
  } from '../utils/workflowInterface.js';
46
50
 
@@ -53,12 +57,20 @@
53
57
  * The wire format stays an open string; this only constrains *authoring*.
54
58
  */
55
59
  dataTypes?: PortDataTypeConfig[];
60
+ /**
61
+ * The instance's port-compatibility checker (pass `fd.portCompatibility`).
62
+ * The composer's port picker draws each candidate with the canvas's shape
63
+ * symbol and lane chip, and both read the checker for shape and colour.
64
+ * Defaults to a checker over the built-in port config.
65
+ */
66
+ checker?: PortCompatibilityChecker;
56
67
  }
57
68
 
58
69
  const {
59
70
  workflow,
60
71
  onChange,
61
- dataTypes = DEFAULT_PORT_CONFIG.dataTypes.filter((dt) => dt.enabled !== false)
72
+ dataTypes = DEFAULT_PORT_CONFIG.dataTypes.filter((dt) => dt.enabled !== false),
73
+ checker = new PortCompatibilityChecker(DEFAULT_PORT_CONFIG)
62
74
  }: Props = $props();
63
75
 
64
76
  type Direction = 'inputs' | 'outputs';
@@ -181,7 +193,7 @@
181
193
  });
182
194
 
183
195
  function bindablePorts(direction: Direction) {
184
- return listBindablePorts(workflow, entryDirectionOf(direction));
196
+ return rankBindablePorts(workflow, entryDirectionOf(direction));
185
197
  }
186
198
 
187
199
  function nextId(direction: Direction): string {
@@ -223,12 +235,38 @@
223
235
  });
224
236
  }
225
237
 
226
- function addEntry(direction: Direction): void {
227
- const entry: WorkflowInterfaceEntry = { id: nextId(direction), dataType: '', bindings: [] };
238
+ /**
239
+ * Which section's "Add" composer is open, if any. One at a time: opening
240
+ * the other side's closes this one, and adding or cancelling closes it.
241
+ */
242
+ let composerFor = $state<Direction | null>(null);
243
+
244
+ function toggleComposer(direction: Direction): void {
245
+ composerFor = composerFor === direction ? null : direction;
246
+ }
247
+
248
+ function appendEntry(direction: Direction, entry: WorkflowInterfaceEntry): void {
228
249
  // A row id of its own, so adding an entry leaves every other card — and
229
250
  // every other card's disclosure — exactly as the author left it.
230
251
  rowIds[direction] = [...rowIds[direction], mintRowId()];
231
252
  commit(direction, [...entriesFor(direction), entry]);
253
+ composerFor = null;
254
+ }
255
+
256
+ /** The composer's "no, custom" path: an empty, unbound entry with a generated id. */
257
+ function addEntry(direction: Direction): void {
258
+ appendEntry(direction, { id: nextId(direction), dataType: '', bindings: [] });
259
+ }
260
+
261
+ /** The composer's "yes, bind" path: an entry pulled from the picked port. */
262
+ function addBoundEntry(direction: Direction, candidate: RankedBindablePort): void {
263
+ appendEntry(
264
+ direction,
265
+ entryFromBindablePort(
266
+ candidate,
267
+ entriesFor(direction).map((entry) => entry.id)
268
+ )
269
+ );
232
270
  }
233
271
 
234
272
  function removeEntry(direction: Direction, index: number): void {
@@ -268,28 +306,24 @@
268
306
  <div class="wf-interface">
269
307
  {#each SECTIONS as section (section.key)}
270
308
  {@const list = entriesFor(section.key)}
271
- <div class="wf-interface__section">
309
+ <section class="wf-interface__section">
272
310
  <div class="wf-interface__section-header">
273
311
  <h4 class="wf-interface__section-title">
312
+ <Icon
313
+ icon={section.key === 'inputs'
314
+ ? 'heroicons:arrow-right-end-on-rectangle'
315
+ : 'heroicons:arrow-right-start-on-rectangle'}
316
+ />
274
317
  {section.key === 'inputs'
275
318
  ? m().workflowInterface.inputsHeading
276
319
  : m().workflowInterface.outputsHeading}
320
+ {#if list.length > 0}
321
+ <span class="wf-interface__count">{list.length}</span>
322
+ {/if}
277
323
  </h4>
278
- <button type="button" class="wf-interface__add" onclick={() => addEntry(section.key)}>
279
- <Icon icon="heroicons:plus" />
280
- {section.key === 'inputs'
281
- ? m().workflowInterface.addInput
282
- : m().workflowInterface.addOutput}
283
- </button>
284
324
  </div>
285
325
 
286
- {#if list.length === 0}
287
- <p class="wf-interface__empty">
288
- {section.key === 'inputs'
289
- ? m().workflowInterface.noInputs
290
- : m().workflowInterface.noOutputs}
291
- </p>
292
- {:else}
326
+ {#if list.length > 0}
293
327
  <ul class="wf-interface__list">
294
328
  {#each list as entry, index (rowIds[section.key][index] ?? `pending-${index}`)}
295
329
  {@const status = statusFor(section.key, entry.id)}
@@ -297,6 +331,7 @@
297
331
  {entry}
298
332
  {status}
299
333
  {dataTypes}
334
+ {checker}
300
335
  direction={section.key}
301
336
  candidates={bindablePorts(section.key)}
302
337
  footerIssues={footerIssues(section.key, entry.id, status)}
@@ -316,30 +351,64 @@
316
351
  {/each}
317
352
  </ul>
318
353
  {/if}
319
- </div>
354
+
355
+ <!-- The insertion point, always shown: a new entry lands here, at the end
356
+ of the list. The dashed slot is the add action; while the composer is
357
+ open it takes the slot's place, so the draft sits exactly where the
358
+ entry it becomes will sit. Doubles as the empty state — an empty side
359
+ is a side with only its insertion point. -->
360
+ {#if composerFor === section.key}
361
+ <WorkflowInterfaceEntryComposer
362
+ direction={section.key}
363
+ candidates={bindablePorts(section.key)}
364
+ {checker}
365
+ onBind={(candidate) => addBoundEntry(section.key, candidate)}
366
+ onCustom={() => addEntry(section.key)}
367
+ onCancel={() => (composerFor = null)}
368
+ />
369
+ {:else}
370
+ <button type="button" class="wf-interface__add" onclick={() => toggleComposer(section.key)}>
371
+ <Icon icon="heroicons:plus" />
372
+ {section.key === 'inputs'
373
+ ? m().workflowInterface.addInput
374
+ : m().workflowInterface.addOutput}
375
+ </button>
376
+ {/if}
377
+ </section>
320
378
  {/each}
321
379
  </div>
322
380
 
323
381
  <style>
382
+ /*
383
+ Two sections — inputs, outputs — in the visual family of the settings
384
+ form this editor sits beside: the same section-title voice as
385
+ `.config-surface__section-title`, the shared `.flowdrop-btn` for the add
386
+ action as a dashed insertion slot at the end of each side.
387
+ */
324
388
  .wf-interface {
325
389
  display: flex;
326
390
  flex-direction: column;
327
- gap: var(--fd-space-lg, 1.5rem);
391
+ gap: var(--fd-space-xl);
328
392
  }
329
393
 
330
394
  .wf-interface__section {
331
395
  display: flex;
332
396
  flex-direction: column;
333
- gap: var(--fd-space-xs);
397
+ gap: var(--fd-space-sm);
334
398
  }
335
399
 
336
400
  .wf-interface__section-header {
337
401
  display: flex;
338
402
  align-items: center;
339
403
  justify-content: space-between;
404
+ gap: var(--fd-space-sm);
405
+ min-height: 2rem;
340
406
  }
341
407
 
342
408
  .wf-interface__section-title {
409
+ display: inline-flex;
410
+ align-items: center;
411
+ gap: var(--fd-space-xs);
343
412
  margin: 0;
344
413
  font-size: var(--fd-text-xs);
345
414
  font-weight: 600;
@@ -348,28 +417,65 @@
348
417
  letter-spacing: 0.05em;
349
418
  }
350
419
 
351
- .wf-interface__add {
420
+ .wf-interface__section-title :global(svg) {
421
+ font-size: 0.875rem;
422
+ }
423
+
424
+ .wf-interface__count {
352
425
  display: inline-flex;
353
426
  align-items: center;
354
- gap: 0.25rem;
355
- padding: 0.25rem 0.5rem;
356
- border-radius: var(--fd-radius-sm);
357
- border: 1px solid var(--fd-border);
358
- background: var(--fd-background);
359
- color: var(--fd-foreground);
427
+ justify-content: center;
428
+ min-width: 1.25rem;
429
+ height: 1.125rem;
430
+ padding: 0 0.375rem;
431
+ border-radius: var(--fd-radius-full);
432
+ background-color: var(--fd-muted);
433
+ color: var(--fd-muted-foreground);
434
+ font-size: var(--fd-text-2xs);
435
+ font-weight: 600;
436
+ letter-spacing: 0;
437
+ font-variant-numeric: tabular-nums;
438
+ }
439
+
440
+ /* The insertion slot: a dashed, full-width add action where the next entry
441
+ will appear. Quiet at rest, primary on hover and focus. */
442
+ .wf-interface__add {
443
+ display: flex;
444
+ align-items: center;
445
+ justify-content: center;
446
+ gap: var(--fd-space-xs);
447
+ width: 100%;
448
+ min-height: 2.5rem;
449
+ padding: var(--fd-space-sm);
450
+ border: 1px dashed var(--fd-border-strong);
451
+ border-radius: var(--fd-radius-lg);
452
+ background-color: transparent;
453
+ color: var(--fd-muted-foreground);
454
+ font: inherit;
360
455
  font-size: var(--fd-text-xs);
456
+ font-weight: 600;
361
457
  cursor: pointer;
458
+ transition:
459
+ border-color var(--fd-transition-fast),
460
+ background-color var(--fd-transition-fast),
461
+ color var(--fd-transition-fast);
362
462
  }
363
463
 
364
464
  .wf-interface__add:hover {
365
- background: var(--fd-muted);
465
+ border-color: var(--fd-primary);
466
+ background-color: var(--fd-primary-muted);
467
+ color: var(--fd-primary);
366
468
  }
367
469
 
368
- .wf-interface__empty {
369
- margin: 0;
370
- font-size: var(--fd-text-xs);
371
- color: var(--fd-muted-foreground);
372
- font-style: italic;
470
+ .wf-interface__add:focus-visible {
471
+ outline: none;
472
+ border-color: var(--fd-primary);
473
+ color: var(--fd-primary);
474
+ box-shadow: 0 0 0 var(--fd-ring-width) var(--fd-primary-muted);
475
+ }
476
+
477
+ .wf-interface__add :global(svg) {
478
+ font-size: 0.875rem;
373
479
  }
374
480
 
375
481
  .wf-interface__list {
@@ -378,6 +484,6 @@
378
484
  padding: 0;
379
485
  display: flex;
380
486
  flex-direction: column;
381
- gap: var(--fd-space-xs);
487
+ gap: var(--fd-space-sm);
382
488
  }
383
489
  </style>
@@ -1,3 +1,4 @@
1
+ import { PortCompatibilityChecker } from '../utils/connections.js';
1
2
  import type { PortDataTypeConfig, Workflow, WorkflowInterface } from '../types/index.js';
2
3
  interface Props {
3
4
  workflow: Workflow;
@@ -8,6 +9,13 @@ interface Props {
8
9
  * The wire format stays an open string; this only constrains *authoring*.
9
10
  */
10
11
  dataTypes?: PortDataTypeConfig[];
12
+ /**
13
+ * The instance's port-compatibility checker (pass `fd.portCompatibility`).
14
+ * The composer's port picker draws each candidate with the canvas's shape
15
+ * symbol and lane chip, and both read the checker for shape and colour.
16
+ * Defaults to a checker over the built-in port config.
17
+ */
18
+ checker?: PortCompatibilityChecker;
11
19
  }
12
20
  declare const WorkflowInterfaceEditor: import("svelte").Component<Props, {}, "">;
13
21
  type WorkflowInterfaceEditor = ReturnType<typeof WorkflowInterfaceEditor>;