@datalayer/agent-runtimes 0.0.8 → 0.0.10

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.
Files changed (275) hide show
  1. package/README.md +2 -1
  2. package/lib/{examples/components → components}/AgentConfiguration.d.ts +27 -12
  3. package/lib/{examples/components → components}/AgentConfiguration.js +170 -22
  4. package/lib/{examples/components → components}/FooterMetrics.d.ts +1 -2
  5. package/lib/{examples/components → components}/Header.d.ts +1 -6
  6. package/lib/{examples/components → components}/Header.js +5 -39
  7. package/lib/{examples/components → components}/HeaderControls.d.ts +1 -2
  8. package/lib/{examples/components → components}/HeaderControls.js +1 -1
  9. package/lib/{examples/components → components}/LexicalEditor.d.ts +2 -3
  10. package/lib/{examples/components → components}/LexicalEditor.js +2 -2
  11. package/lib/components/MainContent.d.ts +34 -0
  12. package/lib/{examples/components → components}/MainContent.js +18 -9
  13. package/lib/components/McpServerManager.d.ts +30 -0
  14. package/lib/components/McpServerManager.js +331 -0
  15. package/lib/{examples/components → components}/MockFileBrowser.d.ts +1 -2
  16. package/lib/{examples/components → components}/SessionTabs.d.ts +2 -3
  17. package/lib/{examples/components → components}/TimeTravel.d.ts +1 -2
  18. package/lib/components/chat/components/AgentDetails.d.ts +3 -1
  19. package/lib/components/chat/components/AgentDetails.js +323 -31
  20. package/lib/components/chat/components/Chat.d.ts +37 -3
  21. package/lib/components/chat/components/Chat.js +29 -10
  22. package/lib/components/chat/components/ChatFloating.d.ts +27 -2
  23. package/lib/components/chat/components/ChatFloating.js +17 -10
  24. package/lib/components/chat/components/ChatPopupStandalone.js +1 -1
  25. package/lib/components/chat/components/ChatSidebar.d.ts +1 -1
  26. package/lib/components/chat/components/ChatStandalone.d.ts +1 -1
  27. package/lib/components/chat/components/ChatStandalone.js +1 -1
  28. package/lib/components/chat/components/ContextDistribution.d.ts +70 -6
  29. package/lib/components/chat/components/ContextDistribution.js +11 -4
  30. package/lib/components/chat/components/ContextInspector.d.ts +81 -0
  31. package/lib/components/chat/components/ContextInspector.js +261 -0
  32. package/lib/components/chat/components/ContextPanel.d.ts +112 -0
  33. package/lib/components/chat/components/ContextPanel.js +373 -0
  34. package/lib/components/chat/components/base/ChatBase.d.ts +74 -19
  35. package/lib/components/chat/components/base/ChatBase.js +296 -37
  36. package/lib/components/chat/components/index.d.ts +3 -1
  37. package/lib/components/chat/components/index.js +2 -0
  38. package/lib/components/chat/extensions/ExtensionRegistry.d.ts +1 -1
  39. package/lib/components/chat/extensions/index.d.ts +1 -0
  40. package/lib/components/chat/index.d.ts +3 -3
  41. package/lib/components/chat/protocols/AGUIAdapter.js +24 -4
  42. package/lib/components/chat/protocols/VercelAIAdapter.js +35 -1
  43. package/lib/components/chat/store/chatStore.d.ts +2 -3
  44. package/lib/components/chat/store/conversationStore.d.ts +83 -0
  45. package/lib/components/chat/store/conversationStore.js +174 -0
  46. package/lib/components/chat/store/index.d.ts +2 -1
  47. package/lib/components/chat/store/index.js +1 -0
  48. package/lib/components/chat/types/inference.d.ts +17 -0
  49. package/lib/components/chat/types/protocol.d.ts +10 -0
  50. package/lib/components/index.d.ts +23 -0
  51. package/lib/components/index.js +11 -0
  52. package/lib/config/agents.d.ts +33 -0
  53. package/lib/config/agents.js +424 -0
  54. package/lib/config/index.d.ts +4 -0
  55. package/lib/config/index.js +8 -0
  56. package/lib/config/mcpServers.d.ts +18 -0
  57. package/lib/config/mcpServers.js +129 -0
  58. package/lib/config/skills.d.ts +25 -0
  59. package/lib/config/skills.js +54 -0
  60. package/lib/{lib → config}/utils.d.ts +1 -1
  61. package/lib/{lib → config}/utils.js +2 -2
  62. package/lib/examples/AgentRuntimeLexical2Example.d.ts +1 -0
  63. package/lib/examples/AgentRuntimeLexical2Example.js +3 -2
  64. package/lib/examples/AgentRuntimeLexicalExample.d.ts +1 -0
  65. package/lib/examples/AgentRuntimeLexicalExample.js +5 -3
  66. package/lib/examples/AgentRuntimeLexicalSidebarExample.d.ts +1 -0
  67. package/lib/examples/AgentRuntimeLexicalSidebarExample.js +3 -3
  68. package/lib/examples/AgentRuntimeNotebookExample.js +1 -1
  69. package/lib/examples/AgentSpaceFormExample.d.ts +2 -2
  70. package/lib/examples/AgentSpaceFormExample.js +167 -29
  71. package/lib/examples/CopilotKitLexicalExample.d.ts +1 -0
  72. package/lib/examples/CopilotKitLexicalExample.js +3 -2
  73. package/lib/examples/index.d.ts +1 -0
  74. package/lib/examples/stores/notebooks/NotebookExample2.ipynb.json +43 -43
  75. package/lib/hooks/useAGUI.d.ts +1 -1
  76. package/lib/hooks/useAGUI.js +1 -1
  77. package/lib/identity/types.d.ts +1 -1
  78. package/lib/index.d.ts +2 -0
  79. package/lib/index.js +1 -0
  80. package/lib/runtime/index.d.ts +3 -0
  81. package/lib/runtime/runtimeStore.d.ts +3 -4
  82. package/lib/runtime/useAgentConnection.d.ts +2 -3
  83. package/lib/runtime/useAgentRuntime.d.ts +2 -3
  84. package/lib/stories/Cell.stories.js +1 -1
  85. package/lib/tools/adapters/agent-runtimes/notebookHooks.js +1 -0
  86. package/lib/tools/adapters/copilotkit/notebookHooks.js +1 -0
  87. package/lib/types.d.ts +150 -0
  88. package/package.json +4 -5
  89. package/scripts/apply-patches.sh +32 -0
  90. package/scripts/codegen/generate_agents.py +452 -0
  91. package/scripts/codegen/generate_mcp_servers.py +424 -0
  92. package/scripts/codegen/generate_skills.py +321 -0
  93. package/scripts/download-ai-elements.py +35 -20
  94. package/scripts/sync-jupyter.sh +6 -0
  95. package/lib/components/ui/accordion.d.ts +0 -7
  96. package/lib/components/ui/accordion.js +0 -22
  97. package/lib/components/ui/alert-dialog.d.ts +0 -14
  98. package/lib/components/ui/alert-dialog.js +0 -43
  99. package/lib/components/ui/alert.d.ts +0 -9
  100. package/lib/components/ui/alert.js +0 -24
  101. package/lib/components/ui/aspect-ratio.d.ts +0 -3
  102. package/lib/components/ui/aspect-ratio.js +0 -11
  103. package/lib/components/ui/avatar.d.ts +0 -6
  104. package/lib/components/ui/avatar.js +0 -18
  105. package/lib/components/ui/badge.d.ts +0 -9
  106. package/lib/components/ui/badge.js +0 -22
  107. package/lib/components/ui/breadcrumb.d.ts +0 -11
  108. package/lib/components/ui/breadcrumb.js +0 -27
  109. package/lib/components/ui/button-group.d.ts +0 -11
  110. package/lib/components/ui/button-group.js +0 -31
  111. package/lib/components/ui/button.d.ts +0 -13
  112. package/lib/components/ui/button.js +0 -39
  113. package/lib/components/ui/calendar.d.ts +0 -8
  114. package/lib/components/ui/calendar.js +0 -80
  115. package/lib/components/ui/card.d.ts +0 -9
  116. package/lib/components/ui/card.js +0 -24
  117. package/lib/components/ui/carousel.d.ts +0 -19
  118. package/lib/components/ui/carousel.js +0 -95
  119. package/lib/components/ui/chart.d.ts +0 -53
  120. package/lib/components/ui/chart.js +0 -136
  121. package/lib/components/ui/checkbox.d.ts +0 -4
  122. package/lib/components/ui/checkbox.js +0 -13
  123. package/lib/components/ui/collapsible.d.ts +0 -5
  124. package/lib/components/ui/collapsible.js +0 -17
  125. package/lib/components/ui/command.d.ts +0 -18
  126. package/lib/components/ui/command.js +0 -38
  127. package/lib/components/ui/context-menu.d.ts +0 -25
  128. package/lib/components/ui/context-menu.js +0 -55
  129. package/lib/components/ui/dialog.d.ts +0 -15
  130. package/lib/components/ui/dialog.js +0 -40
  131. package/lib/components/ui/drawer.d.ts +0 -13
  132. package/lib/components/ui/drawer.js +0 -39
  133. package/lib/components/ui/dropdown-menu.d.ts +0 -25
  134. package/lib/components/ui/dropdown-menu.js +0 -55
  135. package/lib/components/ui/empty.d.ts +0 -11
  136. package/lib/components/ui/empty.js +0 -37
  137. package/lib/components/ui/field.d.ts +0 -24
  138. package/lib/components/ui/field.js +0 -80
  139. package/lib/components/ui/form.d.ts +0 -24
  140. package/lib/components/ui/form.js +0 -63
  141. package/lib/components/ui/hover-card.d.ts +0 -6
  142. package/lib/components/ui/hover-card.js +0 -18
  143. package/lib/components/ui/input-group.d.ts +0 -19
  144. package/lib/components/ui/input-group.js +0 -69
  145. package/lib/components/ui/input-otp.d.ts +0 -11
  146. package/lib/components/ui/input-otp.js +0 -25
  147. package/lib/components/ui/input.d.ts +0 -3
  148. package/lib/components/ui/input.js +0 -6
  149. package/lib/components/ui/item.d.ts +0 -23
  150. package/lib/components/ui/item.js +0 -66
  151. package/lib/components/ui/kbd.d.ts +0 -3
  152. package/lib/components/ui/kbd.js +0 -13
  153. package/lib/components/ui/label.d.ts +0 -4
  154. package/lib/components/ui/label.js +0 -12
  155. package/lib/components/ui/menubar.d.ts +0 -26
  156. package/lib/components/ui/menubar.js +0 -58
  157. package/lib/components/ui/navigation-menu.d.ts +0 -14
  158. package/lib/components/ui/navigation-menu.js +0 -31
  159. package/lib/components/ui/pagination.d.ts +0 -13
  160. package/lib/components/ui/pagination.js +0 -29
  161. package/lib/components/ui/popover.d.ts +0 -7
  162. package/lib/components/ui/popover.js +0 -21
  163. package/lib/components/ui/progress.d.ts +0 -4
  164. package/lib/components/ui/progress.js +0 -12
  165. package/lib/components/ui/radio-group.d.ts +0 -5
  166. package/lib/components/ui/radio-group.js +0 -16
  167. package/lib/components/ui/resizable.d.ts +0 -8
  168. package/lib/components/ui/resizable.js +0 -19
  169. package/lib/components/ui/scroll-area.d.ts +0 -5
  170. package/lib/components/ui/scroll-area.js +0 -17
  171. package/lib/components/ui/select.d.ts +0 -15
  172. package/lib/components/ui/select.js +0 -42
  173. package/lib/components/ui/separator.d.ts +0 -4
  174. package/lib/components/ui/separator.js +0 -12
  175. package/lib/components/ui/sheet.d.ts +0 -13
  176. package/lib/components/ui/sheet.js +0 -44
  177. package/lib/components/ui/sidebar.d.ts +0 -69
  178. package/lib/components/ui/sidebar.js +0 -216
  179. package/lib/components/ui/skeleton.d.ts +0 -2
  180. package/lib/components/ui/skeleton.js +0 -10
  181. package/lib/components/ui/slider.d.ts +0 -4
  182. package/lib/components/ui/slider.js +0 -18
  183. package/lib/components/ui/sonner.d.ts +0 -3
  184. package/lib/components/ui/sonner.js +0 -25
  185. package/lib/components/ui/spinner.d.ts +0 -2
  186. package/lib/components/ui/spinner.js +0 -11
  187. package/lib/components/ui/switch.d.ts +0 -4
  188. package/lib/components/ui/switch.js +0 -12
  189. package/lib/components/ui/table.d.ts +0 -10
  190. package/lib/components/ui/table.js +0 -32
  191. package/lib/components/ui/tabs.d.ts +0 -7
  192. package/lib/components/ui/tabs.js +0 -21
  193. package/lib/components/ui/textarea.d.ts +0 -3
  194. package/lib/components/ui/textarea.js +0 -6
  195. package/lib/components/ui/toast.d.ts +0 -15
  196. package/lib/components/ui/toast.js +0 -38
  197. package/lib/components/ui/toaster.d.ts +0 -1
  198. package/lib/components/ui/toaster.js +0 -14
  199. package/lib/components/ui/toggle-group.d.ts +0 -9
  200. package/lib/components/ui/toggle-group.js +0 -26
  201. package/lib/components/ui/toggle.d.ts +0 -9
  202. package/lib/components/ui/toggle.js +0 -30
  203. package/lib/components/ui/tooltip.d.ts +0 -7
  204. package/lib/components/ui/tooltip.js +0 -21
  205. package/lib/components/vercel-ai-elements/artifact.d.ts +0 -23
  206. package/lib/components/vercel-ai-elements/artifact.js +0 -24
  207. package/lib/components/vercel-ai-elements/code-block.d.ts +0 -17
  208. package/lib/components/vercel-ai-elements/code-block.js +0 -94
  209. package/lib/components/vercel-ai-elements/conversation.d.ts +0 -15
  210. package/lib/components/vercel-ai-elements/conversation.js +0 -21
  211. package/lib/components/vercel-ai-elements/loader.d.ts +0 -5
  212. package/lib/components/vercel-ai-elements/loader.js +0 -8
  213. package/lib/components/vercel-ai-elements/message.d.ts +0 -46
  214. package/lib/components/vercel-ai-elements/message.js +0 -109
  215. package/lib/components/vercel-ai-elements/model-selector.d.ts +0 -35
  216. package/lib/components/vercel-ai-elements/model-selector.js +0 -22
  217. package/lib/components/vercel-ai-elements/prompt-input.d.ts +0 -195
  218. package/lib/components/vercel-ai-elements/prompt-input.js +0 -589
  219. package/lib/components/vercel-ai-elements/reasoning.d.ts +0 -26
  220. package/lib/components/vercel-ai-elements/reasoning.js +0 -80
  221. package/lib/components/vercel-ai-elements/shimmer.d.ts +0 -9
  222. package/lib/components/vercel-ai-elements/shimmer.js +0 -22
  223. package/lib/components/vercel-ai-elements/sources.d.ts +0 -12
  224. package/lib/components/vercel-ai-elements/sources.js +0 -13
  225. package/lib/components/vercel-ai-elements/suggestion.d.ts +0 -10
  226. package/lib/components/vercel-ai-elements/suggestion.js +0 -16
  227. package/lib/components/vercel-ai-elements/tool.d.ts +0 -23
  228. package/lib/components/vercel-ai-elements/tool.js +0 -52
  229. package/lib/examples/components/MainContent.d.ts +0 -19
  230. package/lib/examples/components/index.d.ts +0 -10
  231. package/lib/examples/components/index.js +0 -13
  232. package/lib/examples/vercel-ai-elements/VercelAiElementsShowcase.d.ts +0 -12
  233. package/lib/examples/vercel-ai-elements/VercelAiElementsShowcase.js +0 -69
  234. package/lib/examples/vercel-ai-elements/components/ArtifactShowcase.d.ts +0 -1
  235. package/lib/examples/vercel-ai-elements/components/ArtifactShowcase.js +0 -85
  236. package/lib/examples/vercel-ai-elements/components/CodeBlockShowcase.d.ts +0 -1
  237. package/lib/examples/vercel-ai-elements/components/CodeBlockShowcase.js +0 -62
  238. package/lib/examples/vercel-ai-elements/components/ConversationShowcase.d.ts +0 -1
  239. package/lib/examples/vercel-ai-elements/components/ConversationShowcase.js +0 -51
  240. package/lib/examples/vercel-ai-elements/components/LoaderShowcase.d.ts +0 -1
  241. package/lib/examples/vercel-ai-elements/components/LoaderShowcase.js +0 -9
  242. package/lib/examples/vercel-ai-elements/components/MessageShowcase.d.ts +0 -1
  243. package/lib/examples/vercel-ai-elements/components/MessageShowcase.js +0 -56
  244. package/lib/examples/vercel-ai-elements/components/ModelSelectorShowcase.d.ts +0 -1
  245. package/lib/examples/vercel-ai-elements/components/ModelSelectorShowcase.js +0 -50
  246. package/lib/examples/vercel-ai-elements/components/PromptInputShowcase.d.ts +0 -1
  247. package/lib/examples/vercel-ai-elements/components/PromptInputShowcase.js +0 -16
  248. package/lib/examples/vercel-ai-elements/components/ReasoningShowcase.d.ts +0 -1
  249. package/lib/examples/vercel-ai-elements/components/ReasoningShowcase.js +0 -72
  250. package/lib/examples/vercel-ai-elements/components/ShimmerShowcase.d.ts +0 -1
  251. package/lib/examples/vercel-ai-elements/components/ShimmerShowcase.js +0 -9
  252. package/lib/examples/vercel-ai-elements/components/SourcesShowcase.d.ts +0 -1
  253. package/lib/examples/vercel-ai-elements/components/SourcesShowcase.js +0 -43
  254. package/lib/examples/vercel-ai-elements/components/SuggestionShowcase.d.ts +0 -1
  255. package/lib/examples/vercel-ai-elements/components/SuggestionShowcase.js +0 -31
  256. package/lib/examples/vercel-ai-elements/components/ToolShowcase.d.ts +0 -1
  257. package/lib/examples/vercel-ai-elements/components/ToolShowcase.js +0 -54
  258. package/lib/examples/vercel-ai-elements/index.d.ts +0 -13
  259. package/lib/examples/vercel-ai-elements/index.js +0 -17
  260. package/lib/examples/vercel-ai-elements/main.d.ts +0 -1
  261. package/lib/examples/vercel-ai-elements/main.js +0 -9
  262. package/lib/examples/vercel-ai-elements/showcase.css +0 -128
  263. package/lib/hooks/useToast.d.ts +0 -44
  264. package/lib/hooks/useToast.js +0 -128
  265. package/patches/@datalayer+jupyter-lexical+1.0.8.patch +0 -11628
  266. package/patches/@datalayer+jupyter-react+2.0.2.patch +0 -5338
  267. package/style/showcase-vercel-ai.css +0 -137
  268. /package/lib/{examples/components → components}/FooterMetrics.js +0 -0
  269. /package/lib/{examples/components → components}/MockFileBrowser.js +0 -0
  270. /package/lib/{examples/components → components}/SessionTabs.js +0 -0
  271. /package/lib/{examples/components → components}/TimeTravel.js +0 -0
  272. /package/lib/{models → types}/AIAgent.d.ts +0 -0
  273. /package/lib/{models → types}/AIAgent.js +0 -0
  274. /package/lib/{models → types}/index.d.ts +0 -0
  275. /package/lib/{models → types}/index.js +0 -0
