@flowdrop/flowdrop 2.10.0 → 2.11.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 (175) hide show
  1. package/CHANGELOG.md +175 -0
  2. package/dist/components/App.svelte +112 -29
  3. package/dist/components/CanvasController.svelte +1 -1
  4. package/dist/components/ConfigForm.svelte +5 -5
  5. package/dist/components/ConfigModal.svelte +2 -2
  6. package/dist/components/ConfigModal.svelte.d.ts +1 -1
  7. package/dist/components/ConnectionLine.svelte +1 -1
  8. package/dist/components/EdgeRefresher.svelte +1 -1
  9. package/dist/components/FlowDropZone.svelte +11 -7
  10. package/dist/components/FlowDropZone.svelte.d.ts +12 -0
  11. package/dist/components/LogsSidebar.svelte +15 -12
  12. package/dist/components/MarkdownDisplay.svelte +1 -1
  13. package/dist/components/PipelineStatus.svelte +5 -18
  14. package/dist/components/PortCoordinateTracker.svelte +1 -1
  15. package/dist/components/SchemaForm.svelte +1 -1
  16. package/dist/components/SettingsModal.svelte +1 -1
  17. package/dist/components/SettingsPanel.svelte +1 -1
  18. package/dist/components/WorkflowEditor.svelte +200 -174
  19. package/dist/components/WorkflowInterfaceEditor.svelte +43 -8
  20. package/dist/components/WorkflowInterfaceEditor.svelte.d.ts +12 -1
  21. package/dist/components/WorkflowInterfaceEntryCard.svelte +117 -44
  22. package/dist/components/WorkflowInterfaceEntryCard.svelte.d.ts +14 -1
  23. package/dist/components/WorkflowPlaygroundSettings.svelte +551 -0
  24. package/dist/components/WorkflowPlaygroundSettings.svelte.d.ts +20 -0
  25. package/dist/components/chat/AIChatPanel.svelte +1 -1
  26. package/dist/components/form/index.d.ts +2 -2
  27. package/dist/components/form/index.js +2 -2
  28. package/dist/components/nodes/ToolNode.svelte +1 -1
  29. package/dist/components/playground/ControlPanel.svelte +30 -0
  30. package/dist/components/playground/ControlPanel.svelte.d.ts +5 -0
  31. package/dist/components/playground/Playground.svelte +94 -42
  32. package/dist/components/playground/PlaygroundApp.svelte +1 -1
  33. package/dist/components/playground/PlaygroundModal.svelte +1 -1
  34. package/dist/components/playground/PlaygroundStudio.svelte +1 -1
  35. package/dist/core/index.d.ts +1 -1
  36. package/dist/helpers/workflowEditorHelper.d.ts +12 -0
  37. package/dist/helpers/workflowEditorHelper.js +31 -0
  38. package/dist/messages/defaults.d.ts +53 -0
  39. package/dist/messages/defaults.js +48 -2
  40. package/dist/openapi/v1/openapi.yaml +113 -5
  41. package/dist/playground/index.d.ts +3 -1
  42. package/dist/playground/index.js +2 -1
  43. package/dist/playground/mount.d.ts +6 -10
  44. package/dist/playground/mount.js +43 -24
  45. package/dist/schemas/index.js +1 -1
  46. package/dist/schemas/v1/workflow.schema.json +140 -2
  47. package/dist/services/globalSave.js +11 -1
  48. package/dist/services/playgroundService.d.ts +6 -1
  49. package/dist/services/playgroundService.js +5 -0
  50. package/dist/skins/default.d.ts +1 -1
  51. package/dist/skins/drafter.d.ts +1 -1
  52. package/dist/skins/index.d.ts +4 -4
  53. package/dist/skins/index.js +3 -3
  54. package/dist/skins/slate.d.ts +1 -1
  55. package/dist/stores/instanceContainer.svelte.d.ts +15 -0
  56. package/dist/stores/instanceContainer.svelte.js +11 -1
  57. package/dist/stores/playgroundStore.svelte.d.ts +8 -0
  58. package/dist/stores/playgroundStore.svelte.js +18 -4
  59. package/dist/stores/workflowStore.svelte.d.ts +4 -1
  60. package/dist/stores/workflowStore.svelte.js +8 -1
  61. package/dist/styles/base.css +14 -3
  62. package/dist/styles/tokenAliases.d.ts +13 -0
  63. package/dist/styles/tokenAliases.js +89 -0
  64. package/dist/themes/scopedSkinCss.d.ts +30 -0
  65. package/dist/themes/scopedSkinCss.js +95 -0
  66. package/dist/types/index.d.ts +86 -4
  67. package/dist/types/index.js +15 -3
  68. package/dist/types/skin.d.ts +2 -2
  69. package/dist/utils/playgroundChat.d.ts +121 -0
  70. package/dist/utils/playgroundChat.js +275 -0
  71. package/dist/utils/portal.d.ts +8 -0
  72. package/dist/utils/portal.js +15 -0
  73. package/dist/utils/workflowInterface.d.ts +88 -20
  74. package/dist/utils/workflowInterface.js +179 -18
  75. package/dist/webmcp/WebMCPConfirm.svelte +68 -18
  76. package/dist/webmcp/gate.d.ts +6 -0
  77. package/dist/webmcp/gate.js +4 -0
  78. package/dist/webmcp/runtime.js +2 -1
  79. package/package.json +8 -7
  80. package/dist/components/Button.stories.svelte +0 -65
  81. package/dist/components/Button.stories.svelte.d.ts +0 -19
  82. package/dist/components/CanvasBanner.stories.svelte +0 -30
  83. package/dist/components/CanvasBanner.stories.svelte.d.ts +0 -27
  84. package/dist/components/CanvasContextMenu.stories.svelte +0 -63
  85. package/dist/components/CanvasContextMenu.stories.svelte.d.ts +0 -19
  86. package/dist/components/ConfigPanel.stories.svelte +0 -47
  87. package/dist/components/ConfigPanel.stories.svelte.d.ts +0 -27
  88. package/dist/components/EditorStatusBar.stories.svelte +0 -44
  89. package/dist/components/EditorStatusBar.stories.svelte.d.ts +0 -27
  90. package/dist/components/FlowDropEdge.stories.svelte +0 -197
  91. package/dist/components/FlowDropEdge.stories.svelte.d.ts +0 -26
  92. package/dist/components/LoadingSpinner.stories.svelte +0 -30
  93. package/dist/components/LoadingSpinner.stories.svelte.d.ts +0 -27
  94. package/dist/components/Logo.stories.svelte +0 -22
  95. package/dist/components/Logo.stories.svelte.d.ts +0 -27
  96. package/dist/components/MarkdownDisplay.stories.svelte +0 -38
  97. package/dist/components/MarkdownDisplay.stories.svelte.d.ts +0 -27
  98. package/dist/components/Navbar.stories.svelte +0 -58
  99. package/dist/components/Navbar.stories.svelte.d.ts +0 -27
  100. package/dist/components/NodeStatusOverlay.stories.svelte +0 -85
  101. package/dist/components/NodeStatusOverlay.stories.svelte.d.ts +0 -27
  102. package/dist/components/SchemaForm.stories.svelte +0 -122
  103. package/dist/components/SchemaForm.stories.svelte.d.ts +0 -27
  104. package/dist/components/StatusIcon.stories.svelte +0 -60
  105. package/dist/components/StatusIcon.stories.svelte.d.ts +0 -27
  106. package/dist/components/StatusLabel.stories.svelte +0 -17
  107. package/dist/components/StatusLabel.stories.svelte.d.ts +0 -27
  108. package/dist/components/ThemeToggle.stories.svelte +0 -25
  109. package/dist/components/ThemeToggle.stories.svelte.d.ts +0 -27
  110. package/dist/components/console/CommandConsole.stories.svelte +0 -111
  111. package/dist/components/console/CommandConsole.stories.svelte.d.ts +0 -27
  112. package/dist/components/form/FormCheckboxGroup.stories.svelte +0 -28
  113. package/dist/components/form/FormCheckboxGroup.stories.svelte.d.ts +0 -27
  114. package/dist/components/form/FormFieldWrapper.stories.svelte +0 -53
  115. package/dist/components/form/FormFieldWrapper.stories.svelte.d.ts +0 -27
  116. package/dist/components/form/FormNumberField.stories.svelte +0 -36
  117. package/dist/components/form/FormNumberField.stories.svelte.d.ts +0 -27
  118. package/dist/components/form/FormRangeField.stories.svelte +0 -31
  119. package/dist/components/form/FormRangeField.stories.svelte.d.ts +0 -27
  120. package/dist/components/form/FormSelect.stories.svelte +0 -50
  121. package/dist/components/form/FormSelect.stories.svelte.d.ts +0 -27
  122. package/dist/components/form/FormTextField.stories.svelte +0 -30
  123. package/dist/components/form/FormTextField.stories.svelte.d.ts +0 -27
  124. package/dist/components/form/FormTextarea.stories.svelte +0 -34
  125. package/dist/components/form/FormTextarea.stories.svelte.d.ts +0 -27
  126. package/dist/components/form/FormToggle.stories.svelte +0 -30
  127. package/dist/components/form/FormToggle.stories.svelte.d.ts +0 -27
  128. package/dist/components/interrupt/ChoicePrompt.stories.svelte +0 -68
  129. package/dist/components/interrupt/ChoicePrompt.stories.svelte.d.ts +0 -27
  130. package/dist/components/interrupt/ConfirmationPrompt.stories.svelte +0 -71
  131. package/dist/components/interrupt/ConfirmationPrompt.stories.svelte.d.ts +0 -27
  132. package/dist/components/interrupt/ReviewPrompt.stories.svelte +0 -77
  133. package/dist/components/interrupt/ReviewPrompt.stories.svelte.d.ts +0 -27
  134. package/dist/components/interrupt/TextInputPrompt.stories.svelte +0 -51
  135. package/dist/components/interrupt/TextInputPrompt.stories.svelte.d.ts +0 -27
  136. package/dist/components/nodes/CaptionNode.stories.svelte +0 -65
  137. package/dist/components/nodes/CaptionNode.stories.svelte.d.ts +0 -18
  138. package/dist/components/nodes/GatewayNode.stories.svelte +0 -108
  139. package/dist/components/nodes/GatewayNode.stories.svelte.d.ts +0 -26
  140. package/dist/components/nodes/IdeaNode.stories.svelte +0 -52
  141. package/dist/components/nodes/IdeaNode.stories.svelte.d.ts +0 -26
  142. package/dist/components/nodes/NotesNode.stories.svelte +0 -76
  143. package/dist/components/nodes/NotesNode.stories.svelte.d.ts +0 -26
  144. package/dist/components/nodes/SimpleNode.stories.svelte +0 -223
  145. package/dist/components/nodes/SimpleNode.stories.svelte.d.ts +0 -26
  146. package/dist/components/nodes/SquareNode.stories.svelte +0 -127
  147. package/dist/components/nodes/SquareNode.stories.svelte.d.ts +0 -26
  148. package/dist/components/nodes/TerminalNode.stories.svelte +0 -25
  149. package/dist/components/nodes/TerminalNode.stories.svelte.d.ts +0 -26
  150. package/dist/components/nodes/ToolNode.stories.svelte +0 -189
  151. package/dist/components/nodes/ToolNode.stories.svelte.d.ts +0 -26
  152. package/dist/components/nodes/WorkflowNode.stories.svelte +0 -188
  153. package/dist/components/nodes/WorkflowNode.stories.svelte.d.ts +0 -26
  154. package/dist/components/playground/MessageBubble.stories.svelte +0 -151
  155. package/dist/components/playground/MessageBubble.stories.svelte.d.ts +0 -27
  156. package/dist/mocks/app-environment.d.ts +0 -8
  157. package/dist/mocks/app-environment.js +0 -16
  158. package/dist/mocks/app-forms.d.ts +0 -6
  159. package/dist/mocks/app-forms.js +0 -29
  160. package/dist/mocks/app-navigation.d.ts +0 -5
  161. package/dist/mocks/app-navigation.js +0 -36
  162. package/dist/mocks/app-stores.d.ts +0 -14
  163. package/dist/mocks/app-stores.js +0 -26
  164. package/dist/stories/CanvasDecorator.svelte +0 -49
  165. package/dist/stories/CanvasDecorator.svelte.d.ts +0 -8
  166. package/dist/stories/EdgeDecorator.svelte +0 -125
  167. package/dist/stories/EdgeDecorator.svelte.d.ts +0 -17
  168. package/dist/stories/NodeDecorator.svelte +0 -75
  169. package/dist/stories/NodeDecorator.svelte.d.ts +0 -8
  170. package/dist/stories/WebMCPFakeAgent.svelte +0 -229
  171. package/dist/stories/WebMCPFakeAgent.svelte.d.ts +0 -10
  172. package/dist/stories/utils.d.ts +0 -93
  173. package/dist/stories/utils.js +0 -156
  174. package/dist/webmcp/WebMCP.stories.svelte +0 -101
  175. package/dist/webmcp/WebMCP.stories.svelte.d.ts +0 -18
