@invect/ui 0.0.1
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/LICENSE +21 -0
- package/README.md +77 -0
- package/dist/Invect-CWpIwZ5F.js +92738 -0
- package/dist/Invect.d.ts +25 -0
- package/dist/InvectShell.d.ts +14 -0
- package/dist/api/agent-tools.api.d.ts +1 -0
- package/dist/api/client.d.ts +207 -0
- package/dist/api/credentials.api.d.ts +47 -0
- package/dist/api/executions.api.d.ts +43 -0
- package/dist/api/flows.api.d.ts +100 -0
- package/dist/api/index.d.ts +9 -0
- package/dist/api/node-data.api.d.ts +66 -0
- package/dist/api/query-keys.d.ts +22 -0
- package/dist/api/triggers.api.d.ts +44 -0
- package/dist/api/types.d.ts +147 -0
- package/dist/api/use-flow-run-stream.d.ts +12 -0
- package/dist/assets/invect-branding.d.ts +4 -0
- package/dist/assets/provider-icons/index.d.ts +8 -0
- package/dist/babel-C9OtljFZ.js +9721 -0
- package/dist/components/PageLayout.d.ts +17 -0
- package/dist/components/chat/ChatInput.d.ts +17 -0
- package/dist/components/chat/ChatMessageList.d.ts +14 -0
- package/dist/components/chat/ChatModelSelector.d.ts +11 -0
- package/dist/components/chat/ChatPanel.d.ts +19 -0
- package/dist/components/chat/ChatPromptOverlay.d.ts +13 -0
- package/dist/components/chat/ChatProviderSelector.d.ts +9 -0
- package/dist/components/chat/ChatSettingsPanel.d.ts +11 -0
- package/dist/components/chat/InlineCredentialSetup.d.ts +9 -0
- package/dist/components/chat/MarkdownRenderer.d.ts +7 -0
- package/dist/components/chat/chat-memory.d.ts +21 -0
- package/dist/components/chat/chat.store.d.ts +416 -0
- package/dist/components/chat/index.d.ts +5 -0
- package/dist/components/chat/use-chat.d.ts +28 -0
- package/dist/components/credentials/CreateCredentialModal.d.ts +13 -0
- package/dist/components/credentials/CredentialDetailDialog.d.ts +17 -0
- package/dist/components/credentials/EditCredentialModal.d.ts +11 -0
- package/dist/components/credentials/OAuth2ConnectButton.d.ts +38 -0
- package/dist/components/credentials/OAuth2ProviderSelector.d.ts +15 -0
- package/dist/components/credentials/credential-utils.d.ts +12 -0
- package/dist/components/credentials/index.d.ts +9 -0
- package/dist/components/dashboard/FailedRunsAlert.d.ts +3 -0
- package/dist/components/dashboard/FlowCard.d.ts +7 -0
- package/dist/components/dashboard/RecentActivityTable.d.ts +9 -0
- package/dist/components/dashboard/StatCard.d.ts +10 -0
- package/dist/components/dashboard/index.d.ts +5 -0
- package/dist/components/dashboard/status-helpers.d.ts +5 -0
- package/dist/components/flow-editor/ActionsSidebar.d.ts +2 -0
- package/dist/components/flow-editor/FlowEditor.d.ts +21 -0
- package/dist/components/flow-editor/FlowHeader.d.ts +9 -0
- package/dist/components/flow-editor/FlowLayout.d.ts +24 -0
- package/dist/components/flow-editor/ModeSwitcher.d.ts +7 -0
- package/dist/components/flow-editor/NodeSidebar.d.ts +24 -0
- package/dist/components/flow-editor/RunControls.d.ts +12 -0
- package/dist/components/flow-editor/ToolConfigPanel.d.ts +16 -0
- package/dist/components/flow-editor/ValidationPanel.d.ts +5 -0
- package/dist/components/flow-editor/flow-editor.store.d.ts +1 -0
- package/dist/components/flow-editor/index.d.ts +6 -0
- package/dist/components/flow-editor/inline-edit.d.ts +10 -0
- package/dist/components/flow-editor/node-config-panel/ConfigFieldWithTemplate.d.ts +26 -0
- package/dist/components/flow-editor/node-config-panel/CredentialCombobox.d.ts +21 -0
- package/dist/components/flow-editor/node-config-panel/CredentialsSection.d.ts +19 -0
- package/dist/components/flow-editor/node-config-panel/DroppableInput.d.ts +20 -0
- package/dist/components/flow-editor/node-config-panel/DynamicSelectField.d.ts +22 -0
- package/dist/components/flow-editor/node-config-panel/JsonPreviewPanel.d.ts +25 -0
- package/dist/components/flow-editor/node-config-panel/NodeConfigPanel.d.ts +14 -0
- package/dist/components/flow-editor/node-config-panel/NodeConfigPanelHeader.d.ts +15 -0
- package/dist/components/flow-editor/node-config-panel/ParametersSection.d.ts +16 -0
- package/dist/components/flow-editor/node-config-panel/SearchableSelectField.d.ts +17 -0
- package/dist/components/flow-editor/node-config-panel/SwitchCasesField.d.ts +18 -0
- package/dist/components/flow-editor/node-config-panel/hooks/index.d.ts +2 -0
- package/dist/components/flow-editor/node-config-panel/hooks/use-node-config-panel-state.d.ts +24 -0
- package/dist/components/flow-editor/node-config-panel/hooks/use-node-execution.d.ts +46 -0
- package/dist/components/flow-editor/node-config-panel/hooks/use-upstream-slots.d.ts +16 -0
- package/dist/components/flow-editor/node-config-panel/panels/AgentToolsPanel.d.ts +18 -0
- package/dist/components/flow-editor/node-config-panel/panels/ConfigurationPanel.d.ts +49 -0
- package/dist/components/flow-editor/node-config-panel/panels/DataMapperPane.d.ts +40 -0
- package/dist/components/flow-editor/node-config-panel/panels/InputPanel.d.ts +49 -0
- package/dist/components/flow-editor/node-config-panel/panels/OutputPanel.d.ts +7 -0
- package/dist/components/flow-editor/node-config-panel/panels/index.d.ts +4 -0
- package/dist/components/flow-editor/node-config-panel/types.d.ts +19 -0
- package/dist/components/flow-editor/node-config-panel/use-node-config-panel-store.d.ts +49 -0
- package/dist/components/flow-editor/node-config-panel/use-node-config-state.d.ts +26 -0
- package/dist/components/flow-editor/node-config-panel/use-run-node.d.ts +16 -0
- package/dist/components/flow-editor/node-config-panel/utils.d.ts +9 -0
- package/dist/components/flow-editor/serialize-to-sdk.d.ts +20 -0
- package/dist/components/flow-editor/toolbar-context.d.ts +2 -0
- package/dist/components/flow-editor/use-copy-paste.d.ts +7 -0
- package/dist/components/flow-editor/use-copy-paste.types.d.ts +38 -0
- package/dist/components/flow-editor/use-flow-editor.d.ts +44 -0
- package/dist/components/flow-runs-table/FlowRunsTable.d.ts +6 -0
- package/dist/components/flow-runs-table/index.d.ts +1 -0
- package/dist/components/flow-viewer/FlowRunsView.d.ts +7 -0
- package/dist/components/flow-viewer/FlowStatusView.d.ts +21 -0
- package/dist/components/flow-viewer/RunSelector.d.ts +13 -0
- package/dist/components/flow-viewer/RunsSidebar.d.ts +14 -0
- package/dist/components/flow-viewer/agent-tool-executions-list.d.ts +7 -0
- package/dist/components/flow-viewer/index.d.ts +1 -0
- package/dist/components/flow-viewer/logs-panel.d.ts +18 -0
- package/dist/components/flow-viewer/use-execution-log-data.d.ts +113 -0
- package/dist/components/graph/BatchFlowEdge.d.ts +33 -0
- package/dist/components/graph/LayoutSelector.d.ts +9 -0
- package/dist/components/graph/index.d.ts +47 -0
- package/dist/components/graph/styleUtils.d.ts +124 -0
- package/dist/components/nodes/AgentConfigPanel.d.ts +24 -0
- package/dist/components/nodes/AgentNode.d.ts +8 -0
- package/dist/components/nodes/AgentToolsBox.d.ts +41 -0
- package/dist/components/nodes/NodeAppendix.d.ts +19 -0
- package/dist/components/nodes/NodeStatusIndicator.d.ts +30 -0
- package/dist/components/nodes/NodeViewContext.d.ts +18 -0
- package/dist/components/nodes/ToolParamField.d.ts +28 -0
- package/dist/components/nodes/ToolSelectorModal.d.ts +80 -0
- package/dist/components/nodes/ToolSelectorParts.d.ts +30 -0
- package/dist/components/nodes/UniversalNode.d.ts +2 -0
- package/dist/components/nodes/createContextAwareNodes.d.ts +6 -0
- package/dist/components/nodes/index.d.ts +22 -0
- package/dist/components/nodes/nodeRegistry.d.ts +13 -0
- package/dist/components/nodes/withNodeContext.d.ts +7 -0
- package/dist/components/shared/InvectLoader.d.ts +8 -0
- package/dist/components/shared/InvectLogo.d.ts +9 -0
- package/dist/components/shared/ProviderIcon.d.ts +23 -0
- package/dist/components/side-menu/side-menu.d.ts +4 -0
- package/dist/components/sidebar/BaseSidebar.d.ts +17 -0
- package/dist/components/sidebar/index.d.ts +1 -0
- package/dist/components/triggers/CronPreview.d.ts +12 -0
- package/dist/components/triggers/index.d.ts +1 -0
- package/dist/components/ui/alert-dialog.d.ts +18 -0
- package/dist/components/ui/badge.d.ts +9 -0
- package/dist/components/ui/button.d.ts +13 -0
- package/dist/components/ui/card.d.ts +9 -0
- package/dist/components/ui/codemirror-js-editor.d.ts +25 -0
- package/dist/components/ui/codemirror-json-editor.d.ts +18 -0
- package/dist/components/ui/codemirror-nunjucks-editor.d.ts +13 -0
- package/dist/components/ui/codemirror-vscode-theme.d.ts +24 -0
- package/dist/components/ui/collapsible.d.ts +6 -0
- package/dist/components/ui/command.d.ts +18 -0
- package/dist/components/ui/dialog.d.ts +18 -0
- package/dist/components/ui/dropdown-menu.d.ts +25 -0
- package/dist/components/ui/empty-state.d.ts +21 -0
- package/dist/components/ui/input.d.ts +3 -0
- package/dist/components/ui/label.d.ts +4 -0
- package/dist/components/ui/popover.d.ts +10 -0
- package/dist/components/ui/resizable.d.ts +8 -0
- package/dist/components/ui/scroll-area.d.ts +5 -0
- package/dist/components/ui/select.d.ts +18 -0
- package/dist/components/ui/separator.d.ts +4 -0
- package/dist/components/ui/slider.d.ts +4 -0
- package/dist/components/ui/switch.d.ts +3 -0
- package/dist/components/ui/table.d.ts +10 -0
- package/dist/components/ui/textarea.d.ts +3 -0
- package/dist/components/ui/tooltip.d.ts +7 -0
- package/dist/components/ui/tree-view.d.ts +107 -0
- package/dist/contexts/AgentToolCallbacksContext.d.ts +23 -0
- package/dist/contexts/ApiContext.d.ts +11 -0
- package/dist/contexts/FlowDataContext.d.ts +9 -0
- package/dist/contexts/NodeRegistryContext.d.ts +14 -0
- package/dist/contexts/PluginRegistryContext.d.ts +39 -0
- package/dist/contexts/ThemeProvider.d.ts +18 -0
- package/dist/contexts/ValidationContext.d.ts +22 -0
- package/dist/demo/DemoInvect.d.ts +11 -0
- package/dist/demo/FlowViewer.d.ts +31 -0
- package/dist/demo/demo-api-client.d.ts +33 -0
- package/dist/demo/index.d.ts +6 -0
- package/dist/demo/sample-data.d.ts +1538 -0
- package/dist/demo.d.ts +2 -0
- package/dist/demo.js +2774 -0
- package/dist/estree-ClbRfS-1.js +7076 -0
- package/dist/fonts/geist-cyrillic-wght-normal.woff2 +0 -0
- package/dist/fonts/geist-latin-ext-wght-normal.woff2 +0 -0
- package/dist/fonts/geist-latin-wght-normal.woff2 +0 -0
- package/dist/fonts/iosevka-latin-400-normal.woff2 +0 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/use-document-title.d.ts +1 -0
- package/dist/hooks/use-flow-data.d.ts +22 -0
- package/dist/hooks/use-invect-portal-class.d.ts +21 -0
- package/dist/hooks/useFlowEditorStore.d.ts +1 -0
- package/dist/index.css +3 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.js +717 -0
- package/dist/lib/utils.d.ts +2 -0
- package/dist/prettier.d.ts +13 -0
- package/dist/routes/all-flow-runs.d.ts +5 -0
- package/dist/routes/credentials.d.ts +5 -0
- package/dist/routes/flow-route-layout.d.ts +19 -0
- package/dist/routes/flow-runs.d.ts +5 -0
- package/dist/routes/flow.d.ts +5 -0
- package/dist/routes/home.d.ts +5 -0
- package/dist/services/index.d.ts +1 -0
- package/dist/standalone-C3Df7W52.js +3463 -0
- package/dist/stores/executionViewStore.d.ts +64 -0
- package/dist/stores/flow-editor.store.d.ts +137 -0
- package/dist/stores/flowEditorStore.d.ts +1 -0
- package/dist/stores/index.d.ts +2 -0
- package/dist/stores/uiStore.d.ts +45 -0
- package/dist/types/agent-tools.types.d.ts +53 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/node-definition.types.d.ts +85 -0
- package/dist/types/plugin.types.d.ts +100 -0
- package/dist/utils/credentialBranding.d.ts +8 -0
- package/dist/utils/credentialFiltering.d.ts +20 -0
- package/dist/utils/flowTransformations.d.ts +16 -0
- package/dist/utils/layoutUtils.d.ts +23 -0
- package/dist/utils/nodeReferenceUtils.d.ts +37 -0
- package/dist/vendor.d.ts +5 -0
- package/package.json +130 -0
- package/src/.DS_Store +0 -0
- package/src/Invect.tsx +229 -0
- package/src/InvectShell.tsx +55 -0
- package/src/api/agent-tools.api.ts +23 -0
- package/src/api/client.ts +899 -0
- package/src/api/credentials.api.ts +197 -0
- package/src/api/executions.api.ts +228 -0
- package/src/api/flows.api.ts +195 -0
- package/src/api/index.ts +17 -0
- package/src/api/node-data.api.ts +167 -0
- package/src/api/query-keys.ts +44 -0
- package/src/api/triggers.api.ts +120 -0
- package/src/api/types.ts +212 -0
- package/src/api/use-flow-run-stream.ts +206 -0
- package/src/app.css +560 -0
- package/src/assets/.DS_Store +0 -0
- package/src/assets/favicon.ico +0 -0
- package/src/assets/fonts/geist-cyrillic-wght-normal.woff2 +0 -0
- package/src/assets/fonts/geist-latin-ext-wght-normal.woff2 +0 -0
- package/src/assets/fonts/geist-latin-wght-normal.woff2 +0 -0
- package/src/assets/fonts/iosevka-latin-400-normal.woff2 +0 -0
- package/src/assets/invect-branding.ts +51 -0
- package/src/assets/provider-icons/anthropic.svg +1 -0
- package/src/assets/provider-icons/anthropic_light.svg +1 -0
- package/src/assets/provider-icons/github.svg +1 -0
- package/src/assets/provider-icons/github_light.svg +1 -0
- package/src/assets/provider-icons/gmail.svg +1 -0
- package/src/assets/provider-icons/google_calendar.svg +1 -0
- package/src/assets/provider-icons/google_docs.svg +1 -0
- package/src/assets/provider-icons/google_drive.svg +1 -0
- package/src/assets/provider-icons/google_sheets.svg +1 -0
- package/src/assets/provider-icons/index.ts +55 -0
- package/src/assets/provider-icons/linear.svg +1 -0
- package/src/assets/provider-icons/openai.svg +1 -0
- package/src/assets/provider-icons/postgres.svg +1 -0
- package/src/assets/provider-icons/slack.svg +1 -0
- package/src/assets/small-loader-dark.svg +22 -0
- package/src/assets/small-loader-light.svg +22 -0
- package/src/assets/small.svg +7 -0
- package/src/components/.DS_Store +0 -0
- package/src/components/PageLayout.tsx +55 -0
- package/src/components/chat/ChatInput.tsx +115 -0
- package/src/components/chat/ChatMessageList.tsx +788 -0
- package/src/components/chat/ChatModelSelector.tsx +208 -0
- package/src/components/chat/ChatPanel.tsx +243 -0
- package/src/components/chat/ChatPromptOverlay.tsx +150 -0
- package/src/components/chat/ChatProviderSelector.tsx +135 -0
- package/src/components/chat/ChatSettingsPanel.tsx +277 -0
- package/src/components/chat/InlineCredentialSetup.tsx +343 -0
- package/src/components/chat/MarkdownRenderer.tsx +140 -0
- package/src/components/chat/chat-memory.ts +88 -0
- package/src/components/chat/chat.store.ts +479 -0
- package/src/components/chat/index.ts +5 -0
- package/src/components/chat/use-chat.ts +473 -0
- package/src/components/credentials/CreateCredentialModal.tsx +609 -0
- package/src/components/credentials/CredentialDetailDialog.tsx +882 -0
- package/src/components/credentials/EditCredentialModal.tsx +399 -0
- package/src/components/credentials/OAuth2ConnectButton.tsx +288 -0
- package/src/components/credentials/OAuth2ProviderSelector.tsx +360 -0
- package/src/components/credentials/credential-utils.ts +99 -0
- package/src/components/credentials/index.ts +10 -0
- package/src/components/dashboard/FailedRunsAlert.tsx +67 -0
- package/src/components/dashboard/FlowCard.tsx +64 -0
- package/src/components/dashboard/RecentActivityTable.tsx +92 -0
- package/src/components/dashboard/StatCard.tsx +32 -0
- package/src/components/dashboard/index.ts +5 -0
- package/src/components/dashboard/status-helpers.tsx +102 -0
- package/src/components/flow-editor/ActionsSidebar.tsx +503 -0
- package/src/components/flow-editor/FlowEditor.tsx +1002 -0
- package/src/components/flow-editor/FlowHeader.tsx +87 -0
- package/src/components/flow-editor/FlowLayout.tsx +117 -0
- package/src/components/flow-editor/ModeSwitcher.tsx +49 -0
- package/src/components/flow-editor/NodeSidebar.tsx +343 -0
- package/src/components/flow-editor/RunControls.tsx +109 -0
- package/src/components/flow-editor/ToolConfigPanel.tsx +434 -0
- package/src/components/flow-editor/ValidationPanel.tsx +167 -0
- package/src/components/flow-editor/flow-editor.store.ts +2 -0
- package/src/components/flow-editor/index.ts +6 -0
- package/src/components/flow-editor/inline-edit.tsx +111 -0
- package/src/components/flow-editor/node-config-panel/ConfigFieldWithTemplate.tsx +334 -0
- package/src/components/flow-editor/node-config-panel/CredentialCombobox.tsx +217 -0
- package/src/components/flow-editor/node-config-panel/CredentialsSection.tsx +154 -0
- package/src/components/flow-editor/node-config-panel/DroppableInput.tsx +45 -0
- package/src/components/flow-editor/node-config-panel/DynamicSelectField.tsx +223 -0
- package/src/components/flow-editor/node-config-panel/JsonPreviewPanel.tsx +134 -0
- package/src/components/flow-editor/node-config-panel/NodeConfigPanel.tsx +650 -0
- package/src/components/flow-editor/node-config-panel/NodeConfigPanelHeader.tsx +91 -0
- package/src/components/flow-editor/node-config-panel/ParametersSection.tsx +144 -0
- package/src/components/flow-editor/node-config-panel/SearchableSelectField.tsx +126 -0
- package/src/components/flow-editor/node-config-panel/SwitchCasesField.tsx +212 -0
- package/src/components/flow-editor/node-config-panel/hooks/index.ts +2 -0
- package/src/components/flow-editor/node-config-panel/hooks/use-node-config-panel-state.ts +284 -0
- package/src/components/flow-editor/node-config-panel/hooks/use-node-execution.ts +287 -0
- package/src/components/flow-editor/node-config-panel/hooks/use-upstream-slots.ts +310 -0
- package/src/components/flow-editor/node-config-panel/panels/AgentToolsPanel.tsx +837 -0
- package/src/components/flow-editor/node-config-panel/panels/ConfigurationPanel.tsx +383 -0
- package/src/components/flow-editor/node-config-panel/panels/DataMapperPane.tsx +456 -0
- package/src/components/flow-editor/node-config-panel/panels/InputPanel.tsx +338 -0
- package/src/components/flow-editor/node-config-panel/panels/OutputPanel.tsx +109 -0
- package/src/components/flow-editor/node-config-panel/panels/index.ts +4 -0
- package/src/components/flow-editor/node-config-panel/types.ts +20 -0
- package/src/components/flow-editor/node-config-panel/use-node-config-panel-store.ts +283 -0
- package/src/components/flow-editor/node-config-panel/use-node-config-state.ts +172 -0
- package/src/components/flow-editor/node-config-panel/use-run-node.ts +147 -0
- package/src/components/flow-editor/node-config-panel/utils.ts +73 -0
- package/src/components/flow-editor/serialize-to-sdk.ts +204 -0
- package/src/components/flow-editor/toolbar-context.ts +9 -0
- package/src/components/flow-editor/use-copy-paste.ts +575 -0
- package/src/components/flow-editor/use-copy-paste.types.ts +35 -0
- package/src/components/flow-editor/use-flow-editor.ts +241 -0
- package/src/components/flow-runs-table/FlowRunsTable.tsx +631 -0
- package/src/components/flow-runs-table/index.ts +1 -0
- package/src/components/flow-viewer/FlowRunsView.tsx +268 -0
- package/src/components/flow-viewer/FlowStatusView.tsx +351 -0
- package/src/components/flow-viewer/RunSelector.tsx +422 -0
- package/src/components/flow-viewer/RunsSidebar.tsx +125 -0
- package/src/components/flow-viewer/agent-tool-executions-list.tsx +298 -0
- package/src/components/flow-viewer/index.ts +1 -0
- package/src/components/flow-viewer/logs-panel.tsx +567 -0
- package/src/components/flow-viewer/use-execution-log-data.ts +374 -0
- package/src/components/graph/BatchFlowEdge.tsx +229 -0
- package/src/components/graph/LayoutSelector.tsx +42 -0
- package/src/components/graph/index.ts +61 -0
- package/src/components/graph/styleUtils.ts +375 -0
- package/src/components/nodes/.DS_Store +0 -0
- package/src/components/nodes/AgentConfigPanel.tsx +1033 -0
- package/src/components/nodes/AgentNode.tsx +298 -0
- package/src/components/nodes/AgentToolsBox.tsx +193 -0
- package/src/components/nodes/NodeAppendix.tsx +98 -0
- package/src/components/nodes/NodeStatusIndicator.tsx +74 -0
- package/src/components/nodes/NodeViewContext.tsx +45 -0
- package/src/components/nodes/ToolParamField.tsx +282 -0
- package/src/components/nodes/ToolSelectorModal.tsx +648 -0
- package/src/components/nodes/ToolSelectorParts.tsx +505 -0
- package/src/components/nodes/UniversalNode.tsx +356 -0
- package/src/components/nodes/createContextAwareNodes.ts +19 -0
- package/src/components/nodes/index.ts +45 -0
- package/src/components/nodes/nodeRegistry.ts +50 -0
- package/src/components/nodes/withNodeContext.tsx +55 -0
- package/src/components/shared/InvectLoader.tsx +59 -0
- package/src/components/shared/InvectLogo.tsx +59 -0
- package/src/components/shared/ProviderIcon.tsx +115 -0
- package/src/components/side-menu/side-menu.tsx +267 -0
- package/src/components/sidebar/BaseSidebar.tsx +148 -0
- package/src/components/sidebar/index.ts +1 -0
- package/src/components/triggers/CronPreview.tsx +243 -0
- package/src/components/triggers/index.ts +1 -0
- package/src/components/ui/alert-dialog.tsx +152 -0
- package/src/components/ui/badge.tsx +39 -0
- package/src/components/ui/button.tsx +58 -0
- package/src/components/ui/card.tsx +75 -0
- package/src/components/ui/codemirror-js-editor.tsx +432 -0
- package/src/components/ui/codemirror-json-editor.tsx +816 -0
- package/src/components/ui/codemirror-nunjucks-editor.tsx +451 -0
- package/src/components/ui/codemirror-vscode-theme.ts +243 -0
- package/src/components/ui/collapsible.tsx +12 -0
- package/src/components/ui/command.tsx +162 -0
- package/src/components/ui/dialog.tsx +140 -0
- package/src/components/ui/dropdown-menu.tsx +232 -0
- package/src/components/ui/empty-state.tsx +93 -0
- package/src/components/ui/input.tsx +26 -0
- package/src/components/ui/label.tsx +19 -0
- package/src/components/ui/popover.tsx +53 -0
- package/src/components/ui/resizable.tsx +61 -0
- package/src/components/ui/scroll-area.tsx +56 -0
- package/src/components/ui/select.tsx +179 -0
- package/src/components/ui/separator.tsx +26 -0
- package/src/components/ui/slider.tsx +58 -0
- package/src/components/ui/switch.tsx +22 -0
- package/src/components/ui/table.tsx +90 -0
- package/src/components/ui/textarea.tsx +23 -0
- package/src/components/ui/tooltip.tsx +54 -0
- package/src/components/ui/tree-view.tsx +574 -0
- package/src/contexts/AgentToolCallbacksContext.tsx +31 -0
- package/src/contexts/ApiContext.tsx +51 -0
- package/src/contexts/FlowDataContext.tsx +21 -0
- package/src/contexts/NodeRegistryContext.tsx +54 -0
- package/src/contexts/PluginRegistryContext.tsx +182 -0
- package/src/contexts/ThemeProvider.tsx +106 -0
- package/src/contexts/ValidationContext.tsx +122 -0
- package/src/demo/DemoInvect.tsx +42 -0
- package/src/demo/FlowViewer.tsx +294 -0
- package/src/demo/demo-api-client.ts +246 -0
- package/src/demo/index.ts +28 -0
- package/src/demo/sample-data.ts +1980 -0
- package/src/hooks/index.ts +1 -0
- package/src/hooks/use-document-title.ts +8 -0
- package/src/hooks/use-flow-data.ts +144 -0
- package/src/hooks/use-invect-portal-class.ts +27 -0
- package/src/hooks/useFlowEditorStore.ts +2 -0
- package/src/index.ts +70 -0
- package/src/lib/utils.ts +6 -0
- package/src/prettier.d.ts +13 -0
- package/src/routes/all-flow-runs.tsx +27 -0
- package/src/routes/credentials.tsx +362 -0
- package/src/routes/flow-route-layout.tsx +113 -0
- package/src/routes/flow-runs.tsx +22 -0
- package/src/routes/flow.tsx +22 -0
- package/src/routes/home.tsx +282 -0
- package/src/services/index.ts +6 -0
- package/src/stores/executionViewStore.ts +211 -0
- package/src/stores/flow-editor.store.ts +738 -0
- package/src/stores/flowEditorStore.ts +2 -0
- package/src/stores/index.ts +10 -0
- package/src/stores/uiStore.ts +189 -0
- package/src/types/agent-tools.types.ts +64 -0
- package/src/types/index.ts +5 -0
- package/src/types/node-definition.types.ts +104 -0
- package/src/types/plugin.types.ts +123 -0
- package/src/utils/credentialBranding.ts +116 -0
- package/src/utils/credentialFiltering.ts +68 -0
- package/src/utils/flowTransformations.ts +137 -0
- package/src/utils/layoutUtils.ts +127 -0
- package/src/utils/nodeReferenceUtils.ts +135 -0
- package/src/vendor.d.ts +7 -0
|
@@ -0,0 +1,473 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useChat Hook
|
|
3
|
+
*
|
|
4
|
+
* Manages the SSE streaming connection to POST /chat.
|
|
5
|
+
* Reads events from the response body and dispatches them to the chat store.
|
|
6
|
+
* Handles ui_action events from tools to refresh data and navigate.
|
|
7
|
+
*
|
|
8
|
+
* Messages are scoped per flow and automatically persisted to the backend.
|
|
9
|
+
* When the active flowId changes, existing messages are saved and the new
|
|
10
|
+
* flow's history is loaded from the server.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { useCallback, useRef, useEffect } from 'react';
|
|
14
|
+
import { useNavigate } from 'react-router';
|
|
15
|
+
import { useQueryClient } from '@tanstack/react-query';
|
|
16
|
+
import { useApiClient } from '../../contexts/ApiContext';
|
|
17
|
+
import { useChatStore } from './chat.store';
|
|
18
|
+
import { useFlowEditorStore } from '~/stores/flow-editor.store';
|
|
19
|
+
import { queryKeys } from '../../api/query-keys';
|
|
20
|
+
import { getAllMemoryNotes, saveMemoryNote, deleteMemoryNote } from './chat-memory';
|
|
21
|
+
import type { ChatStreamEvent, ChatMessage } from './chat.store';
|
|
22
|
+
|
|
23
|
+
interface UseChatOptions {
|
|
24
|
+
flowId?: string;
|
|
25
|
+
selectedNodeId?: string;
|
|
26
|
+
selectedRunId?: string;
|
|
27
|
+
viewMode?: 'edit' | 'runs';
|
|
28
|
+
basePath?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function useChat(options: UseChatOptions = {}) {
|
|
32
|
+
const apiClient = useApiClient();
|
|
33
|
+
const store = useChatStore();
|
|
34
|
+
const queryClient = useQueryClient();
|
|
35
|
+
const navigate = useNavigate();
|
|
36
|
+
|
|
37
|
+
// Refs for stable access inside the streaming loop (avoids stale closures)
|
|
38
|
+
const optionsRef = useRef(options);
|
|
39
|
+
optionsRef.current = options;
|
|
40
|
+
|
|
41
|
+
const apiClientRef = useRef(apiClient);
|
|
42
|
+
apiClientRef.current = apiClient;
|
|
43
|
+
|
|
44
|
+
// ─── Flow-scoped history: load/save on flow switch ───
|
|
45
|
+
|
|
46
|
+
// Save current messages to backend
|
|
47
|
+
const saveMessages = useCallback(async () => {
|
|
48
|
+
const state = useChatStore.getState();
|
|
49
|
+
if (!state.activeFlowId || !state.isDirty() || state.messages.length === 0) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
try {
|
|
53
|
+
await apiClientRef.current.saveChatMessages(
|
|
54
|
+
state.activeFlowId,
|
|
55
|
+
state.getSerializableMessages(),
|
|
56
|
+
);
|
|
57
|
+
state.markClean();
|
|
58
|
+
} catch (err) {
|
|
59
|
+
// Non-critical — log but don't disrupt UX
|
|
60
|
+
console.warn('[chat] Failed to save messages:', err);
|
|
61
|
+
}
|
|
62
|
+
}, []);
|
|
63
|
+
|
|
64
|
+
// Load messages from backend for a given flow
|
|
65
|
+
const loadMessages = useCallback(async (flowId: string) => {
|
|
66
|
+
const state = useChatStore.getState();
|
|
67
|
+
state.setLoadingHistory(true);
|
|
68
|
+
try {
|
|
69
|
+
const records = await apiClientRef.current.getChatMessages(flowId);
|
|
70
|
+
const messages: ChatMessage[] = records.map((r, idx) => ({
|
|
71
|
+
id: r.id || `loaded_${idx}`,
|
|
72
|
+
role: r.role,
|
|
73
|
+
content: r.content,
|
|
74
|
+
toolMeta: r.toolMeta ? (r.toolMeta as ChatMessage['toolMeta']) : undefined,
|
|
75
|
+
createdAt: new Date(r.createdAt).getTime(),
|
|
76
|
+
}));
|
|
77
|
+
useChatStore.getState().loadMessages(messages);
|
|
78
|
+
} catch (err) {
|
|
79
|
+
console.warn('[chat] Failed to load messages:', err);
|
|
80
|
+
useChatStore.getState().setLoadingHistory(false);
|
|
81
|
+
}
|
|
82
|
+
}, []);
|
|
83
|
+
|
|
84
|
+
// When flowId changes, save old conversation and load new one
|
|
85
|
+
useEffect(() => {
|
|
86
|
+
const currentActiveFlow = useChatStore.getState().activeFlowId;
|
|
87
|
+
const newFlowId = options.flowId ?? null;
|
|
88
|
+
|
|
89
|
+
if (currentActiveFlow === newFlowId) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// Save messages for the old flow (fire-and-forget)
|
|
94
|
+
saveMessages();
|
|
95
|
+
|
|
96
|
+
// Switch to new flow
|
|
97
|
+
useChatStore.getState().setActiveFlow(newFlowId);
|
|
98
|
+
|
|
99
|
+
// Load messages for the new flow
|
|
100
|
+
if (newFlowId) {
|
|
101
|
+
loadMessages(newFlowId);
|
|
102
|
+
}
|
|
103
|
+
}, [options.flowId, saveMessages, loadMessages]);
|
|
104
|
+
|
|
105
|
+
// Save messages when the window is about to unload
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
const onBeforeUnload = () => {
|
|
108
|
+
const state = useChatStore.getState();
|
|
109
|
+
if (!state.activeFlowId || !state.isDirty() || state.messages.length === 0) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
// Use fetch with keepalive for reliability on tab close
|
|
113
|
+
const url = `${apiClientRef.current.getBaseURL()}/chat/messages/${state.activeFlowId}`;
|
|
114
|
+
const body = JSON.stringify({ messages: state.getSerializableMessages() });
|
|
115
|
+
fetch(url, {
|
|
116
|
+
method: 'PUT',
|
|
117
|
+
headers: { 'Content-Type': 'application/json' },
|
|
118
|
+
body,
|
|
119
|
+
keepalive: true,
|
|
120
|
+
}).catch(() => {
|
|
121
|
+
// best-effort save on tab close — nothing to handle
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
window.addEventListener('beforeunload', onBeforeUnload);
|
|
125
|
+
return () => window.removeEventListener('beforeunload', onBeforeUnload);
|
|
126
|
+
}, []);
|
|
127
|
+
|
|
128
|
+
const sendMessage = useCallback(
|
|
129
|
+
async (content: string, opts?: { isEdit?: boolean }) => {
|
|
130
|
+
if (store.isStreaming || !content.trim()) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Add user message to store
|
|
135
|
+
store.addUserMessage(content);
|
|
136
|
+
|
|
137
|
+
// Build message history for the API (only user/assistant messages)
|
|
138
|
+
const historyMessages = store.messages
|
|
139
|
+
.filter((m) => m.role === 'user' || (m.role === 'assistant' && m.content))
|
|
140
|
+
.map((m) => ({ role: m.role, content: m.content }));
|
|
141
|
+
|
|
142
|
+
// When this is an edit+resend, inject a system-level note so the LLM
|
|
143
|
+
// knows the flow may contain nodes/edges from the deleted conversation.
|
|
144
|
+
if (opts?.isEdit) {
|
|
145
|
+
historyMessages.push({
|
|
146
|
+
role: 'user' as const,
|
|
147
|
+
content:
|
|
148
|
+
'[Note: I edited an earlier message. The conversation was rewound to this point, ' +
|
|
149
|
+
'but the flow may still contain nodes or edges from the previous conversation that ' +
|
|
150
|
+
'no longer match this chat history. Please use get_current_flow_context to check ' +
|
|
151
|
+
'the actual flow state before making changes.]\n\n' +
|
|
152
|
+
content,
|
|
153
|
+
});
|
|
154
|
+
} else {
|
|
155
|
+
historyMessages.push({ role: 'user' as const, content });
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const context = {
|
|
159
|
+
flowId: optionsRef.current.flowId,
|
|
160
|
+
selectedNodeId: optionsRef.current.selectedNodeId,
|
|
161
|
+
selectedRunId: optionsRef.current.selectedRunId,
|
|
162
|
+
viewMode: optionsRef.current.viewMode,
|
|
163
|
+
maxSteps: useChatStore.getState().settings.maxSteps,
|
|
164
|
+
credentialId: useChatStore.getState().settings.credentialId ?? undefined,
|
|
165
|
+
model: useChatStore.getState().settings.model ?? undefined,
|
|
166
|
+
memoryNotes: getAllMemoryNotes(optionsRef.current.flowId),
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// Create abort controller
|
|
170
|
+
const controller = new AbortController();
|
|
171
|
+
store.startStreaming(controller);
|
|
172
|
+
|
|
173
|
+
try {
|
|
174
|
+
const response = await apiClient.sendChatMessage(
|
|
175
|
+
historyMessages,
|
|
176
|
+
context,
|
|
177
|
+
controller.signal,
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
if (!response.body) {
|
|
181
|
+
store.setError('No response body from chat endpoint');
|
|
182
|
+
return;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const reader = response.body.getReader();
|
|
186
|
+
const decoder = new TextDecoder();
|
|
187
|
+
let buffer = '';
|
|
188
|
+
|
|
189
|
+
while (true) {
|
|
190
|
+
const { done, value } = await reader.read();
|
|
191
|
+
if (done) {
|
|
192
|
+
break;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
buffer += decoder.decode(value, { stream: true });
|
|
196
|
+
|
|
197
|
+
// Parse SSE frames from buffer
|
|
198
|
+
const lines = buffer.split('\n');
|
|
199
|
+
buffer = lines.pop() ?? ''; // Keep incomplete line in buffer
|
|
200
|
+
|
|
201
|
+
for (const line of lines) {
|
|
202
|
+
if (line.startsWith('event: ')) {
|
|
203
|
+
// Event type is parsed from the JSON payload, not the SSE frame header
|
|
204
|
+
} else if (line.startsWith('data: ')) {
|
|
205
|
+
const data = line.slice(6);
|
|
206
|
+
try {
|
|
207
|
+
const event: ChatStreamEvent = JSON.parse(data);
|
|
208
|
+
handleEvent(event, store, {
|
|
209
|
+
queryClient,
|
|
210
|
+
navigate,
|
|
211
|
+
optionsRef,
|
|
212
|
+
});
|
|
213
|
+
} catch {
|
|
214
|
+
// Ignore malformed JSON
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
// Empty line = end of SSE frame (already handled by split)
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// Finalize: clean up pending tool calls and commit assistant text
|
|
222
|
+
store.finalizePendingToolCalls();
|
|
223
|
+
store.finalizeAssistantMessage();
|
|
224
|
+
|
|
225
|
+
// Auto-save after stream completes
|
|
226
|
+
saveMessages();
|
|
227
|
+
} catch (error: unknown) {
|
|
228
|
+
if ((error as Error).name === 'AbortError') {
|
|
229
|
+
// User cancelled — clean up pending tool calls
|
|
230
|
+
store.finalizePendingToolCalls();
|
|
231
|
+
saveMessages();
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
// Clean up pending tool calls before showing the error
|
|
235
|
+
store.finalizePendingToolCalls();
|
|
236
|
+
saveMessages();
|
|
237
|
+
const msg = (error as Error).message || 'Chat request failed';
|
|
238
|
+
// Friendly error messages for common failures
|
|
239
|
+
if (msg.includes('Failed to fetch') || msg.includes('NetworkError')) {
|
|
240
|
+
store.setError('Connection lost — check that the server is running and try again.');
|
|
241
|
+
} else if (msg.includes('503') || msg.includes('initializing')) {
|
|
242
|
+
store.setError('Server is still starting up — please try again in a moment.');
|
|
243
|
+
} else {
|
|
244
|
+
store.setError(msg);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
[
|
|
249
|
+
apiClient,
|
|
250
|
+
options.flowId,
|
|
251
|
+
options.selectedNodeId,
|
|
252
|
+
options.viewMode,
|
|
253
|
+
store,
|
|
254
|
+
queryClient,
|
|
255
|
+
navigate,
|
|
256
|
+
saveMessages,
|
|
257
|
+
],
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
// Wrap clearMessages to also delete from backend
|
|
261
|
+
const clearMessages = useCallback(async () => {
|
|
262
|
+
store.clearMessages();
|
|
263
|
+
const flowId = options.flowId;
|
|
264
|
+
if (flowId) {
|
|
265
|
+
try {
|
|
266
|
+
await apiClient.deleteChatMessages(flowId);
|
|
267
|
+
store.markClean();
|
|
268
|
+
} catch (err) {
|
|
269
|
+
console.warn('[chat] Failed to delete messages on server:', err);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}, [store, options.flowId, apiClient]);
|
|
273
|
+
|
|
274
|
+
return {
|
|
275
|
+
sendMessage,
|
|
276
|
+
stopStreaming: store.stopStreaming,
|
|
277
|
+
clearMessages,
|
|
278
|
+
messages: store.messages,
|
|
279
|
+
isStreaming: store.isStreaming,
|
|
280
|
+
isLoadingHistory: store.isLoadingHistory,
|
|
281
|
+
streamingText: store.streamingText,
|
|
282
|
+
error: store.error,
|
|
283
|
+
isOpen: store.isOpen,
|
|
284
|
+
togglePanel: store.togglePanel,
|
|
285
|
+
setOpen: store.setOpen,
|
|
286
|
+
// Settings
|
|
287
|
+
settings: store.settings,
|
|
288
|
+
isSettingsPanelOpen: store.isSettingsPanelOpen,
|
|
289
|
+
toggleSettingsPanel: store.toggleSettingsPanel,
|
|
290
|
+
updateSettings: store.updateSettings,
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// =====================================
|
|
295
|
+
// UI Action Handler
|
|
296
|
+
// =====================================
|
|
297
|
+
|
|
298
|
+
interface UiActionContext {
|
|
299
|
+
queryClient: ReturnType<typeof useQueryClient>;
|
|
300
|
+
navigate: ReturnType<typeof useNavigate>;
|
|
301
|
+
optionsRef: React.RefObject<UseChatOptions>;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* Handle a ui_action event from the chat stream.
|
|
306
|
+
* Maps tool-emitted actions to query invalidation, navigation, and store updates.
|
|
307
|
+
*/
|
|
308
|
+
function handleUiAction(action: string, data: Record<string, unknown>, ctx: UiActionContext) {
|
|
309
|
+
const { queryClient, navigate, optionsRef } = ctx;
|
|
310
|
+
const basePath = optionsRef.current?.basePath ?? '';
|
|
311
|
+
|
|
312
|
+
switch (action) {
|
|
313
|
+
// ─── Flow was modified (new version published) ───
|
|
314
|
+
case 'refresh_flow': {
|
|
315
|
+
const flowId = (data.flowId as string) || optionsRef.current?.flowId;
|
|
316
|
+
if (!flowId) {
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// DO NOT call resetDirty() here — let syncFromServer's content-based guard decide.
|
|
321
|
+
// If the user has unsaved local changes, syncFromServer will reject the incoming
|
|
322
|
+
// data (snapshot mismatch). If the user has no local changes, it will apply cleanly.
|
|
323
|
+
|
|
324
|
+
// Invalidate React Query caches to trigger refetch
|
|
325
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.reactFlow(flowId) });
|
|
326
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.flowVersions(flowId) });
|
|
327
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.flow(flowId) });
|
|
328
|
+
|
|
329
|
+
// Select a specific node if the tool requested it
|
|
330
|
+
const selectNodeId = data.selectNodeId as string | undefined;
|
|
331
|
+
if (selectNodeId) {
|
|
332
|
+
// Small delay to let the refetch land before selecting
|
|
333
|
+
setTimeout(() => {
|
|
334
|
+
useFlowEditorStore.getState().selectNode(selectNodeId);
|
|
335
|
+
}, 300);
|
|
336
|
+
}
|
|
337
|
+
break;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// ─── Navigate to a different flow ───
|
|
341
|
+
case 'navigate_to_flow': {
|
|
342
|
+
const flowId = data.flowId as string;
|
|
343
|
+
if (!flowId) {
|
|
344
|
+
break;
|
|
345
|
+
}
|
|
346
|
+
navigate(`${basePath}/flow/${flowId}`);
|
|
347
|
+
break;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// ─── Open a flow run (after execution) ───
|
|
351
|
+
case 'open_flow_run': {
|
|
352
|
+
const flowId = (data.flowId as string) || optionsRef.current?.flowId;
|
|
353
|
+
const flowRunId = data.flowRunId as string;
|
|
354
|
+
if (!flowId || !flowRunId) {
|
|
355
|
+
break;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// Invalidate runs list so it includes the new run
|
|
359
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.executions(flowId) });
|
|
360
|
+
|
|
361
|
+
// Navigate to runs view with the specific run selected
|
|
362
|
+
navigate(`${basePath}/flow/${flowId}/runs?runId=${flowRunId}`);
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
// ─── Open credential setup (handled by CredentialSetupBubble in chat UI) ───
|
|
367
|
+
case 'open_credential_setup': {
|
|
368
|
+
// No-op: the credential modal is rendered inline in the chat message bubble.
|
|
369
|
+
break;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
// ─── Plan tracking ───
|
|
373
|
+
case 'show_plan':
|
|
374
|
+
case 'update_plan': {
|
|
375
|
+
const steps = data.steps as
|
|
376
|
+
| Array<{
|
|
377
|
+
index: number;
|
|
378
|
+
title: string;
|
|
379
|
+
status: string;
|
|
380
|
+
}>
|
|
381
|
+
| undefined;
|
|
382
|
+
if (steps) {
|
|
383
|
+
useChatStore.getState().setPlan({
|
|
384
|
+
summary: (data.summary as string) ?? '',
|
|
385
|
+
steps: steps.map((s) => ({
|
|
386
|
+
index: s.index,
|
|
387
|
+
title: s.title,
|
|
388
|
+
status: s.status as 'pending' | 'in_progress' | 'done' | 'skipped',
|
|
389
|
+
})),
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
break;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// ─── Memory persistence (browser-local) ───
|
|
396
|
+
case 'save_memory_note': {
|
|
397
|
+
const scope = data.scope as 'flow' | 'workspace';
|
|
398
|
+
const content = data.content as string;
|
|
399
|
+
const flowId = data.flowId as string;
|
|
400
|
+
if (content) {
|
|
401
|
+
saveMemoryNote(scope, content, flowId || undefined);
|
|
402
|
+
}
|
|
403
|
+
break;
|
|
404
|
+
}
|
|
405
|
+
case 'delete_memory_note': {
|
|
406
|
+
const scope = data.scope as 'flow' | 'workspace';
|
|
407
|
+
const content = data.content as string;
|
|
408
|
+
const flowId = data.flowId as string;
|
|
409
|
+
if (content) {
|
|
410
|
+
deleteMemoryNote(scope, content, flowId || undefined);
|
|
411
|
+
}
|
|
412
|
+
break;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
default:
|
|
416
|
+
console.log('[chat] Unhandled ui_action:', action, data);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// =====================================
|
|
421
|
+
// Event Dispatcher
|
|
422
|
+
// =====================================
|
|
423
|
+
|
|
424
|
+
/**
|
|
425
|
+
* Dispatch a single SSE event to the chat store.
|
|
426
|
+
*/
|
|
427
|
+
function handleEvent(
|
|
428
|
+
event: ChatStreamEvent,
|
|
429
|
+
store: ReturnType<typeof useChatStore.getState>,
|
|
430
|
+
uiCtx: UiActionContext,
|
|
431
|
+
) {
|
|
432
|
+
switch (event.type) {
|
|
433
|
+
case 'text_delta':
|
|
434
|
+
if (event.text) {
|
|
435
|
+
store.appendStreamingText(event.text);
|
|
436
|
+
}
|
|
437
|
+
break;
|
|
438
|
+
|
|
439
|
+
case 'tool_call_start':
|
|
440
|
+
if (event.toolName && event.toolCallId) {
|
|
441
|
+
store.addToolCallMessage(event.toolName, event.toolCallId, event.args ?? {});
|
|
442
|
+
}
|
|
443
|
+
break;
|
|
444
|
+
|
|
445
|
+
case 'tool_call_result':
|
|
446
|
+
if (event.toolCallId && event.result) {
|
|
447
|
+
store.updateToolCallResult(event.toolCallId, event.result);
|
|
448
|
+
}
|
|
449
|
+
break;
|
|
450
|
+
|
|
451
|
+
case 'error':
|
|
452
|
+
if (event.message) {
|
|
453
|
+
store.setError(event.message);
|
|
454
|
+
}
|
|
455
|
+
break;
|
|
456
|
+
|
|
457
|
+
case 'done':
|
|
458
|
+
// Stream complete — finalizeAssistantMessage is called by the main loop
|
|
459
|
+
break;
|
|
460
|
+
|
|
461
|
+
case 'suggestions':
|
|
462
|
+
if (event.suggestions && Array.isArray(event.suggestions)) {
|
|
463
|
+
useChatStore.getState().setSuggestions(event.suggestions);
|
|
464
|
+
}
|
|
465
|
+
break;
|
|
466
|
+
|
|
467
|
+
case 'ui_action':
|
|
468
|
+
if (event.action) {
|
|
469
|
+
handleUiAction(event.action, event.data ?? {}, uiCtx);
|
|
470
|
+
}
|
|
471
|
+
break;
|
|
472
|
+
}
|
|
473
|
+
}
|