@datalayer/agent-runtimes 0.0.9 → 0.0.11
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 -1
- package/lib/{examples/components → components}/AgentConfiguration.d.ts +54 -9
- package/lib/components/AgentConfiguration.js +585 -0
- package/lib/{examples/components → components}/FooterMetrics.d.ts +1 -2
- package/lib/{examples/components → components}/Header.d.ts +1 -6
- package/lib/{examples/components → components}/Header.js +5 -39
- package/lib/{examples/components → components}/HeaderControls.d.ts +1 -2
- package/lib/{examples/components → components}/HeaderControls.js +1 -1
- package/lib/{examples/components → components}/LexicalEditor.d.ts +2 -3
- package/lib/{examples/components → components}/LexicalEditor.js +2 -2
- package/lib/components/MainContent.d.ts +34 -0
- package/lib/{examples/components → components}/MainContent.js +18 -9
- package/lib/components/McpServerManager.d.ts +30 -0
- package/lib/components/McpServerManager.js +331 -0
- package/lib/{examples/components → components}/MockFileBrowser.d.ts +1 -2
- package/lib/{examples/components → components}/SessionTabs.d.ts +2 -3
- package/lib/{examples/components → components}/TimeTravel.d.ts +1 -2
- package/lib/components/chat/components/AgentDetails.d.ts +3 -1
- package/lib/components/chat/components/AgentDetails.js +472 -22
- package/lib/components/chat/components/Chat.d.ts +37 -3
- package/lib/components/chat/components/Chat.js +29 -10
- package/lib/components/chat/components/ChatFloating.d.ts +27 -2
- package/lib/components/chat/components/ChatFloating.js +17 -10
- package/lib/components/chat/components/ChatPopupStandalone.js +1 -1
- package/lib/components/chat/components/ChatSidebar.d.ts +1 -1
- package/lib/components/chat/components/ChatStandalone.d.ts +1 -1
- package/lib/components/chat/components/ChatStandalone.js +1 -1
- package/lib/components/chat/components/ContextDistribution.d.ts +70 -6
- package/lib/components/chat/components/ContextDistribution.js +13 -6
- package/lib/components/chat/components/ContextInspector.d.ts +81 -0
- package/lib/components/chat/components/ContextInspector.js +263 -0
- package/lib/components/chat/components/ContextPanel.d.ts +112 -0
- package/lib/components/chat/components/ContextPanel.js +368 -0
- package/lib/components/chat/components/base/ChatBase.d.ts +74 -19
- package/lib/components/chat/components/base/ChatBase.js +296 -37
- package/lib/components/chat/components/index.d.ts +3 -1
- package/lib/components/chat/components/index.js +2 -0
- package/lib/components/chat/extensions/ExtensionRegistry.d.ts +1 -1
- package/lib/components/chat/extensions/index.d.ts +1 -0
- package/lib/components/chat/index.d.ts +3 -3
- package/lib/components/chat/protocols/AGUIAdapter.js +24 -4
- package/lib/components/chat/protocols/VercelAIAdapter.js +35 -1
- package/lib/components/chat/store/chatStore.d.ts +2 -3
- package/lib/components/chat/store/conversationStore.d.ts +83 -0
- package/lib/components/chat/store/conversationStore.js +174 -0
- package/lib/components/chat/store/index.d.ts +2 -1
- package/lib/components/chat/store/index.js +1 -0
- package/lib/components/chat/types/inference.d.ts +17 -0
- package/lib/components/chat/types/protocol.d.ts +10 -0
- package/lib/components/index.d.ts +23 -0
- package/lib/components/index.js +11 -0
- package/lib/config/agents/code-ai/agents.d.ts +25 -0
- package/lib/config/agents/code-ai/agents.js +70 -0
- package/lib/config/agents/code-ai/index.d.ts +1 -0
- package/lib/config/agents/code-ai/index.js +5 -0
- package/lib/config/agents/codemode-paper/agents.d.ts +29 -0
- package/lib/config/agents/codemode-paper/agents.js +288 -0
- package/lib/config/agents/codemode-paper/index.d.ts +1 -0
- package/lib/config/agents/codemode-paper/index.js +5 -0
- package/lib/config/agents/datalayer-ai/agents.d.ts +29 -0
- package/lib/config/agents/datalayer-ai/agents.js +267 -0
- package/lib/config/agents/datalayer-ai/index.d.ts +1 -0
- package/lib/config/agents/datalayer-ai/index.js +5 -0
- package/lib/config/agents/index.d.ts +19 -0
- package/lib/config/agents/index.js +38 -0
- package/lib/config/envvars.d.ts +28 -0
- package/lib/config/envvars.js +115 -0
- package/lib/config/index.d.ts +5 -0
- package/lib/config/index.js +9 -0
- package/lib/config/mcpServers.d.ts +18 -0
- package/lib/config/mcpServers.js +153 -0
- package/lib/config/skills.d.ts +27 -0
- package/lib/config/skills.js +60 -0
- package/lib/{lib → config}/utils.d.ts +1 -1
- package/lib/{lib → config}/utils.js +2 -2
- package/lib/examples/AgentRuntimeLexical2Example.d.ts +1 -0
- package/lib/examples/AgentRuntimeLexical2Example.js +3 -2
- package/lib/examples/AgentRuntimeLexicalExample.d.ts +1 -0
- package/lib/examples/AgentRuntimeLexicalExample.js +5 -3
- package/lib/examples/AgentRuntimeLexicalSidebarExample.d.ts +1 -0
- package/lib/examples/AgentRuntimeLexicalSidebarExample.js +3 -3
- package/lib/examples/AgentRuntimeNotebookExample.js +1 -1
- package/lib/examples/AgentSpaceFormExample.d.ts +2 -2
- package/lib/examples/AgentSpaceFormExample.js +215 -35
- package/lib/examples/CopilotKitLexicalExample.d.ts +1 -0
- package/lib/examples/CopilotKitLexicalExample.js +3 -2
- package/lib/examples/index.d.ts +1 -0
- package/lib/examples/stores/notebooks/NotebookExample2.ipynb.json +43 -43
- package/lib/hooks/useAGUI.d.ts +1 -1
- package/lib/hooks/useAGUI.js +1 -1
- package/lib/identity/types.d.ts +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +1 -0
- package/lib/runtime/index.d.ts +3 -0
- package/lib/runtime/runtimeStore.d.ts +3 -4
- package/lib/runtime/useAgentConnection.d.ts +2 -3
- package/lib/runtime/useAgentRuntime.d.ts +2 -3
- package/lib/stories/Cell.stories.js +1 -1
- package/lib/tools/adapters/agent-runtimes/notebookHooks.js +1 -0
- package/lib/tools/adapters/copilotkit/notebookHooks.js +1 -0
- package/lib/types.d.ts +158 -0
- package/package.json +5 -6
- package/scripts/apply-patches.sh +1 -1
- package/scripts/codegen/generate_agents.py +863 -0
- package/scripts/codegen/generate_envvars.py +302 -0
- package/scripts/codegen/generate_mcp_servers.py +436 -0
- package/scripts/codegen/generate_skills.py +334 -0
- package/scripts/download-ai-elements.py +35 -20
- package/scripts/sync-jupyter.sh +6 -0
- package/lib/components/ui/accordion.d.ts +0 -7
- package/lib/components/ui/accordion.js +0 -22
- package/lib/components/ui/alert-dialog.d.ts +0 -14
- package/lib/components/ui/alert-dialog.js +0 -43
- package/lib/components/ui/alert.d.ts +0 -9
- package/lib/components/ui/alert.js +0 -24
- package/lib/components/ui/aspect-ratio.d.ts +0 -3
- package/lib/components/ui/aspect-ratio.js +0 -11
- package/lib/components/ui/avatar.d.ts +0 -6
- package/lib/components/ui/avatar.js +0 -18
- package/lib/components/ui/badge.d.ts +0 -9
- package/lib/components/ui/badge.js +0 -22
- package/lib/components/ui/breadcrumb.d.ts +0 -11
- package/lib/components/ui/breadcrumb.js +0 -27
- package/lib/components/ui/button-group.d.ts +0 -11
- package/lib/components/ui/button-group.js +0 -31
- package/lib/components/ui/button.d.ts +0 -13
- package/lib/components/ui/button.js +0 -39
- package/lib/components/ui/calendar.d.ts +0 -8
- package/lib/components/ui/calendar.js +0 -80
- package/lib/components/ui/card.d.ts +0 -9
- package/lib/components/ui/card.js +0 -24
- package/lib/components/ui/carousel.d.ts +0 -19
- package/lib/components/ui/carousel.js +0 -95
- package/lib/components/ui/chart.d.ts +0 -53
- package/lib/components/ui/chart.js +0 -136
- package/lib/components/ui/checkbox.d.ts +0 -4
- package/lib/components/ui/checkbox.js +0 -13
- package/lib/components/ui/collapsible.d.ts +0 -5
- package/lib/components/ui/collapsible.js +0 -17
- package/lib/components/ui/command.d.ts +0 -18
- package/lib/components/ui/command.js +0 -38
- package/lib/components/ui/context-menu.d.ts +0 -25
- package/lib/components/ui/context-menu.js +0 -55
- package/lib/components/ui/dialog.d.ts +0 -15
- package/lib/components/ui/dialog.js +0 -40
- package/lib/components/ui/drawer.d.ts +0 -13
- package/lib/components/ui/drawer.js +0 -39
- package/lib/components/ui/dropdown-menu.d.ts +0 -25
- package/lib/components/ui/dropdown-menu.js +0 -55
- package/lib/components/ui/empty.d.ts +0 -11
- package/lib/components/ui/empty.js +0 -37
- package/lib/components/ui/field.d.ts +0 -24
- package/lib/components/ui/field.js +0 -80
- package/lib/components/ui/form.d.ts +0 -24
- package/lib/components/ui/form.js +0 -63
- package/lib/components/ui/hover-card.d.ts +0 -6
- package/lib/components/ui/hover-card.js +0 -18
- package/lib/components/ui/input-group.d.ts +0 -19
- package/lib/components/ui/input-group.js +0 -69
- package/lib/components/ui/input-otp.d.ts +0 -11
- package/lib/components/ui/input-otp.js +0 -25
- package/lib/components/ui/input.d.ts +0 -3
- package/lib/components/ui/input.js +0 -6
- package/lib/components/ui/item.d.ts +0 -23
- package/lib/components/ui/item.js +0 -66
- package/lib/components/ui/kbd.d.ts +0 -3
- package/lib/components/ui/kbd.js +0 -13
- package/lib/components/ui/label.d.ts +0 -4
- package/lib/components/ui/label.js +0 -12
- package/lib/components/ui/menubar.d.ts +0 -26
- package/lib/components/ui/menubar.js +0 -58
- package/lib/components/ui/navigation-menu.d.ts +0 -14
- package/lib/components/ui/navigation-menu.js +0 -31
- package/lib/components/ui/pagination.d.ts +0 -13
- package/lib/components/ui/pagination.js +0 -29
- package/lib/components/ui/popover.d.ts +0 -7
- package/lib/components/ui/popover.js +0 -21
- package/lib/components/ui/progress.d.ts +0 -4
- package/lib/components/ui/progress.js +0 -12
- package/lib/components/ui/radio-group.d.ts +0 -5
- package/lib/components/ui/radio-group.js +0 -16
- package/lib/components/ui/resizable.d.ts +0 -8
- package/lib/components/ui/resizable.js +0 -19
- package/lib/components/ui/scroll-area.d.ts +0 -5
- package/lib/components/ui/scroll-area.js +0 -17
- package/lib/components/ui/select.d.ts +0 -15
- package/lib/components/ui/select.js +0 -42
- package/lib/components/ui/separator.d.ts +0 -4
- package/lib/components/ui/separator.js +0 -12
- package/lib/components/ui/sheet.d.ts +0 -13
- package/lib/components/ui/sheet.js +0 -44
- package/lib/components/ui/sidebar.d.ts +0 -69
- package/lib/components/ui/sidebar.js +0 -216
- package/lib/components/ui/skeleton.d.ts +0 -2
- package/lib/components/ui/skeleton.js +0 -10
- package/lib/components/ui/slider.d.ts +0 -4
- package/lib/components/ui/slider.js +0 -18
- package/lib/components/ui/sonner.d.ts +0 -3
- package/lib/components/ui/sonner.js +0 -25
- package/lib/components/ui/spinner.d.ts +0 -2
- package/lib/components/ui/spinner.js +0 -11
- package/lib/components/ui/switch.d.ts +0 -4
- package/lib/components/ui/switch.js +0 -12
- package/lib/components/ui/table.d.ts +0 -10
- package/lib/components/ui/table.js +0 -32
- package/lib/components/ui/tabs.d.ts +0 -7
- package/lib/components/ui/tabs.js +0 -21
- package/lib/components/ui/textarea.d.ts +0 -3
- package/lib/components/ui/textarea.js +0 -6
- package/lib/components/ui/toast.d.ts +0 -15
- package/lib/components/ui/toast.js +0 -38
- package/lib/components/ui/toaster.d.ts +0 -1
- package/lib/components/ui/toaster.js +0 -14
- package/lib/components/ui/toggle-group.d.ts +0 -9
- package/lib/components/ui/toggle-group.js +0 -26
- package/lib/components/ui/toggle.d.ts +0 -9
- package/lib/components/ui/toggle.js +0 -30
- package/lib/components/ui/tooltip.d.ts +0 -7
- package/lib/components/ui/tooltip.js +0 -21
- package/lib/components/vercel-ai-elements/artifact.d.ts +0 -23
- package/lib/components/vercel-ai-elements/artifact.js +0 -24
- package/lib/components/vercel-ai-elements/code-block.d.ts +0 -17
- package/lib/components/vercel-ai-elements/code-block.js +0 -94
- package/lib/components/vercel-ai-elements/conversation.d.ts +0 -15
- package/lib/components/vercel-ai-elements/conversation.js +0 -21
- package/lib/components/vercel-ai-elements/loader.d.ts +0 -5
- package/lib/components/vercel-ai-elements/loader.js +0 -8
- package/lib/components/vercel-ai-elements/message.d.ts +0 -46
- package/lib/components/vercel-ai-elements/message.js +0 -109
- package/lib/components/vercel-ai-elements/model-selector.d.ts +0 -35
- package/lib/components/vercel-ai-elements/model-selector.js +0 -22
- package/lib/components/vercel-ai-elements/prompt-input.d.ts +0 -195
- package/lib/components/vercel-ai-elements/prompt-input.js +0 -589
- package/lib/components/vercel-ai-elements/reasoning.d.ts +0 -26
- package/lib/components/vercel-ai-elements/reasoning.js +0 -80
- package/lib/components/vercel-ai-elements/shimmer.d.ts +0 -9
- package/lib/components/vercel-ai-elements/shimmer.js +0 -22
- package/lib/components/vercel-ai-elements/sources.d.ts +0 -12
- package/lib/components/vercel-ai-elements/sources.js +0 -13
- package/lib/components/vercel-ai-elements/suggestion.d.ts +0 -10
- package/lib/components/vercel-ai-elements/suggestion.js +0 -16
- package/lib/components/vercel-ai-elements/tool.d.ts +0 -23
- package/lib/components/vercel-ai-elements/tool.js +0 -52
- package/lib/examples/components/AgentConfiguration.js +0 -382
- package/lib/examples/components/MainContent.d.ts +0 -19
- package/lib/examples/components/index.d.ts +0 -10
- package/lib/examples/components/index.js +0 -13
- package/lib/examples/vercel-ai-elements/VercelAiElementsShowcase.d.ts +0 -12
- package/lib/examples/vercel-ai-elements/VercelAiElementsShowcase.js +0 -69
- package/lib/examples/vercel-ai-elements/components/ArtifactShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/ArtifactShowcase.js +0 -85
- package/lib/examples/vercel-ai-elements/components/CodeBlockShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/CodeBlockShowcase.js +0 -62
- package/lib/examples/vercel-ai-elements/components/ConversationShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/ConversationShowcase.js +0 -51
- package/lib/examples/vercel-ai-elements/components/LoaderShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/LoaderShowcase.js +0 -9
- package/lib/examples/vercel-ai-elements/components/MessageShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/MessageShowcase.js +0 -56
- package/lib/examples/vercel-ai-elements/components/ModelSelectorShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/ModelSelectorShowcase.js +0 -50
- package/lib/examples/vercel-ai-elements/components/PromptInputShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/PromptInputShowcase.js +0 -16
- package/lib/examples/vercel-ai-elements/components/ReasoningShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/ReasoningShowcase.js +0 -72
- package/lib/examples/vercel-ai-elements/components/ShimmerShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/ShimmerShowcase.js +0 -9
- package/lib/examples/vercel-ai-elements/components/SourcesShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/SourcesShowcase.js +0 -43
- package/lib/examples/vercel-ai-elements/components/SuggestionShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/SuggestionShowcase.js +0 -31
- package/lib/examples/vercel-ai-elements/components/ToolShowcase.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/components/ToolShowcase.js +0 -54
- package/lib/examples/vercel-ai-elements/index.d.ts +0 -13
- package/lib/examples/vercel-ai-elements/index.js +0 -17
- package/lib/examples/vercel-ai-elements/main.d.ts +0 -1
- package/lib/examples/vercel-ai-elements/main.js +0 -9
- package/lib/examples/vercel-ai-elements/showcase.css +0 -128
- package/lib/hooks/useToast.d.ts +0 -44
- package/lib/hooks/useToast.js +0 -128
- package/patches/@datalayer+jupyter-lexical+1.0.8.patch +0 -11628
- package/patches/@datalayer+jupyter-react+2.0.2.patch +0 -5338
- package/style/showcase-vercel-ai.css +0 -137
- /package/lib/{examples/components → components}/FooterMetrics.js +0 -0
- /package/lib/{examples/components → components}/MockFileBrowser.js +0 -0
- /package/lib/{examples/components → components}/SessionTabs.js +0 -0
- /package/lib/{examples/components → components}/TimeTravel.js +0 -0
- /package/lib/{models → types}/AIAgent.d.ts +0 -0
- /package/lib/{models → types}/AIAgent.js +0 -0
- /package/lib/{models → types}/index.d.ts +0 -0
- /package/lib/{models → types}/index.js +0 -0
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type Suggestion } from './base/ChatBase';
|
|
2
|
+
import type { ModelConfig } from './base/ChatBase';
|
|
3
|
+
import type { McpServerSelection } from '../types';
|
|
2
4
|
import type { OAuthProvider, OAuthProviderConfig, Identity } from '../../../identity';
|
|
3
5
|
/**
|
|
4
6
|
* Supported transports (communication transports)
|
|
@@ -54,10 +56,21 @@ export interface ChatProps {
|
|
|
54
56
|
showSkillsMenu?: boolean;
|
|
55
57
|
/** Indicate tools are accessed via Codemode meta-tools */
|
|
56
58
|
codemodeEnabled?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Show token usage bar between input and selectors.
|
|
61
|
+
* @default true
|
|
62
|
+
*/
|
|
63
|
+
showTokenUsage?: boolean;
|
|
57
64
|
/** Initial model ID to select (e.g., 'openai:gpt-4o-mini') */
|
|
58
65
|
initialModel?: string;
|
|
59
|
-
/**
|
|
60
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Override the list of available models.
|
|
68
|
+
* When provided, this list replaces the models returned by the config endpoint.
|
|
69
|
+
* Use this to restrict the model selector to a specific subset of models.
|
|
70
|
+
*/
|
|
71
|
+
availableModels?: ModelConfig[];
|
|
72
|
+
/** MCP server selections to enable (others will be disabled) */
|
|
73
|
+
mcpServers?: McpServerSelection[];
|
|
61
74
|
/** Initial skill IDs to enable */
|
|
62
75
|
initialSkills?: string[];
|
|
63
76
|
/** Clear messages when component mounts or agentId changes */
|
|
@@ -82,6 +95,27 @@ export interface ChatProps {
|
|
|
82
95
|
onIdentityConnect?: (identity: Identity) => void;
|
|
83
96
|
/** Callback when identity disconnects */
|
|
84
97
|
onIdentityDisconnect?: (provider: OAuthProvider) => void;
|
|
98
|
+
/**
|
|
99
|
+
* Runtime ID for conversation persistence.
|
|
100
|
+
* When provided, messages are fetched from the server API on page reload
|
|
101
|
+
* and prevents message mixing between different agent spaces.
|
|
102
|
+
*/
|
|
103
|
+
runtimeId?: string;
|
|
104
|
+
/**
|
|
105
|
+
* Endpoint URL for fetching conversation history.
|
|
106
|
+
* When runtimeId is provided, this endpoint is called to fetch
|
|
107
|
+
* the conversation history on mount.
|
|
108
|
+
* If not provided, defaults to `{protocol.endpoint}/history`.
|
|
109
|
+
*/
|
|
110
|
+
historyEndpoint?: string;
|
|
111
|
+
/**
|
|
112
|
+
* Error banner to display at the top of the chat.
|
|
113
|
+
* Use this to show sandbox connection errors or other warnings.
|
|
114
|
+
*/
|
|
115
|
+
errorBanner?: {
|
|
116
|
+
message: string;
|
|
117
|
+
variant?: 'danger' | 'warning';
|
|
118
|
+
};
|
|
85
119
|
}
|
|
86
120
|
/**
|
|
87
121
|
* Chat Component
|
|
@@ -124,5 +158,5 @@ export interface ChatProps {
|
|
|
124
158
|
* />
|
|
125
159
|
* ```
|
|
126
160
|
*/
|
|
127
|
-
export declare function Chat({ transport, extensions: _extensions, baseUrl, wsUrl, agentId, placeholder, title, autoConnect: _autoConnect, streaming: _streaming, onMessageSent: _onMessageSent, onMessageReceived: _onMessageReceived, onDisconnect, onLogout: _onLogout, onCollapsePanel: _onCollapsePanel, className, height, showHeader, showModelSelector, showToolsMenu, showSkillsMenu, codemodeEnabled, initialModel,
|
|
161
|
+
export declare function Chat({ transport, extensions: _extensions, baseUrl, wsUrl, agentId, placeholder, title, autoConnect: _autoConnect, streaming: _streaming, onMessageSent: _onMessageSent, onMessageReceived: _onMessageReceived, onDisconnect, onLogout: _onLogout, onCollapsePanel: _onCollapsePanel, className, height, showHeader, showModelSelector, showToolsMenu, showSkillsMenu, codemodeEnabled, showTokenUsage, initialModel, availableModels, mcpServers, initialSkills, clearOnMount: _clearOnMount, suggestions, submitOnSuggestionClick, description, autoFocus, identityProviders, onIdentityConnect, onIdentityDisconnect, runtimeId, historyEndpoint, errorBanner, }: ChatProps): import("react/jsx-runtime").JSX.Element;
|
|
128
162
|
export default Chat;
|
|
@@ -70,7 +70,7 @@ function getEndpointPath(transport, agentId) {
|
|
|
70
70
|
case 'ag-ui':
|
|
71
71
|
return `/api/v1/ag-ui/${agentId}/`;
|
|
72
72
|
case 'a2a':
|
|
73
|
-
// A2A requires trailing slash
|
|
73
|
+
// A2A requires trailing slash for FastA2A compatibility
|
|
74
74
|
return `/api/v1/a2a/agents/${agentId}/`;
|
|
75
75
|
case 'acp':
|
|
76
76
|
return `/api/v1/acp/ws/${agentId}`;
|
|
@@ -130,7 +130,7 @@ function getProtocolType(transport) {
|
|
|
130
130
|
* />
|
|
131
131
|
* ```
|
|
132
132
|
*/
|
|
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, initialModel,
|
|
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, }) {
|
|
134
134
|
const [error, setError] = useState(null);
|
|
135
135
|
const [isInitializing, setIsInitializing] = useState(true);
|
|
136
136
|
const [showDetails, setShowDetails] = useState(false);
|
|
@@ -282,16 +282,35 @@ export function Chat({ transport, extensions: _extensions, baseUrl = 'http://loc
|
|
|
282
282
|
display: showDetails ? 'flex' : 'none',
|
|
283
283
|
flexDirection: 'column',
|
|
284
284
|
height: '100%',
|
|
285
|
-
}, children: _jsx(AgentDetails, { name: title || 'AI Agent', protocol: transport, url: protocolConfig?.endpoint || baseUrl, messageCount: messageCount, agentId: agentId, identityProviders: identityProviders, onIdentityConnect: onIdentityConnect, onIdentityDisconnect: onIdentityDisconnect, onBack: () => setShowDetails(false) }) }),
|
|
285
|
+
}, 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: {
|
|
286
286
|
display: showDetails ? 'none' : 'flex',
|
|
287
287
|
flexDirection: 'column',
|
|
288
288
|
height: '100%',
|
|
289
|
-
}, children:
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
289
|
+
}, children: [errorBanner && (_jsxs(Box, { sx: {
|
|
290
|
+
display: 'flex',
|
|
291
|
+
alignItems: 'center',
|
|
292
|
+
gap: 2,
|
|
293
|
+
px: 3,
|
|
294
|
+
py: 2,
|
|
295
|
+
bg: errorBanner.variant === 'warning'
|
|
296
|
+
? 'attention.subtle'
|
|
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'
|
|
305
|
+
? 'attention.fg'
|
|
306
|
+
: 'danger.fg',
|
|
307
|
+
flex: 1,
|
|
308
|
+
}, 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, headerContent: _jsx(IconButton, { icon: InfoIcon, "aria-label": "Agent details", variant: "invisible", size: "small", onClick: () => 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: {
|
|
309
|
+
showNewChat: true,
|
|
310
|
+
showClear: true,
|
|
311
|
+
onNewChat: handleNewChat,
|
|
312
|
+
}, avatarConfig: {
|
|
313
|
+
showAvatars: true,
|
|
314
|
+
}, backgroundColor: "canvas.default", focusTrigger: focusTrigger })] })] }));
|
|
296
315
|
}
|
|
297
316
|
export default Chat;
|
|
@@ -20,7 +20,7 @@ export type { ToolCallStatus, ToolCallRenderContext, RenderToolResult, RespondCa
|
|
|
20
20
|
*/
|
|
21
21
|
export interface ChatFloatingProps {
|
|
22
22
|
/**
|
|
23
|
-
* AG-UI endpoint URL (e.g., http://localhost:8000/api/v1/examples/agentic_chat
|
|
23
|
+
* AG-UI endpoint URL (e.g., http://localhost:8000/api/v1/examples/agentic_chat).
|
|
24
24
|
* When provided with useStore=false, enables AG-UI protocol mode.
|
|
25
25
|
*/
|
|
26
26
|
endpoint?: string;
|
|
@@ -135,6 +135,12 @@ export interface ChatFloatingProps {
|
|
|
135
135
|
* @default false
|
|
136
136
|
*/
|
|
137
137
|
showPanelBackdrop?: boolean;
|
|
138
|
+
/**
|
|
139
|
+
* Override the list of available models.
|
|
140
|
+
* When provided, this list replaces the models returned by the config endpoint.
|
|
141
|
+
* Use this to restrict the model selector to a specific subset of models.
|
|
142
|
+
*/
|
|
143
|
+
availableModels?: ModelConfig[];
|
|
138
144
|
/**
|
|
139
145
|
* Show model selector in footer.
|
|
140
146
|
* @default false
|
|
@@ -150,6 +156,25 @@ export interface ChatFloatingProps {
|
|
|
150
156
|
* @default false
|
|
151
157
|
*/
|
|
152
158
|
showSkillsMenu?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Show token usage bar between input and selectors.
|
|
161
|
+
* @default true
|
|
162
|
+
*/
|
|
163
|
+
showTokenUsage?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Runtime ID used to scope and persist conversation history.
|
|
166
|
+
* When provided, history is fetched on mount from the historyEndpoint.
|
|
167
|
+
*/
|
|
168
|
+
runtimeId?: string;
|
|
169
|
+
/**
|
|
170
|
+
* Endpoint URL for fetching conversation history.
|
|
171
|
+
* Defaults to `{protocol.endpoint}/history` when runtimeId is set.
|
|
172
|
+
*/
|
|
173
|
+
historyEndpoint?: string;
|
|
174
|
+
/**
|
|
175
|
+
* Auth token for the history endpoint.
|
|
176
|
+
*/
|
|
177
|
+
historyAuthToken?: string;
|
|
153
178
|
/** Additional ChatBase props */
|
|
154
179
|
panelProps?: Partial<ChatBaseProps>;
|
|
155
180
|
}
|
|
@@ -157,5 +182,5 @@ export interface ChatFloatingProps {
|
|
|
157
182
|
* ChatFloating component
|
|
158
183
|
* A floating chat window built on ChatBase
|
|
159
184
|
*/
|
|
160
|
-
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, tools: _tools, initialState: _initialState, suggestions, submitOnSuggestionClick, hideMessagesAfterToolUI, defaultViewMode, showPanelBackdrop, showModelSelector, showToolsMenu, showSkillsMenu, panelProps, }: ChatFloatingProps): import("react/jsx-runtime").JSX.Element;
|
|
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, tools: _tools, initialState: _initialState, suggestions, submitOnSuggestionClick, hideMessagesAfterToolUI, defaultViewMode, showPanelBackdrop, availableModels, showModelSelector, showToolsMenu, showSkillsMenu, showTokenUsage, runtimeId, historyEndpoint, historyAuthToken, panelProps, }: ChatFloatingProps): import("react/jsx-runtime").JSX.Element;
|
|
161
186
|
export default ChatFloating;
|
|
@@ -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, tools: _tools, initialState: _initialState, suggestions, submitOnSuggestionClick = true, hideMessagesAfterToolUI = false, defaultViewMode = 'floating', showPanelBackdrop = false, showModelSelector = false, showToolsMenu = false, showSkillsMenu = false, panelProps, }) {
|
|
46
|
+
export function ChatFloating({ endpoint, protocol: protocolProp, useStore: useStoreMode = true, title = 'Chat', description = 'Start a conversation with the AI agent.', position = 'bottom-right', defaultOpen = false, width = 400, height = 550, showHeader = true, showButton = true, showNewChatButton = true, showClearButton = true, showSettingsButton = false, enableKeyboardShortcuts = true, toggleShortcut = '/', showPoweredBy = true, poweredByProps, clickOutsideToClose = true, escapeToClose = true, className, onSettingsClick, onNewChat, onOpen, onClose, onStateUpdate, children, brandIcon, buttonIcon, buttonTooltip = 'Chat with AI', brandColor = '#7c3aed', offset = 20, animationDuration = 200, renderToolResult, tools: _tools, initialState: _initialState, suggestions, submitOnSuggestionClick = true, hideMessagesAfterToolUI = false, defaultViewMode = 'floating', showPanelBackdrop = false, availableModels, showModelSelector = false, showToolsMenu = false, showSkillsMenu = false, showTokenUsage = true, runtimeId, historyEndpoint, historyAuthToken, panelProps, }) {
|
|
47
47
|
// Store-based state
|
|
48
48
|
const storeIsOpen = useChatOpen();
|
|
49
49
|
const storeMessages = useChatMessages();
|
|
@@ -68,15 +68,23 @@ export function ChatFloating({ endpoint, protocol: protocolProp, useStore: useSt
|
|
|
68
68
|
return protocolProp;
|
|
69
69
|
if (!endpoint)
|
|
70
70
|
return undefined;
|
|
71
|
-
// Extract base URL from endpoint
|
|
72
|
-
|
|
71
|
+
// Extract base URL from endpoint - everything before /api/v1/
|
|
72
|
+
// e.g., https://prod1.datalayer.run/agent-runtimes/pool1/rt123/api/v1/ag-ui/default/
|
|
73
|
+
// -> https://prod1.datalayer.run/agent-runtimes/pool1/rt123
|
|
74
|
+
const baseUrl = endpoint.match(/^(.*?)\/api\/v1\//)?.[1] ||
|
|
75
|
+
endpoint.match(/^(https?:\/\/[^/]+)/)?.[1] ||
|
|
76
|
+
'';
|
|
77
|
+
// Extract agentId from endpoint path (e.g., .../ag-ui/default/ -> default)
|
|
78
|
+
const agentIdMatch = endpoint.match(/\/ag-ui\/([^/]+)/);
|
|
79
|
+
const extractedAgentId = agentIdMatch ? agentIdMatch[1] : undefined;
|
|
73
80
|
return {
|
|
74
81
|
type: 'ag-ui',
|
|
75
82
|
endpoint,
|
|
76
|
-
|
|
77
|
-
|
|
83
|
+
agentId: extractedAgentId,
|
|
84
|
+
// Enable config query for model/tools/skills selector or token usage
|
|
85
|
+
enableConfigQuery: showModelSelector || showToolsMenu || showSkillsMenu || showTokenUsage,
|
|
78
86
|
// Config endpoint is at /api/v1/configure (global, not per-agent)
|
|
79
|
-
configEndpoint: showModelSelector || showToolsMenu || showSkillsMenu
|
|
87
|
+
configEndpoint: showModelSelector || showToolsMenu || showSkillsMenu || showTokenUsage
|
|
80
88
|
? `${baseUrl}/api/v1/configure`
|
|
81
89
|
: undefined,
|
|
82
90
|
};
|
|
@@ -86,6 +94,7 @@ export function ChatFloating({ endpoint, protocol: protocolProp, useStore: useSt
|
|
|
86
94
|
showModelSelector,
|
|
87
95
|
showToolsMenu,
|
|
88
96
|
showSkillsMenu,
|
|
97
|
+
showTokenUsage,
|
|
89
98
|
]);
|
|
90
99
|
// Clear messages when endpoint/protocol changes (e.g., switching examples)
|
|
91
100
|
useEffect(() => {
|
|
@@ -364,9 +373,7 @@ export function ChatFloating({ endpoint, protocol: protocolProp, useStore: useSt
|
|
|
364
373
|
border: '1px solid',
|
|
365
374
|
borderColor: 'border.default',
|
|
366
375
|
borderRadius: viewMode === 'panel' || isMobile ? 0 : '12px',
|
|
367
|
-
boxShadow: viewMode === 'panel'
|
|
368
|
-
? '-4px 0 20px rgba(0, 0, 0, 0.15)'
|
|
369
|
-
: '0 8px 30px rgba(0, 0, 0, 0.12)',
|
|
376
|
+
boxShadow: viewMode === 'panel' ? 'shadow.large' : 'shadow.extra-large',
|
|
370
377
|
overflow: 'hidden',
|
|
371
378
|
transform: viewMode === 'panel'
|
|
372
379
|
? isOpen
|
|
@@ -393,6 +400,6 @@ export function ChatFloating({ endpoint, protocol: protocolProp, useStore: useSt
|
|
|
393
400
|
...poweredByProps,
|
|
394
401
|
}, renderToolResult: renderToolResult, description: description, onStateUpdate: onStateUpdate, onNewChat: onNewChat, suggestions: suggestions, submitOnSuggestionClick: submitOnSuggestionClick, hideMessagesAfterToolUI: hideMessagesAfterToolUI, avatarConfig: {
|
|
395
402
|
showAvatars: true,
|
|
396
|
-
}, placeholder: "Type a message...", backgroundColor: "canvas.subtle", frontendTools: _tools, showModelSelector: showModelSelector, showToolsMenu: showToolsMenu, showSkillsMenu: showSkillsMenu, ...panelProps, children: children }) })] }));
|
|
403
|
+
}, placeholder: "Type a message...", backgroundColor: "canvas.subtle", frontendTools: _tools, showModelSelector: showModelSelector, availableModels: availableModels, showToolsMenu: showToolsMenu, showSkillsMenu: showSkillsMenu, showTokenUsage: showTokenUsage, runtimeId: runtimeId, historyEndpoint: historyEndpoint, historyAuthToken: historyAuthToken, ...panelProps, children: children }) })] }));
|
|
397
404
|
}
|
|
398
405
|
export default ChatFloating;
|
|
@@ -382,7 +382,7 @@ export function ChatPopupStandalone({ onSendMessage, title = 'Chat', description
|
|
|
382
382
|
border: '1px solid',
|
|
383
383
|
borderColor: 'border.default',
|
|
384
384
|
borderRadius: isMobile ? 0 : '12px',
|
|
385
|
-
boxShadow: '
|
|
385
|
+
boxShadow: 'shadow.extra-large',
|
|
386
386
|
overflow: 'hidden',
|
|
387
387
|
transform: getAnimationTransform(isOpen),
|
|
388
388
|
opacity: isOpen ? 1 : 0,
|
|
@@ -59,7 +59,7 @@ export interface ChatSidebarProps {
|
|
|
59
59
|
/**
|
|
60
60
|
* Handler for sending messages.
|
|
61
61
|
* When provided, this is used instead of protocol mode.
|
|
62
|
-
* Signature: (message, messages, options?) => Promise<string | void
|
|
62
|
+
* Signature: `(message, messages, options?) => Promise<string | void>`
|
|
63
63
|
*/
|
|
64
64
|
onSendMessage?: MessageHandler;
|
|
65
65
|
/** Enable streaming mode (default: true) */
|
|
@@ -19,7 +19,7 @@ export interface ChatStandaloneProps {
|
|
|
19
19
|
/**
|
|
20
20
|
* Handler for sending messages - REQUIRED.
|
|
21
21
|
* This function will be called when the user sends a message.
|
|
22
|
-
* Signature: (message, messages, options?) => Promise<string | void
|
|
22
|
+
* Signature: `(message, messages, options?) => Promise<string | void>`
|
|
23
23
|
* - message: The user's message text
|
|
24
24
|
* - messages: All messages in the conversation (including the new user message)
|
|
25
25
|
* - options: Streaming callbacks (onChunk, onComplete, onError, signal)
|
|
@@ -292,7 +292,7 @@ export function ChatStandalone({ onSendMessage, title = 'Chat', description = 'S
|
|
|
292
292
|
border: '1px solid',
|
|
293
293
|
borderColor: 'border.default',
|
|
294
294
|
borderRadius: isMobile ? 0 : '12px',
|
|
295
|
-
boxShadow: '
|
|
295
|
+
boxShadow: 'shadow.extra-large',
|
|
296
296
|
overflow: 'hidden',
|
|
297
297
|
transform: getAnimationTransform(isOpen),
|
|
298
298
|
opacity: isOpen ? 1 : 0,
|
|
@@ -14,6 +14,54 @@ interface Distribution {
|
|
|
14
14
|
value: number;
|
|
15
15
|
children: DistributionChild[];
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Tool snapshot
|
|
19
|
+
*/
|
|
20
|
+
interface ToolSnapshot {
|
|
21
|
+
name: string;
|
|
22
|
+
description: string | null;
|
|
23
|
+
parametersTokens: number;
|
|
24
|
+
totalTokens: number;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Message snapshot
|
|
28
|
+
*/
|
|
29
|
+
interface MessageSnapshot {
|
|
30
|
+
role: string;
|
|
31
|
+
content: string;
|
|
32
|
+
estimatedTokens: number;
|
|
33
|
+
timestamp: string | null;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Request usage snapshot
|
|
37
|
+
*/
|
|
38
|
+
interface RequestUsageSnapshot {
|
|
39
|
+
requestNum: number;
|
|
40
|
+
inputTokens: number;
|
|
41
|
+
outputTokens: number;
|
|
42
|
+
toolNames: string[];
|
|
43
|
+
timestamp: string | null;
|
|
44
|
+
turnId: string | null;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Turn usage
|
|
48
|
+
*/
|
|
49
|
+
interface TurnUsage {
|
|
50
|
+
inputTokens: number;
|
|
51
|
+
outputTokens: number;
|
|
52
|
+
requests: number;
|
|
53
|
+
toolCalls: number;
|
|
54
|
+
toolNames: string[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Session usage
|
|
58
|
+
*/
|
|
59
|
+
interface SessionUsage {
|
|
60
|
+
inputTokens: number;
|
|
61
|
+
outputTokens: number;
|
|
62
|
+
requests: number;
|
|
63
|
+
toolCalls: number;
|
|
64
|
+
}
|
|
17
65
|
/**
|
|
18
66
|
* Context snapshot response from API
|
|
19
67
|
*/
|
|
@@ -21,16 +69,32 @@ export interface ContextSnapshotResponse {
|
|
|
21
69
|
agentId: string;
|
|
22
70
|
systemPrompts: string[];
|
|
23
71
|
systemPromptTokens: number;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
72
|
+
tools: ToolSnapshot[];
|
|
73
|
+
toolTokens: number;
|
|
74
|
+
historyToolCallTokens: number;
|
|
75
|
+
historyToolReturnTokens: number;
|
|
76
|
+
currentToolCallTokens: number;
|
|
77
|
+
currentToolReturnTokens: number;
|
|
78
|
+
toolCallTokens: number;
|
|
79
|
+
toolReturnTokens: number;
|
|
80
|
+
messages: MessageSnapshot[];
|
|
81
|
+
historyUserTokens: number;
|
|
82
|
+
historyAssistantTokens: number;
|
|
83
|
+
currentUserTokens: number;
|
|
84
|
+
currentAssistantTokens: number;
|
|
85
|
+
historyTokens: number;
|
|
86
|
+
currentMessageTokens: number;
|
|
30
87
|
userMessageTokens: number;
|
|
31
88
|
assistantMessageTokens: number;
|
|
32
89
|
totalTokens: number;
|
|
90
|
+
modelInputTokens: number | null;
|
|
91
|
+
modelOutputTokens: number | null;
|
|
92
|
+
sumResponseInputTokens: number;
|
|
93
|
+
sumResponseOutputTokens: number;
|
|
94
|
+
perRequestUsage: RequestUsageSnapshot[];
|
|
33
95
|
contextWindow: number;
|
|
96
|
+
turnUsage: TurnUsage | null;
|
|
97
|
+
sessionUsage: SessionUsage | null;
|
|
34
98
|
distribution: Distribution;
|
|
35
99
|
error?: string;
|
|
36
100
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
// Copyright (c) 2025-2026 Datalayer, Inc.
|
|
3
3
|
// Distributed under the terms of the Modified BSD License.
|
|
4
4
|
/**
|
|
@@ -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,
|
|
@@ -139,8 +139,15 @@ export function ContextDistribution({ agentId, height = '250px', }) {
|
|
|
139
139
|
bg: 'canvas.default',
|
|
140
140
|
fontFamily: 'mono',
|
|
141
141
|
fontSize: 0,
|
|
142
|
-
}, children: [_jsx(Text, { sx: { fontWeight: 'bold', display: 'block', mb: 2 }, children: "Context Breakdown:" }), snapshotData.systemPromptTokens > 0 && (_jsxs(Box, { sx: { mb: 2 }, children: [_jsxs(Text, { sx: { fontWeight: 'bold' }, children: ["System Prompts: ", formatTokens(snapshotData.systemPromptTokens), ' ', "tokens"] }), snapshotData.systemPrompts.map((prompt, idx) => (_jsxs(Text, { sx: { display: 'block', ml: 3, mt: 1, color: 'fg.muted' }, children: ["\u2022", ' ', prompt.length > 100 ? prompt.slice(0, 100) + '...' : prompt] }, idx)))] })),
|
|
143
|
-
|
|
144
|
-
|
|
142
|
+
}, children: [_jsx(Text, { sx: { fontWeight: 'bold', display: 'block', mb: 2 }, children: "Context Breakdown:" }), snapshotData.systemPromptTokens > 0 && (_jsxs(Box, { sx: { mb: 2 }, children: [_jsxs(Text, { sx: { fontWeight: 'bold' }, children: ["System Prompts: ", formatTokens(snapshotData.systemPromptTokens), ' ', "tokens"] }), snapshotData.systemPrompts.map((prompt, idx) => (_jsxs(Text, { sx: { display: 'block', ml: 3, mt: 1, color: 'fg.muted' }, children: ["\u2022", ' ', prompt.length > 100 ? prompt.slice(0, 100) + '...' : prompt] }, idx)))] })), snapshotData.toolTokens > 0 && (_jsxs(Box, { sx: { mb: 2 }, children: [_jsxs(Text, { sx: { fontWeight: 'bold' }, children: ["Tool Definitions: ", formatTokens(snapshotData.toolTokens), " tokens (", snapshotData.tools.length, " tools)"] }), _jsxs(Box, { sx: { ml: 3, mt: 1 }, children: [snapshotData.tools.slice(0, 5).map((tool, idx) => (_jsxs(Text, { sx: { display: 'block', color: 'fg.muted' }, children: ["\u2022 ", tool.name, ": ", formatTokens(tool.totalTokens), " tokens"] }, idx))), snapshotData.tools.length > 5 && (_jsxs(Text, { sx: {
|
|
143
|
+
display: 'block',
|
|
144
|
+
color: 'fg.muted',
|
|
145
|
+
fontStyle: 'italic',
|
|
146
|
+
}, children: ["...and ", snapshotData.tools.length - 5, " more tools"] }))] })] })), (snapshotData.historyUserTokens > 0 ||
|
|
147
|
+
snapshotData.historyAssistantTokens > 0 ||
|
|
148
|
+
snapshotData.historyToolCallTokens > 0) && (_jsxs(Box, { sx: { mb: 2 }, children: [_jsxs(Text, { sx: { fontWeight: 'bold' }, children: ["History:", ' ', formatTokens(snapshotData.historyUserTokens +
|
|
149
|
+
snapshotData.historyAssistantTokens +
|
|
150
|
+
snapshotData.historyToolCallTokens +
|
|
151
|
+
snapshotData.historyToolReturnTokens), ' ', "tokens"] }), _jsxs(Box, { sx: { ml: 3, mt: 1 }, children: [_jsxs(Text, { sx: { display: 'block' }, children: ["\u2022 User Messages:", ' ', formatTokens(snapshotData.historyUserTokens), " tokens"] }), _jsxs(Text, { sx: { display: 'block' }, children: ["\u2022 Assistant Responses:", ' ', formatTokens(snapshotData.historyAssistantTokens), " tokens"] }), snapshotData.historyToolCallTokens > 0 && (_jsxs(Text, { sx: { display: 'block' }, children: ["\u2022 Tool Calls:", ' ', formatTokens(snapshotData.historyToolCallTokens), " tokens"] })), snapshotData.historyToolReturnTokens > 0 && (_jsxs(Text, { sx: { display: 'block' }, children: ["\u2022 Tool Returns:", ' ', formatTokens(snapshotData.historyToolReturnTokens), " tokens"] }))] })] })), snapshotData.currentUserTokens > 0 && (_jsx(Box, { sx: { mb: 2 }, children: _jsxs(Text, { sx: { fontWeight: 'bold' }, children: ["Current User: ", formatTokens(snapshotData.currentUserTokens), ' ', "tokens"] }) })), snapshotData.turnUsage && (_jsxs(Box, { sx: { mb: 2 }, children: [_jsx(Text, { sx: { fontWeight: 'bold' }, children: "Turn Usage (model-reported):" }), _jsxs(Box, { sx: { ml: 3, mt: 1 }, children: [_jsxs(Text, { sx: { display: 'block' }, children: ["\u2022 Input: ", formatTokens(snapshotData.turnUsage.inputTokens), ' ', "tokens"] }), _jsxs(Text, { sx: { display: 'block' }, children: ["\u2022 Output: ", formatTokens(snapshotData.turnUsage.outputTokens), ' ', "tokens"] }), _jsxs(Text, { sx: { display: 'block' }, children: ["\u2022 Requests: ", snapshotData.turnUsage.requests] }), snapshotData.turnUsage.toolCalls > 0 && (_jsxs(Text, { sx: { display: 'block' }, children: ["\u2022 Tool Calls: ", snapshotData.turnUsage.toolCalls, snapshotData.turnUsage.toolNames.length > 0 && (_jsxs(_Fragment, { children: [" (", snapshotData.turnUsage.toolNames.join(', '), ")"] }))] }))] })] })), snapshotData.sessionUsage && (_jsxs(Box, { sx: { mb: 2 }, children: [_jsx(Text, { sx: { fontWeight: 'bold' }, children: "Session Totals:" }), _jsxs(Box, { sx: { ml: 3, mt: 1 }, children: [_jsxs(Text, { sx: { display: 'block' }, children: ["\u2022 Total Input:", ' ', formatTokens(snapshotData.sessionUsage.inputTokens), " tokens"] }), _jsxs(Text, { sx: { display: 'block' }, children: ["\u2022 Total Output:", ' ', formatTokens(snapshotData.sessionUsage.outputTokens), " tokens"] }), _jsxs(Text, { sx: { display: 'block' }, children: ["\u2022 Total Requests: ", snapshotData.sessionUsage.requests] }), snapshotData.sessionUsage.toolCalls > 0 && (_jsxs(Text, { sx: { display: 'block' }, children: ["\u2022 Total Tool Calls: ", snapshotData.sessionUsage.toolCalls] }))] })] }))] }))] }));
|
|
145
152
|
}
|
|
146
153
|
export default ContextDistribution;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool detail from API
|
|
3
|
+
*/
|
|
4
|
+
interface ToolDetail {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string | null;
|
|
7
|
+
parametersSchema: Record<string, unknown>;
|
|
8
|
+
parametersTokens: number;
|
|
9
|
+
totalTokens: number;
|
|
10
|
+
sourceType: string;
|
|
11
|
+
isAsync: boolean;
|
|
12
|
+
requiresApproval: boolean;
|
|
13
|
+
sourceCode: string | null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Message detail from API
|
|
17
|
+
*/
|
|
18
|
+
interface MessageDetail {
|
|
19
|
+
role: string;
|
|
20
|
+
content: string;
|
|
21
|
+
estimatedTokens: number;
|
|
22
|
+
timestamp: string | null;
|
|
23
|
+
inContext: boolean;
|
|
24
|
+
toolName: string | null;
|
|
25
|
+
toolCallId: string | null;
|
|
26
|
+
isToolCall: boolean;
|
|
27
|
+
isToolResult: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* System prompt from API
|
|
31
|
+
*/
|
|
32
|
+
interface SystemPrompt {
|
|
33
|
+
content: string;
|
|
34
|
+
tokens: number;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Token summary from API
|
|
38
|
+
*/
|
|
39
|
+
interface TokenSummary {
|
|
40
|
+
systemPrompts: number;
|
|
41
|
+
tools: number;
|
|
42
|
+
memory: number;
|
|
43
|
+
history: number;
|
|
44
|
+
current: number;
|
|
45
|
+
total: number;
|
|
46
|
+
contextWindow: number;
|
|
47
|
+
usagePercent: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Full context response from API
|
|
51
|
+
*/
|
|
52
|
+
export interface FullContextResponse {
|
|
53
|
+
agentId: string;
|
|
54
|
+
modelConfiguration: {
|
|
55
|
+
modelName: string | null;
|
|
56
|
+
contextWindow: number;
|
|
57
|
+
settings: Record<string, unknown>;
|
|
58
|
+
};
|
|
59
|
+
systemPrompts: SystemPrompt[];
|
|
60
|
+
systemPromptTokens: number;
|
|
61
|
+
tools: ToolDetail[];
|
|
62
|
+
toolTokens: number;
|
|
63
|
+
messages: MessageDetail[];
|
|
64
|
+
memoryBlocks: Record<string, unknown>[];
|
|
65
|
+
memoryTokens: number;
|
|
66
|
+
toolEnvironment: Record<string, string>;
|
|
67
|
+
toolRules: Record<string, unknown>[];
|
|
68
|
+
tokenSummary: TokenSummary;
|
|
69
|
+
error?: string;
|
|
70
|
+
}
|
|
71
|
+
export interface ContextInspectorProps {
|
|
72
|
+
/** Agent ID for fetching full context */
|
|
73
|
+
agentId: string;
|
|
74
|
+
/** API base URL for fetching context data */
|
|
75
|
+
apiBase?: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* ContextInspector component displays full detailed context snapshot.
|
|
79
|
+
*/
|
|
80
|
+
export declare function ContextInspector({ agentId, apiBase }: ContextInspectorProps): import("react/jsx-runtime").JSX.Element;
|
|
81
|
+
export default ContextInspector;
|