@@ -4307,7 +4307,12 @@ components:
4307
4307
  session fills the port with. The interface editor writes that one key.
4308
4308
  turn:
4309
4309
  $ref: '#/components/schemas/WorkflowInterfaceTurn'
4310
+ deprecated: true
4310
4311
  description: |
4312
+ **Deprecated** since 2.11.0, removed in 3.0: the chat binding now lives in
4313
+ the workflow's `playground` settings. Still accepted and round-tripped; a
4314
+ workflow without stored Playground settings falls back to it.
4315
+
4311
4316
  What this port is for in a chat turn. Absent means the port plays no part
4312
4317
  in a turn. Validated by the server against its vocabulary.
4313
4318
  required:
@@ -4367,6 +4372,9 @@ components:
4367
4372
  interface:
4368
4373
  $ref: '#/components/schemas/WorkflowInterface'
4369
4374
  description: Public contract for callers. Absent = the workflow declares no interface.
4375
+ playground:
4376
+ $ref: '#/components/schemas/WorkflowPlayground'
4377
+ description: Playground settings (the chat binding). Absent = the server predates them (before FlowDrop 2.7.0).
4370
4378
  required:
4371
4379
  - id
4372
4380
  - name
@@ -4394,6 +4402,9 @@ components:
4394
4402
  type: array
