@datalayer/agent-runtimes 0.0.2
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 +32 -0
- package/README.md +56 -0
- package/lib/App.css +47 -0
- package/lib/App.d.ts +3 -0
- package/lib/App.js +18 -0
- package/lib/components/chat/components/AgentDetails.d.ts +19 -0
- package/lib/components/chat/components/AgentDetails.js +170 -0
- package/lib/components/chat/components/Chat.d.ts +105 -0
- package/lib/components/chat/components/Chat.js +275 -0
- package/lib/components/chat/components/ChatFloating.d.ts +146 -0
- package/lib/components/chat/components/ChatFloating.js +381 -0
- package/lib/components/chat/components/ChatInline.d.ts +42 -0
- package/lib/components/chat/components/ChatInline.js +327 -0
- package/lib/components/chat/components/ChatPopupStandalone.d.ts +110 -0
- package/lib/components/chat/components/ChatPopupStandalone.js +422 -0
- package/lib/components/chat/components/ChatSidebar.d.ts +78 -0
- package/lib/components/chat/components/ChatSidebar.js +224 -0
- package/lib/components/chat/components/ChatStandalone.d.ts +105 -0
- package/lib/components/chat/components/ChatStandalone.js +320 -0
- package/lib/components/chat/components/base/ChatBase.d.ts +285 -0
- package/lib/components/chat/components/base/ChatBase.js +1192 -0
- package/lib/components/chat/components/display/ToolCallDisplay.d.ts +26 -0
- package/lib/components/chat/components/display/ToolCallDisplay.js +225 -0
- package/lib/components/chat/components/display/index.d.ts +6 -0
- package/lib/components/chat/components/display/index.js +10 -0
- package/lib/components/chat/components/elements/ChatHeader.d.ts +43 -0
- package/lib/components/chat/components/elements/ChatHeader.js +67 -0
- package/lib/components/chat/components/elements/ChatInputPrompt.d.ts +26 -0
- package/lib/components/chat/components/elements/ChatInputPrompt.js +145 -0
- package/lib/components/chat/components/elements/ChatMessages.d.ts +36 -0
- package/lib/components/chat/components/elements/ChatMessages.js +195 -0
- package/lib/components/chat/components/elements/FloatingBrandButton.d.ts +34 -0
- package/lib/components/chat/components/elements/FloatingBrandButton.js +88 -0
- package/lib/components/chat/components/elements/MessagePart.d.ts +50 -0
- package/lib/components/chat/components/elements/MessagePart.js +48 -0
- package/lib/components/chat/components/elements/PoweredByTag.d.ts +26 -0
- package/lib/components/chat/components/elements/PoweredByTag.js +33 -0
- package/lib/components/chat/components/elements/ToolApprovalDialog.d.ts +42 -0
- package/lib/components/chat/components/elements/ToolApprovalDialog.js +96 -0
- package/lib/components/chat/components/index.d.ts +21 -0
- package/lib/components/chat/components/index.js +34 -0
- package/lib/components/chat/components/parts/DynamicToolPart.d.ts +20 -0
- package/lib/components/chat/components/parts/DynamicToolPart.js +13 -0
- package/lib/components/chat/components/parts/ReasoningPart.d.ts +17 -0
- package/lib/components/chat/components/parts/ReasoningPart.js +69 -0
- package/lib/components/chat/components/parts/TextPart.d.ts +28 -0
- package/lib/components/chat/components/parts/TextPart.js +103 -0
- package/lib/components/chat/components/parts/ToolPart.d.ts +17 -0
- package/lib/components/chat/components/parts/ToolPart.js +163 -0
- package/lib/components/chat/components/parts/index.d.ts +9 -0
- package/lib/components/chat/components/parts/index.js +13 -0
- package/lib/components/chat/extensions/A2UIExtension.d.ts +87 -0
- package/lib/components/chat/extensions/A2UIExtension.js +312 -0
- package/lib/components/chat/extensions/ExtensionRegistry.d.ts +66 -0
- package/lib/components/chat/extensions/ExtensionRegistry.js +128 -0
- package/lib/components/chat/extensions/MCPUIExtension.d.ts +77 -0
- package/lib/components/chat/extensions/MCPUIExtension.js +212 -0
- package/lib/components/chat/extensions/index.d.ts +9 -0
- package/lib/components/chat/extensions/index.js +12 -0
- package/lib/components/chat/handler.d.ts +20 -0
- package/lib/components/chat/handler.js +56 -0
- package/lib/components/chat/index.d.ts +61 -0
- package/lib/components/chat/index.js +76 -0
- package/lib/components/chat/inference/BaseInferenceProvider.d.ts +57 -0
- package/lib/components/chat/inference/BaseInferenceProvider.js +69 -0
- package/lib/components/chat/inference/DatalayerInferenceProvider.d.ts +83 -0
- package/lib/components/chat/inference/DatalayerInferenceProvider.js +305 -0
- package/lib/components/chat/inference/SelfHostedInferenceProvider.d.ts +54 -0
- package/lib/components/chat/inference/SelfHostedInferenceProvider.js +246 -0
- package/lib/components/chat/inference/index.d.ts +9 -0
- package/lib/components/chat/inference/index.js +12 -0
- package/lib/components/chat/middleware/MiddlewarePipeline.d.ts +118 -0
- package/lib/components/chat/middleware/MiddlewarePipeline.js +255 -0
- package/lib/components/chat/middleware/index.d.ts +7 -0
- package/lib/components/chat/middleware/index.js +10 -0
- package/lib/components/chat/protocols/A2AAdapter.d.ts +79 -0
- package/lib/components/chat/protocols/A2AAdapter.js +388 -0
- package/lib/components/chat/protocols/ACPAdapter.d.ts +161 -0
- package/lib/components/chat/protocols/ACPAdapter.js +504 -0
- package/lib/components/chat/protocols/AGUIAdapter.d.ts +82 -0
- package/lib/components/chat/protocols/AGUIAdapter.js +518 -0
- package/lib/components/chat/protocols/BaseProtocolAdapter.d.ts +75 -0
- package/lib/components/chat/protocols/BaseProtocolAdapter.js +119 -0
- package/lib/components/chat/protocols/VercelAIAdapter.d.ts +77 -0
- package/lib/components/chat/protocols/VercelAIAdapter.js +252 -0
- package/lib/components/chat/protocols/index.d.ts +11 -0
- package/lib/components/chat/protocols/index.js +14 -0
- package/lib/components/chat/store/chatStore.d.ts +158 -0
- package/lib/components/chat/store/chatStore.js +313 -0
- package/lib/components/chat/store/index.d.ts +6 -0
- package/lib/components/chat/store/index.js +10 -0
- package/lib/components/chat/tools/ToolExecutor.d.ts +49 -0
- package/lib/components/chat/tools/ToolExecutor.js +151 -0
- package/lib/components/chat/tools/index.d.ts +8 -0
- package/lib/components/chat/tools/index.js +11 -0
- package/lib/components/chat/types/extension.d.ts +181 -0
- package/lib/components/chat/types/extension.js +46 -0
- package/lib/components/chat/types/index.d.ts +11 -0
- package/lib/components/chat/types/index.js +16 -0
- package/lib/components/chat/types/inference.d.ts +117 -0
- package/lib/components/chat/types/inference.js +5 -0
- package/lib/components/chat/types/message.d.ts +117 -0
- package/lib/components/chat/types/message.js +50 -0
- package/lib/components/chat/types/middleware.d.ts +153 -0
- package/lib/components/chat/types/middleware.js +32 -0
- package/lib/components/chat/types/protocol.d.ts +209 -0
- package/lib/components/chat/types/protocol.js +5 -0
- package/lib/components/chat/types/tool.d.ts +140 -0
- package/lib/components/chat/types/tool.js +23 -0
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +6 -0
- package/lib/components/sparklines/Sparklines.d.ts +16 -0
- package/lib/components/sparklines/Sparklines.js +65 -0
- package/lib/components/sparklines/SparklinesLine.d.ts +8 -0
- package/lib/components/sparklines/SparklinesLine.js +37 -0
- package/lib/components/sparklines/dataProcessing.d.ts +25 -0
- package/lib/components/sparklines/dataProcessing.js +35 -0
- package/lib/components/sparklines/index.d.ts +4 -0
- package/lib/components/sparklines/index.js +7 -0
- package/lib/components/sparklines/types.d.ts +36 -0
- package/lib/components/sparklines/types.js +5 -0
- package/lib/components/ui/accordion.d.ts +7 -0
- package/lib/components/ui/accordion.js +22 -0
- package/lib/components/ui/alert-dialog.d.ts +14 -0
- package/lib/components/ui/alert-dialog.js +43 -0
- package/lib/components/ui/alert.d.ts +9 -0
- package/lib/components/ui/alert.js +24 -0
- package/lib/components/ui/aspect-ratio.d.ts +3 -0
- package/lib/components/ui/aspect-ratio.js +11 -0
- package/lib/components/ui/avatar.d.ts +6 -0
- package/lib/components/ui/avatar.js +18 -0
- package/lib/components/ui/badge.d.ts +9 -0
- package/lib/components/ui/badge.js +22 -0
- package/lib/components/ui/breadcrumb.d.ts +11 -0
- package/lib/components/ui/breadcrumb.js +27 -0
- package/lib/components/ui/button-group.d.ts +11 -0
- package/lib/components/ui/button-group.js +31 -0
- package/lib/components/ui/button.d.ts +13 -0
- package/lib/components/ui/button.js +39 -0
- package/lib/components/ui/calendar.d.ts +8 -0
- package/lib/components/ui/calendar.js +80 -0
- package/lib/components/ui/card.d.ts +9 -0
- package/lib/components/ui/card.js +24 -0
- package/lib/components/ui/carousel.d.ts +19 -0
- package/lib/components/ui/carousel.js +95 -0
- package/lib/components/ui/chart.d.ts +53 -0
- package/lib/components/ui/chart.js +136 -0
- package/lib/components/ui/checkbox.d.ts +4 -0
- package/lib/components/ui/checkbox.js +13 -0
- package/lib/components/ui/collapsible.d.ts +5 -0
- package/lib/components/ui/collapsible.js +17 -0
- package/lib/components/ui/command.d.ts +18 -0
- package/lib/components/ui/command.js +38 -0
- package/lib/components/ui/context-menu.d.ts +25 -0
- package/lib/components/ui/context-menu.js +55 -0
- package/lib/components/ui/dialog.d.ts +15 -0
- package/lib/components/ui/dialog.js +40 -0
- package/lib/components/ui/drawer.d.ts +13 -0
- package/lib/components/ui/drawer.js +39 -0
- package/lib/components/ui/dropdown-menu.d.ts +25 -0
- package/lib/components/ui/dropdown-menu.js +55 -0
- package/lib/components/ui/empty.d.ts +11 -0
- package/lib/components/ui/empty.js +37 -0
- package/lib/components/ui/field.d.ts +24 -0
- package/lib/components/ui/field.js +80 -0
- package/lib/components/ui/form.d.ts +24 -0
- package/lib/components/ui/form.js +63 -0
- package/lib/components/ui/hover-card.d.ts +6 -0
- package/lib/components/ui/hover-card.js +18 -0
- package/lib/components/ui/input-group.d.ts +19 -0
- package/lib/components/ui/input-group.js +69 -0
- package/lib/components/ui/input-otp.d.ts +11 -0
- package/lib/components/ui/input-otp.js +25 -0
- package/lib/components/ui/input.d.ts +3 -0
- package/lib/components/ui/input.js +6 -0
- package/lib/components/ui/item.d.ts +23 -0
- package/lib/components/ui/item.js +66 -0
- package/lib/components/ui/kbd.d.ts +3 -0
- package/lib/components/ui/kbd.js +13 -0
- package/lib/components/ui/label.d.ts +4 -0
- package/lib/components/ui/label.js +12 -0
- package/lib/components/ui/menubar.d.ts +26 -0
- package/lib/components/ui/menubar.js +58 -0
- package/lib/components/ui/navigation-menu.d.ts +14 -0
- package/lib/components/ui/navigation-menu.js +31 -0
- package/lib/components/ui/pagination.d.ts +13 -0
- package/lib/components/ui/pagination.js +29 -0
- package/lib/components/ui/popover.d.ts +7 -0
- package/lib/components/ui/popover.js +21 -0
- package/lib/components/ui/progress.d.ts +4 -0
- package/lib/components/ui/progress.js +12 -0
- package/lib/components/ui/radio-group.d.ts +5 -0
- package/lib/components/ui/radio-group.js +16 -0
- package/lib/components/ui/resizable.d.ts +8 -0
- package/lib/components/ui/resizable.js +19 -0
- package/lib/components/ui/scroll-area.d.ts +5 -0
- package/lib/components/ui/scroll-area.js +17 -0
- package/lib/components/ui/select.d.ts +15 -0
- package/lib/components/ui/select.js +42 -0
- package/lib/components/ui/separator.d.ts +4 -0
- package/lib/components/ui/separator.js +12 -0
- package/lib/components/ui/sheet.d.ts +13 -0
- package/lib/components/ui/sheet.js +44 -0
- package/lib/components/ui/sidebar.d.ts +69 -0
- package/lib/components/ui/sidebar.js +216 -0
- package/lib/components/ui/skeleton.d.ts +2 -0
- package/lib/components/ui/skeleton.js +10 -0
- package/lib/components/ui/slider.d.ts +4 -0
- package/lib/components/ui/slider.js +18 -0
- package/lib/components/ui/sonner.d.ts +3 -0
- package/lib/components/ui/sonner.js +25 -0
- package/lib/components/ui/spinner.d.ts +2 -0
- package/lib/components/ui/spinner.js +11 -0
- package/lib/components/ui/switch.d.ts +4 -0
- package/lib/components/ui/switch.js +12 -0
- package/lib/components/ui/table.d.ts +10 -0
- package/lib/components/ui/table.js +32 -0
- package/lib/components/ui/tabs.d.ts +7 -0
- package/lib/components/ui/tabs.js +21 -0
- package/lib/components/ui/textarea.d.ts +3 -0
- package/lib/components/ui/textarea.js +6 -0
- package/lib/components/ui/toast.d.ts +15 -0
- package/lib/components/ui/toast.js +38 -0
- package/lib/components/ui/toaster.d.ts +1 -0
- package/lib/components/ui/toaster.js +14 -0
- package/lib/components/ui/toggle-group.d.ts +9 -0
- package/lib/components/ui/toggle-group.js +26 -0
- package/lib/components/ui/toggle.d.ts +9 -0
- package/lib/components/ui/toggle.js +30 -0
- package/lib/components/ui/tooltip.d.ts +7 -0
- package/lib/components/ui/tooltip.js +21 -0
- package/lib/components/vercel-ai-elements/artifact.d.ts +23 -0
- package/lib/components/vercel-ai-elements/artifact.js +24 -0
- package/lib/components/vercel-ai-elements/code-block.d.ts +17 -0
- package/lib/components/vercel-ai-elements/code-block.js +94 -0
- package/lib/components/vercel-ai-elements/conversation.d.ts +15 -0
- package/lib/components/vercel-ai-elements/conversation.js +21 -0
- package/lib/components/vercel-ai-elements/loader.d.ts +5 -0
- package/lib/components/vercel-ai-elements/loader.js +8 -0
- package/lib/components/vercel-ai-elements/message.d.ts +46 -0
- package/lib/components/vercel-ai-elements/message.js +109 -0
- package/lib/components/vercel-ai-elements/model-selector.d.ts +35 -0
- package/lib/components/vercel-ai-elements/model-selector.js +22 -0
- package/lib/components/vercel-ai-elements/prompt-input.d.ts +195 -0
- package/lib/components/vercel-ai-elements/prompt-input.js +589 -0
- package/lib/components/vercel-ai-elements/reasoning.d.ts +26 -0
- package/lib/components/vercel-ai-elements/reasoning.js +80 -0
- package/lib/components/vercel-ai-elements/shimmer.d.ts +9 -0
- package/lib/components/vercel-ai-elements/shimmer.js +22 -0
- package/lib/components/vercel-ai-elements/sources.d.ts +12 -0
- package/lib/components/vercel-ai-elements/sources.js +13 -0
- package/lib/components/vercel-ai-elements/suggestion.d.ts +10 -0
- package/lib/components/vercel-ai-elements/suggestion.js +16 -0
- package/lib/components/vercel-ai-elements/tool.d.ts +23 -0
- package/lib/components/vercel-ai-elements/tool.js +52 -0
- package/lib/examples/A2UiRestaurantExample.d.ts +25 -0
- package/lib/examples/A2UiRestaurantExample.js +305 -0
- package/lib/examples/AgUiAgenticExample.d.ts +25 -0
- package/lib/examples/AgUiAgenticExample.js +63 -0
- package/lib/examples/AgUiBackendToolRenderingExample.d.ts +30 -0
- package/lib/examples/AgUiBackendToolRenderingExample.js +103 -0
- package/lib/examples/AgUiHaikuGenUIExample.d.ts +44 -0
- package/lib/examples/AgUiHaikuGenUIExample.js +151 -0
- package/lib/examples/AgUiHumanInTheLoopExample.d.ts +26 -0
- package/lib/examples/AgUiHumanInTheLoopExample.js +220 -0
- package/lib/examples/AgUiSharedStateExample.d.ts +25 -0
- package/lib/examples/AgUiSharedStateExample.js +181 -0
- package/lib/examples/AgUiToolsBasedGenUIExample.d.ts +25 -0
- package/lib/examples/AgUiToolsBasedGenUIExample.js +257 -0
- package/lib/examples/AgentRuntimeCustomExample.d.ts +9 -0
- package/lib/examples/AgentRuntimeCustomExample.js +68 -0
- package/lib/examples/AgentRuntimeLexical2Example.d.ts +42 -0
- package/lib/examples/AgentRuntimeLexical2Example.js +236 -0
- package/lib/examples/AgentRuntimeLexicalExample.d.ts +36 -0
- package/lib/examples/AgentRuntimeLexicalExample.js +260 -0
- package/lib/examples/AgentRuntimeLexicalSidebarExample.d.ts +41 -0
- package/lib/examples/AgentRuntimeLexicalSidebarExample.js +166 -0
- package/lib/examples/AgentRuntimeNotebookExample.d.ts +9 -0
- package/lib/examples/AgentRuntimeNotebookExample.js +148 -0
- package/lib/examples/AgentRuntimeNotebookSidebarExample.d.ts +13 -0
- package/lib/examples/AgentRuntimeNotebookSidebarExample.js +121 -0
- package/lib/examples/AgentRuntimeStandaloneExample.d.ts +21 -0
- package/lib/examples/AgentRuntimeStandaloneExample.js +158 -0
- package/lib/examples/AgentSpaceFormExample.d.ts +22 -0
- package/lib/examples/AgentSpaceFormExample.js +296 -0
- package/lib/examples/AgentSpaceHomeExample.d.ts +8 -0
- package/lib/examples/AgentSpaceHomeExample.js +171 -0
- package/lib/examples/CopilotKitLexicalExample.d.ts +38 -0
- package/lib/examples/CopilotKitLexicalExample.js +161 -0
- package/lib/examples/CopilotKitNotebookExample.d.ts +11 -0
- package/lib/examples/CopilotKitNotebookExample.js +70 -0
- package/lib/examples/DatalayerNotebookExample.d.ts +16 -0
- package/lib/examples/DatalayerNotebookExample.js +99 -0
- package/lib/examples/JupyterCellExample.d.ts +6 -0
- package/lib/examples/JupyterCellExample.js +19 -0
- package/lib/examples/JupyterNotebookExample.d.ts +6 -0
- package/lib/examples/JupyterNotebookExample.js +21 -0
- package/lib/examples/ag-ui/haiku/HaikuDisplay.d.ts +18 -0
- package/lib/examples/ag-ui/haiku/HaikuDisplay.js +110 -0
- package/lib/examples/ag-ui/haiku/InlineHaikuCard.d.ts +39 -0
- package/lib/examples/ag-ui/haiku/InlineHaikuCard.js +117 -0
- package/lib/examples/ag-ui/haiku/index.d.ts +11 -0
- package/lib/examples/ag-ui/haiku/index.js +15 -0
- package/lib/examples/ag-ui/index.d.ts +10 -0
- package/lib/examples/ag-ui/index.js +16 -0
- package/lib/examples/ag-ui/weather/InlineWeatherCard.d.ts +43 -0
- package/lib/examples/ag-ui/weather/InlineWeatherCard.js +180 -0
- package/lib/examples/ag-ui/weather/index.d.ts +9 -0
- package/lib/examples/ag-ui/weather/index.js +13 -0
- package/lib/examples/components/AgentConfiguration.d.ts +50 -0
- package/lib/examples/components/AgentConfiguration.js +115 -0
- package/lib/examples/components/AgentsDataTable.d.ts +13 -0
- package/lib/examples/components/AgentsDataTable.js +74 -0
- package/lib/examples/components/FooterMetrics.d.ts +12 -0
- package/lib/examples/components/FooterMetrics.js +17 -0
- package/lib/examples/components/Header.d.ts +27 -0
- package/lib/examples/components/Header.js +294 -0
- package/lib/examples/components/HeaderControls.d.ts +11 -0
- package/lib/examples/components/HeaderControls.js +24 -0
- package/lib/examples/components/LexicalEditor.d.ts +27 -0
- package/lib/examples/components/LexicalEditor.js +118 -0
- package/lib/examples/components/MainContent.d.ts +19 -0
- package/lib/examples/components/MainContent.js +68 -0
- package/lib/examples/components/MockFileBrowser.d.ts +12 -0
- package/lib/examples/components/MockFileBrowser.js +131 -0
- package/lib/examples/components/Rating.d.ts +14 -0
- package/lib/examples/components/Rating.js +12 -0
- package/lib/examples/components/SessionTabs.d.ts +21 -0
- package/lib/examples/components/SessionTabs.js +11 -0
- package/lib/examples/components/TimeTravel.d.ts +15 -0
- package/lib/examples/components/TimeTravel.js +23 -0
- package/lib/examples/components/index.d.ts +11 -0
- package/lib/examples/components/index.js +14 -0
- package/lib/examples/example-selector.d.ts +22 -0
- package/lib/examples/example-selector.js +62 -0
- package/lib/examples/index.d.ts +21 -0
- package/lib/examples/index.js +25 -0
- package/lib/examples/lexical/editorConfig.d.ts +76 -0
- package/lib/examples/lexical/editorConfig.js +55 -0
- package/lib/examples/lexical/lexical-theme.css +436 -0
- package/lib/examples/lexical/theme.d.ts +61 -0
- package/lib/examples/lexical/theme.js +72 -0
- package/lib/examples/main.d.ts +2 -0
- package/lib/examples/main.js +334 -0
- package/lib/examples/stores/agents/earthquake-detector.ipynb.json +111 -0
- package/lib/examples/stores/agents/earthquake-detector.json +13 -0
- package/lib/examples/stores/agents/earthquake-detector.lexical.json +2988 -0
- package/lib/examples/stores/agents/sales-forecaster.ipynb.json +111 -0
- package/lib/examples/stores/agents/sales-forecaster.json +13 -0
- package/lib/examples/stores/agents/sales-forecaster.lexical.json +2988 -0
- package/lib/examples/stores/agents/social-post-generator.ipynb.json +111 -0
- package/lib/examples/stores/agents/social-post-generator.json +13 -0
- package/lib/examples/stores/agents/social-post-generator.lexical.json +2988 -0
- package/lib/examples/stores/agents/stock-market.ipynb.json +56 -0
- package/lib/examples/stores/agents/stock-market.json +13 -0
- package/lib/examples/stores/agents/stock-market.lexical.json +1026 -0
- package/lib/examples/stores/examplesStore.d.ts +26 -0
- package/lib/examples/stores/examplesStore.js +60 -0
- package/lib/examples/stores/notebooks/Empty.ipynb.json +33 -0
- package/lib/examples/stores/notebooks/IPyWidgetsExample.ipynb.json +101 -0
- package/lib/examples/stores/notebooks/IPyWidgetsExampleWithState.ipynb.json +112 -0
- package/lib/examples/stores/notebooks/Lite.ipynb.json +128 -0
- package/lib/examples/stores/notebooks/Matplotlib.ipynb.json +137 -0
- package/lib/examples/stores/notebooks/NotebookExample1.ipynb.json +126 -0
- package/lib/examples/stores/notebooks/NotebookExample2.ipynb.json +48 -0
- package/lib/examples/stores/notebooks/NotebookOutputs.ipynb.json +49 -0
- package/lib/examples/stores/notebooks/NotebookToCExample.ipynb.json +102 -0
- package/lib/examples/stores/notebooks/OutputIPyWidgetsExample.d.ts +145 -0
- package/lib/examples/stores/notebooks/OutputIPyWidgetsExample.js +153 -0
- package/lib/examples/stores/notebooks/PyGWalker.ipynb.json +55 -0
- package/lib/examples/vercel-ai-elements/VercelAiElementsShowcase.d.ts +12 -0
- package/lib/examples/vercel-ai-elements/VercelAiElementsShowcase.js +69 -0
- package/lib/examples/vercel-ai-elements/components/ArtifactShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/ArtifactShowcase.js +85 -0
- package/lib/examples/vercel-ai-elements/components/CodeBlockShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/CodeBlockShowcase.js +62 -0
- package/lib/examples/vercel-ai-elements/components/ConversationShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/ConversationShowcase.js +51 -0
- package/lib/examples/vercel-ai-elements/components/LoaderShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/LoaderShowcase.js +9 -0
- package/lib/examples/vercel-ai-elements/components/MessageShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/MessageShowcase.js +56 -0
- package/lib/examples/vercel-ai-elements/components/ModelSelectorShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/ModelSelectorShowcase.js +50 -0
- package/lib/examples/vercel-ai-elements/components/PromptInputShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/PromptInputShowcase.js +16 -0
- package/lib/examples/vercel-ai-elements/components/ReasoningShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/ReasoningShowcase.js +72 -0
- package/lib/examples/vercel-ai-elements/components/ShimmerShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/ShimmerShowcase.js +9 -0
- package/lib/examples/vercel-ai-elements/components/SourcesShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/SourcesShowcase.js +43 -0
- package/lib/examples/vercel-ai-elements/components/SuggestionShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/SuggestionShowcase.js +31 -0
- package/lib/examples/vercel-ai-elements/components/ToolShowcase.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/components/ToolShowcase.js +54 -0
- package/lib/examples/vercel-ai-elements/index.d.ts +13 -0
- package/lib/examples/vercel-ai-elements/index.js +17 -0
- package/lib/examples/vercel-ai-elements/main.d.ts +1 -0
- package/lib/examples/vercel-ai-elements/main.js +9 -0
- package/lib/examples/vercel-ai-elements/showcase.css +128 -0
- package/lib/hooks/index.d.ts +68 -0
- package/lib/hooks/index.js +81 -0
- package/lib/hooks/useA2A.d.ts +75 -0
- package/lib/hooks/useA2A.js +368 -0
- package/lib/hooks/useAGUI.d.ts +63 -0
- package/lib/hooks/useAGUI.js +162 -0
- package/lib/hooks/useAcp.d.ts +121 -0
- package/lib/hooks/useAcp.js +459 -0
- package/lib/hooks/useAgents.d.ts +13 -0
- package/lib/hooks/useAgents.js +71 -0
- package/lib/hooks/useChat.d.ts +62 -0
- package/lib/hooks/useChat.js +363 -0
- package/lib/hooks/useKeyboardShortcuts.d.ts +47 -0
- package/lib/hooks/useKeyboardShortcuts.js +153 -0
- package/lib/hooks/useMobile.d.ts +1 -0
- package/lib/hooks/useMobile.js +19 -0
- package/lib/hooks/useNotebookAIAgent.d.ts +8 -0
- package/lib/hooks/useNotebookAIAgent.js +56 -0
- package/lib/hooks/useToast.d.ts +44 -0
- package/lib/hooks/useToast.js +128 -0
- package/lib/hooks/useTools.d.ts +107 -0
- package/lib/hooks/useTools.js +130 -0
- package/lib/hooks/useVercelChat.d.ts +45 -0
- package/lib/hooks/useVercelChat.js +62 -0
- package/lib/index.css +73 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +5 -0
- package/lib/lexical/ChatInlinePlugin.d.ts +21 -0
- package/lib/lexical/ChatInlinePlugin.js +379 -0
- package/lib/lexical/index.d.ts +6 -0
- package/lib/lexical/index.js +10 -0
- package/lib/lib/utils.d.ts +2 -0
- package/lib/lib/utils.js +9 -0
- package/lib/main.d.ts +1 -0
- package/lib/main.js +12 -0
- package/lib/models/AIAgent.d.ts +17 -0
- package/lib/models/AIAgent.js +5 -0
- package/lib/models/index.d.ts +1 -0
- package/lib/models/index.js +5 -0
- package/lib/renderers/a2ui/components/A2UIRenderer.d.ts +7 -0
- package/lib/renderers/a2ui/components/A2UIRenderer.js +102 -0
- package/lib/renderers/a2ui/components/SurfaceRenderer.d.ts +7 -0
- package/lib/renderers/a2ui/components/SurfaceRenderer.js +101 -0
- package/lib/renderers/a2ui/components/content/AudioPlayer.d.ts +9 -0
- package/lib/renderers/a2ui/components/content/AudioPlayer.js +38 -0
- package/lib/renderers/a2ui/components/content/Divider.d.ts +9 -0
- package/lib/renderers/a2ui/components/content/Divider.js +35 -0
- package/lib/renderers/a2ui/components/content/Icon.d.ts +9 -0
- package/lib/renderers/a2ui/components/content/Icon.js +110 -0
- package/lib/renderers/a2ui/components/content/Image.d.ts +9 -0
- package/lib/renderers/a2ui/components/content/Image.js +61 -0
- package/lib/renderers/a2ui/components/content/Text.d.ts +9 -0
- package/lib/renderers/a2ui/components/content/Text.js +64 -0
- package/lib/renderers/a2ui/components/content/Video.d.ts +9 -0
- package/lib/renderers/a2ui/components/content/Video.js +37 -0
- package/lib/renderers/a2ui/components/content/index.d.ts +6 -0
- package/lib/renderers/a2ui/components/content/index.js +25 -0
- package/lib/renderers/a2ui/components/index.d.ts +5 -0
- package/lib/renderers/a2ui/components/index.js +24 -0
- package/lib/renderers/a2ui/components/interactive/Button.d.ts +11 -0
- package/lib/renderers/a2ui/components/interactive/Button.js +71 -0
- package/lib/renderers/a2ui/components/interactive/CheckBox.d.ts +9 -0
- package/lib/renderers/a2ui/components/interactive/CheckBox.js +48 -0
- package/lib/renderers/a2ui/components/interactive/DateTimeInput.d.ts +9 -0
- package/lib/renderers/a2ui/components/interactive/DateTimeInput.js +62 -0
- package/lib/renderers/a2ui/components/interactive/MultipleChoice.d.ts +9 -0
- package/lib/renderers/a2ui/components/interactive/MultipleChoice.js +73 -0
- package/lib/renderers/a2ui/components/interactive/Slider.d.ts +9 -0
- package/lib/renderers/a2ui/components/interactive/Slider.js +53 -0
- package/lib/renderers/a2ui/components/interactive/TextField.d.ts +9 -0
- package/lib/renderers/a2ui/components/interactive/TextField.js +72 -0
- package/lib/renderers/a2ui/components/interactive/index.d.ts +6 -0
- package/lib/renderers/a2ui/components/interactive/index.js +25 -0
- package/lib/renderers/a2ui/components/layout/Card.d.ts +11 -0
- package/lib/renderers/a2ui/components/layout/Card.js +30 -0
- package/lib/renderers/a2ui/components/layout/Column.d.ts +11 -0
- package/lib/renderers/a2ui/components/layout/Column.js +65 -0
- package/lib/renderers/a2ui/components/layout/List.d.ts +11 -0
- package/lib/renderers/a2ui/components/layout/List.js +55 -0
- package/lib/renderers/a2ui/components/layout/Modal.d.ts +11 -0
- package/lib/renderers/a2ui/components/layout/Modal.js +58 -0
- package/lib/renderers/a2ui/components/layout/Row.d.ts +11 -0
- package/lib/renderers/a2ui/components/layout/Row.js +65 -0
- package/lib/renderers/a2ui/components/layout/Tabs.d.ts +11 -0
- package/lib/renderers/a2ui/components/layout/Tabs.js +48 -0
- package/lib/renderers/a2ui/components/layout/index.d.ts +6 -0
- package/lib/renderers/a2ui/components/layout/index.js +25 -0
- package/lib/renderers/a2ui/context/A2UIContext.d.ts +17 -0
- package/lib/renderers/a2ui/context/A2UIContext.js +54 -0
- package/lib/renderers/a2ui/context/ThemeContext.d.ts +20 -0
- package/lib/renderers/a2ui/context/ThemeContext.js +333 -0
- package/lib/renderers/a2ui/hooks/useA2UI.d.ts +36 -0
- package/lib/renderers/a2ui/hooks/useA2UI.js +62 -0
- package/lib/renderers/a2ui/hooks/useDataBinding.d.ts +8 -0
- package/lib/renderers/a2ui/hooks/useDataBinding.js +83 -0
- package/lib/renderers/a2ui/index.d.ts +9 -0
- package/lib/renderers/a2ui/index.js +28 -0
- package/lib/renderers/a2ui/lib/utils.d.ts +11 -0
- package/lib/renderers/a2ui/lib/utils.js +38 -0
- package/lib/renderers/a2ui/types/index.d.ts +17 -0
- package/lib/renderers/a2ui/types/index.js +5 -0
- package/lib/renderers/index.d.ts +1 -0
- package/lib/renderers/index.js +5 -0
- package/lib/state/index.d.ts +1 -0
- package/lib/state/index.js +5 -0
- package/lib/state/substates/AIAgentState.d.ts +11 -0
- package/lib/state/substates/AIAgentState.js +42 -0
- package/lib/state/substates/index.d.ts +1 -0
- package/lib/state/substates/index.js +5 -0
- package/lib/stories/Button.d.ts +15 -0
- package/lib/stories/Button.js +13 -0
- package/lib/stories/Button.stories.d.ts +23 -0
- package/lib/stories/Button.stories.js +48 -0
- package/lib/stories/Cell.stories.d.ts +12 -0
- package/lib/stories/Cell.stories.js +123 -0
- package/lib/stories/Header.d.ts +12 -0
- package/lib/stories/Header.js +8 -0
- package/lib/stories/Header.stories.d.ts +18 -0
- package/lib/stories/Header.stories.js +30 -0
- package/lib/stories/Page.d.ts +3 -0
- package/lib/stories/Page.js +12 -0
- package/lib/stories/Page.stories.d.ts +12 -0
- package/lib/stories/Page.stories.js +28 -0
- package/lib/stories/assets/accessibility.png +0 -0
- package/lib/stories/assets/accessibility.svg +1 -0
- package/lib/stories/assets/addon-library.png +0 -0
- package/lib/stories/assets/assets.png +0 -0
- package/lib/stories/assets/context.png +0 -0
- package/lib/stories/assets/discord.svg +1 -0
- package/lib/stories/assets/docs.png +0 -0
- package/lib/stories/assets/figma-plugin.png +0 -0
- package/lib/stories/assets/github.svg +1 -0
- package/lib/stories/assets/share.png +0 -0
- package/lib/stories/assets/styling.png +0 -0
- package/lib/stories/assets/testing.png +0 -0
- package/lib/stories/assets/theming.png +0 -0
- package/lib/stories/assets/tutorials.svg +1 -0
- package/lib/stories/assets/youtube.svg +1 -0
- package/lib/stories/button.css +35 -0
- package/lib/stories/header.css +37 -0
- package/lib/stories/page.css +73 -0
- package/lib/test-setup.d.ts +1 -0
- package/lib/test-setup.js +80 -0
- package/lib/tools/adapters/agent-runtimes/AgentRuntimesToolAdapter.d.ts +40 -0
- package/lib/tools/adapters/agent-runtimes/AgentRuntimesToolAdapter.js +110 -0
- package/lib/tools/adapters/agent-runtimes/index.d.ts +9 -0
- package/lib/tools/adapters/agent-runtimes/index.js +13 -0
- package/lib/tools/adapters/agent-runtimes/lexicalHooks.d.ts +24 -0
- package/lib/tools/adapters/agent-runtimes/lexicalHooks.js +50 -0
- package/lib/tools/adapters/agent-runtimes/notebookHooks.d.ts +24 -0
- package/lib/tools/adapters/agent-runtimes/notebookHooks.js +51 -0
- package/lib/tools/adapters/copilotkit/CopilotKitToolAdapter.d.ts +73 -0
- package/lib/tools/adapters/copilotkit/CopilotKitToolAdapter.js +244 -0
- package/lib/tools/adapters/copilotkit/index.d.ts +10 -0
- package/lib/tools/adapters/copilotkit/index.js +14 -0
- package/lib/tools/adapters/copilotkit/lexicalHooks.d.ts +27 -0
- package/lib/tools/adapters/copilotkit/lexicalHooks.js +59 -0
- package/lib/tools/adapters/copilotkit/notebookHooks.d.ts +27 -0
- package/lib/tools/adapters/copilotkit/notebookHooks.js +58 -0
- package/lib/tools/adapters/index.d.ts +1 -0
- package/lib/tools/adapters/index.js +5 -0
- package/lib/tools/index.d.ts +6 -0
- package/lib/tools/index.js +18 -0
- package/lib/types.d.ts +5 -0
- package/lib/types.js +5 -0
- package/package.json +327 -0
- package/style/animation/Animation.module.css +174 -0
- package/style/base.css +204 -0
- package/style/index.css +6 -0
- package/style/showcase-vercel-ai.css +137 -0
|
@@ -0,0 +1,422 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
/*
|
|
3
|
+
* Copyright (c) 2025-2026 Datalayer, Inc.
|
|
4
|
+
* Distributed under the terms of the Modified BSD License.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Standalone Chat Popup component.
|
|
8
|
+
* A floating chat window that uses props-based message handling.
|
|
9
|
+
* Perfect for custom integrations where you want full control over inference.
|
|
10
|
+
*
|
|
11
|
+
* This component uses ChatBase for all chat functionality and provides
|
|
12
|
+
* a floating popup wrapper with animation, positioning, and FAB button.
|
|
13
|
+
*
|
|
14
|
+
* @module components/chat/components/ChatPopupStandalone
|
|
15
|
+
*/
|
|
16
|
+
import { useCallback, useEffect, useRef, useState, } from 'react';
|
|
17
|
+
import { IconButton, Text, Tooltip, Textarea, Button } from '@primer/react';
|
|
18
|
+
import { Box } from '@datalayer/primer-addons';
|
|
19
|
+
import { XIcon, CommentDiscussionIcon, PaperAirplaneIcon, SquareCircleIcon, } from '@primer/octicons-react';
|
|
20
|
+
import { AiAgentIcon } from '@datalayer/icons-react';
|
|
21
|
+
import { ChatBase, } from './base/ChatBase';
|
|
22
|
+
import { PoweredByTag } from './elements/PoweredByTag';
|
|
23
|
+
import { useChatOpen, useChatMessages, useChatStore, useChatLoading, useChatStreaming, } from '../store/chatStore';
|
|
24
|
+
import { generateMessageId, createUserMessage, createAssistantMessage, } from '../types/message';
|
|
25
|
+
import { useChatKeyboardShortcuts, getShortcutDisplay, } from '../../../hooks/useKeyboardShortcuts';
|
|
26
|
+
/**
|
|
27
|
+
* Hook to detect mobile viewport
|
|
28
|
+
*/
|
|
29
|
+
function useIsMobile(breakpoint = 640) {
|
|
30
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const checkMobile = () => {
|
|
33
|
+
setIsMobile(window.innerWidth < breakpoint);
|
|
34
|
+
};
|
|
35
|
+
checkMobile();
|
|
36
|
+
window.addEventListener('resize', checkMobile);
|
|
37
|
+
return () => window.removeEventListener('resize', checkMobile);
|
|
38
|
+
}, [breakpoint]);
|
|
39
|
+
return isMobile;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* ChatPopupStandalone component
|
|
43
|
+
* A floating popup chat that uses ChatBase with custom onSendMessage handler
|
|
44
|
+
*/
|
|
45
|
+
export function ChatPopupStandalone({ onSendMessage, title = 'Chat', description = 'Start a conversation.', position = 'bottom-right', defaultOpen = false, width = 380, height = 520, showHeader = true, showButton = true, showNewChatButton = true, showClearButton = true, showSettingsButton = false, enableKeyboardShortcuts = true, toggleShortcut = '/', showPoweredBy = true, poweredByProps, clickOutsideToClose = true, escapeToClose = true, className, placeholder = 'Type a message...', onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, buttonIcon, buttonTooltip = 'Chat with AI', brandColor = '#7c3aed', offset = 20, animationDuration = 200, enableStreaming = true, emptyStateMessage = 'Start a conversation', renderToolResult, panelProps, }) {
|
|
46
|
+
// Use Zustand store for state management
|
|
47
|
+
const isOpen = useChatOpen();
|
|
48
|
+
const messages = useChatMessages();
|
|
49
|
+
const isLoading = useChatLoading();
|
|
50
|
+
const { isStreaming } = useChatStreaming();
|
|
51
|
+
const setOpen = useChatStore(state => state.setOpen);
|
|
52
|
+
const addMessage = useChatStore(state => state.addMessage);
|
|
53
|
+
const updateMessage = useChatStore(state => state.updateMessage);
|
|
54
|
+
const clearMessages = useChatStore(state => state.clearMessages);
|
|
55
|
+
const setLoading = useChatStore(state => state.setLoading);
|
|
56
|
+
const startStreaming = useChatStore(state => state.startStreaming);
|
|
57
|
+
const appendToStream = useChatStore(state => state.appendToStream);
|
|
58
|
+
const stopStreaming = useChatStore(state => state.stopStreaming);
|
|
59
|
+
const popupRef = useRef(null);
|
|
60
|
+
const textareaRef = useRef(null);
|
|
61
|
+
const abortControllerRef = useRef(null);
|
|
62
|
+
const isMobile = useIsMobile();
|
|
63
|
+
const [isAnimating, setIsAnimating] = useState(false);
|
|
64
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
65
|
+
const [inputValue, setInputValue] = useState('');
|
|
66
|
+
// Initialize open state from defaultOpen
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
setOpen(defaultOpen);
|
|
69
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
|
+
}, []);
|
|
71
|
+
// Toggle popup with animation
|
|
72
|
+
const handleToggle = useCallback(() => {
|
|
73
|
+
const newOpen = !isOpen;
|
|
74
|
+
setIsAnimating(true);
|
|
75
|
+
if (newOpen) {
|
|
76
|
+
setOpen(newOpen);
|
|
77
|
+
onOpen?.();
|
|
78
|
+
// Focus input when opening
|
|
79
|
+
setTimeout(() => textareaRef.current?.focus(), animationDuration);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
// Delay closing for animation
|
|
83
|
+
setTimeout(() => {
|
|
84
|
+
setOpen(newOpen);
|
|
85
|
+
onClose?.();
|
|
86
|
+
setIsAnimating(false);
|
|
87
|
+
}, animationDuration);
|
|
88
|
+
}
|
|
89
|
+
// Reset animating after duration
|
|
90
|
+
setTimeout(() => setIsAnimating(false), animationDuration);
|
|
91
|
+
}, [isOpen, setOpen, onOpen, onClose, animationDuration]);
|
|
92
|
+
// Handle new chat
|
|
93
|
+
const handleNewChat = useCallback(() => {
|
|
94
|
+
clearMessages();
|
|
95
|
+
onNewChat?.();
|
|
96
|
+
}, [clearMessages, onNewChat]);
|
|
97
|
+
// Handle clear
|
|
98
|
+
const handleClear = useCallback(() => {
|
|
99
|
+
if (window.confirm('Clear all messages?')) {
|
|
100
|
+
clearMessages();
|
|
101
|
+
}
|
|
102
|
+
}, [clearMessages]);
|
|
103
|
+
// Handle stop generation
|
|
104
|
+
const handleStop = useCallback(() => {
|
|
105
|
+
abortControllerRef.current?.abort();
|
|
106
|
+
stopStreaming();
|
|
107
|
+
setLoading(false);
|
|
108
|
+
}, [stopStreaming, setLoading]);
|
|
109
|
+
// Handle send message with streaming support
|
|
110
|
+
const handleSend = useCallback(async () => {
|
|
111
|
+
const content = inputValue.trim();
|
|
112
|
+
if (!content || isLoading)
|
|
113
|
+
return;
|
|
114
|
+
setInputValue('');
|
|
115
|
+
// Add user message
|
|
116
|
+
const userMessage = createUserMessage(content);
|
|
117
|
+
addMessage(userMessage);
|
|
118
|
+
// Create assistant message placeholder
|
|
119
|
+
const assistantMessageId = generateMessageId();
|
|
120
|
+
const assistantMessage = createAssistantMessage('');
|
|
121
|
+
assistantMessage.id = assistantMessageId;
|
|
122
|
+
addMessage(assistantMessage);
|
|
123
|
+
setLoading(true);
|
|
124
|
+
abortControllerRef.current = new AbortController();
|
|
125
|
+
try {
|
|
126
|
+
if (enableStreaming) {
|
|
127
|
+
startStreaming(assistantMessageId);
|
|
128
|
+
await onSendMessage(content, {
|
|
129
|
+
onChunk: chunk => {
|
|
130
|
+
appendToStream(assistantMessageId, chunk);
|
|
131
|
+
},
|
|
132
|
+
onComplete: fullResponse => {
|
|
133
|
+
updateMessage(assistantMessageId, { content: fullResponse });
|
|
134
|
+
stopStreaming();
|
|
135
|
+
setLoading(false);
|
|
136
|
+
},
|
|
137
|
+
onError: error => {
|
|
138
|
+
updateMessage(assistantMessageId, {
|
|
139
|
+
content: `Error: ${error.message}`,
|
|
140
|
+
});
|
|
141
|
+
stopStreaming();
|
|
142
|
+
setLoading(false);
|
|
143
|
+
},
|
|
144
|
+
signal: abortControllerRef.current.signal,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
const response = await onSendMessage(content, {
|
|
149
|
+
signal: abortControllerRef.current.signal,
|
|
150
|
+
});
|
|
151
|
+
updateMessage(assistantMessageId, { content: response });
|
|
152
|
+
setLoading(false);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
if (error.name !== 'AbortError') {
|
|
157
|
+
updateMessage(assistantMessageId, {
|
|
158
|
+
content: `Error: ${error.message}`,
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
stopStreaming();
|
|
162
|
+
setLoading(false);
|
|
163
|
+
}
|
|
164
|
+
}, [
|
|
165
|
+
inputValue,
|
|
166
|
+
isLoading,
|
|
167
|
+
onSendMessage,
|
|
168
|
+
enableStreaming,
|
|
169
|
+
addMessage,
|
|
170
|
+
updateMessage,
|
|
171
|
+
setLoading,
|
|
172
|
+
startStreaming,
|
|
173
|
+
appendToStream,
|
|
174
|
+
stopStreaming,
|
|
175
|
+
]);
|
|
176
|
+
// Handle keyboard input
|
|
177
|
+
const handleKeyDown = useCallback((e) => {
|
|
178
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
179
|
+
e.preventDefault();
|
|
180
|
+
handleSend();
|
|
181
|
+
}
|
|
182
|
+
}, [handleSend]);
|
|
183
|
+
// Keyboard shortcuts
|
|
184
|
+
useChatKeyboardShortcuts({
|
|
185
|
+
onToggle: enableKeyboardShortcuts ? handleToggle : undefined,
|
|
186
|
+
onNewChat: enableKeyboardShortcuts ? handleNewChat : undefined,
|
|
187
|
+
onClear: enableKeyboardShortcuts && messages.length > 0 ? handleClear : undefined,
|
|
188
|
+
enabled: enableKeyboardShortcuts,
|
|
189
|
+
});
|
|
190
|
+
// Escape to close
|
|
191
|
+
useEffect(() => {
|
|
192
|
+
if (!escapeToClose || !isOpen)
|
|
193
|
+
return;
|
|
194
|
+
const handleKeyDown = (event) => {
|
|
195
|
+
if (event.key === 'Escape') {
|
|
196
|
+
handleToggle();
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
200
|
+
return () => document.removeEventListener('keydown', handleKeyDown);
|
|
201
|
+
}, [escapeToClose, isOpen, handleToggle]);
|
|
202
|
+
// Click outside to close
|
|
203
|
+
useEffect(() => {
|
|
204
|
+
if (!clickOutsideToClose || !isOpen)
|
|
205
|
+
return;
|
|
206
|
+
const handleClickOutside = (event) => {
|
|
207
|
+
if (popupRef.current &&
|
|
208
|
+
!popupRef.current.contains(event.target)) {
|
|
209
|
+
handleToggle();
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
// Delay adding listener to prevent immediate close
|
|
213
|
+
const timeoutId = setTimeout(() => {
|
|
214
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
215
|
+
}, 100);
|
|
216
|
+
return () => {
|
|
217
|
+
clearTimeout(timeoutId);
|
|
218
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
219
|
+
};
|
|
220
|
+
}, [clickOutsideToClose, isOpen, handleToggle]);
|
|
221
|
+
// Mobile body scroll lock
|
|
222
|
+
useEffect(() => {
|
|
223
|
+
if (isMobile && isOpen) {
|
|
224
|
+
document.body.style.overflow = 'hidden';
|
|
225
|
+
document.body.style.position = 'fixed';
|
|
226
|
+
document.body.style.width = '100%';
|
|
227
|
+
document.body.style.touchAction = 'none';
|
|
228
|
+
return () => {
|
|
229
|
+
document.body.style.overflow = '';
|
|
230
|
+
document.body.style.position = '';
|
|
231
|
+
document.body.style.width = '';
|
|
232
|
+
document.body.style.touchAction = '';
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
}, [isMobile, isOpen]);
|
|
236
|
+
// Position styles
|
|
237
|
+
const getPositionStyles = () => {
|
|
238
|
+
const styles = {
|
|
239
|
+
position: 'fixed',
|
|
240
|
+
zIndex: 1000,
|
|
241
|
+
};
|
|
242
|
+
switch (position) {
|
|
243
|
+
case 'bottom-right':
|
|
244
|
+
styles.bottom = offset;
|
|
245
|
+
styles.right = offset;
|
|
246
|
+
break;
|
|
247
|
+
case 'bottom-left':
|
|
248
|
+
styles.bottom = offset;
|
|
249
|
+
styles.left = offset;
|
|
250
|
+
break;
|
|
251
|
+
case 'top-right':
|
|
252
|
+
styles.top = offset;
|
|
253
|
+
styles.right = offset;
|
|
254
|
+
break;
|
|
255
|
+
case 'top-left':
|
|
256
|
+
styles.top = offset;
|
|
257
|
+
styles.left = offset;
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
return styles;
|
|
261
|
+
};
|
|
262
|
+
// Animation transform based on position
|
|
263
|
+
const getAnimationTransform = (open) => {
|
|
264
|
+
if (open)
|
|
265
|
+
return 'scale(1) translateY(0)';
|
|
266
|
+
switch (position) {
|
|
267
|
+
case 'bottom-right':
|
|
268
|
+
case 'bottom-left':
|
|
269
|
+
return 'scale(0.95) translateY(20px)';
|
|
270
|
+
case 'top-right':
|
|
271
|
+
case 'top-left':
|
|
272
|
+
return 'scale(0.95) translateY(-20px)';
|
|
273
|
+
default:
|
|
274
|
+
return 'scale(0.95)';
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
// Shortcut hint for toggle
|
|
278
|
+
const shortcutHint = enableKeyboardShortcuts
|
|
279
|
+
? getShortcutDisplay({
|
|
280
|
+
key: toggleShortcut,
|
|
281
|
+
ctrlOrCmd: true,
|
|
282
|
+
handler: () => { },
|
|
283
|
+
})
|
|
284
|
+
: undefined;
|
|
285
|
+
// Responsive dimensions
|
|
286
|
+
const popupWidth = isMobile ? '100%' : width;
|
|
287
|
+
const popupHeight = isMobile ? '100%' : height;
|
|
288
|
+
// Mobile full-screen styles
|
|
289
|
+
const mobileStyles = isMobile
|
|
290
|
+
? {
|
|
291
|
+
position: 'fixed',
|
|
292
|
+
top: 0,
|
|
293
|
+
left: 0,
|
|
294
|
+
right: 0,
|
|
295
|
+
bottom: 0,
|
|
296
|
+
width: '100%',
|
|
297
|
+
height: '100%',
|
|
298
|
+
borderRadius: 0,
|
|
299
|
+
}
|
|
300
|
+
: {};
|
|
301
|
+
// Close button for header
|
|
302
|
+
const closeButton = (_jsx(Tooltip, { text: `Close${escapeToClose ? ' (Esc)' : ''}`, direction: "s", children: _jsx(IconButton, { icon: XIcon, "aria-label": "Close", onClick: handleToggle, variant: "invisible", size: "small" }) }));
|
|
303
|
+
return (_jsxs(_Fragment, { children: [showButton && !isOpen && (_jsx(Box, { sx: {
|
|
304
|
+
...getPositionStyles(),
|
|
305
|
+
}, children: _jsxs(Box, { sx: {
|
|
306
|
+
position: 'relative',
|
|
307
|
+
display: 'inline-flex',
|
|
308
|
+
}, onMouseEnter: () => setIsHovered(true), onMouseLeave: () => setIsHovered(false), children: [_jsx(Tooltip, { text: `${buttonTooltip}${shortcutHint ? ` (${shortcutHint})` : ''}`, direction: position.includes('right') ? 'w' : 'e', children: _jsx(IconButton, { icon: buttonIcon
|
|
309
|
+
? buttonIcon
|
|
310
|
+
: CommentDiscussionIcon, "aria-label": buttonTooltip, onClick: handleToggle, size: "large", sx: {
|
|
311
|
+
width: 56,
|
|
312
|
+
height: 56,
|
|
313
|
+
borderRadius: '50%',
|
|
314
|
+
bg: brandColor || 'accent.emphasis',
|
|
315
|
+
color: 'fg.onEmphasis',
|
|
316
|
+
boxShadow: 'shadow.large',
|
|
317
|
+
transition: 'transform 0.2s ease, box-shadow 0.2s ease',
|
|
318
|
+
transform: isHovered ? 'scale(1.1)' : 'scale(1)',
|
|
319
|
+
'&:hover': {
|
|
320
|
+
bg: brandColor || 'accent.emphasis',
|
|
321
|
+
boxShadow: 'shadow.extra-large',
|
|
322
|
+
},
|
|
323
|
+
} }) }), messages.length > 0 && (_jsx(Box, { sx: {
|
|
324
|
+
position: 'absolute',
|
|
325
|
+
top: -4,
|
|
326
|
+
right: -4,
|
|
327
|
+
minWidth: 20,
|
|
328
|
+
height: 20,
|
|
329
|
+
px: 1,
|
|
330
|
+
display: 'flex',
|
|
331
|
+
alignItems: 'center',
|
|
332
|
+
justifyContent: 'center',
|
|
333
|
+
bg: 'danger.emphasis',
|
|
334
|
+
color: 'fg.onEmphasis',
|
|
335
|
+
borderRadius: '50%',
|
|
336
|
+
fontSize: 0,
|
|
337
|
+
fontWeight: 'bold',
|
|
338
|
+
}, children: _jsx(Text, { sx: { fontSize: 0 }, children: messages.length > 99 ? '99+' : messages.length }) })), messages.length > 0 && (_jsx(Box, { sx: {
|
|
339
|
+
position: 'absolute',
|
|
340
|
+
top: 0,
|
|
341
|
+
left: 0,
|
|
342
|
+
right: 0,
|
|
343
|
+
bottom: 0,
|
|
344
|
+
borderRadius: '50%',
|
|
345
|
+
border: '2px solid',
|
|
346
|
+
borderColor: brandColor || 'accent.emphasis',
|
|
347
|
+
animation: 'pulse 2s infinite',
|
|
348
|
+
'@keyframes pulse': {
|
|
349
|
+
'0%': {
|
|
350
|
+
transform: 'scale(1)',
|
|
351
|
+
opacity: 1,
|
|
352
|
+
},
|
|
353
|
+
'100%': {
|
|
354
|
+
transform: 'scale(1.5)',
|
|
355
|
+
opacity: 0,
|
|
356
|
+
},
|
|
357
|
+
},
|
|
358
|
+
} }))] }) })), isMobile && isOpen && (_jsx(Box, { sx: {
|
|
359
|
+
position: 'fixed',
|
|
360
|
+
top: 0,
|
|
361
|
+
left: 0,
|
|
362
|
+
right: 0,
|
|
363
|
+
bottom: 0,
|
|
364
|
+
bg: 'neutral.muted',
|
|
365
|
+
opacity: 0.5,
|
|
366
|
+
zIndex: 999,
|
|
367
|
+
}, onClick: handleToggle })), (isOpen || isAnimating) && (_jsxs(Box, { ref: popupRef, className: className, sx: {
|
|
368
|
+
...getPositionStyles(),
|
|
369
|
+
width: isMobile
|
|
370
|
+
? '100%'
|
|
371
|
+
: typeof popupWidth === 'number'
|
|
372
|
+
? `${popupWidth}px`
|
|
373
|
+
: popupWidth,
|
|
374
|
+
height: isMobile
|
|
375
|
+
? '100%'
|
|
376
|
+
: typeof popupHeight === 'number'
|
|
377
|
+
? `${popupHeight}px`
|
|
378
|
+
: popupHeight,
|
|
379
|
+
display: 'flex',
|
|
380
|
+
flexDirection: 'column',
|
|
381
|
+
bg: 'canvas.default',
|
|
382
|
+
border: '1px solid',
|
|
383
|
+
borderColor: 'border.default',
|
|
384
|
+
borderRadius: isMobile ? 0 : '12px',
|
|
385
|
+
boxShadow: '0 8px 30px rgba(0, 0, 0, 0.12)',
|
|
386
|
+
overflow: 'hidden',
|
|
387
|
+
transform: getAnimationTransform(isOpen),
|
|
388
|
+
opacity: isOpen ? 1 : 0,
|
|
389
|
+
transition: `transform ${animationDuration}ms ease, opacity ${animationDuration}ms ease`,
|
|
390
|
+
zIndex: 1001,
|
|
391
|
+
...mobileStyles,
|
|
392
|
+
}, children: [_jsx(ChatBase, { title: title, showHeader: showHeader, showInput: false, showPoweredBy: false, useStore: true, brandIcon: brandIcon || _jsx(AiAgentIcon, { colored: true, size: 20 }), headerButtons: {
|
|
393
|
+
showNewChat: showNewChatButton,
|
|
394
|
+
showClear: showClearButton && messages.length > 0,
|
|
395
|
+
showSettings: showSettingsButton,
|
|
396
|
+
onNewChat: handleNewChat,
|
|
397
|
+
onClear: handleClear,
|
|
398
|
+
onSettings: onSettingsClick,
|
|
399
|
+
}, headerActions: closeButton, renderToolResult: renderToolResult, description: description, emptyState: {
|
|
400
|
+
title: emptyStateMessage,
|
|
401
|
+
}, avatarConfig: {
|
|
402
|
+
showAvatars: true,
|
|
403
|
+
}, backgroundColor: "canvas.subtle", ...panelProps, children: children }), _jsxs(Box, { sx: {
|
|
404
|
+
display: 'flex',
|
|
405
|
+
gap: 2,
|
|
406
|
+
p: 3,
|
|
407
|
+
borderTop: '1px solid',
|
|
408
|
+
borderColor: 'border.default',
|
|
409
|
+
bg: 'canvas.default',
|
|
410
|
+
}, children: [_jsx(Textarea, { ref: textareaRef, value: inputValue, onChange: e => setInputValue(e.target.value), onKeyDown: handleKeyDown, placeholder: placeholder, disabled: isLoading, sx: {
|
|
411
|
+
flex: 1,
|
|
412
|
+
resize: 'none',
|
|
413
|
+
minHeight: '40px',
|
|
414
|
+
maxHeight: '120px',
|
|
415
|
+
}, rows: 1 }), isLoading || isStreaming ? (_jsx(Button, { onClick: handleStop, variant: "danger", children: _jsx(SquareCircleIcon, {}) })) : (_jsx(Button, { onClick: handleSend, variant: "primary", disabled: !inputValue.trim(), children: _jsx(PaperAirplaneIcon, {}) }))] }), showPoweredBy && (_jsx(Box, { sx: {
|
|
416
|
+
p: 2,
|
|
417
|
+
borderTop: '1px solid',
|
|
418
|
+
borderColor: 'border.default',
|
|
419
|
+
bg: 'canvas.subtle',
|
|
420
|
+
}, children: _jsx(PoweredByTag, { show: true, brandName: "Datalayer", brandUrl: "https://datalayer.ai", ...poweredByProps }) }))] }))] }));
|
|
421
|
+
}
|
|
422
|
+
export default ChatPopupStandalone;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat sidebar component.
|
|
3
|
+
* Provides a collapsible sidebar with chat interface.
|
|
4
|
+
* Features: keyboard shortcuts, mobile responsive, powered by tag.
|
|
5
|
+
* Built on top of ChatBase for core chat functionality.
|
|
6
|
+
*
|
|
7
|
+
* @module components/chat/components/ChatSidebar
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { type ChatBaseProps, type MessageHandler } from './base/ChatBase';
|
|
11
|
+
import type { PoweredByTagProps } from './elements/PoweredByTag';
|
|
12
|
+
export type { MessageHandler };
|
|
13
|
+
/**
|
|
14
|
+
* ChatSidebar props
|
|
15
|
+
*/
|
|
16
|
+
export interface ChatSidebarProps {
|
|
17
|
+
/** Sidebar title */
|
|
18
|
+
title?: string;
|
|
19
|
+
/** Initial open state */
|
|
20
|
+
defaultOpen?: boolean;
|
|
21
|
+
/** Sidebar position */
|
|
22
|
+
position?: 'left' | 'right';
|
|
23
|
+
/** Sidebar width when open */
|
|
24
|
+
width?: number | string;
|
|
25
|
+
/** Show header */
|
|
26
|
+
showHeader?: boolean;
|
|
27
|
+
/** Show new chat button */
|
|
28
|
+
showNewChatButton?: boolean;
|
|
29
|
+
/** Show clear button */
|
|
30
|
+
showClearButton?: boolean;
|
|
31
|
+
/** Show settings button */
|
|
32
|
+
showSettingsButton?: boolean;
|
|
33
|
+
/** Enable keyboard shortcuts */
|
|
34
|
+
enableKeyboardShortcuts?: boolean;
|
|
35
|
+
/** Keyboard shortcut to toggle (default: 'k') */
|
|
36
|
+
toggleShortcut?: string;
|
|
37
|
+
/** Show powered by tag */
|
|
38
|
+
showPoweredBy?: boolean;
|
|
39
|
+
/** Powered by tag props */
|
|
40
|
+
poweredByProps?: Partial<PoweredByTagProps>;
|
|
41
|
+
/** Enable click outside to close */
|
|
42
|
+
clickOutsideToClose?: boolean;
|
|
43
|
+
/** Enable escape key to close */
|
|
44
|
+
escapeToClose?: boolean;
|
|
45
|
+
/** Custom class name */
|
|
46
|
+
className?: string;
|
|
47
|
+
/** Callback when settings clicked */
|
|
48
|
+
onSettingsClick?: () => void;
|
|
49
|
+
/** Callback when new chat clicked */
|
|
50
|
+
onNewChat?: () => void;
|
|
51
|
+
/** Callback when sidebar opens */
|
|
52
|
+
onOpen?: () => void;
|
|
53
|
+
/** Callback when sidebar closes */
|
|
54
|
+
onClose?: () => void;
|
|
55
|
+
/** Children to render in sidebar body (custom content) */
|
|
56
|
+
children?: React.ReactNode;
|
|
57
|
+
/** Custom brand icon */
|
|
58
|
+
brandIcon?: React.ReactNode;
|
|
59
|
+
/**
|
|
60
|
+
* Handler for sending messages.
|
|
61
|
+
* When provided, this is used instead of protocol mode.
|
|
62
|
+
* Signature: (message, messages, options?) => Promise<string | void>
|
|
63
|
+
*/
|
|
64
|
+
onSendMessage?: MessageHandler;
|
|
65
|
+
/** Enable streaming mode (default: true) */
|
|
66
|
+
enableStreaming?: boolean;
|
|
67
|
+
/** Input placeholder */
|
|
68
|
+
placeholder?: string;
|
|
69
|
+
/** Description shown in empty state */
|
|
70
|
+
description?: string;
|
|
71
|
+
/** Additional ChatBase props */
|
|
72
|
+
panelProps?: Partial<ChatBaseProps>;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Chat Sidebar component
|
|
76
|
+
*/
|
|
77
|
+
export declare function ChatSidebar({ title, defaultOpen, position, width, showHeader, showNewChatButton, showClearButton, showSettingsButton, enableKeyboardShortcuts, toggleShortcut, showPoweredBy, poweredByProps, clickOutsideToClose, escapeToClose, className, onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, onSendMessage, enableStreaming, placeholder, description, panelProps, }: ChatSidebarProps): import("react/jsx-runtime").JSX.Element;
|
|
78
|
+
export default ChatSidebar;
|