@datalayer/agent-runtimes 0.0.10 → 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 +33 -21
- package/lib/components/AgentConfiguration.js +76 -21
- package/lib/components/chat/components/AgentDetails.d.ts +3 -1
- package/lib/components/chat/components/AgentDetails.js +164 -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/ContextDistribution.js +2 -2
- package/lib/components/chat/components/ContextInspector.js +4 -2
- package/lib/components/chat/components/ContextPanel.js +1 -6
- 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 +2 -19
- package/lib/components/index.js +1 -10
- package/lib/config/index.d.ts +0 -3
- package/lib/config/index.js +0 -3
- 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} +61 -17
- 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/specs/agents/codeai/agents.d.ts +28 -0
- package/lib/specs/agents/codeai/agents.js +151 -0
- package/lib/specs/agents/codeai/index.d.ts +1 -0
- package/lib/specs/agents/codeai/index.js +5 -0
- package/lib/{config → specs/agents/codemode-paper}/agents.d.ts +4 -6
- package/lib/specs/agents/codemode-paper/agents.js +308 -0
- package/lib/specs/agents/codemode-paper/index.d.ts +1 -0
- package/lib/specs/agents/codemode-paper/index.js +5 -0
- package/lib/specs/agents/datalayer-ai/agents.d.ts +31 -0
- package/lib/{config → specs/agents/datalayer-ai}/agents.js +42 -184
- package/lib/specs/agents/datalayer-ai/index.d.ts +1 -0
- package/lib/specs/agents/datalayer-ai/index.js +5 -0
- package/lib/specs/agents/index.d.ts +21 -0
- package/lib/specs/agents/index.js +47 -0
- package/lib/specs/envvars.d.ts +29 -0
- package/lib/specs/envvars.js +125 -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 +47 -1
- package/lib/specs/models.d.ts +68 -0
- package/lib/specs/models.js +239 -0
- package/lib/{config → specs}/skills.d.ts +2 -0
- package/lib/{config → specs}/skills.js +6 -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} +42 -8
- 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 +608 -157
- package/scripts/codegen/generate_envvars.py +302 -0
- package/scripts/codegen/generate_mcp_servers.py +33 -21
- package/scripts/codegen/generate_models.py +486 -0
- package/scripts/codegen/generate_skills.py +21 -8
- 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/{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/{types.js → types/Types.js} +0 -0
|
@@ -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',
|
|
@@ -67,7 +67,7 @@ export function ContextDistribution({ agentId, height = '250px', }) {
|
|
|
67
67
|
borderColor: 'border.default',
|
|
68
68
|
}, children: _jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "Failed to load context distribution" }) }));
|
|
69
69
|
}
|
|
70
|
-
const { distribution, totalTokens
|
|
70
|
+
const { distribution, totalTokens } = snapshotData;
|
|
71
71
|
const hasData = distribution.children && distribution.children.length > 0;
|
|
72
72
|
// ECharts option for treemap
|
|
73
73
|
const chartOption = {
|
|
@@ -121,7 +121,7 @@ export function ContextDistribution({ agentId, height = '250px', }) {
|
|
|
121
121
|
justifyContent: 'space-between',
|
|
122
122
|
alignItems: 'center',
|
|
123
123
|
mb: 2,
|
|
124
|
-
}, children: [_jsxs(Text, { sx: { fontSize: 1, fontWeight: 'bold' }, children: ["Current Context (", formatTokens(totalTokens), "
|
|
124
|
+
}, children: [_jsxs(Text, { sx: { fontSize: 1, fontWeight: 'bold' }, children: ["Current Context (", formatTokens(totalTokens), " total)"] }), _jsx(Button, { size: "small", variant: "invisible", onClick: () => setShowDetails(!showDetails), leadingVisual: ListUnorderedIcon, children: showDetails ? 'Hide Details' : 'Show Details' })] }), hasData ? (_jsx(ReactECharts, { option: chartOption, style: { height }, opts: { renderer: 'svg' } })) : (_jsx(Box, { sx: {
|
|
125
125
|
p: 4,
|
|
126
126
|
bg: 'canvas.subtle',
|
|
127
127
|
borderRadius: 2,
|
|
@@ -194,9 +194,11 @@ export function ContextInspector({ agentId, apiBase }) {
|
|
|
194
194
|
}, children: _jsx(Text, { sx: { color: 'attention.fg' }, children: contextData.error }) }));
|
|
195
195
|
}
|
|
196
196
|
const { tokenSummary, modelConfiguration } = contextData;
|
|
197
|
-
return (_jsxs(Box, { children: [_jsxs(Box, { sx: { mb: 3 }, children: [_jsxs(
|
|
197
|
+
return (_jsxs(Box, { children: [_jsxs(Box, { sx: { mb: 3 }, children: [_jsxs(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: ["Total usage: ", formatTokens(tokenSummary.total), " /", ' ', formatTokens(tokenSummary.contextWindow), " (", Math.round(tokenSummary.usagePercent), "%)"] }), _jsx(ProgressBar, { progress: Math.min(tokenSummary.usagePercent, 100), sx: { mt: 2, height: 8 }, bg: tokenSummary.usagePercent > 90
|
|
198
198
|
? 'danger.emphasis'
|
|
199
|
-
:
|
|
199
|
+
: tokenSummary.usagePercent > 70
|
|
200
|
+
? 'attention.emphasis'
|
|
201
|
+
: 'success.emphasis' }), _jsxs(Box, { sx: {
|
|
200
202
|
display: 'flex',
|
|
201
203
|
gap: 3,
|
|
202
204
|
mt: 2,
|
|
@@ -270,7 +270,6 @@ export function ContextPanel({ agentId, apiBase, messageCount = 0, defaultView =
|
|
|
270
270
|
}, children: _jsx(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: "Failed to load context details. Make sure the agent is running." }) })] }));
|
|
271
271
|
}
|
|
272
272
|
const { totalTokens, contextWindow, sessionUsage, turnUsage, distribution } = snapshotData;
|
|
273
|
-
const contextUsagePercent = (totalTokens / contextWindow) * 100;
|
|
274
273
|
const hasDistributionData = distribution?.children && distribution.children.length > 0;
|
|
275
274
|
const hasHistoryData = snapshotData.perRequestUsage && snapshotData.perRequestUsage.length > 0;
|
|
276
275
|
return (_jsxs(Box, { children: [_jsxs(Box, { sx: {
|
|
@@ -288,11 +287,7 @@ export function ContextPanel({ agentId, apiBase, messageCount = 0, defaultView =
|
|
|
288
287
|
borderRadius: 2,
|
|
289
288
|
border: '1px solid',
|
|
290
289
|
borderColor: 'border.default',
|
|
291
|
-
}, children: [
|
|
292
|
-
display: 'flex',
|
|
293
|
-
justifyContent: 'space-between',
|
|
294
|
-
mb: 1,
|
|
295
|
-
}, children: [_jsxs(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: [formatTokens(totalTokens), " / ", formatTokens(contextWindow), " tokens"] }), _jsxs(Text, { sx: { fontSize: 1, color: 'fg.muted' }, children: [contextUsagePercent.toFixed(1), "%"] })] }), _jsx(ProgressBar, { progress: Math.min(contextUsagePercent, 100), sx: { height: 8 }, bg: contextUsagePercent > 80 ? 'danger.emphasis' : 'accent.emphasis' })] }), (sessionUsage || turnUsage) && (_jsxs(Box, { sx: {
|
|
290
|
+
}, children: [_jsx(Box, { sx: { mb: 3 }, children: _jsxs(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: ["Total usage: ", formatTokens(totalTokens)] }) }), (sessionUsage || turnUsage) && (_jsxs(Box, { sx: {
|
|
296
291
|
display: 'flex',
|
|
297
292
|
gap: 3,
|
|
298
293
|
mb: 3,
|
|
@@ -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;
|