4395
4403
  items:
4396
4404
  $ref: '#/components/schemas/WorkflowEdge'
4405
+ playground:
4406
+ $ref: '#/components/schemas/WorkflowPlayground'
4407
+ description: 'Playground settings. Send only `chat`: null clears the stored settings, and omitting the key leaves them alone.'
4397
4408
  tags:
4398
4409
  type: array
4399
4410
  items:
@@ -4422,6 +4433,9 @@ components:
4422
4433
  type: array
4423
4434
  items:
4424
4435
  $ref: '#/components/schemas/WorkflowEdge'
4436
+ playground:
4437
+ $ref: '#/components/schemas/WorkflowPlayground'
4438
+ description: 'Playground settings. Send only `chat`: null clears the stored settings, and omitting the key leaves them alone.'
4425
4439
  metadata:
4426
4440
  type: object
4427
4441
  properties:
@@ -4864,11 +4878,14 @@ components:
4864
4878
  description: |
4865
4879
  Request body for a turn: the person's message, named inputs, or both.
4866
4880
 
4867
- `content` fills the input port whose interface entry has `turn: message`.
4868
- A workflow that declares turn ports but no `message` port is form-only:
4869
- it runs on `inputs` alone and the server refuses `content` with a 400
4870
- whose message names the fix. A workflow that declares no turn port at all
4871
- keeps the server's older behaviour (deprecated) and still needs `content`.
4881
+ `content` fills the interface input named by the workflow's chat binding
4882
+ (`playground.resolved.message`). A workflow whose binding has no message
4883
+ input is form-only: it runs on `inputs` alone and the server refuses
4884
+ `content` with a 400 whose message names the fix. That includes a
4885
+ workflow with no binding at all (`playground.source: none`): it has no
4886
+ chat until somebody sets one up, and nothing is guessed from its nodes.
4887
+ Only a server before FlowDrop 2.7.0, which sends no `playground`, still
4888
+ guesses the message input from the nodes (deprecated).
4872
4889
  properties:
4873
4890
  content:
4874
4891
  type: string
@@ -6548,6 +6565,7 @@ components:
6548
6565
  type: string
6549
6566
  label: Country
6550
6567
  WorkflowInterfaceTurn:
6568
+ deprecated: true
6551
6569
  type: string
6552
6570
  enum:
6553
6571
  - message
@@ -6556,6 +6574,8 @@ components:
6556
6574
  - message_id
6557
6575
  - reply
6558
6576
  description: |
6577
+ **Deprecated** since 2.11.0, removed in 3.0 (see `WorkflowPlayground`).
6578
+
6559
6579
  The chat-turn vocabulary of an interface port.
6560
6580
 
6561
6581
  Inputs — at most one entry per value:
@@ -6567,6 +6587,94 @@ components:
6567
6587
 
6568
6588
  Outputs — any number:
6569
6589
  - `reply` — each value becomes one assistant message
