@flowdrop/flowdrop 2.11.0 → 2.13.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.
- package/CHANGELOG.md +233 -0
- package/dist/adapters/agentspec/autoLayout.d.ts +18 -36
- package/dist/adapters/agentspec/autoLayout.js +75 -93
- package/dist/chat/activity.d.ts +49 -0
- package/dist/chat/activity.js +65 -0
- package/dist/chat/commandClassifier.js +2 -1
- package/dist/commands/executor.js +186 -27
- package/dist/commands/index.d.ts +2 -1
- package/dist/commands/index.js +2 -0
- package/dist/commands/parser.js +43 -3
- package/dist/commands/session.d.ts +60 -0
- package/dist/commands/session.js +332 -0
- package/dist/commands/storeIntegration.svelte.js +18 -1
- package/dist/commands/types.d.ts +77 -4
- package/dist/components/App.svelte +976 -226
- package/dist/components/App.svelte.d.ts +34 -2
- package/dist/components/BindablePortListbox.svelte +68 -369
- package/dist/components/Button.svelte +17 -14
- package/dist/components/Button.svelte.d.ts +2 -2
- package/dist/components/CanvasContextMenu.svelte +31 -10
- package/dist/components/CanvasController.svelte +146 -3
- package/dist/components/CanvasController.svelte.d.ts +25 -33
- package/dist/components/CanvasIconButton.svelte +6 -6
- package/dist/components/CanvasToolbar.svelte +103 -0
- package/dist/components/CanvasToolbar.svelte.d.ts +23 -0
- package/dist/components/CanvasZoomControls.svelte +122 -0
- package/dist/components/CanvasZoomControls.svelte.d.ts +15 -0
- package/dist/components/ConfigForm.svelte +159 -121
- package/dist/components/ConfigModal.svelte +11 -54
- package/dist/components/ConfigPanel.svelte +98 -228
- package/dist/components/ConfigPanel.svelte.d.ts +2 -2
- package/dist/components/ConnectPortPicker.svelte +153 -0
- package/dist/components/ConnectPortPicker.svelte.d.ts +22 -0
- package/dist/components/DoctorMenu.svelte +422 -0
- package/dist/components/DoctorMenu.svelte.d.ts +7 -0
- package/dist/components/ExternalLinkRow.svelte +82 -0
- package/dist/components/ExternalLinkRow.svelte.d.ts +14 -0
- package/dist/components/FlowDropEdge.svelte +52 -2
- package/dist/components/FlowDropEdge.svelte.d.ts +5 -1
- package/dist/components/InterfaceNameInput.svelte +103 -0
- package/dist/components/InterfaceNameInput.svelte.d.ts +13 -0
- package/dist/components/InterfaceTag.svelte +215 -0
- package/dist/components/InterfaceTag.svelte.d.ts +20 -0
- package/dist/components/InterfaceTagAnchor.svelte +103 -0
- package/dist/components/InterfaceTagAnchor.svelte.d.ts +12 -0
- package/dist/components/InterfaceTagLayer.svelte +314 -0
- package/dist/components/InterfaceTagLayer.svelte.d.ts +28 -0
- package/dist/components/LogsSidebar.svelte +43 -43
- package/dist/components/LoopbackLanes.svelte +54 -0
- package/dist/components/LoopbackLanes.svelte.d.ts +8 -0
- package/dist/components/Navbar.svelte +539 -169
- package/dist/components/Navbar.svelte.d.ts +20 -1
- package/dist/components/NodeInspector.svelte +153 -0
- package/dist/components/NodeInspector.svelte.d.ts +19 -0
- package/dist/components/NodeLastRun.svelte +212 -0
- package/dist/components/NodeLastRun.svelte.d.ts +13 -0
- package/dist/components/NodeSidebar.svelte +279 -23
- package/dist/components/NodeSidebar.svelte.d.ts +11 -0
- package/dist/components/NodeStatusOverlay.svelte +144 -353
- package/dist/components/NodeStatusOverlay.svelte.d.ts +4 -1
- package/dist/components/PortMappingRow.svelte +28 -44
- package/dist/components/PortPickerListbox.svelte +475 -0
- package/dist/components/PortPickerListbox.svelte.d.ts +73 -0
- package/dist/components/ReadOnlyDetails.svelte +52 -89
- package/dist/components/RunBar.svelte +222 -0
- package/dist/components/RunBar.svelte.d.ts +20 -0
- package/dist/components/RunsMenu.svelte +649 -0
- package/dist/components/RunsMenu.svelte.d.ts +14 -0
- package/dist/components/SettingsModal.svelte +27 -59
- package/dist/components/SettingsPanel.svelte +515 -241
- package/dist/components/StraightGuides.svelte +46 -0
- package/dist/components/StraightGuides.svelte.d.ts +7 -0
- package/dist/components/ThemeToggle.svelte +14 -4
- package/dist/components/UniversalNode.svelte +152 -51
- package/dist/components/WebMCPBridgeMenu.svelte +336 -0
- package/dist/components/WebMCPBridgeMenu.svelte.d.ts +3 -0
- package/dist/components/WorkflowEditor.svelte +789 -136
- package/dist/components/WorkflowEditor.svelte.d.ts +43 -1
- package/dist/components/WorkflowInterfaceEditor.svelte +63 -92
- package/dist/components/WorkflowInterfaceEntryCard.svelte +478 -549
- package/dist/components/WorkflowInterfaceEntryComposer.svelte +23 -67
- package/dist/components/WorkflowPlaygroundSettings.svelte +48 -85
- package/dist/components/WorkflowSettingsPanel.svelte +311 -0
- package/dist/components/WorkflowSettingsPanel.svelte.d.ts +20 -0
- package/dist/components/ZoomTier.svelte +56 -0
- package/dist/components/ZoomTier.svelte.d.ts +4 -0
- package/dist/components/chat/AIChatPanel.svelte +463 -312
- package/dist/components/chat/ActivityList.svelte +130 -0
- package/dist/components/chat/ActivityList.svelte.d.ts +11 -0
- package/dist/components/chat/ActivityRow.svelte +179 -0
- package/dist/components/chat/ActivityRow.svelte.d.ts +16 -0
- package/dist/components/chat/CommandPreview.svelte +42 -64
- package/dist/components/console/CommandConsole.svelte +106 -41
- package/dist/components/console/CommandConsole.svelte.d.ts +2 -0
- package/dist/components/console/ConsoleAutocomplete.svelte +14 -13
- package/dist/components/console/ConsoleInput.svelte +60 -27
- package/dist/components/console/ConsoleOutput.svelte +86 -24
- package/dist/components/console/ConsoleStrip.svelte +80 -0
- package/dist/components/console/ConsoleStrip.svelte.d.ts +13 -0
- package/dist/components/form/FieldFactory.svelte +30 -4
- package/dist/components/form/FormArray.svelte +306 -339
- package/dist/components/form/FormArray.svelte.d.ts +10 -0
- package/dist/components/form/FormArrayRows.svelte +443 -0
- package/dist/components/form/FormArrayRows.svelte.d.ts +18 -0
- package/dist/components/form/FormAutocomplete.svelte +2 -2
- package/dist/components/form/FormCheckboxGroup.svelte +10 -85
- package/dist/components/form/FormCodeEditor.svelte +3 -3
- package/dist/components/form/FormFieldWrapper.svelte +98 -18
- package/dist/components/form/FormFieldWrapper.svelte.d.ts +10 -0
- package/dist/components/form/FormFieldset.svelte +44 -28
- package/dist/components/form/FormMarkdownEditor.svelte +6 -6
- package/dist/components/form/FormPorts.svelte +437 -141
- package/dist/components/form/FormSelect.svelte +1 -1
- package/dist/components/form/FormTemplateEditor.svelte +22 -26
- package/dist/components/form/FormToggle.svelte +15 -106
- package/dist/components/form/FormToggle.svelte.d.ts +3 -2
- package/dist/components/form/FormUISchemaRenderer.svelte +38 -3
- package/dist/components/form/humanizeKey.d.ts +7 -0
- package/dist/components/form/humanizeKey.js +21 -0
- package/dist/components/form/types.d.ts +6 -0
- package/dist/components/icons/MenuOpenIcon.svelte +8 -1
- package/dist/components/interrupt/ChoicePrompt.svelte +51 -152
- package/dist/components/interrupt/ChoicePrompt.svelte.d.ts +0 -2
- package/dist/components/interrupt/ConfirmationPrompt.svelte +18 -201
- package/dist/components/interrupt/ConfirmationPrompt.svelte.d.ts +0 -4
- package/dist/components/interrupt/FormPrompt.svelte +22 -147
- package/dist/components/interrupt/FormPrompt.svelte.d.ts +0 -4
- package/dist/components/interrupt/InterruptBubble.svelte +198 -355
- package/dist/components/interrupt/InterruptBubble.svelte.d.ts +0 -2
- package/dist/components/interrupt/ReviewPrompt.svelte +0 -10
- package/dist/components/interrupt/TextInputPrompt.svelte +23 -120
- package/dist/components/interrupt/TextInputPrompt.svelte.d.ts +0 -2
- package/dist/components/layouts/MainLayout.svelte +110 -75
- package/dist/components/layouts/MainLayout.svelte.d.ts +17 -0
- package/dist/components/nodes/CaptionNode.svelte +7 -0
- package/dist/components/nodes/GatewayNode.svelte +66 -431
- package/dist/components/nodes/IdeaNode.svelte +6 -5
- package/dist/components/nodes/NodeCard.svelte +1051 -0
- package/dist/components/nodes/NodeCard.svelte.d.ts +30 -0
- package/dist/components/nodes/NodeConfigButton.svelte +28 -9
- package/dist/components/nodes/NodeProblemMark.svelte +113 -0
- package/dist/components/nodes/NodeProblemMark.svelte.d.ts +8 -0
- package/dist/components/nodes/NodeTip.svelte +104 -0
- package/dist/components/nodes/NodeTip.svelte.d.ts +15 -0
- package/dist/components/nodes/NotesNode.svelte +183 -150
- package/dist/components/nodes/SimpleNode.svelte +176 -44
- package/dist/components/nodes/SquareNode.svelte +127 -34
- package/dist/components/nodes/TerminalNode.svelte +232 -88
- package/dist/components/nodes/ToolNode.svelte +49 -381
- package/dist/components/nodes/WorkflowNode.svelte +40 -399
- package/dist/components/playground/ChatBubble.svelte +248 -62
- package/dist/components/playground/ChatInput.svelte +134 -297
- package/dist/components/playground/ChatInput.svelte.d.ts +17 -0
- package/dist/components/playground/ControlPanel.svelte +290 -190
- package/dist/components/playground/ControlPanel.svelte.d.ts +10 -2
- package/dist/components/playground/DockedPlayground.svelte +82 -0
- package/dist/components/playground/DockedPlayground.svelte.d.ts +30 -0
- package/dist/components/playground/ExecutionConsole.svelte +54 -36
- package/dist/components/playground/ExecutionConsole.svelte.d.ts +12 -0
- package/dist/components/playground/ExecutionLogs.svelte +4 -0
- package/dist/components/playground/HeaderMenu.svelte +170 -0
- package/dist/components/playground/HeaderMenu.svelte.d.ts +22 -0
- package/dist/components/playground/InputCollector.svelte +8 -32
- package/dist/components/playground/InputFields.svelte +246 -0
- package/dist/components/playground/InputFields.svelte.d.ts +16 -0
- package/dist/components/playground/InterfaceInputForm.svelte +285 -30
- package/dist/components/playground/InterfaceInputForm.svelte.d.ts +20 -0
- package/dist/components/playground/InterfaceJsonInput.svelte +92 -0
- package/dist/components/playground/InterfaceJsonInput.svelte.d.ts +10 -0
- package/dist/components/playground/LogRow.svelte +12 -12
- package/dist/components/playground/MessageMarkdown.svelte +11 -11
- package/dist/components/playground/MessageStream.svelte +154 -182
- package/dist/components/playground/Playground.svelte +17 -1139
- package/dist/components/playground/PlaygroundApp.svelte +12 -2
- package/dist/components/playground/PlaygroundApp.svelte.d.ts +2 -1
- package/dist/components/playground/PlaygroundHeader.svelte +309 -0
- package/dist/components/playground/PlaygroundHeader.svelte.d.ts +22 -0
- package/dist/components/playground/PlaygroundModal.svelte +6 -0
- package/dist/components/playground/PlaygroundStudio.svelte +30 -32
- package/dist/components/playground/PlaygroundSurface.svelte +648 -0
- package/dist/components/playground/PlaygroundSurface.svelte.d.ts +79 -0
- package/dist/components/playground/StepsSummary.svelte +312 -0
- package/dist/components/playground/StepsSummary.svelte.d.ts +11 -0
- package/dist/components/playground/messageDisplay.d.ts +9 -0
- package/dist/components/playground/messageDisplay.js +24 -2
- package/dist/components/playground/stepSummary.d.ts +71 -0
- package/dist/components/playground/stepSummary.js +152 -0
- package/dist/components/ports/PortTypeBadge.svelte +13 -1
- package/dist/components/primitives/Button.svelte +226 -0
- package/dist/components/primitives/Button.svelte.d.ts +31 -0
- package/dist/components/primitives/Card.svelte +110 -0
- package/dist/components/primitives/Card.svelte.d.ts +20 -0
- package/dist/components/primitives/Checkbox.svelte +126 -0
- package/dist/components/primitives/Checkbox.svelte.d.ts +15 -0
- package/dist/components/primitives/Chip.svelte +143 -0
- package/dist/components/primitives/Chip.svelte.d.ts +22 -0
- package/dist/components/primitives/Combobox.svelte +444 -0
- package/dist/components/primitives/Combobox.svelte.d.ts +22 -0
- package/dist/components/primitives/Composer.svelte +293 -0
- package/dist/components/primitives/Composer.svelte.d.ts +47 -0
- package/dist/components/primitives/EmptyState.svelte +113 -0
- package/dist/components/primitives/EmptyState.svelte.d.ts +18 -0
- package/dist/components/primitives/Field.svelte +178 -0
- package/dist/components/primitives/Field.svelte.d.ts +30 -0
- package/dist/components/primitives/IconButton.svelte +156 -0
- package/dist/components/primitives/IconButton.svelte.d.ts +27 -0
- package/dist/components/primitives/Menu.svelte +435 -0
- package/dist/components/primitives/Menu.svelte.d.ts +61 -0
- package/dist/components/primitives/Notice.svelte +161 -0
- package/dist/components/primitives/Notice.svelte.d.ts +22 -0
- package/dist/components/primitives/PanelHeader.svelte +134 -0
- package/dist/components/primitives/PanelHeader.svelte.d.ts +23 -0
- package/dist/components/primitives/Segmented.svelte +198 -0
- package/dist/components/primitives/Segmented.svelte.d.ts +32 -0
- package/dist/components/primitives/Select.svelte +130 -0
- package/dist/components/primitives/Select.svelte.d.ts +26 -0
- package/dist/components/primitives/StatusPill.svelte +218 -0
- package/dist/components/primitives/StatusPill.svelte.d.ts +24 -0
- package/dist/components/primitives/Switch.svelte +113 -0
- package/dist/components/primitives/Switch.svelte.d.ts +14 -0
- package/dist/components/primitives/Tabs.svelte +209 -0
- package/dist/components/primitives/Tabs.svelte.d.ts +32 -0
- package/dist/components/primitives/Toolbar.svelte +94 -0
- package/dist/components/primitives/Toolbar.svelte.d.ts +14 -0
- package/dist/components/primitives/ToolbarSeparator.svelte +40 -0
- package/dist/components/primitives/ToolbarSeparator.svelte.d.ts +7 -0
- package/dist/components/surfaces/SurfaceOverlay.svelte +10 -40
- package/dist/components/surfaces/TabbedSurface.svelte +49 -39
- package/dist/components/surfaces/TabbedSurface.svelte.d.ts +8 -0
- package/dist/components/toast/DismissibleToast.svelte +94 -32
- package/dist/components/toast/DismissibleToast.svelte.d.ts +17 -7
- package/dist/config/endpoints.d.ts +43 -1
- package/dist/config/endpoints.js +21 -3
- package/dist/core/index.d.ts +8 -5
- package/dist/core/index.js +1 -1
- package/dist/editor/connectCandidates.d.ts +56 -0
- package/dist/editor/connectCandidates.js +131 -0
- package/dist/editor/contextMenu.d.ts +31 -2
- package/dist/editor/contextMenu.js +96 -9
- package/dist/editor/index.d.ts +4 -1
- package/dist/editor/index.js +1 -0
- package/dist/editor/interfaceMenu.d.ts +35 -0
- package/dist/editor/interfaceMenu.js +47 -0
- package/dist/editor/portMenu.d.ts +23 -0
- package/dist/editor/portMenu.js +34 -0
- package/dist/editor/tidy.d.ts +30 -0
- package/dist/editor/tidy.js +66 -0
- package/dist/helpers/workflowEditorHelper.d.ts +3 -0
- package/dist/helpers/workflowEditorHelper.js +8 -3
- package/dist/layout/fromWorkflow.d.ts +42 -0
- package/dist/layout/fromWorkflow.js +135 -0
- package/dist/layout/geometry.d.ts +102 -0
- package/dist/layout/geometry.js +317 -0
- package/dist/layout/index.d.ts +21 -0
- package/dist/layout/index.js +14 -0
- package/dist/layout/inspect.d.ts +18 -0
- package/dist/layout/inspect.js +81 -0
- package/dist/layout/lanePath.d.ts +23 -0
- package/dist/layout/lanePath.js +47 -0
- package/dist/layout/measure.d.ts +141 -0
- package/dist/layout/measure.js +477 -0
- package/dist/layout/primitives.d.ts +124 -0
- package/dist/layout/primitives.js +461 -0
- package/dist/layout/sweep.d.ts +59 -0
- package/dist/layout/sweep.js +257 -0
- package/dist/layout/toWorkflow.d.ts +43 -0
- package/dist/layout/toWorkflow.js +131 -0
- package/dist/layout/types.d.ts +93 -0
- package/dist/layout/types.js +35 -0
- package/dist/messages/defaults.d.ts +641 -26
- package/dist/messages/defaults.js +578 -25
- package/dist/messages/types.d.ts +21 -1
- package/dist/openapi/v1/openapi.yaml +109 -0
- package/dist/playground/index.d.ts +28 -1
- package/dist/playground/index.js +29 -0
- package/dist/playground/mount.d.ts +28 -2
- package/dist/playground/mount.js +41 -15
- package/dist/playground/runAction.d.ts +29 -0
- package/dist/playground/runAction.js +38 -0
- package/dist/services/doctorService.d.ts +52 -0
- package/dist/services/doctorService.js +113 -0
- package/dist/services/globalSave.js +12 -29
- package/dist/services/nodeExecutionService.d.ts +12 -1
- package/dist/services/nodeExecutionService.js +58 -58
- package/dist/services/playgroundService.d.ts +17 -2
- package/dist/services/playgroundService.js +48 -5
- package/dist/services/runsService.d.ts +42 -0
- package/dist/services/runsService.js +87 -0
- package/dist/services/toastQueue.d.ts +33 -0
- package/dist/services/toastQueue.js +38 -0
- package/dist/services/toastService.d.ts +30 -9
- package/dist/services/toastService.js +81 -46
- package/dist/settings/index.d.ts +1 -0
- package/dist/skins/graphite.d.ts +26 -0
- package/dist/skins/graphite.js +473 -0
- package/dist/skins/index.d.ts +2 -1
- package/dist/skins/index.js +4 -2
- package/dist/skins/slate.js +4 -4
- package/dist/stores/attachedRunStore.svelte.d.ts +35 -0
- package/dist/stores/attachedRunStore.svelte.js +47 -0
- package/dist/stores/connectDragStore.svelte.d.ts +39 -0
- package/dist/stores/connectDragStore.svelte.js +42 -0
- package/dist/stores/doctorStore.svelte.d.ts +79 -0
- package/dist/stores/doctorStore.svelte.js +244 -0
- package/dist/stores/editedNodesStore.svelte.d.ts +42 -0
- package/dist/stores/editedNodesStore.svelte.js +84 -0
- package/dist/stores/editorModeStore.svelte.d.ts +34 -0
- package/dist/stores/editorModeStore.svelte.js +55 -0
- package/dist/stores/instanceContainer.svelte.d.ts +53 -0
- package/dist/stores/instanceContainer.svelte.js +38 -1
- package/dist/stores/loopbackLanesStore.svelte.d.ts +18 -0
- package/dist/stores/loopbackLanesStore.svelte.js +25 -0
- package/dist/stores/nodeHighlightStore.svelte.d.ts +34 -0
- package/dist/stores/nodeHighlightStore.svelte.js +56 -0
- package/dist/stores/playgroundStore.svelte.d.ts +66 -2
- package/dist/stores/playgroundStore.svelte.js +164 -2
- package/dist/stores/runController.svelte.d.ts +382 -0
- package/dist/stores/runController.svelte.js +1217 -0
- package/dist/stores/settingsStore.svelte.d.ts +80 -18
- package/dist/stores/settingsStore.svelte.js +180 -62
- package/dist/stores/workflowStore.svelte.d.ts +14 -0
- package/dist/stores/workflowStore.svelte.js +22 -1
- package/dist/styles/base.css +286 -25
- package/dist/styles/fonts/Inter-LICENSE.txt +93 -0
- package/dist/styles/fonts/inter-latin-wght-normal.woff2 +0 -0
- package/dist/styles/fonts/inter.css +19 -0
- package/dist/styles/toast.css +100 -20
- package/dist/styles/tokenAliases.js +118 -1
- package/dist/styles/tokens.css +586 -14
- package/dist/svelte-app.d.ts +47 -5
- package/dist/svelte-app.js +15 -3
- package/dist/themes/graphite.d.ts +2 -0
- package/dist/themes/graphite.js +15 -0
- package/dist/themes/index.d.ts +2 -1
- package/dist/themes/index.js +22 -3
- package/dist/themes/minimal.js +10 -0
- package/dist/themes/scopedSkinCss.d.ts +22 -5
- package/dist/themes/scopedSkinCss.js +136 -11
- package/dist/types/chat.d.ts +6 -0
- package/dist/types/doctor.d.ts +82 -0
- package/dist/types/doctor.js +11 -0
- package/dist/types/events.d.ts +35 -0
- package/dist/types/events.js +4 -1
- package/dist/types/index.d.ts +17 -2
- package/dist/types/navbar.d.ts +36 -0
- package/dist/types/playground.d.ts +75 -0
- package/dist/types/settings.d.ts +120 -7
- package/dist/types/settings.js +35 -3
- package/dist/types/skin.d.ts +21 -8
- package/dist/types/theme.d.ts +40 -2
- package/dist/utils/appearance.d.ts +19 -0
- package/dist/utils/appearance.js +13 -0
- package/dist/utils/canvasFit.d.ts +41 -0
- package/dist/utils/canvasFit.js +44 -0
- package/dist/utils/chipTitles.d.ts +9 -0
- package/dist/utils/chipTitles.js +19 -0
- package/dist/utils/connections.js +8 -0
- package/dist/utils/consoleHighlight.d.ts +28 -0
- package/dist/utils/consoleHighlight.js +269 -0
- package/dist/utils/deprecation.d.ts +17 -0
- package/dist/utils/deprecation.js +29 -0
- package/dist/utils/doctorOperations.d.ts +40 -0
- package/dist/utils/doctorOperations.js +237 -0
- package/dist/utils/duration.d.ts +13 -0
- package/dist/utils/duration.js +40 -0
- package/dist/utils/inspectorContext.d.ts +19 -0
- package/dist/utils/inspectorContext.js +12 -0
- package/dist/utils/inspectorSections.d.ts +20 -0
- package/dist/utils/inspectorSections.js +44 -0
- package/dist/utils/inspectorSurface.d.ts +46 -0
- package/dist/utils/inspectorSurface.js +51 -0
- package/dist/utils/interfaceTags.d.ts +102 -0
- package/dist/utils/interfaceTags.js +211 -0
- package/dist/utils/itemRef.d.ts +86 -0
- package/dist/utils/itemRef.js +106 -0
- package/dist/utils/lastRun.d.ts +35 -0
- package/dist/utils/lastRun.js +73 -0
- package/dist/utils/messageNodeLink.d.ts +17 -0
- package/dist/utils/messageNodeLink.js +16 -0
- package/dist/utils/minimapVisibility.d.ts +28 -0
- package/dist/utils/minimapVisibility.js +34 -0
- package/dist/utils/nodeAriaLabel.d.ts +12 -0
- package/dist/utils/nodeAriaLabel.js +17 -0
- package/dist/utils/nodeFingerprint.d.ts +27 -0
- package/dist/utils/nodeFingerprint.js +66 -0
- package/dist/utils/nodeFormSchema.d.ts +10 -0
- package/dist/utils/nodeFormSchema.js +2 -2
- package/dist/utils/nodeGeometry.d.ts +168 -0
- package/dist/utils/nodeGeometry.js +204 -0
- package/dist/utils/nodeProblem.d.ts +19 -0
- package/dist/utils/nodeProblem.js +9 -0
- package/dist/utils/nodeStatus.d.ts +38 -3
- package/dist/utils/nodeStatus.js +67 -39
- package/dist/utils/nodeSwap.js +9 -1
- package/dist/utils/nodeWrapper.d.ts +1 -0
- package/dist/utils/playgroundHistory.d.ts +48 -0
- package/dist/utils/playgroundHistory.js +38 -0
- package/dist/utils/playgroundInputRuns.d.ts +26 -0
- package/dist/utils/playgroundInputRuns.js +50 -0
- package/dist/utils/portExposure.d.ts +49 -0
- package/dist/utils/portExposure.js +122 -0
- package/dist/utils/portUtils.d.ts +16 -0
- package/dist/utils/portUtils.js +37 -0
- package/dist/utils/portal.d.ts +0 -19
- package/dist/utils/portal.js +8 -1
- package/dist/utils/reservedPorts.d.ts +59 -0
- package/dist/utils/reservedPorts.js +60 -0
- package/dist/utils/runEdges.d.ts +24 -0
- package/dist/utils/runEdges.js +35 -0
- package/dist/utils/runsList.d.ts +69 -0
- package/dist/utils/runsList.js +134 -0
- package/dist/utils/selectOptions.d.ts +62 -0
- package/dist/utils/selectOptions.js +137 -0
- package/dist/utils/sessionRuns.d.ts +62 -0
- package/dist/utils/sessionRuns.js +123 -0
- package/dist/utils/sheetWidths.d.ts +29 -0
- package/dist/utils/sheetWidths.js +41 -0
- package/dist/utils/sidebarWidths.d.ts +34 -0
- package/dist/utils/sidebarWidths.js +47 -0
- package/dist/utils/straightWires.d.ts +73 -0
- package/dist/utils/straightWires.js +99 -0
- package/dist/utils/themeScope.svelte.d.ts +10 -0
- package/dist/utils/themeScope.svelte.js +80 -0
- package/dist/utils/wiredHandles.d.ts +10 -0
- package/dist/utils/wiredHandles.js +14 -0
- package/dist/utils/workflowDraft.d.ts +9 -0
- package/dist/utils/workflowDraft.js +39 -0
- package/dist/utils/workflowInterface.d.ts +40 -7
- package/dist/utils/workflowInterface.js +66 -16
- package/dist/utils/zoomTier.d.ts +43 -0
- package/dist/utils/zoomTier.js +107 -0
- package/dist/utils/zoomTierRows.d.ts +41 -0
- package/dist/utils/zoomTierRows.js +103 -0
- package/dist/webmcp/WebMCPConfirm.svelte +1 -1
- package/dist/webmcp/bridge.d.ts +5 -0
- package/dist/webmcp/bridge.js +8 -0
- package/dist/webmcp/bridgeController.svelte.d.ts +84 -0
- package/dist/webmcp/bridgeController.svelte.js +224 -0
- package/dist/webmcp/descriptors.d.ts +1 -1
- package/dist/webmcp/descriptors.js +66 -5
- package/dist/webmcp/fakeWidget.d.ts +34 -0
- package/dist/webmcp/fakeWidget.js +75 -0
- package/dist/webmcp/gate.js +4 -0
- package/dist/webmcp/index.d.ts +2 -0
- package/dist/webmcp/index.js +1 -0
- package/dist/webmcp/runtime.js +4 -1
- package/dist/webmcp/types.d.ts +2 -0
- package/dist/webmcp/validate.js +5 -1
- package/package.json +8 -2
- package/dist/components/Select.svelte +0 -53
- package/dist/components/Select.svelte.d.ts +0 -15
- package/dist/components/icons/CommandLineIcon.svelte +0 -15
- package/dist/components/icons/CommandLineIcon.svelte.d.ts +0 -26
- package/dist/components/toast/WarningIcon.svelte +0 -28
- package/dist/components/toast/WarningIcon.svelte.d.ts +0 -26
|
@@ -1,56 +1,29 @@
|
|
|
1
1
|
<!--
|
|
2
2
|
Playground Component
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
between them.
|
|
8
|
-
|
|
9
|
-
Used by PlaygroundStudio (standalone), PlaygroundModal (modal), and the
|
|
4
|
+
The standalone Playground: the conversation surface (PlaygroundSurface) with
|
|
5
|
+
the props the standalone entry points have always passed. Used by
|
|
6
|
+
PlaygroundStudio (standalone), PlaygroundModal (modal), and the
|
|
10
7
|
/workflow/[id]/playground/[sessionId] route.
|
|
11
|
-
-->
|
|
12
8
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* is seen on the next page load.
|
|
21
|
-
*/
|
|
22
|
-
const serversWithoutPlaygroundSettings = new Set<string>();
|
|
23
|
-
</script>
|
|
9
|
+
Deprecated in favour of the editor's Test mode and removed in 3.0 (see the
|
|
10
|
+
plan's T13). Keep this file a thin wrapper: anything the docked Playground
|
|
11
|
+
of Test mode needs belongs in PlaygroundSurface, so it survives this
|
|
12
|
+
file's removal.
|
|
13
|
+
|
|
14
|
+
It warns once per page when mounted (utils/deprecation.ts).
|
|
15
|
+
-->
|
|
24
16
|
|
|
25
17
|
<script lang="ts">
|
|
26
|
-
import {
|
|
27
|
-
import
|
|
28
|
-
import ExecutionConsole from './ExecutionConsole.svelte';
|
|
29
|
-
import ControlPanel from './ControlPanel.svelte';
|
|
18
|
+
import { warnStandalonePlaygroundDeprecated } from '../../utils/deprecation.js';
|
|
19
|
+
import PlaygroundSurface from './PlaygroundSurface.svelte';
|
|
30
20
|
import type { Workflow } from '../../types/index.js';
|
|
31
21
|
import type { EndpointConfig } from '../../config/endpoints.js';
|
|
32
22
|
import type { AuthProvider } from '../../types/auth.js';
|
|
33
|
-
import type {
|
|
34
|
-
PlaygroundMode,
|
|
35
|
-
PlaygroundConfig,
|
|
36
|
-
PlaygroundSessionStatus
|
|
37
|
-
} from '../../types/playground.js';
|
|
38
|
-
import { pipelineSignalService } from '../../services/pipelineSignalService.js';
|
|
39
|
-
import { workflowLaunchService } from '../../services/workflowLaunchService.js';
|
|
40
|
-
import { provideInstance } from '../../stores/getInstance.svelte.js';
|
|
23
|
+
import type { PlaygroundMode, PlaygroundConfig } from '../../types/playground.js';
|
|
41
24
|
import type { FlowDropInstance } from '../../stores/instanceContainer.svelte.js';
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
import { getMessages } from '../../messages/index.js';
|
|
45
|
-
import {
|
|
46
|
-
parseSlashCommand,
|
|
47
|
-
dispatchCommand,
|
|
48
|
-
describeLaunchResult,
|
|
49
|
-
type CommandOutcome
|
|
50
|
-
} from '../../playground/commands/index.js';
|
|
51
|
-
import { resolveRunAction } from '../../playground/runAction.js';
|
|
52
|
-
import { isPlaygroundChatHalfSet, isPlaygroundChatSet } from '../../utils/playgroundChat.js';
|
|
53
|
-
import type { PlaygroundMessageRequest } from '../../types/playground.js';
|
|
25
|
+
|
|
26
|
+
warnStandalonePlaygroundDeprecated();
|
|
54
27
|
|
|
55
28
|
interface Props {
|
|
56
29
|
workflowId: string;
|
|
@@ -68,1102 +41,7 @@
|
|
|
68
41
|
instance?: FlowDropInstance;
|
|
69
42
|
}
|
|
70
43
|
|
|
71
|
-
let
|
|
72
|
-
workflowId,
|
|
73
|
-
workflow,
|
|
74
|
-
mode = 'standalone',
|
|
75
|
-
initialSessionId,
|
|
76
|
-
endpointConfig,
|
|
77
|
-
authProvider,
|
|
78
|
-
config = {},
|
|
79
|
-
onClose,
|
|
80
|
-
onTogglePanel,
|
|
81
|
-
isPipelinePanelOpen = false,
|
|
82
|
-
onSessionNavigate,
|
|
83
|
-
instance
|
|
84
|
-
}: Props = $props();
|
|
85
|
-
|
|
86
|
-
// Resolve/provide once at init; the instance prop is a fixed mount-time choice.
|
|
87
|
-
// svelte-ignore state_referenced_locally
|
|
88
|
-
const fd = provideInstance(instance);
|
|
89
|
-
|
|
90
|
-
// The messages getter is read from context here, at init: `m()` calls
|
|
91
|
-
// getContext, which throws outside component initialisation, and every
|
|
92
|
-
// read below happens in an event handler or after an await.
|
|
93
|
-
const messages = getMessages();
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* One line above the composer when the chat binding cannot chat: nothing
|
|
97
|
-
* set up, or a stored binding that no longer binds anything (its inputs
|
|
98
|
-
* were removed) — the form or Run still work — or a message input with no
|
|
99
|
-
* reply, which would take what the person types and never answer.
|
|
100
|
-
*/
|
|
101
|
-
const chatNotice = $derived.by(() => {
|
|
102
|
-
const resolved = fd.playground.chatBinding;
|
|
103
|
-
if (resolved === null) return undefined;
|
|
104
|
-
if (!isPlaygroundChatSet(resolved.binding)) return messages().playground.chatNotSetUp;
|
|
105
|
-
if (isPlaygroundChatHalfSet(resolved.binding)) return messages().playground.chatHalfSet;
|
|
106
|
-
return undefined;
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
let loadedInitialSessionId = $state<string | undefined>(undefined);
|
|
110
|
-
let autoRunTriggered = $state(false);
|
|
111
|
-
let isRefreshing = $state(false);
|
|
112
|
-
/**
|
|
113
|
-
* Transient result of the last slash command. Deliberately component state,
|
|
114
|
-
* not a session message — see runCommand.
|
|
115
|
-
*/
|
|
116
|
-
let commandFeedback = $state<CommandOutcome | null>(null);
|
|
117
|
-
/**
|
|
118
|
-
* A signal accepted but not yet observed as effective.
|
|
119
|
-
*
|
|
120
|
-
* Backends refuse a second signal on the same pipeline, so we hold this to
|
|
121
|
-
* disable rather than fire a request guaranteed to be rejected. Cleared when
|
|
122
|
-
* the session status changes — that transition is the signal taking effect
|
|
123
|
-
* (or the run ending on its own).
|
|
124
|
-
*/
|
|
125
|
-
let pendingSignal = $state<{ pipelineId: string; signal: string } | null>(null);
|
|
126
|
-
// Monotonic token so a slow session load can't overwrite a newer one when the
|
|
127
|
-
// user switches sessions faster than the network responds (last-load wins).
|
|
128
|
-
let loadToken = 0;
|
|
129
|
-
|
|
130
|
-
const messagePageSize = $derived(config.messagePageSize ?? 50);
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* How a turn is collected, from the workflow interface's turn ports.
|
|
134
|
-
* `legacy` (no interface, or no `turn` declared) keeps the host-configured
|
|
135
|
-
* behaviour exactly; the other modes follow the interface:
|
|
136
|
-
* - `chat`: the chat box (unless the host hides it with showChatInput:
|
|
137
|
-
* false), plus a form for any other interface inputs;
|
|
138
|
-
* - `form`: a form and Run; the turn sends `inputs` and no content;
|
|
139
|
-
* - `run`: Run alone; the turn sends neither.
|
|
140
|
-
* In `form` and `run` the chat box and predefinedMessage are ignored: the
|
|
141
|
-
* server refuses content for a workflow with no `message` port.
|
|
142
|
-
*/
|
|
143
|
-
const inputMode = $derived(fd.playground.inputMode);
|
|
144
|
-
const showChatBox = $derived(
|
|
145
|
-
inputMode === 'legacy'
|
|
146
|
-
? (config.showChatInput ?? true)
|
|
147
|
-
: inputMode === 'chat' && config.showChatInput !== false
|
|
148
|
-
);
|
|
149
|
-
|
|
150
|
-
// Vertical resizer state for the ExecutionConsole ↔ ControlPanel split.
|
|
151
|
-
let playgroundContentEl = $state<HTMLElement | null>(null);
|
|
152
|
-
let controlPanelHeight = $state(140);
|
|
153
|
-
let isVerticalResizing = $state(false);
|
|
154
|
-
let containerHeight = $state(0);
|
|
155
|
-
let dragContainerBottom = 0;
|
|
156
|
-
|
|
157
|
-
$effect(() => {
|
|
158
|
-
if (!playgroundContentEl) return;
|
|
159
|
-
const observer = new ResizeObserver(([entry]) => {
|
|
160
|
-
containerHeight = entry.contentRect.height;
|
|
161
|
-
});
|
|
162
|
-
observer.observe(playgroundContentEl);
|
|
163
|
-
return () => observer.disconnect();
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
$effect(() => {
|
|
167
|
-
if (containerHeight > 0) {
|
|
168
|
-
controlPanelHeight = clampControlPanelHeight(untrack(() => controlPanelHeight));
|
|
169
|
-
}
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
// A form arriving with the workflow interface needs room beside the
|
|
173
|
-
// composer: grow the panel once (the user can still drag it back).
|
|
174
|
-
let formRoomGiven = false;
|
|
175
|
-
$effect(() => {
|
|
176
|
-
if (fd.playground.interfaceFormEntries.length === 0 || formRoomGiven) return;
|
|
177
|
-
formRoomGiven = true;
|
|
178
|
-
untrack(() => {
|
|
179
|
-
controlPanelHeight = clampControlPanelHeight(Math.max(controlPanelHeight, 320));
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
const maxControlPanelHeight = $derived(containerHeight ? Math.round(containerHeight * 0.6) : 600);
|
|
184
|
-
|
|
185
|
-
function clampControlPanelHeight(h: number): number {
|
|
186
|
-
return Math.min(Math.max(h, 140), maxControlPanelHeight);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
function handleVerticalResizerPointerDown(e: PointerEvent) {
|
|
190
|
-
if (playgroundContentEl)
|
|
191
|
-
dragContainerBottom = playgroundContentEl.getBoundingClientRect().bottom;
|
|
192
|
-
isVerticalResizing = true;
|
|
193
|
-
(e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
function handleVerticalResizerPointerMove(e: PointerEvent) {
|
|
197
|
-
if (!isVerticalResizing) return;
|
|
198
|
-
controlPanelHeight = clampControlPanelHeight(dragContainerBottom - e.clientY);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
function handleVerticalResizerPointerUp() {
|
|
202
|
-
isVerticalResizing = false;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
function handleVerticalResizerKeyDown(e: KeyboardEvent) {
|
|
206
|
-
const step = e.shiftKey ? 50 : 20;
|
|
207
|
-
if (e.key === 'ArrowUp') {
|
|
208
|
-
e.preventDefault();
|
|
209
|
-
controlPanelHeight = clampControlPanelHeight(controlPanelHeight + step);
|
|
210
|
-
} else if (e.key === 'ArrowDown') {
|
|
211
|
-
e.preventDefault();
|
|
212
|
-
controlPanelHeight = clampControlPanelHeight(controlPanelHeight - step);
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
onMount(() => {
|
|
217
|
-
if (endpointConfig) fd.api.configure(endpointConfig, authProvider);
|
|
218
|
-
if (workflow) fd.playground.setWorkflow(workflow);
|
|
219
|
-
|
|
220
|
-
const handleVisibility = () => {
|
|
221
|
-
if (document.visibilityState === 'visible' && fd.playgroundService.isPolling()) {
|
|
222
|
-
const sessionId = fd.playground.currentSession?.id;
|
|
223
|
-
if (sessionId) {
|
|
224
|
-
void fd.playgroundService
|
|
225
|
-
.getMessages(
|
|
226
|
-
fd.api.config,
|
|
227
|
-
sessionId,
|
|
228
|
-
{
|
|
229
|
-
since: fd.playgroundService.getLastSequenceNumber() ?? undefined
|
|
230
|
-
},
|
|
231
|
-
fd.api.authProvider
|
|
232
|
-
)
|
|
233
|
-
.then((response) => fd.playground.applyServerResponse(response, sessionId))
|
|
234
|
-
.catch((err) => logger.error('[Playground] Visibility catchup failed:', err));
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
};
|
|
238
|
-
document.addEventListener('visibilitychange', handleVisibility);
|
|
239
|
-
|
|
240
|
-
const handleRefreshStatus = () => void refreshFromServer();
|
|
241
|
-
document.addEventListener('flowdrop:refresh-status', handleRefreshStatus);
|
|
242
|
-
|
|
243
|
-
void initializePlayground();
|
|
244
|
-
|
|
245
|
-
return () => {
|
|
246
|
-
document.removeEventListener('visibilitychange', handleVisibility);
|
|
247
|
-
document.removeEventListener('flowdrop:refresh-status', handleRefreshStatus);
|
|
248
|
-
};
|
|
249
|
-
});
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* Handle reactive changes to initialSessionId prop
|
|
253
|
-
*/
|
|
254
|
-
$effect(() => {
|
|
255
|
-
if (!initialSessionId) return;
|
|
256
|
-
if (loadedInitialSessionId === initialSessionId) return;
|
|
257
|
-
|
|
258
|
-
const sessionList = fd.playground.sessions;
|
|
259
|
-
if (sessionList.length === 0) return;
|
|
260
|
-
|
|
261
|
-
void loadInitialSession(initialSessionId);
|
|
262
|
-
});
|
|
263
|
-
|
|
264
|
-
/**
|
|
265
|
-
* Make sure the playground knows the workflow's interface and chat binding.
|
|
266
|
-
*
|
|
267
|
-
* The mode (chat box, form, Run) is read from the workflow's Playground
|
|
268
|
-
* settings, else from its interface's deprecated turn ports. A workflow
|
|
269
|
-
* passed in with both an `interface` and a `playground` key is used as is;
|
|
270
|
-
* when either is missing, the workflow is loaded through the workflows API
|
|
271
|
-
* (`workflows.get`) and only the missing keys are taken from there: a key
|
|
272
|
-
* the caller passed is its live copy (the editor's, unsaved edits and all)
|
|
273
|
-
* and never gives way to the saved one. Any failure
|
|
274
|
-
* leaves the playground in `legacy` mode, which is the behaviour it had
|
|
275
|
-
* before turn ports.
|
|
276
|
-
*/
|
|
277
|
-
async function ensureWorkflowInterface(): Promise<void> {
|
|
278
|
-
if (!fd.api.config) return;
|
|
279
|
-
const server = fd.api.config.baseUrl;
|
|
280
|
-
if (
|
|
281
|
-
workflow?.interface !== undefined &&
|
|
282
|
-
(workflow.playground !== undefined || serversWithoutPlaygroundSettings.has(server))
|
|
283
|
-
) {
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
try {
|
|
287
|
-
const loaded = await fd.api.client.loadWorkflow(workflowId);
|
|
288
|
-
if (loaded.playground === undefined) serversWithoutPlaygroundSettings.add(server);
|
|
289
|
-
if (!workflow) {
|
|
290
|
-
if (loaded.interface !== undefined || loaded.playground !== undefined) {
|
|
291
|
-
fd.playground.setWorkflow(loaded);
|
|
292
|
-
}
|
|
293
|
-
return;
|
|
294
|
-
}
|
|
295
|
-
const missingInterface = workflow.interface === undefined && loaded.interface !== undefined;
|
|
296
|
-
const missingPlayground =
|
|
297
|
-
workflow.playground === undefined && loaded.playground !== undefined;
|
|
298
|
-
if (!missingInterface && !missingPlayground) return;
|
|
299
|
-
fd.playground.setWorkflow({
|
|
300
|
-
...workflow,
|
|
301
|
-
...(missingInterface && { interface: loaded.interface }),
|
|
302
|
-
...(missingPlayground && { playground: loaded.playground })
|
|
303
|
-
});
|
|
304
|
-
} catch (err) {
|
|
305
|
-
logger.debug('[Playground] Workflow interface unavailable, keeping legacy input:', err);
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
async function initializePlayground(): Promise<void> {
|
|
310
|
-
try {
|
|
311
|
-
await Promise.all([loadSessions(), ensureWorkflowInterface()]);
|
|
312
|
-
|
|
313
|
-
if (initialSessionId) {
|
|
314
|
-
await loadInitialSession(initialSessionId);
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
if (config.autoRun && !autoRunTriggered) {
|
|
318
|
-
autoRunTriggered = true;
|
|
319
|
-
logger.debug('[Playground] Auto-run triggered');
|
|
320
|
-
await startRun();
|
|
321
|
-
}
|
|
322
|
-
} catch (err) {
|
|
323
|
-
logger.error('[Playground] Initialization error:', err);
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
async function loadInitialSession(sessionId: string): Promise<void> {
|
|
328
|
-
const sessionList = fd.playground.sessions;
|
|
329
|
-
const sessionExists = sessionList.some((s) => s.id === sessionId);
|
|
330
|
-
|
|
331
|
-
if (!sessionExists) {
|
|
332
|
-
logger.warn(
|
|
333
|
-
`[Playground] Initial session "${sessionId}" not found. ` +
|
|
334
|
-
`Available: ${sessionList.map((s) => s.id).join(', ') || 'none'}`
|
|
335
|
-
);
|
|
336
|
-
return;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
loadedInitialSessionId = sessionId;
|
|
340
|
-
|
|
341
|
-
try {
|
|
342
|
-
await loadSession(sessionId);
|
|
343
|
-
} catch (err) {
|
|
344
|
-
logger.error('[Playground] Failed to load initial session:', err);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
onDestroy(() => {
|
|
349
|
-
// Only this instance's poller. interruptService polling is page-wide and
|
|
350
|
-
// never started by the library; a host that starts it stops it.
|
|
351
|
-
fd.playgroundService.stopPolling();
|
|
352
|
-
fd.playground.reset();
|
|
353
|
-
fd.interrupts.reset();
|
|
354
|
-
});
|
|
355
|
-
|
|
356
|
-
async function loadSessions(): Promise<void> {
|
|
357
|
-
fd.playground.setLoading(true);
|
|
358
|
-
fd.playground.setError(null);
|
|
359
|
-
|
|
360
|
-
try {
|
|
361
|
-
const sessionList = await fd.playgroundService.listSessions(
|
|
362
|
-
fd.api.config,
|
|
363
|
-
workflowId,
|
|
364
|
-
undefined,
|
|
365
|
-
fd.api.authProvider
|
|
366
|
-
);
|
|
367
|
-
fd.playground.setSessions(sessionList);
|
|
368
|
-
} catch (err) {
|
|
369
|
-
const errorMessage = err instanceof Error ? err.message : 'Failed to load sessions';
|
|
370
|
-
fd.playground.setError(errorMessage);
|
|
371
|
-
logger.error('Failed to load sessions:', err);
|
|
372
|
-
} finally {
|
|
373
|
-
fd.playground.setLoading(false);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
async function loadSession(sessionId: string): Promise<void> {
|
|
378
|
-
fd.playground.setLoading(true);
|
|
379
|
-
fd.playground.setError(null);
|
|
380
|
-
const token = ++loadToken;
|
|
381
|
-
|
|
382
|
-
try {
|
|
383
|
-
const session = await fd.playgroundService.getSession(
|
|
384
|
-
fd.api.config,
|
|
385
|
-
sessionId,
|
|
386
|
-
fd.api.authProvider
|
|
387
|
-
);
|
|
388
|
-
if (token !== loadToken) return; // a newer session load superseded us
|
|
389
|
-
fd.playground.setCurrentSession(session);
|
|
390
|
-
|
|
391
|
-
// Load only the most recent page; older messages load on demand when the
|
|
392
|
-
// user scrolls up (loadOlderMessages). Clear right before applying the
|
|
393
|
-
// fresh page — not before the await — so switching sessions doesn't blank
|
|
394
|
-
// the view for the duration of the fetch.
|
|
395
|
-
const response = await fd.playgroundService.getMessages(
|
|
396
|
-
fd.api.config,
|
|
397
|
-
sessionId,
|
|
398
|
-
{
|
|
399
|
-
latest: true,
|
|
400
|
-
limit: messagePageSize
|
|
401
|
-
},
|
|
402
|
-
fd.api.authProvider
|
|
403
|
-
);
|
|
404
|
-
if (token !== loadToken) return;
|
|
405
|
-
fd.playground.clearMessages();
|
|
406
|
-
fd.playground.applyServerResponse(response, sessionId);
|
|
407
|
-
fd.playground.setHasOlder(deriveHasOlder(response));
|
|
408
|
-
|
|
409
|
-
if (session.status !== 'idle') {
|
|
410
|
-
// Seed polling from the newest loaded message so it tails live updates
|
|
411
|
-
// instead of crawling forward from the start of the conversation.
|
|
412
|
-
startPolling(sessionId, true);
|
|
413
|
-
}
|
|
414
|
-
} catch (err) {
|
|
415
|
-
if (token !== loadToken) return; // don't surface a superseded load's error
|
|
416
|
-
const errorMessage = err instanceof Error ? err.message : 'Failed to load session';
|
|
417
|
-
fd.playground.setError(errorMessage);
|
|
418
|
-
logger.error('Failed to load session:', err);
|
|
419
|
-
} finally {
|
|
420
|
-
if (token === loadToken) fd.playground.setLoading(false);
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
/**
|
|
425
|
-
* Load the page of messages immediately older than the oldest one currently
|
|
426
|
-
* shown. Triggered by scroll-up in MessageStream, which serializes calls and
|
|
427
|
-
* owns the in-flight/anchoring state. Bypasses applyServerResponse so a
|
|
428
|
-
* historical fetch never disturbs the live polling cursor or pipeline view.
|
|
429
|
-
*/
|
|
430
|
-
async function loadOlderMessages(): Promise<void> {
|
|
431
|
-
const sessionId = fd.playground.currentSession?.id;
|
|
432
|
-
const before = fd.playground.oldestSequenceNumber;
|
|
433
|
-
if (!sessionId || before === null) return;
|
|
434
|
-
|
|
435
|
-
try {
|
|
436
|
-
const response = await fd.playgroundService.getMessages(
|
|
437
|
-
fd.api.config,
|
|
438
|
-
sessionId,
|
|
439
|
-
{
|
|
440
|
-
before,
|
|
441
|
-
limit: messagePageSize
|
|
442
|
-
},
|
|
443
|
-
fd.api.authProvider
|
|
444
|
-
);
|
|
445
|
-
// The session may have changed while the fetch was in flight — don't
|
|
446
|
-
// splice an old session's page into the new session's store.
|
|
447
|
-
if (fd.playground.currentSession?.id !== sessionId) return;
|
|
448
|
-
if (response.data && response.data.length > 0) {
|
|
449
|
-
fd.playground.addMessages(response.data);
|
|
450
|
-
}
|
|
451
|
-
fd.playground.setHasOlder(deriveHasOlder(response));
|
|
452
|
-
} catch (err) {
|
|
453
|
-
logger.error('[Playground] Failed to load older messages:', err);
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
/**
|
|
458
|
-
* Whether older messages remain after a backward-pagination response. Prefer
|
|
459
|
-
* the server's explicit `hasOlder` flag; fall back to inferring from page
|
|
460
|
-
* fullness for backends that haven't adopted the field yet.
|
|
461
|
-
*/
|
|
462
|
-
function deriveHasOlder(response: PlaygroundMessagesApiResponse): boolean {
|
|
463
|
-
if (typeof response.hasOlder === 'boolean') return response.hasOlder;
|
|
464
|
-
return (response.data?.length ?? 0) >= messagePageSize;
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
async function handleCreateSession(): Promise<void> {
|
|
468
|
-
fd.playground.setLoading(true);
|
|
469
|
-
fd.playground.setError(null);
|
|
470
|
-
|
|
471
|
-
try {
|
|
472
|
-
const sessionName = `Session ${fd.playground.sessions.length + 1}`;
|
|
473
|
-
const session = await fd.playgroundService.createSession(
|
|
474
|
-
fd.api.config,
|
|
475
|
-
workflowId,
|
|
476
|
-
sessionName,
|
|
477
|
-
undefined,
|
|
478
|
-
fd.api.authProvider
|
|
479
|
-
);
|
|
480
|
-
|
|
481
|
-
// Stop polling the previous (possibly running) session before switching,
|
|
482
|
-
// mirroring handleSelectSession. Otherwise its next poll keeps the old
|
|
483
|
-
// 'running' status alive and the new session's chat input stays disabled.
|
|
484
|
-
fd.playgroundService.stopPolling();
|
|
485
|
-
|
|
486
|
-
if (onSessionNavigate) {
|
|
487
|
-
onSessionNavigate(session.id);
|
|
488
|
-
return;
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
fd.playground.addSession(session);
|
|
492
|
-
fd.playground.setCurrentSession(session);
|
|
493
|
-
fd.playground.clearMessages();
|
|
494
|
-
} catch (err) {
|
|
495
|
-
const errorMessage = err instanceof Error ? err.message : 'Failed to create session';
|
|
496
|
-
fd.playground.setError(errorMessage);
|
|
497
|
-
logger.error('Failed to create session:', err);
|
|
498
|
-
} finally {
|
|
499
|
-
fd.playground.setLoading(false);
|
|
500
|
-
}
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
async function handleSelectSession(sessionId: string): Promise<void> {
|
|
504
|
-
fd.playground.pinExecution(null);
|
|
505
|
-
const currentSessionId = fd.playground.currentSession?.id;
|
|
506
|
-
if (currentSessionId === sessionId) return;
|
|
507
|
-
|
|
508
|
-
fd.playgroundService.stopPolling();
|
|
509
|
-
fd.playground.updateSessionStatus('idle');
|
|
510
|
-
await loadSession(sessionId);
|
|
511
|
-
}
|
|
512
|
-
|
|
513
|
-
async function handleDeleteSession(sessionId: string): Promise<void> {
|
|
514
|
-
try {
|
|
515
|
-
await fd.playgroundService.deleteSession(fd.api.config, sessionId, fd.api.authProvider);
|
|
516
|
-
fd.playground.removeSession(sessionId);
|
|
517
|
-
|
|
518
|
-
if (fd.playground.currentSession?.id === sessionId) {
|
|
519
|
-
fd.playgroundService.stopPolling();
|
|
520
|
-
}
|
|
521
|
-
} catch (err) {
|
|
522
|
-
const errorMessage = err instanceof Error ? err.message : 'Failed to delete session';
|
|
523
|
-
fd.playground.setError(errorMessage);
|
|
524
|
-
logger.error('Failed to delete session:', err);
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
/**
|
|
529
|
-
* Reset a stuck session to idle.
|
|
530
|
-
*
|
|
531
|
-
* Mirrors handleStopExecution: tear down polling and force the local status
|
|
532
|
-
* back to idle even on failure, since the point of reset is to escape a state
|
|
533
|
-
* the client and server disagree about.
|
|
534
|
-
*/
|
|
535
|
-
async function handleResetSession(): Promise<void> {
|
|
536
|
-
const sessionId = fd.playground.currentSession?.id;
|
|
537
|
-
if (!sessionId) return;
|
|
538
|
-
|
|
539
|
-
try {
|
|
540
|
-
await fd.playgroundService.resetSession(fd.api.config, sessionId, fd.api.authProvider);
|
|
541
|
-
fd.playgroundService.stopPolling();
|
|
542
|
-
fd.playground.updateSessionStatus('idle');
|
|
543
|
-
fd.playground.setError(null);
|
|
544
|
-
} catch (err) {
|
|
545
|
-
fd.playgroundService.stopPolling();
|
|
546
|
-
fd.playground.updateSessionStatus('idle');
|
|
547
|
-
logger.error('Failed to reset session:', err);
|
|
548
|
-
throw err;
|
|
549
|
-
}
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
/**
|
|
553
|
-
* Launch a run with named inputs and no chat message.
|
|
554
|
-
*
|
|
555
|
-
* Creates a session first when there is none, so the run has a conversation
|
|
556
|
-
* to report into — the launch endpoint accepts a session id precisely so its
|
|
557
|
-
* messages land somewhere the user is looking.
|
|
558
|
-
*/
|
|
559
|
-
async function handleLaunchWorkflow(inputs: Record<string, string>) {
|
|
560
|
-
if (!fd.playground.currentSession) {
|
|
561
|
-
await handleCreateSession();
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
const sessionId = fd.playground.currentSession?.id;
|
|
565
|
-
|
|
566
|
-
const result = await workflowLaunchService.launch(
|
|
567
|
-
fd.api.config,
|
|
568
|
-
workflowId,
|
|
569
|
-
{ inputs, sessionId },
|
|
570
|
-
fd.api.authProvider
|
|
571
|
-
);
|
|
572
|
-
|
|
573
|
-
if (result.status === 'launched' && sessionId) {
|
|
574
|
-
// Mirror handleSendMessage: reflect the run optimistically and tail it.
|
|
575
|
-
fd.playground.updateSessionStatus('running');
|
|
576
|
-
fd.playground.pinExecution(null);
|
|
577
|
-
fd.playground.setError(null);
|
|
578
|
-
if (!fd.playgroundService.isPolling()) {
|
|
579
|
-
startPolling(sessionId, true);
|
|
580
|
-
}
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
return result;
|
|
584
|
-
}
|
|
585
|
-
|
|
586
|
-
/**
|
|
587
|
-
* Start a run from a button or auto-run, without posting a chat message.
|
|
588
|
-
*
|
|
589
|
-
* Falls back to sending `predefinedMessage` only where the backend has no
|
|
590
|
-
* launch verb — there a message is genuinely the only way to start a run, so
|
|
591
|
-
* the fabricated turn is the lesser evil. Everywhere else this is what stops
|
|
592
|
-
* "Run workflow" appearing in the conversation as though a user typed it.
|
|
593
|
-
*/
|
|
594
|
-
async function startRun(): Promise<void> {
|
|
595
|
-
// A workflow that declares turn ports but no message port runs as a turn
|
|
596
|
-
// on its inputs: no fabricated message, which its server would refuse.
|
|
597
|
-
if (inputMode === 'form' || inputMode === 'run') {
|
|
598
|
-
await takeTurn({});
|
|
599
|
-
return;
|
|
600
|
-
}
|
|
601
|
-
|
|
602
|
-
const action = resolveRunAction({
|
|
603
|
-
canLaunch: workflowLaunchService.isSupported(fd.api.config),
|
|
604
|
-
predefinedMessage: config.predefinedMessage,
|
|
605
|
-
defaultMessage: messages().playground.chat.predefinedRun
|
|
606
|
-
});
|
|
607
|
-
|
|
608
|
-
if (action.kind === 'message') {
|
|
609
|
-
logger.debug('[Playground] Starting run by message:', action.content);
|
|
610
|
-
await handleSendMessage(action.content);
|
|
611
|
-
return;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
const result = await handleLaunchWorkflow({});
|
|
615
|
-
|
|
616
|
-
// Only failures need reporting: a successful launch is evident from the run
|
|
617
|
-
// itself appearing in the console.
|
|
618
|
-
if (result.status !== 'launched') {
|
|
619
|
-
commandFeedback = describeLaunchResult(result, messages().playground.commands);
|
|
620
|
-
// A refused launch never sends the `enableRun` message that would
|
|
621
|
-
// otherwise bring Run back.
|
|
622
|
-
fd.playground.releaseRunLock();
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
|
|
626
|
-
/**
|
|
627
|
-
* Send an operator signal to a specific pipeline.
|
|
628
|
-
*
|
|
629
|
-
* Records the signal as pending on acceptance so a second one is refused
|
|
630
|
-
* client-side rather than by the backend.
|
|
631
|
-
*/
|
|
632
|
-
async function handleSendSignal(
|
|
633
|
-
signal: 'pause' | 'resume' | 'cancel',
|
|
634
|
-
pipelineId: string,
|
|
635
|
-
reason?: string
|
|
636
|
-
) {
|
|
637
|
-
const result = await pipelineSignalService[signal](
|
|
638
|
-
fd.api.config,
|
|
639
|
-
pipelineId,
|
|
640
|
-
{ reason },
|
|
641
|
-
fd.api.authProvider
|
|
642
|
-
);
|
|
643
|
-
|
|
644
|
-
if (result.status === 'accepted') {
|
|
645
|
-
pendingSignal = { pipelineId, signal };
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
return result;
|
|
649
|
-
}
|
|
650
|
-
|
|
651
|
-
/**
|
|
652
|
-
* Clear a pending signal once the session status moves.
|
|
653
|
-
*
|
|
654
|
-
* The status transition is the observable consequence of the signal landing
|
|
655
|
-
* — or of the run ending by itself, which equally means the signal is moot.
|
|
656
|
-
*/
|
|
657
|
-
$effect(() => {
|
|
658
|
-
// Track the status so this re-runs on every change.
|
|
659
|
-
void fd.playground.currentSession?.status;
|
|
660
|
-
untrack(() => {
|
|
661
|
-
if (pendingSignal) pendingSignal = null;
|
|
662
|
-
});
|
|
663
|
-
});
|
|
664
|
-
|
|
665
|
-
/**
|
|
666
|
-
* Run a slash command and surface its outcome as transient composer feedback.
|
|
667
|
-
*
|
|
668
|
-
* Commands are never posted as session messages — control traffic must not
|
|
669
|
-
* enter conversation history, or it returns as the next turn's chat input.
|
|
670
|
-
*/
|
|
671
|
-
async function runCommand(input: string): Promise<void> {
|
|
672
|
-
const parsed = parseSlashCommand(input);
|
|
673
|
-
const msgs = messages().playground.commands;
|
|
674
|
-
|
|
675
|
-
if (parsed.kind === 'unknown') {
|
|
676
|
-
commandFeedback = {
|
|
677
|
-
status: 'error',
|
|
678
|
-
message: parsed.suggestions.length
|
|
679
|
-
? msgs.unknownWithSuggestions({
|
|
680
|
-
name: parsed.name,
|
|
681
|
-
suggestions: parsed.suggestions.map((s) => `/${s}`).join(', ')
|
|
682
|
-
})
|
|
683
|
-
: msgs.unknown({ name: parsed.name })
|
|
684
|
-
};
|
|
685
|
-
return;
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
if (parsed.kind !== 'command') return;
|
|
689
|
-
|
|
690
|
-
commandFeedback = await dispatchCommand(parsed.command, {
|
|
691
|
-
config: fd.api.config,
|
|
692
|
-
sessionId: fd.playground.currentSession?.id ?? null,
|
|
693
|
-
// The active run: pinned if the user pinned one, else the latest main
|
|
694
|
-
// run. Sub-flows are excluded upstream, so `/pause` targets the run the
|
|
695
|
-
// user means rather than whichever inner iteration is on screen.
|
|
696
|
-
pipelineId: fd.playground.activeExecutionId,
|
|
697
|
-
pendingSignal,
|
|
698
|
-
handlers: {
|
|
699
|
-
createSession: handleCreateSession,
|
|
700
|
-
deleteSession: handleDeleteSession,
|
|
701
|
-
stopExecution: handleStopExecution,
|
|
702
|
-
resetSession: handleResetSession,
|
|
703
|
-
sendSignal: handleSendSignal,
|
|
704
|
-
launchWorkflow: handleLaunchWorkflow
|
|
705
|
-
},
|
|
706
|
-
messages: msgs
|
|
707
|
-
});
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
async function handleSendMessage(content: string): Promise<boolean> {
|
|
711
|
-
// Commands are intercepted *before* the executing guard: /stop is only
|
|
712
|
-
// useful while a run is in flight, which is exactly when plain text is
|
|
713
|
-
// refused.
|
|
714
|
-
const parsed = parseSlashCommand(content);
|
|
715
|
-
if (parsed.kind === 'command' || parsed.kind === 'unknown') {
|
|
716
|
-
await runCommand(content);
|
|
717
|
-
return true;
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
commandFeedback = null;
|
|
721
|
-
|
|
722
|
-
// An escaped message (`//foo`) is sent as its literal text (`/foo`).
|
|
723
|
-
const messageContent = parsed.kind === 'message' ? parsed.content : content;
|
|
724
|
-
|
|
725
|
-
return takeTurn({ content: messageContent });
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
/**
|
|
729
|
-
* Take one turn: post the request to the session's turn door and tail the
|
|
730
|
-
* session. The interface form's values ride along as `inputs` (none in
|
|
731
|
-
* legacy mode). A refusal (a 400 naming the fix, a 409, …) is shown with the
|
|
732
|
-
* server's own message and leaves the session idle.
|
|
733
|
-
*
|
|
734
|
-
* @returns Whether the turn was accepted
|
|
735
|
-
*/
|
|
736
|
-
async function takeTurn(request: PlaygroundMessageRequest): Promise<boolean> {
|
|
737
|
-
// Not `canRun`: a Run click has already taken the run lock by now.
|
|
738
|
-
if (fd.playground.isExecuting || fd.playground.turnPending) {
|
|
739
|
-
fd.playground.releaseRunLock();
|
|
740
|
-
return false;
|
|
741
|
-
}
|
|
742
|
-
fd.playground.setTurnPending(true);
|
|
743
|
-
|
|
744
|
-
try {
|
|
745
|
-
// In legacy mode there are no interface form entries, so `inputs` is
|
|
746
|
-
// `{}` — exactly what the legacy door was always sent.
|
|
747
|
-
const turnInputs = fd.playground.turnInputs;
|
|
748
|
-
if (!turnInputs.ok) {
|
|
749
|
-
fd.playground.setError(
|
|
750
|
-
messages().playground.inputForm.missingRequired({
|
|
751
|
-
names: turnInputs.missing.map((entry) => entry.name ?? entry.id).join(', ')
|
|
752
|
-
})
|
|
753
|
-
);
|
|
754
|
-
fd.playground.releaseRunLock();
|
|
755
|
-
return false;
|
|
756
|
-
}
|
|
757
|
-
const body: PlaygroundMessageRequest = { ...request, inputs: turnInputs.inputs };
|
|
758
|
-
|
|
759
|
-
if (!fd.playground.currentSession) {
|
|
760
|
-
await handleCreateSession();
|
|
761
|
-
}
|
|
762
|
-
const sessionId = fd.playground.currentSession?.id;
|
|
763
|
-
if (!sessionId) {
|
|
764
|
-
fd.playground.releaseRunLock();
|
|
765
|
-
return false;
|
|
766
|
-
}
|
|
767
|
-
|
|
768
|
-
fd.playground.updateSessionStatus('running');
|
|
769
|
-
fd.playground.pinExecution(null);
|
|
770
|
-
fd.playground.setError(null);
|
|
771
|
-
|
|
772
|
-
try {
|
|
773
|
-
const response = await fd.playgroundService.sendTurn(
|
|
774
|
-
fd.api.config,
|
|
775
|
-
sessionId,
|
|
776
|
-
body,
|
|
777
|
-
fd.api.authProvider
|
|
778
|
-
);
|
|
779
|
-
// The legacy door answers with the user's row; the turn door with a
|
|
780
|
-
// turn result, and the row arrives with the poll started below.
|
|
781
|
-
if (response.kind === 'turn') {
|
|
782
|
-
fd.playground.setLastTurn(response.result);
|
|
783
|
-
} else {
|
|
784
|
-
fd.playground.addMessage(response.message);
|
|
785
|
-
fd.playground.setLastTurn(null);
|
|
786
|
-
}
|
|
787
|
-
// Only start polling if not already active — avoids resetting the cursor
|
|
788
|
-
// mid-session and re-fetching messages that are already in the store.
|
|
789
|
-
// Seed from the newest loaded message so polling tails live updates
|
|
790
|
-
// rather than crawling forward from the start of the conversation.
|
|
791
|
-
if (!fd.playgroundService.isPolling()) {
|
|
792
|
-
startPolling(sessionId, true);
|
|
793
|
-
}
|
|
794
|
-
return true;
|
|
795
|
-
} catch (err) {
|
|
796
|
-
const errorMessage = err instanceof Error ? err.message : 'Failed to send message';
|
|
797
|
-
fd.playground.setError(errorMessage);
|
|
798
|
-
fd.playground.updateSessionStatus('idle');
|
|
799
|
-
fd.playground.releaseRunLock();
|
|
800
|
-
logger.error('Failed to send message:', err);
|
|
801
|
-
return false;
|
|
802
|
-
}
|
|
803
|
-
} finally {
|
|
804
|
-
fd.playground.setTurnPending(false);
|
|
805
|
-
}
|
|
806
|
-
}
|
|
807
|
-
|
|
808
|
-
async function handleStopExecution(): Promise<void> {
|
|
809
|
-
const sessionId = fd.playground.currentSession?.id;
|
|
810
|
-
if (!sessionId) return;
|
|
811
|
-
|
|
812
|
-
try {
|
|
813
|
-
await fd.playgroundService.stopExecution(fd.api.config, sessionId, fd.api.authProvider);
|
|
814
|
-
fd.playgroundService.stopPolling();
|
|
815
|
-
fd.playground.updateSessionStatus('idle');
|
|
816
|
-
} catch (err) {
|
|
817
|
-
const errorMessage = err instanceof Error ? err.message : 'Failed to stop execution';
|
|
818
|
-
fd.playground.setError(errorMessage);
|
|
819
|
-
fd.playgroundService.stopPolling();
|
|
820
|
-
fd.playground.updateSessionStatus('idle');
|
|
821
|
-
logger.error('Failed to stop execution:', err);
|
|
822
|
-
}
|
|
823
|
-
}
|
|
824
|
-
|
|
825
|
-
function startPolling(
|
|
826
|
-
sessionId: string,
|
|
827
|
-
seedSequence = false,
|
|
828
|
-
overrideShouldStopPolling?: (status: PlaygroundSessionStatus) => boolean
|
|
829
|
-
): void {
|
|
830
|
-
const pollingInterval = config.pollingInterval ?? 1500;
|
|
831
|
-
const initialSequenceNumber = seedSequence ? fd.playground.latestSequenceNumber : null;
|
|
832
|
-
|
|
833
|
-
fd.playgroundService.startPolling(
|
|
834
|
-
fd.api.config,
|
|
835
|
-
sessionId,
|
|
836
|
-
(response) => fd.playground.applyServerResponse(response, sessionId),
|
|
837
|
-
pollingInterval,
|
|
838
|
-
overrideShouldStopPolling ?? config.shouldStopPolling,
|
|
839
|
-
initialSequenceNumber,
|
|
840
|
-
fd.api.authProvider
|
|
841
|
-
);
|
|
842
|
-
}
|
|
843
|
-
|
|
844
|
-
async function refreshFromServer(): Promise<void> {
|
|
845
|
-
const sessionId = fd.playground.currentSession?.id;
|
|
846
|
-
if (!sessionId || isRefreshing) return;
|
|
847
|
-
isRefreshing = true;
|
|
848
|
-
try {
|
|
849
|
-
const response = await fd.playgroundService.getMessages(
|
|
850
|
-
fd.api.config,
|
|
851
|
-
sessionId,
|
|
852
|
-
{
|
|
853
|
-
since: fd.playgroundService.getLastSequenceNumber() ?? undefined
|
|
854
|
-
},
|
|
855
|
-
fd.api.authProvider
|
|
856
|
-
);
|
|
857
|
-
fd.playground.applyServerResponse(response, sessionId);
|
|
858
|
-
if (response.sessionStatus === 'running' && !fd.playgroundService.isPolling()) {
|
|
859
|
-
startPolling(sessionId, true);
|
|
860
|
-
}
|
|
861
|
-
} catch (err) {
|
|
862
|
-
logger.error('[Playground] Status refresh failed:', err);
|
|
863
|
-
} finally {
|
|
864
|
-
isRefreshing = false;
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
async function handleInterruptResolved(): Promise<void> {
|
|
869
|
-
const sessionId = fd.playground.currentSession?.id;
|
|
870
|
-
if (!sessionId) return;
|
|
871
|
-
|
|
872
|
-
try {
|
|
873
|
-
// Catch up immediately rather than waiting for the next poll interval.
|
|
874
|
-
// Use the service's sequence cursor so we only fetch new messages.
|
|
875
|
-
const response = await fd.playgroundService.getMessages(
|
|
876
|
-
fd.api.config,
|
|
877
|
-
sessionId,
|
|
878
|
-
{
|
|
879
|
-
since: fd.playgroundService.getLastSequenceNumber() ?? undefined
|
|
880
|
-
},
|
|
881
|
-
fd.api.authProvider
|
|
882
|
-
);
|
|
883
|
-
fd.playground.applyServerResponse(response, sessionId);
|
|
884
|
-
} catch (err) {
|
|
885
|
-
logger.error('[Playground] Failed to refresh after interrupt:', err);
|
|
886
|
-
}
|
|
887
|
-
|
|
888
|
-
// Polling continues through awaiting_input now, but restart defensively
|
|
889
|
-
// in case it stopped for any reason (e.g. component re-mount).
|
|
890
|
-
if (!fd.playgroundService.isPolling()) {
|
|
891
|
-
startPolling(sessionId, true);
|
|
892
|
-
}
|
|
893
|
-
}
|
|
44
|
+
let props: Props = $props();
|
|
894
45
|
</script>
|
|
895
46
|
|
|
896
|
-
<
|
|
897
|
-
class="flowdrop-scope playground"
|
|
898
|
-
class:playground--embedded={mode === 'embedded'}
|
|
899
|
-
class:playground--standalone={mode === 'standalone'}
|
|
900
|
-
class:playground--modal={mode === 'modal'}
|
|
901
|
-
>
|
|
902
|
-
<main class="playground__main">
|
|
903
|
-
{#if fd.playground.error}
|
|
904
|
-
<div class="playground__error">
|
|
905
|
-
<Icon icon="mdi:alert-circle" />
|
|
906
|
-
<span>{fd.playground.error}</span>
|
|
907
|
-
<button
|
|
908
|
-
type="button"
|
|
909
|
-
class="playground__error-dismiss"
|
|
910
|
-
onclick={() => fd.playground.setError(null)}
|
|
911
|
-
>
|
|
912
|
-
<Icon icon="mdi:close" />
|
|
913
|
-
</button>
|
|
914
|
-
</div>
|
|
915
|
-
{/if}
|
|
916
|
-
|
|
917
|
-
<div class="playground__content" bind:this={playgroundContentEl}>
|
|
918
|
-
{#if fd.playground.isLoading && !fd.playground.currentSession}
|
|
919
|
-
<div class="playground__loading">
|
|
920
|
-
<Icon icon="mdi:loading" class="playground__loading-icon" />
|
|
921
|
-
<span>Loading...</span>
|
|
922
|
-
</div>
|
|
923
|
-
{:else}
|
|
924
|
-
<ExecutionConsole
|
|
925
|
-
showTimestamps={config.showTimestamps ?? true}
|
|
926
|
-
autoScroll={config.autoScroll ?? true}
|
|
927
|
-
enableMarkdown={config.enableMarkdown ?? true}
|
|
928
|
-
onInterruptResolved={handleInterruptResolved}
|
|
929
|
-
onCreateSession={fd.playground.sessions.length === 0 ? handleCreateSession : undefined}
|
|
930
|
-
onLoadOlder={loadOlderMessages}
|
|
931
|
-
/>
|
|
932
|
-
|
|
933
|
-
<!-- Focusable ARIA splitter: keyboard/pointer handlers drive the resize -->
|
|
934
|
-
<!-- svelte-ignore a11y_no_noninteractive_tabindex -->
|
|
935
|
-
<!-- svelte-ignore a11y_no_noninteractive_element_interactions -->
|
|
936
|
-
<div
|
|
937
|
-
class="playground__vertical-resizer"
|
|
938
|
-
class:playground__vertical-resizer--active={isVerticalResizing}
|
|
939
|
-
role="separator"
|
|
940
|
-
aria-orientation="horizontal"
|
|
941
|
-
aria-valuenow={Math.round(controlPanelHeight)}
|
|
942
|
-
aria-valuemin={140}
|
|
943
|
-
aria-valuemax={maxControlPanelHeight}
|
|
944
|
-
aria-label="Resize execution console"
|
|
945
|
-
tabindex="0"
|
|
946
|
-
onpointerdown={handleVerticalResizerPointerDown}
|
|
947
|
-
onpointermove={handleVerticalResizerPointerMove}
|
|
948
|
-
onpointerup={handleVerticalResizerPointerUp}
|
|
949
|
-
onpointercancel={handleVerticalResizerPointerUp}
|
|
950
|
-
onkeydown={handleVerticalResizerKeyDown}
|
|
951
|
-
>
|
|
952
|
-
<div class="playground__vertical-resizer-handle"></div>
|
|
953
|
-
</div>
|
|
954
|
-
|
|
955
|
-
<ControlPanel
|
|
956
|
-
style="height: {controlPanelHeight}px; flex-shrink: 0;"
|
|
957
|
-
{isPipelinePanelOpen}
|
|
958
|
-
{onTogglePanel}
|
|
959
|
-
{isRefreshing}
|
|
960
|
-
{onSessionNavigate}
|
|
961
|
-
onCreateSession={handleCreateSession}
|
|
962
|
-
onSelectSession={handleSelectSession}
|
|
963
|
-
onDeleteSession={handleDeleteSession}
|
|
964
|
-
onSendMessage={handleSendMessage}
|
|
965
|
-
onStopExecution={handleStopExecution}
|
|
966
|
-
onRunWorkflow={startRun}
|
|
967
|
-
awaitEnableRun={inputMode === 'legacy'}
|
|
968
|
-
onRefresh={refreshFromServer}
|
|
969
|
-
enableCommands
|
|
970
|
-
{commandFeedback}
|
|
971
|
-
onDismissCommandFeedback={() => (commandFeedback = null)}
|
|
972
|
-
showChatInput={showChatBox}
|
|
973
|
-
showRunButton={config.showRunButton ?? true}
|
|
974
|
-
predefinedMessage={inputMode === 'form' || inputMode === 'run'
|
|
975
|
-
? undefined
|
|
976
|
-
: config.predefinedMessage}
|
|
977
|
-
formEntries={fd.playground.interfaceFormEntries}
|
|
978
|
-
notice={chatNotice}
|
|
979
|
-
formValues={fd.playground.formValues}
|
|
980
|
-
onFormChange={(values) => fd.playground.setFormValues(values)}
|
|
981
|
-
showSessionHeader={config.showSessionHeader ?? true}
|
|
982
|
-
showNewSessionButton={config.showNewSessionButton ?? true}
|
|
983
|
-
showSessionList={config.showSessionList ?? true}
|
|
984
|
-
/>
|
|
985
|
-
{/if}
|
|
986
|
-
</div>
|
|
987
|
-
</main>
|
|
988
|
-
|
|
989
|
-
{#if (mode === 'embedded' || mode === 'modal') && onClose}
|
|
990
|
-
<button
|
|
991
|
-
type="button"
|
|
992
|
-
class="playground__floating-close"
|
|
993
|
-
onclick={onClose}
|
|
994
|
-
title="Close playground"
|
|
995
|
-
aria-label="Close playground"
|
|
996
|
-
>
|
|
997
|
-
<Icon icon={mode === 'modal' ? 'mdi:close' : 'mdi:dock-right'} />
|
|
998
|
-
</button>
|
|
999
|
-
{/if}
|
|
1000
|
-
</div>
|
|
1001
|
-
|
|
1002
|
-
<style>
|
|
1003
|
-
.playground {
|
|
1004
|
-
position: relative;
|
|
1005
|
-
display: flex;
|
|
1006
|
-
flex-direction: column;
|
|
1007
|
-
height: 100%;
|
|
1008
|
-
overflow: clip; /* clip avoids the BFC that overflow:hidden creates, which breaks position:sticky inside */
|
|
1009
|
-
background-color: var(--fd-muted);
|
|
1010
|
-
font-family:
|
|
1011
|
-
-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
.playground--embedded {
|
|
1015
|
-
border-left: 1px solid var(--fd-border);
|
|
1016
|
-
box-shadow: -4px 0 20px rgba(0, 0, 0, 0.08);
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
.playground--standalone {
|
|
1020
|
-
background: var(--fd-layout-background, var(--fd-muted));
|
|
1021
|
-
}
|
|
1022
|
-
|
|
1023
|
-
:global([data-theme='dark']) .playground--standalone {
|
|
1024
|
-
background: linear-gradient(135deg, #141418 0%, #1a1a2e 50%, #16162a 100%);
|
|
1025
|
-
}
|
|
1026
|
-
|
|
1027
|
-
.playground--modal {
|
|
1028
|
-
width: 100%;
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
.playground__main {
|
|
1032
|
-
flex: 1;
|
|
1033
|
-
display: flex;
|
|
1034
|
-
flex-direction: column;
|
|
1035
|
-
min-width: 0;
|
|
1036
|
-
min-height: 0;
|
|
1037
|
-
overflow: clip; /* clip avoids the BFC that overflow:hidden creates, which breaks position:sticky inside */
|
|
1038
|
-
background-color: var(--fd-background);
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
.playground__error {
|
|
1042
|
-
display: flex;
|
|
1043
|
-
align-items: center;
|
|
1044
|
-
gap: var(--fd-space-xs);
|
|
1045
|
-
padding: var(--fd-space-md) var(--fd-space-xl);
|
|
1046
|
-
background-color: var(--fd-error-muted);
|
|
1047
|
-
border-bottom: 1px solid var(--fd-error);
|
|
1048
|
-
color: var(--fd-error);
|
|
1049
|
-
font-size: var(--fd-text-sm);
|
|
1050
|
-
flex-shrink: 0;
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1053
|
-
.playground__error-dismiss {
|
|
1054
|
-
margin-left: auto;
|
|
1055
|
-
display: flex;
|
|
1056
|
-
align-items: center;
|
|
1057
|
-
justify-content: center;
|
|
1058
|
-
width: var(--fd-space-3xl);
|
|
1059
|
-
height: var(--fd-space-3xl);
|
|
1060
|
-
border: none;
|
|
1061
|
-
border-radius: var(--fd-radius-sm);
|
|
1062
|
-
background: transparent;
|
|
1063
|
-
color: var(--fd-error);
|
|
1064
|
-
cursor: pointer;
|
|
1065
|
-
transition: background-color var(--fd-transition-fast);
|
|
1066
|
-
}
|
|
1067
|
-
|
|
1068
|
-
.playground__error-dismiss:hover {
|
|
1069
|
-
background-color: var(--fd-error-muted);
|
|
1070
|
-
}
|
|
1071
|
-
|
|
1072
|
-
.playground__content {
|
|
1073
|
-
flex: 1;
|
|
1074
|
-
min-height: 0;
|
|
1075
|
-
display: flex;
|
|
1076
|
-
flex-direction: column;
|
|
1077
|
-
}
|
|
1078
|
-
|
|
1079
|
-
.playground__vertical-resizer {
|
|
1080
|
-
height: 8px;
|
|
1081
|
-
flex-shrink: 0;
|
|
1082
|
-
cursor: row-resize;
|
|
1083
|
-
background-color: var(--fd-background);
|
|
1084
|
-
border-top: 1px solid var(--fd-border);
|
|
1085
|
-
border-bottom: 1px solid var(--fd-border);
|
|
1086
|
-
display: flex;
|
|
1087
|
-
align-items: center;
|
|
1088
|
-
justify-content: center;
|
|
1089
|
-
touch-action: none;
|
|
1090
|
-
z-index: 1;
|
|
1091
|
-
transition: background-color var(--fd-transition-normal);
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
.playground__vertical-resizer:hover,
|
|
1095
|
-
.playground__vertical-resizer--active {
|
|
1096
|
-
background-color: var(--fd-primary-muted);
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
.playground__vertical-resizer-handle {
|
|
1100
|
-
width: 48px;
|
|
1101
|
-
height: 4px;
|
|
1102
|
-
background-color: var(--fd-border-strong);
|
|
1103
|
-
border-radius: var(--fd-radius-sm);
|
|
1104
|
-
transition:
|
|
1105
|
-
background-color var(--fd-transition-normal),
|
|
1106
|
-
transform var(--fd-transition-normal);
|
|
1107
|
-
}
|
|
1108
|
-
|
|
1109
|
-
.playground__vertical-resizer:hover .playground__vertical-resizer-handle {
|
|
1110
|
-
background-color: var(--fd-primary);
|
|
1111
|
-
transform: scaleX(1.1);
|
|
1112
|
-
}
|
|
1113
|
-
|
|
1114
|
-
.playground__vertical-resizer--active .playground__vertical-resizer-handle {
|
|
1115
|
-
background-color: var(--fd-primary-hover);
|
|
1116
|
-
transform: scaleX(1.2);
|
|
1117
|
-
}
|
|
1118
|
-
|
|
1119
|
-
.playground__loading {
|
|
1120
|
-
display: flex;
|
|
1121
|
-
flex-direction: column;
|
|
1122
|
-
align-items: center;
|
|
1123
|
-
justify-content: center;
|
|
1124
|
-
flex: 1;
|
|
1125
|
-
gap: var(--fd-space-xl);
|
|
1126
|
-
color: var(--fd-muted-foreground);
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
:global(.playground__loading-icon) {
|
|
1130
|
-
font-size: var(--fd-text-2xl);
|
|
1131
|
-
animation: playground-spin 1s linear infinite;
|
|
1132
|
-
}
|
|
1133
|
-
|
|
1134
|
-
@keyframes playground-spin {
|
|
1135
|
-
from {
|
|
1136
|
-
transform: rotate(0deg);
|
|
1137
|
-
}
|
|
1138
|
-
to {
|
|
1139
|
-
transform: rotate(360deg);
|
|
1140
|
-
}
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
.playground__floating-close {
|
|
1144
|
-
position: absolute;
|
|
1145
|
-
top: var(--fd-space-md);
|
|
1146
|
-
right: var(--fd-space-md);
|
|
1147
|
-
z-index: 10;
|
|
1148
|
-
display: flex;
|
|
1149
|
-
align-items: center;
|
|
1150
|
-
justify-content: center;
|
|
1151
|
-
width: var(--fd-playground-icon-btn-size, 2rem);
|
|
1152
|
-
height: var(--fd-playground-icon-btn-size, 2rem);
|
|
1153
|
-
border: 1px solid var(--fd-border);
|
|
1154
|
-
border-radius: var(--fd-radius-md);
|
|
1155
|
-
background-color: var(--fd-background);
|
|
1156
|
-
color: var(--fd-muted-foreground);
|
|
1157
|
-
cursor: pointer;
|
|
1158
|
-
transition: all var(--fd-transition-fast);
|
|
1159
|
-
}
|
|
1160
|
-
|
|
1161
|
-
.playground__floating-close:hover {
|
|
1162
|
-
background-color: var(--fd-muted);
|
|
1163
|
-
color: var(--fd-foreground);
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
.playground--modal .playground__floating-close {
|
|
1167
|
-
display: none;
|
|
1168
|
-
}
|
|
1169
|
-
</style>
|
|
47
|
+
<PlaygroundSurface {...props} />
|