@datalayer/agent-runtimes 0.0.11 → 0.0.12
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 +2 -2
- package/lib/Agent.d.ts +29 -0
- package/lib/Agent.js +131 -0
- package/lib/AgentLexical.d.ts +34 -0
- package/lib/AgentLexical.js +296 -0
- package/lib/AgentNotebook.d.ts +19 -0
- package/lib/AgentNotebook.js +192 -0
- package/lib/agent-lexical-main.d.ts +1 -0
- package/lib/agent-lexical-main.js +11 -0
- package/lib/agent-main.d.ts +1 -0
- package/lib/agent-main.js +11 -0
- package/lib/agent-notebook-main.d.ts +1 -0
- package/lib/agent-notebook-main.js +12 -0
- package/lib/components/AgentConfiguration.d.ts +4 -22
- package/lib/components/AgentConfiguration.js +8 -8
- package/lib/components/chat/components/AgentDetails.d.ts +3 -1
- package/lib/components/chat/components/AgentDetails.js +6 -6
- package/lib/components/chat/components/Chat.d.ts +29 -3
- package/lib/components/chat/components/Chat.js +64 -59
- package/lib/components/chat/components/ChatFloating.d.ts +34 -12
- package/lib/components/chat/components/ChatFloating.js +54 -21
- package/lib/components/chat/components/ChatInline.d.ts +5 -1
- package/lib/components/chat/components/ChatInline.js +8 -1
- package/lib/components/chat/components/ChatSidebar.d.ts +6 -1
- package/lib/components/chat/components/ChatSidebar.js +2 -2
- package/lib/components/chat/components/ChatStandalone.d.ts +6 -1
- package/lib/components/chat/components/ChatStandalone.js +2 -2
- package/lib/components/chat/components/base/ChatBase.d.ts +49 -8
- package/lib/components/chat/components/base/ChatBase.js +544 -149
- package/lib/components/chat/components/base/InputPrompt.d.ts +42 -0
- package/lib/components/chat/components/base/InputPrompt.js +131 -0
- package/lib/components/chat/components/index.d.ts +3 -3
- package/lib/components/chat/components/index.js +1 -1
- package/lib/components/chat/components/parts/ReasoningPart.js +2 -4
- package/lib/components/chat/components/parts/TextPart.js +2 -70
- package/lib/components/chat/components/styles/streamdownStyles.d.ts +23 -0
- package/lib/components/chat/components/styles/streamdownStyles.js +319 -0
- package/lib/components/chat/index.d.ts +1 -1
- package/lib/components/chat/index.js +1 -1
- package/lib/components/chat/inference/DatalayerInferenceProvider.js +16 -12
- package/lib/components/chat/inference/SelfHostedInferenceProvider.js +16 -12
- package/lib/components/chat/protocols/AGUIAdapter.d.ts +10 -3
- package/lib/components/chat/protocols/AGUIAdapter.js +123 -44
- package/lib/components/chat/types/tool.d.ts +5 -2
- package/lib/components/index.d.ts +1 -18
- package/lib/components/index.js +0 -9
- package/lib/config/index.d.ts +0 -4
- package/lib/config/index.js +0 -4
- package/lib/examples/A2UiRestaurantExample.js +1 -1
- package/lib/examples/AgentRuntimeChatExample.d.ts +15 -0
- package/lib/examples/AgentRuntimeChatExample.js +126 -0
- package/lib/examples/{AgentSpaceFormExample.d.ts → AgentRuntimeFormExample.d.ts} +3 -3
- package/lib/examples/{AgentSpaceFormExample.js → AgentRuntimeFormExample.js} +10 -8
- package/lib/examples/AgentRuntimeLexicalExample.js +6 -3
- package/lib/examples/AgentRuntimeLexicalSidebarExample.js +8 -1
- package/lib/examples/AgentRuntimeNotebookExample.js +6 -5
- package/lib/examples/CopilotKitNotebookExample.js +2 -2
- package/lib/examples/JupyterNotebookExample.js +2 -2
- package/lib/{components → examples/components}/Header.d.ts +2 -1
- package/lib/{components → examples/components}/HeaderControls.js +1 -1
- package/lib/{components → examples/components}/LexicalEditor.d.ts +6 -1
- package/lib/{components → examples/components}/LexicalEditor.js +4 -4
- package/lib/{components → examples/components}/MainContent.d.ts +1 -1
- package/lib/{components → examples/components}/MainContent.js +7 -5
- package/lib/examples/components/index.d.ts +16 -0
- package/lib/examples/components/index.js +13 -0
- package/lib/examples/example-selector.js +2 -1
- package/lib/examples/index.d.ts +1 -1
- package/lib/examples/index.js +1 -1
- package/lib/examples/main.js +2 -2
- package/lib/examples/stores/examplesStore.d.ts +2 -23
- package/lib/index.d.ts +2 -1
- package/lib/index.js +1 -0
- package/lib/lexical/ChatInlinePlugin.d.ts +13 -2
- package/lib/lexical/ChatInlinePlugin.js +41 -179
- package/lib/lexical/index.d.ts +1 -0
- package/lib/lexical/index.js +1 -0
- package/lib/lexical/useChatInlineToolbarItems.d.ts +28 -0
- package/lib/lexical/useChatInlineToolbarItems.js +163 -0
- package/lib/runtime/useAgentRuntime.d.ts +1 -1
- package/lib/runtime/useAgentRuntime.js +1 -1
- package/lib/{config/agents/code-ai → specs/agents/codeai}/agents.d.ts +5 -2
- package/lib/specs/agents/codeai/agents.js +151 -0
- package/lib/{config → specs}/agents/codemode-paper/agents.d.ts +4 -2
- package/lib/{config → specs}/agents/codemode-paper/agents.js +39 -19
- package/lib/{config → specs}/agents/datalayer-ai/agents.d.ts +4 -2
- package/lib/{config → specs}/agents/datalayer-ai/agents.js +17 -2
- package/lib/{config → specs}/agents/index.d.ts +3 -1
- package/lib/{config → specs}/agents/index.js +12 -3
- package/lib/{config → specs}/envvars.d.ts +1 -0
- package/lib/{config → specs}/envvars.js +10 -0
- package/lib/specs/index.d.ts +5 -0
- package/lib/specs/index.js +9 -0
- package/lib/{config → specs}/mcpServers.d.ts +2 -1
- package/lib/{config → specs}/mcpServers.js +23 -1
- package/lib/specs/models.d.ts +68 -0
- package/lib/specs/models.js +239 -0
- package/lib/state/substates/AIAgentState.d.ts +0 -1
- package/lib/tools/adapters/agent-runtimes/AgentRuntimesToolAdapter.d.ts +11 -22
- package/lib/tools/adapters/agent-runtimes/AgentRuntimesToolAdapter.js +5 -5
- package/lib/tools/adapters/agent-runtimes/lexicalHooks.d.ts +6 -6
- package/lib/tools/adapters/agent-runtimes/lexicalHooks.js +4 -4
- package/lib/tools/adapters/agent-runtimes/notebookHooks.d.ts +6 -6
- package/lib/tools/adapters/agent-runtimes/notebookHooks.js +4 -4
- package/lib/{types.d.ts → types/Types.d.ts} +32 -6
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/package.json +11 -5
- package/scripts/codegen/generate_agents.py +53 -13
- package/scripts/codegen/generate_envvars.py +1 -1
- package/scripts/codegen/generate_mcp_servers.py +5 -5
- package/scripts/codegen/generate_models.py +486 -0
- package/scripts/codegen/generate_skills.py +2 -2
- package/style/primer-primitives.css +22 -0
- package/lib/components/chat/components/elements/ChatInputPrompt.d.ts +0 -37
- package/lib/components/chat/components/elements/ChatInputPrompt.js +0 -150
- package/lib/config/agents/code-ai/agents.js +0 -70
- /package/lib/{components → examples/components}/FooterMetrics.d.ts +0 -0
- /package/lib/{components → examples/components}/FooterMetrics.js +0 -0
- /package/lib/{components → examples/components}/Header.js +0 -0
- /package/lib/{components → examples/components}/HeaderControls.d.ts +0 -0
- /package/lib/{components → examples/components}/MockFileBrowser.d.ts +0 -0
- /package/lib/{components → examples/components}/MockFileBrowser.js +0 -0
- /package/lib/{components → examples/components}/SessionTabs.d.ts +0 -0
- /package/lib/{components → examples/components}/SessionTabs.js +0 -0
- /package/lib/{components → examples/components}/TimeTravel.d.ts +0 -0
- /package/lib/{components → examples/components}/TimeTravel.js +0 -0
- /package/lib/{config/agents/code-ai → specs/agents/codeai}/index.d.ts +0 -0
- /package/lib/{config/agents/code-ai → specs/agents/codeai}/index.js +0 -0
- /package/lib/{config → specs}/agents/codemode-paper/index.d.ts +0 -0
- /package/lib/{config → specs}/agents/codemode-paper/index.js +0 -0
- /package/lib/{config → specs}/agents/datalayer-ai/index.d.ts +0 -0
- /package/lib/{config → specs}/agents/datalayer-ai/index.js +0 -0
- /package/lib/{config → specs}/skills.d.ts +0 -0
- /package/lib/{config → specs}/skills.js +0 -0
- /package/lib/{types.js → types/Types.js} +0 -0
|
@@ -19,8 +19,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
19
19
|
* @module components/chat/components/Chat
|
|
20
20
|
*/
|
|
21
21
|
import { useEffect, useMemo, useState } from 'react';
|
|
22
|
-
import {
|
|
23
|
-
import {
|
|
22
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
23
|
+
import { Text, Button, Spinner } from '@primer/react';
|
|
24
|
+
import { AlertIcon, SyncIcon } from '@primer/octicons-react';
|
|
24
25
|
import { Box } from '@datalayer/primer-addons';
|
|
25
26
|
import { ChatBase } from './base/ChatBase';
|
|
26
27
|
import { AgentDetails } from './AgentDetails';
|
|
@@ -56,6 +57,8 @@ catch {
|
|
|
56
57
|
// No Jupyter config available
|
|
57
58
|
}
|
|
58
59
|
}
|
|
60
|
+
// Shared QueryClient for AgentDetails and ChatBase
|
|
61
|
+
const queryClient = new QueryClient();
|
|
59
62
|
/**
|
|
60
63
|
* Get transport endpoint path
|
|
61
64
|
*/
|
|
@@ -130,7 +133,7 @@ function getProtocolType(transport) {
|
|
|
130
133
|
* />
|
|
131
134
|
* ```
|
|
132
135
|
*/
|
|
133
|
-
export function Chat({ transport, extensions: _extensions, baseUrl = 'http://localhost:8765', wsUrl, agentId, placeholder = 'Type your message...', title, autoConnect: _autoConnect = true, streaming: _streaming = true, onMessageSent: _onMessageSent, onMessageReceived: _onMessageReceived, onDisconnect, onLogout: _onLogout, onCollapsePanel: _onCollapsePanel, className, height = '600px', showHeader = true, showModelSelector = true, showToolsMenu = true, showSkillsMenu = false, codemodeEnabled = false, showTokenUsage = true, initialModel, availableModels, mcpServers, initialSkills, clearOnMount: _clearOnMount = true, suggestions, submitOnSuggestionClick = true, description, autoFocus = false, identityProviders, onIdentityConnect, onIdentityDisconnect, runtimeId, historyEndpoint, errorBanner, }) {
|
|
136
|
+
export function Chat({ transport, extensions: _extensions, baseUrl = 'http://localhost:8765', wsUrl, agentId, placeholder = 'Type your message...', title, autoConnect: _autoConnect = true, streaming: _streaming = true, onMessageSent: _onMessageSent, onMessageReceived: _onMessageReceived, onDisconnect, onLogout: _onLogout, onCollapsePanel: _onCollapsePanel, className, height = '600px', showHeader = true, showModelSelector = true, showToolsMenu = true, showSkillsMenu = false, codemodeEnabled = false, showTokenUsage = true, initialModel, availableModels, mcpServers, initialSkills, clearOnMount: _clearOnMount = true, suggestions, submitOnSuggestionClick = true, description, autoFocus = false, identityProviders, onIdentityConnect, onIdentityDisconnect, runtimeId, historyEndpoint, pendingPrompt, errorBanner, showInformation = true, chatViewMode, onChatViewModeChange, frontendTools, }) {
|
|
134
137
|
const [error, setError] = useState(null);
|
|
135
138
|
const [isInitializing, setIsInitializing] = useState(true);
|
|
136
139
|
const [showDetails, setShowDetails] = useState(false);
|
|
@@ -250,67 +253,69 @@ export function Chat({ transport, extensions: _extensions, baseUrl = 'http://loc
|
|
|
250
253
|
};
|
|
251
254
|
// Render error state
|
|
252
255
|
if (error) {
|
|
253
|
-
return (_jsxs(Box, { className: className, sx: {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
256
|
+
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsxs(Box, { className: className, sx: {
|
|
257
|
+
display: 'flex',
|
|
258
|
+
flexDirection: 'column',
|
|
259
|
+
alignItems: 'center',
|
|
260
|
+
justifyContent: 'center',
|
|
261
|
+
height,
|
|
262
|
+
p: 4,
|
|
263
|
+
bg: 'canvas.default',
|
|
264
|
+
}, children: [_jsx(AlertIcon, { size: 48 }), _jsx(Text, { sx: { mt: 3, color: 'danger.fg', fontSize: 2 }, children: "Connection Error" }), _jsx(Text, { sx: { mt: 1, color: 'fg.muted', fontSize: 1 }, children: error }), _jsx(Button, { variant: "primary", sx: { mt: 3 }, leadingVisual: SyncIcon, onClick: handleReconnect, children: "Retry" })] }) }));
|
|
262
265
|
}
|
|
263
266
|
// Render loading state
|
|
264
267
|
if (isInitializing || !protocolConfig) {
|
|
265
|
-
return (_jsxs(Box, { className: className, sx: {
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
268
|
+
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsxs(Box, { className: className, sx: {
|
|
269
|
+
display: 'flex',
|
|
270
|
+
flexDirection: 'column',
|
|
271
|
+
alignItems: 'center',
|
|
272
|
+
justifyContent: 'center',
|
|
273
|
+
height,
|
|
274
|
+
p: 4,
|
|
275
|
+
bg: 'canvas.default',
|
|
276
|
+
}, children: [_jsx(Spinner, { size: "large" }), _jsxs(Text, { sx: { mt: 3, color: 'fg.muted' }, children: ["Connecting to ", transport.toUpperCase().replace('-', ' '), " agent..."] })] }) }));
|
|
277
|
+
}
|
|
278
|
+
return (_jsx(QueryClientProvider, { client: queryClient, children: _jsxs(Box, { className: className, sx: {
|
|
279
|
+
position: 'relative',
|
|
270
280
|
height,
|
|
271
|
-
p: 4,
|
|
272
281
|
bg: 'canvas.default',
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
: 'danger.subtle',
|
|
298
|
-
borderBottom: '1px solid',
|
|
299
|
-
borderColor: errorBanner.variant === 'warning'
|
|
300
|
-
? 'attention.muted'
|
|
301
|
-
: 'danger.muted',
|
|
302
|
-
}, children: [_jsx(AlertIcon, { size: 16, fill: errorBanner.variant === 'warning' ? 'attention.fg' : 'danger.fg' }), _jsx(Text, { sx: {
|
|
303
|
-
fontSize: 1,
|
|
304
|
-
color: errorBanner.variant === 'warning'
|
|
282
|
+
display: 'flex',
|
|
283
|
+
flexDirection: 'column',
|
|
284
|
+
}, children: [_jsx(Box, { sx: {
|
|
285
|
+
display: showDetails ? 'flex' : 'none',
|
|
286
|
+
flexDirection: 'column',
|
|
287
|
+
height: '100%',
|
|
288
|
+
}, children: _jsx(AgentDetails, { name: title || 'AI Agent', protocol: transport, url: protocolConfig?.endpoint || baseUrl, messageCount: messageCount, agentId: agentId, apiBase: baseUrl, identityProviders: identityProviders, onIdentityConnect: onIdentityConnect, onIdentityDisconnect: onIdentityDisconnect, onBack: () => setShowDetails(false) }) }), _jsxs(Box, { sx: {
|
|
289
|
+
display: showDetails ? 'none' : 'flex',
|
|
290
|
+
flexDirection: 'column',
|
|
291
|
+
height: '100%',
|
|
292
|
+
}, children: [errorBanner && (_jsxs(Box, { sx: {
|
|
293
|
+
display: 'flex',
|
|
294
|
+
alignItems: 'center',
|
|
295
|
+
gap: 2,
|
|
296
|
+
px: 3,
|
|
297
|
+
py: 2,
|
|
298
|
+
bg: errorBanner.variant === 'warning'
|
|
299
|
+
? 'attention.subtle'
|
|
300
|
+
: 'danger.subtle',
|
|
301
|
+
borderBottom: '1px solid',
|
|
302
|
+
borderColor: errorBanner.variant === 'warning'
|
|
303
|
+
? 'attention.muted'
|
|
304
|
+
: 'danger.muted',
|
|
305
|
+
}, children: [_jsx(AlertIcon, { size: 16, fill: errorBanner.variant === 'warning'
|
|
305
306
|
? 'attention.fg'
|
|
306
|
-
: 'danger.fg',
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
307
|
+
: 'danger.fg' }), _jsx(Text, { sx: {
|
|
308
|
+
fontSize: 1,
|
|
309
|
+
color: errorBanner.variant === 'warning'
|
|
310
|
+
? 'attention.fg'
|
|
311
|
+
: 'danger.fg',
|
|
312
|
+
flex: 1,
|
|
313
|
+
}, children: errorBanner.message })] })), _jsx(ChatBase, { title: title, 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), showModelSelector: showModelSelector, showToolsMenu: showToolsMenu, showSkillsMenu: showSkillsMenu, showTokenUsage: showTokenUsage, codemodeEnabled: codemodeEnabled, initialModel: initialModel, availableModels: availableModels, mcpServers: mcpServers, initialSkills: initialSkills, connectedIdentities: identitiesForChat, onNewChat: handleNewChat, onMessagesChange: messages => setMessageCount(messages.length), headerButtons: {
|
|
314
|
+
showNewChat: true,
|
|
315
|
+
showClear: true,
|
|
316
|
+
onNewChat: handleNewChat,
|
|
317
|
+
}, avatarConfig: {
|
|
318
|
+
showAvatars: true,
|
|
319
|
+
}, backgroundColor: "canvas.default", focusTrigger: focusTrigger, chatViewMode: chatViewMode, onChatViewModeChange: onChatViewModeChange, frontendTools: frontendTools })] })] }) }));
|
|
315
320
|
}
|
|
316
321
|
export default Chat;
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
* @module components/chat/components/ChatFloating
|
|
13
13
|
*/
|
|
14
14
|
import React from 'react';
|
|
15
|
-
import { type ChatBaseProps, type RenderToolResult, type ToolCallRenderContext, type ToolCallStatus, type ProtocolConfig, type RespondCallback, type Suggestion, type RemoteConfig, type ModelConfig, type BuiltinTool, type MCPServerConfig, type MCPServerTool } from './base/ChatBase';
|
|
15
|
+
import { type ChatBaseProps, type RenderToolResult, type ToolCallRenderContext, type ToolCallStatus, type ProtocolConfig, type RespondCallback, type Suggestion, type RemoteConfig, type ModelConfig, type BuiltinTool, type MCPServerConfig, type MCPServerTool, type ChatViewMode } from './base/ChatBase';
|
|
16
16
|
import type { PoweredByTagProps } from './elements/PoweredByTag';
|
|
17
|
-
|
|
17
|
+
import type { FrontendToolDefinition } from '../types/tool';
|
|
18
|
+
export type { ToolCallStatus, ToolCallRenderContext, RenderToolResult, RespondCallback, Suggestion, RemoteConfig, ModelConfig, BuiltinTool, MCPServerConfig, MCPServerTool, ChatViewMode, };
|
|
18
19
|
/**
|
|
19
20
|
* ChatFloating props
|
|
20
21
|
*/
|
|
@@ -100,13 +101,11 @@ export interface ChatFloatingProps {
|
|
|
100
101
|
* using this function instead of being hidden.
|
|
101
102
|
*/
|
|
102
103
|
renderToolResult?: RenderToolResult;
|
|
103
|
-
/**
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
handler: (args: unknown) => Promise<unknown>;
|
|
109
|
-
}>;
|
|
104
|
+
/**
|
|
105
|
+
* Frontend tool definitions to register with the chat.
|
|
106
|
+
* Consistent with Chat and ChatBase.
|
|
107
|
+
*/
|
|
108
|
+
frontendTools?: FrontendToolDefinition[];
|
|
110
109
|
/** Initial state (for shared state example) */
|
|
111
110
|
initialState?: Record<string, unknown>;
|
|
112
111
|
/**
|
|
@@ -126,9 +125,19 @@ export interface ChatFloatingProps {
|
|
|
126
125
|
hideMessagesAfterToolUI?: boolean;
|
|
127
126
|
/**
|
|
128
127
|
* Default view mode.
|
|
128
|
+
* - 'floating': Full-height floating panel (pinned to right edge with offset)
|
|
129
|
+
* - 'floating-small': Standard floating popup
|
|
130
|
+
* - 'panel': Full-height side panel (right edge, no floating offset)
|
|
129
131
|
* @default 'floating'
|
|
130
132
|
*/
|
|
131
|
-
defaultViewMode?: 'floating' | 'panel';
|
|
133
|
+
defaultViewMode?: 'floating' | 'floating-small' | 'panel';
|
|
134
|
+
/**
|
|
135
|
+
* Callback when the user switches view mode via the header toggle.
|
|
136
|
+
* The parent component receives the new ChatViewMode value.
|
|
137
|
+
* When the user selects 'sidebar', the parent should switch to rendering
|
|
138
|
+
* a ChatSidebar instead.
|
|
139
|
+
*/
|
|
140
|
+
onViewModeChange?: (mode: ChatViewMode) => void;
|
|
132
141
|
/**
|
|
133
142
|
* Show backdrop overlay in panel mode.
|
|
134
143
|
* When true, a semi-transparent overlay covers the page behind the panel.
|
|
@@ -168,13 +177,26 @@ export interface ChatFloatingProps {
|
|
|
168
177
|
runtimeId?: string;
|
|
169
178
|
/**
|
|
170
179
|
* Endpoint URL for fetching conversation history.
|
|
171
|
-
* Defaults to `{protocol.endpoint}/history` when runtimeId is set.
|
|
180
|
+
* Defaults to `{protocol.endpoint}/api/v1/history` when runtimeId is set.
|
|
172
181
|
*/
|
|
173
182
|
historyEndpoint?: string;
|
|
174
183
|
/**
|
|
175
184
|
* Auth token for the history endpoint.
|
|
176
185
|
*/
|
|
177
186
|
historyAuthToken?: string;
|
|
187
|
+
/**
|
|
188
|
+
* A prompt to append and send after the conversation history is loaded.
|
|
189
|
+
* The message is shown in the chat and sent to the agent exactly once.
|
|
190
|
+
*/
|
|
191
|
+
pendingPrompt?: string;
|
|
192
|
+
/**
|
|
193
|
+
* Show the information icon in the header.
|
|
194
|
+
* When clicked, fires onInformationClick.
|
|
195
|
+
* @default false
|
|
196
|
+
*/
|
|
197
|
+
showInformation?: boolean;
|
|
198
|
+
/** Callback when the information icon is clicked */
|
|
199
|
+
onInformationClick?: () => void;
|
|
178
200
|
/** Additional ChatBase props */
|
|
179
201
|
panelProps?: Partial<ChatBaseProps>;
|
|
180
202
|
}
|
|
@@ -182,5 +204,5 @@ export interface ChatFloatingProps {
|
|
|
182
204
|
* ChatFloating component
|
|
183
205
|
* A floating chat window built on ChatBase
|
|
184
206
|
*/
|
|
185
|
-
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,
|
|
207
|
+
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, historyAuthToken, pendingPrompt, showInformation, onInformationClick, panelProps, }: ChatFloatingProps): import("react/jsx-runtime").JSX.Element;
|
|
186
208
|
export default ChatFloating;
|
|
@@ -19,7 +19,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
19
19
|
import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
|
|
20
20
|
import { IconButton, Text, Tooltip } from '@primer/react';
|
|
21
21
|
import { Box } from '@datalayer/primer-addons';
|
|
22
|
-
import { XIcon, CommentDiscussionIcon
|
|
22
|
+
import { XIcon, CommentDiscussionIcon } from '@primer/octicons-react';
|
|
23
23
|
import { AiAgentIcon } from '@datalayer/icons-react';
|
|
24
24
|
import { ChatBase, } from './base/ChatBase';
|
|
25
25
|
import { useChatOpen, useChatMessages, useChatStore } from '../store/chatStore';
|
|
@@ -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 = true, escapeToClose = true, className, onSettingsClick, onNewChat, onOpen, onClose, onStateUpdate, children, brandIcon, buttonIcon, buttonTooltip = 'Chat with AI', brandColor = '#7c3aed', offset = 20, animationDuration = 200, renderToolResult,
|
|
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 = true, escapeToClose = true, className, onSettingsClick, onNewChat, onOpen, onClose, onStateUpdate, children, brandIcon, buttonIcon, buttonTooltip = 'Chat with AI', brandColor = '#7c3aed', 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, historyAuthToken, pendingPrompt, showInformation = false, onInformationClick, panelProps, }) {
|
|
47
47
|
// Store-based state
|
|
48
48
|
const storeIsOpen = useChatOpen();
|
|
49
49
|
const storeMessages = useChatMessages();
|
|
@@ -61,6 +61,22 @@ export function ChatFloating({ endpoint, protocol: protocolProp, useStore: useSt
|
|
|
61
61
|
const [isHovered, setIsHovered] = useState(false);
|
|
62
62
|
const [viewMode, setViewMode] = useState(defaultViewMode);
|
|
63
63
|
const [focusTrigger, setFocusTrigger] = useState(0);
|
|
64
|
+
// Map internal viewMode to ChatViewMode for the header toggle
|
|
65
|
+
const chatViewMode = viewMode === 'panel' ? 'sidebar' : viewMode;
|
|
66
|
+
// Handle view mode changes from the header segmented toggle
|
|
67
|
+
const handleChatViewModeChange = useCallback((mode) => {
|
|
68
|
+
if (mode === 'sidebar') {
|
|
69
|
+
// 'sidebar' means the parent should switch to a ChatSidebar layout.
|
|
70
|
+
// Notify parent and let it handle the transition.
|
|
71
|
+
onViewModeChange?.(mode);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
// 'floating' or 'floating-small' stays within ChatFloating
|
|
75
|
+
setViewMode(mode);
|
|
76
|
+
setFocusTrigger(prev => prev + 1);
|
|
77
|
+
onViewModeChange?.(mode);
|
|
78
|
+
}
|
|
79
|
+
}, [onViewModeChange]);
|
|
64
80
|
// Build protocol config from endpoint if not provided directly
|
|
65
81
|
// Memoize to avoid creating new object on every render (which would trigger useEffect re-runs)
|
|
66
82
|
const protocol = useMemo(() => {
|
|
@@ -258,13 +274,6 @@ export function ChatFloating({ endpoint, protocol: protocolProp, useStore: useSt
|
|
|
258
274
|
borderRadius: 0,
|
|
259
275
|
}
|
|
260
276
|
: {};
|
|
261
|
-
// Toggle view mode handler
|
|
262
|
-
const handleToggleViewMode = useCallback(() => {
|
|
263
|
-
setViewMode(prev => (prev === 'floating' ? 'panel' : 'floating'));
|
|
264
|
-
setFocusTrigger(prev => prev + 1);
|
|
265
|
-
}, []);
|
|
266
|
-
// View mode toggle button
|
|
267
|
-
const viewModeToggle = !isMobile && (_jsx(Tooltip, { text: viewMode === 'floating' ? 'Expand to panel' : 'Collapse to popup', direction: "s", children: _jsx(IconButton, { icon: viewMode === 'floating' ? SidebarExpandIcon : SidebarCollapseIcon, "aria-label": viewMode === 'floating' ? 'Expand to panel' : 'Collapse to popup', onClick: handleToggleViewMode, variant: "invisible", size: "small" }) }));
|
|
268
277
|
// Close button for header
|
|
269
278
|
const closeButton = (_jsx(Tooltip, { text: `Close${escapeToClose ? ' (Esc)' : ''}`, direction: "s", children: _jsx(IconButton, { icon: XIcon, "aria-label": "Close", onClick: handleToggle, variant: "invisible", size: "small" }) }));
|
|
270
279
|
return (_jsxs(_Fragment, { children: [showButton && !isOpen && (_jsx(Box, { sx: {
|
|
@@ -344,7 +353,19 @@ export function ChatFloating({ endpoint, protocol: protocolProp, useStore: useSt
|
|
|
344
353
|
zIndex: 1000,
|
|
345
354
|
}, onClick: handleToggle })), _jsx(Box, { ref: popupRef, className: className, sx: {
|
|
346
355
|
position: 'fixed',
|
|
347
|
-
|
|
356
|
+
// floating (normal) — full-height column pinned to the right edge
|
|
357
|
+
...(viewMode === 'floating' && !isMobile
|
|
358
|
+
? {
|
|
359
|
+
top: 0,
|
|
360
|
+
right: 0,
|
|
361
|
+
bottom: 0,
|
|
362
|
+
left: 'auto',
|
|
363
|
+
}
|
|
364
|
+
: {}),
|
|
365
|
+
// floating-small — standard popup positioned via getPositionStyles()
|
|
366
|
+
...(viewMode === 'floating-small' && !isMobile
|
|
367
|
+
? getPositionStyles()
|
|
368
|
+
: {}),
|
|
348
369
|
...(viewMode === 'panel' && !isMobile
|
|
349
370
|
? {
|
|
350
371
|
top: 0,
|
|
@@ -355,18 +376,30 @@ export function ChatFloating({ endpoint, protocol: protocolProp, useStore: useSt
|
|
|
355
376
|
: {}),
|
|
356
377
|
width: viewMode === 'panel' && !isMobile
|
|
357
378
|
? '420px'
|
|
358
|
-
: isMobile
|
|
359
|
-
? '
|
|
360
|
-
: typeof popupWidth === 'number'
|
|
379
|
+
: viewMode === 'floating' && !isMobile
|
|
380
|
+
? typeof popupWidth === 'number'
|
|
361
381
|
? `${popupWidth}px`
|
|
362
|
-
: popupWidth
|
|
363
|
-
|
|
382
|
+
: popupWidth
|
|
383
|
+
: viewMode === 'floating-small' && !isMobile
|
|
384
|
+
? typeof popupWidth === 'number'
|
|
385
|
+
? `${popupWidth}px`
|
|
386
|
+
: popupWidth
|
|
387
|
+
: isMobile
|
|
388
|
+
? '100%'
|
|
389
|
+
: typeof popupWidth === 'number'
|
|
390
|
+
? `${popupWidth}px`
|
|
391
|
+
: popupWidth,
|
|
392
|
+
height: (viewMode === 'panel' || viewMode === 'floating') && !isMobile
|
|
364
393
|
? 'auto'
|
|
365
|
-
: isMobile
|
|
366
|
-
? '
|
|
367
|
-
: typeof popupHeight === 'number'
|
|
394
|
+
: viewMode === 'floating-small' && !isMobile
|
|
395
|
+
? typeof popupHeight === 'number'
|
|
368
396
|
? `${popupHeight}px`
|
|
369
|
-
: popupHeight
|
|
397
|
+
: popupHeight
|
|
398
|
+
: isMobile
|
|
399
|
+
? '100%'
|
|
400
|
+
: typeof popupHeight === 'number'
|
|
401
|
+
? `${popupHeight}px`
|
|
402
|
+
: popupHeight,
|
|
370
403
|
display: 'flex',
|
|
371
404
|
flexDirection: 'column',
|
|
372
405
|
bg: 'canvas.default',
|
|
@@ -394,12 +427,12 @@ export function ChatFloating({ endpoint, protocol: protocolProp, useStore: useSt
|
|
|
394
427
|
onNewChat: handleNewChat,
|
|
395
428
|
onClear: handleClear,
|
|
396
429
|
onSettings: onSettingsClick,
|
|
397
|
-
}, headerActions:
|
|
430
|
+
}, headerActions: _jsx(_Fragment, { children: closeButton }), chatViewMode: chatViewMode, onChatViewModeChange: handleChatViewModeChange, showPoweredBy: showPoweredBy, poweredByProps: {
|
|
398
431
|
brandName: 'Datalayer',
|
|
399
432
|
brandUrl: 'https://datalayer.ai',
|
|
400
433
|
...poweredByProps,
|
|
401
434
|
}, renderToolResult: renderToolResult, description: description, onStateUpdate: onStateUpdate, onNewChat: onNewChat, suggestions: suggestions, submitOnSuggestionClick: submitOnSuggestionClick, hideMessagesAfterToolUI: hideMessagesAfterToolUI, avatarConfig: {
|
|
402
435
|
showAvatars: true,
|
|
403
|
-
}, placeholder: "Type a message...", backgroundColor: "canvas.subtle", frontendTools:
|
|
436
|
+
}, 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 }) })] }));
|
|
404
437
|
}
|
|
405
438
|
export default ChatFloating;
|
|
@@ -34,9 +34,13 @@ export interface ChatInlineProps {
|
|
|
34
34
|
onSaveSelection?: () => void;
|
|
35
35
|
/** Callback to restore selection after input blur */
|
|
36
36
|
onRestoreSelection?: () => void;
|
|
37
|
+
/** A pending prompt to submit automatically (from toolbar dropdown action) */
|
|
38
|
+
pendingPrompt?: string | null;
|
|
39
|
+
/** Callback after the pending prompt has been consumed */
|
|
40
|
+
onPendingPromptConsumed?: () => void;
|
|
37
41
|
}
|
|
38
42
|
/**
|
|
39
43
|
* ChatInline - Inline AI chat component for text selection assistance.
|
|
40
44
|
*/
|
|
41
|
-
export declare function ChatInline({ selectedText, protocol, onReplaceSelection, onInsertInline, onInsertBelow, onClose, onSaveSelection, onRestoreSelection, }: ChatInlineProps): JSX.Element;
|
|
45
|
+
export declare function ChatInline({ selectedText, protocol, onReplaceSelection, onInsertInline, onInsertBelow, onClose, onSaveSelection, onRestoreSelection, pendingPrompt, onPendingPromptConsumed, }: ChatInlineProps): JSX.Element;
|
|
42
46
|
export default ChatInline;
|
|
@@ -91,7 +91,7 @@ const AI_OPTIONS_GROUPS = [
|
|
|
91
91
|
/**
|
|
92
92
|
* ChatInline - Inline AI chat component for text selection assistance.
|
|
93
93
|
*/
|
|
94
|
-
export function ChatInline({ selectedText, protocol, onReplaceSelection, onInsertInline, onInsertBelow, onClose, onSaveSelection, onRestoreSelection, }) {
|
|
94
|
+
export function ChatInline({ selectedText, protocol, onReplaceSelection, onInsertInline, onInsertBelow, onClose, onSaveSelection, onRestoreSelection, pendingPrompt, onPendingPromptConsumed, }) {
|
|
95
95
|
// Input state
|
|
96
96
|
const [input, setInput] = useState('');
|
|
97
97
|
// AI state
|
|
@@ -195,6 +195,13 @@ ${selectedText || ''}
|
|
|
195
195
|
setAiState('initial');
|
|
196
196
|
}
|
|
197
197
|
}, [selectedText]);
|
|
198
|
+
// Handle pending prompt from toolbar dropdown
|
|
199
|
+
useEffect(() => {
|
|
200
|
+
if (pendingPrompt && aiState === 'initial') {
|
|
201
|
+
submitPrompt(pendingPrompt);
|
|
202
|
+
onPendingPromptConsumed?.();
|
|
203
|
+
}
|
|
204
|
+
}, [pendingPrompt, aiState, submitPrompt, onPendingPromptConsumed]);
|
|
198
205
|
// Handle form submission
|
|
199
206
|
const handleSubmit = useCallback((e) => {
|
|
200
207
|
e.preventDefault();
|
|
@@ -68,11 +68,16 @@ export interface ChatSidebarProps {
|
|
|
68
68
|
placeholder?: string;
|
|
69
69
|
/** Description shown in empty state */
|
|
70
70
|
description?: string;
|
|
71
|
+
/**
|
|
72
|
+
* A prompt to append and send after the conversation history is loaded.
|
|
73
|
+
* The message is shown in the chat and sent to the agent exactly once.
|
|
74
|
+
*/
|
|
75
|
+
pendingPrompt?: string;
|
|
71
76
|
/** Additional ChatBase props */
|
|
72
77
|
panelProps?: Partial<ChatBaseProps>;
|
|
73
78
|
}
|
|
74
79
|
/**
|
|
75
80
|
* Chat Sidebar component
|
|
76
81
|
*/
|
|
77
|
-
export declare function ChatSidebar({ title, defaultOpen, position, width, showHeader, showNewChatButton, showClearButton, showSettingsButton, enableKeyboardShortcuts, toggleShortcut, showPoweredBy, poweredByProps, clickOutsideToClose, escapeToClose, className, onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, onSendMessage, enableStreaming, placeholder, description, panelProps, }: ChatSidebarProps): import("react/jsx-runtime").JSX.Element;
|
|
82
|
+
export declare function ChatSidebar({ title, defaultOpen, position, width, showHeader, showNewChatButton, showClearButton, showSettingsButton, enableKeyboardShortcuts, toggleShortcut, showPoweredBy, poweredByProps, clickOutsideToClose, escapeToClose, className, onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, onSendMessage, enableStreaming, placeholder, description, pendingPrompt, panelProps, }: ChatSidebarProps): import("react/jsx-runtime").JSX.Element;
|
|
78
83
|
export default ChatSidebar;
|
|
@@ -37,7 +37,7 @@ function useIsMobile(breakpoint = 640) {
|
|
|
37
37
|
/**
|
|
38
38
|
* Chat Sidebar component
|
|
39
39
|
*/
|
|
40
|
-
export function ChatSidebar({ title = 'Chat', defaultOpen = true, position = 'right', width = 400, showHeader = true, showNewChatButton = true, showClearButton = true, showSettingsButton = false, enableKeyboardShortcuts = true, toggleShortcut = 'k', showPoweredBy = true, poweredByProps, clickOutsideToClose = true, escapeToClose = true, className, onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, onSendMessage, enableStreaming = true, placeholder = 'Ask a question...', description, panelProps, }) {
|
|
40
|
+
export function ChatSidebar({ title = 'Chat', defaultOpen = true, position = 'right', width = 400, showHeader = true, showNewChatButton = true, showClearButton = true, showSettingsButton = false, enableKeyboardShortcuts = true, toggleShortcut = 'k', showPoweredBy = true, poweredByProps, clickOutsideToClose = true, escapeToClose = true, className, onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, onSendMessage, enableStreaming = true, placeholder = 'Ask a question...', description, pendingPrompt, panelProps, }) {
|
|
41
41
|
const isOpen = useChatOpen();
|
|
42
42
|
const messages = useChatMessages();
|
|
43
43
|
const setOpen = useChatStore(state => state.setOpen);
|
|
@@ -219,6 +219,6 @@ export function ChatSidebar({ title = 'Chat', defaultOpen = true, position = 'ri
|
|
|
219
219
|
...poweredByProps,
|
|
220
220
|
}, avatarConfig: {
|
|
221
221
|
showAvatars: true,
|
|
222
|
-
}, placeholder: placeholder, description: description, onSendMessage: onSendMessage, enableStreaming: enableStreaming, ...panelProps, children: children }) })] }));
|
|
222
|
+
}, placeholder: placeholder, description: description, onSendMessage: onSendMessage, enableStreaming: enableStreaming, pendingPrompt: pendingPrompt, ...panelProps, children: children }) })] }));
|
|
223
223
|
}
|
|
224
224
|
export default ChatSidebar;
|
|
@@ -94,6 +94,11 @@ export interface ChatStandaloneProps {
|
|
|
94
94
|
* When provided, tool calls will be rendered inline in the chat.
|
|
95
95
|
*/
|
|
96
96
|
renderToolResult?: RenderToolResult;
|
|
97
|
+
/**
|
|
98
|
+
* A prompt to append and send after the conversation history is loaded.
|
|
99
|
+
* The message is shown in the chat and sent to the agent exactly once.
|
|
100
|
+
*/
|
|
101
|
+
pendingPrompt?: string;
|
|
97
102
|
/** Additional ChatBase props */
|
|
98
103
|
panelProps?: Partial<ChatBaseProps>;
|
|
99
104
|
}
|
|
@@ -101,5 +106,5 @@ export interface ChatStandaloneProps {
|
|
|
101
106
|
* ChatStandalone component
|
|
102
107
|
* A floating popup chat that uses ChatBase with custom onSendMessage handler
|
|
103
108
|
*/
|
|
104
|
-
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, panelProps, }: ChatStandaloneProps): import("react/jsx-runtime").JSX.Element;
|
|
109
|
+
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;
|
|
105
110
|
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, 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, pendingPrompt, panelProps, }) {
|
|
45
45
|
// Use Zustand store for state management
|
|
46
46
|
const isOpen = useChatOpen();
|
|
47
47
|
const messages = useChatMessages();
|
|
@@ -310,7 +310,7 @@ export function ChatStandalone({ onSendMessage, title = 'Chat', description = 'S
|
|
|
310
310
|
title: emptyStateMessage,
|
|
311
311
|
}, avatarConfig: {
|
|
312
312
|
showAvatars: true,
|
|
313
|
-
}, backgroundColor: "canvas.subtle", focusTrigger: focusTrigger, ...panelProps, children: children }), showPoweredBy && (_jsx(Box, { sx: {
|
|
313
|
+
}, backgroundColor: "canvas.subtle", focusTrigger: focusTrigger, pendingPrompt: pendingPrompt, ...panelProps, children: children }), showPoweredBy && (_jsx(Box, { sx: {
|
|
314
314
|
p: 2,
|
|
315
315
|
borderTop: '1px solid',
|
|
316
316
|
borderColor: 'border.default',
|
|
@@ -4,8 +4,14 @@ import type { ChatMessage } from '../../types/message';
|
|
|
4
4
|
import type { TransportType } from '../../types/protocol';
|
|
5
5
|
import type { McpServerSelection } from '../../types/inference';
|
|
6
6
|
import type { FrontendToolDefinition } from '../../types/tool';
|
|
7
|
-
import type { BuiltinTool as BuiltinToolType } from '../../../../types';
|
|
8
|
-
|
|
7
|
+
import type { BuiltinTool as BuiltinToolType } from '../../../../types/Types';
|
|
8
|
+
/**
|
|
9
|
+
* View mode for the chat component.
|
|
10
|
+
* - 'floating': Full-height floating panel (pinned to the right edge with offset)
|
|
11
|
+
* - 'floating-small': Standard floating popup
|
|
12
|
+
* - 'sidebar': Docked sidebar panel
|
|
13
|
+
*/
|
|
14
|
+
export type ChatViewMode = 'floating' | 'floating-small' | 'sidebar';
|
|
9
15
|
/**
|
|
10
16
|
* Tool call status for tool rendering
|
|
11
17
|
*/
|
|
@@ -145,15 +151,27 @@ export interface MCPServerTool {
|
|
|
145
151
|
/**
|
|
146
152
|
* MCP Server configuration from backend
|
|
147
153
|
*/
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
154
|
+
export interface MCPServerConfig {
|
|
155
|
+
id: string;
|
|
156
|
+
name: string;
|
|
157
|
+
description?: string;
|
|
158
|
+
url?: string;
|
|
159
|
+
enabled: boolean;
|
|
160
|
+
tools: MCPServerTool[];
|
|
161
|
+
command?: string;
|
|
162
|
+
args?: string[];
|
|
163
|
+
requiredEnvVars?: string[];
|
|
164
|
+
isAvailable?: boolean;
|
|
165
|
+
transport?: string;
|
|
166
|
+
isConfig?: boolean;
|
|
167
|
+
isRunning?: boolean;
|
|
168
|
+
}
|
|
152
169
|
/**
|
|
153
170
|
* Remote configuration from server
|
|
154
171
|
*/
|
|
155
172
|
export interface RemoteConfig {
|
|
156
173
|
models: ModelConfig[];
|
|
174
|
+
defaultModel?: string;
|
|
157
175
|
builtinTools: BuiltinTool[];
|
|
158
176
|
mcpServers?: MCPServerConfig[];
|
|
159
177
|
}
|
|
@@ -237,6 +255,16 @@ export interface ChatBaseProps {
|
|
|
237
255
|
loadingState?: React.ReactNode;
|
|
238
256
|
/** Header actions */
|
|
239
257
|
headerActions?: React.ReactNode;
|
|
258
|
+
/**
|
|
259
|
+
* Current chat view mode.
|
|
260
|
+
* When provided, a segmented view-mode toggle is rendered in the header
|
|
261
|
+
* with icons for each mode: floating (popup), floating-small (compact), sidebar (docked).
|
|
262
|
+
*/
|
|
263
|
+
chatViewMode?: ChatViewMode;
|
|
264
|
+
/**
|
|
265
|
+
* Callback when the user clicks a different view mode in the header toggle.
|
|
266
|
+
*/
|
|
267
|
+
onChatViewModeChange?: (mode: ChatViewMode) => void;
|
|
240
268
|
/**
|
|
241
269
|
* Use Zustand store for state management.
|
|
242
270
|
* When true, uses the shared store. When false with protocol, uses protocol mode.
|
|
@@ -293,6 +321,14 @@ export interface ChatBaseProps {
|
|
|
293
321
|
renderToolResult?: RenderToolResult;
|
|
294
322
|
/** Custom footer content (rendered above input) */
|
|
295
323
|
footerContent?: ReactNode;
|
|
324
|
+
/**
|
|
325
|
+
* Show the information icon in the header.
|
|
326
|
+
* When clicked, fires onInformationClick.
|
|
327
|
+
* @default false
|
|
328
|
+
*/
|
|
329
|
+
showInformation?: boolean;
|
|
330
|
+
/** Callback when the information icon is clicked */
|
|
331
|
+
onInformationClick?: () => void;
|
|
296
332
|
/** Custom header content (rendered below title row) */
|
|
297
333
|
headerContent?: ReactNode;
|
|
298
334
|
/** Children to render in the messages area (for custom content) */
|
|
@@ -398,7 +434,7 @@ export interface ChatBaseProps {
|
|
|
398
434
|
* Endpoint URL for fetching conversation history.
|
|
399
435
|
* When runtimeId is provided, this endpoint is called to fetch
|
|
400
436
|
* the conversation history on mount.
|
|
401
|
-
* If not provided, defaults to `{protocol.endpoint}/history`.
|
|
437
|
+
* If not provided, defaults to `{protocol.endpoint}/api/v1/history`.
|
|
402
438
|
*/
|
|
403
439
|
historyEndpoint?: string;
|
|
404
440
|
/**
|
|
@@ -406,10 +442,15 @@ export interface ChatBaseProps {
|
|
|
406
442
|
* If not provided, uses the protocol's authToken.
|
|
407
443
|
*/
|
|
408
444
|
historyAuthToken?: string;
|
|
445
|
+
/**
|
|
446
|
+
* A prompt to append and send after the conversation history is loaded.
|
|
447
|
+
* The message is shown in the chat and sent to the agent exactly once.
|
|
448
|
+
*/
|
|
449
|
+
pendingPrompt?: string;
|
|
409
450
|
}
|
|
410
451
|
/**
|
|
411
452
|
* ChatBase component - Universal chat panel supporting store, protocol, and custom modes
|
|
412
453
|
*/
|
|
413
|
-
export declare function ChatBase({ title, showHeader, showTokenUsage, showLoadingIndicator, showErrors, showInput, showModelSelector, showToolsMenu, showSkillsMenu, codemodeEnabled, initialModel, availableModels, mcpServers, initialSkills, className, loadingState, headerActions, useStore: useStoreMode, protocol: protocolProp, agentRuntimeConfig, onSendMessage, enableStreaming, brandIcon, avatarConfig, headerButtons, showPoweredBy, poweredByProps, emptyState, renderToolResult, footerContent, headerContent, children, borderRadius, backgroundColor, border, boxShadow, compact, placeholder, description, onStateUpdate, onNewChat, onClear, onMessagesChange, autoFocus, suggestions, submitOnSuggestionClick, hideMessagesAfterToolUI, focusTrigger, frontendTools, onAuthorizationRequired, connectedIdentities, runtimeId, historyEndpoint, historyAuthToken, }: ChatBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
454
|
+
export declare function ChatBase({ title, showHeader, showTokenUsage, showLoadingIndicator, showErrors, showInput, showModelSelector, showToolsMenu, showSkillsMenu, codemodeEnabled, initialModel, availableModels, mcpServers, initialSkills, className, loadingState, headerActions, chatViewMode, onChatViewModeChange, useStore: useStoreMode, protocol: protocolProp, agentRuntimeConfig, onSendMessage, enableStreaming, brandIcon, avatarConfig, headerButtons, showPoweredBy, poweredByProps, emptyState, renderToolResult, footerContent, showInformation, onInformationClick, headerContent, children, borderRadius, backgroundColor, border, boxShadow, compact, placeholder, description, onStateUpdate, onNewChat, onClear, onMessagesChange, autoFocus, suggestions, submitOnSuggestionClick, hideMessagesAfterToolUI, focusTrigger, frontendTools, onAuthorizationRequired, connectedIdentities, runtimeId, historyEndpoint, historyAuthToken, pendingPrompt, }: ChatBaseProps): import("react/jsx-runtime").JSX.Element;
|
|
414
455
|
export type { PoweredByTagProps };
|
|
415
456
|
export default ChatBase;
|