6590
+ PlaygroundChatHistory:
6591
+ type: object
6592
+ description: The interface input that receives recent messages.
6593
+ properties:
6594
+ input:
6595
+ type: string
6596
+ description: Interface input entry id.
6597
+ limit:
6598
+ type: integer
6599
+ minimum: 1
6600
+ description: How many past user and assistant messages fill the input. The server enforces its own maximum.
6601
+ example: 10
6602
+ required:
6603
+ - input
6604
+ - limit
6605
+ PlaygroundReplyPort:
6606
+ type: object
6607
+ description: A node output port whose value prints as an assistant reply.
6608
+ properties:
6609
+ node_id:
6610
+ type: string
6611
+ description: Id of the node.
6612
+ example: chat_output.2
6613
+ port:
6614
+ type: string
6615
+ description: Id of the node's output port.
6616
+ example: message
6617
+ required:
6618
+ - node_id
6619
+ - port
6620
+ PlaygroundChatBinding:
6621
+ type: object
6622
+ description: |
6623
+ A workflow's chat binding: which interface inputs a chat turn fills and which
6624
+ node output ports print as replies. Inputs are named by interface entry id,
6625
+ replies by node id and output port id.
6626
+ properties:
6627
+ message:
6628
+ type: string
6629
+ nullable: true
6630
+ description: Interface input that receives the person's message.
6631
+ history:
6632
+ allOf:
6633
+ - $ref: '#/components/schemas/PlaygroundChatHistory'
6634
+ nullable: true
6635
+ description: Interface input that receives recent messages.
6636
+ session_id:
6637
+ type: string
6638
+ nullable: true
6639
+ description: Interface input that receives the session's id.
6640
+ message_id:
6641
+ type: string
6642
+ nullable: true
6643
+ description: Interface input that receives the id of the person's message.
6644
+ replies:
6645
+ type: array
6646
+ items:
6647
+ $ref: '#/components/schemas/PlaygroundReplyPort'
6648
+ description: Node output ports whose values print as assistant messages.
6649
+ sub_workflow_replies:
6650
+ type: boolean
6651
+ description: Whether replies from sub-workflows print too.
6652
+ required:
6653
+ - replies
6654
+ WorkflowPlayground:
6655
+ type: object
6656
+ description: |
6657
+ Playground settings of a workflow (FlowDrop 2.7.0 and later). Sent with every
6658
+ workflow read. On save the client sends only `{"chat": ...}`: `chat: null`
6659
+ clears the stored settings, and a request without the `playground` key
6660
+ leaves them alone. The server answers 422 with problems for an invalid
6661
+ binding.
6662
+ properties:
6663
+ chat:
6664
+ allOf:
6665
+ - $ref: '#/components/schemas/PlaygroundChatBinding'
6666
+ nullable: true
6667
+ description: The stored chat binding; null when none is stored.
6668
+ resolved:
6669
+ allOf:
6670
+ - $ref: '#/components/schemas/PlaygroundChatBinding'
6671
+ description: The binding in effect (never null); read-only, ignored on save.
6672
+ source:
6673
+ type: string
6674
+ description: |
6675
+ Where the binding in effect comes from: `settings`, `interface_turn`
6676
+ (the deprecated interface `turn` annotations) or `none`. Clients should
6677
+ tolerate other values. Read-only, ignored on save.
6570
6678
  KanbanColumnDef:
6571
6679
  type: object
6572
6680
  properties:
