@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,479 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat Store (Zustand)
|
|
3
|
+
*
|
|
4
|
+
* Manages the chat assistant UI state: messages, streaming status,
|
|
5
|
+
* panel visibility, and the SSE connection lifecycle.
|
|
6
|
+
*
|
|
7
|
+
* Messages are scoped per flow — each flow has its own conversation.
|
|
8
|
+
* The store auto-loads messages from the backend when switching flows
|
|
9
|
+
* and saves them when the conversation changes.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { create } from 'zustand';
|
|
13
|
+
import { immer } from 'zustand/middleware/immer';
|
|
14
|
+
import { devtools } from 'zustand/middleware';
|
|
15
|
+
|
|
16
|
+
// =====================================
|
|
17
|
+
// Types
|
|
18
|
+
// =====================================
|
|
19
|
+
|
|
20
|
+
export interface ChatMessage {
|
|
21
|
+
id: string;
|
|
22
|
+
role: 'user' | 'assistant' | 'system' | 'tool';
|
|
23
|
+
content: string;
|
|
24
|
+
toolCalls?: Array<{ id: string; name: string; input: Record<string, unknown> }>;
|
|
25
|
+
toolCallId?: string;
|
|
26
|
+
/** Metadata for rendering tool call/result UI */
|
|
27
|
+
toolMeta?: {
|
|
28
|
+
toolName: string;
|
|
29
|
+
args?: Record<string, unknown>;
|
|
30
|
+
result?: { success: boolean; data?: unknown; error?: string };
|
|
31
|
+
status: 'pending' | 'done' | 'error';
|
|
32
|
+
startedAt?: number;
|
|
33
|
+
durationMs?: number;
|
|
34
|
+
};
|
|
35
|
+
createdAt: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ChatStreamEvent {
|
|
39
|
+
type:
|
|
40
|
+
| 'text_delta'
|
|
41
|
+
| 'tool_call_start'
|
|
42
|
+
| 'tool_call_result'
|
|
43
|
+
| 'ui_action'
|
|
44
|
+
| 'suggestions'
|
|
45
|
+
| 'error'
|
|
46
|
+
| 'done';
|
|
47
|
+
text?: string;
|
|
48
|
+
toolName?: string;
|
|
49
|
+
toolCallId?: string;
|
|
50
|
+
args?: Record<string, unknown>;
|
|
51
|
+
result?: { success: boolean; data?: unknown; error?: string };
|
|
52
|
+
action?: string;
|
|
53
|
+
data?: Record<string, unknown>;
|
|
54
|
+
message?: string;
|
|
55
|
+
recoverable?: boolean;
|
|
56
|
+
usage?: { promptTokens?: number; completionTokens?: number; totalTokens?: number };
|
|
57
|
+
suggestions?: Array<{ label: string; prompt: string }>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface PlanStep {
|
|
61
|
+
index: number;
|
|
62
|
+
title: string;
|
|
63
|
+
status: 'pending' | 'in_progress' | 'done' | 'skipped';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface ChatPlan {
|
|
67
|
+
summary: string;
|
|
68
|
+
steps: PlanStep[];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface ChatSettings {
|
|
72
|
+
/** Max tool-calling steps per message (1-200, default 50) */
|
|
73
|
+
maxSteps: number;
|
|
74
|
+
/** Selected credential ID for the chat assistant LLM provider */
|
|
75
|
+
credentialId: string | null;
|
|
76
|
+
/** Selected model ID override (null = provider default) */
|
|
77
|
+
model: string | null;
|
|
78
|
+
/** Recently used model IDs */
|
|
79
|
+
recentModels: string[];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const DEFAULT_CHAT_SETTINGS: ChatSettings = {
|
|
83
|
+
maxSteps: 50,
|
|
84
|
+
credentialId: null,
|
|
85
|
+
model: null,
|
|
86
|
+
recentModels: [],
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// =====================================
|
|
90
|
+
// State & Actions
|
|
91
|
+
// =====================================
|
|
92
|
+
|
|
93
|
+
interface ChatState {
|
|
94
|
+
/** Whether the chat panel is open */
|
|
95
|
+
isOpen: boolean;
|
|
96
|
+
/** The flow ID the current messages belong to (null = no flow) */
|
|
97
|
+
activeFlowId: string | null;
|
|
98
|
+
/** All messages in the current conversation (for the active flow) */
|
|
99
|
+
messages: ChatMessage[];
|
|
100
|
+
/** Whether we're loading messages from the backend */
|
|
101
|
+
isLoadingHistory: boolean;
|
|
102
|
+
/** Whether the assistant is currently streaming a response */
|
|
103
|
+
isStreaming: boolean;
|
|
104
|
+
/** Active AbortController for cancelling the stream */
|
|
105
|
+
abortController: AbortController | null;
|
|
106
|
+
/** Accumulated text for the current streaming assistant message */
|
|
107
|
+
streamingText: string;
|
|
108
|
+
/** Error message to display */
|
|
109
|
+
error: string | null;
|
|
110
|
+
/** Prompt queued from the overlay — ChatPanel consumes and clears it */
|
|
111
|
+
pendingPrompt: string | null;
|
|
112
|
+
/** Whether messages have been modified since last save */
|
|
113
|
+
_dirty: boolean;
|
|
114
|
+
/** Whether the settings panel is open */
|
|
115
|
+
isSettingsPanelOpen: boolean;
|
|
116
|
+
/** Chat settings (persisted to localStorage) */
|
|
117
|
+
settings: ChatSettings;
|
|
118
|
+
/** Current plan from the assistant (set via show_plan / update_plan uiActions) */
|
|
119
|
+
currentPlan: ChatPlan | null;
|
|
120
|
+
/** Suggested follow-up actions from the assistant */
|
|
121
|
+
suggestions: Array<{ label: string; prompt: string }>;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
interface ChatActions {
|
|
125
|
+
togglePanel: () => void;
|
|
126
|
+
setOpen: (open: boolean) => void;
|
|
127
|
+
/** Switch to a different flow's conversation. Clears current messages in-memory. */
|
|
128
|
+
setActiveFlow: (flowId: string | null) => void;
|
|
129
|
+
/** Load messages from the backend into the store */
|
|
130
|
+
loadMessages: (messages: ChatMessage[]) => void;
|
|
131
|
+
setLoadingHistory: (loading: boolean) => void;
|
|
132
|
+
addUserMessage: (content: string) => string;
|
|
133
|
+
startStreaming: (controller: AbortController) => void;
|
|
134
|
+
appendStreamingText: (text: string) => void;
|
|
135
|
+
addToolCallMessage: (toolName: string, toolCallId: string, args: Record<string, unknown>) => void;
|
|
136
|
+
updateToolCallResult: (
|
|
137
|
+
toolCallId: string,
|
|
138
|
+
result: { success: boolean; data?: unknown; error?: string },
|
|
139
|
+
) => void;
|
|
140
|
+
finalizeAssistantMessage: () => void;
|
|
141
|
+
stopStreaming: () => void;
|
|
142
|
+
setError: (error: string | null) => void;
|
|
143
|
+
clearMessages: () => void;
|
|
144
|
+
/** Mark any pending tool calls as errored (stream ended before result arrived) */
|
|
145
|
+
finalizePendingToolCalls: () => void;
|
|
146
|
+
/** Queue a prompt from the overlay — opens the panel automatically */
|
|
147
|
+
setPendingPrompt: (prompt: string) => void;
|
|
148
|
+
/** Consume (clear) the pending prompt — called by ChatPanel after sending */
|
|
149
|
+
consumePendingPrompt: () => string | null;
|
|
150
|
+
/** Mark messages as synced (not dirty) */
|
|
151
|
+
markClean: () => void;
|
|
152
|
+
/** Check if messages need saving */
|
|
153
|
+
isDirty: () => boolean;
|
|
154
|
+
/** Get messages suitable for backend persistence */
|
|
155
|
+
getSerializableMessages: () => Array<{
|
|
156
|
+
role: ChatMessage['role'];
|
|
157
|
+
content: string;
|
|
158
|
+
toolMeta?: Record<string, unknown> | null;
|
|
159
|
+
}>;
|
|
160
|
+
/** Toggle the settings panel open/closed */
|
|
161
|
+
toggleSettingsPanel: () => void;
|
|
162
|
+
/** Update chat settings (merges with existing) */
|
|
163
|
+
updateSettings: (patch: Partial<ChatSettings>) => void;
|
|
164
|
+
/** Truncate messages from a given message ID onwards (for edit+resend) */
|
|
165
|
+
truncateFrom: (messageId: string) => void;
|
|
166
|
+
/** Set or update the current plan */
|
|
167
|
+
setPlan: (plan: ChatPlan) => void;
|
|
168
|
+
/** Set follow-up suggestions (cleared on next user message) */
|
|
169
|
+
setSuggestions: (suggestions: Array<{ label: string; prompt: string }>) => void;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
type ChatStore = ChatState & ChatActions;
|
|
173
|
+
|
|
174
|
+
let messageIdCounter = 0;
|
|
175
|
+
function genId(): string {
|
|
176
|
+
return `msg_${Date.now()}_${++messageIdCounter}`;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function loadPersistedSettings(): ChatSettings {
|
|
180
|
+
try {
|
|
181
|
+
const raw = localStorage.getItem('invect-chat-settings');
|
|
182
|
+
if (raw) {
|
|
183
|
+
const parsed = JSON.parse(raw);
|
|
184
|
+
return { ...DEFAULT_CHAT_SETTINGS, ...parsed };
|
|
185
|
+
}
|
|
186
|
+
} catch {
|
|
187
|
+
// ignore
|
|
188
|
+
}
|
|
189
|
+
return DEFAULT_CHAT_SETTINGS;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const initialState: ChatState = {
|
|
193
|
+
isOpen: false,
|
|
194
|
+
activeFlowId: null,
|
|
195
|
+
messages: [],
|
|
196
|
+
isLoadingHistory: false,
|
|
197
|
+
isStreaming: false,
|
|
198
|
+
abortController: null,
|
|
199
|
+
streamingText: '',
|
|
200
|
+
error: null,
|
|
201
|
+
pendingPrompt: null,
|
|
202
|
+
_dirty: false,
|
|
203
|
+
isSettingsPanelOpen: false,
|
|
204
|
+
settings: loadPersistedSettings(),
|
|
205
|
+
currentPlan: null,
|
|
206
|
+
suggestions: [],
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
// =====================================
|
|
210
|
+
// Store
|
|
211
|
+
// =====================================
|
|
212
|
+
|
|
213
|
+
export const useChatStore = create<ChatStore>()(
|
|
214
|
+
devtools(
|
|
215
|
+
immer((set, get) => ({
|
|
216
|
+
...initialState,
|
|
217
|
+
|
|
218
|
+
togglePanel: () =>
|
|
219
|
+
set((s) => {
|
|
220
|
+
s.isOpen = !s.isOpen;
|
|
221
|
+
}),
|
|
222
|
+
|
|
223
|
+
setOpen: (open) =>
|
|
224
|
+
set((s) => {
|
|
225
|
+
s.isOpen = open;
|
|
226
|
+
}),
|
|
227
|
+
|
|
228
|
+
setActiveFlow: (flowId) =>
|
|
229
|
+
set((s) => {
|
|
230
|
+
if (s.activeFlowId === flowId) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
s.activeFlowId = flowId;
|
|
234
|
+
s.messages = [];
|
|
235
|
+
s.streamingText = '';
|
|
236
|
+
s.error = null;
|
|
237
|
+
s._dirty = false;
|
|
238
|
+
s.isLoadingHistory = false;
|
|
239
|
+
s.currentPlan = null;
|
|
240
|
+
}),
|
|
241
|
+
|
|
242
|
+
loadMessages: (messages) =>
|
|
243
|
+
set((s) => {
|
|
244
|
+
s.messages = messages;
|
|
245
|
+
s._dirty = false;
|
|
246
|
+
s.isLoadingHistory = false;
|
|
247
|
+
}),
|
|
248
|
+
|
|
249
|
+
setLoadingHistory: (loading) =>
|
|
250
|
+
set((s) => {
|
|
251
|
+
s.isLoadingHistory = loading;
|
|
252
|
+
}),
|
|
253
|
+
|
|
254
|
+
addUserMessage: (content) => {
|
|
255
|
+
const id = genId();
|
|
256
|
+
set((s) => {
|
|
257
|
+
s.messages.push({
|
|
258
|
+
id,
|
|
259
|
+
role: 'user',
|
|
260
|
+
content,
|
|
261
|
+
createdAt: Date.now(),
|
|
262
|
+
});
|
|
263
|
+
s.error = null;
|
|
264
|
+
s._dirty = true;
|
|
265
|
+
s.suggestions = [];
|
|
266
|
+
});
|
|
267
|
+
return id;
|
|
268
|
+
},
|
|
269
|
+
|
|
270
|
+
startStreaming: (controller) =>
|
|
271
|
+
set((s) => {
|
|
272
|
+
s.isStreaming = true;
|
|
273
|
+
s.abortController = controller as unknown as AbortController; // immer doesn't proxy AbortController
|
|
274
|
+
s.streamingText = '';
|
|
275
|
+
}),
|
|
276
|
+
|
|
277
|
+
appendStreamingText: (text) =>
|
|
278
|
+
set((s) => {
|
|
279
|
+
s.streamingText += text;
|
|
280
|
+
}),
|
|
281
|
+
|
|
282
|
+
addToolCallMessage: (toolName, toolCallId, args) =>
|
|
283
|
+
set((s) => {
|
|
284
|
+
// Commit any accumulated streaming text as a separate message BEFORE
|
|
285
|
+
// the tool call so that text and tool calls interleave chronologically.
|
|
286
|
+
if (s.streamingText.trim()) {
|
|
287
|
+
s.messages.push({
|
|
288
|
+
id: genId(),
|
|
289
|
+
role: 'assistant',
|
|
290
|
+
content: s.streamingText,
|
|
291
|
+
createdAt: Date.now(),
|
|
292
|
+
});
|
|
293
|
+
s.streamingText = '';
|
|
294
|
+
s._dirty = true;
|
|
295
|
+
}
|
|
296
|
+
s.messages.push({
|
|
297
|
+
id: genId(),
|
|
298
|
+
role: 'assistant',
|
|
299
|
+
content: '',
|
|
300
|
+
toolMeta: { toolName, args, status: 'pending', startedAt: Date.now() },
|
|
301
|
+
createdAt: Date.now(),
|
|
302
|
+
});
|
|
303
|
+
s._dirty = true;
|
|
304
|
+
}),
|
|
305
|
+
|
|
306
|
+
updateToolCallResult: (toolCallId, result) =>
|
|
307
|
+
set((s) => {
|
|
308
|
+
// Find the last tool call message with matching pending status
|
|
309
|
+
for (let i = s.messages.length - 1; i >= 0; i--) {
|
|
310
|
+
const msg = s.messages[i];
|
|
311
|
+
if (msg?.toolMeta && msg.toolMeta.status === 'pending') {
|
|
312
|
+
msg.toolMeta.result = result;
|
|
313
|
+
msg.toolMeta.status = result.success ? 'done' : 'error';
|
|
314
|
+
if (msg.toolMeta.startedAt) {
|
|
315
|
+
msg.toolMeta.durationMs = Date.now() - msg.toolMeta.startedAt;
|
|
316
|
+
}
|
|
317
|
+
s._dirty = true;
|
|
318
|
+
break;
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
}),
|
|
322
|
+
|
|
323
|
+
finalizeAssistantMessage: () =>
|
|
324
|
+
set((s) => {
|
|
325
|
+
if (s.streamingText.trim()) {
|
|
326
|
+
s.messages.push({
|
|
327
|
+
id: genId(),
|
|
328
|
+
role: 'assistant',
|
|
329
|
+
content: s.streamingText,
|
|
330
|
+
createdAt: Date.now(),
|
|
331
|
+
});
|
|
332
|
+
s._dirty = true;
|
|
333
|
+
}
|
|
334
|
+
s.streamingText = '';
|
|
335
|
+
s.isStreaming = false;
|
|
336
|
+
s.abortController = null;
|
|
337
|
+
}),
|
|
338
|
+
|
|
339
|
+
stopStreaming: () => {
|
|
340
|
+
const controller = get().abortController;
|
|
341
|
+
if (controller) {
|
|
342
|
+
try {
|
|
343
|
+
controller.abort();
|
|
344
|
+
} catch {
|
|
345
|
+
// ignore
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
set((s) => {
|
|
349
|
+
// Finalize any partial text
|
|
350
|
+
if (s.streamingText.trim()) {
|
|
351
|
+
s.messages.push({
|
|
352
|
+
id: genId(),
|
|
353
|
+
role: 'assistant',
|
|
354
|
+
content: s.streamingText,
|
|
355
|
+
createdAt: Date.now(),
|
|
356
|
+
});
|
|
357
|
+
s._dirty = true;
|
|
358
|
+
}
|
|
359
|
+
s.streamingText = '';
|
|
360
|
+
s.isStreaming = false;
|
|
361
|
+
s.abortController = null;
|
|
362
|
+
});
|
|
363
|
+
},
|
|
364
|
+
|
|
365
|
+
setError: (error) =>
|
|
366
|
+
set((s) => {
|
|
367
|
+
s.error = error;
|
|
368
|
+
s.isStreaming = false;
|
|
369
|
+
s.abortController = null;
|
|
370
|
+
}),
|
|
371
|
+
|
|
372
|
+
finalizePendingToolCalls: () =>
|
|
373
|
+
set((s) => {
|
|
374
|
+
for (const msg of s.messages) {
|
|
375
|
+
if (msg.toolMeta && msg.toolMeta.status === 'pending') {
|
|
376
|
+
msg.toolMeta.status = 'error';
|
|
377
|
+
msg.toolMeta.result = {
|
|
378
|
+
success: false,
|
|
379
|
+
error: 'Stream ended before tool completed',
|
|
380
|
+
};
|
|
381
|
+
s._dirty = true;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}),
|
|
385
|
+
|
|
386
|
+
setPendingPrompt: (prompt) =>
|
|
387
|
+
set((s) => {
|
|
388
|
+
s.pendingPrompt = prompt;
|
|
389
|
+
s.isOpen = true;
|
|
390
|
+
}),
|
|
391
|
+
|
|
392
|
+
consumePendingPrompt: () => {
|
|
393
|
+
const prompt = get().pendingPrompt;
|
|
394
|
+
if (prompt) {
|
|
395
|
+
set((s) => {
|
|
396
|
+
s.pendingPrompt = null;
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
return prompt;
|
|
400
|
+
},
|
|
401
|
+
|
|
402
|
+
clearMessages: () =>
|
|
403
|
+
set((s) => {
|
|
404
|
+
s.messages = [];
|
|
405
|
+
s.streamingText = '';
|
|
406
|
+
s.error = null;
|
|
407
|
+
s._dirty = true;
|
|
408
|
+
}),
|
|
409
|
+
|
|
410
|
+
markClean: () =>
|
|
411
|
+
set((s) => {
|
|
412
|
+
s._dirty = false;
|
|
413
|
+
}),
|
|
414
|
+
|
|
415
|
+
isDirty: () => get()._dirty,
|
|
416
|
+
|
|
417
|
+
getSerializableMessages: () => {
|
|
418
|
+
return get().messages.map((m) => ({
|
|
419
|
+
role: m.role,
|
|
420
|
+
content: m.content,
|
|
421
|
+
toolMeta: m.toolMeta ? (m.toolMeta as unknown as Record<string, unknown>) : null,
|
|
422
|
+
}));
|
|
423
|
+
},
|
|
424
|
+
|
|
425
|
+
toggleSettingsPanel: () =>
|
|
426
|
+
set((s) => {
|
|
427
|
+
s.isSettingsPanelOpen = !s.isSettingsPanelOpen;
|
|
428
|
+
}),
|
|
429
|
+
|
|
430
|
+
updateSettings: (patch) =>
|
|
431
|
+
set((s) => {
|
|
432
|
+
// Reset model when credential changes (different provider = different models)
|
|
433
|
+
if ('credentialId' in patch && patch.credentialId !== s.settings.credentialId) {
|
|
434
|
+
patch = { ...patch, model: null };
|
|
435
|
+
}
|
|
436
|
+
const next = { ...s.settings, ...patch };
|
|
437
|
+
s.settings = next;
|
|
438
|
+
// Persist to localStorage
|
|
439
|
+
try {
|
|
440
|
+
localStorage.setItem('invect-chat-settings', JSON.stringify(next));
|
|
441
|
+
} catch {
|
|
442
|
+
// ignore
|
|
443
|
+
}
|
|
444
|
+
}),
|
|
445
|
+
|
|
446
|
+
truncateFrom: (messageId) =>
|
|
447
|
+
set((s) => {
|
|
448
|
+
const idx = s.messages.findIndex((m) => m.id === messageId);
|
|
449
|
+
if (idx !== -1) {
|
|
450
|
+
s.messages = s.messages.slice(0, idx);
|
|
451
|
+
s._dirty = true;
|
|
452
|
+
}
|
|
453
|
+
}),
|
|
454
|
+
|
|
455
|
+
setPlan: (plan) =>
|
|
456
|
+
set((s) => {
|
|
457
|
+
s.currentPlan = plan;
|
|
458
|
+
}),
|
|
459
|
+
|
|
460
|
+
setSuggestions: (suggestions) =>
|
|
461
|
+
set((s) => {
|
|
462
|
+
s.suggestions = suggestions;
|
|
463
|
+
}),
|
|
464
|
+
})),
|
|
465
|
+
{ name: 'chat' },
|
|
466
|
+
),
|
|
467
|
+
);
|
|
468
|
+
|
|
469
|
+
// Selector hooks
|
|
470
|
+
export const useChatOpen = () => useChatStore((s) => s.isOpen);
|
|
471
|
+
const _useChatMessages = () => useChatStore((s) => s.messages);
|
|
472
|
+
const _useChatStreaming = () => useChatStore((s) => s.isStreaming);
|
|
473
|
+
const _useChatStreamingText = () => useChatStore((s) => s.streamingText);
|
|
474
|
+
const _useChatError = () => useChatStore((s) => s.error);
|
|
475
|
+
const _useChatPendingPrompt = () => useChatStore((s) => s.pendingPrompt);
|
|
476
|
+
const _useChatSettingsPanelOpen = () => useChatStore((s) => s.isSettingsPanelOpen);
|
|
477
|
+
const _useChatPlan = () => useChatStore((s) => s.currentPlan);
|
|
478
|
+
const _useChatSuggestions = () => useChatStore((s) => s.suggestions);
|
|
479
|
+
const _useChatSettings = () => useChatStore((s) => s.settings);
|