@datalayer/agent-runtimes 1.0.4 → 1.0.6
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 +182 -1
- package/lib/AgentNode.d.ts +3 -0
- package/lib/AgentNode.js +676 -0
- package/lib/App.js +1 -1
- package/lib/agent-node/themeStore.d.ts +3 -0
- package/lib/agent-node/themeStore.js +156 -0
- package/lib/agent-node-main.d.ts +1 -0
- package/lib/agent-node-main.js +14 -0
- 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 +20 -14
- package/lib/chat/ChatFloating.d.ts +7 -140
- package/lib/chat/ChatFloating.js +3 -3
- 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 +83 -51
- package/lib/chat/ChatStandalone.d.ts +4 -54
- package/lib/chat/ChatStandalone.js +3 -3
- package/lib/chat/base/ChatBase.js +1414 -174
- package/lib/chat/display/FloatingBrandButton.js +8 -1
- package/lib/chat/header/ChatHeader.d.ts +3 -1
- package/lib/chat/header/ChatHeader.js +15 -12
- package/lib/chat/header/ChatHeaderBase.d.ts +30 -5
- package/lib/chat/header/ChatHeaderBase.js +41 -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 +91 -56
- 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 +154 -114
- package/lib/chat/messages/ChatMessages.js +6 -2
- package/lib/chat/prompt/InputFooter.d.ts +21 -6
- package/lib/chat/prompt/InputFooter.js +76 -20
- package/lib/chat/prompt/InputPrompt.d.ts +5 -1
- package/lib/chat/prompt/InputPrompt.js +4 -4
- package/lib/chat/prompt/InputPromptFooter.d.ts +3 -1
- package/lib/chat/prompt/InputPromptFooter.js +3 -3
- 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 +20 -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.d.ts +22 -0
- package/lib/config/AgentConfiguration.js +319 -64
- 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/AgUiSharedStateExample.js +2 -1
- package/lib/examples/AgentCheckpointsExample.js +14 -28
- package/lib/examples/AgentCodemodeExample.d.ts +4 -6
- package/lib/examples/AgentCodemodeExample.js +603 -169
- package/lib/examples/AgentEvalsExample.js +339 -53
- package/lib/examples/AgentGuardrailsExample.js +383 -66
- package/lib/examples/AgentHooksExample.d.ts +3 -0
- package/lib/examples/AgentHooksExample.js +122 -0
- package/lib/examples/AgentInferenceProviderExample.d.ts +3 -0
- package/lib/examples/AgentInferenceProviderExample.js +329 -0
- package/lib/examples/AgentMCPExample.d.ts +3 -0
- package/lib/examples/AgentMCPExample.js +481 -0
- package/lib/examples/AgentMemoryExample.d.ts +1 -2
- package/lib/examples/AgentMemoryExample.js +78 -33
- package/lib/examples/AgentMonitoringExample.js +261 -200
- package/lib/examples/AgentNotificationsExample.d.ts +1 -2
- package/lib/examples/AgentNotificationsExample.js +114 -33
- package/lib/examples/AgentOtelExample.js +32 -42
- package/lib/examples/AgentOutputsExample.d.ts +11 -6
- package/lib/examples/AgentOutputsExample.js +433 -81
- package/lib/examples/AgentParametersExample.d.ts +3 -0
- package/lib/examples/AgentParametersExample.js +248 -0
- package/lib/examples/AgentSandboxExample.d.ts +3 -3
- package/lib/examples/AgentSandboxExample.js +74 -45
- package/lib/examples/AgentSkillsExample.js +95 -103
- package/lib/examples/AgentSubagentsExample.d.ts +14 -0
- package/lib/examples/AgentSubagentsExample.js +228 -0
- package/lib/examples/AgentToolApprovalsExample.js +49 -561
- package/lib/examples/AgentTriggersExample.js +823 -569
- package/lib/examples/{AgentspecExample.d.ts → AgentspecsExample.d.ts} +2 -2
- package/lib/examples/AgentspecsExample.js +1096 -0
- package/lib/examples/ChatCustomExample.js +16 -28
- package/lib/examples/ChatExample.js +13 -29
- 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} +66 -17
- 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 +9 -3
- package/lib/examples/components/ExampleWrapper.js +45 -9
- 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 +108 -41
- package/lib/examples/index.d.ts +10 -6
- package/lib/examples/index.js +10 -6
- package/lib/examples/lexical/initial-content.json +6 -6
- package/lib/examples/main.js +257 -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/examples/utils/useExampleAgentRuntimesUrl.d.ts +5 -0
- package/lib/examples/utils/useExampleAgentRuntimesUrl.js +19 -0
- 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 +153 -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} +70 -4
- package/lib/hooks/{useAgents.js → useAgentRuntimes.js} +237 -32
- 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 +21 -4
- package/lib/specs/agents/agents.js +2879 -316
- package/lib/specs/agents/index.js +3 -1
- package/lib/specs/benchmarks.d.ts +20 -0
- package/lib/specs/benchmarks.js +205 -0
- package/lib/specs/envvars.js +27 -20
- package/lib/specs/evals.d.ts +10 -9
- package/lib/specs/evals.js +128 -88
- 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/mcpServers.js +35 -6
- package/lib/specs/memory.d.ts +0 -2
- package/lib/specs/memory.js +4 -17
- package/lib/specs/models.d.ts +0 -2
- package/lib/specs/models.js +20 -15
- 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 +1 -1
- package/lib/specs/skills.js +23 -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 +208 -0
- package/lib/stores/agentRuntimeStore.js +650 -0
- package/lib/stores/conversationStore.js +2 -2
- 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/agents-lifecycle.d.ts +18 -0
- package/lib/types/agents.d.ts +6 -0
- package/lib/types/agentspecs.d.ts +54 -1
- package/lib/types/benchmarks.d.ts +43 -0
- package/lib/types/benchmarks.js +5 -0
- package/lib/types/chat.d.ts +325 -8
- package/lib/types/context.d.ts +27 -0
- package/lib/types/cost.d.ts +2 -2
- package/lib/types/evals.d.ts +26 -17
- package/lib/types/index.d.ts +3 -0
- package/lib/types/index.js +3 -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 +19 -11
- package/scripts/codegen/__pycache__/generate_agents.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_benchmarks.cpython-313.pyc +0 -0
- package/scripts/codegen/__pycache__/generate_evals.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 +187 -45
- package/scripts/codegen/generate_benchmarks.py +441 -0
- package/scripts/codegen/generate_evals.py +94 -16
- package/scripts/codegen/generate_events.py +35 -14
- 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/AgentspecExample.js +0 -705
- 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/{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
package/lib/chat/Chat.js
CHANGED
|
@@ -63,22 +63,25 @@ const queryClient = new QueryClient();
|
|
|
63
63
|
* Get transport endpoint path
|
|
64
64
|
*/
|
|
65
65
|
function getEndpointPath(protocol, agentId) {
|
|
66
|
+
const resolvedAgentId = typeof agentId === 'string' && agentId.trim().length > 0
|
|
67
|
+
? agentId.trim()
|
|
68
|
+
: 'default';
|
|
66
69
|
switch (protocol) {
|
|
67
70
|
case 'vercel-ai':
|
|
68
|
-
return `/api/v1/vercel-ai/${
|
|
71
|
+
return `/api/v1/vercel-ai/${resolvedAgentId}`;
|
|
69
72
|
case 'vercel-ai-jupyter':
|
|
70
73
|
// Jupyter server endpoint - same protocol as vercel-ai
|
|
71
74
|
// Note: no leading slash - will be joined with baseUrl that may have trailing slash
|
|
72
75
|
return 'agent_runtimes/chat';
|
|
73
76
|
case 'ag-ui':
|
|
74
|
-
return `/api/v1/ag-ui/${
|
|
77
|
+
return `/api/v1/ag-ui/${resolvedAgentId}/`;
|
|
75
78
|
case 'a2a':
|
|
76
79
|
// A2A requires trailing slash for FastA2A compatibility
|
|
77
|
-
return `/api/v1/a2a/agents/${
|
|
80
|
+
return `/api/v1/a2a/agents/${resolvedAgentId}/`;
|
|
78
81
|
case 'acp':
|
|
79
|
-
return `/api/v1/acp/ws/${
|
|
82
|
+
return `/api/v1/acp/ws/${resolvedAgentId}`;
|
|
80
83
|
default:
|
|
81
|
-
return `/api/v1/agents/${
|
|
84
|
+
return `/api/v1/agents/${resolvedAgentId}/chat`;
|
|
82
85
|
}
|
|
83
86
|
}
|
|
84
87
|
/**
|
|
@@ -133,7 +136,10 @@ function getProtocolType(protocol) {
|
|
|
133
136
|
* />
|
|
134
137
|
* ```
|
|
135
138
|
*/
|
|
136
|
-
export function Chat({ protocol: transport, extensions: _extensions, baseUrl = 'http://localhost:8765', wsUrl, agentId, authToken: authTokenProp, placeholder = 'Type your message...', title, brandIcon, autoConnect: _autoConnect = true, streaming: _streaming = true, onMessageSent: _onMessageSent, onMessageReceived: _onMessageReceived, onDisconnect, onLogout: _onLogout, onCollapsePanel: _onCollapsePanel, className, height = '600px', showHeader = true, showNewChatButton = true, showClearButton = true, showModelSelector = true, showToolsMenu = true, showInput = true,
|
|
139
|
+
export function Chat({ protocol: transport, extensions: _extensions, baseUrl = 'http://localhost:8765', wsUrl, agentId, authToken: authTokenProp, placeholder = 'Type your message...', title, subtitle, brandIcon, autoConnect: _autoConnect = true, streaming: _streaming = true, onMessageSent: _onMessageSent, onMessageReceived: _onMessageReceived, onDisconnect, onLogout: _onLogout, onCollapsePanel: _onCollapsePanel, className, height = '600px', showHeader = true, showNewChatButton = true, showClearButton = true, showModelSelector = true, showToolsMenu = true, showInput = true, disableInputPrompt = false, showSkillsMenu = true, codemodeEnabled = false, onToggleCodemode, showTokenUsage = true, initialModel, availableModels, mcpServers, initialSkills, clearOnMount: _clearOnMount = true, suggestions, submitOnSuggestionClick = true, description, headerContent, headerActions, autoFocus = false, identityProviders, onIdentityConnect, onIdentityDisconnect, runtimeId, historyEndpoint, pendingPrompt, errorBanner, showInformation = true, chatViewMode, onChatViewModeChange, frontendTools, onToolCallStart, onToolCallComplete, renderToolResult, hideMessagesAfterToolUI = false, contextSnapshot, mcpStatusData, codemodeStatusData, sandboxStatusData, showToolApprovalBanner, pendingApprovals, onApproveApproval, onRejectApproval, }) {
|
|
140
|
+
const resolvedAgentId = typeof agentId === 'string' && agentId.trim().length > 0
|
|
141
|
+
? agentId.trim()
|
|
142
|
+
: 'default';
|
|
137
143
|
const [error, setError] = useState(null);
|
|
138
144
|
const [isInitializing, setIsInitializing] = useState(true);
|
|
139
145
|
const [showDetails, setShowDetails] = useState(false);
|
|
@@ -201,21 +207,21 @@ export function Chat({ protocol: transport, extensions: _extensions, baseUrl = '
|
|
|
201
207
|
break;
|
|
202
208
|
}
|
|
203
209
|
case 'acp': {
|
|
204
|
-
endpoint = `${baseUrl}${getEndpointPath(transport,
|
|
210
|
+
endpoint = `${baseUrl}${getEndpointPath(transport, resolvedAgentId)}`;
|
|
205
211
|
const acpWsUrl = wsUrl ||
|
|
206
|
-
`${baseUrl.replace('http', 'ws')}/api/v1/acp/ws/${
|
|
212
|
+
`${baseUrl.replace('http', 'ws')}/api/v1/acp/ws/${resolvedAgentId}`;
|
|
207
213
|
options = { wsUrl: acpWsUrl };
|
|
208
214
|
break;
|
|
209
215
|
}
|
|
210
216
|
default: {
|
|
211
|
-
endpoint = `${baseUrl}${getEndpointPath(transport,
|
|
217
|
+
endpoint = `${baseUrl}${getEndpointPath(transport, resolvedAgentId)}`;
|
|
212
218
|
break;
|
|
213
219
|
}
|
|
214
220
|
}
|
|
215
221
|
return {
|
|
216
222
|
type: getProtocolType(transport),
|
|
217
223
|
endpoint,
|
|
218
|
-
agentId,
|
|
224
|
+
agentId: resolvedAgentId,
|
|
219
225
|
authToken,
|
|
220
226
|
options,
|
|
221
227
|
// Enable config query for all protocols to fetch models and tools
|
|
@@ -232,7 +238,7 @@ export function Chat({ protocol: transport, extensions: _extensions, baseUrl = '
|
|
|
232
238
|
setError(err instanceof Error ? err.message : 'Failed to configure');
|
|
233
239
|
return undefined;
|
|
234
240
|
}
|
|
235
|
-
}, [transport, baseUrl, wsUrl,
|
|
241
|
+
}, [transport, baseUrl, wsUrl, resolvedAgentId, authTokenProp]);
|
|
236
242
|
// Set initialized once protocol config is built
|
|
237
243
|
useEffect(() => {
|
|
238
244
|
if (protocolConfig) {
|
|
@@ -285,7 +291,7 @@ export function Chat({ protocol: transport, extensions: _extensions, baseUrl = '
|
|
|
285
291
|
display: showDetails ? 'flex' : 'none',
|
|
286
292
|
flexDirection: 'column',
|
|
287
293
|
height: '100%',
|
|
288
|
-
}, children: _jsx(AgentDetails, { name: title || 'AI Agent', icon: brandIcon, protocol: transport, url: protocolConfig?.endpoint || baseUrl, messageCount: messageCount, agentId: agentId, apiBase: baseUrl, identityProviders: identityProviders, onIdentityConnect: onIdentityConnect, onIdentityDisconnect: onIdentityDisconnect, onBack: () => setShowDetails(false) }) }), _jsxs(Box, { sx: {
|
|
294
|
+
}, children: _jsx(AgentDetails, { name: title || 'AI Agent', icon: brandIcon, protocol: transport, url: protocolConfig?.endpoint || baseUrl, messageCount: messageCount, agentId: agentId, apiBase: baseUrl, identityProviders: identityProviders, onIdentityConnect: onIdentityConnect, onIdentityDisconnect: onIdentityDisconnect, onBack: () => setShowDetails(false), mcpStatusData: mcpStatusData, codemodeStatusData: codemodeStatusData }) }), _jsxs(Box, { sx: {
|
|
289
295
|
display: showDetails ? 'none' : 'flex',
|
|
290
296
|
flexDirection: 'column',
|
|
291
297
|
height: '100%',
|
|
@@ -310,12 +316,12 @@ export function Chat({ protocol: transport, extensions: _extensions, baseUrl = '
|
|
|
310
316
|
? 'attention.fg'
|
|
311
317
|
: 'danger.fg',
|
|
312
318
|
flex: 1,
|
|
313
|
-
}, children: errorBanner.message })] })), _jsx(ChatBase, { title: title, brandIcon: brandIcon, showHeader: showHeader, protocol: protocolConfig, placeholder: placeholder, description: description, suggestions: suggestions, submitOnSuggestionClick: submitOnSuggestionClick, autoFocus: autoFocus, runtimeId: runtimeId, historyEndpoint: historyEndpoint, pendingPrompt: pendingPrompt, showInformation: showInformation, onInformationClick: () => setShowDetails(true), headerContent: headerContent, headerActions: headerActions, showModelSelector: showModelSelector, showToolsMenu: showToolsMenu, showInput: showInput, showSkillsMenu: showSkillsMenu, showTokenUsage: showTokenUsage, codemodeEnabled: codemodeEnabled, initialModel: initialModel, availableModels: availableModels, mcpServers: mcpServers, initialSkills: initialSkills, connectedIdentities: identitiesForChat, onNewChat: handleNewChat, onMessagesChange: messages => setMessageCount(messages.length), headerButtons: {
|
|
319
|
+
}, children: errorBanner.message })] })), _jsx(ChatBase, { title: title, subtitle: subtitle, brandIcon: brandIcon, showHeader: showHeader, protocol: protocolConfig, placeholder: placeholder, description: description, suggestions: suggestions, submitOnSuggestionClick: submitOnSuggestionClick, autoFocus: autoFocus, runtimeId: runtimeId, historyEndpoint: historyEndpoint, pendingPrompt: pendingPrompt, showInformation: showInformation, onInformationClick: () => setShowDetails(true), headerContent: headerContent, headerActions: headerActions, showModelSelector: showModelSelector, showToolsMenu: showToolsMenu, showInput: showInput, disableInputPrompt: disableInputPrompt, showSkillsMenu: showSkillsMenu, showTokenUsage: showTokenUsage, codemodeEnabled: codemodeEnabled, onToggleCodemode: onToggleCodemode, initialModel: initialModel, availableModels: availableModels, mcpServers: mcpServers, initialSkills: initialSkills, connectedIdentities: identitiesForChat, onNewChat: handleNewChat, onMessagesChange: messages => setMessageCount(messages.length), headerButtons: {
|
|
314
320
|
showNewChat: showNewChatButton,
|
|
315
321
|
showClear: showClearButton,
|
|
316
322
|
onNewChat: handleNewChat,
|
|
317
323
|
}, avatarConfig: {
|
|
318
324
|
showAvatars: true,
|
|
319
|
-
}, backgroundColor: "canvas.default", focusTrigger: focusTrigger, chatViewMode: chatViewMode, onChatViewModeChange: onChatViewModeChange, frontendTools: frontendTools, renderToolResult: renderToolResult, hideMessagesAfterToolUI: hideMessagesAfterToolUI })] })] }) }));
|
|
325
|
+
}, backgroundColor: "canvas.default", focusTrigger: focusTrigger, chatViewMode: chatViewMode, onChatViewModeChange: onChatViewModeChange, frontendTools: frontendTools, onToolCallStart: onToolCallStart, onToolCallComplete: onToolCallComplete, renderToolResult: renderToolResult, hideMessagesAfterToolUI: hideMessagesAfterToolUI, contextSnapshot: contextSnapshot, mcpStatusData: mcpStatusData, sandboxStatusData: sandboxStatusData, showToolApprovalBanner: showToolApprovalBanner, pendingApprovals: pendingApprovals, onApproveApproval: onApproveApproval, onRejectApproval: onRejectApproval })] })] }) }));
|
|
320
326
|
}
|
|
321
327
|
export default Chat;
|
|
@@ -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();
|
|
@@ -431,7 +431,7 @@ export function ChatFloating({ endpoint, protocol: protocolProp, useStore: useSt
|
|
|
431
431
|
}, children: _jsx(ChatBase, { title: title, showHeader: showHeader, useStore: useStoreMode, protocol: protocol, autoFocus: isOpen, focusTrigger: focusTrigger, brandIcon: brandIcon || _jsx(AiAgentIcon, { colored: true, size: 20 }), headerButtons: {
|
|
432
432
|
showNewChat: showNewChatButton,
|
|
433
433
|
showClear: showClearButton && messages.length > 0,
|
|
434
|
-
showSettings: showSettingsButton,
|
|
434
|
+
showSettings: showSettingsButton && !!onSettingsClick,
|
|
435
435
|
onNewChat: handleNewChat,
|
|
436
436
|
onClear: handleClear,
|
|
437
437
|
onSettings: onSettingsClick,
|
|
@@ -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;
|