@@ -142,7 +142,9 @@ export { WorkflowLaunchService, workflowLaunchService, type LaunchResult, type L
142
142
  export { PipelineSignalService, pipelineSignalService, type SignalType, type SignalResult, type SignalRefusal, type SendSignalOptions } from '../services/pipelineSignalService.js';
143
143
  export { PlaygroundStore } from '../stores/playgroundStore.svelte.js';
144
144
  export type { PlaygroundSession, PlaygroundMessage, PlaygroundInputField, PlaygroundMessageRequest, PlaygroundTurnResult, PlaygroundTurnResponse, PlaygroundMessagesResult, PlaygroundConfig, PlaygroundMode, PlaygroundSessionStatus, PlaygroundMessageRole, PlaygroundMessageLevel, PlaygroundMessageMetadata, PlaygroundMessageDisplay, ResolvedMessageDisplay, PlaygroundMessageOrigin, PlaygroundApiResponse, PlaygroundSessionsResponse, PlaygroundSessionResponse, PlaygroundMessageResponse, PlaygroundMessagesApiResponse, PlaygroundExecution } from '../types/playground.js';
145
- export { resolvePlaygroundInputMode, interfaceFormEntries, interfaceFormSchema, collectInterfaceInputs, type InterfaceInputsResult, type PlaygroundInputMode } from '../utils/workflowInterface.js';
145
+ export { resolvePlaygroundInputMode, interfaceFormEntries, interfaceFormSchema, collectInterfaceInputs, playgroundChatIssues, type InterfaceInputsResult, type PlaygroundInputMode, type PlaygroundChatIssue, type PlaygroundChatInputKey } from '../utils/workflowInterface.js';
146
+ export { resolvePlaygroundChat, type ResolvedPlaygroundChat } from '../utils/playgroundChat.js';
147
+ export type { WorkflowPlayground, PlaygroundChatBinding, PlaygroundReplyPort, PlaygroundChatSource } from '../types/index.js';
146
148
  export { isChatInputNode, CHAT_INPUT_PATTERNS, defaultShouldStopPolling, defaultIsTerminalStatus, DEFAULT_STOP_POLLING_STATUSES, DEFAULT_TERMINAL_STATUSES } from '../types/playground.js';
147
149
  export type { InterruptType, InterruptStatus, Interrupt, InterruptChoice, InterruptConfig, ConfirmationConfig, ChoiceConfig, TextConfig, FormConfig, ReviewConfig, ReviewChange, ReviewFieldDecision, ReviewResolution, InterruptResolution, InterruptApiResponse, InterruptListResponse, InterruptResponse, InterruptMessageMetadata, InterruptPollingConfig } from '../types/interrupt.js';
148
150
  export { isInterruptMetadata, extractInterruptMetadata, metadataToInterrupt, defaultInterruptPollingConfig } from '../types/interrupt.js';
@@ -159,7 +159,8 @@ export { PipelineSignalService, pipelineSignalService } from '../services/pipeli
159
159
  // Playground Store
160
160
  // ============================================================================
161
161
  export { PlaygroundStore } from '../stores/playgroundStore.svelte.js';
162
- export { resolvePlaygroundInputMode, interfaceFormEntries, interfaceFormSchema, collectInterfaceInputs } from '../utils/workflowInterface.js';
162
+ export { resolvePlaygroundInputMode, interfaceFormEntries, interfaceFormSchema, collectInterfaceInputs, playgroundChatIssues } from '../utils/workflowInterface.js';
163
+ export { resolvePlaygroundChat } from '../utils/playgroundChat.js';
163
164
  export { isChatInputNode, CHAT_INPUT_PATTERNS, defaultShouldStopPolling, defaultIsTerminalStatus, DEFAULT_STOP_POLLING_STATUSES, DEFAULT_TERMINAL_STATUSES } from '../types/playground.js';
164
165
  export { isInterruptMetadata, extractInterruptMetadata, metadataToInterrupt, defaultInterruptPollingConfig } from '../types/interrupt.js';
165
166
  // ============================================================================
@@ -127,16 +127,12 @@ export interface PlaygroundMountOptions {
127
127
  /**
128
128
  * Identifier for this playground's FlowDrop instance.
129
129
  *
130
- * When omitted, the playground uses the page-default instance — matching
131
- * the legacy behavior where all playground mounts (and the editor's
132
- * built-in playground) shared one session/message store. Pass an explicit
133
- * id to isolate this playground's session/message *state* from other
134
- * FlowDrop instances on the page.
135
- *
136
- * Note: live polling is NOT isolated — `playgroundService` keeps one
137
- * page-global polling timer, so only one playground can actively poll at
138
- * a time regardless of instance. Use `pushMessages()` with your own
139
- * transport if two playgrounds need concurrent live updates.
130
+ * When omitted, the first playground on the page uses the page-default
131
+ * instance (legacy behavior, shared with the editor's built-in playground);
132
+ * any further playground mounted without an id while the first is alive
133
+ * gets its own isolated instance. Pass an explicit id to always have a
134
+ * dedicated instance. Session/message state and live polling are both per
135
+ * instance, so playgrounds poll independently.
140
136
  */
141
137
  instanceId?: string;
142
138
  }
@@ -49,7 +49,6 @@ import PlaygroundModal from '../components/playground/PlaygroundModal.svelte';
49
49
  import PlaygroundStudio from '../components/playground/PlaygroundStudio.svelte';
50
50
  import PlaygroundApp from '../components/playground/PlaygroundApp.svelte';
51
51
  import { initializeSettings } from '../stores/settingsStore.svelte.js';
52
- import { playgroundService } from '../services/playgroundService.js';
53
52
  import { createFlowDropInstance, getDefaultInstance } from '../stores/instanceContainer.svelte.js';
54
53
  async function resolveEndpointConfig(endpointConfig) {
55
54
  if (!endpointConfig)
@@ -86,33 +85,53 @@ function sizeContainer(container, height, width) {
86
85
  if (width !== undefined)
87
86
  container.style.width = width;
88
87
  }
88
+ /** Whether a playground mount currently owns the page-default instance. */
89
+ let defaultPlaygroundClaimed = false;
89
90
  /**
90
- * Resolve the FlowDrop instance for a playground mount. No `instanceId` →
91
- * the page-default instance (legacy shared-store behavior); an explicit id →
92
- * a fresh isolated instance owned (and destroyed) by this mount.
91
+ * Resolve the FlowDrop instance for a playground mount.
92
+ *
93
+ * - Explicit `instanceId` → a fresh isolated instance owned by this mount.
94
+ * - No `instanceId` and the default is not claimed by another playground →
95
+ * the page-default instance (legacy shared-store behavior, and the one
96
+ * `playgroundService` singleton the legacy API reaches).
97
+ * - No `instanceId` but another playground holds the default → a fresh
98
+ * isolated instance, so the second mount neither shares nor wipes the
99
+ * first one's session, messages or polling.
100
+ *
101
+ * The claim is separate from the editor's (`svelte-app.ts`): an editor and a
102
+ * playground may still share the default instance, which the editor's own
103
+ * run/playground hand-off relies on.
93
104
  */
94
105
  function acquirePlaygroundInstance(instanceId) {
95
- if (instanceId) {
96
- return { fd: createFlowDropInstance({ id: instanceId }), ownsInstance: true };
106
+ if (!instanceId && !defaultPlaygroundClaimed) {
107
+ defaultPlaygroundClaimed = true;
108
+ return { fd: getDefaultInstance(), isDefault: true };
97
109
  }
98
- return { fd: getDefaultInstance(), ownsInstance: false };
110
+ return { fd: createFlowDropInstance({ id: instanceId }), isDefault: false };
99
111
  }
100
- function buildMountedPlayground(svelteApp, workflowId, config, fd, ownsInstance, onSessionStatusChange) {
112
+ function buildMountedPlayground(svelteApp, workflowId, config, fd, isDefault, onSessionStatusChange) {
101
113
  const pollingInterval = config.pollingInterval ?? 1500;
102
114
  const unsubscribeStatus = onSessionStatusChange
103
115
  ? fd.playground.subscribeToSessionStatus(onSessionStatusChange)
104
116
  : undefined;
117
+ let destroyed = false;
105
118
  return {
106
119
  destroy: () => {
120
+ // A second destroy must not release a claim another mount now holds.
121
+ if (destroyed)
122
+ return;
123
+ destroyed = true;
107
124
  unsubscribeStatus?.();
108
- // Caution (shared default instance): stopPolling is page-global and
109
- // reset() clears state other default-mounted playgrounds rely on —
110
- // pass `instanceId` to isolate. Preserved legacy behavior.
111
- playgroundService.stopPolling();
125
+ // Stops this instance's own polling and clears its session state. On the
126
+ // page-default instance that is the legacy singleton service, so a mount
127
+ // that owns the default keeps the old behavior; any other mount runs on
128
+ // an isolated instance and cannot touch a sibling playground.
129
+ fd.playgroundService.stopPolling();
112
130
  fd.playground.reset();
113
- // Fully dispose instances created for this mount; the shared default
114
- // instance only gets the reset above (legacy behavior).
115
- if (ownsInstance) {
131
+ if (isDefault) {
132
+ defaultPlaygroundClaimed = false;
133
+ }
134
+ else {
116
135
  fd.destroy();
117
136
  }
118
137
  unmount(svelteApp);
@@ -121,16 +140,16 @@ function buildMountedPlayground(svelteApp, workflowId, config, fd, ownsInstance,
121
140
  getSessions: () => fd.playground.sessions,
122
141
  getMessageCount: () => fd.playground.messageCount,
123
142
  isExecuting: () => fd.playground.isExecuting,
124
- stopPolling: () => playgroundService.stopPolling(),
143
+ stopPolling: () => fd.playgroundService.stopPolling(),
125
144
  startPolling: () => {
126
145
  const session = fd.playground.currentSession;
127
146
  if (session) {
128
- playgroundService.startPolling(fd.api.config, session.id, (response) => fd.playground.applyServerResponse(response, session.id), pollingInterval, config.shouldStopPolling, playgroundService.getLastSequenceNumber(), fd.api.authProvider);
147
+ fd.playgroundService.startPolling(fd.api.config, session.id, (response) => fd.playground.applyServerResponse(response, session.id), pollingInterval, config.shouldStopPolling, fd.playgroundService.getLastSequenceNumber(), fd.api.authProvider);
129
148
  }
130
149
  },
131
150
  pushMessages: (response) => fd.playground.applyServerResponse(response, null),
132
151
  reset: () => {
133
- playgroundService.stopPolling();
152
+ fd.playgroundService.stopPolling();
134
153
  fd.playground.reset();
135
154
  }
136
155
  };
@@ -181,7 +200,7 @@ export async function mountPlayground(container, options) {
181
200
  endpointConfig,
182
201
  settings: initialSettings
183
202
  });
184
- const { fd, ownsInstance } = acquirePlaygroundInstance(instanceId);
203
+ const { fd, isDefault } = acquirePlaygroundInstance(instanceId);
185
204
  let targetContainer = container;
186
205
  if (mode === 'modal') {
187
206
  targetContainer = document.body;
@@ -226,7 +245,7 @@ export async function mountPlayground(container, options) {
226
245
  }
227
246
  });
228
247
  }
229
- return buildMountedPlayground(svelteApp, workflowId, config, fd, ownsInstance, onSessionStatusChange);
248
+ return buildMountedPlayground(svelteApp, workflowId, config, fd, isDefault, onSessionStatusChange);
230
249
  }
231
250
  /**
232
251
  * Unmount a Playground instance
@@ -263,7 +282,7 @@ export async function mountPlaygroundStudio(container, options) {
263
282
  endpointConfig,
264
283
  settings: initialSettings
265
284
  });
266
- const { fd, ownsInstance } = acquirePlaygroundInstance(instanceId);
285
+ const { fd, isDefault } = acquirePlaygroundInstance(instanceId);
267
286
  sizeContainer(container, height, width);
268
287
  const svelteApp = mount(PlaygroundStudio, {
269
288
  target: container,
@@ -284,7 +303,7 @@ export async function mountPlaygroundStudio(container, options) {
284
303
  extraPipelineViews: pipelineViews
285
304
  }
286
305
  });
287
- return buildMountedPlayground(svelteApp, workflowId, config, fd, ownsInstance, onSessionStatusChange);
306
+ return buildMountedPlayground(svelteApp, workflowId, config, fd, isDefault, onSessionStatusChange);
288
307
  }
289
308
  /**
290
309
  * Mount the full-page PlaygroundApp (PlaygroundStudio, optionally wrapped in the
@@ -328,7 +347,7 @@ export async function mountPlaygroundApp(container, options) {
328
347
  endpointConfig,
329
348
  settings: initialSettings
330
349
  });
331
- const { fd, ownsInstance } = acquirePlaygroundInstance(instanceId);
350
+ const { fd, isDefault } = acquirePlaygroundInstance(instanceId);
332
351
  sizeContainer(container, height, width);
333
352
  const svelteApp = mount(PlaygroundApp, {
334
353
  target: container,
@@ -355,5 +374,5 @@ export async function mountPlaygroundApp(container, options) {
355
374
  onSessionNavigate
356
375
  }
357
376
  });
358
- return buildMountedPlayground(svelteApp, workflowId, config, fd, ownsInstance, onSessionStatusChange);
377
+ return buildMountedPlayground(svelteApp, workflowId, config, fd, isDefault, onSessionStatusChange);
359
378
  }
@@ -17,7 +17,7 @@
17
17
  *
18
18
  * @module schemas
19
19
  */
20
- import workflowSchema from './v1/workflow.schema.json';
20
+ import workflowSchema from './v1/workflow.schema.json' with { type: 'json' };
21
21
  /** Current workflow schema format version */
22
22
  export const WORKFLOW_SCHEMA_VERSION = '1.0.0';
23
23
  export { workflowSchema };
@@ -51,6 +51,16 @@
51
51
  "description": "Public contract for callers. Absent = the workflow declares no interface."
52
52
  }
53
53
  ]
54
+ },
55
+ "playground": {
56
+ "allOf": [
57
+ {
58
+ "$ref": "#/$defs/WorkflowPlayground"
59
+ },
60
+ {
61
+ "description": "Playground settings (the chat binding). Absent = the server predates them (before FlowDrop 2.7.0)."
62
+ }
63
+ ]
54
64
  }
55
65
  },
