@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/ChatSidebar.js
CHANGED
|
@@ -12,10 +12,10 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
12
12
|
* @module chat/ChatSidebar
|
|
13
13
|
*/
|
|
14
14
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
15
|
-
import {
|
|
15
|
+
import { createPortal } from 'react-dom';
|
|
16
|
+
import { IconButton } from '@primer/react';
|
|
16
17
|
import { Box } from '@datalayer/primer-addons';
|
|
17
18
|
import { SidebarCollapseIcon, SidebarExpandIcon, XIcon, } from '@primer/octicons-react';
|
|
18
|
-
import { AiAgentIcon } from '@datalayer/icons-react';
|
|
19
19
|
import { useChatKeyboardShortcuts, getShortcutDisplay, } from '@datalayer/core/lib/hooks';
|
|
20
20
|
import { ChatBase } from './base/ChatBase';
|
|
21
21
|
import { useChatStore, useChatOpen, useChatMessages, } from '../stores/chatStore';
|
|
@@ -37,7 +37,7 @@ function useIsMobile(breakpoint = 640) {
|
|
|
37
37
|
/**
|
|
38
38
|
* Chat Sidebar component
|
|
39
39
|
*/
|
|
40
|
-
export function ChatSidebar({ title = 'Chat', protocol: protocolProp, defaultOpen = true, position = 'right', width = 400, showHeader = true, showNewChatButton = true, showClearButton = true, showSettingsButton = false, enableKeyboardShortcuts = true, toggleShortcut = 'k', showPoweredBy = true, poweredByProps, clickOutsideToClose = true, className, onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, onSendMessage, enableStreaming = true, placeholder = 'Ask a question...', description, pendingPrompt, panelProps, }) {
|
|
40
|
+
export function ChatSidebar({ title = 'Chat', protocol: protocolProp, defaultOpen = true, position = 'right', width = 400, showHeader = true, showNewChatButton = true, showClearButton = true, showSettingsButton = false, enableKeyboardShortcuts = true, toggleShortcut = 'k', showPoweredBy = true, poweredByProps, clickOutsideToClose = true, className, onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, onSendMessage, enableStreaming = true, onToolCallStart, onToolCallComplete, placeholder = 'Ask a question...', description, pendingPrompt, showToolApprovalBanner, pendingApprovals, onApproveApproval, onRejectApproval, panelProps, }) {
|
|
41
41
|
const isOpen = useChatOpen();
|
|
42
42
|
const messages = useChatMessages();
|
|
43
43
|
const setOpen = useChatStore(state => state.setOpen);
|
|
@@ -45,6 +45,37 @@ export function ChatSidebar({ title = 'Chat', protocol: protocolProp, defaultOpe
|
|
|
45
45
|
const sidebarRef = useRef(null);
|
|
46
46
|
const inputRef = useRef(null);
|
|
47
47
|
const isMobile = useIsMobile();
|
|
48
|
+
const [desktopViewportHeight, setDesktopViewportHeight] = useState(null);
|
|
49
|
+
// Compute available desktop height from the element's top position so the
|
|
50
|
+
// sidebar always fits within the visible viewport.
|
|
51
|
+
useEffect(() => {
|
|
52
|
+
if (isMobile) {
|
|
53
|
+
setDesktopViewportHeight(null);
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const updateHeight = () => {
|
|
57
|
+
const el = sidebarRef.current;
|
|
58
|
+
if (!el)
|
|
59
|
+
return;
|
|
60
|
+
const rect = el.getBoundingClientRect();
|
|
61
|
+
const viewportHeight = window.visualViewport?.height || window.innerHeight || 0;
|
|
62
|
+
const bottomPadding = 4; // keep a small breathing space from viewport edge
|
|
63
|
+
const available = Math.max(220, Math.floor(viewportHeight - rect.top - bottomPadding));
|
|
64
|
+
setDesktopViewportHeight(prev => prev !== null && Math.abs(prev - available) < 2 ? prev : available);
|
|
65
|
+
};
|
|
66
|
+
updateHeight();
|
|
67
|
+
window.addEventListener('resize', updateHeight);
|
|
68
|
+
window.addEventListener('scroll', updateHeight, true);
|
|
69
|
+
const observer = new ResizeObserver(() => updateHeight());
|
|
70
|
+
if (sidebarRef.current) {
|
|
71
|
+
observer.observe(sidebarRef.current);
|
|
72
|
+
}
|
|
73
|
+
return () => {
|
|
74
|
+
window.removeEventListener('resize', updateHeight);
|
|
75
|
+
window.removeEventListener('scroll', updateHeight, true);
|
|
76
|
+
observer.disconnect();
|
|
77
|
+
};
|
|
78
|
+
}, [isMobile]);
|
|
48
79
|
// Initialize open state from defaultOpen
|
|
49
80
|
useEffect(() => {
|
|
50
81
|
setOpen(defaultOpen);
|
|
@@ -137,58 +168,45 @@ export function ChatSidebar({ title = 'Chat', protocol: protocolProp, defaultOpe
|
|
|
137
168
|
: SidebarExpandIcon, "aria-label": `Close sidebar${shortcutHint ? ` (${shortcutHint})` : ''}`, onClick: handleToggle, variant: "invisible", size: "small" }));
|
|
138
169
|
// Collapsed state
|
|
139
170
|
if (!isOpen) {
|
|
140
|
-
|
|
171
|
+
const collapsedLauncher = (_jsx(Box, { ref: sidebarRef, className: className, sx: {
|
|
141
172
|
position: 'fixed',
|
|
142
173
|
top: 12,
|
|
143
|
-
...(position === 'right'
|
|
174
|
+
...(position === 'right'
|
|
175
|
+
? { right: 'env(safe-area-inset-right)' }
|
|
176
|
+
: { left: 'env(safe-area-inset-left)' }),
|
|
144
177
|
zIndex: 1001,
|
|
145
178
|
display: 'flex',
|
|
146
179
|
flexDirection: 'column',
|
|
147
180
|
alignItems: 'center',
|
|
148
181
|
gap: 2,
|
|
149
|
-
}, children:
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
border: '1px solid',
|
|
178
|
-
borderColor: 'border.default',
|
|
179
|
-
borderRadius: 2,
|
|
180
|
-
boxShadow: 'shadow.small',
|
|
181
|
-
}, children: brandIcon || _jsx(AiAgentIcon, { colored: true, size: 20 }) }), shortcutHint && (_jsx(Box, { sx: {
|
|
182
|
-
px: 1,
|
|
183
|
-
py: '2px',
|
|
184
|
-
bg: 'canvas.default',
|
|
185
|
-
border: '1px solid',
|
|
186
|
-
borderColor: 'border.default',
|
|
187
|
-
color: 'fg.muted',
|
|
188
|
-
borderRadius: 1,
|
|
189
|
-
fontSize: 0,
|
|
190
|
-
boxShadow: 'shadow.small',
|
|
191
|
-
}, children: _jsx(Text, { sx: { fontSize: '10px', fontFamily: 'mono' }, children: shortcutHint }) }))] }));
|
|
182
|
+
}, children: _jsxs(Box, { sx: { position: 'relative' }, children: [_jsx(IconButton, { icon: position === 'right' ? SidebarExpandIcon : SidebarCollapseIcon, "aria-label": "Open chat", description: shortcutHint ? `Open chat (${shortcutHint})` : 'Open chat', onClick: handleToggle, variant: "default", size: "small", sx: {
|
|
183
|
+
bg: 'canvas.default',
|
|
184
|
+
border: '1px solid',
|
|
185
|
+
borderColor: 'border.default',
|
|
186
|
+
boxShadow: 'shadow.small',
|
|
187
|
+
} }), messages.length > 0 && (_jsx(Box, { sx: {
|
|
188
|
+
position: 'absolute',
|
|
189
|
+
top: -6,
|
|
190
|
+
right: -6,
|
|
191
|
+
minWidth: 16,
|
|
192
|
+
height: 16,
|
|
193
|
+
px: 1,
|
|
194
|
+
display: 'flex',
|
|
195
|
+
alignItems: 'center',
|
|
196
|
+
justifyContent: 'center',
|
|
197
|
+
bg: 'accent.emphasis',
|
|
198
|
+
color: 'fg.onEmphasis',
|
|
199
|
+
borderRadius: '50%',
|
|
200
|
+
fontSize: '10px',
|
|
201
|
+
fontWeight: 'bold',
|
|
202
|
+
boxShadow: 'shadow.small',
|
|
203
|
+
}, children: messages.length > 99 ? '99+' : messages.length }))] }) }));
|
|
204
|
+
// Render the collapsed launcher in a body portal so it stays pinned to the
|
|
205
|
+
// viewport edge even when ancestors use transforms/positioning contexts.
|
|
206
|
+
if (typeof document !== 'undefined' && document.body) {
|
|
207
|
+
return createPortal(collapsedLauncher, document.body);
|
|
208
|
+
}
|
|
209
|
+
return collapsedLauncher;
|
|
192
210
|
}
|
|
193
211
|
// Mobile full-screen overlay
|
|
194
212
|
const mobileStyles = isMobile
|
|
@@ -217,21 +235,35 @@ export function ChatSidebar({ title = 'Chat', protocol: protocolProp, defaultOpe
|
|
|
217
235
|
position: 'relative',
|
|
218
236
|
display: 'flex',
|
|
219
237
|
flexDirection: 'column',
|
|
238
|
+
alignSelf: 'stretch',
|
|
220
239
|
width: isMobile
|
|
221
240
|
? '100%'
|
|
222
241
|
: typeof width === 'number'
|
|
223
242
|
? `${width}px`
|
|
224
243
|
: width,
|
|
225
|
-
height:
|
|
244
|
+
height: isMobile
|
|
245
|
+
? '100%'
|
|
246
|
+
: desktopViewportHeight
|
|
247
|
+
? `${desktopViewportHeight}px`
|
|
248
|
+
: 'calc(100dvh - 8px)',
|
|
249
|
+
minHeight: 0,
|
|
250
|
+
maxHeight: isMobile
|
|
251
|
+
? '100%'
|
|
252
|
+
: desktopViewportHeight
|
|
253
|
+
? `${desktopViewportHeight}px`
|
|
254
|
+
: 'calc(100dvh - 8px)',
|
|
255
|
+
marginBlock: isMobile ? 0 : '4px',
|
|
256
|
+
flex: isMobile ? '1 1 auto' : '0 0 auto',
|
|
226
257
|
bg: 'canvas.default',
|
|
227
258
|
borderLeft: !isMobile && position === 'right' ? '1px solid' : 'none',
|
|
228
259
|
borderRight: !isMobile && position === 'left' ? '1px solid' : 'none',
|
|
229
260
|
borderColor: 'border.default',
|
|
261
|
+
overflow: 'hidden',
|
|
230
262
|
...mobileStyles,
|
|
231
263
|
}, children: _jsx(ChatBase, { title: title, showHeader: showHeader, brandIcon: brandIcon, protocol: protocolProp, headerButtons: {
|
|
232
264
|
showNewChat: showNewChatButton,
|
|
233
265
|
showClear: showClearButton && messages.length > 0,
|
|
234
|
-
showSettings: showSettingsButton,
|
|
266
|
+
showSettings: showSettingsButton && !!onSettingsClick,
|
|
235
267
|
onNewChat: handleNewChat,
|
|
236
268
|
onClear: handleClear,
|
|
237
269
|
onSettings: onSettingsClick,
|
|
@@ -241,6 +273,6 @@ export function ChatSidebar({ title = 'Chat', protocol: protocolProp, defaultOpe
|
|
|
241
273
|
...poweredByProps,
|
|
242
274
|
}, avatarConfig: {
|
|
243
275
|
showAvatars: true,
|
|
244
|
-
}, placeholder: placeholder, description: description, onSendMessage: onSendMessage, enableStreaming: enableStreaming, pendingPrompt: pendingPrompt, ...panelProps, children: children }) })] }));
|
|
276
|
+
}, placeholder: placeholder, description: description, onSendMessage: onSendMessage, enableStreaming: enableStreaming, onToolCallStart: onToolCallStart, onToolCallComplete: onToolCallComplete, pendingPrompt: pendingPrompt, showToolApprovalBanner: showToolApprovalBanner, pendingApprovals: pendingApprovals, onApproveApproval: onApproveApproval, onRejectApproval: onRejectApproval, ...panelProps, children: children }) })] }));
|
|
245
277
|
}
|
|
246
278
|
export default ChatSidebar;
|
|
@@ -9,25 +9,17 @@
|
|
|
9
9
|
* @module chat/ChatStandalone
|
|
10
10
|
*/
|
|
11
11
|
import React from 'react';
|
|
12
|
-
import {
|
|
13
|
-
import { type ChatBaseProps, type RenderToolResult, type MessageHandler } from '../types';
|
|
12
|
+
import type { ChatCommonProps, MessageHandler } from '../types';
|
|
14
13
|
/**
|
|
15
|
-
* ChatStandalone props
|
|
14
|
+
* ChatStandalone props — extends ChatCommonProps with standalone popup configuration.
|
|
16
15
|
*/
|
|
17
|
-
export interface ChatStandaloneProps {
|
|
16
|
+
export interface ChatStandaloneProps extends ChatCommonProps {
|
|
18
17
|
/**
|
|
19
18
|
* Handler for sending messages - REQUIRED.
|
|
20
19
|
* This function will be called when the user sends a message.
|
|
21
20
|
* Signature: `(message, messages, options?) => Promise<string | void>`
|
|
22
|
-
* - message: The user's message text
|
|
23
|
-
* - messages: All messages in the conversation (including the new user message)
|
|
24
|
-
* - options: Streaming callbacks (onChunk, onComplete, onError, signal)
|
|
25
21
|
*/
|
|
26
22
|
onSendMessage: MessageHandler;
|
|
27
|
-
/** title */
|
|
28
|
-
title?: string;
|
|
29
|
-
/** Description shown in empty state */
|
|
30
|
-
description?: string;
|
|
31
23
|
/** Position of the popup */
|
|
32
24
|
position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
|
|
33
25
|
/** Default open state */
|
|
@@ -36,44 +28,16 @@ export interface ChatStandaloneProps {
|
|
|
36
28
|
width?: number | string;
|
|
37
29
|
/** height */
|
|
38
30
|
height?: number | string;
|
|
39
|
-
/** Show header */
|
|
40
|
-
showHeader?: boolean;
|
|
41
31
|
/** Show the floating button when closed */
|
|
42
32
|
showButton?: boolean;
|
|
43
|
-
/** Show new chat button */
|
|
44
|
-
showNewChatButton?: boolean;
|
|
45
|
-
/** Show clear button */
|
|
46
|
-
showClearButton?: boolean;
|
|
47
|
-
/** Show settings button */
|
|
48
|
-
showSettingsButton?: boolean;
|
|
49
33
|
/** Enable keyboard shortcuts */
|
|
50
34
|
enableKeyboardShortcuts?: boolean;
|
|
51
35
|
/** Toggle shortcut key */
|
|
52
36
|
toggleShortcut?: string;
|
|
53
|
-
/** Show powered by tag */
|
|
54
|
-
showPoweredBy?: boolean;
|
|
55
|
-
/** Powered by tag props */
|
|
56
|
-
poweredByProps?: Partial<PoweredByTagProps>;
|
|
57
37
|
/** Enable click outside to close */
|
|
58
38
|
clickOutsideToClose?: boolean;
|
|
59
39
|
/** Enable escape key to close */
|
|
60
40
|
escapeToClose?: boolean;
|
|
61
|
-
/** Custom class name */
|
|
62
|
-
className?: string;
|
|
63
|
-
/** Input placeholder */
|
|
64
|
-
placeholder?: string;
|
|
65
|
-
/** Callback when settings clicked */
|
|
66
|
-
onSettingsClick?: () => void;
|
|
67
|
-
/** Callback when new chat clicked */
|
|
68
|
-
onNewChat?: () => void;
|
|
69
|
-
/** Callback when popup opens */
|
|
70
|
-
onOpen?: () => void;
|
|
71
|
-
/** Callback when popup closes */
|
|
72
|
-
onClose?: () => void;
|
|
73
|
-
/** Children to render in popup body (custom content) */
|
|
74
|
-
children?: React.ReactNode;
|
|
75
|
-
/** Custom brand icon */
|
|
76
|
-
brandIcon?: React.ReactNode;
|
|
77
41
|
/** Custom button icon when closed */
|
|
78
42
|
buttonIcon?: React.ReactNode;
|
|
79
43
|
/** Button tooltip text */
|
|
@@ -84,26 +48,12 @@ export interface ChatStandaloneProps {
|
|
|
84
48
|
offset?: number;
|
|
85
49
|
/** Animation duration (in ms) */
|
|
86
50
|
animationDuration?: number;
|
|
87
|
-
/** Enable streaming mode */
|
|
88
|
-
enableStreaming?: boolean;
|
|
89
51
|
/** Empty state message */
|
|
90
52
|
emptyStateMessage?: string;
|
|
91
|
-
/**
|
|
92
|
-
* Custom render function for tool results.
|
|
93
|
-
* When provided, tool calls will be rendered inline in the chat.
|
|
94
|
-
*/
|
|
95
|
-
renderToolResult?: RenderToolResult;
|
|
96
|
-
/**
|
|
97
|
-
* A prompt to append and send after the conversation history is loaded.
|
|
98
|
-
* The message is shown in the chat and sent to the agent exactly once.
|
|
99
|
-
*/
|
|
100
|
-
pendingPrompt?: string;
|
|
101
|
-
/** Additional ChatBase props */
|
|
102
|
-
panelProps?: Partial<ChatBaseProps>;
|
|
103
53
|
}
|
|
104
54
|
/**
|
|
105
55
|
* ChatStandalone component
|
|
106
56
|
* A floating popup chat that uses ChatBase with custom onSendMessage handler
|
|
107
57
|
*/
|
|
108
|
-
export declare function ChatStandalone({ onSendMessage, title, description, position, defaultOpen, width, height, showHeader, showButton, showNewChatButton, showClearButton, showSettingsButton, enableKeyboardShortcuts, toggleShortcut, showPoweredBy, poweredByProps, clickOutsideToClose, escapeToClose, className, placeholder, onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, buttonIcon, buttonTooltip, brandColor, offset, animationDuration, enableStreaming, emptyStateMessage, renderToolResult, pendingPrompt, panelProps, }: ChatStandaloneProps): import("react/jsx-runtime").JSX.Element;
|
|
58
|
+
export declare function ChatStandalone({ onSendMessage, title, description, position, defaultOpen, width, height, showHeader, showButton, showNewChatButton, showClearButton, showSettingsButton, enableKeyboardShortcuts, toggleShortcut, showPoweredBy, poweredByProps, clickOutsideToClose, escapeToClose, className, placeholder, onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, buttonIcon, buttonTooltip, brandColor, offset, animationDuration, enableStreaming, emptyStateMessage, renderToolResult, onToolCallStart, onToolCallComplete, pendingPrompt, showToolApprovalBanner, pendingApprovals, onApproveApproval, onRejectApproval, panelProps, }: ChatStandaloneProps): import("react/jsx-runtime").JSX.Element;
|
|
109
59
|
export default ChatStandalone;
|
|
@@ -41,7 +41,7 @@ function useIsMobile(breakpoint = 640) {
|
|
|
41
41
|
* ChatStandalone component
|
|
42
42
|
* A floating popup chat that uses ChatBase with custom onSendMessage handler
|
|
43
43
|
*/
|
|
44
|
-
export function ChatStandalone({ onSendMessage, title = 'Chat', description = 'Start a conversation.', position = 'bottom-right', defaultOpen = false, width = 380, height = 520, showHeader = true, showButton = true, showNewChatButton = true, showClearButton = true, showSettingsButton = false, enableKeyboardShortcuts = true, toggleShortcut = '/', showPoweredBy = true, poweredByProps, clickOutsideToClose = true, escapeToClose = true, className, placeholder = 'Type a message...', onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, buttonIcon, buttonTooltip = 'Chat with AI', brandColor = '#7c3aed', offset = 20, animationDuration = 200, enableStreaming = true, emptyStateMessage = 'Start a conversation', renderToolResult, pendingPrompt, panelProps, }) {
|
|
44
|
+
export function ChatStandalone({ onSendMessage, title = 'Chat', description = 'Start a conversation.', position = 'bottom-right', defaultOpen = false, width = 380, height = 520, showHeader = true, showButton = true, showNewChatButton = true, showClearButton = true, showSettingsButton = false, enableKeyboardShortcuts = true, toggleShortcut = '/', showPoweredBy = true, poweredByProps, clickOutsideToClose = true, escapeToClose = true, className, placeholder = 'Type a message...', onSettingsClick, onNewChat, onOpen, onClose, children, brandIcon, buttonIcon, buttonTooltip = 'Chat with AI', brandColor = '#7c3aed', offset = 20, animationDuration = 200, enableStreaming = true, emptyStateMessage = 'Start a conversation', renderToolResult, onToolCallStart, onToolCallComplete, pendingPrompt, showToolApprovalBanner, pendingApprovals, onApproveApproval, onRejectApproval, panelProps, }) {
|
|
45
45
|
// Use Zustand store for state management
|
|
46
46
|
const isOpen = useChatOpen();
|
|
47
47
|
const messages = useChatMessages();
|
|
@@ -306,11 +306,11 @@ export function ChatStandalone({ onSendMessage, title = 'Chat', description = 'S
|
|
|
306
306
|
onNewChat: handleNewChat,
|
|
307
307
|
onClear: handleClear,
|
|
308
308
|
onSettings: onSettingsClick,
|
|
309
|
-
}, headerActions: closeButton, renderToolResult: renderToolResult, description: description, placeholder: placeholder, emptyState: {
|
|
309
|
+
}, headerActions: closeButton, renderToolResult: renderToolResult, onToolCallStart: onToolCallStart, onToolCallComplete: onToolCallComplete, description: description, placeholder: placeholder, emptyState: {
|
|
310
310
|
title: emptyStateMessage,
|
|
311
311
|
}, avatarConfig: {
|
|
312
312
|
showAvatars: true,
|
|
313
|
-
}, backgroundColor: "canvas.subtle", focusTrigger: focusTrigger, pendingPrompt: pendingPrompt, ...panelProps, children: children }), showPoweredBy && (_jsx(Box, { sx: {
|
|
313
|
+
}, backgroundColor: "canvas.subtle", focusTrigger: focusTrigger, pendingPrompt: pendingPrompt, showToolApprovalBanner: showToolApprovalBanner, pendingApprovals: pendingApprovals, onApproveApproval: onApproveApproval, onRejectApproval: onRejectApproval, ...panelProps, children: children }), showPoweredBy && (_jsx(Box, { sx: {
|
|
314
314
|
p: 2,
|
|
315
315
|
borderTop: '1px solid',
|
|
316
316
|
borderColor: 'border.default',
|