@flowdrop/flowdrop 2.16.0 → 2.18.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 (130) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/README.md +6 -1
  3. package/dist/api/enhanced-client.d.ts +3 -1
  4. package/dist/api/enhanced-client.js +4 -2
  5. package/dist/commands/executor.js +9 -0
  6. package/dist/commands/storeIntegration.svelte.js +6 -0
  7. package/dist/commands/types.d.ts +8 -0
  8. package/dist/components/App.svelte +414 -105
  9. package/dist/components/App.svelte.d.ts +31 -0
  10. package/dist/components/CanvasToolbar.svelte +40 -3
  11. package/dist/components/CanvasToolbar.svelte.d.ts +5 -1
  12. package/dist/components/ConnectPortPicker.svelte +8 -4
  13. package/dist/components/DoctorMenu.svelte +208 -126
  14. package/dist/components/FlowDropZone.svelte +7 -1
  15. package/dist/components/FlowDropZone.svelte.d.ts +5 -0
  16. package/dist/components/ImpactConfirm.svelte +554 -0
  17. package/dist/components/ImpactConfirm.svelte.d.ts +22 -0
  18. package/dist/components/Input.svelte +8 -2
  19. package/dist/components/LockBanner.svelte +76 -0
  20. package/dist/components/LockBanner.svelte.d.ts +14 -0
  21. package/dist/components/LockFence.svelte +33 -0
  22. package/dist/components/LockFence.svelte.d.ts +19 -0
  23. package/dist/components/Navbar.svelte +77 -9
  24. package/dist/components/Navbar.svelte.d.ts +10 -0
  25. package/dist/components/NodeSidebar.svelte +36 -15
  26. package/dist/components/NodeSidebar.svelte.d.ts +2 -0
  27. package/dist/components/NodeSwapPicker.svelte +4 -14
  28. package/dist/components/RunBar.svelte +50 -3
  29. package/dist/components/RunBar.svelte.d.ts +5 -0
  30. package/dist/components/RunInputsDialog.svelte +198 -0
  31. package/dist/components/RunInputsDialog.svelte.d.ts +34 -0
  32. package/dist/components/Textarea.svelte +7 -1
  33. package/dist/components/WorkflowCompareDialog.svelte +177 -0
  34. package/dist/components/WorkflowCompareDialog.svelte.d.ts +10 -0
  35. package/dist/components/WorkflowEditor.svelte +120 -15
  36. package/dist/components/WorkflowEditor.svelte.d.ts +6 -0
  37. package/dist/components/WorkflowInterfaceEditor.svelte +17 -4
  38. package/dist/components/WorkflowInterfaceEntryCard.svelte +40 -7
  39. package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +2 -0
  40. package/dist/components/WorkflowPlaygroundSettings.svelte +9 -1
  41. package/dist/components/form/FieldFactory.svelte +13 -6
  42. package/dist/components/form/FormArray.svelte +0 -1
  43. package/dist/components/form/FormArrayRows.svelte +4 -4
  44. package/dist/components/form/FormCodeEditor.svelte +18 -2
  45. package/dist/components/form/FormMarkdownEditor.svelte +22 -8
  46. package/dist/components/form/FormTemplateEditor.svelte +17 -1
  47. package/dist/components/form/readOnly.d.ts +13 -0
  48. package/dist/components/form/readOnly.js +18 -0
  49. package/dist/components/nodes/CaptionNode.svelte +1 -0
  50. package/dist/components/nodes/NodeCard.svelte +2 -2
  51. package/dist/components/primitives/Checkbox.svelte +5 -1
  52. package/dist/components/primitives/Select.svelte +6 -1
  53. package/dist/components/primitives/Switch.svelte +5 -1
  54. package/dist/components/toast/DismissibleToast.svelte +25 -6
  55. package/dist/components/toast/DismissibleToast.svelte.d.ts +3 -0
  56. package/dist/config/endpoints.d.ts +7 -0
  57. package/dist/config/endpoints.js +2 -1
  58. package/dist/editor/connectCandidates.d.ts +3 -0
  59. package/dist/editor/connectCandidates.js +14 -5
  60. package/dist/editor/index.d.ts +2 -1
  61. package/dist/editor/index.js +1 -1
  62. package/dist/helpers/workflowEditorHelper.d.ts +15 -0
  63. package/dist/helpers/workflowEditorHelper.js +9 -0
  64. package/dist/index.d.ts +2 -0
  65. package/dist/messages/defaults.d.ts +145 -0
  66. package/dist/messages/defaults.js +139 -1
  67. package/dist/openapi/v1/openapi.yaml +492 -0
  68. package/dist/registry/nodeComponentRegistry.d.ts +5 -0
  69. package/dist/schemas/v1/workflow.schema.json +2 -0
  70. package/dist/services/draftStorage.d.ts +24 -10
  71. package/dist/services/draftStorage.js +60 -35
  72. package/dist/services/globalSave.d.ts +45 -10
  73. package/dist/services/globalSave.js +296 -32
  74. package/dist/services/impactGate.d.ts +38 -0
  75. package/dist/services/impactGate.js +72 -0
  76. package/dist/services/impactService.d.ts +45 -0
  77. package/dist/services/impactService.js +157 -0
  78. package/dist/services/runsService.d.ts +9 -0
  79. package/dist/services/runsService.js +13 -0
  80. package/dist/services/toastQueue.d.ts +9 -0
  81. package/dist/services/toastService.d.ts +4 -0
  82. package/dist/services/toastService.js +9 -3
  83. package/dist/services/workflowLaunchService.d.ts +6 -0
  84. package/dist/services/workflowLaunchService.js +5 -1
  85. package/dist/settings/index.d.ts +2 -2
  86. package/dist/settings/index.js +1 -1
  87. package/dist/stores/doctorStore.svelte.d.ts +24 -1
  88. package/dist/stores/doctorStore.svelte.js +105 -2
  89. package/dist/stores/historyStore.svelte.d.ts +12 -2
  90. package/dist/stores/historyStore.svelte.js +25 -2
  91. package/dist/stores/instanceContainer.svelte.d.ts +23 -0
  92. package/dist/stores/instanceContainer.svelte.js +32 -2
  93. package/dist/stores/lockStore.svelte.d.ts +39 -0
  94. package/dist/stores/lockStore.svelte.js +109 -0
  95. package/dist/stores/runController.svelte.d.ts +2 -0
  96. package/dist/stores/runController.svelte.js +27 -11
  97. package/dist/stores/saveConflictStore.svelte.d.ts +62 -0
  98. package/dist/stores/saveConflictStore.svelte.js +169 -0
  99. package/dist/stores/workflowStore.svelte.d.ts +14 -4
  100. package/dist/stores/workflowStore.svelte.js +55 -18
  101. package/dist/styles/base.css +6 -0
  102. package/dist/styles/toast.css +10 -1
  103. package/dist/svelte-app.d.ts +33 -0
  104. package/dist/svelte-app.js +178 -22
  105. package/dist/types/doctor.d.ts +3 -1
  106. package/dist/types/events.d.ts +37 -0
  107. package/dist/types/events.js +2 -0
  108. package/dist/types/impact.d.ts +77 -0
  109. package/dist/types/impact.js +7 -0
  110. package/dist/types/lock.d.ts +35 -0
  111. package/dist/types/lock.js +13 -0
  112. package/dist/types/navbar.d.ts +6 -0
  113. package/dist/types/settings.d.ts +31 -0
  114. package/dist/types/settings.js +132 -0
  115. package/dist/utils/draftRestore.d.ts +27 -0
  116. package/dist/utils/draftRestore.js +36 -0
  117. package/dist/utils/interfaceTags.js +4 -1
  118. package/dist/utils/links.d.ts +29 -0
  119. package/dist/utils/links.js +63 -0
  120. package/dist/utils/nodeSearch.d.ts +10 -0
  121. package/dist/utils/nodeSearch.js +37 -0
  122. package/dist/utils/runOffer.d.ts +21 -0
  123. package/dist/utils/runOffer.js +13 -0
  124. package/dist/utils/workflowCompare.d.ts +35 -0
  125. package/dist/utils/workflowCompare.js +84 -0
  126. package/dist/utils/workflowInterface.d.ts +26 -1
  127. package/dist/utils/workflowInterface.js +91 -11
  128. package/dist/webmcp/runtime.js +16 -3
  129. package/dist/webmcp/types.d.ts +11 -1
  130. package/package.json +3 -2