56
66
  "required": [
@@ -794,6 +804,99 @@
794
804
  "const"
795
805
  ]
796
806
  },
807
+ "PlaygroundChatBinding": {
808
+ "type": "object",
809
+ "description": "A workflow's chat binding: which interface inputs a chat turn fills and which\nnode output ports print as replies. Inputs are named by interface entry id,\nreplies by node id and output port id.\n",
810
+ "properties": {
811
+ "message": {
812
+ "type": [
813
+ "string",
814
+ "null"
815
+ ],
816
+ "description": "Interface input that receives the person's message."
817
+ },
818
+ "history": {
819
+ "anyOf": [
820
+ {
821
+ "allOf": [
822
+ {
823
+ "$ref": "#/$defs/PlaygroundChatHistory"
824
+ }
825
+ ],
826
+ "description": "Interface input that receives recent messages."
827
+ },
828
+ {
829
+ "type": "null"
830
+ }
831
+ ]
832
+ },
833
+ "session_id": {
834
+ "type": [
835
+ "string",
836
+ "null"
837
+ ],
838
+ "description": "Interface input that receives the session's id."
839
+ },
840
+ "message_id": {
841
+ "type": [
842
+ "string",
843
+ "null"
844
+ ],
845
+ "description": "Interface input that receives the id of the person's message."
846
+ },
847
+ "replies": {
848
+ "type": "array",
849
+ "items": {
850
+ "$ref": "#/$defs/PlaygroundReplyPort"
851
+ },
852
+ "description": "Node output ports whose values print as assistant messages."
853
+ },
854
+ "sub_workflow_replies": {
855
+ "type": "boolean",
856
+ "description": "Whether replies from sub-workflows print too."
857
+ }
858
+ },
859
+ "required": [
860
+ "replies"
861
+ ]
862
+ },
863
+ "PlaygroundChatHistory": {
864
+ "type": "object",
865
+ "description": "The interface input that receives recent messages.",
866
+ "properties": {
867
+ "input": {
868
+ "type": "string",
869
+ "description": "Interface input entry id."
870
+ },
871
+ "limit": {
872
+ "type": "integer",
873
+ "minimum": 1,
874
+ "description": "How many past user and assistant messages fill the input. The server enforces its own maximum."
875
+ }
876
+ },
877
+ "required": [
878
+ "input",
879
+ "limit"
880
+ ]
881
+ },
882
+ "PlaygroundReplyPort": {
883
+ "type": "object",
884
+ "description": "A node output port whose value prints as an assistant reply.",
885
+ "properties": {
886
+ "node_id": {
887
+ "type": "string",
888
+ "description": "Id of the node."
889
+ },
890
+ "port": {
891
+ "type": "string",
892
+ "description": "Id of the node's output port."
893
+ }
894
+ },
895
+ "required": [
896
+ "node_id",
897
+ "port"
898
+ ]
899
+ },
797
900
  "PortBinding": {
798
901
  "type": "object",
799
902
  "description": "A resolved pointer to one inner node port, used by `WorkflowInterfaceEntry.bindings`.\n",
@@ -1171,7 +1274,8 @@
1171
1274
  "$ref": "#/$defs/WorkflowInterfaceTurn"
1172
1275
  },
