@flowdrop/flowdrop 2.0.1 → 2.1.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 (34) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/commands/executor.js +4 -1
  3. package/dist/commands/types.d.ts +4 -0
  4. package/dist/components/App.svelte +122 -12
  5. package/dist/components/WorkflowInterfaceEditor.svelte +941 -0
  6. package/dist/components/WorkflowInterfaceEditor.svelte.d.ts +14 -0
  7. package/dist/components/form/FormPorts.svelte +34 -2
  8. package/dist/components/nodes/GatewayNode.svelte +13 -1
  9. package/dist/components/nodes/SimpleNode.svelte +11 -0
  10. package/dist/components/nodes/SquareNode.svelte +11 -0
  11. package/dist/components/nodes/TerminalNode.svelte +11 -0
  12. package/dist/components/nodes/WorkflowNode.svelte +11 -2
  13. package/dist/core/index.d.ts +1 -1
  14. package/dist/messages/defaults.d.ts +42 -0
  15. package/dist/messages/defaults.js +34 -0
  16. package/dist/openapi/v1/openapi.yaml +105 -0
  17. package/dist/schemas/v1/workflow.schema.json +109 -0
  18. package/dist/services/workflowLaunchService.d.ts +13 -1
  19. package/dist/services/workflowLaunchService.js +8 -0
  20. package/dist/stores/workflowStore.svelte.d.ts +22 -0
  21. package/dist/stores/workflowStore.svelte.js +18 -0
  22. package/dist/styles/base.css +10 -0
  23. package/dist/types/index.d.ts +58 -4
  24. package/dist/utils/colors.d.ts +1 -2
  25. package/dist/utils/colors.js +1 -2
  26. package/dist/utils/connections.d.ts +5 -0
  27. package/dist/utils/connections.js +1 -1
  28. package/dist/utils/nodeSwap.d.ts +9 -0
  29. package/dist/utils/nodeSwap.js +50 -2
  30. package/dist/utils/portUtils.d.ts +0 -2
  31. package/dist/utils/portUtils.js +0 -2
  32. package/dist/utils/workflowInterface.d.ts +199 -0
  33. package/dist/utils/workflowInterface.js +382 -0
  34. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.1.0] - 2026-08-18
11
+
12
+ **The workflow interface release.** A workflow can now declare its public call signature — named inputs and outputs bound to internal node ports — and author it in a dedicated settings panel. Entirely additive: workflows without an `interface` behave exactly as before.
13
+
14
+ ### Added
15
+
16
+ - **`Workflow.interface`** — the workflow's public contract. New `/core` types `WorkflowInterface`, `WorkflowInterfaceEntry`, and `PortBinding`: each entry maps a stable public `id` (plus optional `name`, `description`, `dataType`, `required`, `defaultValue`, `examples`, `schema`, and server-owned `meta`) to exactly one internal port binding. Control-flow ports (`trigger`/`tool` data types and the loop-back port) are not bindable — they are orchestration, not call signature.
17
+ - **Interface panel in workflow settings.** The workflow settings dialog gains an Interface tab powered by the new `WorkflowInterfaceEditor`: per-entry status dot (ok, unbound, dangling, hidden, over-bound, type mismatch) with plain-language explanations, a binding picker limited to exposed ports, and an inline "already receives a value from …" conflict message when a bound input port also has an incoming edge.
18
+ - **Progressive disclosure + "Pull from port".** An entry's resting state is just its public id and binding; name, data type (with a one-click "Use port type" mismatch fix), required, description, default value, and examples sit behind a "More options" disclosure that auto-opens on a type mismatch. A "Pull from port" button copies the bound port's declared fields into the entry — it never derives the public `id` from the internal port name.
19
+ - **Example values for callers.** `WorkflowInterfaceEntry.examples` (inputs only, never validated against `schema`) with add/remove editing in the panel.
20
+ - **Launch preflight.** `workflowLaunchService` accepts the `workflow` in its launch options and validates the provided inputs against the declared interface before any network call — unknown input keys and missing required inputs (honoring `defaultValue`) return an `invalid-input` result locally.
21
+ - **Canvas marker for bound ports.** Port handles referenced by an interface binding render a ring (themeable via `--fd-ring`), so the workflow's public surface is visible on the canvas itself.
22
+ - **Data types from the instance vocabulary.** The panel's data-type select is sourced from the instance's port configuration (`fd.portCompatibility.getEnabledDataTypes()`); a stored value outside the vocabulary is kept as an extra option instead of being silently dropped.
23
+ - **API surface.** `interface` schemas in the OpenAPI spec and the generated workflow JSON schema; the `demo_tool_workflow` mock fixture exercises the full contract. New `workflowInterface` message-catalog domain for every string in the panel.
24
+
25
+ ### Changed
26
+
27
+ - **Node swap preserves the interface.** Swapping a node rewrites interface bindings to the replacement node's mapped ports in the same history entry, so undo restores both the graph and the contract together.
28
+
10
29
  ## [2.0.1] - 2026-08-14
