@datalayer/agent-runtimes 1.0.4 → 1.0.5
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/README.md +34 -0
- package/lib/App.js +1 -1
- package/lib/agents/AgentDetails.d.ts +22 -1
- package/lib/agents/AgentDetails.js +34 -47
- package/lib/api/index.d.ts +0 -1
- package/lib/api/index.js +4 -2
- package/lib/chat/Chat.d.ts +5 -106
- package/lib/chat/Chat.js +4 -4
- package/lib/chat/ChatFloating.d.ts +7 -140
- package/lib/chat/ChatFloating.js +2 -2
- package/lib/chat/ChatPopupStandalone.d.ts +8 -47
- package/lib/chat/ChatPopupStandalone.js +3 -3
- package/lib/chat/ChatSidebar.d.ts +4 -69
- package/lib/chat/ChatSidebar.js +2 -2
- package/lib/chat/ChatStandalone.d.ts +4 -54
- package/lib/chat/ChatStandalone.js +3 -3
- package/lib/chat/base/ChatBase.js +1083 -157
- package/lib/chat/header/ChatHeaderBase.d.ts +11 -6
- package/lib/chat/header/ChatHeaderBase.js +18 -16
- package/lib/chat/indicators/McpStatusIndicator.d.ts +7 -4
- package/lib/chat/indicators/McpStatusIndicator.js +7 -32
- package/lib/chat/indicators/SandboxStatusIndicator.d.ts +4 -1
- package/lib/chat/indicators/SandboxStatusIndicator.js +9 -9
- package/lib/chat/indicators/SkillsStatusIndicator.d.ts +7 -0
- package/lib/chat/indicators/SkillsStatusIndicator.js +88 -0
- package/lib/chat/indicators/index.d.ts +1 -0
- package/lib/chat/indicators/index.js +1 -0
- package/lib/chat/messages/ChatMessageList.d.ts +1 -1
- package/lib/chat/messages/ChatMessageList.js +108 -113
- package/lib/chat/prompt/InputFooter.d.ts +19 -6
- package/lib/chat/prompt/InputFooter.js +71 -18
- package/lib/chat/prompt/InputPrompt.d.ts +3 -1
- package/lib/chat/prompt/InputPrompt.js +4 -4
- package/lib/chat/prompt/InputPromptFooter.js +1 -1
- package/lib/chat/prompt/InputPromptLexical.d.ts +3 -1
- package/lib/chat/prompt/InputPromptLexical.js +12 -5
- package/lib/chat/prompt/InputPromptText.d.ts +3 -1
- package/lib/chat/prompt/InputPromptText.js +2 -2
- package/lib/chat/tools/ToolApprovalBanner.js +1 -1
- package/lib/chat/tools/ToolCallDisplay.d.ts +3 -1
- package/lib/chat/tools/ToolCallDisplay.js +2 -2
- package/lib/chat/usage/TokenUsageBar.js +20 -2
- package/lib/client/AgentRuntimesClientContext.d.ts +53 -0
- package/lib/client/AgentRuntimesClientContext.js +55 -0
- package/lib/client/AgentsMixin.d.ts +0 -18
- package/lib/client/AgentsMixin.js +6 -30
- package/lib/client/IAgentRuntimesClient.d.ts +215 -0
- package/lib/client/IAgentRuntimesClient.js +5 -0
- package/lib/client/SdkAgentRuntimesClient.d.ts +151 -0
- package/lib/client/SdkAgentRuntimesClient.js +134 -0
- package/lib/client/index.d.ts +4 -1
- package/lib/client/index.js +3 -1
- package/lib/components/NotificationEventCard.js +5 -1
- package/lib/config/AgentConfiguration.js +3 -3
- package/lib/context/ContextDistribution.d.ts +3 -1
- package/lib/context/ContextDistribution.js +8 -27
- package/lib/context/ContextInspector.d.ts +3 -1
- package/lib/context/ContextInspector.js +19 -67
- package/lib/context/ContextPanel.d.ts +3 -1
- package/lib/context/ContextPanel.js +104 -64
- package/lib/context/ContextUsage.d.ts +3 -1
- package/lib/context/ContextUsage.js +3 -3
- package/lib/context/CostTracker.d.ts +9 -3
- package/lib/context/CostTracker.js +26 -47
- package/lib/context/CostUsageChart.d.ts +12 -0
- package/lib/context/CostUsageChart.js +378 -0
- package/lib/context/GraphFlowChart.d.ts +16 -0
- package/lib/context/GraphFlowChart.js +182 -0
- package/lib/context/TokenUsageChart.d.ts +8 -1
- package/lib/context/TokenUsageChart.js +349 -211
- package/lib/context/TurnGraphChart.d.ts +39 -0
- package/lib/context/TurnGraphChart.js +538 -0
- package/lib/context/otelWsPool.d.ts +20 -0
- package/lib/context/otelWsPool.js +69 -0
- package/lib/examples/A2UiComponentGalleryExample.d.ts +0 -17
- package/lib/examples/A2UiComponentGalleryExample.js +315 -522
- package/lib/examples/A2UiContactCardExample.d.ts +0 -18
- package/lib/examples/A2UiContactCardExample.js +154 -411
- package/lib/examples/A2UiRestaurantExample.d.ts +0 -30
- package/lib/examples/A2UiRestaurantExample.js +114 -212
- package/lib/examples/A2UiViewerExample.d.ts +0 -18
- package/lib/examples/A2UiViewerExample.js +283 -532
- package/lib/examples/AgUiBackendToolRenderingExample.js +1 -1
- package/lib/examples/AgUiHaikuGenUiExample.d.ts +1 -1
- package/lib/examples/AgUiHaikuGenUiExample.js +1 -1
- package/lib/examples/AgentCheckpointsExample.js +13 -27
- package/lib/examples/AgentCodemodeExample.d.ts +4 -6
- package/lib/examples/AgentCodemodeExample.js +591 -169
- package/lib/examples/AgentEvalsExample.js +12 -16
- package/lib/examples/AgentGuardrailsExample.js +370 -64
- package/lib/examples/AgentHooksExample.d.ts +3 -0
- package/lib/examples/AgentHooksExample.js +104 -0
- package/lib/examples/AgentMCPExample.d.ts +3 -0
- package/lib/examples/AgentMCPExample.js +480 -0
- package/lib/examples/AgentMemoryExample.js +13 -17
- package/lib/examples/AgentMonitoringExample.js +260 -199
- package/lib/examples/AgentNotificationsExample.js +49 -17
- package/lib/examples/AgentOtelExample.js +2 -3
- package/lib/examples/AgentOutputsExample.d.ts +11 -6
- package/lib/examples/AgentOutputsExample.js +382 -81
- package/lib/examples/AgentParametersExample.d.ts +3 -0
- package/lib/examples/AgentParametersExample.js +246 -0
- package/lib/examples/AgentSandboxExample.d.ts +2 -2
- package/lib/examples/AgentSandboxExample.js +68 -40
- package/lib/examples/AgentSkillsExample.js +91 -99
- package/lib/examples/{AgentspecExample.js → AgentSpecsExample.js} +10 -21
- package/lib/examples/AgentSubagentsExample.d.ts +14 -0
- package/lib/examples/AgentSubagentsExample.js +228 -0
- package/lib/examples/AgentToolApprovalsExample.js +29 -557
- package/lib/examples/AgentTriggersExample.js +819 -565
- package/lib/examples/ChatCustomExample.js +11 -24
- package/lib/examples/ChatExample.js +7 -24
- package/lib/examples/CopilotKitLexicalExample.js +2 -1
- package/lib/examples/CopilotKitNotebookExample.js +2 -1
- package/lib/examples/HomeExample.d.ts +15 -0
- package/lib/examples/HomeExample.js +77 -0
- package/lib/examples/Lexical2Example.js +4 -2
- package/lib/examples/{LexicalExample.d.ts → LexicalAgentExample.d.ts} +4 -4
- package/lib/examples/{LexicalExample.js → LexicalAgentExample.js} +65 -16
- package/lib/examples/{LexicalSidebarExample.d.ts → LexicalAgentSidebarExample.d.ts} +5 -5
- package/lib/examples/LexicalAgentSidebarExample.js +261 -0
- package/lib/examples/NotebookAgentExample.d.ts +9 -0
- package/lib/examples/NotebookAgentExample.js +192 -0
- package/lib/examples/{NotebookSidebarExample.d.ts → NotebookAgentSidebarExample.d.ts} +2 -2
- package/lib/examples/NotebookAgentSidebarExample.js +221 -0
- package/lib/examples/{DatalayerNotebookExample.d.ts → NotebookCollaborationExample.d.ts} +4 -4
- package/lib/examples/{DatalayerNotebookExample.js → NotebookCollaborationExample.js} +3 -3
- package/lib/examples/NotebookExample.d.ts +4 -7
- package/lib/examples/NotebookExample.js +14 -146
- package/lib/examples/components/AuthRequiredView.d.ts +6 -0
- package/lib/examples/components/AuthRequiredView.js +33 -0
- package/lib/examples/components/ExampleWrapper.d.ts +7 -0
- package/lib/examples/components/ExampleWrapper.js +25 -6
- package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.js +1 -1
- package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.js +1 -1
- package/lib/examples/{ag-ui → components}/haiku/index.d.ts +1 -1
- package/lib/examples/{ag-ui → components}/haiku/index.js +1 -1
- package/lib/examples/components/index.d.ts +3 -0
- package/lib/examples/components/index.js +4 -0
- package/lib/examples/{ag-ui → components}/weather/index.d.ts +1 -1
- package/lib/examples/{ag-ui → components}/weather/index.js +1 -1
- package/lib/examples/example-selector.d.ts +17 -4
- package/lib/examples/example-selector.js +107 -41
- package/lib/examples/index.d.ts +9 -6
- package/lib/examples/index.js +9 -6
- package/lib/examples/main.js +217 -27
- package/lib/examples/utils/a2ui.d.ts +18 -0
- package/lib/examples/utils/a2ui.js +69 -0
- package/lib/examples/utils/a2uiMarkdownProvider.d.ts +7 -0
- package/lib/examples/utils/a2uiMarkdownProvider.js +9 -0
- package/lib/examples/utils/agentId.d.ts +18 -0
- package/lib/examples/utils/agentId.js +54 -0
- package/lib/examples/utils/agents/earthquake-detector.json +11 -11
- package/lib/examples/utils/agents/sales-forecaster.json +11 -11
- package/lib/examples/utils/agents/social-post-generator.json +11 -11
- package/lib/examples/utils/agents/stock-market.json +11 -11
- package/lib/examples/utils/examplesStore.js +82 -27
- package/lib/hooks/index.d.ts +8 -8
- package/lib/hooks/index.js +7 -7
- package/lib/hooks/useA2A.d.ts +2 -3
- package/lib/hooks/useAIAgentsWebSocket.d.ts +43 -4
- package/lib/hooks/useAIAgentsWebSocket.js +118 -12
- package/lib/hooks/useAcp.d.ts +1 -2
- package/lib/hooks/useAgUi.d.ts +1 -1
- package/lib/hooks/{useAgents.d.ts → useAgentRuntimes.d.ts} +39 -2
- package/lib/hooks/{useAgents.js → useAgentRuntimes.js} +125 -15
- package/lib/hooks/useAgentsCatalog.js +1 -1
- package/lib/hooks/useAgentsService.d.ts +2 -2
- package/lib/hooks/useAgentsService.js +7 -7
- package/lib/hooks/useCheckpoints.js +1 -1
- package/lib/hooks/useConfig.d.ts +4 -1
- package/lib/hooks/useConfig.js +10 -3
- package/lib/hooks/useContextSnapshot.d.ts +9 -4
- package/lib/hooks/useContextSnapshot.js +9 -37
- package/lib/hooks/useMonitoring.js +3 -0
- package/lib/hooks/useSandbox.d.ts +20 -8
- package/lib/hooks/useSandbox.js +105 -40
- package/lib/hooks/useSkills.d.ts +23 -5
- package/lib/hooks/useSkills.js +94 -39
- package/lib/hooks/useToolApprovals.d.ts +60 -36
- package/lib/hooks/useToolApprovals.js +318 -69
- package/lib/hooks/useVercelAI.d.ts +1 -1
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -0
- package/lib/inference/index.d.ts +0 -1
- package/lib/middleware/index.d.ts +0 -1
- package/lib/protocols/AGUIAdapter.js +6 -0
- package/lib/protocols/VercelAIAdapter.d.ts +7 -0
- package/lib/protocols/VercelAIAdapter.js +59 -7
- package/lib/specs/agents/agents.d.ts +10 -0
- package/lib/specs/agents/agents.js +2139 -262
- package/lib/specs/agents/index.js +3 -1
- package/lib/specs/envvars.d.ts +1 -0
- package/lib/specs/envvars.js +38 -20
- package/lib/specs/evals.js +6 -6
- package/lib/specs/events.d.ts +3 -10
- package/lib/specs/events.js +127 -84
- package/lib/specs/frontendTools.js +2 -2
- package/lib/specs/guardrails.d.ts +0 -7
- package/lib/specs/guardrails.js +240 -159
- package/lib/specs/index.d.ts +1 -0
- package/lib/specs/index.js +1 -0
- package/lib/specs/mcpServers.js +35 -6
- package/lib/specs/memory.d.ts +0 -2
- package/lib/specs/memory.js +4 -17
- package/lib/specs/models.js +25 -5
- package/lib/specs/notifications.js +102 -18
- package/lib/specs/outputs.js +15 -9
- package/lib/specs/personas.d.ts +41 -0
- package/lib/specs/personas.js +168 -0
- package/lib/specs/skills.d.ts +2 -1
- package/lib/specs/skills.js +41 -23
- package/lib/specs/teams/index.js +3 -1
- package/lib/specs/teams/teams.js +468 -348
- package/lib/specs/tools.js +4 -4
- package/lib/specs/triggers.js +61 -11
- package/lib/stores/agentRuntimeStore.d.ts +204 -0
- package/lib/stores/agentRuntimeStore.js +636 -0
- package/lib/stores/index.d.ts +1 -1
- package/lib/stores/index.js +1 -1
- package/lib/tools/adapters/copilotkit/lexicalHooks.d.ts +1 -2
- package/lib/tools/adapters/copilotkit/lexicalHooks.js +1 -3
- package/lib/tools/adapters/copilotkit/notebookHooks.d.ts +1 -2
- package/lib/tools/adapters/copilotkit/notebookHooks.js +1 -3
- package/lib/tools/index.d.ts +0 -2
- package/lib/tools/index.js +0 -1
- package/lib/types/agentspecs.d.ts +50 -1
- package/lib/types/chat.d.ts +309 -8
- package/lib/types/context.d.ts +27 -0
- package/lib/types/cost.d.ts +2 -2
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +2 -0
- package/lib/types/mcp.d.ts +8 -0
- package/lib/types/models.d.ts +2 -2
- package/lib/types/personas.d.ts +25 -0
- package/lib/types/personas.js +5 -0
- package/lib/types/skills.d.ts +43 -1
- package/lib/types/stream.d.ts +110 -0
- package/lib/types/stream.js +36 -0
- package/lib/utils/utils.d.ts +9 -5
- package/lib/utils/utils.js +9 -5
- package/package.json +13 -9
- package/scripts/codegen/__pycache__/generate_agents.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_events.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
- package/scripts/codegen/generate_agents.py +102 -6
- package/scripts/codegen/generate_events.py +35 -13
- package/scripts/codegen/generate_personas.py +319 -0
- package/scripts/codegen/generate_skills.py +9 -9
- package/scripts/sync-jupyter.sh +26 -7
- package/lib/api/tool-approvals.d.ts +0 -62
- package/lib/api/tool-approvals.js +0 -145
- package/lib/examples/LexicalSidebarExample.js +0 -163
- package/lib/examples/NotebookSidebarExample.js +0 -119
- package/lib/examples/NotebookSimpleExample.d.ts +0 -6
- package/lib/examples/NotebookSimpleExample.js +0 -22
- package/lib/examples/ag-ui/index.d.ts +0 -10
- package/lib/examples/ag-ui/index.js +0 -16
- package/lib/hooks/useAgentsRegistry.d.ts +0 -10
- package/lib/hooks/useAgentsRegistry.js +0 -20
- package/lib/stores/agentsStore.d.ts +0 -123
- package/lib/stores/agentsStore.js +0 -270
- /package/lib/examples/{AgentspecExample.d.ts → AgentSpecsExample.d.ts} +0 -0
- /package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.d.ts +0 -0
- /package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.d.ts +0 -0
- /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.d.ts +0 -0
- /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.js +0 -0
|
@@ -12,36 +12,16 @@
|
|
|
12
12
|
* @module chat/ChatFloating
|
|
13
13
|
*/
|
|
14
14
|
import React from 'react';
|
|
15
|
-
import type {
|
|
16
|
-
import type { ChatBaseProps, ChatViewMode, FrontendToolDefinition, ModelConfig, Protocol, ProtocolConfig, RenderToolResult, Suggestion } from '../types';
|
|
15
|
+
import type { ChatCommonProps, ChatViewMode } from '../types';
|
|
17
16
|
/**
|
|
18
|
-
* ChatFloating props
|
|
17
|
+
* ChatFloating props — extends ChatCommonProps with floating/popup-specific configuration.
|
|
19
18
|
*/
|
|
20
|
-
export interface ChatFloatingProps {
|
|
19
|
+
export interface ChatFloatingProps extends ChatCommonProps {
|
|
21
20
|
/**
|
|
22
|
-
* AG-UI endpoint URL (e.g., http://localhost:8000/api/v1/examples/agentic_chat).
|
|
21
|
+
* AG-UI endpoint URL (e.g., `http://localhost:8000/api/v1/examples/agentic_chat`).
|
|
23
22
|
* When provided with useStore=false, enables AG-UI protocol mode.
|
|
24
23
|
*/
|
|
25
24
|
endpoint?: string;
|
|
26
|
-
/**
|
|
27
|
-
* Protocol type or full configuration.
|
|
28
|
-
*
|
|
29
|
-
* When a `Protocol` string is provided (e.g. `'vercel-ai'`), it overrides the
|
|
30
|
-
* auto-detected protocol from the endpoint URL. When a full `ProtocolConfig`
|
|
31
|
-
* object is provided, it is used directly and takes precedence over endpoint.
|
|
32
|
-
*
|
|
33
|
-
* @default 'vercel-ai'
|
|
34
|
-
*/
|
|
35
|
-
protocol?: Protocol | ProtocolConfig;
|
|
36
|
-
/**
|
|
37
|
-
* Use Zustand store for state management instead of protocol endpoint.
|
|
38
|
-
* @default false
|
|
39
|
-
*/
|
|
40
|
-
useStore?: boolean;
|
|
41
|
-
/** title */
|
|
42
|
-
title?: string;
|
|
43
|
-
/** Description shown in empty state */
|
|
44
|
-
description?: string;
|
|
45
25
|
/** Position of the popup */
|
|
46
26
|
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
47
27
|
/** Default open state */
|
|
@@ -50,46 +30,19 @@ export interface ChatFloatingProps {
|
|
|
50
30
|
width?: number | string;
|
|
51
31
|
/** height */
|
|
52
32
|
height?: number | string;
|
|
53
|
-
/** Show header */
|
|
54
|
-
showHeader?: boolean;
|
|
55
33
|
/** Show the floating button when closed */
|
|
56
34
|
showButton?: boolean;
|
|
57
|
-
/** Show new chat button */
|
|
58
|
-
showNewChatButton?: boolean;
|
|
59
|
-
/** Show clear button */
|
|
60
|
-
showClearButton?: boolean;
|
|
61
|
-
/** Show settings button */
|
|
62
|
-
showSettingsButton?: boolean;
|
|
63
35
|
/** Enable keyboard shortcuts */
|
|
64
36
|
enableKeyboardShortcuts?: boolean;
|
|
65
37
|
/** Toggle shortcut key */
|
|
66
38
|
toggleShortcut?: string;
|
|
67
|
-
/**
|
|
68
|
-
|
|
69
|
-
/** Powered by tag props */
|
|
70
|
-
poweredByProps?: Partial<PoweredByTagProps>;
|
|
71
|
-
/** Enable click outside to close
|
|
39
|
+
/**
|
|
40
|
+
* Enable click outside to close
|
|
72
41
|
* @default false
|
|
73
42
|
*/
|
|
74
43
|
clickOutsideToClose?: boolean;
|
|
75
44
|
/** Enable escape key to close */
|
|
76
45
|
escapeToClose?: boolean;
|
|
77
|
-
/** Custom class name */
|
|
78
|
-
className?: string;
|
|
79
|
-
/** Callback when settings clicked */
|
|
80
|
-
onSettingsClick?: () => void;
|
|
81
|
-
/** Callback when new chat clicked */
|
|
82
|
-
onNewChat?: () => void;
|
|
83
|
-
/** Callback when popup opens */
|
|
84
|
-
onOpen?: () => void;
|
|
85
|
-
/** Callback when popup closes */
|
|
86
|
-
onClose?: () => void;
|
|
87
|
-
/** Callback for state updates (for shared state example) */
|
|
88
|
-
onStateUpdate?: (state: unknown) => void;
|
|
89
|
-
/** Children to render in popup body (custom content) */
|
|
90
|
-
children?: React.ReactNode;
|
|
91
|
-
/** Custom brand icon */
|
|
92
|
-
brandIcon?: React.ReactNode;
|
|
93
46
|
/** Custom button icon when closed */
|
|
94
47
|
buttonIcon?: React.ReactNode;
|
|
95
48
|
/** Button tooltip text */
|
|
@@ -100,34 +53,8 @@ export interface ChatFloatingProps {
|
|
|
100
53
|
offset?: number;
|
|
101
54
|
/** Animation duration (in ms) */
|
|
102
55
|
animationDuration?: number;
|
|
103
|
-
/**
|
|
104
|
-
* Custom render function for tool results.
|
|
105
|
-
* When provided, tool calls will be rendered inline in the chat
|
|
106
|
-
* using this function instead of being hidden.
|
|
107
|
-
*/
|
|
108
|
-
renderToolResult?: RenderToolResult;
|
|
109
|
-
/**
|
|
110
|
-
* Frontend tool definitions to register with the chat.
|
|
111
|
-
* Consistent with Chat and ChatBase.
|
|
112
|
-
*/
|
|
113
|
-
frontendTools?: FrontendToolDefinition[];
|
|
114
56
|
/** Initial state (for shared state example) */
|
|
115
57
|
initialState?: Record<string, unknown>;
|
|
116
|
-
/**
|
|
117
|
-
* Suggestions to show in empty state.
|
|
118
|
-
* When clicked, the suggestion message is populated in the input.
|
|
119
|
-
*/
|
|
120
|
-
suggestions?: Suggestion[];
|
|
121
|
-
/**
|
|
122
|
-
* Whether to automatically submit the message when a suggestion is clicked.
|
|
123
|
-
* @default true
|
|
124
|
-
*/
|
|
125
|
-
submitOnSuggestionClick?: boolean;
|
|
126
|
-
/**
|
|
127
|
-
* Whether to hide assistant messages that follow a rendered tool call UI.
|
|
128
|
-
* @default false
|
|
129
|
-
*/
|
|
130
|
-
hideMessagesAfterToolUI?: boolean;
|
|
131
58
|
/**
|
|
132
59
|
* Default view mode.
|
|
133
60
|
* - 'floating': Full-height floating panel (pinned to right edge with offset)
|
|
@@ -149,70 +76,10 @@ export interface ChatFloatingProps {
|
|
|
149
76
|
* @default false
|
|
150
77
|
*/
|
|
151
78
|
showPanelBackdrop?: boolean;
|
|
152
|
-
/**
|
|
153
|
-
* Override the list of available models.
|
|
154
|
-
* When provided, this list replaces the models returned by the config endpoint.
|
|
155
|
-
* Use this to restrict the model selector to a specific subset of models.
|
|
156
|
-
*/
|
|
157
|
-
availableModels?: ModelConfig[];
|
|
158
|
-
/**
|
|
159
|
-
* Show model selector in footer.
|
|
160
|
-
* @default false
|
|
161
|
-
*/
|
|
162
|
-
showModelSelector?: boolean;
|
|
163
|
-
/**
|
|
164
|
-
* Show tools menu in footer.
|
|
165
|
-
* @default false
|
|
166
|
-
*/
|
|
167
|
-
showToolsMenu?: boolean;
|
|
168
|
-
/**
|
|
169
|
-
* Show skills menu in footer.
|
|
170
|
-
* @default false
|
|
171
|
-
*/
|
|
172
|
-
showSkillsMenu?: boolean;
|
|
173
|
-
/**
|
|
174
|
-
* Show token usage bar between input and selectors.
|
|
175
|
-
* @default true
|
|
176
|
-
*/
|
|
177
|
-
showTokenUsage?: boolean;
|
|
178
|
-
/**
|
|
179
|
-
* Runtime ID used to scope and persist conversation history.
|
|
180
|
-
* When provided, history is fetched on mount from the historyEndpoint.
|
|
181
|
-
*/
|
|
182
|
-
runtimeId?: string;
|
|
183
|
-
/**
|
|
184
|
-
* Endpoint URL for fetching conversation history.
|
|
185
|
-
* Defaults to `{protocol.endpoint}/api/v1/history` when runtimeId is set.
|
|
186
|
-
*/
|
|
187
|
-
historyEndpoint?: string;
|
|
188
|
-
/**
|
|
189
|
-
* Auth token for authenticating with the agent runtime.
|
|
190
|
-
* Used for indicator API calls (MCP status, sandbox status) and history.
|
|
191
|
-
*/
|
|
192
|
-
authToken?: string;
|
|
193
|
-
/**
|
|
194
|
-
* Auth token for the history endpoint.
|
|
195
|
-
*/
|
|
196
|
-
historyAuthToken?: string;
|
|
197
|
-
/**
|
|
198
|
-
* A prompt to append and send after the conversation history is loaded.
|
|
199
|
-
* The message is shown in the chat and sent to the agent exactly once.
|
|
200
|
-
*/
|
|
201
|
-
pendingPrompt?: string;
|
|
202
|
-
/**
|
|
203
|
-
* Show the information icon in the header.
|
|
204
|
-
* When clicked, fires onInformationClick.
|
|
205
|
-
* @default false
|
|
206
|
-
*/
|
|
207
|
-
showInformation?: boolean;
|
|
208
|
-
/** Callback when the information icon is clicked */
|
|
209
|
-
onInformationClick?: () => void;
|
|
210
|
-
/** Additional ChatBase props */
|
|
211
|
-
panelProps?: Partial<ChatBaseProps>;
|
|
212
79
|
}
|
|
213
80
|
/**
|
|
214
81
|
* ChatFloating component
|
|
215
82
|
* A floating chat window built on ChatBase
|
|
216
83
|
*/
|
|
217
|
-
export declare function ChatFloating({ endpoint, protocol: protocolProp, useStore: useStoreMode, title, description, position, defaultOpen, width, height, showHeader, showButton, showNewChatButton, showClearButton, showSettingsButton, enableKeyboardShortcuts, toggleShortcut, showPoweredBy, poweredByProps, clickOutsideToClose, escapeToClose, className, onSettingsClick, onNewChat, onOpen, onClose, onStateUpdate, children, brandIcon, buttonIcon, buttonTooltip, brandColor, offset, animationDuration, renderToolResult, frontendTools, initialState: _initialState, suggestions, submitOnSuggestionClick, hideMessagesAfterToolUI, defaultViewMode, onViewModeChange, showPanelBackdrop, availableModels, showModelSelector, showToolsMenu, showSkillsMenu, showTokenUsage, runtimeId, historyEndpoint, authToken, historyAuthToken, pendingPrompt, showInformation, onInformationClick, panelProps, }: ChatFloatingProps): import("react/jsx-runtime").JSX.Element;
|
|
84
|
+
export declare function ChatFloating({ endpoint, protocol: protocolProp, useStore: useStoreMode, title, description, position, defaultOpen, width, height, showHeader, showButton, showNewChatButton, showClearButton, showSettingsButton, enableKeyboardShortcuts, toggleShortcut, showPoweredBy, poweredByProps, clickOutsideToClose, escapeToClose, className, onSettingsClick, onNewChat, onOpen, onClose, onStateUpdate, children, brandIcon, buttonIcon, buttonTooltip, brandColor, offset, animationDuration, renderToolResult, frontendTools, initialState: _initialState, suggestions, submitOnSuggestionClick, hideMessagesAfterToolUI, defaultViewMode, onViewModeChange, showPanelBackdrop, availableModels, showModelSelector, showToolsMenu, showSkillsMenu, showTokenUsage, runtimeId, historyEndpoint, authToken, historyAuthToken, pendingPrompt, showInformation, onInformationClick, onToolCallStart, onToolCallComplete, showToolApprovalBanner, pendingApprovals, onApproveApproval, onRejectApproval, panelProps, }: ChatFloatingProps): import("react/jsx-runtime").JSX.Element;
|
|
218
85
|
export default ChatFloating;
|
package/lib/chat/ChatFloating.js
CHANGED
|
@@ -43,7 +43,7 @@ function useIsMobile(breakpoint = 640) {
|
|
|
43
43
|
* ChatFloating component
|
|
44
44
|
* A floating chat window built on ChatBase
|
|
45
45
|
*/
|
|
46
|
-
export function ChatFloating({ endpoint, protocol: protocolProp, useStore: useStoreMode = true, title = 'Chat', description = 'Start a conversation with the AI agent.', position = 'bottom-right', defaultOpen = false, width = 400, height = 550, showHeader = true, showButton = true, showNewChatButton = true, showClearButton = true, showSettingsButton = false, enableKeyboardShortcuts = true, toggleShortcut = '/', showPoweredBy = true, poweredByProps, clickOutsideToClose = false, escapeToClose = true, className, onSettingsClick, onNewChat, onOpen, onClose, onStateUpdate, children, brandIcon, buttonIcon, buttonTooltip = 'Chat with AI', brandColor, offset = 20, animationDuration = 200, renderToolResult, frontendTools, initialState: _initialState, suggestions, submitOnSuggestionClick = true, hideMessagesAfterToolUI = false, defaultViewMode = 'floating', onViewModeChange, showPanelBackdrop = false, availableModels, showModelSelector = false, showToolsMenu = false, showSkillsMenu = false, showTokenUsage = true, runtimeId, historyEndpoint, authToken, historyAuthToken, pendingPrompt, showInformation = false, onInformationClick, panelProps, }) {
|
|
46
|
+
export function ChatFloating({ endpoint, protocol: protocolProp, useStore: useStoreMode = true, title = 'Chat', description = 'Start a conversation with the AI agent.', position = 'bottom-right', defaultOpen = false, width = 400, height = 550, showHeader = true, showButton = true, showNewChatButton = true, showClearButton = true, showSettingsButton = false, enableKeyboardShortcuts = true, toggleShortcut = '/', showPoweredBy = true, poweredByProps, clickOutsideToClose = false, escapeToClose = true, className, onSettingsClick, onNewChat, onOpen, onClose, onStateUpdate, children, brandIcon, buttonIcon, buttonTooltip = 'Chat with AI', brandColor, offset = 20, animationDuration = 200, renderToolResult, frontendTools, initialState: _initialState, suggestions, submitOnSuggestionClick = true, hideMessagesAfterToolUI = false, defaultViewMode = 'floating', onViewModeChange, showPanelBackdrop = false, availableModels, showModelSelector = false, showToolsMenu = false, showSkillsMenu = false, showTokenUsage = true, runtimeId, historyEndpoint, authToken, historyAuthToken, pendingPrompt, showInformation = false, onInformationClick, onToolCallStart, onToolCallComplete, showToolApprovalBanner, pendingApprovals, onApproveApproval, onRejectApproval, panelProps, }) {
|
|
47
47
|
// Store-based state
|
|
48
48
|
const storeIsOpen = useChatOpen();
|
|
49
49
|
const storeMessages = useChatMessages();
|
|
@@ -441,6 +441,6 @@ export function ChatFloating({ endpoint, protocol: protocolProp, useStore: useSt
|
|
|
441
441
|
...poweredByProps,
|
|
442
442
|
}, renderToolResult: renderToolResult, description: description, onStateUpdate: onStateUpdate, onNewChat: onNewChat, suggestions: suggestions, submitOnSuggestionClick: submitOnSuggestionClick, hideMessagesAfterToolUI: hideMessagesAfterToolUI, avatarConfig: {
|
|
443
443
|
showAvatars: true,
|
|
444
|
-
}, placeholder: "Type a message...", backgroundColor: "canvas.subtle", frontendTools: frontendTools, showModelSelector: showModelSelector, availableModels: availableModels, showToolsMenu: showToolsMenu, showSkillsMenu: showSkillsMenu, showTokenUsage: showTokenUsage, runtimeId: runtimeId, historyEndpoint: historyEndpoint, historyAuthToken: historyAuthToken, pendingPrompt: pendingPrompt, showInformation: showInformation, onInformationClick: onInformationClick, ...panelProps, children: children }) })] }));
|
|
444
|
+
}, placeholder: "Type a message...", backgroundColor: "canvas.subtle", frontendTools: frontendTools, showModelSelector: showModelSelector, availableModels: availableModels, showToolsMenu: showToolsMenu, showSkillsMenu: showSkillsMenu, showTokenUsage: showTokenUsage, runtimeId: runtimeId, historyEndpoint: historyEndpoint, historyAuthToken: historyAuthToken, pendingPrompt: pendingPrompt, showInformation: showInformation, onInformationClick: onInformationClick, onToolCallStart: onToolCallStart, onToolCallComplete: onToolCallComplete, showToolApprovalBanner: showToolApprovalBanner, pendingApprovals: pendingApprovals, onApproveApproval: onApproveApproval, onRejectApproval: onRejectApproval, ...panelProps, children: children }) })] }));
|
|
445
445
|
}
|
|
446
446
|
export default ChatFloating;
|
|
@@ -9,10 +9,11 @@
|
|
|
9
9
|
* @module chat/ChatPopupStandalone
|
|
10
10
|
*/
|
|
11
11
|
import React from 'react';
|
|
12
|
-
import {
|
|
13
|
-
import { ChatBaseProps, RenderToolResult } from '../types';
|
|
12
|
+
import type { ChatCommonProps } from '../types';
|
|
14
13
|
/**
|
|
15
|
-
* Simple message handler type for standalone usage
|
|
14
|
+
* Simple message handler type for standalone usage.
|
|
15
|
+
* Note: This differs from the shared MessageHandler — it does not receive
|
|
16
|
+
* the full message history.
|
|
16
17
|
*/
|
|
17
18
|
export type MessageHandler = (message: string, options?: {
|
|
18
19
|
onChunk?: (chunk: string) => void;
|
|
@@ -21,18 +22,15 @@ export type MessageHandler = (message: string, options?: {
|
|
|
21
22
|
signal?: AbortSignal;
|
|
22
23
|
}) => Promise<string>;
|
|
23
24
|
/**
|
|
24
|
-
* ChatPopupStandalone props
|
|
25
|
+
* ChatPopupStandalone props — extends ChatCommonProps with popup-specific configuration.
|
|
26
|
+
* Uses its own `onSendMessage` signature (no message history array).
|
|
25
27
|
*/
|
|
26
|
-
export interface ChatPopupStandaloneProps {
|
|
28
|
+
export interface ChatPopupStandaloneProps extends Omit<ChatCommonProps, 'onSendMessage'> {
|
|
27
29
|
/**
|
|
28
30
|
* Handler for sending messages - REQUIRED.
|
|
29
31
|
* This function will be called when the user sends a message.
|
|
30
32
|
*/
|
|
31
33
|
onSendMessage: MessageHandler;
|
|
32
|
-
/** Popup title */
|
|
33
|
-
title?: string;
|
|
34
|
-
/** Description shown in empty state */
|
|
35
|
-
description?: string;
|
|
36
34
|
/** Position of the popup */
|
|
37
35
|
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
38
36
|
/** Default open state */
|
|
@@ -41,44 +39,16 @@ export interface ChatPopupStandaloneProps {
|
|
|
41
39
|
width?: number | string;
|
|
42
40
|
/** Popup height */
|
|
43
41
|
height?: number | string;
|
|
44
|
-
/** Show header */
|
|
45
|
-
showHeader?: boolean;
|
|
46
42
|
/** Show the floating button when closed */
|
|
47
43
|
showButton?: boolean;
|
|
48
|
-
/** Show new chat button */
|
|
49
|
-
showNewChatButton?: boolean;
|
|
50
|
-
/** Show clear button */
|
|
51
|
-
showClearButton?: boolean;
|
|
52
|
-
/** Show settings button */
|
|
53
|
-
showSettingsButton?: boolean;
|
|
54
44
|
/** Enable keyboard shortcuts */
|
|
55
45
|
enableKeyboardShortcuts?: boolean;
|
|
56
46
|
/** Toggle shortcut key */
|
|
57
47
|
toggleShortcut?: string;
|
|
58
|
-
/** Show powered by tag */
|
|
59
|
-
showPoweredBy?: boolean;
|
|
60
|
-
/** Powered by tag props */
|
|
61
|
-
poweredByProps?: Partial<PoweredByTagProps>;
|
|
62
48
|
/** Enable click outside to close */
|
|
63
49
|
clickOutsideToClose?: boolean;
|
|
64
50
|
/** Enable escape key to close */
|
|
65
51
|
escapeToClose?: boolean;
|
|
66
|
-
/** Custom class name */
|
|
67
|
-
className?: string;
|
|
68
|
-
/** Input placeholder */
|
|
69
|
-
placeholder?: string;
|
|
70
|
-
/** Callback when settings clicked */
|
|
71
|
-
onSettingsClick?: () => void;
|
|
72
|
-
/** Callback when new chat clicked */
|
|
73
|
-
onNewChat?: () => void;
|
|
74
|
-
/** Callback when popup opens */
|
|
75
|
-
onOpen?: () => void;
|
|
76
|
-
/** Callback when popup closes */
|
|
77
|
-
onClose?: () => void;
|
|
78
|
-
/** Children to render in popup body (custom content) */
|
|
79
|
-
children?: React.ReactNode;
|
|
80
|
-
/** Custom brand icon */
|
|
81
|
-
brandIcon?: React.ReactNode;
|
|
82
52
|
/** Custom button icon when closed */
|
|
83
53
|
buttonIcon?: React.ReactNode;
|
|
84
54
|
/** Button tooltip text */
|
|
@@ -89,21 +59,12 @@ export interface ChatPopupStandaloneProps {
|
|
|
89
59
|
offset?: number;
|
|
90
60
|
/** Animation duration (in ms) */
|
|
91
61
|
animationDuration?: number;
|
|
92
|
-
/** Enable streaming mode */
|
|
93
|
-
enableStreaming?: boolean;
|
|
94
62
|
/** Empty state message */
|
|
95
63
|
emptyStateMessage?: string;
|
|
96
|
-
/**
|
|
97
|
-
* Custom render function for tool results.
|
|
98
|
-
* When provided, tool calls will be rendered inline in the chat.
|
|
99
|
-
*/
|
|
100
|
-
renderToolResult?: RenderToolResult;
|
|
101
|
-
/** Additional ChatBase props */
|
|
102
|
-
panelProps?: Partial<ChatBaseProps>;
|
|
103
64
|
}
|
|
104
65
|
/**
|
|
105
66
|
* ChatPopupStandalone component
|
|
106
67
|
* A floating popup chat that uses ChatBase with custom onSendMessage handler
|
|
107
68
|
*/
|
|
108
|
-
export declare function ChatPopupStandalone({ onSendMessage, title, description, position, defaultOpen, width, height, showHeader, showButton, showNewChatButton, showClearButton, showSettingsButton, enableKeyboardShortcuts, toggleShortcut, showPoweredBy, poweredByProps, clickOutsideToClose, escapeToClose, className, placeholder, onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, buttonIcon, buttonTooltip, brandColor, offset, animationDuration, enableStreaming, emptyStateMessage, renderToolResult, panelProps, }: ChatPopupStandaloneProps): import("react/jsx-runtime").JSX.Element;
|
|
69
|
+
export declare function ChatPopupStandalone({ onSendMessage, title, description, position, defaultOpen, width, height, showHeader, showButton, showNewChatButton, showClearButton, showSettingsButton, enableKeyboardShortcuts, toggleShortcut, showPoweredBy, poweredByProps, clickOutsideToClose, escapeToClose, className, placeholder, onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, buttonIcon, buttonTooltip, brandColor, offset, animationDuration, enableStreaming, emptyStateMessage, renderToolResult, onToolCallStart, onToolCallComplete, showToolApprovalBanner, pendingApprovals, onApproveApproval, onRejectApproval, panelProps, }: ChatPopupStandaloneProps): import("react/jsx-runtime").JSX.Element;
|
|
109
70
|
export default ChatPopupStandalone;
|
|
@@ -42,7 +42,7 @@ function useIsMobile(breakpoint = 640) {
|
|
|
42
42
|
* ChatPopupStandalone component
|
|
43
43
|
* A floating popup chat that uses ChatBase with custom onSendMessage handler
|
|
44
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, }) {
|
|
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, onToolCallStart, onToolCallComplete, showToolApprovalBanner, pendingApprovals, onApproveApproval, onRejectApproval, panelProps, }) {
|
|
46
46
|
// Use Zustand store for state management
|
|
47
47
|
const isOpen = useChatOpen();
|
|
48
48
|
const messages = useChatMessages();
|
|
@@ -396,11 +396,11 @@ export function ChatPopupStandalone({ onSendMessage, title = 'Chat', description
|
|
|
396
396
|
onNewChat: handleNewChat,
|
|
397
397
|
onClear: handleClear,
|
|
398
398
|
onSettings: onSettingsClick,
|
|
399
|
-
}, headerActions: closeButton, renderToolResult: renderToolResult, description: description, emptyState: {
|
|
399
|
+
}, headerActions: closeButton, renderToolResult: renderToolResult, onToolCallStart: onToolCallStart, onToolCallComplete: onToolCallComplete, description: description, emptyState: {
|
|
400
400
|
title: emptyStateMessage,
|
|
401
401
|
}, avatarConfig: {
|
|
402
402
|
showAvatars: true,
|
|
403
|
-
}, backgroundColor: "canvas.subtle", ...panelProps, children: children }), _jsxs(Box, { sx: {
|
|
403
|
+
}, backgroundColor: "canvas.subtle", showToolApprovalBanner: showToolApprovalBanner, pendingApprovals: pendingApprovals, onApproveApproval: onApproveApproval, onRejectApproval: onRejectApproval, ...panelProps, children: children }), _jsxs(Box, { sx: {
|
|
404
404
|
display: 'flex',
|
|
405
405
|
gap: 2,
|
|
406
406
|
p: 3,
|
|
@@ -1,92 +1,27 @@
|
|
|
1
|
+
import type { ChatCommonProps } from '../types';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
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 chat/ChatSidebar
|
|
3
|
+
* ChatSidebar props — extends ChatCommonProps with sidebar-specific configuration.
|
|
8
4
|
*/
|
|
9
|
-
|
|
10
|
-
import type { PoweredByTagProps } from './display/PoweredByTag';
|
|
11
|
-
import type { ChatBaseProps, MessageHandler, Protocol, ProtocolConfig } from '../types';
|
|
12
|
-
/**
|
|
13
|
-
* ChatSidebar props
|
|
14
|
-
*/
|
|
15
|
-
export interface ChatSidebarProps {
|
|
5
|
+
export interface ChatSidebarProps extends ChatCommonProps {
|
|
16
6
|
/** Sidebar title */
|
|
17
7
|
title?: string;
|
|
18
|
-
/**
|
|
19
|
-
* Protocol type or full configuration.
|
|
20
|
-
*
|
|
21
|
-
* When a `Protocol` string is provided (e.g. `'vercel-ai'`), it is forwarded
|
|
22
|
-
* to ChatBase. When a full `ProtocolConfig` object is provided, it is passed
|
|
23
|
-
* directly via `panelProps`.
|
|
24
|
-
*
|
|
25
|
-
* @default 'vercel-ai'
|
|
26
|
-
*/
|
|
27
|
-
protocol?: Protocol | ProtocolConfig;
|
|
28
8
|
/** Initial open state */
|
|
29
9
|
defaultOpen?: boolean;
|
|
30
10
|
/** Sidebar position */
|
|
31
11
|
position?: 'left' | 'right';
|
|
32
12
|
/** Sidebar width when open */
|
|
33
13
|
width?: number | string;
|
|
34
|
-
/** Show header */
|
|
35
|
-
showHeader?: boolean;
|
|
36
|
-
/** Show new chat button */
|
|
37
|
-
showNewChatButton?: boolean;
|
|
38
|
-
/** Show clear button */
|
|
39
|
-
showClearButton?: boolean;
|
|
40
|
-
/** Show settings button */
|
|
41
|
-
showSettingsButton?: boolean;
|
|
42
14
|
/** Enable keyboard shortcuts */
|
|
43
15
|
enableKeyboardShortcuts?: boolean;
|
|
44
16
|
/** Keyboard shortcut to toggle (default: 'k') */
|
|
45
17
|
toggleShortcut?: string;
|
|
46
|
-
/** Show powered by tag */
|
|
47
|
-
showPoweredBy?: boolean;
|
|
48
|
-
/** Powered by tag props */
|
|
49
|
-
poweredByProps?: Partial<PoweredByTagProps>;
|
|
50
18
|
/** Enable click outside to close */
|
|
51
19
|
clickOutsideToClose?: boolean;
|
|
52
20
|
/** Enable escape key to close */
|
|
53
21
|
escapeToClose?: boolean;
|
|
54
|
-
/** Custom class name */
|
|
55
|
-
className?: string;
|
|
56
|
-
/** Callback when settings clicked */
|
|
57
|
-
onSettingsClick?: () => void;
|
|
58
|
-
/** Callback when new chat clicked */
|
|
59
|
-
onNewChat?: () => void;
|
|
60
|
-
/** Callback when sidebar opens */
|
|
61
|
-
onOpen?: () => void;
|
|
62
|
-
/** Callback when sidebar closes */
|
|
63
|
-
onClose?: () => void;
|
|
64
|
-
/** Children to render in sidebar body (custom content) */
|
|
65
|
-
children?: React.ReactNode;
|
|
66
|
-
/** Custom brand icon */
|
|
67
|
-
brandIcon?: React.ReactNode;
|
|
68
|
-
/**
|
|
69
|
-
* Handler for sending messages.
|
|
70
|
-
* When provided, this is used instead of protocol mode.
|
|
71
|
-
* Signature: `(message, messages, options?) => Promise<string | void>`
|
|
72
|
-
*/
|
|
73
|
-
onSendMessage?: MessageHandler;
|
|
74
|
-
/** Enable streaming mode (default: true) */
|
|
75
|
-
enableStreaming?: boolean;
|
|
76
|
-
/** Input placeholder */
|
|
77
|
-
placeholder?: string;
|
|
78
|
-
/** Description shown in empty state */
|
|
79
|
-
description?: string;
|
|
80
|
-
/**
|
|
81
|
-
* A prompt to append and send after the conversation history is loaded.
|
|
82
|
-
* The message is shown in the chat and sent to the agent exactly once.
|
|
83
|
-
*/
|
|
84
|
-
pendingPrompt?: string;
|
|
85
|
-
/** Additional ChatBase props */
|
|
86
|
-
panelProps?: Partial<ChatBaseProps>;
|
|
87
22
|
}
|
|
88
23
|
/**
|
|
89
24
|
* Chat Sidebar component
|
|
90
25
|
*/
|
|
91
|
-
export declare function ChatSidebar({ title, protocol: protocolProp, defaultOpen, position, width, showHeader, showNewChatButton, showClearButton, showSettingsButton, enableKeyboardShortcuts, toggleShortcut, showPoweredBy, poweredByProps, clickOutsideToClose, className, onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, onSendMessage, enableStreaming, placeholder, description, pendingPrompt, panelProps, }: ChatSidebarProps): import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare function ChatSidebar({ title, protocol: protocolProp, defaultOpen, position, width, showHeader, showNewChatButton, showClearButton, showSettingsButton, enableKeyboardShortcuts, toggleShortcut, showPoweredBy, poweredByProps, clickOutsideToClose, className, onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, onSendMessage, enableStreaming, onToolCallStart, onToolCallComplete, placeholder, description, pendingPrompt, showToolApprovalBanner, pendingApprovals, onApproveApproval, onRejectApproval, panelProps, }: ChatSidebarProps): import("react/jsx-runtime").JSX.Element;
|
|
92
27
|
export default ChatSidebar;
|
package/lib/chat/ChatSidebar.js
CHANGED
|
@@ -37,7 +37,7 @@ function useIsMobile(breakpoint = 640) {
|
|
|
37
37
|
/**
|
|
38
38
|
* Chat Sidebar component
|
|
39
39
|
*/
|
|
40
|
-
export function ChatSidebar({ title = 'Chat', protocol: protocolProp, defaultOpen = true, position = 'right', width = 400, showHeader = true, showNewChatButton = true, showClearButton = true, showSettingsButton = false, enableKeyboardShortcuts = true, toggleShortcut = 'k', showPoweredBy = true, poweredByProps, clickOutsideToClose = true, className, onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, onSendMessage, enableStreaming = true, placeholder = 'Ask a question...', description, pendingPrompt, panelProps, }) {
|
|
40
|
+
export function ChatSidebar({ title = 'Chat', protocol: protocolProp, defaultOpen = true, position = 'right', width = 400, showHeader = true, showNewChatButton = true, showClearButton = true, showSettingsButton = false, enableKeyboardShortcuts = true, toggleShortcut = 'k', showPoweredBy = true, poweredByProps, clickOutsideToClose = true, className, onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, onSendMessage, enableStreaming = true, onToolCallStart, onToolCallComplete, placeholder = 'Ask a question...', description, pendingPrompt, showToolApprovalBanner, pendingApprovals, onApproveApproval, onRejectApproval, panelProps, }) {
|
|
41
41
|
const isOpen = useChatOpen();
|
|
42
42
|
const messages = useChatMessages();
|
|
43
43
|
const setOpen = useChatStore(state => state.setOpen);
|
|
@@ -241,6 +241,6 @@ export function ChatSidebar({ title = 'Chat', protocol: protocolProp, defaultOpe
|
|
|
241
241
|
...poweredByProps,
|
|
242
242
|
}, avatarConfig: {
|
|
243
243
|
showAvatars: true,
|
|
244
|
-
}, placeholder: placeholder, description: description, onSendMessage: onSendMessage, enableStreaming: enableStreaming, pendingPrompt: pendingPrompt, ...panelProps, children: children }) })] }));
|
|
244
|
+
}, placeholder: placeholder, description: description, onSendMessage: onSendMessage, enableStreaming: enableStreaming, onToolCallStart: onToolCallStart, onToolCallComplete: onToolCallComplete, pendingPrompt: pendingPrompt, showToolApprovalBanner: showToolApprovalBanner, pendingApprovals: pendingApprovals, onApproveApproval: onApproveApproval, onRejectApproval: onRejectApproval, ...panelProps, children: children }) })] }));
|
|
245
245
|
}
|
|
246
246
|
export default ChatSidebar;
|
|
@@ -9,25 +9,17 @@
|
|
|
9
9
|
* @module chat/ChatStandalone
|
|
10
10
|
*/
|
|
11
11
|
import React from 'react';
|
|
12
|
-
import {
|
|
13
|
-
import { type ChatBaseProps, type RenderToolResult, type MessageHandler } from '../types';
|
|
12
|
+
import type { ChatCommonProps, MessageHandler } from '../types';
|
|
14
13
|
/**
|
|
15
|
-
* ChatStandalone props
|
|
14
|
+
* ChatStandalone props — extends ChatCommonProps with standalone popup configuration.
|
|
16
15
|
*/
|
|
17
|
-
export interface ChatStandaloneProps {
|
|
16
|
+
export interface ChatStandaloneProps extends ChatCommonProps {
|
|
18
17
|
/**
|
|
19
18
|
* Handler for sending messages - REQUIRED.
|
|
20
19
|
* This function will be called when the user sends a message.
|
|
21
20
|
* Signature: `(message, messages, options?) => Promise<string | void>`
|
|
22
|
-
* - message: The user's message text
|
|
23
|
-
* - messages: All messages in the conversation (including the new user message)
|
|
24
|
-
* - options: Streaming callbacks (onChunk, onComplete, onError, signal)
|
|
25
21
|
*/
|
|
26
22
|
onSendMessage: MessageHandler;
|
|
27
|
-
/** title */
|
|
28
|
-
title?: string;
|
|
29
|
-
/** Description shown in empty state */
|
|
30
|
-
description?: string;
|
|
31
23
|
/** Position of the popup */
|
|
32
24
|
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
33
25
|
/** Default open state */
|
|
@@ -36,44 +28,16 @@ export interface ChatStandaloneProps {
|
|
|
36
28
|
width?: number | string;
|
|
37
29
|
/** height */
|
|
38
30
|
height?: number | string;
|
|
39
|
-
/** Show header */
|
|
40
|
-
showHeader?: boolean;
|
|
41
31
|
/** Show the floating button when closed */
|
|
42
32
|
showButton?: boolean;
|
|
43
|
-
/** Show new chat button */
|
|
44
|
-
showNewChatButton?: boolean;
|
|
45
|
-
/** Show clear button */
|
|
46
|
-
showClearButton?: boolean;
|
|
47
|
-
/** Show settings button */
|
|
48
|
-
showSettingsButton?: boolean;
|
|
49
33
|
/** Enable keyboard shortcuts */
|
|
50
34
|
enableKeyboardShortcuts?: boolean;
|
|
51
35
|
/** Toggle shortcut key */
|
|
52
36
|
toggleShortcut?: string;
|
|
53
|
-
/** Show powered by tag */
|
|
54
|
-
showPoweredBy?: boolean;
|
|
55
|
-
/** Powered by tag props */
|
|
56
|
-
poweredByProps?: Partial<PoweredByTagProps>;
|
|
57
37
|
/** Enable click outside to close */
|
|
58
38
|
clickOutsideToClose?: boolean;
|
|
59
39
|
/** Enable escape key to close */
|
|
60
40
|
escapeToClose?: boolean;
|
|
61
|
-
/** Custom class name */
|
|
62
|
-
className?: string;
|
|
63
|
-
/** Input placeholder */
|
|
64
|
-
placeholder?: string;
|
|
65
|
-
/** Callback when settings clicked */
|
|
66
|
-
onSettingsClick?: () => void;
|
|
67
|
-
/** Callback when new chat clicked */
|
|
68
|
-
onNewChat?: () => void;
|
|
69
|
-
/** Callback when popup opens */
|
|
70
|
-
onOpen?: () => void;
|
|
71
|
-
/** Callback when popup closes */
|
|
72
|
-
onClose?: () => void;
|
|
73
|
-
/** Children to render in popup body (custom content) */
|
|
74
|
-
children?: React.ReactNode;
|
|
75
|
-
/** Custom brand icon */
|
|
76
|
-
brandIcon?: React.ReactNode;
|
|
77
41
|
/** Custom button icon when closed */
|
|
78
42
|
buttonIcon?: React.ReactNode;
|
|
79
43
|
/** Button tooltip text */
|
|
@@ -84,26 +48,12 @@ export interface ChatStandaloneProps {
|
|
|
84
48
|
offset?: number;
|
|
85
49
|
/** Animation duration (in ms) */
|
|
86
50
|
animationDuration?: number;
|
|
87
|
-
/** Enable streaming mode */
|
|
88
|
-
enableStreaming?: boolean;
|
|
89
51
|
/** Empty state message */
|
|
90
52
|
emptyStateMessage?: string;
|
|
91
|
-
/**
|
|
92
|
-
* Custom render function for tool results.
|
|
93
|
-
* When provided, tool calls will be rendered inline in the chat.
|
|
94
|
-
*/
|
|
95
|
-
renderToolResult?: RenderToolResult;
|
|
96
|
-
/**
|
|
97
|
-
* A prompt to append and send after the conversation history is loaded.
|
|
98
|
-
* The message is shown in the chat and sent to the agent exactly once.
|
|
99
|
-
*/
|
|
100
|
-
pendingPrompt?: string;
|
|
101
|
-
/** Additional ChatBase props */
|
|
102
|
-
panelProps?: Partial<ChatBaseProps>;
|
|
103
53
|
}
|
|
104
54
|
/**
|
|
105
55
|
* ChatStandalone component
|
|
106
56
|
* A floating popup chat that uses ChatBase with custom onSendMessage handler
|
|
107
57
|
*/
|
|
108
|
-
export declare function ChatStandalone({ onSendMessage, title, description, position, defaultOpen, width, height, showHeader, showButton, showNewChatButton, showClearButton, showSettingsButton, enableKeyboardShortcuts, toggleShortcut, showPoweredBy, poweredByProps, clickOutsideToClose, escapeToClose, className, placeholder, onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, buttonIcon, buttonTooltip, brandColor, offset, animationDuration, enableStreaming, emptyStateMessage, renderToolResult, pendingPrompt, panelProps, }: ChatStandaloneProps): import("react/jsx-runtime").JSX.Element;
|
|
58
|
+
export declare function ChatStandalone({ onSendMessage, title, description, position, defaultOpen, width, height, showHeader, showButton, showNewChatButton, showClearButton, showSettingsButton, enableKeyboardShortcuts, toggleShortcut, showPoweredBy, poweredByProps, clickOutsideToClose, escapeToClose, className, placeholder, onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, buttonIcon, buttonTooltip, brandColor, offset, animationDuration, enableStreaming, emptyStateMessage, renderToolResult, onToolCallStart, onToolCallComplete, pendingPrompt, showToolApprovalBanner, pendingApprovals, onApproveApproval, onRejectApproval, panelProps, }: ChatStandaloneProps): import("react/jsx-runtime").JSX.Element;
|
|
109
59
|
export default ChatStandalone;
|
|
@@ -41,7 +41,7 @@ function useIsMobile(breakpoint = 640) {
|
|
|
41
41
|
* ChatStandalone component
|
|
42
42
|
* A floating popup chat that uses ChatBase with custom onSendMessage handler
|
|
43
43
|
*/
|
|
44
|
-
export function ChatStandalone({ 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, pendingPrompt, panelProps, }) {
|
|
44
|
+
export function ChatStandalone({ 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, onToolCallStart, onToolCallComplete, pendingPrompt, showToolApprovalBanner, pendingApprovals, onApproveApproval, onRejectApproval, panelProps, }) {
|
|
45
45
|
// Use Zustand store for state management
|
|
46
46
|
const isOpen = useChatOpen();
|
|
47
47
|
const messages = useChatMessages();
|
|
@@ -306,11 +306,11 @@ export function ChatStandalone({ onSendMessage, title = 'Chat', description = 'S
|
|
|
306
306
|
onNewChat: handleNewChat,
|
|
307
307
|
onClear: handleClear,
|
|
308
308
|
onSettings: onSettingsClick,
|
|
309
|
-
}, headerActions: closeButton, renderToolResult: renderToolResult, description: description, placeholder: placeholder, emptyState: {
|
|
309
|
+
}, headerActions: closeButton, renderToolResult: renderToolResult, onToolCallStart: onToolCallStart, onToolCallComplete: onToolCallComplete, description: description, placeholder: placeholder, emptyState: {
|
|
310
310
|
title: emptyStateMessage,
|
|
311
311
|
}, avatarConfig: {
|
|
312
312
|
showAvatars: true,
|
|
313
|
-
}, backgroundColor: "canvas.subtle", focusTrigger: focusTrigger, pendingPrompt: pendingPrompt, ...panelProps, children: children }), showPoweredBy && (_jsx(Box, { sx: {
|
|
313
|
+
}, backgroundColor: "canvas.subtle", focusTrigger: focusTrigger, pendingPrompt: pendingPrompt, showToolApprovalBanner: showToolApprovalBanner, pendingApprovals: pendingApprovals, onApproveApproval: onApproveApproval, onRejectApproval: onRejectApproval, ...panelProps, children: children }), showPoweredBy && (_jsx(Box, { sx: {
|
|
314
314
|
p: 2,
|
|
315
315
|
borderTop: '1px solid',
|
|
316
316
|
borderColor: 'border.default',
|