@@ -0,0 +1,30 @@
1
+ import type { McpServerSelection } from './chat/types';
2
+ export type { McpServerSelection };
3
+ export interface McpServerManagerProps {
4
+ /** Base URL for the API */
5
+ baseUrl: string;
6
+ /** Agent ID for updating the running agent's MCP servers */
7
+ agentId?: string;
8
+ /** Whether codemode is enabled - affects tool regeneration on add/remove */
9
+ enableCodemode?: boolean;
10
+ /** Currently selected MCP servers (for selection mode) */
11
+ selectedServers?: McpServerSelection[];
12
+ /** Callback when server selection changes */
13
+ onSelectedServersChange?: (servers: McpServerSelection[]) => void;
14
+ /** Callback when MCP servers are added/removed (for codemode tool regeneration) */
15
+ onServersChange?: () => void;
16
+ /** Whether the manager is disabled (e.g., for existing agents) */
17
+ disabled?: boolean;
18
+ }
19
+ /**
20
+ * McpServerManager - Manage MCP servers for agent spaces
21
+ *
22
+ * Features:
23
+ * - View MCP Catalog servers (predefined, can be enabled on-demand)
24
+ * - Add/Enable servers from the catalog
25
+ * - Remove/Disable active catalog servers
26
+ * - View MCP Config servers from mcp.json (read-only, auto-started)
27
+ * - Trigger codemode tool regeneration on changes
28
+ */
29
+ export declare function McpServerManager({ baseUrl, agentId, enableCodemode, selectedServers, onSelectedServersChange, onServersChange, disabled, }: McpServerManagerProps): import("react/jsx-runtime").JSX.Element;
30
+ export default McpServerManager;
@@ -0,0 +1,331 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2025-2026 Datalayer, Inc.
4
+ * Distributed under the terms of the Modified BSD License.
5
+ */
6
+ import { useCallback, useMemo, useState } from 'react';
7
+ import { Text, Button, Flash, Label, Spinner, IconButton, TextInput, } from '@primer/react';
8
+ import { ToolsIcon, PlusIcon, TrashIcon, SyncIcon, ServerIcon, CheckIcon, SearchIcon, } from '@primer/octicons-react';
9
+ import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
10
+ import { Box } from '@datalayer/primer-addons';
11
+ /**
12
+ * McpServerManager - Manage MCP servers for agent spaces
13
+ *
14
+ * Features:
15
+ * - View MCP Catalog servers (predefined, can be enabled on-demand)
16
+ * - Add/Enable servers from the catalog
17
+ * - Remove/Disable active catalog servers
18
+ * - View MCP Config servers from mcp.json (read-only, auto-started)
19
+ * - Trigger codemode tool regeneration on changes
20
+ */
21
+ export function McpServerManager({ baseUrl, agentId, enableCodemode = false, selectedServers = [], onSelectedServersChange, onServersChange, disabled = false, }) {
22
+ const queryClient = useQueryClient();
23
+ const [searchQuery, setSearchQuery] = useState('');
24
+ const [error, setError] = useState(null);
25
+ // Fetch all available servers (catalog + mcp.json running servers)
26
+ const catalogQuery = useQuery({
27
+ queryKey: ['mcp-available', baseUrl],
28
+ queryFn: async () => {
29
+ const response = await fetch(`${baseUrl}/api/v1/mcp/servers/available`);
30
+ if (!response.ok) {
31
+ throw new Error('Failed to fetch available MCP servers');
32
+ }
33
+ return response.json();
34
+ },
35
+ enabled: !!baseUrl,
36
+ staleTime: 1000 * 60 * 5, // 5 minutes
37
+ retry: 1,
38
+ });
39
+ // Enable server mutation
40
+ const enableMutation = useMutation({
41
+ mutationFn: async (serverName) => {
42
+ const response = await fetch(`${baseUrl}/api/v1/mcp/servers/catalog/${serverName}/enable`, { method: 'POST' });
43
+ if (!response.ok) {
44
+ const error = await response
45
+ .json()
46
+ .catch(() => ({ detail: 'Unknown error' }));
47
+ throw new Error(error.detail || 'Failed to enable server');
48
+ }
49
+ return response.json();
50
+ },
51
+ onSuccess: () => {
52
+ setError(null);
53
+ // Invalidate queries to refresh the list
54
+ queryClient.invalidateQueries({ queryKey: ['mcp-servers', baseUrl] });
55
+ queryClient.invalidateQueries({ queryKey: ['mcp-available', baseUrl] });
56
+ // Also invalidate the config query to refresh tools menu in Chat
57
+ queryClient.invalidateQueries({
58
+ queryKey: ['models', `${baseUrl}/api/v1/configure`],
59
+ });
60
+ // Notify parent about server changes (for codemode tool regeneration or other updates)
61
+ onServersChange?.();
62
+ },
63
+ onError: (error) => {
64
+ setError(error.message);
65
+ },
66
+ });
67
+ // Disable server mutation
68
+ const disableMutation = useMutation({
69
+ mutationFn: async (serverName) => {
70
+ const response = await fetch(`${baseUrl}/api/v1/mcp/servers/catalog/${serverName}/disable`, { method: 'DELETE' });
71
+ if (!response.ok) {
72
+ const error = await response
73
+ .json()
74
+ .catch(() => ({ detail: 'Unknown error' }));
75
+ throw new Error(error.detail || 'Failed to disable server');
76
+ }
77
+ },
78
+ onSuccess: () => {
79
+ setError(null);
80
+ // Invalidate queries to refresh the list
81
+ queryClient.invalidateQueries({ queryKey: ['mcp-servers', baseUrl] });
82
+ queryClient.invalidateQueries({ queryKey: ['mcp-available', baseUrl] });
83
+ // Also invalidate the config query to refresh tools menu in Chat
84
+ queryClient.invalidateQueries({
85
+ queryKey: ['models', `${baseUrl}/api/v1/configure`],
86
+ });
87
+ // Notify parent about server changes (for codemode tool regeneration or other updates)
88
+ onServersChange?.();
89
+ },
90
+ onError: (error) => {
91
+ setError(error.message);
92
+ },
93
+ });
94
+ // Update agent's MCP servers mutation
95
+ const updateAgentMcpServersMutation = useMutation({
96
+ mutationFn: async (newServers) => {
97
+ if (!agentId)
98
+ return;
99
+ const response = await fetch(`${baseUrl}/api/v1/agents/${agentId}/mcp-servers`, {
100
+ method: 'PATCH',
101
+ headers: { 'Content-Type': 'application/json' },
102
+ body: JSON.stringify({ selected_mcp_servers: newServers }),
103
+ });
104
+ if (!response.ok) {
105
+ const error = await response
106
+ .json()
107
+ .catch(() => ({ detail: 'Unknown error' }));
108
+ throw new Error(error.detail || 'Failed to update agent MCP servers');
109
+ }
110
+ return response.json();
111
+ },
112
+ onSuccess: () => {
113
+ setError(null);
114
+ // Also invalidate the config query to refresh tools menu in Chat
115
+ queryClient.invalidateQueries({
116
+ queryKey: ['models', `${baseUrl}/api/v1/configure`],
117
+ });
118
+ // Notify parent about server changes
119
+ onServersChange?.();
120
+ },
121
+ onError: (error) => {
122
+ setError(error.message);
123
+ },
124
+ });
125
+ // Separate servers into categories based on running status and config flag
126
+ // The /available endpoint returns all servers with isRunning and isConfig flags
127
+ const { assignedConfigServers, assignedCatalogServers } = useMemo(() => {
128
+ const all = catalogQuery.data || [];
129
+ const assignedConfig = [];
130
+ const assignedCatalog = [];
131
+ all.forEach(server => {
132
+ const isConfigSelected = selectedServers.some(s => s.id === server.id && s.origin === 'config');
133
+ const isCatalogSelected = selectedServers.some(s => s.id === server.id && s.origin === 'catalog');
134
+ if (server.isConfig) {
135
+ // mcp.json config servers (only shown if running)
136
+ if (server.isRunning && isConfigSelected) {
137
+ assignedConfig.push(server);
138
+ }
139
+ }
140
+ else {
141
+ // Catalog servers - show in running section if running
142
+ if (server.isRunning && isCatalogSelected) {
143
+ assignedCatalog.push(server);
144
+ }
145
+ }
146
+ });
147
+ return {
148
+ assignedConfigServers: assignedConfig,
149
+ assignedCatalogServers: assignedCatalog,
150
+ };
151
+ }, [catalogQuery.data, selectedServers]);
152
+ // Get servers that are not yet running (available to enable)
153
+ // This includes catalog servers that are NOT running and NOT config servers
154
+ const availableCatalogServers = useMemo(() => {
155
+ const all = catalogQuery.data || [];
156
+ // Filter to catalog servers (isConfig=false) that are NOT currently running
157
+ return all.filter(server => !server.isRunning && !server.isConfig);
158
+ }, [catalogQuery.data]);
159
+ // Filter catalog servers by search query
160
+ const filteredCatalogServers = useMemo(() => {
161
+ if (!searchQuery.trim())
162
+ return availableCatalogServers;
163
+ const query = searchQuery.toLowerCase();
164
+ return availableCatalogServers.filter(server => server.name.toLowerCase().includes(query) ||
165
+ server.id.toLowerCase().includes(query) ||
166
+ server.tools.some(t => t.name.toLowerCase().includes(query)));
167
+ }, [availableCatalogServers, searchQuery]);
168
+ // Handle enabling a server
169
+ const handleEnableServer = useCallback((serverName) => {
170
+ enableMutation.mutate(serverName, {
171
+ onSuccess: () => {
172
+ // After enabling, automatically add to selected servers
173
+ // Since we are enabling from catalog, origin is catalog
174
+ const selection = {
175
+ id: serverName,
176
+ origin: 'catalog',
177
+ };
178
+ const exists = selectedServers?.some(s => s.id === serverName && s.origin === 'catalog');
179
+ if (!exists) {
180
+ const newServers = [...(selectedServers || []), selection];
181
+ onSelectedServersChange?.(newServers);
182
+ // Update the running agent's MCP servers
183
+ if (agentId) {
184
+ updateAgentMcpServersMutation.mutate(newServers);
185
+ }
186
+ }
187
+ },
188
+ });
189
+ }, [
190
+ enableMutation,
191
+ selectedServers,
192
+ onSelectedServersChange,
193
+ agentId,
194
+ updateAgentMcpServersMutation,
195
+ ]);
196
+ // Handle disabling a server
197
+ const handleDisableServer = useCallback((serverName) => {
198
+ disableMutation.mutate(serverName);
199
+ // Also remove from selected servers so the Chat tools menu updates
200
+ if (selectedServers) {
201
+ const newServers = selectedServers.filter(s => !(s.id === serverName && s.origin === 'catalog'));
202
+ // Only update if changed
203
+ if (newServers.length !== selectedServers.length) {
204
+ onSelectedServersChange?.(newServers);
205
+ // Update the running agent's MCP servers
206
+ if (agentId) {
207
+ updateAgentMcpServersMutation.mutate(newServers);
208
+ }
209
+ }
210
+ }
211
+ }, [
212
+ disableMutation,
213
+ selectedServers,
214
+ onSelectedServersChange,
215
+ agentId,
216
+ updateAgentMcpServersMutation,
217
+ ]);
218
+ // Handle removing a server from selection (without disabling it globally)
219
+ const handleRemoveServer = useCallback((serverName, isConfig) => {
220
+ if (selectedServers) {
221
+ const origin = isConfig ? 'config' : 'catalog';
222
+ const newServers = selectedServers.filter(s => !(s.id === serverName && s.origin === origin));
223
+ // Only update if changed
224
+ if (newServers.length !== selectedServers.length) {
225
+ onSelectedServersChange?.(newServers);
226
+ // Update the running agent's MCP servers
227
+ if (agentId) {
228
+ updateAgentMcpServersMutation.mutate(newServers);
229
+ }
230
+ }
231
+ }
232
+ }, [
233
+ selectedServers,
234
+ onSelectedServersChange,
235
+ agentId,
236
+ updateAgentMcpServersMutation,
237
+ ]);
238
+ // Handle refreshing the server lists
239
+ const handleRefresh = useCallback(() => {
240
+ queryClient.invalidateQueries({ queryKey: ['mcp-servers', baseUrl] });
241
+ queryClient.invalidateQueries({ queryKey: ['mcp-available', baseUrl] });
242
+ }, [queryClient, baseUrl]);
243
+ // Handle server selection (for agent configuration)
244
+ const handleServerSelect = useCallback((server, selected) => {
245
+ // Determine origin
246
+ const origin = server.isConfig ? 'config' : 'catalog';
247
+ const selectionItem = { id: server.id, origin };
248
+ let newSelection;
249
+ if (selected) {
250
+ newSelection = [...(selectedServers || []), selectionItem];
251
+ }
252
+ else {
253
+ newSelection = (selectedServers || []).filter(s => !(s.id === server.id && s.origin === origin));
254
+ }
255
+ onSelectedServersChange?.(newSelection);
256
+ }, [selectedServers, onSelectedServersChange]);
257
+ const isLoading = catalogQuery.isLoading;
258
+ const isMutating = enableMutation.isPending || disableMutation.isPending;
259
+ return (_jsxs(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 4 }, children: [_jsxs(Box, { sx: {
260
+ display: 'flex',
261
+ alignItems: 'center',
262
+ justifyContent: 'space-between',
263
+ }, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2 }, children: [_jsx(ToolsIcon, { size: 16 }), _jsx(Text, { sx: { fontWeight: 'semibold' }, children: "MCP Server Management" })] }), _jsx(IconButton, { icon: SyncIcon, "aria-label": "Refresh server lists", size: "small", onClick: handleRefresh, disabled: isLoading || isMutating })] }), error && (_jsx(Flash, { variant: "danger", children: _jsx(Text, { sx: { fontSize: 1 }, children: error }) })), enableCodemode && (_jsx(Flash, { variant: "default", children: _jsxs(Text, { sx: { fontSize: 0 }, children: [_jsx("strong", { children: "Codemode enabled:" }), " Adding or removing MCP servers will regenerate the Codemode tool registry."] }) })), isLoading && (_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2, py: 3 }, children: [_jsx(Spinner, { size: "small" }), _jsx(Text, { sx: { color: 'fg.muted' }, children: "Loading MCP servers..." })] })), !isLoading && assignedConfigServers.length > 0 && (_jsxs(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [_jsxs(Text, { sx: { fontWeight: 'semibold', fontSize: 1 }, children: ["Assigned Configured Servers (", assignedConfigServers.length, ")"] }), _jsx(Text, { sx: { color: 'fg.muted', fontSize: 0 }, children: "These servers are from ~/.datalayer/mcp.json and assigned to this agent." }), _jsx(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: assignedConfigServers.map(server => (_jsx(ServerCard, { server: server, variant: "config", disabled: disabled, isSelected: true, onSelect: onSelectedServersChange ? handleServerSelect : undefined, onRemove: () => handleRemoveServer(server.id, true) }, server.id))) })] })), !isLoading && assignedCatalogServers.length > 0 && (_jsxs(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [_jsxs(Text, { sx: { fontWeight: 'semibold', fontSize: 1 }, children: ["Assigned Catalog Servers (", assignedCatalogServers.length, ")"] }), _jsx(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: assignedCatalogServers.map(server => (_jsx(ServerCard, { server: server, variant: "active", disabled: disabled || isMutating, isSelected: true, onSelect: onSelectedServersChange ? handleServerSelect : undefined, onRemove: () => handleDisableServer(server.id), isRemoving: disableMutation.isPending &&
264
+ disableMutation.variables === server.id }, server.id))) })] })), !isLoading && (_jsxs(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: [_jsxs(Text, { sx: { fontWeight: 'semibold', fontSize: 1 }, children: ["Available from Catalog (", availableCatalogServers.length, ")"] }), availableCatalogServers.length > 3 && (_jsx(TextInput, { leadingVisual: SearchIcon, placeholder: "Search servers...", value: searchQuery, onChange: e => setSearchQuery(e.target.value), sx: { width: '100%' } })), filteredCatalogServers.length === 0 ? (_jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: searchQuery
265
+ ? 'No servers match your search.'
266
+ : 'All catalog servers are already enabled.' })) : (_jsx(Box, { sx: { display: 'flex', flexDirection: 'column', gap: 2 }, children: filteredCatalogServers.map(server => (_jsx(ServerCard, { server: server, variant: "catalog", disabled: disabled || isMutating, onAdd: () => handleEnableServer(server.id), isAdding: enableMutation.isPending &&
267
+ enableMutation.variables === server.id }, server.id))) }))] }))] }));
268
+ }
269
+ function ServerCard({ server, variant, disabled = false, isSelected = false, onSelect, onAdd, onRemove, isAdding = false, isRemoving = false, }) {
270
+ // Check availability based on isAvailable field from the server
271
+ const isAvailable = server.isAvailable !== false;
272
+ const missingEnvVars = !isAvailable && server.requiredEnvVars && server.requiredEnvVars.length > 0;
273
+ return (_jsxs(Box, { sx: {
274
+ display: 'flex',
275
+ alignItems: 'flex-start',
276
+ gap: 2,
277
+ padding: 2,
278
+ borderRadius: 2,
279
+ backgroundColor: 'canvas.subtle',
280
+ border: '1px solid',
281
+ borderColor: isSelected ? 'accent.emphasis' : 'border.default',
282
+ opacity: disabled || !isAvailable ? 0.6 : 1,
283
+ cursor: onSelect && !disabled && isAvailable ? 'pointer' : 'default',
284
+ }, onClick: () => {
285
+ if (onSelect && !disabled && isAvailable) {
286
+ onSelect(server, !isSelected);
287
+ }
288
+ }, children: [_jsx(Box, { sx: {
289
+ display: 'flex',
290
+ alignItems: 'center',
291
+ justifyContent: 'center',
292
+ width: 32,
293
+ height: 32,
294
+ borderRadius: 2,
295
+ backgroundColor: variant === 'config' ? 'attention.subtle' : 'accent.subtle',
296
+ flexShrink: 0,
297
+ }, children: _jsx(ServerIcon, { size: 16 }) }), _jsxs(Box, { sx: { flex: 1, minWidth: 0 }, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2, mb: 1 }, children: [_jsx(Text, { sx: { fontWeight: 'semibold', fontSize: 1 }, children: server.name }), variant === 'active' && (_jsx(Label, { variant: "success", size: "small", children: "Active" })), variant === 'config' && (_jsx(Label, { variant: "attention", size: "small", children: "Config" })), !isAvailable && (_jsx(Label, { variant: "danger", size: "small", children: "Missing env vars" })), isSelected && (_jsxs(Label, { variant: "accent", size: "small", children: [_jsx(CheckIcon, { size: 12 }), " Selected"] }))] }), server.description && (_jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', mb: 1 }, children: server.description })), missingEnvVars && (_jsxs(Box, { sx: {
298
+ fontSize: 0,
299
+ color: 'danger.fg',
300
+ mb: 1,
301
+ p: 1,
302
+ bg: 'danger.subtle',
303
+ borderRadius: 1,
304
+ }, children: [_jsx(Text, { sx: { fontWeight: 'semibold', display: 'block', mb: 1 }, children: "Missing environment variables:" }), server.requiredEnvVars.map(envVar => (_jsx(Text, { as: "code", sx: {
305
+ display: 'inline-block',
306
+ mr: 1,
307
+ mb: 1,
308
+ px: 1,
309
+ py: '2px',
310
+ bg: 'canvas.default',
311
+ borderRadius: 1,
312
+ fontFamily: 'mono',
313
+ fontSize: 0,
314
+ }, children: envVar }, envVar)))] })), server.tools.length > 0 && (_jsxs(Text, { sx: {
315
+ fontSize: 0,
316
+ color: 'fg.muted',
317
+ overflow: 'hidden',
318
+ textOverflow: 'ellipsis',
319
+ whiteSpace: 'nowrap',
320
+ }, children: ["Tools: ", server.tools.map(t => t.name).join(', ')] })), server.transport && (_jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: ["Transport: ", server.transport] }))] }), _jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 1, flexShrink: 0 }, children: [variant === 'catalog' && onAdd && (_jsx(Button, { variant: "primary", size: "small", leadingVisual: isAdding ? Spinner : PlusIcon, onClick: e => {
321
+ e.stopPropagation();
322
+ onAdd();
323
+ }, disabled: disabled || !isAvailable || isAdding, children: "Add" })), variant === 'active' && onRemove && (_jsx(Button, { variant: "danger", size: "small", leadingVisual: isRemoving ? Spinner : TrashIcon, onClick: e => {
324
+ e.stopPropagation();
325
+ onRemove();
326
+ }, disabled: disabled || isRemoving, children: "Remove" })), variant === 'config' && onRemove && (_jsx(Button, { variant: "danger", size: "small", leadingVisual: isRemoving ? Spinner : TrashIcon, onClick: e => {
327
+ e.stopPropagation();
328
+ onRemove();
329
+ }, disabled: disabled || isRemoving, children: "Remove" })), variant === 'config' && !onRemove && (_jsx(Text, { sx: { fontSize: 0, color: 'fg.muted', fontStyle: 'italic' }, children: "Auto-started from mcp.json" }))] })] }));
330
+ }
331
+ export default McpServerManager;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- interface MockFileBrowserProps {
2
+ export interface MockFileBrowserProps {
3
3
  codemode?: boolean;
4
4
  }
5
5
  /**
@@ -9,4 +9,3 @@ interface MockFileBrowserProps {
9
9
  * In production, this would be replaced with a real Simple UI FileBrowser component.
10
10
  */
11
11
  export declare const MockFileBrowser: React.FC<MockFileBrowserProps>;
12
- export {};
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
- interface Session {
2
+ export interface Session {
3
3
  id: string;
4
4
  name: string;
5
5
  active: boolean;
6
6
  }
7
- interface SessionTabsProps {
7
+ export interface SessionTabsProps {
8
8
  sessions: Session[];
9
9
  activeSession: string;
10
10
  agentName?: string;
@@ -18,4 +18,3 @@ interface SessionTabsProps {
18
18
  * Displays the current session name.
19
19
  */
20
20
  export declare const SessionTabs: React.FC<SessionTabsProps>;
21
- export {};
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- interface TimeTravelProps {
2
+ export interface TimeTravelProps {
3
3
  value: number;
4
4
  onChange: (value: number) => void;
5
5
  min?: number;
@@ -12,4 +12,3 @@ interface TimeTravelProps {
12
12
  * Slider for navigating through document history.
13
13
  */
14
14
  export declare const TimeTravel: React.FC<TimeTravelProps>;
15
- export {};
@@ -10,6 +10,8 @@ export interface AgentDetailsProps {
10
10
  messageCount: number;
11
11
  /** Agent ID for context usage tracking */
12
12
  agentId?: string;
13
+ /** API base URL for fetching context data */
14
+ apiBase?: string;
13
15
  /** Identity provider configurations */
14
16
  identityProviders?: {
15
17
  [K in OAuthProvider]?: {
@@ -28,5 +30,5 @@ export interface AgentDetailsProps {
28
30
  /**
29
31
  * AgentDetails component displays comprehensive information about the agent.
30
32
  */
31
- export declare function AgentDetails({ name, protocol, url, messageCount, agentId, identityProviders, onIdentityConnect, onIdentityDisconnect, onBack, }: AgentDetailsProps): import("react/jsx-runtime").JSX.Element;
33
+ export declare function AgentDetails({ name, protocol, url, messageCount, agentId, apiBase, identityProviders, onIdentityConnect, onIdentityDisconnect, onBack, }: AgentDetailsProps): import("react/jsx-runtime").JSX.Element;
32
34
  export default AgentDetails;