@@ -17,7 +17,7 @@ import { dynamicPortToNodePort, WORKFLOW_INTERFACE_INPUT_TURNS, WORKFLOW_INTERFA
17
17
  import { isPortExposed } from './portUtils.js';
18
18
  import { LOOPBACK_PORT_NAME } from './connections.js';
19
19
  import { PORTS_CONFIG_KEY } from './nodeFormSchema.js';
20
- import { buildHandleId } from './handleIds.js';
20
+ import { buildHandleId, extractPortId } from './handleIds.js';
21
21
  import { isPlaygroundChatHalfSet, normalizePlaygroundChat, playgroundBoundInputs, resolvePlaygroundChat } from './playgroundChat.js';
22
22
  /** Precedence used to pick the single reported status when several apply. */
23
23
  const STATUS_PRECEDENCE = [
@@ -412,6 +412,22 @@ export function nodeCanvasLabel(node) {
412
412
  const title = node.data?.config?.instanceTitle;
413
413
  return (typeof title === 'string' && title) || node.data?.label || node.id;
414
414
  }
415
+ /**
416
+ * Tells same-named nodes apart in a picker: when two or more items with
417
+ * different node ids share a label, each of them gets " · <node id>" appended.
418
+ * Unique labels, and several ports of one node, stay as they are.
419
+ */
420
+ export function disambiguateLabels(items) {
421
+ const nodesByLabel = new Map();
422
+ for (const item of items) {
423
+ const ids = nodesByLabel.get(item.nodeLabel) ?? new Set();
424
+ ids.add(item.nodeId);
425
+ nodesByLabel.set(item.nodeLabel, ids);
426
+ }
427
+ return items.map((item) => (nodesByLabel.get(item.nodeLabel)?.size ?? 0) > 1
428
+ ? { ...item, nodeLabel: `${item.nodeLabel} · ${item.nodeId}` }
429
+ : item);
430
+ }
415
431
  /**
416
432
  * Every canvas-exposed port of a workflow, for one direction — the candidate
417
433
  * set a binding picker offers (design decision 3: external ⊂ internal, so an
@@ -449,7 +465,7 @@ export function listBindablePorts(workflow, direction) {
449
465
  }
450
466
  }
451
467
  }
452
- return result;
468
+ return disambiguateLabels(result);
453
469
  }
454
470
  /**
455
471
  * A stable key for a bindable port — `nodeId::portId` — the value a picker
@@ -502,18 +518,82 @@ export function rankBindablePorts(workflow, direction) {
502
518
  * re-derives it. DN1's concern — a contract silently keyed on internal port
503
519
  * names — is about that ongoing coupling, which this does not introduce.
504
520
  */
505
- export function entryFromBindablePort(candidate, existingIds) {
521
+ export function entryFromBindablePort(candidate, existingIds, workflow, direction) {
522
+ const suggestion = suggestEntryFromBindablePort(workflow, candidate, existingIds, direction);
523
+ return {
524
+ ...pullEntryFieldsFromPort(candidate.port),
525
+ ...suggestion,
526
+ bindings: [{ nodeId: candidate.nodeId, portId: candidate.port.id }]
527
+ };
528
+ }
529
+ /** Port ids too generic to name a public entry: the node's title names it instead. */
530
+ export const GENERIC_PORT_IDS = [
531
+ 'data',
532
+ 'value',
533
+ 'input',
534
+ 'output',
535
+ 'result',
536
+ 'text'
537
+ ];
538
+ /**
539
+ * The id, title and type to seed a new entry with for a picked port.
540
+ *
541
+ * A generic port id (`data`, `value`, ...) says nothing about the contract, so
542
+ * the bound node's canvas label gives the id (snake_case) and the title. A
543
+ * `mixed` port takes the type of the port at the other end of an edge on its
544
+ * handle, when that one is typed. The id gets a numeric suffix only on a
545
+ * collision with `existingIds`.
546
+ */
547
+ export function suggestEntryFromBindablePort(workflow, candidate, existingIds, direction) {
548
+ const { port } = candidate;
549
+ const generic = GENERIC_PORT_IDS.includes(port.id);
550
+ // The picker label may carry a " · node id" suffix; an entry is named after the node itself.
551
+ const ownNode = workflow?.nodes.find((n) => n.id === candidate.nodeId);
552
+ const label = ownNode ? nodeCanvasLabel(ownNode) : candidate.nodeLabel;
553
+ // Accents fold to their base letter (Übersetzung -> ubersetzung), ß to ss.
554
+ const fromLabel = label
555
+ .normalize('NFD')
556
+ .replace(/[\u0300-\u036f]/g, '')
557
+ .replace(/ß/g, 'ss')
558
+ .toLowerCase()
559
+ .replace(/[^a-z0-9]+/g, '_')
560
+ .replace(/^_+|_+$/g, '')
561
+ .slice(0, 40)
562
+ .replace(/_+$/g, '');
563
+ const base = generic && fromLabel ? fromLabel : port.id;
506
564
  const taken = new Set(existingIds);
507
- let id = candidate.port.id;
565
+ let id = base;
508
566
  for (let n = 2; taken.has(id); n += 1) {
509
- id = `${candidate.port.id}_${n}`;
567
+ id = `${base}_${n}`;
510
568
  }
511
- return {
512
- id,
513
- dataType: candidate.port.dataType,
514
- bindings: [{ nodeId: candidate.nodeId, portId: candidate.port.id }],
515
- ...pullEntryFieldsFromPort(candidate.port)
516
- };
569
+ let dataType = port.dataType;
570
+ if (dataType === 'mixed' && workflow && direction) {
571
+ const handleId = buildHandleId(candidate.nodeId, direction, port.id);
572
+ const edge = workflow.edges.find((e) => direction === 'input' ? e.targetHandle === handleId : e.sourceHandle === handleId);
573
+ const otherNode = edge
574
+ ? workflow.nodes.find((n) => n.id === (direction === 'input' ? edge.source : edge.target))
575
+ : undefined;
576
+ const otherPortId = edge
577
+ ? extractPortId(direction === 'input' ? edge.sourceHandle : edge.targetHandle)
578
+ : null;
579
+ const otherMetadata = otherNode?.data?.metadata;
580
+ if (otherNode && otherMetadata && otherPortId) {
581
+ const otherDirection = direction === 'input' ? 'output' : 'input';
582
+ const dynamicRaw = otherDirection === 'input'
583
+ ? otherNode.data?.config?.dynamicInputs
584
+ : otherNode.data?.config?.dynamicOutputs;
585
+ const otherPorts = [
586
+ ...(otherDirection === 'input'
587
+ ? (otherMetadata.inputs ?? [])
588
+ : (otherMetadata.outputs ?? [])),
589
+ ...(dynamicRaw ?? []).map((dynamic) => dynamicPortToNodePort(dynamic, otherDirection))
590
+ ];
591
+ const otherType = otherPorts.find((other) => other.id === otherPortId)?.dataType;
592
+ if (otherType && otherType !== 'mixed')
593
+ dataType = otherType;
594
+ }
595
+ }
596
+ return { id, name: generic ? label : port.name, dataType };
517
597
  }
518
598
  // ---------------------------------------------------------------------------
519
599
  // Chat turn ports — deprecated since 2.11.0, removed in 3.0 with interface
@@ -82,6 +82,10 @@ function describeError(err) {
82
82
  const reasons = errorDetails(err);
83
83
  return reasons.length ? `${err.message}: ${reasons.join('; ')}` : err.message;
84
84
  }
85
+ /** The answer for a change a locked editor would refuse, given before any approval is asked. */
86
+ function lockedResult() {
87
+ return errorResult('LOCKED', 'The editor is locked (read-only), so this change was not made. Ask the user to unlock it.');
88
+ }
85
89
  function stripResult(result) {
86
90
  if (result.ok) {
87
91
  const out = { ok: true, message: result.message };
@@ -161,7 +165,9 @@ export function buildHostToolDescriptors(hooks) {
161
165
  verb: 'save',
162
166
  description: 'Save the workflow to the server. Nothing an agent changes is persisted until ' +
163
167
  'this runs or the person clicks Save. Asks for approval; cannot be undone from ' +
164
- 'the editor. Fails with FORBIDDEN when the user may not save, CONFLICT when the ' +
168
+ 'the editor. Fails with FORBIDDEN when the user may not save, LOCKED when the editor is ' +
169
+ 'locked (read-only), WORKFLOW_IN_USE_BREAKING when the change breaks places that use the ' +
170
+ 'workflow (the person was shown them; do not retry), CONFLICT when the ' +
165
171
  'server copy changed since it was loaded (reload the page), INVALID when the ' +
166
172
  'server rejected the workflow — the message says which node or port.',
167
173
  inputSchema: EMPTY_SCHEMA,
@@ -269,6 +275,9 @@ export function createToolRuntime(options) {
269
275
  const context = createStoreCommandContext(nodeTypes(), onUIAction, instance);
270
276
  if (!context)
271
277
  return errorResult('NO_WORKFLOW', 'No workflow is loaded in this editor');
278
+ // A locked editor refuses every change: say so now, do not ask first and refuse after.
279
+ if (instance.workflow.locked && needsApproval(commands))
280
+ return lockedResult();
272
281
  // D3: reads and view changes run; document changes wait for the gate.
273
282
  if (needsApproval(commands)) {
274
283
  let approved;
@@ -357,6 +366,9 @@ export function createToolRuntime(options) {
357
366
  if (workflowCan('save') === false) {
358
367
  return errorResult('FORBIDDEN', 'Saving this workflow is not permitted');
359
368
  }
369
+ // The editor refuses a save while locked; do not ask for approval first.
370
+ if (instance.workflow.locked)
371
+ return lockedResult();
360
372
  const refused = await askHostGate('save');
361
373
  if (refused)
362
374
  return refused;
@@ -460,12 +472,13 @@ export function createToolRuntime(options) {
460
472
  const host = hostByVerb.get(name);
461
473
  if (host) {
462
474
  const mutating = !host.readOnly;
475
+ const refused = name === 'save' && instance.workflow.locked;
463
476
  return {
464
477
  commands: [],
465
478
  skipped: [],
466
479
  mutating,
467
480
  consequential: host.consequential,
468
- asks: gate.asks && mutating
481
+ asks: gate.asks && mutating && !refused
469
482
  };
470
483
  }
471
484
  const descriptor = byVerb.get(name);
@@ -481,7 +494,7 @@ export function createToolRuntime(options) {
481
494
  skipped,
482
495
  mutating,
483
496
  consequential: false,
484
- asks: gate.asks && mutating && !gate.editsPreApproved
497
+ asks: gate.asks && mutating && !gate.editsPreApproved && !instance.workflow.locked
485
498
  };
486
499
  }
487
500
  return {
@@ -114,14 +114,17 @@ export interface ModelContextLike {
114
114
  * (`CONFLICT`, `NOT_FOUND`); the rest name what a browser agent must do next.
115
115
  *
116
116
  * - `FORBIDDEN` — the server refused; the agent should tell the user.
117
+ * - `LOCKED` — the editor is locked (read-only); nothing was changed and nobody was asked.
117
118
  * - `UNAVAILABLE` — nothing to act on yet (unsaved workflow, no runtime).
118
119
  * - `NEEDS_APPROVAL` — a person must approve in the UI first.
119
120
  * - `INVALID` — the workflow failed validation; `message` says where.
120
121
  * - `CONFLICT` — the server copy changed since it was loaded; reload.
122
+ * - `WORKFLOW_IN_USE_BREAKING` — the server refused the save because the change
123
+ * breaks places that use the workflow; the person has been shown them.
121
124
  * - `PENDING` — a run is paused for a person (never for the agent, D8).
122
125
  * - `NOT_FOUND` — the run id is unknown.
123
126
  */
124
- export type HostCode = 'FORBIDDEN' | 'UNAVAILABLE' | 'NEEDS_APPROVAL' | 'INVALID' | 'CONFLICT' | 'PENDING' | 'NOT_FOUND' | (string & Record<never, never>);
127
+ export type HostCode = 'FORBIDDEN' | 'LOCKED' | 'UNAVAILABLE' | 'NEEDS_APPROVAL' | 'INVALID' | 'CONFLICT' | 'PENDING' | 'NOT_FOUND' | (string & Record<never, never>);
125
128
  /**
126
129
  * What every host hook returns. `ok: false` needs a `code`; `ok: true` may
127
130
  * still carry one (`PENDING`). `can` lets a host refresh what the user may do
@@ -158,6 +161,13 @@ export interface RunStatus {
158
161
  pending?: RunPending | null;
159
162
  /** Why an execution budget paused the run, when it did. */
160
163
  pausedReason?: string | null;
164
+ /**
165
+ * What the site says is happening to the run. `kind: 'waiting_for_worker'`
166
+ * makes the run bar say the run waits for a worker.
167
+ */
168
+ activity?: {
169
+ kind?: string;
170
+ } | null;
161
171
  /** The run's output once it has one. Host-shaped. */
162
172
  outputs?: unknown;
163
173
  /** Per-node status once the host has it. Host-shaped. */
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A drop-in visual workflow editor for any web application. You own the backend. You own the data. You own the orchestration.",
4
4
  "license": "MIT",
5
5
  "private": false,
6
- "version": "2.16.0",
6
+ "version": "2.18.0",
7
7
  "author": "Shibin Das (D34dMan)",
8
8
  "bugs": {
9
9
  "url": "https://github.com/flowdrop-io/flowdrop/issues"
@@ -277,7 +277,8 @@
277
277
  "dag",
278
278
  "agent",
279
279
  "ai-workflow",
280
- "embeddable"
280
+ "embeddable",
281
+ "workflow-specification"
281
282
  ],
282
283
  "dependencies": {
283
284
  "diff": "^8.0.3",