1173
1276
  {
1174
- "description": "What this port is for in a chat turn. Absent means the port plays no part\nin a turn. Validated by the server against its vocabulary.\n"
1277
+ "deprecated": true,
1278
+ "description": "**Deprecated** since 2.11.0, removed in 3.0: the chat binding now lives in\nthe workflow's `playground` settings. Still accepted and round-tripped; a\nworkflow without stored Playground settings falls back to it.\n\nWhat this port is for in a chat turn. Absent means the port plays no part\nin a turn. Validated by the server against its vocabulary.\n"
1175
1279
  }
1176
1280
  ]
1177
1281
  }
@@ -1183,6 +1287,7 @@
1183
1287
  ]
1184
1288
  },
1185
1289
  "WorkflowInterfaceTurn": {
1290
+ "deprecated": true,
1186
1291
  "type": "string",
1187
1292
  "enum": [
1188
1293
  "message",
@@ -1191,7 +1296,7 @@
1191
1296
  "message_id",
1192
1297
  "reply"
1193
1298
  ],
1194
- "description": "The chat-turn vocabulary of an interface port.\n\nInputs — at most one entry per value:\n- `message` — the person's message (the turn's content), a string\n- `history` — past user and assistant messages, bounded by `meta.limit`\n (default 10)\n- `session_id` — the session's id\n- `message_id` — the id of the person's message\n\nOutputs — any number:\n- `reply` — each value becomes one assistant message\n"
1299
+ "description": "**Deprecated** since 2.11.0, removed in 3.0 (see `WorkflowPlayground`).\n\nThe chat-turn vocabulary of an interface port.\n\nInputs — at most one entry per value:\n- `message` — the person's message (the turn's content), a string\n- `history` — past user and assistant messages, bounded by `meta.limit`\n (default 10)\n- `session_id` — the session's id\n- `message_id` — the id of the person's message\n\nOutputs — any number:\n- `reply` — each value becomes one assistant message\n"
1195
1300
  },
1196
1301
  "WorkflowMetadata": {
1197
1302
  "type": "object",
@@ -1309,6 +1414,39 @@
1309
1414
  "position",
1310
1415
  "data"
1311
1416
  ]