11
30
 
12
31
  ### Fixed
@@ -904,7 +904,10 @@ function executeSwapNode(command, context) {
904
904
  if (context.dispatch.swapNode) {
905
905
  context.dispatch.swapNode({
906
906
  nodes: swapResult.updatedNodes,
907
- edges: swapResult.updatedEdges
907
+ edges: swapResult.updatedEdges,
908
+ oldNodeId: node.id,
909
+ newNodeId: preview.newNodeId,
910
+ portMappings: preview.portMappings
908
911
  });
909
912
  }
910
913
  else {
@@ -7,6 +7,7 @@
7
7
  * @module commands/types
8
8
  */
9
9
  import type { NodeMetadata, Workflow, WorkflowNode, WorkflowEdge } from '../types/index.js';
10
+ import type { PortMapping } from '../utils/nodeSwap.js';
10
11
  export interface AddNodeCommand {
11
12
  type: 'add_node';
12
13
  nodeTypeId: string;
@@ -320,6 +321,9 @@ export interface CommandDispatch {
320
321
  swapNode?: (updates: {
321
322
  nodes: WorkflowNode[];
322
323
  edges: WorkflowEdge[];
324
+ oldNodeId?: string;
325
+ newNodeId?: string;
326
+ portMappings?: PortMapping[];
323
327
  }) => void;
324
328
  }
325
329
  export interface CommandContext {
@@ -15,6 +15,7 @@
15
15
  import MenuOpenIcon from './icons/MenuOpenIcon.svelte';
16
16
  import ConfigForm from './ConfigForm.svelte';
17
17
  import ConfigPanel from './ConfigPanel.svelte';
18
+ import WorkflowInterfaceEditor from './WorkflowInterfaceEditor.svelte';
18
19
  import ReadOnlyDetails from './ReadOnlyDetails.svelte';
19
20
  import CommandConsole from './console/CommandConsole.svelte';
20
21
  import AIChatPanel from './chat/AIChatPanel.svelte';
@@ -350,6 +351,10 @@
350
351
 
351
352
  // Workflow settings sidebar state
352
353
  let isWorkflowSettingsOpen = $state(false);
354
+ // Inner tab within the workflow-settings surface — see Phase 3 of
355
+ // `.claude/plans/workflow-interface.md`. Settings and the interface editor
356
+ // are two tabs of one surface, not a field inside the settings form.
357
+ let workflowSettingsTab = $state<'settings' | 'interface'>('settings');
353
358
 
354
359
  // Which surface (`config` | `console` | `chat`) is focused in its host. A
355
360
  // single selector across hosts: each TabbedSurface highlights this id when it
@@ -362,7 +367,9 @@
362
367
  let swapInteractiveState = $state<InteractiveSwapState | null>(null);
363
368
 
364
369
  // Built-in workflow settings field names — consumer schemas must not reuse these.
365
- const WORKFLOW_SETTINGS_RESERVED = new Set(['name', 'description', 'format']);
370
+ // 'interface' is reserved too: it names `Workflow.interface`'s own tab, not a
371
+ // workflowSettingsSchema field, but a consumer schema could still collide.
372
+ const WORKFLOW_SETTINGS_RESERVED = new Set(['name', 'description', 'format', 'interface']);
366
373
 
367
374
  // Workflow configuration schema (derived to pick up dynamic format options)
368
375
  let workflowConfigSchema: ConfigSchema = $derived.by(() => {
@@ -685,7 +692,10 @@
685
692
  fd.workflow.swapNode({
686
693
  nodes: result.updatedNodes,
687
694
  edges: result.updatedEdges,
688
- description: `Swap node: ${oldLabel} → ${newLabel}`
695
+ description: `Swap node: ${oldLabel} → ${newLabel}`,
696
+ oldNodeId: state.oldNode.id,
697
+ newNodeId: state.newNodeId,
698
+ portMappings: preview.portMappings
689
699
  });
690
700
 
691
701
  // onAfterSwap hook (fire-and-forget — swap is already applied)
@@ -1206,6 +1216,66 @@
1206
1216
  />
1207
1217
  {/snippet}
1208
1218
 
1219
+ <!--
1220
+ The canonical Workflow.interface editor (Phase 3 of
1221
+ `.claude/plans/workflow-interface.md`). Edits route through
1222
+ `fd.workflow.batchUpdate`, so history covers them like any other workflow
1223
+ mutation.
1224
+ -->
1225
+ {#snippet workflowInterfaceEl()}
1226
+ {#if fd.workflow.current}
1227
+ <WorkflowInterfaceEditor
1228
+ workflow={fd.workflow.current}
1229
+ dataTypes={fd.portCompatibility.getEnabledDataTypes()}
1230
+ onChange={(next) => fd.workflow.batchUpdate({ interface: next })}
1231
+ />
1232
+ {/if}
1233
+ {/snippet}
1234
+
1235
+ <!--
1236
+ Two tabs of the workflow-settings surface: the schema-driven settings form,
1237
+ and the interface editor. A tab, not a field in the settings form — see
1238
+ Phase 3's rationale (`ConfigForm` cannot express a bindings list).
1239
+ -->
1240
+ {#snippet workflowSettingsTabs()}
1241
+ <div class="workflow-settings-tabs">
1242
+ <div class="workflow-settings-tabs__bar" role="tablist">
1243
+ <button
1244
+ type="button"
1245
+ role="tab"
1246
+ aria-selected={workflowSettingsTab === 'settings'}
1247
+ class="workflow-settings-tabs__tab"
1248
+ class:workflow-settings-tabs__tab--active={workflowSettingsTab === 'settings'}
1249
+ onclick={() => (workflowSettingsTab = 'settings')}
1250
+ >
1251
+ {mergedMessages.navigation.workflowSettingsPanelSubtitle}
1252
+ </button>
1253
+ <button
1254
+ type="button"
1255
+ role="tab"
1256
+ aria-selected={workflowSettingsTab === 'interface'}
1257
+ class="workflow-settings-tabs__tab"
1258
+ class:workflow-settings-tabs__tab--active={workflowSettingsTab === 'interface'}
1259
+ onclick={() => (workflowSettingsTab = 'interface')}
1260
+ >
1261
+ {mergedMessages.navigation.workflowSettingsInterfaceTab}
1262
+ </button>
1263
+ </div>
1264
+ <div
1265
+ class="workflow-settings-tabs__panel"
1266
+ style:display={workflowSettingsTab === 'settings' ? 'block' : 'none'}
1267
+ >
1268
+ {@render workflowConfigFormEl()}
1269
+ </div>
1270
+ <div
1271
+ class="workflow-settings-tabs__panel"
1272
+ style:display={workflowSettingsTab === 'interface' ? 'block' : 'none'}
1273
+ >
1274
+ {@render workflowInterfaceEl()}
1275
+ </div>
1276
+ </div>
1277
+ {/snippet}
1278
+
1209
1279
  <!--
1210
1280
  Chromeless config body for tabbed/overlay hosts. `showHeader` draws a slim
1211
1281
  title + close bar when the host doesn't provide one (bottom / shared sidebar);
@@ -1236,16 +1306,16 @@
1236
1306
  </div>
1237
1307
  {/if}
1238
1308
  <div class="config-surface__content">
1239
- <div class="config-surface__section">
1240
- <h3 class="config-surface__section-title">
1241
- {activeConfig.configTitle ?? 'Configuration'}
1242
- </h3>
1243
- {#if activeConfig.kind === 'node'}
1309
+ {#if activeConfig.kind === 'node'}
1310
+ <div class="config-surface__section">
1311
+ <h3 class="config-surface__section-title">
1312
+ {activeConfig.configTitle ?? 'Configuration'}
1313
+ </h3>
1244
1314
  {@render nodeConfigFormEl(activeConfig.node)}
1245
- {:else}
1246
- {@render workflowConfigFormEl()}
1247
- {/if}
1248
- </div>
1315
+ </div>
1316
+ {:else}
1317
+ {@render workflowSettingsTabs()}
1318
+ {/if}
1249
1319
  </div>
1250
1320
  </div>
1251
1321
  {/if}
@@ -1313,7 +1383,7 @@
1313
1383
  {#if activeConfig.kind === 'node'}
1314
1384
  {@render nodeConfigFormEl(activeConfig.node)}
1315
1385
  {:else}
1316
- {@render workflowConfigFormEl()}
1386
+ {@render workflowSettingsTabs()}
1317
1387
  {/if}
1318
1388
  </ConfigPanel>
1319
1389
  {/if}
@@ -1667,4 +1737,44 @@
1667
1737
  text-transform: uppercase;
1668
1738
  letter-spacing: 0.05em;
1669
1739
  }
1740
+
1741
+ /*
1742
+ Inner tab strip for the workflow-settings surface — Settings vs. Interface
1743
+ (Phase 3 of `.claude/plans/workflow-interface.md`). Deliberately not the
1744
+ `TabbedSurface` component: that one governs which *host* a surface lives in
1745
+ (sidebar/modal/below); this is a surface's own internal navigation, sitting
1746
+ inside whichever host already scrolls it.
1747
+ */
1748
+ .workflow-settings-tabs {
1749
+ display: flex;
1750
+ flex-direction: column;
1751
+ gap: var(--fd-space-xs, 0.5rem);
1752
+ }
1753
+
1754
+ .workflow-settings-tabs__bar {
1755
+ display: flex;
1756
+ gap: 0;
1757
+ border-bottom: 1px solid var(--fd-border);
1758
+ }
1759
+
1760
+ .workflow-settings-tabs__tab {
1761
+ padding: 0.375rem 0.75rem;
1762
+ font-size: var(--fd-text-xs);
1763
+ font-weight: 500;
1764
+ cursor: pointer;
1765
+ border: none;
1766
+ border-bottom: 2px solid transparent;
1767
+ background: transparent;
1768
+ color: var(--fd-muted-foreground);
1769
+ transition: all var(--fd-transition-fast);
1770
+ }
1771
+
1772
+ .workflow-settings-tabs__tab:hover {
1773
+ color: var(--fd-foreground);
1774
+ }
1775
+
1776
+ .workflow-settings-tabs__tab--active {
1777
+ color: var(--fd-foreground);
1778
+ border-bottom-color: var(--fd-primary);
1779
+ }
1670
1780
  </style>