@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,63 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Text } from '@primer/react';
|
|
3
|
+
import { Box } from '@datalayer/primer-addons';
|
|
4
|
+
import { datalayerTheme, DatalayerThemeProvider } from '@datalayer/core';
|
|
5
|
+
import { ChatFloating } from '../components/chat';
|
|
6
|
+
// AG-UI endpoint for agentic chat example
|
|
7
|
+
const AGENTIC_CHAT_ENDPOINT = 'http://localhost:8765/api/v1/examples/agentic_chat/';
|
|
8
|
+
/**
|
|
9
|
+
* AgUiAgenticExample Component
|
|
10
|
+
*
|
|
11
|
+
* Shows a floating chat button that opens a chat popup connected to
|
|
12
|
+
* the Agentic Chat AG-UI example.
|
|
13
|
+
*
|
|
14
|
+
* Features demonstrated:
|
|
15
|
+
* - Basic AG-UI SSE streaming
|
|
16
|
+
* - Tool calling (current_time tool)
|
|
17
|
+
* - Floating popup interface
|
|
18
|
+
*/
|
|
19
|
+
const AgUiAgenticExample = () => {
|
|
20
|
+
return (_jsx(DatalayerThemeProvider, { theme: datalayerTheme, children: _jsxs(Box, { sx: {
|
|
21
|
+
minHeight: '100vh',
|
|
22
|
+
backgroundColor: 'canvas.default',
|
|
23
|
+
padding: 4,
|
|
24
|
+
}, children: [_jsxs(Box, { sx: {
|
|
25
|
+
maxWidth: '800px',
|
|
26
|
+
margin: '0 auto',
|
|
27
|
+
}, children: [_jsx(Text, { as: "h1", sx: {
|
|
28
|
+
fontSize: 4,
|
|
29
|
+
fontWeight: 'bold',
|
|
30
|
+
marginBottom: 2,
|
|
31
|
+
}, children: "AG-UI: Agentic Example" }), _jsx(Text, { as: "p", sx: {
|
|
32
|
+
fontSize: 2,
|
|
33
|
+
color: 'fg.muted',
|
|
34
|
+
marginBottom: 4,
|
|
35
|
+
}, children: "Click the chat button in the bottom-right corner to start a conversation with an AI agent that can use tools." }), _jsxs(Box, { sx: {
|
|
36
|
+
padding: 4,
|
|
37
|
+
backgroundColor: 'canvas.subtle',
|
|
38
|
+
borderRadius: 2,
|
|
39
|
+
border: '1px solid',
|
|
40
|
+
borderColor: 'border.default',
|
|
41
|
+
}, children: [_jsx(Text, { as: "h2", sx: { fontSize: 2, fontWeight: 'semibold', marginBottom: 2 }, children: "Available Tools" }), _jsx(Box, { as: "ul", sx: { paddingLeft: 3 }, children: _jsxs(Box, { as: "li", sx: { marginBottom: 1 }, children: [_jsx(Text, { sx: { fontFamily: 'mono', fontSize: 1 }, children: "current_time()" }), _jsxs(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: [' ', "- Returns the current date and time"] })] }) }), _jsx(Text, { as: "p", sx: {
|
|
42
|
+
fontSize: 1,
|
|
43
|
+
color: 'fg.muted',
|
|
44
|
+
marginTop: 3,
|
|
45
|
+
}, children: "Try asking: \"What time is it?\" or \"What's the current date?\"" })] }), _jsxs(Box, { sx: {
|
|
46
|
+
marginTop: 4,
|
|
47
|
+
padding: 4,
|
|
48
|
+
backgroundColor: 'canvas.subtle',
|
|
49
|
+
borderRadius: 2,
|
|
50
|
+
border: '1px solid',
|
|
51
|
+
borderColor: 'border.default',
|
|
52
|
+
}, children: [_jsx(Text, { as: "h2", sx: { fontSize: 2, fontWeight: 'semibold', marginBottom: 2 }, children: "About This Example" }), _jsx(Text, { as: "p", sx: { fontSize: 1, color: 'fg.muted' }, children: "This example demonstrates the AG-UI (Agent User Interface) protocol for streaming AI interactions. The agent uses SSE (Server-Sent Events) to stream responses and tool calls in real-time." }), _jsxs(Text, { as: "p", sx: { fontSize: 1, color: 'fg.muted', marginTop: 2 }, children: [_jsx("strong", { children: "Protocol Events:" }), " TEXT_MESSAGE_START, TEXT_MESSAGE_CONTENT, TEXT_MESSAGE_END, TOOL_CALL_START, TOOL_CALL_END"] })] })] }), _jsx(ChatFloating, { endpoint: AGENTIC_CHAT_ENDPOINT, title: "Agentic Chat", description: "Chat with an AI agent that can use tools like getting the current time.", position: "bottom-right", brandColor: "#7c3aed", defaultOpen: true, suggestions: [
|
|
53
|
+
{
|
|
54
|
+
title: 'What time is it?',
|
|
55
|
+
message: 'What is the current time?',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
title: "Today's date",
|
|
59
|
+
message: "What's the current date?",
|
|
60
|
+
},
|
|
61
|
+
] })] }) }));
|
|
62
|
+
};
|
|
63
|
+
export default AgUiAgenticExample;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgUiBackendToolRenderingExample
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates backend tool rendering where tools execute on the server
|
|
5
|
+
* and return structured data that the frontend renders INLINE in the chat.
|
|
6
|
+
*
|
|
7
|
+
* This example shows a weather assistant that fetches real weather data
|
|
8
|
+
* and renders beautiful weather cards directly in the chat conversation,
|
|
9
|
+
* similar to the AG-UI Dojo implementation.
|
|
10
|
+
*
|
|
11
|
+
* Backend: /api/v1/examples/backend_tool_rendering/
|
|
12
|
+
*/
|
|
13
|
+
import React from 'react';
|
|
14
|
+
/**
|
|
15
|
+
* AgUiBackendToolRenderingExample Component
|
|
16
|
+
*
|
|
17
|
+
* Demonstrates backend tool rendering with AG-UI.
|
|
18
|
+
* The agent has a `get_weather` tool that calls the Open-Meteo API
|
|
19
|
+
* and returns weather data. This data is rendered INLINE in the chat
|
|
20
|
+
* as a beautiful weather card with dynamic theming.
|
|
21
|
+
*
|
|
22
|
+
* Features demonstrated:
|
|
23
|
+
* - Backend tool execution
|
|
24
|
+
* - Real API integration (Open-Meteo)
|
|
25
|
+
* - INLINE rendering of tool results in chat
|
|
26
|
+
* - Dynamic theming based on weather conditions
|
|
27
|
+
* - Loading states while fetching data
|
|
28
|
+
*/
|
|
29
|
+
declare const AgUiBackendToolRenderingExample: React.FC;
|
|
30
|
+
export default AgUiBackendToolRenderingExample;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } 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
|
+
* AgUiBackendToolRenderingExample
|
|
8
|
+
*
|
|
9
|
+
* Demonstrates backend tool rendering where tools execute on the server
|
|
10
|
+
* and return structured data that the frontend renders INLINE in the chat.
|
|
11
|
+
*
|
|
12
|
+
* This example shows a weather assistant that fetches real weather data
|
|
13
|
+
* and renders beautiful weather cards directly in the chat conversation,
|
|
14
|
+
* similar to the AG-UI Dojo implementation.
|
|
15
|
+
*
|
|
16
|
+
* Backend: /api/v1/examples/backend_tool_rendering/
|
|
17
|
+
*/
|
|
18
|
+
import { useCallback } from 'react';
|
|
19
|
+
import { Text } from '@primer/react';
|
|
20
|
+
import { Box } from '@datalayer/primer-addons';
|
|
21
|
+
import { datalayerTheme, DatalayerThemeProvider } from '@datalayer/core';
|
|
22
|
+
import { ChatFloating } from '../components/chat';
|
|
23
|
+
import { InlineWeatherCard } from './ag-ui/weather';
|
|
24
|
+
// AG-UI endpoint for backend tool rendering example
|
|
25
|
+
const BACKEND_TOOL_RENDERING_ENDPOINT = 'http://localhost:8765/api/v1/examples/backend_tool_rendering/';
|
|
26
|
+
/**
|
|
27
|
+
* Render function for tool results - renders weather cards inline in chat
|
|
28
|
+
*/
|
|
29
|
+
const renderWeatherToolResult = (context) => {
|
|
30
|
+
// Only render for the get_weather tool
|
|
31
|
+
if (context.toolName !== 'get_weather') {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
// Extract location from args
|
|
35
|
+
const location = context.args?.location;
|
|
36
|
+
// Cast result to WeatherResult if available
|
|
37
|
+
const weatherResult = context.result;
|
|
38
|
+
return (_jsx(InlineWeatherCard, { location: location, result: weatherResult, status: context.status, error: context.error }));
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* AgUiBackendToolRenderingExample Component
|
|
42
|
+
*
|
|
43
|
+
* Demonstrates backend tool rendering with AG-UI.
|
|
44
|
+
* The agent has a `get_weather` tool that calls the Open-Meteo API
|
|
45
|
+
* and returns weather data. This data is rendered INLINE in the chat
|
|
46
|
+
* as a beautiful weather card with dynamic theming.
|
|
47
|
+
*
|
|
48
|
+
* Features demonstrated:
|
|
49
|
+
* - Backend tool execution
|
|
50
|
+
* - Real API integration (Open-Meteo)
|
|
51
|
+
* - INLINE rendering of tool results in chat
|
|
52
|
+
* - Dynamic theming based on weather conditions
|
|
53
|
+
* - Loading states while fetching data
|
|
54
|
+
*/
|
|
55
|
+
const AgUiBackendToolRenderingExample = () => {
|
|
56
|
+
// Optional: still track weather for sidebar display if needed
|
|
57
|
+
const handleStateUpdate = useCallback((_state) => {
|
|
58
|
+
// State updates are still available if needed for other purposes
|
|
59
|
+
// Uncomment to debug: console.log('[WeatherExample] State update:', _state);
|
|
60
|
+
}, []);
|
|
61
|
+
return (_jsx(DatalayerThemeProvider, { theme: datalayerTheme, children: _jsxs(Box, { sx: {
|
|
62
|
+
minHeight: '100vh',
|
|
63
|
+
backgroundColor: 'canvas.default',
|
|
64
|
+
padding: 4,
|
|
65
|
+
}, children: [_jsxs(Box, { sx: {
|
|
66
|
+
maxWidth: '800px',
|
|
67
|
+
margin: '0 auto',
|
|
68
|
+
}, children: [_jsx(Text, { as: "h1", sx: {
|
|
69
|
+
fontSize: 4,
|
|
70
|
+
fontWeight: 'bold',
|
|
71
|
+
marginBottom: 2,
|
|
72
|
+
}, children: "AG-UI: Backend Tool Rendering (Inline)" }), _jsxs(Text, { as: "p", sx: {
|
|
73
|
+
fontSize: 2,
|
|
74
|
+
color: 'fg.muted',
|
|
75
|
+
marginBottom: 4,
|
|
76
|
+
}, children: ["Ask about the weather anywhere in the world. Weather cards are rendered ", _jsx("strong", { children: "inline in the chat" }), " with dynamic theming!"] }), _jsxs(Box, { sx: {
|
|
77
|
+
padding: 4,
|
|
78
|
+
backgroundColor: 'canvas.subtle',
|
|
79
|
+
borderRadius: 2,
|
|
80
|
+
border: '1px solid',
|
|
81
|
+
borderColor: 'border.default',
|
|
82
|
+
}, children: [_jsx(Text, { as: "h2", sx: { fontSize: 2, fontWeight: 'semibold', marginBottom: 2 }, children: "About This Example" }), _jsxs(Text, { as: "p", sx: { fontSize: 1, color: 'fg.muted' }, children: ["This demonstrates ", _jsx("strong", { children: "inline backend tool rendering" }), ' ', "with AG-UI. When the agent calls the ", _jsx("code", { children: "get_weather" }), ' ', "tool, the result is rendered as a beautiful weather card directly in the chat conversation, similar to the AG-UI Dojo implementation."] }), _jsxs(Box, { sx: { marginTop: 3 }, children: [_jsx(Text, { sx: { fontSize: 1, fontWeight: 'medium' }, children: "Features:" }), _jsxs(Box, { as: "ul", sx: {
|
|
83
|
+
paddingLeft: 3,
|
|
84
|
+
marginTop: 1,
|
|
85
|
+
fontSize: 1,
|
|
86
|
+
color: 'fg.muted',
|
|
87
|
+
}, children: [_jsx("li", { children: "\uD83C\uDF24\uFE0F Dynamic background colors based on weather conditions" }), _jsx("li", { children: "\uD83C\uDFA8 Weather icons (sun, rain, cloud)" }), _jsx("li", { children: "\uD83C\uDF21\uFE0F Temperature in both Celsius and Fahrenheit" }), _jsx("li", { children: "\uD83D\uDCA8 Humidity, wind speed, and feels-like stats" }), _jsx("li", { children: "\u23F3 Loading spinner while fetching data" })] })] }), _jsxs(Box, { sx: { marginTop: 3 }, children: [_jsx(Text, { sx: { fontSize: 1, fontWeight: 'medium' }, children: "Try these prompts:" }), _jsxs(Box, { as: "ul", sx: {
|
|
88
|
+
paddingLeft: 3,
|
|
89
|
+
marginTop: 1,
|
|
90
|
+
fontSize: 1,
|
|
91
|
+
color: 'fg.muted',
|
|
92
|
+
}, children: [_jsx("li", { children: "\"What's the weather in New York?\"" }), _jsx("li", { children: "\"Weather in London and Paris\"" }), _jsx("li", { children: "\"Is it sunny in Sydney?\"" }), _jsx("li", { children: "\"How's the weather in Tokyo today?\"" })] })] })] })] }), _jsx(ChatFloating, { endpoint: BACKEND_TOOL_RENDERING_ENDPOINT, title: "Weather Assistant", description: "Ask me about the weather anywhere in the world!", position: "bottom-right", brandColor: "#667eea", onStateUpdate: handleStateUpdate, renderToolResult: renderWeatherToolResult, suggestions: [
|
|
93
|
+
{
|
|
94
|
+
title: 'Paris weather',
|
|
95
|
+
message: "What's the weather like in Paris?",
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
title: 'Tokyo forecast',
|
|
99
|
+
message: 'Show me the weather forecast for Tokyo.',
|
|
100
|
+
},
|
|
101
|
+
] })] }) }));
|
|
102
|
+
};
|
|
103
|
+
export default AgUiBackendToolRenderingExample;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgUiHaikuGenUIExample
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates tool-based generative UI where the agent generates haiku
|
|
5
|
+
* poetry that is rendered:
|
|
6
|
+
* 1. INLINE in the chat conversation
|
|
7
|
+
* 2. In a main display area (carousel) for a richer experience
|
|
8
|
+
*
|
|
9
|
+
* This follows the AG-UI Dojo pattern where tool results are rendered
|
|
10
|
+
* as UI components in both locations.
|
|
11
|
+
*
|
|
12
|
+
* Backend: /api/v1/examples/haiku_generative_ui/
|
|
13
|
+
*/
|
|
14
|
+
import React from 'react';
|
|
15
|
+
import { type HaikuResult } from './ag-ui/haiku';
|
|
16
|
+
/**
|
|
17
|
+
* Ref handle for haiku state synchronization between chat and main display
|
|
18
|
+
*/
|
|
19
|
+
export interface HaikuDisplayHandle {
|
|
20
|
+
/** Add a new haiku to the display */
|
|
21
|
+
addHaiku: (haiku: HaikuResult) => void;
|
|
22
|
+
/** Get current haikus */
|
|
23
|
+
getHaikus: () => HaikuResult[];
|
|
24
|
+
/** Clear all haikus */
|
|
25
|
+
clearHaikus: () => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* AgUiHaikuGenUIExample Component
|
|
29
|
+
*
|
|
30
|
+
* Demonstrates tool-based generative UI with haiku generation.
|
|
31
|
+
* The agent has a `generate_haiku` tool that returns structured
|
|
32
|
+
* haiku data. This data is rendered:
|
|
33
|
+
* - INLINE in the chat as a haiku card
|
|
34
|
+
* - In the main view as part of a carousel
|
|
35
|
+
*
|
|
36
|
+
* Features demonstrated:
|
|
37
|
+
* - Tool-based generative UI
|
|
38
|
+
* - Ref-based state synchronization between chat and main view
|
|
39
|
+
* - Carousel display for multiple haikus
|
|
40
|
+
* - Dynamic gradient backgrounds
|
|
41
|
+
* - Japanese/English text rendering
|
|
42
|
+
*/
|
|
43
|
+
declare const AgUiHaikuGenUIExample: React.FC;
|
|
44
|
+
export default AgUiHaikuGenUIExample;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } 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
|
+
* AgUiHaikuGenUIExample
|
|
8
|
+
*
|
|
9
|
+
* Demonstrates tool-based generative UI where the agent generates haiku
|
|
10
|
+
* poetry that is rendered:
|
|
11
|
+
* 1. INLINE in the chat conversation
|
|
12
|
+
* 2. In a main display area (carousel) for a richer experience
|
|
13
|
+
*
|
|
14
|
+
* This follows the AG-UI Dojo pattern where tool results are rendered
|
|
15
|
+
* as UI components in both locations.
|
|
16
|
+
*
|
|
17
|
+
* Backend: /api/v1/examples/haiku_generative_ui/
|
|
18
|
+
*/
|
|
19
|
+
import { useState, useCallback, useRef, useImperativeHandle, forwardRef, } from 'react';
|
|
20
|
+
import { Text } from '@primer/react';
|
|
21
|
+
import { Box } from '@datalayer/primer-addons';
|
|
22
|
+
import { datalayerTheme, DatalayerThemeProvider } from '@datalayer/core';
|
|
23
|
+
import { ChatFloating } from '../components/chat';
|
|
24
|
+
import { InlineHaikuCard, HaikuDisplay } from './ag-ui/haiku';
|
|
25
|
+
// AG-UI endpoint for haiku generative UI example
|
|
26
|
+
const HAIKU_ENDPOINT = 'http://localhost:8765/api/v1/examples/haiku_generative_ui/';
|
|
27
|
+
/**
|
|
28
|
+
* HaikuDisplayWithRef - A display component that exposes a ref for external control.
|
|
29
|
+
*
|
|
30
|
+
* This allows the chat's tool rendering to update the main display
|
|
31
|
+
* when new haikus are generated.
|
|
32
|
+
*/
|
|
33
|
+
const HaikuDisplayWithRef = forwardRef(({ title }, ref) => {
|
|
34
|
+
const [haikus, setHaikus] = useState([]);
|
|
35
|
+
// Expose methods via ref
|
|
36
|
+
useImperativeHandle(ref, () => ({
|
|
37
|
+
addHaiku: (haiku) => {
|
|
38
|
+
setHaikus(prev => [haiku, ...prev]); // Newest first
|
|
39
|
+
},
|
|
40
|
+
getHaikus: () => haikus,
|
|
41
|
+
clearHaikus: () => setHaikus([]),
|
|
42
|
+
}));
|
|
43
|
+
return _jsx(HaikuDisplay, { haikus: haikus, title: title });
|
|
44
|
+
});
|
|
45
|
+
HaikuDisplayWithRef.displayName = 'HaikuDisplayWithRef';
|
|
46
|
+
/**
|
|
47
|
+
* AgUiHaikuGenUIExample Component
|
|
48
|
+
*
|
|
49
|
+
* Demonstrates tool-based generative UI with haiku generation.
|
|
50
|
+
* The agent has a `generate_haiku` tool that returns structured
|
|
51
|
+
* haiku data. This data is rendered:
|
|
52
|
+
* - INLINE in the chat as a haiku card
|
|
53
|
+
* - In the main view as part of a carousel
|
|
54
|
+
*
|
|
55
|
+
* Features demonstrated:
|
|
56
|
+
* - Tool-based generative UI
|
|
57
|
+
* - Ref-based state synchronization between chat and main view
|
|
58
|
+
* - Carousel display for multiple haikus
|
|
59
|
+
* - Dynamic gradient backgrounds
|
|
60
|
+
* - Japanese/English text rendering
|
|
61
|
+
*/
|
|
62
|
+
const AgUiHaikuGenUIExample = () => {
|
|
63
|
+
// Ref to the main display for adding haikus
|
|
64
|
+
const displayRef = useRef(null);
|
|
65
|
+
// Track processed tool call IDs to avoid duplicates
|
|
66
|
+
const processedToolCallIds = useRef(new Set());
|
|
67
|
+
/**
|
|
68
|
+
* Render function for tool results - renders haiku cards inline in chat
|
|
69
|
+
* and also updates the main display
|
|
70
|
+
*/
|
|
71
|
+
const renderHaikuToolResult = useCallback((context) => {
|
|
72
|
+
// Only render for the generate_haiku tool
|
|
73
|
+
if (context.toolName !== 'generate_haiku') {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
// Extract haiku data from args (the tool's parameters are what we render)
|
|
77
|
+
const args = context.args;
|
|
78
|
+
// Build haiku result from args
|
|
79
|
+
const haiku = args.japanese && args.english
|
|
80
|
+
? {
|
|
81
|
+
japanese: args.japanese,
|
|
82
|
+
english: args.english,
|
|
83
|
+
gradient: args.gradient ||
|
|
84
|
+
'linear-gradient(135deg, #667eea 0%, #764ba2 100%)',
|
|
85
|
+
}
|
|
86
|
+
: undefined;
|
|
87
|
+
// When tool completes successfully, add to main display (deduplicated)
|
|
88
|
+
if (context.status === 'complete' &&
|
|
89
|
+
haiku &&
|
|
90
|
+
displayRef.current &&
|
|
91
|
+
context.toolCallId &&
|
|
92
|
+
!processedToolCallIds.current.has(context.toolCallId)) {
|
|
93
|
+
processedToolCallIds.current.add(context.toolCallId);
|
|
94
|
+
displayRef.current.addHaiku(haiku);
|
|
95
|
+
}
|
|
96
|
+
return (_jsx(InlineHaikuCard, { haiku: haiku, status: context.status, error: context.error }));
|
|
97
|
+
}, []);
|
|
98
|
+
return (_jsx(DatalayerThemeProvider, { theme: datalayerTheme, children: _jsxs(Box, { sx: {
|
|
99
|
+
minHeight: '100vh',
|
|
100
|
+
backgroundColor: 'canvas.default',
|
|
101
|
+
padding: 4,
|
|
102
|
+
}, children: [_jsxs(Box, { sx: {
|
|
103
|
+
maxWidth: '800px',
|
|
104
|
+
margin: '0 auto',
|
|
105
|
+
}, children: [_jsx(Text, { as: "h1", sx: {
|
|
106
|
+
fontSize: 4,
|
|
107
|
+
fontWeight: 'bold',
|
|
108
|
+
marginBottom: 2,
|
|
109
|
+
}, children: "AG-UI: Haiku Generative UI" }), _jsx(Text, { as: "p", sx: {
|
|
110
|
+
fontSize: 2,
|
|
111
|
+
color: 'fg.muted',
|
|
112
|
+
marginBottom: 4,
|
|
113
|
+
}, children: "Ask the assistant to generate haiku poetry. Haikus appear both in the chat and in the display area below!" }), _jsx(Box, { sx: {
|
|
114
|
+
padding: 5,
|
|
115
|
+
backgroundColor: 'canvas.subtle',
|
|
116
|
+
borderRadius: 2,
|
|
117
|
+
border: '1px solid',
|
|
118
|
+
borderColor: 'border.default',
|
|
119
|
+
marginBottom: 4,
|
|
120
|
+
}, children: _jsx(HaikuDisplayWithRef, { ref: displayRef, title: "Your Haiku Collection" }) }), _jsxs(Box, { sx: {
|
|
121
|
+
padding: 4,
|
|
122
|
+
backgroundColor: 'canvas.subtle',
|
|
123
|
+
borderRadius: 2,
|
|
124
|
+
border: '1px solid',
|
|
125
|
+
borderColor: 'border.default',
|
|
126
|
+
}, children: [_jsx(Text, { as: "h2", sx: { fontSize: 2, fontWeight: 'semibold', marginBottom: 2 }, children: "About This Example" }), _jsxs(Text, { as: "p", sx: { fontSize: 1, color: 'fg.muted' }, children: ["This demonstrates ", _jsx("strong", { children: "tool-based generative UI" }), " with AG-UI. When the agent generates a haiku using the", ' ', _jsx("code", { children: "generate_haiku" }), " tool, it's rendered as a beautiful card both in the chat and in the main display area above."] }), _jsxs(Box, { sx: { marginTop: 3 }, children: [_jsx(Text, { sx: { fontSize: 1, fontWeight: 'medium' }, children: "Features:" }), _jsxs(Box, { as: "ul", sx: {
|
|
127
|
+
paddingLeft: 3,
|
|
128
|
+
marginTop: 1,
|
|
129
|
+
fontSize: 1,
|
|
130
|
+
color: 'fg.muted',
|
|
131
|
+
}, children: [_jsx("li", { children: "\uD83C\uDFA8 Beautiful gradient backgrounds matching mood" }), _jsx("li", { children: "\uD83C\uDDEF\uD83C\uDDF5 Japanese text with English translation" }), _jsx("li", { children: "\uD83D\uDCDA Carousel to browse your haiku collection" }), _jsx("li", { children: "\uD83D\uDD04 Real-time rendering as the tool executes" }), _jsx("li", { children: "\u2728 Synchronized display between chat and main view" })] })] }), _jsxs(Box, { sx: { marginTop: 3 }, children: [_jsx(Text, { sx: { fontSize: 1, fontWeight: 'medium' }, children: "Try these prompts:" }), _jsxs(Box, { as: "ul", sx: {
|
|
132
|
+
paddingLeft: 3,
|
|
133
|
+
marginTop: 1,
|
|
134
|
+
fontSize: 1,
|
|
135
|
+
color: 'fg.muted',
|
|
136
|
+
}, children: [_jsx("li", { children: "\"Write me a haiku about cherry blossoms\"" }), _jsx("li", { children: "\"Create a haiku about coding late at night\"" }), _jsx("li", { children: "\"Generate a haiku about the ocean\"" }), _jsx("li", { children: "\"Write a haiku about autumn leaves\"" })] })] })] })] }), _jsx(ChatFloating, { endpoint: HAIKU_ENDPOINT, title: "Haiku Generator", description: "Ask me to write haiku poetry about any topic!", position: "bottom-right", brandColor: "#667eea", defaultOpen: true, renderToolResult: renderHaikuToolResult, hideMessagesAfterToolUI: true, suggestions: [
|
|
137
|
+
{
|
|
138
|
+
title: 'Cherry blossoms',
|
|
139
|
+
message: 'Write me a haiku about cherry blossoms in spring.',
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
title: 'Night coding',
|
|
143
|
+
message: 'Create a haiku about coding late at night.',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
title: 'Mountain path',
|
|
147
|
+
message: 'Generate a haiku about hiking a mountain trail.',
|
|
148
|
+
},
|
|
149
|
+
] })] }) }));
|
|
150
|
+
};
|
|
151
|
+
export default AgUiHaikuGenUIExample;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgUiHumanInTheLoopExample
|
|
3
|
+
*
|
|
4
|
+
* Demonstrates a floating chat popup that connects to the AG-UI
|
|
5
|
+
* Human in the Loop example backend. This shows how to implement
|
|
6
|
+
* approval workflows where the human must approve generated plans.
|
|
7
|
+
*
|
|
8
|
+
* Backend: /api/v1/examples/human_in_the_loop/
|
|
9
|
+
*
|
|
10
|
+
* Pattern: Uses renderToolResult with respond callback for human-in-the-loop
|
|
11
|
+
* interactions, matching the CopilotKit useHumanInTheLoop pattern.
|
|
12
|
+
*/
|
|
13
|
+
import React from 'react';
|
|
14
|
+
/**
|
|
15
|
+
* AgUiHumanInTheLoopExample Component
|
|
16
|
+
*
|
|
17
|
+
* Demonstrates human-in-the-loop approval patterns with AG-UI.
|
|
18
|
+
* The agent generates task steps that require human approval before proceeding.
|
|
19
|
+
*
|
|
20
|
+
* Features demonstrated:
|
|
21
|
+
* - Tool call rendering with Reject/Confirm buttons
|
|
22
|
+
* - respond callback for sending user decisions back to the agent
|
|
23
|
+
* - UI state changes based on user actions
|
|
24
|
+
*/
|
|
25
|
+
declare const AgUiHumanInTheLoopExample: React.FC;
|
|
26
|
+
export default AgUiHumanInTheLoopExample;
|
|
@@ -0,0 +1,220 @@
|
|
|
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
|
+
* AgUiHumanInTheLoopExample
|
|
8
|
+
*
|
|
9
|
+
* Demonstrates a floating chat popup that connects to the AG-UI
|
|
10
|
+
* Human in the Loop example backend. This shows how to implement
|
|
11
|
+
* approval workflows where the human must approve generated plans.
|
|
12
|
+
*
|
|
13
|
+
* Backend: /api/v1/examples/human_in_the_loop/
|
|
14
|
+
*
|
|
15
|
+
* Pattern: Uses renderToolResult with respond callback for human-in-the-loop
|
|
16
|
+
* interactions, matching the CopilotKit useHumanInTheLoop pattern.
|
|
17
|
+
*/
|
|
18
|
+
import { useState, useEffect } from 'react';
|
|
19
|
+
import { Text, Checkbox, FormControl, Label, ProgressBar, Button, } from '@primer/react';
|
|
20
|
+
import { Box } from '@datalayer/primer-addons';
|
|
21
|
+
import { datalayerTheme, DatalayerThemeProvider } from '@datalayer/core';
|
|
22
|
+
import { ChatFloating } from '../components/chat';
|
|
23
|
+
import { TasklistIcon, CheckCircleFillIcon, XCircleFillIcon, } from '@primer/octicons-react';
|
|
24
|
+
// AG-UI endpoint for human in the loop example
|
|
25
|
+
const HUMAN_IN_THE_LOOP_ENDPOINT = 'http://localhost:8765/api/v1/examples/human_in_the_loop/';
|
|
26
|
+
/**
|
|
27
|
+
* StepsFeedback Component
|
|
28
|
+
*
|
|
29
|
+
* Renders the task steps with Reject/Confirm buttons.
|
|
30
|
+
* Matches the CopilotKit pattern for human-in-the-loop tool rendering.
|
|
31
|
+
*/
|
|
32
|
+
const StepsFeedback = ({ args, status, respond, result }) => {
|
|
33
|
+
const [localSteps, setLocalSteps] = useState([]);
|
|
34
|
+
const [accepted, setAccepted] = useState(null);
|
|
35
|
+
// Helper to normalize steps - handles both string[] and TaskStep[]
|
|
36
|
+
const normalizeSteps = (rawSteps) => {
|
|
37
|
+
if (!rawSteps || !Array.isArray(rawSteps))
|
|
38
|
+
return [];
|
|
39
|
+
return rawSteps.map(step => {
|
|
40
|
+
// Handle string steps (from tool args)
|
|
41
|
+
if (typeof step === 'string') {
|
|
42
|
+
return { description: step, status: 'enabled' };
|
|
43
|
+
}
|
|
44
|
+
// Handle TaskStep objects (from state snapshot)
|
|
45
|
+
return {
|
|
46
|
+
description: step.description || '',
|
|
47
|
+
status: step.status || 'enabled',
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
// Initialize local steps when status becomes executing
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (status === 'executing' && localSteps.length === 0) {
|
|
54
|
+
const normalized = normalizeSteps(args.steps);
|
|
55
|
+
if (normalized.length > 0) {
|
|
56
|
+
setLocalSteps(normalized);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}, [status, args.steps, localSteps.length]);
|
|
60
|
+
// Check if result has accepted status (for completed state)
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (status === 'complete' && result && accepted === null) {
|
|
63
|
+
const r = result;
|
|
64
|
+
if (typeof r.accepted === 'boolean') {
|
|
65
|
+
setAccepted(r.accepted);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}, [status, result, accepted]);
|
|
69
|
+
const normalizedSteps = normalizeSteps(args.steps);
|
|
70
|
+
if (normalizedSteps.length === 0) {
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
73
|
+
const displaySteps = localSteps.length > 0 ? localSteps : normalizedSteps;
|
|
74
|
+
const enabledCount = displaySteps.filter(s => s.status === 'enabled').length;
|
|
75
|
+
const progress = displaySteps.length > 0 ? (enabledCount / displaySteps.length) * 100 : 0;
|
|
76
|
+
const handleStepToggle = (index) => {
|
|
77
|
+
setLocalSteps(prev => prev.map((step, i) => i === index
|
|
78
|
+
? {
|
|
79
|
+
...step,
|
|
80
|
+
status: step.status === 'enabled' ? 'disabled' : 'enabled',
|
|
81
|
+
}
|
|
82
|
+
: step));
|
|
83
|
+
};
|
|
84
|
+
const handleReject = () => {
|
|
85
|
+
if (respond) {
|
|
86
|
+
setAccepted(false);
|
|
87
|
+
respond({ accepted: false });
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const handleConfirm = () => {
|
|
91
|
+
if (respond) {
|
|
92
|
+
setAccepted(true);
|
|
93
|
+
respond({
|
|
94
|
+
accepted: true,
|
|
95
|
+
steps: localSteps.filter(step => step.status === 'enabled'),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
return (_jsxs(Box, { "data-testid": "select-steps", sx: {
|
|
100
|
+
width: '100%',
|
|
101
|
+
padding: 3,
|
|
102
|
+
backgroundColor: 'canvas.subtle',
|
|
103
|
+
borderRadius: 2,
|
|
104
|
+
border: '1px solid',
|
|
105
|
+
borderColor: 'border.default',
|
|
106
|
+
}, children: [_jsxs(Box, { sx: {
|
|
107
|
+
display: 'flex',
|
|
108
|
+
justifyContent: 'space-between',
|
|
109
|
+
alignItems: 'center',
|
|
110
|
+
marginBottom: 3,
|
|
111
|
+
}, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: [_jsx(TasklistIcon, { size: 16 }), _jsx(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: "Select Steps" })] }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: [_jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [enabledCount, "/", displaySteps.length, " Selected"] }), _jsx(Label, { variant: status === 'executing' ? 'accent' : 'secondary', size: "small", children: status === 'executing' ? 'Ready' : 'Waiting' })] })] }), _jsx(ProgressBar, { progress: progress, barSize: "small", sx: { mb: 3 } }), _jsx(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 2, mb: 3 }, children: displaySteps.map((step, index) => (_jsxs(Box, { "data-testid": "step-item", sx: {
|
|
112
|
+
display: 'flex',
|
|
113
|
+
alignItems: 'center',
|
|
114
|
+
gap: 2,
|
|
115
|
+
padding: 2,
|
|
116
|
+
borderRadius: 2,
|
|
117
|
+
backgroundColor: step.status === 'enabled' ? 'success.subtle' : 'canvas.default',
|
|
118
|
+
border: '1px solid',
|
|
119
|
+
borderColor: step.status === 'enabled' ? 'success.muted' : 'border.muted',
|
|
120
|
+
opacity: status !== 'executing' ? 0.7 : 1,
|
|
121
|
+
cursor: status === 'executing' ? 'pointer' : 'default',
|
|
122
|
+
transition: 'all 0.2s ease',
|
|
123
|
+
}, onClick: () => status === 'executing' && handleStepToggle(index), children: [_jsx(FormControl, { disabled: status !== 'executing', children: _jsx(Checkbox, { checked: step.status === 'enabled', onChange: () => handleStepToggle(index), disabled: status !== 'executing' }) }), _jsx(Text, { "data-testid": "step-text", sx: {
|
|
124
|
+
flex: 1,
|
|
125
|
+
fontSize: 1,
|
|
126
|
+
textDecoration: step.status === 'disabled' ? 'line-through' : 'none',
|
|
127
|
+
color: step.status === 'disabled' ? 'fg.muted' : 'fg.default',
|
|
128
|
+
}, children: step.description }), step.status === 'enabled' && (_jsx(CheckCircleFillIcon, { size: 16, className: "color-fg-success" }))] }, index))) }), accepted === null && (_jsxs(Box, { sx: { display: 'flex', justifyContent: 'center', gap: 3, mt: 3 }, children: [_jsxs(Button, { variant: "default", disabled: status !== 'executing', onClick: handleReject, sx: {
|
|
129
|
+
display: 'flex',
|
|
130
|
+
alignItems: 'center',
|
|
131
|
+
gap: 1,
|
|
132
|
+
}, children: [_jsx(XCircleFillIcon, { size: 14 }), "Reject"] }), _jsxs(Button, { variant: "primary", disabled: status !== 'executing', onClick: handleConfirm, sx: {
|
|
133
|
+
display: 'flex',
|
|
134
|
+
alignItems: 'center',
|
|
135
|
+
gap: 1,
|
|
136
|
+
backgroundColor: 'success.emphasis',
|
|
137
|
+
'&:hover': {
|
|
138
|
+
backgroundColor: 'success.emphasis',
|
|
139
|
+
},
|
|
140
|
+
}, children: [_jsx(CheckCircleFillIcon, { size: 14 }), "Confirm", _jsx(Label, { variant: "accent", size: "small", sx: { ml: 1, backgroundColor: 'rgba(255,255,255,0.2)' }, children: enabledCount })] })] })), accepted !== null && (_jsx(Box, { sx: { display: 'flex', justifyContent: 'center', mt: 3 }, children: _jsx(Box, { sx: {
|
|
141
|
+
display: 'flex',
|
|
142
|
+
alignItems: 'center',
|
|
143
|
+
gap: 2,
|
|
144
|
+
px: 4,
|
|
145
|
+
py: 2,
|
|
146
|
+
borderRadius: 2,
|
|
147
|
+
backgroundColor: accepted ? 'success.subtle' : 'danger.subtle',
|
|
148
|
+
border: '1px solid',
|
|
149
|
+
borderColor: accepted ? 'success.muted' : 'danger.muted',
|
|
150
|
+
}, children: accepted ? (_jsxs(_Fragment, { children: [_jsx(CheckCircleFillIcon, { size: 16, className: "color-fg-success" }), _jsx(Text, { sx: { fontWeight: 'semibold', color: 'success.fg' }, children: "Accepted" })] })) : (_jsxs(_Fragment, { children: [_jsx(XCircleFillIcon, { size: 16, className: "color-fg-danger" }), _jsx(Text, { sx: { fontWeight: 'semibold', color: 'danger.fg' }, children: "Rejected" })] })) }) }))] }));
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Render function for the generate_task_steps tool
|
|
154
|
+
*
|
|
155
|
+
* This matches the CopilotKit pattern where:
|
|
156
|
+
* - args: Tool arguments (the steps array)
|
|
157
|
+
* - status: 'inProgress' | 'executing' | 'complete' | 'error'
|
|
158
|
+
* - respond: Callback to send result back (only when status === 'executing')
|
|
159
|
+
* - result: Tool result (only when status === 'complete')
|
|
160
|
+
*/
|
|
161
|
+
const renderTaskStepsTool = (context) => {
|
|
162
|
+
const { toolName, args, status, respond, result } = context;
|
|
163
|
+
// Only render for the generate_task_steps tool
|
|
164
|
+
if (toolName !== 'generate_task_steps') {
|
|
165
|
+
return null;
|
|
166
|
+
}
|
|
167
|
+
return (_jsx(StepsFeedback, { args: args, status: status, respond: respond, result: result }));
|
|
168
|
+
};
|
|
169
|
+
/**
|
|
170
|
+
* AgUiHumanInTheLoopExample Component
|
|
171
|
+
*
|
|
172
|
+
* Demonstrates human-in-the-loop approval patterns with AG-UI.
|
|
173
|
+
* The agent generates task steps that require human approval before proceeding.
|
|
174
|
+
*
|
|
175
|
+
* Features demonstrated:
|
|
176
|
+
* - Tool call rendering with Reject/Confirm buttons
|
|
177
|
+
* - respond callback for sending user decisions back to the agent
|
|
178
|
+
* - UI state changes based on user actions
|
|
179
|
+
*/
|
|
180
|
+
const AgUiHumanInTheLoopExample = () => {
|
|
181
|
+
return (_jsx(DatalayerThemeProvider, { theme: datalayerTheme, children: _jsxs(Box, { sx: {
|
|
182
|
+
minHeight: '100vh',
|
|
183
|
+
backgroundColor: 'canvas.default',
|
|
184
|
+
padding: 4,
|
|
185
|
+
}, children: [_jsxs(Box, { sx: {
|
|
186
|
+
maxWidth: '800px',
|
|
187
|
+
margin: '0 auto',
|
|
188
|
+
}, children: [_jsx(Text, { as: "h1", sx: {
|
|
189
|
+
fontSize: 4,
|
|
190
|
+
fontWeight: 'bold',
|
|
191
|
+
marginBottom: 2,
|
|
192
|
+
}, children: "AG-UI: Human in the Loop Example" }), _jsx(Text, { as: "p", sx: {
|
|
193
|
+
fontSize: 2,
|
|
194
|
+
color: 'fg.muted',
|
|
195
|
+
marginBottom: 4,
|
|
196
|
+
}, children: "This example demonstrates human review workflows. Ask the AI to create a plan, then use the Reject/Confirm buttons to respond." }), _jsxs(Box, { sx: {
|
|
197
|
+
padding: 4,
|
|
198
|
+
backgroundColor: 'canvas.subtle',
|
|
199
|
+
borderRadius: 2,
|
|
200
|
+
border: '1px solid',
|
|
201
|
+
borderColor: 'border.default',
|
|
202
|
+
marginBottom: 4,
|
|
203
|
+
}, children: [_jsx(Text, { as: "h2", sx: { fontSize: 2, fontWeight: 'semibold', marginBottom: 2 }, children: "About This Example" }), _jsx(Text, { as: "p", sx: { fontSize: 1, color: 'fg.muted' }, children: "This demonstrates the \"Human in the Loop\" pattern where AI-generated task plans require human approval before proceeding. The pattern follows CopilotKit's useHumanInTheLoop hook." }), _jsx(Text, { as: "p", sx: { fontSize: 1, color: 'fg.muted', marginTop: 2 }, children: _jsx("strong", { children: "How it works:" }) }), _jsxs(Box, { as: "ul", sx: { fontSize: 1, color: 'fg.muted', mt: 1, pl: 3 }, children: [_jsx("li", { children: "The agent calls the generate_task_steps tool" }), _jsx("li", { children: "A custom UI renders with toggleable steps" }), _jsx("li", { children: "User clicks Reject or Confirm to send response back" }), _jsx("li", { children: "The UI updates to show Rejected or Accepted state" })] }), _jsxs(Text, { as: "p", sx: { fontSize: 1, color: 'fg.muted', marginTop: 2 }, children: [_jsx("strong", { children: "Try:" }), " \"Create a plan to learn machine learning\" or \"Plan a trip to Paris in 5 steps\""] })] }), _jsxs(Box, { sx: {
|
|
204
|
+
padding: 4,
|
|
205
|
+
backgroundColor: 'accent.subtle',
|
|
206
|
+
borderRadius: 2,
|
|
207
|
+
border: '1px solid',
|
|
208
|
+
borderColor: 'accent.muted',
|
|
209
|
+
}, children: [_jsx(Text, { as: "h2", sx: { fontSize: 2, fontWeight: 'semibold', marginBottom: 2 }, children: "Key Concept: respond() Callback" }), _jsxs(Text, { as: "p", sx: { fontSize: 1, color: 'fg.default' }, children: ["The ", _jsx("code", { children: "renderToolResult" }), " function receives a", ' ', _jsx("code", { children: "respond" }), " callback when the tool status is \"executing\". Calling ", _jsxs("code", { children: ["respond(", '{ accepted: true, steps: [...] }', ")"] }), ' ', "sends the user's decision back to the agent, completing the human-in-the-loop interaction."] })] })] }), _jsx(ChatFloating, { endpoint: HUMAN_IN_THE_LOOP_ENDPOINT, title: "Task Planner", description: "I can help you plan tasks. I'll generate steps for your review.", position: "bottom-right", brandColor: "#059669", renderToolResult: renderTaskStepsTool, hideMessagesAfterToolUI: true, suggestions: [
|
|
210
|
+
{
|
|
211
|
+
title: 'Plan a trip',
|
|
212
|
+
message: 'Plan a weekend trip to Paris.',
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
title: 'Organize party',
|
|
216
|
+
message: 'Plan a birthday party for next Saturday.',
|
|
217
|
+
},
|
|
218
|
+
] })] }) }));
|
|
219
|
+
};
|
|
220
|
+
export default AgUiHumanInTheLoopExample;
|