1417
+ },
1418
+ "WorkflowPlayground": {
1419
+ "type": "object",
1420
+ "description": "Playground settings of a workflow (FlowDrop 2.7.0 and later). Sent with every\nworkflow read. On save the client sends only `{\"chat\": ...}`: `chat: null`\nclears the stored settings, and a request without the `playground` key\nleaves them alone. The server answers 422 with problems for an invalid\nbinding.\n",
1421
+ "properties": {
1422
+ "chat": {
1423
+ "anyOf": [
1424
+ {
1425
+ "allOf": [
1426
+ {
1427
+ "$ref": "#/$defs/PlaygroundChatBinding"
1428
+ }
1429
+ ],
1430
+ "description": "The stored chat binding; null when none is stored."
1431
+ },
1432
+ {
1433
+ "type": "null"
1434
+ }
1435
+ ]
1436
+ },
1437
+ "resolved": {
1438
+ "allOf": [
1439
+ {
1440
+ "$ref": "#/$defs/PlaygroundChatBinding"
1441
+ }
1442
+ ],
1443
+ "description": "The binding in effect (never null); read-only, ignored on save."
1444
+ },
1445
+ "source": {
1446
+ "type": "string",
1447
+ "description": "Where the binding in effect comes from: `settings`, `interface_turn`\n(the deprecated interface `turn` annotations) or `none`. Clients should\ntolerate other values. Read-only, ignored on save.\n"
1448
+ }
1449
+ }
1312
1450
  }
1313
1451
  }
1314
1452
  }
@@ -12,6 +12,7 @@ import { getDefaultInstance } from '../stores/instanceContainer.svelte.js';
12
12
  import { createEndpointConfig } from '../config/endpoints.js';
13
13
  import { v4 as uuidv4 } from 'uuid';
14
14
  import { DEFAULT_WORKFLOW_FORMAT } from '../types/index.js';
15
+ import { playgroundForSave } from '../utils/playgroundChat.js';
15
16
  import { apiToasts, workflowToasts, dismissToast } from './toastService.js';
16
17
  import { DEFAULT_FEATURES } from '../types/events.js';
17
18
  // ---------------------------------------------------------------------------
@@ -131,6 +132,12 @@ export async function globalSaveWorkflow(options = {}) {
131
132
  // omitting `interface` silently strips the declared contract on save
132
133
  // (absent means "declares no interface" to the server).
133
134
  ...(currentWorkflow.interface !== undefined && { interface: currentWorkflow.interface }),
135
+ // Same rule for the Playground settings (the chat binding, saved with
136
+ // the workflow). Only `chat` goes back; a workflow from a server that
137
+ // sends no `playground` key sends none either.
138
+ ...(currentWorkflow.playground !== undefined && {
139
+ playground: playgroundForSave(currentWorkflow.playground)
140
+ }),
134
141
  // The revision the editor loaded, so a server that checks it can refuse
135
142
  // a stale write (409 CONFLICT) instead of letting the last write win.
136
143
  ...(currentWorkflow.revision !== undefined && { revision: currentWorkflow.revision })
@@ -239,7 +246,10 @@ export async function globalExportWorkflow(options = {}) {
239
246
  },
240
247
  // Same rule as the save path: the export must carry the declared
241
248
  // contract, or a re-import round-trip loses `interface`.
242
- ...(currentWorkflow.interface !== undefined && { interface: currentWorkflow.interface })
249
+ ...(currentWorkflow.interface !== undefined && { interface: currentWorkflow.interface }),
250
+ ...(currentWorkflow.playground !== undefined && {
251
+ playground: playgroundForSave(currentWorkflow.playground)
252
+ })
243
253
  };
244
254
  // Trigger browser download
245
255
  const dataStr = JSON.stringify(finalWorkflow, null, 2);
@@ -35,7 +35,12 @@ export declare class PlaygroundService {
35
35
  private pollingSessionId;
36
36
  private currentBackoff;
37
37
  private lastSequenceNumber;
38
- private constructor();
38
+ /**
39
+ * Polling state is per object: the page singleton backs the default
40
+ * FlowDrop instance (and legacy callers); every other instance owns its own
41
+ * object, so one session polling does not stop another.
42
+ */
43
+ constructor();
39
44
  /**
40
45
  * Get the singleton instance of PlaygroundService
41
46
  *
@@ -30,6 +30,11 @@ export class PlaygroundService {
30
30
  pollingSessionId = null;
31
31
  currentBackoff = DEFAULT_POLLING_INTERVAL;
32
32
  lastSequenceNumber = null;
33
+ /**
34
+ * Polling state is per object: the page singleton backs the default
35
+ * FlowDrop instance (and legacy callers); every other instance owns its own
36
+ * object, so one session polling does not stop another.
37
+ */
33
38
  constructor() { }
34
39
  /**
35
40
  * Get the singleton instance of PlaygroundService
@@ -1,2 +1,2 @@
1
- import type { FlowDropSkin } from '../types/skin';
1
+ import type { FlowDropSkin } from '../types/skin.js';
2
2
  export declare const defaultSkin: FlowDropSkin;
@@ -1,4 +1,4 @@
1
- import type { FlowDropSkin } from '../types/skin';
1
+ import type { FlowDropSkin } from '../types/skin.js';
2
2
  /**
3
3
  * Drafter — a fresh, modern "drafting workspace" skin for the whole editor
4
4
  * environment (see ref-image.png): a fresh white shell around a mint/aqua
@@ -1,7 +1,7 @@
1
- import type { FlowDropSkin, FlowDropSkinName } from '../types/skin';
2
- import { defaultSkin } from './default';
3
- import { slateSkin } from './slate';
4
- import { drafterSkin } from './drafter';
1
+ import type { FlowDropSkin, FlowDropSkinName } from '../types/skin.js';
2
+ import { defaultSkin } from './default.js';
3
+ import { slateSkin } from './slate.js';
4
+ import { drafterSkin } from './drafter.js';
5
5
  /**
6
6
  * Resolve a skin prop to a complete FlowDropSkin object.
7
7
  *
@@ -1,6 +1,6 @@
1
- import { defaultSkin } from './default';
2
- import { slateSkin } from './slate';
3
- import { drafterSkin } from './drafter';
1
+ import { defaultSkin } from './default.js';
2
+ import { slateSkin } from './slate.js';
3
+ import { drafterSkin } from './drafter.js';
4
4
  const builtinSkins = {
5
5
  default: defaultSkin,
6
6
  slate: slateSkin,