@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
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node layout: where the wires run.
|
|
3
|
+
*
|
|
4
|
+
* A wire's two ends come from its cards and handles. Its path is the bezier
|
|
5
|
+
* xyflow draws (`getBezierPath`, right to left, curvature 0.25), sampled into
|
|
6
|
+
* a polyline so crossings can be found with plain segment tests; a loopback
|
|
7
|
+
* drawn as a return lane is a polyline already.
|
|
8
|
+
*
|
|
9
|
+
* Return lanes (decision D5): one track per loopback, the first
|
|
10
|
+
* {@link LANE_CLEARANCE} under the lowest card of its loop body (the cards on a
|
|
11
|
+
* forward path from the loop's target back to its source). Shorter spans are
|
|
12
|
+
* placed first, so a loopback whose span overlaps one already placed goes
|
|
13
|
+
* {@link LANE_TRACK_PITCH} below it: lanes nest instead of crossing, and spans
|
|
14
|
+
* that do not overlap share a track. Loops in rows far apart do not count as
|
|
15
|
+
* overlapping: only lanes whose legs share a y range stack. Any other card under the span has to keep
|
|
16
|
+
* clear of the lane (`measure` counts it as a spacing break). A lane's vertical
|
|
17
|
+
* legs sit one pitch further out per level it wraps, on both ends.
|
|
18
|
+
*
|
|
19
|
+
* @module layout/geometry
|
|
20
|
+
*/
|
|
21
|
+
import { LANE_CLEARANCE, LANE_TRACK_PITCH } from './types.js';
|
|
22
|
+
/** xyflow's default bezier curvature. */
|
|
23
|
+
const CURVATURE = 0.25;
|
|
24
|
+
/** Points a bezier is sampled into. */
|
|
25
|
+
const BEZIER_STEPS = 32;
|
|
26
|
+
/** How far a return lane on the innermost track runs out of a handle before it turns. */
|
|
27
|
+
const LANE_STUB = 30;
|
|
28
|
+
/** Cards by id. */
|
|
29
|
+
export function cardIndex(graph) {
|
|
30
|
+
return new Map(graph.cards.map((card) => [card.id, card]));
|
|
31
|
+
}
|
|
32
|
+
/** Where a wire's two handles are, or undefined when a card or a handle is unknown. */
|
|
33
|
+
export function wireEnds(wire, cards) {
|
|
34
|
+
const source = cards.get(wire.source);
|
|
35
|
+
const target = cards.get(wire.target);
|
|
36
|
+
const out = source?.outputs.find((h) => h.portId === wire.sourcePort);
|
|
37
|
+
const into = target?.inputs.find((h) => h.portId === wire.targetPort);
|
|
38
|
+
if (!source || !target || !out || !into)
|
|
39
|
+
return undefined;
|
|
40
|
+
return {
|
|
41
|
+
sx: source.x + out.dx,
|
|
42
|
+
sy: source.y + out.dy,
|
|
43
|
+
tx: target.x + into.dx,
|
|
44
|
+
ty: target.y + into.dy
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** xyflow's control offset for a right-to-left handle pair. */
|
|
48
|
+
function controlOffset(distance) {
|
|
49
|
+
return distance >= 0 ? 0.5 * distance : CURVATURE * 25 * Math.sqrt(-distance);
|
|
50
|
+
}
|
|
51
|
+
/** The bezier xyflow draws from a right-side source to a left-side target, as a polyline. */
|
|
52
|
+
export function bezierPoints({ sx, sy, tx, ty }) {
|
|
53
|
+
const offset = controlOffset(tx - sx);
|
|
54
|
+
const c1x = sx + offset;
|
|
55
|
+
const c2x = tx - offset;
|
|
56
|
+
const points = [];
|
|
57
|
+
for (let i = 0; i <= BEZIER_STEPS; i++) {
|
|
58
|
+
const t = i / BEZIER_STEPS;
|
|
59
|
+
const u = 1 - t;
|
|
60
|
+
points.push([
|
|
61
|
+
u * u * u * sx + 3 * u * u * t * c1x + 3 * u * t * t * c2x + t * t * t * tx,
|
|
62
|
+
u * u * u * sy + 3 * u * u * t * sy + 3 * u * t * t * ty + t * t * t * ty
|
|
63
|
+
]);
|
|
64
|
+
}
|
|
65
|
+
return points;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* A return lane: out of the source, down to the lane, back along it, up into the target.
|
|
69
|
+
*
|
|
70
|
+
* `outDepth` / `inDepth` push the two vertical legs {@link LANE_TRACK_PITCH} further out
|
|
71
|
+
* per level (the source side runs right of the source, the target side left of the
|
|
72
|
+
* target), so on both ends an outer lane turns further out than the inner lane it wraps.
|
|
73
|
+
*/
|
|
74
|
+
export function lanePoints({ sx, sy, tx, ty }, laneY, outDepth = 0, inDepth = outDepth) {
|
|
75
|
+
const ax = sx + LANE_STUB + outDepth * LANE_TRACK_PITCH;
|
|
76
|
+
const bx = tx - LANE_STUB - inDepth * LANE_TRACK_PITCH;
|
|
77
|
+
return [
|
|
78
|
+
[sx, sy],
|
|
79
|
+
[ax, sy],
|
|
80
|
+
[ax, laneY],
|
|
81
|
+
[bx, laneY],
|
|
82
|
+
[bx, ty],
|
|
83
|
+
[tx, ty]
|
|
84
|
+
];
|
|
85
|
+
}
|
|
86
|
+
/** The x range a loopback spans (its loop body). */
|
|
87
|
+
function span(ends) {
|
|
88
|
+
return [Math.min(ends.sx, ends.tx), Math.max(ends.sx, ends.tx)];
|
|
89
|
+
}
|
|
90
|
+
const forwardIndexes = new WeakMap();
|
|
91
|
+
const bodyCaches = new WeakMap();
|
|
92
|
+
function forwardIndex(wires) {
|
|
93
|
+
let index = forwardIndexes.get(wires);
|
|
94
|
+
if (!index) {
|
|
95
|
+
const out = new Map();
|
|
96
|
+
const into = new Map();
|
|
97
|
+
const push = (map, key, value) => {
|
|
98
|
+
const list = map.get(key);
|
|
99
|
+
if (list)
|
|
100
|
+
list.push(value);
|
|
101
|
+
else
|
|
102
|
+
map.set(key, [value]);
|
|
103
|
+
};
|
|
104
|
+
for (const w of wires) {
|
|
105
|
+
if (w.loopback)
|
|
106
|
+
continue;
|
|
107
|
+
push(out, w.source, w.target);
|
|
108
|
+
push(into, w.target, w.source);
|
|
109
|
+
}
|
|
110
|
+
index = { out, into };
|
|
111
|
+
forwardIndexes.set(wires, index);
|
|
112
|
+
}
|
|
113
|
+
return index;
|
|
114
|
+
}
|
|
115
|
+
/** Every card reachable from `start` along the given adjacency (index-based queue). */
|
|
116
|
+
function reach(start, next) {
|
|
117
|
+
const seen = new Set([start]);
|
|
118
|
+
const queue = [start];
|
|
119
|
+
for (let head = 0; head < queue.length; head++) {
|
|
120
|
+
for (const to of next.get(queue[head]) ?? []) {
|
|
121
|
+
if (!seen.has(to)) {
|
|
122
|
+
seen.add(to);
|
|
123
|
+
queue.push(to);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return seen;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* The loop body of a loopback: every card on a forward path from the wire's
|
|
131
|
+
* target (the loop) to its source, both included.
|
|
132
|
+
*
|
|
133
|
+
* It depends only on the wires, never on where the cards are, so it is worked out once per wire
|
|
134
|
+
* list (a sweep moves cards a thousand times over the same wires) and the same set is returned
|
|
135
|
+
* every time: do not mutate it.
|
|
136
|
+
*/
|
|
137
|
+
export function loopBody(graph, wire) {
|
|
138
|
+
let cache = bodyCaches.get(graph.wires);
|
|
139
|
+
if (!cache)
|
|
140
|
+
bodyCaches.set(graph.wires, (cache = new Map()));
|
|
141
|
+
const key = `${wire.id}\0${wire.source}\0${wire.target}`;
|
|
142
|
+
let body = cache.get(key);
|
|
143
|
+
if (!body) {
|
|
144
|
+
const { out, into } = forwardIndex(graph.wires);
|
|
145
|
+
const fromLoop = reach(wire.target, out);
|
|
146
|
+
const toSource = reach(wire.source, into);
|
|
147
|
+
body = new Set([...fromLoop].filter((id) => toSource.has(id)));
|
|
148
|
+
body.add(wire.source);
|
|
149
|
+
body.add(wire.target);
|
|
150
|
+
cache.set(key, body);
|
|
151
|
+
}
|
|
152
|
+
return body;
|
|
153
|
+
}
|
|
154
|
+
/** The lowest bottom among the given cards (annotations never count). */
|
|
155
|
+
function bottomOf(cards, ids) {
|
|
156
|
+
let bottom = -Infinity;
|
|
157
|
+
for (const id of ids) {
|
|
158
|
+
const card = cards.get(id);
|
|
159
|
+
if (card && card.kind === 'card')
|
|
160
|
+
bottom = Math.max(bottom, card.y + card.height);
|
|
161
|
+
}
|
|
162
|
+
return bottom;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The track of every loopback (by wire id). Shorter spans first; a lane goes one
|
|
166
|
+
* track below every placed lane whose span overlaps its own, and one level deeper.
|
|
167
|
+
*/
|
|
168
|
+
export function assignTracks(graph, cards = cardIndex(graph)) {
|
|
169
|
+
const loops = [];
|
|
170
|
+
for (const wire of graph.wires) {
|
|
171
|
+
if (!wire.loopback)
|
|
172
|
+
continue;
|
|
173
|
+
const ends = wireEnds(wire, cards);
|
|
174
|
+
if (!ends)
|
|
175
|
+
continue;
|
|
176
|
+
const [lo, hi] = span(ends);
|
|
177
|
+
loops.push({ wire, lo, hi, top: Math.min(ends.sy, ends.ty) });
|
|
178
|
+
}
|
|
179
|
+
loops.sort((a, b) => a.hi - a.lo - (b.hi - b.lo) || a.lo - b.lo);
|
|
180
|
+
const placed = [];
|
|
181
|
+
const tracks = new Map();
|
|
182
|
+
for (const loop of loops) {
|
|
183
|
+
let y = bottomOf(cards, loopBody(graph, loop.wire)) + LANE_CLEARANCE;
|
|
184
|
+
let depth = 0;
|
|
185
|
+
const base = y;
|
|
186
|
+
for (const other of placed) {
|
|
187
|
+
// Lanes only share space when their spans overlap and their legs (from the handles down
|
|
188
|
+
// to the lane) overlap too: a loop in a row far below the other one does not push it.
|
|
189
|
+
if (other.lo < loop.hi && other.hi > loop.lo && other.top < base && other.y > loop.top) {
|
|
190
|
+
y = Math.max(y, other.y + LANE_TRACK_PITCH);
|
|
191
|
+
depth = Math.max(depth, other.depth + 1);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
placed.push({ lo: loop.lo, hi: loop.hi, top: loop.top, y, depth });
|
|
195
|
+
tracks.set(loop.wire.id, { y, depth });
|
|
196
|
+
}
|
|
197
|
+
return tracks;
|
|
198
|
+
}
|
|
199
|
+
/** The lane y of every loopback (by wire id). */
|
|
200
|
+
export function assignLanes(graph, cards = cardIndex(graph)) {
|
|
201
|
+
return new Map([...assignTracks(graph, cards)].map(([id, track]) => [id, track.y]));
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The return lane of every loopback in the graph, by wire id: the one place a
|
|
205
|
+
* lane's points are made, so what the edge draws and what `measure` counts are
|
|
206
|
+
* the same. Loopbacks into one port share the final climb, which sits as far
|
|
207
|
+
* out as the outermost of them needs.
|
|
208
|
+
*/
|
|
209
|
+
export function loopbackLanes(graph, cards = cardIndex(graph)) {
|
|
210
|
+
const tracks = assignTracks(graph, cards);
|
|
211
|
+
const climb = new Map();
|
|
212
|
+
const port = (wire) => `${wire.target}\0${wire.targetPort}`;
|
|
213
|
+
for (const wire of graph.wires) {
|
|
214
|
+
const track = tracks.get(wire.id);
|
|
215
|
+
if (track)
|
|
216
|
+
climb.set(port(wire), Math.max(climb.get(port(wire)) ?? 0, track.depth));
|
|
217
|
+
}
|
|
218
|
+
const lanes = new Map();
|
|
219
|
+
for (const wire of graph.wires) {
|
|
220
|
+
const track = tracks.get(wire.id);
|
|
221
|
+
const ends = track && wireEnds(wire, cards);
|
|
222
|
+
if (!track || !ends)
|
|
223
|
+
continue;
|
|
224
|
+
lanes.set(wire.id, {
|
|
225
|
+
points: lanePoints(ends, track.y, track.depth, climb.get(port(wire))),
|
|
226
|
+
laneY: track.y,
|
|
227
|
+
body: loopBody(graph, wire)
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
return lanes;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Every wire whose ends are known, with its path. With `only`, just the wires it picks (a return
|
|
234
|
+
* lane still sees the whole graph: its track depends on the other loopbacks).
|
|
235
|
+
*/
|
|
236
|
+
export function wirePaths(graph, options, only,
|
|
237
|
+
/** The graph's lanes, when the caller has them already. */
|
|
238
|
+
known) {
|
|
239
|
+
const cards = cardIndex(graph);
|
|
240
|
+
const picked = only ? graph.wires.filter(only) : graph.wires;
|
|
241
|
+
const lanes = known ??
|
|
242
|
+
(options.loopbacks === 'lane' && picked.some((wire) => wire.loopback)
|
|
243
|
+
? loopbackLanes(graph, cards)
|
|
244
|
+
: new Map());
|
|
245
|
+
const paths = [];
|
|
246
|
+
for (const wire of picked) {
|
|
247
|
+
const ends = wireEnds(wire, cards);
|
|
248
|
+
if (!ends)
|
|
249
|
+
continue;
|
|
250
|
+
const lane = lanes.get(wire.id);
|
|
251
|
+
paths.push(lane
|
|
252
|
+
? { wire, ...ends, points: lane.points, laneY: lane.laneY, body: lane.body }
|
|
253
|
+
: { wire, ...ends, points: bezierPoints(ends) });
|
|
254
|
+
}
|
|
255
|
+
return paths;
|
|
256
|
+
}
|
|
257
|
+
/** Where two segments cross, strictly inside both (touching ends do not count). */
|
|
258
|
+
export function segmentCrossing(p1, p2, p3, p4) {
|
|
259
|
+
const d = (p2[0] - p1[0]) * (p4[1] - p3[1]) - (p2[1] - p1[1]) * (p4[0] - p3[0]);
|
|
260
|
+
if (Math.abs(d) < 1e-9)
|
|
261
|
+
return null;
|
|
262
|
+
const ua = ((p3[0] - p1[0]) * (p4[1] - p3[1]) - (p3[1] - p1[1]) * (p4[0] - p3[0])) / d;
|
|
263
|
+
const ub = ((p3[0] - p1[0]) * (p2[1] - p1[1]) - (p3[1] - p1[1]) * (p2[0] - p1[0])) / d;
|
|
264
|
+
if (ua <= 0 || ua >= 1 || ub <= 0 || ub >= 1)
|
|
265
|
+
return null;
|
|
266
|
+
return [p1[0] + ua * (p2[0] - p1[0]), p1[1] + ua * (p2[1] - p1[1])];
|
|
267
|
+
}
|
|
268
|
+
/** Bounding boxes of the polylines seen so far: a candidate move reuses most wires unchanged. */
|
|
269
|
+
const boxes = new WeakMap();
|
|
270
|
+
/** A polyline's bounding box. */
|
|
271
|
+
export function boxOf(points) {
|
|
272
|
+
let box = boxes.get(points);
|
|
273
|
+
if (!box) {
|
|
274
|
+
let [minX, minY, maxX, maxY] = [Infinity, Infinity, -Infinity, -Infinity];
|
|
275
|
+
for (const [x, y] of points) {
|
|
276
|
+
if (x < minX)
|
|
277
|
+
minX = x;
|
|
278
|
+
if (x > maxX)
|
|
279
|
+
maxX = x;
|
|
280
|
+
if (y < minY)
|
|
281
|
+
minY = y;
|
|
282
|
+
if (y > maxY)
|
|
283
|
+
maxY = y;
|
|
284
|
+
}
|
|
285
|
+
box = [minX, minY, maxX, maxY];
|
|
286
|
+
boxes.set(points, box);
|
|
287
|
+
}
|
|
288
|
+
return box;
|
|
289
|
+
}
|
|
290
|
+
/** The first point where two polylines cross, or null. */
|
|
291
|
+
export function polylineCrossing(a, b) {
|
|
292
|
+
// Polylines whose boxes are apart cannot cross; neither can segments whose x or y ranges are.
|
|
293
|
+
const ba = boxOf(a);
|
|
294
|
+
const bb = boxOf(b);
|
|
295
|
+
if (ba[0] > bb[2] || bb[0] > ba[2] || ba[1] > bb[3] || bb[1] > ba[3])
|
|
296
|
+
return null;
|
|
297
|
+
for (let i = 0; i < a.length - 1; i++) {
|
|
298
|
+
const [p1, p2] = [a[i], a[i + 1]];
|
|
299
|
+
const ax0 = Math.min(p1[0], p2[0]);
|
|
300
|
+
const ax1 = Math.max(p1[0], p2[0]);
|
|
301
|
+
const ay0 = Math.min(p1[1], p2[1]);
|
|
302
|
+
const ay1 = Math.max(p1[1], p2[1]);
|
|
303
|
+
if (ax0 > bb[2] || ax1 < bb[0] || ay0 > bb[3] || ay1 < bb[1])
|
|
304
|
+
continue;
|
|
305
|
+
for (let j = 0; j < b.length - 1; j++) {
|
|
306
|
+
const [p3, p4] = [b[j], b[j + 1]];
|
|
307
|
+
if (Math.max(p3[0], p4[0]) < ax0 || Math.min(p3[0], p4[0]) > ax1)
|
|
308
|
+
continue;
|
|
309
|
+
if (Math.max(p3[1], p4[1]) < ay0 || Math.min(p3[1], p4[1]) > ay1)
|
|
310
|
+
continue;
|
|
311
|
+
const hit = segmentCrossing(p1, p2, p3, p4);
|
|
312
|
+
if (hit)
|
|
313
|
+
return hit;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return null;
|
|
317
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node layout: the public API of the layout module (not yet in the package exports).
|
|
3
|
+
*
|
|
4
|
+
* @module layout
|
|
5
|
+
*/
|
|
6
|
+
export * from './types.js';
|
|
7
|
+
export { measure, score, better, conflictCards, passCards, portClearance, formatMetrics, formatChange } from './measure.js';
|
|
8
|
+
export type { LayoutMetrics, LayoutScore, LayoutConflict, LayoutCrossing, LayoutPortPass } from './measure.js';
|
|
9
|
+
export { fromWorkflow } from './fromWorkflow.js';
|
|
10
|
+
export type { FromWorkflowOptions, MeasuredCard } from './fromWorkflow.js';
|
|
11
|
+
export { propose, beautify, columnRanks, columnGrid, formatProposal, formatBeautify, STRATEGY_ORDER } from './primitives.js';
|
|
12
|
+
export type { LayoutPrimitive, LayoutStrategy, LayoutProposal, LayoutChanges, BeautifyResult, PortOrderChange } from './primitives.js';
|
|
13
|
+
export { inspect } from './inspect.js';
|
|
14
|
+
export { sweep, formatSweep } from './sweep.js';
|
|
15
|
+
export type { SweepPhase, SweepResult } from './sweep.js';
|
|
16
|
+
export { applyProposalToNodes, applySweepToNodes, buildPortsConfig } from './toWorkflow.js';
|
|
17
|
+
export type { NodeLayoutUpdate } from './toWorkflow.js';
|
|
18
|
+
export { loopbackLanes } from './geometry.js';
|
|
19
|
+
export type { LoopbackLane } from './geometry.js';
|
|
20
|
+
export { lanePath } from './lanePath.js';
|
|
21
|
+
export type { LanePath } from './lanePath.js';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node layout: the public API of the layout module (not yet in the package exports).
|
|
3
|
+
*
|
|
4
|
+
* @module layout
|
|
5
|
+
*/
|
|
6
|
+
export * from './types.js';
|
|
7
|
+
export { measure, score, better, conflictCards, passCards, portClearance, formatMetrics, formatChange } from './measure.js';
|
|
8
|
+
export { fromWorkflow } from './fromWorkflow.js';
|
|
9
|
+
export { propose, beautify, columnRanks, columnGrid, formatProposal, formatBeautify, STRATEGY_ORDER } from './primitives.js';
|
|
10
|
+
export { inspect } from './inspect.js';
|
|
11
|
+
export { sweep, formatSweep } from './sweep.js';
|
|
12
|
+
export { applyProposalToNodes, applySweepToNodes, buildPortsConfig } from './toWorkflow.js';
|
|
13
|
+
export { loopbackLanes } from './geometry.js';
|
|
14
|
+
export { lanePath } from './lanePath.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node layout: `inspect`, the report that tells a person or an agent what is wrong around one
|
|
3
|
+
* node before anything is changed.
|
|
4
|
+
*
|
|
5
|
+
* ```
|
|
6
|
+
* compose y=160 inputs: contact, label outputs: reply
|
|
7
|
+
* in contact ← lookup.contact off by 40 crosses classify.label → compose.label
|
|
8
|
+
* out reply → loop.items straight
|
|
9
|
+
* overlaps none · spacing ok
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* An unknown node id throws (`Unknown node "x"`); the command layer turns that into its error.
|
|
13
|
+
*
|
|
14
|
+
* @module layout/inspect
|
|
15
|
+
*/
|
|
16
|
+
import type { LayoutGraph, LayoutOptions } from './types.js';
|
|
17
|
+
/** The report lines for one node. */
|
|
18
|
+
export declare function inspect(graph: LayoutGraph, nodeId: string, options: LayoutOptions): string[];
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node layout: `inspect`, the report that tells a person or an agent what is wrong around one
|
|
3
|
+
* node before anything is changed.
|
|
4
|
+
*
|
|
5
|
+
* ```
|
|
6
|
+
* compose y=160 inputs: contact, label outputs: reply
|
|
7
|
+
* in contact ← lookup.contact off by 40 crosses classify.label → compose.label
|
|
8
|
+
* out reply → loop.items straight
|
|
9
|
+
* overlaps none · spacing ok
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* An unknown node id throws (`Unknown node "x"`); the command layer turns that into its error.
|
|
13
|
+
*
|
|
14
|
+
* @module layout/inspect
|
|
15
|
+
*/
|
|
16
|
+
import { cardIndex } from './geometry.js';
|
|
17
|
+
import { measure } from './measure.js';
|
|
18
|
+
const wireLabel = (wire) => `${wire.source}.${wire.sourcePort} → ${wire.target}.${wire.targetPort}`;
|
|
19
|
+
/** `overlaps none · spacing ok`, or the conflicts of one card (`overlap with lookup · spacing with cap1`). */
|
|
20
|
+
function conflictsLine(graph, metrics, nodeId) {
|
|
21
|
+
const wires = new Map(graph.wires.map((w) => [w.id, w]));
|
|
22
|
+
const parts = [];
|
|
23
|
+
for (const c of metrics.conflicts) {
|
|
24
|
+
if (c.card !== nodeId && !(c.kind !== 'lane' && c.with === nodeId))
|
|
25
|
+
continue;
|
|
26
|
+
if (c.kind === 'lane') {
|
|
27
|
+
const wire = wires.get(c.with);
|
|
28
|
+
parts.push(`lane with ${wire ? `${wire.source} → ${wire.target}` : c.with}`);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
parts.push(`${c.kind} with ${c.card === nodeId ? c.with : c.card}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return parts.length ? parts.join(' · ') : 'overlaps none · spacing ok';
|
|
35
|
+
}
|
|
36
|
+
/** The report lines for one node. */
|
|
37
|
+
export function inspect(graph, nodeId, options) {
|
|
38
|
+
const card = cardIndex(graph).get(nodeId);
|
|
39
|
+
if (!card)
|
|
40
|
+
throw new Error(`Unknown node "${nodeId}"`);
|
|
41
|
+
const metrics = measure(graph, options);
|
|
42
|
+
if (card.kind !== 'card') {
|
|
43
|
+
return [
|
|
44
|
+
`${card.id} ${card.kind} y=${card.y} fixed obstacle`,
|
|
45
|
+
` ${conflictsLine(graph, metrics, nodeId)}`
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
const ids = (handles) => handles.map((h) => h.portId).join(', ') || '—';
|
|
49
|
+
const lines = [
|
|
50
|
+
`${card.id} y=${card.y} inputs: ${ids(card.inputs)} outputs: ${ids(card.outputs)}`
|
|
51
|
+
];
|
|
52
|
+
const mine = metrics.wires.filter((p) => p.wire.source === nodeId || p.wire.target === nodeId);
|
|
53
|
+
const pad = Math.max(0, ...mine.map((p) => (p.wire.target === nodeId ? p.wire.targetPort : p.wire.sourcePort).length));
|
|
54
|
+
const crossingsOf = (wireId) => metrics.crossings
|
|
55
|
+
.filter((c) => c.a === wireId || c.b === wireId)
|
|
56
|
+
.map((c) => {
|
|
57
|
+
const other = metrics.wires.find((p) => p.wire.id === (c.a === wireId ? c.b : c.a));
|
|
58
|
+
return other ? wireLabel(other.wire) : '';
|
|
59
|
+
})
|
|
60
|
+
.filter(Boolean);
|
|
61
|
+
for (const path of mine) {
|
|
62
|
+
const { wire } = path;
|
|
63
|
+
const incoming = wire.target === nodeId;
|
|
64
|
+
const head = incoming
|
|
65
|
+
? `in ${wire.targetPort.padEnd(pad)} ← ${wire.source}.${wire.sourcePort}`
|
|
66
|
+
: `out ${wire.sourcePort.padEnd(pad)} → ${wire.target}.${wire.targetPort}`;
|
|
67
|
+
const gap = Math.abs(path.sy - path.ty);
|
|
68
|
+
const level = gap < 0.5;
|
|
69
|
+
let state;
|
|
70
|
+
if (wire.loopback)
|
|
71
|
+
state = 'loopback';
|
|
72
|
+
else if (path.tx < path.sx)
|
|
73
|
+
state = level ? 'backward' : `backward, off by ${gap}`;
|
|
74
|
+
else
|
|
75
|
+
state = level ? 'straight' : `off by ${gap}`;
|
|
76
|
+
const crosses = crossingsOf(wire.id);
|
|
77
|
+
lines.push(` ${head} ${state}${crosses.length ? ` crosses ${crosses.join(', ')}` : ''}`);
|
|
78
|
+
}
|
|
79
|
+
lines.push(` ${conflictsLine(graph, metrics, nodeId)}`);
|
|
80
|
+
return lines;
|
|
81
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node layout: a return lane as an SVG path.
|
|
3
|
+
*
|
|
4
|
+
* The lane polyline (`loopbackLanes`) with rounded corners, shortened at the
|
|
5
|
+
* target so the arrowhead the edge draws sits on the last segment. Pure: the
|
|
6
|
+
* edge component only hands it the points.
|
|
7
|
+
*
|
|
8
|
+
* @module layout/lanePath
|
|
9
|
+
*/
|
|
10
|
+
import type { XY } from './geometry.js';
|
|
11
|
+
export interface LanePath {
|
|
12
|
+
/** SVG path data, ending `arrow` before the target. */
|
|
13
|
+
d: string;
|
|
14
|
+
/** The middle of the lane, where a label sits. */
|
|
15
|
+
label: XY;
|
|
16
|
+
/** The arrowhead's direction, in degrees (the last segment's). */
|
|
17
|
+
angleDeg: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Round the corners of `points` with `radius` (smaller where a segment is
|
|
21
|
+
* short) and stop `arrow` before the last point.
|
|
22
|
+
*/
|
|
23
|
+
export declare function lanePath(points: readonly XY[], radius: number, arrow: number): LanePath;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node layout: a return lane as an SVG path.
|
|
3
|
+
*
|
|
4
|
+
* The lane polyline (`loopbackLanes`) with rounded corners, shortened at the
|
|
5
|
+
* target so the arrowhead the edge draws sits on the last segment. Pure: the
|
|
6
|
+
* edge component only hands it the points.
|
|
7
|
+
*
|
|
8
|
+
* @module layout/lanePath
|
|
9
|
+
*/
|
|
10
|
+
/** The point `distance` from `from` towards `to` (clamped to the segment). */
|
|
11
|
+
function towards(from, to, distance) {
|
|
12
|
+
const length = Math.hypot(to[0] - from[0], to[1] - from[1]);
|
|
13
|
+
if (length === 0)
|
|
14
|
+
return from;
|
|
15
|
+
const t = Math.min(distance, length) / length;
|
|
16
|
+
return [from[0] + (to[0] - from[0]) * t, from[1] + (to[1] - from[1]) * t];
|
|
17
|
+
}
|
|
18
|
+
const fmt = (n) => String(Math.round(n * 100) / 100);
|
|
19
|
+
/**
|
|
20
|
+
* Round the corners of `points` with `radius` (smaller where a segment is
|
|
21
|
+
* short) and stop `arrow` before the last point.
|
|
22
|
+
*/
|
|
23
|
+
export function lanePath(points, radius, arrow) {
|
|
24
|
+
const pts = points.slice();
|
|
25
|
+
const last = pts.length - 1;
|
|
26
|
+
const angleDeg = (Math.atan2(pts[last][1] - pts[last - 1][1], pts[last][0] - pts[last - 1][0]) * 180) / Math.PI;
|
|
27
|
+
pts[last] = towards(pts[last], pts[last - 1], arrow);
|
|
28
|
+
let d = `M ${fmt(pts[0][0])},${fmt(pts[0][1])}`;
|
|
29
|
+
for (let i = 1; i < last; i++) {
|
|
30
|
+
const a = pts[i - 1];
|
|
31
|
+
const b = pts[i];
|
|
32
|
+
const c = pts[i + 1];
|
|
33
|
+
const r = Math.min(radius, Math.hypot(b[0] - a[0], b[1] - a[1]) / 2, Math.hypot(c[0] - b[0], c[1] - b[1]) / 2);
|
|
34
|
+
const from = towards(b, a, r);
|
|
35
|
+
const to = towards(b, c, r);
|
|
36
|
+
d += ` L ${fmt(from[0])},${fmt(from[1])} Q ${fmt(b[0])},${fmt(b[1])} ${fmt(to[0])},${fmt(to[1])}`;
|
|
37
|
+
}
|
|
38
|
+
d += ` L ${fmt(pts[last][0])},${fmt(pts[last][1])}`;
|
|
39
|
+
// `lanePoints` (geometry.ts) returns six points: the lane is the segment between its two
|
|
40
|
+
// vertical legs, the third of five. Any other shape gets the middle point of the polyline.
|
|
41
|
+
if (pts.length !== 6) {
|
|
42
|
+
return { d, label: points[Math.floor(points.length / 2)], angleDeg };
|
|
43
|
+
}
|
|
44
|
+
const lo = pts[2];
|
|
45
|
+
const hi = pts[3];
|
|
46
|
+
return { d, label: [(lo[0] + hi[0]) / 2, (lo[1] + hi[1]) / 2], angleDeg };
|
|
47
|
+
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Node layout: how good a layout is.
|
|
3
|
+
*
|
|
4
|
+
* `measure` counts what the rules care about; `score` turns that into one
|
|
5
|
+
* tuple compared rank by rank, so a lower rank can never buy back a higher one:
|
|
6
|
+
*
|
|
7
|
+
* 1. overlaps (H2; fewer)
|
|
8
|
+
* 2. spacing breaks (H3; fewer)
|
|
9
|
+
* 3. ports passed (H4; fewer)
|
|
10
|
+
* 4. straight wires (H1; more)
|
|
11
|
+
* 5. backward wires (S5; fewer)
|
|
12
|
+
* 6. crossings (S1; fewer)
|
|
13
|
+
* 7. near misses (H4, graded; fewer)
|
|
14
|
+
* 8. pixels moved (S3; fewer, the tie-break)
|
|
15
|
+
*
|
|
16
|
+
* Overlaps rank above spacing: a card on top of another is worse than two cards too close, so a
|
|
17
|
+
* move can never trade a spacing break for an overlap, whatever it does for the wires. Only an
|
|
18
|
+
* overlap, a spacing break or a passed port can bend a straight wire (decision D1, widened by H4).
|
|
19
|
+
*
|
|
20
|
+
* Ports passed (H4): a wire that runs through a handle other than its own two ends reads as if
|
|
21
|
+
* it started, ended or was relayed there (a level wire running through a card's unused input and
|
|
22
|
+
* output looks like it goes through the card). Every such wire and handle counts once, except a
|
|
23
|
+
* handle wired to the same port as the wire's other end (what it suggests is true), and a wire
|
|
24
|
+
* drawn right to left (counted as backward instead).
|
|
25
|
+
*
|
|
26
|
+
* Near misses (H4, graded): a wire that stays out of a handle but comes within one grid step of it
|
|
27
|
+
* still looks attached (a wire leaving a card's edge just above a port). Same exceptions; ranked
|
|
28
|
+
* last before pixels, so it only breaks ties and never costs a straight wire or a crossing.
|
|
29
|
+
*
|
|
30
|
+
* Spacing (decision D2): cards side by side need `gapX` between them, stacked
|
|
31
|
+
* cards need `gapY`, diagonal neighbours need neither. Annotations count as
|
|
32
|
+
* obstacles for cards; one annotation against another is not checked
|
|
33
|
+
* (decision D8). A return lane needs `gapY` of air below it too.
|
|
34
|
+
*
|
|
35
|
+
* @module layout/measure
|
|
36
|
+
*/
|
|
37
|
+
import { type WirePath, type XY } from './geometry.js';
|
|
38
|
+
import { type LayoutCard, type LayoutGraph, type LayoutOptions } from './types.js';
|
|
39
|
+
/** Two things too close: two cards, or a card and a return lane (`with` is then the loopback's wire id). */
|
|
40
|
+
export interface LayoutConflict {
|
|
41
|
+
card: string;
|
|
42
|
+
with: string;
|
|
43
|
+
kind: 'overlap' | 'spacing' | 'lane';
|
|
44
|
+
}
|
|
45
|
+
export interface LayoutCrossing {
|
|
46
|
+
/** Wire ids. */
|
|
47
|
+
a: string;
|
|
48
|
+
b: string;
|
|
49
|
+
at: XY;
|
|
50
|
+
}
|
|
51
|
+
/** A wire running through, or close past, a handle that is not one of its ends (H4). */
|
|
52
|
+
export interface LayoutPortPass {
|
|
53
|
+
/** Wire id. */
|
|
54
|
+
wire: string;
|
|
55
|
+
/** The card and port the wire runs through. */
|
|
56
|
+
card: string;
|
|
57
|
+
port: string;
|
|
58
|
+
direction: 'input' | 'output';
|
|
59
|
+
}
|
|
60
|
+
export interface LayoutMetrics {
|
|
61
|
+
/** Level, left-to-right wires (loopbacks not counted). */
|
|
62
|
+
straight: number;
|
|
63
|
+
/** Wires counted for straight and backward: every resolved wire but loopbacks. */
|
|
64
|
+
total: number;
|
|
65
|
+
/** Wires running right to left (loopbacks not counted). */
|
|
66
|
+
backward: number;
|
|
67
|
+
overlaps: number;
|
|
68
|
+
/** Spacing breaks, between cards and against return lanes. */
|
|
69
|
+
spacing: number;
|
|
70
|
+
conflicts: LayoutConflict[];
|
|
71
|
+
crossings: LayoutCrossing[];
|
|
72
|
+
/** Wires running through a port that is not one of their ends (H4). */
|
|
73
|
+
passes: LayoutPortPass[];
|
|
74
|
+
/** Wires that miss such a port by less than a grid step (H4, graded). */
|
|
75
|
+
nearMisses: LayoutPortPass[];
|
|
76
|
+
/** Every resolved wire with its path. */
|
|
77
|
+
wires: WirePath[];
|
|
78
|
+
/** Wires whose card or handle is unknown (left out of every count). */
|
|
79
|
+
unresolved: string[];
|
|
80
|
+
}
|
|
81
|
+
/** Compared rank by rank; lower is better in every rank. */
|
|
82
|
+
export type LayoutScore = readonly [
|
|
83
|
+
overlaps: number,
|
|
84
|
+
spacing: number,
|
|
85
|
+
passes: number,
|
|
86
|
+
straight: number,
|
|
87
|
+
backward: number,
|
|
88
|
+
crossings: number,
|
|
89
|
+
nearMisses: number,
|
|
90
|
+
moved: number
|
|
91
|
+
];
|
|
92
|
+
/**
|
|
93
|
+
* Every wire that runs through, or close past, a handle other than its own two ends. With `cards`,
|
|
94
|
+
* only the handles on those cards.
|
|
95
|
+
*/
|
|
96
|
+
export declare function portClearance(graph: LayoutGraph, wires: readonly WirePath[], cards?: readonly LayoutCard[]): {
|
|
97
|
+
passes: LayoutPortPass[];
|
|
98
|
+
nearMisses: LayoutPortPass[];
|
|
99
|
+
};
|
|
100
|
+
/** Whether a resolved, non-loopback wire is straight: level and left to right. */
|
|
101
|
+
export declare function isStraight(path: WirePath): boolean;
|
|
102
|
+
/** Whether a resolved, non-loopback wire runs right to left. */
|
|
103
|
+
export declare function isBackward(path: WirePath): boolean;
|
|
104
|
+
/** Measure a layout. */
|
|
105
|
+
export declare function measure(graph: LayoutGraph, options: LayoutOptions): LayoutMetrics;
|
|
106
|
+
/** The ranked score of a measured layout, given how far the change moved cards (px). */
|
|
107
|
+
export declare function score(metrics: LayoutMetrics, moved?: number): LayoutScore;
|
|
108
|
+
/**
|
|
109
|
+
* The score of `next`, a layout that differs from the measured `base` only in where `cardId`
|
|
110
|
+
* is. Equal to `score(measure(next, options), moved)`, but counts again only what the move can
|
|
111
|
+
* change: the card's pairs, the wires on the card and (with return lanes) the lanes whose path
|
|
112
|
+
* the move changed, since a lane follows its loop body and the lanes it nests with. A primitive
|
|
113
|
+
* judges its candidates with it and measures the winner.
|
|
114
|
+
*
|
|
115
|
+
* With `bound` (the best score so far) a candidate that is already worse than it on a higher rank
|
|
116
|
+
* is dropped before the dear ranks (ports passed, crossings) are counted: the result is then
|
|
117
|
+
* only guaranteed to rank worse than `bound`, its lower ranks being `Infinity`. Without `bound`
|
|
118
|
+
* it is exact.
|
|
119
|
+
*/
|
|
120
|
+
export declare function scoreMove(base: LayoutMetrics, next: LayoutGraph, cardId: string, options: LayoutOptions, moved?: number, bound?: LayoutScore): LayoutScore;
|
|
121
|
+
/** True when `a` beats `b` (strictly). */
|
|
122
|
+
export declare function better(a: LayoutScore, b: LayoutScore): boolean;
|
|
123
|
+
/** The cards in a conflict. */
|
|
124
|
+
export declare function conflictCards(metrics: LayoutMetrics): Set<string>;
|
|
125
|
+
/** The cards a passed port is on, and the two ends of each wire that passes one. */
|
|
126
|
+
export declare function passCards(metrics: LayoutMetrics): Set<string>;
|
|
127
|
+
/**
|
|
128
|
+
* One line for the console: `straight 3/6 · backward 0 · crossings 0 · overlaps 0 · spacing ok`,
|
|
129
|
+
* with `· ports passed 2` / `· near misses 1` when there are any.
|
|
130
|
+
*/
|
|
131
|
+
export declare function formatMetrics(metrics: LayoutMetrics): string;
|
|
132
|
+
export interface FormatChangeOptions {
|
|
133
|
+
/** Print only the values that changed (dry runs): `overlaps 1 → 0`. */
|
|
134
|
+
onlyChanged?: boolean;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The score before and after on one line: `straight 0 → 1 · crossings 3 → 2 · overlaps 1 ·
|
|
138
|
+
* spacing ok`. A value that did not change is printed once; `backward` appears only when
|
|
139
|
+
* either side is non-zero; `straight` has no `/total`.
|
|
140
|
+
*/
|
|
141
|
+
export declare function formatChange(before: LayoutMetrics, after: LayoutMetrics, options?: FormatChangeOptions): string;
|