@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.
Files changed (299) hide show
  1. package/README.md +182 -1
  2. package/lib/AgentNode.d.ts +3 -0
  3. package/lib/AgentNode.js +676 -0
  4. package/lib/App.js +1 -1
  5. package/lib/agent-node/themeStore.d.ts +3 -0
  6. package/lib/agent-node/themeStore.js +156 -0
  7. package/lib/agent-node-main.d.ts +1 -0
  8. package/lib/agent-node-main.js +14 -0
  9. package/lib/agents/AgentDetails.d.ts +22 -1
  10. package/lib/agents/AgentDetails.js +34 -47
  11. package/lib/api/index.d.ts +0 -1
  12. package/lib/api/index.js +4 -2
  13. package/lib/chat/Chat.d.ts +5 -106
  14. package/lib/chat/Chat.js +20 -14
  15. package/lib/chat/ChatFloating.d.ts +7 -140
  16. package/lib/chat/ChatFloating.js +3 -3
  17. package/lib/chat/ChatPopupStandalone.d.ts +8 -47
  18. package/lib/chat/ChatPopupStandalone.js +3 -3
  19. package/lib/chat/ChatSidebar.d.ts +4 -69
  20. package/lib/chat/ChatSidebar.js +83 -51
  21. package/lib/chat/ChatStandalone.d.ts +4 -54
  22. package/lib/chat/ChatStandalone.js +3 -3
  23. package/lib/chat/base/ChatBase.js +1414 -174
  24. package/lib/chat/display/FloatingBrandButton.js +8 -1
  25. package/lib/chat/header/ChatHeader.d.ts +3 -1
  26. package/lib/chat/header/ChatHeader.js +15 -12
  27. package/lib/chat/header/ChatHeaderBase.d.ts +30 -5
  28. package/lib/chat/header/ChatHeaderBase.js +41 -16
  29. package/lib/chat/indicators/McpStatusIndicator.d.ts +7 -4
  30. package/lib/chat/indicators/McpStatusIndicator.js +7 -32
  31. package/lib/chat/indicators/SandboxStatusIndicator.d.ts +4 -1
  32. package/lib/chat/indicators/SandboxStatusIndicator.js +91 -56
  33. package/lib/chat/indicators/SkillsStatusIndicator.d.ts +7 -0
  34. package/lib/chat/indicators/SkillsStatusIndicator.js +88 -0
  35. package/lib/chat/indicators/index.d.ts +1 -0
  36. package/lib/chat/indicators/index.js +1 -0
  37. package/lib/chat/messages/ChatMessageList.d.ts +1 -1
  38. package/lib/chat/messages/ChatMessageList.js +154 -114
  39. package/lib/chat/messages/ChatMessages.js +6 -2
  40. package/lib/chat/prompt/InputFooter.d.ts +21 -6
  41. package/lib/chat/prompt/InputFooter.js +76 -20
  42. package/lib/chat/prompt/InputPrompt.d.ts +5 -1
  43. package/lib/chat/prompt/InputPrompt.js +4 -4
  44. package/lib/chat/prompt/InputPromptFooter.d.ts +3 -1
  45. package/lib/chat/prompt/InputPromptFooter.js +3 -3
  46. package/lib/chat/prompt/InputPromptLexical.d.ts +3 -1
  47. package/lib/chat/prompt/InputPromptLexical.js +12 -5
  48. package/lib/chat/prompt/InputPromptText.d.ts +3 -1
  49. package/lib/chat/prompt/InputPromptText.js +2 -2
  50. package/lib/chat/tools/ToolApprovalBanner.js +1 -1
  51. package/lib/chat/tools/ToolCallDisplay.d.ts +3 -1
  52. package/lib/chat/tools/ToolCallDisplay.js +2 -2
  53. package/lib/chat/usage/TokenUsageBar.js +20 -2
  54. package/lib/client/AgentRuntimesClientContext.d.ts +53 -0
  55. package/lib/client/AgentRuntimesClientContext.js +55 -0
  56. package/lib/client/AgentsMixin.d.ts +0 -18
  57. package/lib/client/AgentsMixin.js +20 -30
  58. package/lib/client/IAgentRuntimesClient.d.ts +215 -0
  59. package/lib/client/IAgentRuntimesClient.js +5 -0
  60. package/lib/client/SdkAgentRuntimesClient.d.ts +151 -0
  61. package/lib/client/SdkAgentRuntimesClient.js +134 -0
  62. package/lib/client/index.d.ts +4 -1
  63. package/lib/client/index.js +3 -1
  64. package/lib/components/NotificationEventCard.js +5 -1
  65. package/lib/config/AgentConfiguration.d.ts +22 -0
  66. package/lib/config/AgentConfiguration.js +319 -64
  67. package/lib/context/ContextDistribution.d.ts +3 -1
  68. package/lib/context/ContextDistribution.js +8 -27
  69. package/lib/context/ContextInspector.d.ts +3 -1
  70. package/lib/context/ContextInspector.js +19 -67
  71. package/lib/context/ContextPanel.d.ts +3 -1
  72. package/lib/context/ContextPanel.js +104 -64
  73. package/lib/context/ContextUsage.d.ts +3 -1
  74. package/lib/context/ContextUsage.js +3 -3
  75. package/lib/context/CostTracker.d.ts +9 -3
  76. package/lib/context/CostTracker.js +26 -47
  77. package/lib/context/CostUsageChart.d.ts +12 -0
  78. package/lib/context/CostUsageChart.js +378 -0
  79. package/lib/context/GraphFlowChart.d.ts +16 -0
  80. package/lib/context/GraphFlowChart.js +182 -0
  81. package/lib/context/TokenUsageChart.d.ts +8 -1
  82. package/lib/context/TokenUsageChart.js +349 -211
  83. package/lib/context/TurnGraphChart.d.ts +39 -0
  84. package/lib/context/TurnGraphChart.js +538 -0
  85. package/lib/context/otelWsPool.d.ts +20 -0
  86. package/lib/context/otelWsPool.js +69 -0
  87. package/lib/examples/A2UiComponentGalleryExample.d.ts +0 -17
  88. package/lib/examples/A2UiComponentGalleryExample.js +315 -522
  89. package/lib/examples/A2UiContactCardExample.d.ts +0 -18
  90. package/lib/examples/A2UiContactCardExample.js +154 -411
  91. package/lib/examples/A2UiRestaurantExample.d.ts +0 -30
  92. package/lib/examples/A2UiRestaurantExample.js +114 -212
  93. package/lib/examples/A2UiViewerExample.d.ts +0 -18
  94. package/lib/examples/A2UiViewerExample.js +283 -532
  95. package/lib/examples/AgUiBackendToolRenderingExample.js +1 -1
  96. package/lib/examples/AgUiHaikuGenUiExample.d.ts +1 -1
  97. package/lib/examples/AgUiHaikuGenUiExample.js +1 -1
  98. package/lib/examples/AgUiSharedStateExample.js +2 -1
  99. package/lib/examples/AgentCheckpointsExample.js +14 -28
  100. package/lib/examples/AgentCodemodeExample.d.ts +4 -6
  101. package/lib/examples/AgentCodemodeExample.js +603 -169
  102. package/lib/examples/AgentEvalsExample.js +339 -53
  103. package/lib/examples/AgentGuardrailsExample.js +383 -66
  104. package/lib/examples/AgentHooksExample.d.ts +3 -0
  105. package/lib/examples/AgentHooksExample.js +122 -0
  106. package/lib/examples/AgentInferenceProviderExample.d.ts +3 -0
  107. package/lib/examples/AgentInferenceProviderExample.js +329 -0
  108. package/lib/examples/AgentMCPExample.d.ts +3 -0
  109. package/lib/examples/AgentMCPExample.js +481 -0
  110. package/lib/examples/AgentMemoryExample.d.ts +1 -2
  111. package/lib/examples/AgentMemoryExample.js +78 -33
  112. package/lib/examples/AgentMonitoringExample.js +261 -200
  113. package/lib/examples/AgentNotificationsExample.d.ts +1 -2
  114. package/lib/examples/AgentNotificationsExample.js +114 -33
  115. package/lib/examples/AgentOtelExample.js +32 -42
  116. package/lib/examples/AgentOutputsExample.d.ts +11 -6
  117. package/lib/examples/AgentOutputsExample.js +433 -81
  118. package/lib/examples/AgentParametersExample.d.ts +3 -0
  119. package/lib/examples/AgentParametersExample.js +248 -0
  120. package/lib/examples/AgentSandboxExample.d.ts +3 -3
  121. package/lib/examples/AgentSandboxExample.js +74 -45
  122. package/lib/examples/AgentSkillsExample.js +95 -103
  123. package/lib/examples/AgentSubagentsExample.d.ts +14 -0
  124. package/lib/examples/AgentSubagentsExample.js +228 -0
  125. package/lib/examples/AgentToolApprovalsExample.js +49 -561
  126. package/lib/examples/AgentTriggersExample.js +823 -569
  127. package/lib/examples/{AgentspecExample.d.ts → AgentspecsExample.d.ts} +2 -2
  128. package/lib/examples/AgentspecsExample.js +1096 -0
  129. package/lib/examples/ChatCustomExample.js +16 -28
  130. package/lib/examples/ChatExample.js +13 -29
  131. package/lib/examples/CopilotKitLexicalExample.js +2 -1
  132. package/lib/examples/CopilotKitNotebookExample.js +2 -1
  133. package/lib/examples/HomeExample.d.ts +15 -0
  134. package/lib/examples/HomeExample.js +77 -0
  135. package/lib/examples/Lexical2Example.js +4 -2
  136. package/lib/examples/{LexicalExample.d.ts → LexicalAgentExample.d.ts} +4 -4
  137. package/lib/examples/{LexicalExample.js → LexicalAgentExample.js} +66 -17
  138. package/lib/examples/{LexicalSidebarExample.d.ts → LexicalAgentSidebarExample.d.ts} +5 -5
  139. package/lib/examples/LexicalAgentSidebarExample.js +261 -0
  140. package/lib/examples/NotebookAgentExample.d.ts +9 -0
  141. package/lib/examples/NotebookAgentExample.js +192 -0
  142. package/lib/examples/{NotebookSidebarExample.d.ts → NotebookAgentSidebarExample.d.ts} +2 -2
  143. package/lib/examples/NotebookAgentSidebarExample.js +221 -0
  144. package/lib/examples/{DatalayerNotebookExample.d.ts → NotebookCollaborationExample.d.ts} +4 -4
  145. package/lib/examples/{DatalayerNotebookExample.js → NotebookCollaborationExample.js} +3 -3
  146. package/lib/examples/NotebookExample.d.ts +4 -7
  147. package/lib/examples/NotebookExample.js +14 -146
  148. package/lib/examples/components/AuthRequiredView.d.ts +6 -0
  149. package/lib/examples/components/AuthRequiredView.js +33 -0
  150. package/lib/examples/components/ExampleWrapper.d.ts +9 -3
  151. package/lib/examples/components/ExampleWrapper.js +45 -9
  152. package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.js +1 -1
  153. package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.js +1 -1
  154. package/lib/examples/{ag-ui → components}/haiku/index.d.ts +1 -1
  155. package/lib/examples/{ag-ui → components}/haiku/index.js +1 -1
  156. package/lib/examples/components/index.d.ts +3 -0
  157. package/lib/examples/components/index.js +4 -0
  158. package/lib/examples/{ag-ui → components}/weather/index.d.ts +1 -1
  159. package/lib/examples/{ag-ui → components}/weather/index.js +1 -1
  160. package/lib/examples/example-selector.d.ts +17 -4
  161. package/lib/examples/example-selector.js +108 -41
  162. package/lib/examples/index.d.ts +10 -6
  163. package/lib/examples/index.js +10 -6
  164. package/lib/examples/lexical/initial-content.json +6 -6
  165. package/lib/examples/main.js +257 -27
  166. package/lib/examples/utils/a2ui.d.ts +18 -0
  167. package/lib/examples/utils/a2ui.js +69 -0
  168. package/lib/examples/utils/a2uiMarkdownProvider.d.ts +7 -0
  169. package/lib/examples/utils/a2uiMarkdownProvider.js +9 -0
  170. package/lib/examples/utils/agentId.d.ts +18 -0
  171. package/lib/examples/utils/agentId.js +54 -0
  172. package/lib/examples/utils/agents/earthquake-detector.json +11 -11
  173. package/lib/examples/utils/agents/sales-forecaster.json +11 -11
  174. package/lib/examples/utils/agents/social-post-generator.json +11 -11
  175. package/lib/examples/utils/agents/stock-market.json +11 -11
  176. package/lib/examples/utils/examplesStore.js +82 -27
  177. package/lib/examples/utils/useExampleAgentRuntimesUrl.d.ts +5 -0
  178. package/lib/examples/utils/useExampleAgentRuntimesUrl.js +19 -0
  179. package/lib/hooks/index.d.ts +8 -8
  180. package/lib/hooks/index.js +7 -7
  181. package/lib/hooks/useA2A.d.ts +2 -3
  182. package/lib/hooks/useAIAgentsWebSocket.d.ts +43 -4
  183. package/lib/hooks/useAIAgentsWebSocket.js +153 -12
  184. package/lib/hooks/useAcp.d.ts +1 -2
  185. package/lib/hooks/useAgUi.d.ts +1 -1
  186. package/lib/hooks/{useAgents.d.ts → useAgentRuntimes.d.ts} +70 -4
  187. package/lib/hooks/{useAgents.js → useAgentRuntimes.js} +237 -32
  188. package/lib/hooks/useAgentsCatalog.js +1 -1
  189. package/lib/hooks/useAgentsService.d.ts +2 -2
  190. package/lib/hooks/useAgentsService.js +7 -7
  191. package/lib/hooks/useCheckpoints.js +1 -1
  192. package/lib/hooks/useConfig.d.ts +4 -1
  193. package/lib/hooks/useConfig.js +10 -3
  194. package/lib/hooks/useContextSnapshot.d.ts +9 -4
  195. package/lib/hooks/useContextSnapshot.js +9 -37
  196. package/lib/hooks/useMonitoring.js +3 -0
  197. package/lib/hooks/useSandbox.d.ts +20 -8
  198. package/lib/hooks/useSandbox.js +105 -40
  199. package/lib/hooks/useSkills.d.ts +23 -5
  200. package/lib/hooks/useSkills.js +94 -39
  201. package/lib/hooks/useToolApprovals.d.ts +60 -36
  202. package/lib/hooks/useToolApprovals.js +318 -69
  203. package/lib/hooks/useVercelAI.d.ts +1 -1
  204. package/lib/index.d.ts +2 -1
  205. package/lib/index.js +1 -0
  206. package/lib/inference/index.d.ts +0 -1
  207. package/lib/middleware/index.d.ts +0 -1
  208. package/lib/protocols/AGUIAdapter.js +6 -0
  209. package/lib/protocols/VercelAIAdapter.d.ts +7 -0
  210. package/lib/protocols/VercelAIAdapter.js +59 -7
  211. package/lib/specs/agents/agents.d.ts +21 -4
  212. package/lib/specs/agents/agents.js +2879 -316
  213. package/lib/specs/agents/index.js +3 -1
  214. package/lib/specs/benchmarks.d.ts +20 -0
  215. package/lib/specs/benchmarks.js +205 -0
  216. package/lib/specs/envvars.js +27 -20
  217. package/lib/specs/evals.d.ts +10 -9
  218. package/lib/specs/evals.js +128 -88
  219. package/lib/specs/events.d.ts +3 -10
  220. package/lib/specs/events.js +127 -84
  221. package/lib/specs/frontendTools.js +2 -2
  222. package/lib/specs/guardrails.d.ts +0 -7
  223. package/lib/specs/guardrails.js +240 -159
  224. package/lib/specs/mcpServers.js +35 -6
  225. package/lib/specs/memory.d.ts +0 -2
  226. package/lib/specs/memory.js +4 -17
  227. package/lib/specs/models.d.ts +0 -2
  228. package/lib/specs/models.js +20 -15
  229. package/lib/specs/notifications.js +102 -18
  230. package/lib/specs/outputs.js +15 -9
  231. package/lib/specs/personas.d.ts +41 -0
  232. package/lib/specs/personas.js +168 -0
  233. package/lib/specs/skills.d.ts +1 -1
  234. package/lib/specs/skills.js +23 -23
  235. package/lib/specs/teams/index.js +3 -1
  236. package/lib/specs/teams/teams.js +468 -348
  237. package/lib/specs/tools.js +4 -4
  238. package/lib/specs/triggers.js +61 -11
  239. package/lib/stores/agentRuntimeStore.d.ts +208 -0
  240. package/lib/stores/agentRuntimeStore.js +650 -0
  241. package/lib/stores/conversationStore.js +2 -2
  242. package/lib/stores/index.d.ts +1 -1
  243. package/lib/stores/index.js +1 -1
  244. package/lib/tools/adapters/copilotkit/lexicalHooks.d.ts +1 -2
  245. package/lib/tools/adapters/copilotkit/lexicalHooks.js +1 -3
  246. package/lib/tools/adapters/copilotkit/notebookHooks.d.ts +1 -2
  247. package/lib/tools/adapters/copilotkit/notebookHooks.js +1 -3
  248. package/lib/tools/index.d.ts +0 -2
  249. package/lib/tools/index.js +0 -1
  250. package/lib/types/agents-lifecycle.d.ts +18 -0
  251. package/lib/types/agents.d.ts +6 -0
  252. package/lib/types/agentspecs.d.ts +54 -1
  253. package/lib/types/benchmarks.d.ts +43 -0
  254. package/lib/types/benchmarks.js +5 -0
  255. package/lib/types/chat.d.ts +325 -8
  256. package/lib/types/context.d.ts +27 -0
  257. package/lib/types/cost.d.ts +2 -2
  258. package/lib/types/evals.d.ts +26 -17
  259. package/lib/types/index.d.ts +3 -0
  260. package/lib/types/index.js +3 -0
  261. package/lib/types/mcp.d.ts +8 -0
  262. package/lib/types/models.d.ts +2 -2
  263. package/lib/types/personas.d.ts +25 -0
  264. package/lib/types/personas.js +5 -0
  265. package/lib/types/skills.d.ts +43 -1
  266. package/lib/types/stream.d.ts +110 -0
  267. package/lib/types/stream.js +36 -0
  268. package/lib/utils/utils.d.ts +9 -5
  269. package/lib/utils/utils.js +9 -5
  270. package/package.json +19 -11
  271. package/scripts/codegen/__pycache__/generate_agents.cpython-313.pyc +0 -0
  272. package/scripts/codegen/__pycache__/generate_benchmarks.cpython-313.pyc +0 -0
  273. package/scripts/codegen/__pycache__/generate_evals.cpython-313.pyc +0 -0
  274. package/scripts/codegen/__pycache__/generate_events.cpython-313.pyc +0 -0
  275. package/scripts/codegen/__pycache__/versioning.cpython-313.pyc +0 -0
  276. package/scripts/codegen/generate_agents.py +187 -45
  277. package/scripts/codegen/generate_benchmarks.py +441 -0
  278. package/scripts/codegen/generate_evals.py +94 -16
  279. package/scripts/codegen/generate_events.py +35 -14
  280. package/scripts/codegen/generate_personas.py +319 -0
  281. package/scripts/codegen/generate_skills.py +9 -9
  282. package/scripts/sync-jupyter.sh +26 -7
  283. package/lib/api/tool-approvals.d.ts +0 -62
  284. package/lib/api/tool-approvals.js +0 -145
  285. package/lib/examples/AgentspecExample.js +0 -705
  286. package/lib/examples/LexicalSidebarExample.js +0 -163
  287. package/lib/examples/NotebookSidebarExample.js +0 -119
  288. package/lib/examples/NotebookSimpleExample.d.ts +0 -6
  289. package/lib/examples/NotebookSimpleExample.js +0 -22
  290. package/lib/examples/ag-ui/index.d.ts +0 -10
  291. package/lib/examples/ag-ui/index.js +0 -16
  292. package/lib/hooks/useAgentsRegistry.d.ts +0 -10
  293. package/lib/hooks/useAgentsRegistry.js +0 -20
  294. package/lib/stores/agentsStore.d.ts +0 -123
  295. package/lib/stores/agentsStore.js +0 -270
  296. /package/lib/examples/{ag-ui → components}/haiku/HaikuDisplay.d.ts +0 -0
  297. /package/lib/examples/{ag-ui → components}/haiku/InlineHaikuCard.d.ts +0 -0
  298. /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.d.ts +0 -0
  299. /package/lib/examples/{ag-ui → components}/weather/InlineWeatherCard.js +0 -0
@@ -1,705 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- /*
3
- * Copyright (c) 2025-2026 Datalayer, Inc.
4
- * Distributed under the terms of the Modified BSD License.
5
- */
6
- /// <reference types="vite/client" />
7
- import React, { useState, useEffect, useCallback, useRef } from 'react';
8
- import { PageLayout, IconButton } from '@primer/react';
9
- import { SidebarCollapseIcon, SidebarExpandIcon } from '@primer/octicons-react';
10
- import { AiAgentIcon } from '@datalayer/icons-react';
11
- import { Blankslate } from '@primer/react/experimental';
12
- import { QueryClient, QueryClientProvider, useQuery, } from '@tanstack/react-query';
13
- import { Box } from '@datalayer/primer-addons';
14
- import { ThemedProvider } from './utils/themedProvider';
15
- import { Chat } from '../chat';
16
- import { DEFAULT_MODEL } from '../specs';
17
- import { useAgentsStore } from './utils/examplesStore';
18
- import { useIdentity } from '../identity';
19
- import { isSpecSelection, getSpecId } from '../config/AgentConfiguration';
20
- import { MockFileBrowser, MainContent, Header } from './components';
21
- import { AgentConfiguration } from '../config';
22
- import { useChatStore } from '../stores';
23
- // Create a query client for React Query
24
- const queryClient = new QueryClient({
25
- defaultOptions: {
26
- queries: {
27
- staleTime: 1000 * 60 * 5, // 5 minutes
28
- gcTime: 1000 * 60 * 10, // 10 minutes
29
- retry: 1,
30
- refetchOnWindowFocus: false,
31
- },
32
- },
33
- });
34
- /**
35
- * Hook to fetch codemode status and compute Jupyter error banner.
36
- * Must be used inside QueryClientProvider.
37
- */
38
- function useJupyterSandboxStatus(baseUrl, isConfigured, enableCodemode, useJupyterSandbox) {
39
- const { data: codemodeStatus } = useQuery({
40
- queryKey: ['codemode-status', baseUrl],
41
- queryFn: async () => {
42
- const response = await fetch(`${baseUrl}/api/v1/configure/codemode-status`);
43
- if (!response.ok) {
44
- throw new Error('Failed to fetch codemode status');
45
- }
46
- return response.json();
47
- },
48
- enabled: isConfigured && enableCodemode && useJupyterSandbox,
49
- refetchInterval: 10000, // Refresh every 10 seconds
50
- });
51
- return React.useMemo(() => {
52
- if (!isConfigured || !enableCodemode || !useJupyterSandbox) {
53
- return undefined;
54
- }
55
- const sandbox = codemodeStatus?.sandbox;
56
- if (!sandbox) {
57
- return undefined;
58
- }
59
- // Check if Jupyter variant is selected but not connected
60
- if (sandbox.variant === 'local-jupyter' && !sandbox.jupyter_connected) {
61
- return {
62
- message: sandbox.jupyter_error
63
- ? `Jupyter Sandbox Error: ${sandbox.jupyter_error}`
64
- : 'Jupyter Sandbox not connected. Code execution may fail.',
65
- variant: 'danger',
66
- };
67
- }
68
- return undefined;
69
- }, [isConfigured, enableCodemode, useJupyterSandbox, codemodeStatus]);
70
- }
71
- function ChatWithJupyterStatus({ baseUrl, isConfigured, enableCodemode, useJupyterSandbox, chatProps, }) {
72
- const jupyterErrorBanner = useJupyterSandboxStatus(baseUrl, isConfigured, enableCodemode, useJupyterSandbox);
73
- return _jsx(Chat, { ...chatProps, errorBanner: jupyterErrorBanner });
74
- }
75
- // Default configuration - use environment variable if available
76
- // Note: Vercel AI connects to Jupyter server (8888), other protocols connect to agent-runtimes server (8765)
77
- const DEFAULT_WS_URL = import.meta.env.VITE_ACP_WS_URL || 'ws://localhost:8765/api/v1/acp/ws';
78
- const DEFAULT_BASE_URL = import.meta.env.VITE_BASE_URL || 'http://localhost:8765';
79
- const DEFAULT_AGENT_ID = 'demo-agent';
80
- const DEFAULT_SYSTEM_PROMPT = 'You are a helpful AI assistant.';
81
- const RIGHT_PANE_WIDTH = {
82
- min: '420px',
83
- default: '80vw',
84
- max: '95vw',
85
- };
86
- // GitHub OAuth client ID - set via environment variable for security
87
- // For development, you can create a GitHub OAuth App at:
88
- // https://github.com/settings/developers
89
- const GITHUB_CLIENT_ID = import.meta.env.VITE_GITHUB_CLIENT_ID || 'demo-client-id';
90
- // Kaggle API token - set via environment variable
91
- // Get your token at: https://www.kaggle.com/settings/account (API section)
92
- // Download kaggle.json and use the "key" value
93
- const KAGGLE_TOKEN = import.meta.env.VITE_KAGGLE_TOKEN || '';
94
- const MOCK_SKILLS = [];
95
- // Skills are now fetched dynamically from the backend API (/api/v1/skills)
96
- // when Codemode is enabled. The AgentConfiguration component handles this.
97
- // Build default identity providers from env vars (backward compatibility)
98
- const DEFAULT_IDENTITY_PROVIDERS = {
99
- ...(GITHUB_CLIENT_ID
100
- ? {
101
- github: {
102
- type: 'oauth',
103
- clientId: GITHUB_CLIENT_ID,
104
- scopes: ['read:user', 'user:email', 'repo'],
105
- },
106
- }
107
- : {}),
108
- ...(KAGGLE_TOKEN
109
- ? {
110
- kaggle: {
111
- type: 'token',
112
- token: KAGGLE_TOKEN,
113
- displayName: 'Kaggle',
114
- iconUrl: 'https://www.kaggle.com/static/images/favicon.ico',
115
- },
116
- }
117
- : {}),
118
- };
119
- const AgentRuntimeFormExample = ({ initialWsUrl = DEFAULT_WS_URL, initialBaseUrl = DEFAULT_BASE_URL, initialAgentName = DEFAULT_AGENT_ID, initialAgentLibrary = 'pydantic-ai', initialTransport = 'vercel-ai', initialModel = DEFAULT_MODEL, initialEnableCodemode = false, initialAllowDirectToolCalls = false, initialEnableToolReranker = false, initialSelectedMcpServers = [], autoSelectMcpServers = false, identityProviders = DEFAULT_IDENTITY_PROVIDERS,
120
- // Deprecated props - merged into identityProviders for backward compat
121
- githubClientId, kaggleToken, }) => {
122
- const [wsUrl, setWsUrl] = useState(initialWsUrl);
123
- const [baseUrl, setBaseUrl] = useState(initialBaseUrl);
124
- const [agentName, setAgentName] = useState(initialAgentName);
125
- const [selectedAgentId, setSelectedAgentId] = useState('new-agent');
126
- const [agentLibrary, setAgentLibrary] = useState(initialAgentLibrary);
127
- const [transport, setTransport] = useState(initialTransport);
128
- const [extensions, setExtensions] = useState([]);
129
- const [model, setModel] = useState(initialModel);
130
- const [description, setDescription] = useState('');
131
- const [goal, setGoal] = useState('');
132
- const [systemPrompt, setSystemPrompt] = useState(DEFAULT_SYSTEM_PROMPT);
133
- const [systemPromptCodemodeAddons, setSystemPromptCodemodeAddons] = useState('');
134
- const [tools, setTools] = useState([]);
135
- const [sandboxVariant, setSandboxVariant] = useState('');
136
- const [selectedLibrarySpec, setSelectedLibrarySpec] = useState(null);
137
- const [isConfigured, setIsConfigured] = useState(false);
138
- // Agent capabilities state (moved from Header toggles)
139
- const [selectedSkills, setSelectedSkills] = useState([]);
140
- const [enableCodemode, setEnableCodemode] = useState(initialEnableCodemode);
141
- const [useJupyterSandbox, setUseJupyterSandbox] = useState(false);
142
- const [allowDirectToolCalls, setAllowDirectToolCalls] = useState(initialAllowDirectToolCalls);
143
- const [enableToolReranker, setEnableToolReranker] = useState(initialEnableToolReranker);
144
- const [selectedMcpServers, setSelectedMcpServers] = useState(initialSelectedMcpServers);
145
- const autoSelectRef = useRef(false);
146
- const enableSkills = selectedSkills.length > 0;
147
- // =====================================================================
148
- // Two-Container Codemode Architecture
149
- // =====================================================================
150
- //
151
- // When Jupyter sandbox is enabled, the architecture uses two containers:
152
- //
153
- // ┌─────────────────────────────────────┐ ┌─────────────────────────────────┐
154
- // │ agent-runtimes (port 8765) │ │ jupyter server (port 8888) │
155
- // │ ┌─────────────────────────────┐ │ │ ┌─────────────────────────┐ │
156
- // │ │ MCP Servers (stdio) │ │ │ │ Jupyter Kernel │ │
157
- // │ │ - github, filesystem, etc │◀───┼──┼──│ executes generated │ │
158
- // │ └─────────────────────────────┘ │ │ │ Python code │ │
159
- // │ ┌─────────────────────────────┐ │ │ └─────────────────────────┘ │
160
- // │ │ /api/v1/mcp/proxy/* │ │ │ │
161
- // │ │ HTTP proxy for tool calls │ │ │ Tool calls go via HTTP to │
162
- // │ └─────────────────────────────┘ │ │ agent-runtimes MCP proxy │
163
- // └─────────────────────────────────────┘ └─────────────────────────────────┘
164
- //
165
- // The backend automatically configures mcp_proxy_url when jupyter_sandbox
166
- // is provided, defaulting to http://0.0.0.0:8765/api/v1/mcp/proxy
167
- //
168
- // =====================================================================
169
- // Jupyter sandbox URL (used when useJupyterSandbox is true)
170
- // Can be configured via VITE_JUPYTER_SANDBOX_URL environment variable
171
- const jupyterSandboxUrl = import.meta.env.VITE_JUPYTER_SANDBOX_URL ||
172
- 'http://localhost:8888/api/jupyter-server?token=60c1661cc408f978c309d04157af55c9588ff9557c9380e4fb50785750703da6';
173
- const handleSelectedServersChange = React.useCallback((newServers) => {
174
- const oldServers = selectedMcpServers;
175
- // Find added and removed servers
176
- const oldIds = new Set(oldServers.map(s => `${s.id}:${s.origin}`));
177
- const newIds = new Set(newServers.map(s => `${s.id}:${s.origin}`));
178
- const added = newServers.filter(s => !oldIds.has(`${s.id}:${s.origin}`));
179
- const removed = oldServers.filter(s => !newIds.has(`${s.id}:${s.origin}`));
180
- // Add system message about tool changes if there are any
181
- if ((added.length > 0 || removed.length > 0) && isConfigured) {
182
- let messageContent = '';
183
- if (added.length > 0) {
184
- const addedNames = added.map(s => `${s.id} (${s.origin})`).join(', ');
185
- messageContent += `🔧 Tools added: ${addedNames}. `;
186
- }
187
- if (removed.length > 0) {
188
- const removedNames = removed
189
- .map(s => `${s.id} (${s.origin})`)
190
- .join(', ');
191
- messageContent += `🔧 Tools removed: ${removedNames}. You no longer have access to these tools.`;
192
- }
193
- if (messageContent) {
194
- const systemMessage = {
195
- id: `system-mcp-${Date.now()}`,
196
- role: 'system',
197
- content: messageContent.trim(),
198
- createdAt: new Date(),
199
- };
200
- useChatStore.getState().addMessage(systemMessage);
201
- }
202
- }
203
- setSelectedMcpServers(newServers);
204
- }, [selectedMcpServers, isConfigured]);
205
- // Merge deprecated props into identityProviders for backward compatibility
206
- const mergedIdentityProviders = React.useMemo(() => {
207
- const merged = { ...identityProviders };
208
- // Add deprecated githubClientId if provided and not already in config
209
- if (githubClientId && !merged.github) {
210
- merged.github = {
211
- type: 'oauth',
212
- clientId: githubClientId,
213
- scopes: ['read:user', 'user:email', 'repo'],
214
- };
215
- }
216
- // Add deprecated kaggleToken if provided and not already in config
217
- if (kaggleToken && !merged.kaggle) {
218
- merged.kaggle = {
219
- type: 'token',
220
- token: kaggleToken,
221
- displayName: 'Kaggle',
222
- iconUrl: 'https://www.kaggle.com/static/images/favicon.ico',
223
- };
224
- }
225
- return merged;
226
- }, [identityProviders, githubClientId, kaggleToken]);
227
- // Extract OAuth providers for useIdentity hook (token providers are handled separately)
228
- const oauthProvidersConfig = React.useMemo(() => {
229
- const providers = {};
230
- for (const [provider, config] of Object.entries(mergedIdentityProviders)) {
231
- if (config.type === 'oauth') {
232
- providers[provider] = {
233
- clientId: config.clientId,
234
- scopes: config.scopes,
235
- };
236
- }
237
- }
238
- return Object.keys(providers).length > 0 ? providers : undefined;
239
- }, [mergedIdentityProviders]);
240
- // Extract token-based providers for auto-connection
241
- const tokenProviders = React.useMemo(() => {
242
- const providers = [];
243
- for (const [provider, config] of Object.entries(mergedIdentityProviders)) {
244
- if (config.type === 'token') {
245
- providers.push({
246
- provider,
247
- token: config.token,
248
- displayName: config.displayName,
249
- iconUrl: config.iconUrl,
250
- });
251
- }
252
- }
253
- return providers;
254
- }, [mergedIdentityProviders]);
255
- // Identity state - pass OAuth providers to configure them before callback is processed
256
- const { connectWithToken, isConnected: isIdentityConnected } = useIdentity({
257
- providers: oauthProvidersConfig,
258
- autoHandleCallback: true,
259
- });
260
- // Track which token providers we've attempted to connect
261
- const connectedTokenProvidersRef = useRef(new Set());
262
- // Auto-connect all token-based providers if available and not already connected
263
- useEffect(() => {
264
- for (const { provider, token, displayName, iconUrl } of tokenProviders) {
265
- // Skip if we've already attempted to connect this provider
266
- if (connectedTokenProvidersRef.current.has(provider)) {
267
- continue;
268
- }
269
- // Skip if already connected
270
- if (isIdentityConnected(provider)) {
271
- connectedTokenProvidersRef.current.add(provider);
272
- continue;
273
- }
274
- // Mark as attempted
275
- connectedTokenProvidersRef.current.add(provider);
276
- connectWithToken(provider, token, { displayName, iconUrl })
277
- .then(() => {
278
- console.log(`[AgentRuntimeFormExample] ${provider} connected with token`);
279
- })
280
- .catch(err => {
281
- console.error(`[AgentRuntimeFormExample] Failed to connect ${provider}:`, err);
282
- // Remove from attempted set so we can retry
283
- connectedTokenProvidersRef.current.delete(provider);
284
- });
285
- }
286
- }, [tokenProviders, connectWithToken, isIdentityConnected]);
287
- // Handle identity connect/disconnect
288
- const handleIdentityConnect = useCallback((identity) => {
289
- console.log('[AgentRuntimeFormExample] Identity connected:', identity.provider, identity.userInfo?.name || identity.userInfo?.email);
290
- }, []);
291
- const handleIdentityDisconnect = useCallback((provider) => {
292
- console.log('[AgentRuntimeFormExample] Identity disconnected:', provider);
293
- }, []);
294
- // Handle codemode change - keep MCP server selections to scope codemode tools
295
- const handleEnableCodemodeChange = (enabled) => {
296
- setEnableCodemode(enabled);
297
- if (!enabled) {
298
- setAllowDirectToolCalls(false);
299
- setEnableToolReranker(false);
300
- setUseJupyterSandbox(false);
301
- }
302
- };
303
- // UI state
304
- const [activeSession, setActiveSession] = useState('session-1');
305
- const [codemode, _] = useState(false);
306
- const [showContextTree, setShowContextTree] = useState(false);
307
- const [leftPaneVisible, setLeftPaneVisible] = useState(false);
308
- const [rightPaneVisible, setRightPaneVisible] = useState(true);
309
- const [isCreatingAgent, setIsCreatingAgent] = useState(false);
310
- const [createError, setCreateError] = useState(null);
311
- // Get agents and current agent from store
312
- const agents = useAgentsStore(state => state.agents);
313
- const currentAgent = useAgentsStore(state => state.getAgentById(selectedAgentId));
314
- const toggleAgentStatus = useAgentsStore(state => state.toggleAgentStatus);
315
- // Initialize transport from selected agent on mount
316
- useEffect(() => {
317
- if (currentAgent) {
318
- setTransport(currentAgent.protocol);
319
- setAgentName(currentAgent.id);
320
- }
321
- }, [currentAgent]);
322
- // Auto-select MCP servers for codemode when requested
323
- useEffect(() => {
324
- if (!autoSelectMcpServers || autoSelectRef.current)
325
- return;
326
- if (!enableCodemode)
327
- return;
328
- if (selectedMcpServers.length > 0)
329
- return;
330
- if (!baseUrl)
331
- return;
332
- const loadServers = async () => {
333
- try {
334
- const response = await fetch(`${baseUrl}/api/v1/configure`);
335
- if (!response.ok)
336
- return;
337
- const data = await response.json();
338
- const servers = data?.mcpServers || [];
339
- const available = servers.filter((s) => s.isAvailable);
340
- if (available.length > 0) {
341
- setSelectedMcpServers([{ id: available[0].id, origin: 'config' }]);
342
- autoSelectRef.current = true;
343
- }
344
- }
345
- catch {
346
- // no-op
347
- }
348
- };
349
- void loadServers();
350
- }, [autoSelectMcpServers, enableCodemode, selectedMcpServers, baseUrl]);
351
- // Track previous MCP servers to detect changes
352
- const prevMcpServersRef = useRef(selectedMcpServers);
353
- // Cache for library specs (fetched on-demand, outside QueryClientProvider)
354
- const librarySpecsRef = useRef(null);
355
- const fetchLibrarySpecs = useCallback(async () => {
356
- if (librarySpecsRef.current)
357
- return librarySpecsRef.current;
358
- try {
359
- const response = await fetch(`${baseUrl}/api/v1/agents/library`);
360
- if (!response.ok)
361
- return [];
362
- const data = await response.json();
363
- librarySpecsRef.current = data;
364
- return data;
365
- }
366
- catch {
367
- return [];
368
- }
369
- }, [baseUrl]);
370
- const handleAgentSelect = async (agentId) => {
371
- setSelectedAgentId(agentId);
372
- setCreateError(null);
373
- if (agentId === 'new-agent') {
374
- // Reset to defaults for new agent
375
- setAgentName(DEFAULT_AGENT_ID);
376
- setDescription('');
377
- setGoal('');
378
- setSystemPrompt(DEFAULT_SYSTEM_PROMPT);
379
- setSystemPromptCodemodeAddons('');
380
- setTools([]);
381
- setSandboxVariant('');
382
- setSelectedSkills([]);
383
- setSelectedMcpServers([]);
384
- setSelectedLibrarySpec(null);
385
- setEnableCodemode(false);
386
- setAllowDirectToolCalls(false);
387
- setEnableToolReranker(false);
388
- setUseJupyterSandbox(false);
389
- setTransport('ag-ui');
390
- }
391
- else if (isSpecSelection(agentId)) {
392
- // Populate form fields from the selected library spec
393
- const specId = getSpecId(agentId);
394
- const specs = await fetchLibrarySpecs();
395
- const spec = specs.find(s => s.id === specId);
396
- if (spec) {
397
- setSelectedLibrarySpec(spec);
398
- setAgentName(spec.id);
399
- setDescription(spec.description || '');
400
- setGoal(spec.goal || '');
401
- setSystemPrompt(spec.systemPrompt || spec.goal || DEFAULT_SYSTEM_PROMPT);
402
- setSystemPromptCodemodeAddons(spec.systemPromptCodemodeAddons || '');
403
- setTools(spec.tools || []);
404
- setSandboxVariant(spec.sandboxVariant || '');
405
- if (spec.model) {
406
- setModel(spec.model);
407
- }
408
- if (spec.protocol === 'ag-ui' ||
409
- spec.protocol === 'acp' ||
410
- spec.protocol === 'vercel-ai' ||
411
- spec.protocol === 'a2a') {
412
- setTransport(spec.protocol);
413
- }
414
- setSelectedMcpServers((spec.mcpServers || []).map(server => ({
415
- id: server.id,
416
- origin: 'config',
417
- })));
418
- setSelectedSkills(spec.skills || []);
419
- const codemodeConfig = spec.codemode && typeof spec.codemode === 'object'
420
- ? spec.codemode
421
- : null;
422
- const codemodeEnabled = !!spec.systemPromptCodemodeAddons || !!codemodeConfig?.enabled;
423
- setEnableCodemode(codemodeEnabled);
424
- setAllowDirectToolCalls(Boolean(codemodeConfig?.allowDirectToolCalls ??
425
- codemodeConfig?.allow_direct_tool_calls));
426
- setEnableToolReranker(Boolean(codemodeConfig?.enableToolReranker ??
427
- codemodeConfig?.enable_tool_reranker));
428
- setUseJupyterSandbox(spec.sandboxVariant === 'local-jupyter' ||
429
- spec.sandboxVariant === 'jupyter');
430
- }
431
- else {
432
- setSelectedLibrarySpec(null);
433
- }
434
- }
435
- else {
436
- setSelectedLibrarySpec(null);
437
- const agent = agents.find(a => a.id === agentId);
438
- if (agent) {
439
- setAgentName(agent.id);
440
- setTransport(agent.protocol);
441
- }
442
- }
443
- };
444
- /**
445
- * Create a new agent via the API
446
- */
447
- const createAgentOnServer = useCallback(async () => {
448
- setIsCreatingAgent(true);
449
- setCreateError(null);
450
- try {
451
- // Resolve spec ID if creating from a library spec
452
- const specId = isSpecSelection(selectedAgentId)
453
- ? getSpecId(selectedAgentId)
454
- : undefined;
455
- const response = await fetch(`${baseUrl}/api/v1/agents`, {
456
- method: 'POST',
457
- headers: {
458
- 'Content-Type': 'application/json',
459
- },
460
- body: JSON.stringify({
461
- name: agentName,
462
- description: description || `Agent created via UI (${agentLibrary})`,
463
- goal: goal || undefined,
464
- agent_library: agentLibrary,
465
- transport: transport,
466
- model: model,
467
- system_prompt: systemPrompt || DEFAULT_SYSTEM_PROMPT,
468
- system_prompt_codemode_addons: systemPromptCodemodeAddons || undefined,
469
- tools: tools,
470
- sandbox_variant: sandboxVariant || undefined,
471
- enable_skills: enableSkills,
472
- enable_codemode: enableCodemode,
473
- allow_direct_tool_calls: allowDirectToolCalls,
474
- enable_tool_reranker: enableToolReranker,
475
- selected_mcp_servers: selectedMcpServers,
476
- skills: selectedSkills,
477
- jupyter_sandbox: useJupyterSandbox ? jupyterSandboxUrl : undefined,
478
- agent_spec: selectedLibrarySpec || undefined,
479
- ...(specId ? { agent_spec_id: specId } : {}),
480
- }),
481
- });
482
- if (!response.ok) {
483
- const errorData = await response
484
- .json()
485
- .catch(() => ({ detail: 'Unknown error' }));
486
- throw new Error(errorData.detail || `Failed to create agent: ${response.status}`);
487
- }
488
- const data = await response.json();
489
- console.log('[AgentRuntimeExample] Agent created:', data);
490
- return data.id;
491
- }
492
- catch (error) {
493
- const errorMessage = error instanceof Error ? error.message : 'Failed to create agent';
494
- console.error('[AgentRuntimeExample] Error creating agent:', errorMessage);
495
- setCreateError(errorMessage);
496
- return null;
497
- }
498
- finally {
499
- setIsCreatingAgent(false);
500
- }
501
- }, [
502
- baseUrl,
503
- agentName,
504
- agentLibrary,
505
- description,
506
- goal,
507
- transport,
508
- model,
509
- systemPrompt,
510
- systemPromptCodemodeAddons,
511
- tools,
512
- sandboxVariant,
513
- enableSkills,
514
- enableCodemode,
515
- allowDirectToolCalls,
516
- enableToolReranker,
517
- selectedMcpServers,
518
- selectedSkills,
519
- useJupyterSandbox,
520
- jupyterSandboxUrl,
521
- selectedAgentId,
522
- selectedLibrarySpec,
523
- ]);
524
- /**
525
- * Delete an agent via the API
526
- */
527
- const deleteAgentOnServer = useCallback(async (agentId) => {
528
- try {
529
- const response = await fetch(`${baseUrl}/api/v1/agents/${agentId}`, {
530
- method: 'DELETE',
531
- });
532
- if (!response.ok) {
533
- console.warn(`[AgentRuntimeExample] Failed to delete agent: ${response.status}`);
534
- return false;
535
- }
536
- console.log('[AgentRuntimeExample] Agent deleted:', agentId);
537
- return true;
538
- }
539
- catch (error) {
540
- console.warn('[AgentRuntimeExample] Error deleting agent:', error);
541
- return false;
542
- }
543
- }, [baseUrl]);
544
- // Track MCP servers for reference (no longer triggers recreation)
545
- // MCP server updates are now handled via PATCH endpoint by McpServerManager
546
- useEffect(() => {
547
- prevMcpServersRef.current = selectedMcpServers;
548
- }, [selectedMcpServers]);
549
- // True when creating a new agent (blank or from a library spec)
550
- const isNewMode = selectedAgentId === 'new-agent' || isSpecSelection(selectedAgentId);
551
- const handleConnect = async () => {
552
- // For existing agents (not new-agent or spec), ensure transport and agentName are set
553
- if (!isNewMode) {
554
- const agent = agents.find(a => a.id === selectedAgentId);
555
- if (agent) {
556
- setTransport(agent.protocol);
557
- setAgentName(agent.id);
558
- }
559
- setIsConfigured(true);
560
- return;
561
- }
562
- // For vercel-ai-jupyter, no server-side agent creation needed
563
- // It uses Jupyter server's built-in agent endpoint
564
- if (transport === 'vercel-ai-jupyter') {
565
- setIsConfigured(true);
566
- return;
567
- }
568
- // For new agents, first create the agent on the server
569
- if (transport === 'acp' && wsUrl && agentName) {
570
- const createdAgentId = await createAgentOnServer();
571
- if (createdAgentId) {
572
- setAgentName(createdAgentId);
573
- setIsConfigured(true);
574
- }
575
- }
576
- else if ((transport === 'ag-ui' ||
577
- transport === 'vercel-ai' ||
578
- transport === 'a2a') &&
579
- baseUrl &&
580
- agentName) {
581
- const createdAgentId = await createAgentOnServer();
582
- if (createdAgentId) {
583
- setAgentName(createdAgentId);
584
- setIsConfigured(true);
585
- }
586
- }
587
- };
588
- const handleReset = async () => {
589
- // Delete the agent from the server if we created it
590
- if ((selectedAgentId === 'new-agent' || isSpecSelection(selectedAgentId)) &&
591
- agentName) {
592
- await deleteAgentOnServer(agentName);
593
- }
594
- setIsConfigured(false);
595
- };
596
- return (_jsx(QueryClientProvider, { client: queryClient, children: _jsx(ThemedProvider, { children: _jsxs(PageLayout, { containerWidth: "full", children: [_jsx(Header, { activeSession: activeSession, agentName: isNewMode ? undefined : currentAgent?.name, agentDescription: isNewMode ? undefined : currentAgent?.description, agentStatus: currentAgent?.status, showContextTree: showContextTree, isNewAgent: isNewMode, isConfigured: isConfigured, onSessionChange: setActiveSession, onToggleContextTree: () => setShowContextTree(!showContextTree), onToggleStatus: currentAgent
597
- ? () => toggleAgentStatus(currentAgent.id)
598
- : undefined }), leftPaneVisible ? (_jsxs(_Fragment, { children: [_jsx(Box, { sx: {
599
- position: 'fixed',
600
- left: 0,
601
- top: '50%',
602
- transform: 'translateY(-50%)',
603
- zIndex: 100,
604
- }, children: _jsx(IconButton, { icon: SidebarCollapseIcon, "aria-label": "Collapse left pane", size: "small", onClick: () => setLeftPaneVisible(false), sx: {
605
- borderRadius: '0 6px 6px 0',
606
- bg: 'canvas.default',
607
- border: '1px solid',
608
- borderLeft: 'none',
609
- borderColor: 'border.default',
610
- } }) }), _jsx(PageLayout.Pane, { position: "start", "aria-label": "File browser pane", resizable: true, sticky: true, width: { min: '250px', default: '300px', max: '90px' }, children: isNewMode ? (_jsxs(Blankslate, { border: true, spacious: true, narrow: true, children: [_jsx(Blankslate.Visual, { children: _jsx(AiAgentIcon, { colored: true, size: 48 }) }), _jsx(Blankslate.Heading, { children: "Agent Runtimes" }), _jsx(Box, { sx: { textAlign: 'center' }, children: _jsx(Blankslate.Description, { children: "Expose AI Agents through multiple protocols." }) })] })) : (_jsx(MockFileBrowser, { codemode: codemode })) })] })) : (_jsx(Box, { sx: {
611
- position: 'fixed',
612
- left: 0,
613
- top: '50%',
614
- transform: 'translateY(-50%)',
615
- zIndex: 100,
616
- }, children: _jsx(IconButton, { icon: SidebarExpandIcon, "aria-label": "Expand left pane", size: "small", onClick: () => setLeftPaneVisible(true), sx: {
617
- borderRadius: '0 6px 6px 0',
618
- bg: 'canvas.default',
619
- border: '1px solid',
620
- borderLeft: 'none',
621
- borderColor: 'border.default',
622
- } }) })), _jsx(PageLayout.Content, { children: _jsx(MainContent, { showWelcomeMessage: true, isConfigured: isConfigured, baseUrl: baseUrl, agentId: currentAgent?.id || agentName, enableCodemode: enableCodemode, selectedMcpServers: selectedMcpServers, onSelectedMcpServersChange: handleSelectedServersChange, onMcpServersChange: () => {
623
- // Trigger codemode tool regeneration when MCP servers change at runtime
624
- console.log('[AgentRuntimeFormExample] MCP servers changed, regenerating codemode tools...');
625
- // The Chat component will pick up the new selectedMcpServers via props
626
- } }) }), rightPaneVisible ? (_jsxs(_Fragment, { children: [_jsx(Box, { sx: {
627
- position: 'fixed',
628
- right: 0,
629
- top: '50%',
630
- transform: 'translateY(-50%)',
631
- zIndex: 100,
632
- }, children: _jsx(IconButton, { icon: SidebarCollapseIcon, "aria-label": "Collapse right pane", size: "small", onClick: () => setRightPaneVisible(false), sx: {
633
- borderRadius: '6px 0 0 6px',
634
- bg: 'canvas.default',
635
- border: '1px solid',
636
- borderRight: 'none',
637
- borderColor: 'border.default',
638
- } }) }), _jsx(PageLayout.Pane, { position: "end", "aria-label": "Agent configuration and chat pane", width: RIGHT_PANE_WIDTH, resizable: true, sticky: true, children: _jsx(Box, { sx: {
639
- height: '100%',
640
- display: 'flex',
641
- flexDirection: 'column',
642
- p: 2,
643
- }, children: !isConfigured ? (_jsx(AgentConfiguration, { agentLibrary: agentLibrary, protocol: currentAgent?.protocol || transport, extensions: extensions, wsUrl: wsUrl, baseUrl: baseUrl, agentName: agentName, description: description, goal: goal, model: model, systemPrompt: systemPrompt, systemPromptCodemodeAddons: systemPromptCodemodeAddons, tools: tools, sandboxVariant: sandboxVariant, agents: agents, selectedAgentId: selectedAgentId, isCreatingAgent: isCreatingAgent, createError: createError, enableCodemode: enableCodemode, useJupyterSandbox: useJupyterSandbox, allowDirectToolCalls: allowDirectToolCalls, enableToolReranker: enableToolReranker, availableSkills: MOCK_SKILLS, selectedSkills: selectedSkills, selectedMcpServers: selectedMcpServers, identityProviders: oauthProvidersConfig, onIdentityConnect: handleIdentityConnect, onIdentityDisconnect: handleIdentityDisconnect, onAgentLibraryChange: setAgentLibrary, onTransportChange: setTransport, onExtensionsChange: setExtensions, onWsUrlChange: setWsUrl, onBaseUrlChange: setBaseUrl, onAgentNameChange: setAgentName, onDescriptionChange: setDescription, onGoalChange: setGoal, onModelChange: setModel, onSystemPromptChange: setSystemPrompt, onSystemPromptCodemodeAddonsChange: setSystemPromptCodemodeAddons, onToolsChange: setTools, onSandboxVariantChange: setSandboxVariant, onAgentSelect: handleAgentSelect, onConnect: handleConnect, onEnableCodemodeChange: handleEnableCodemodeChange, onUseJupyterSandboxChange: setUseJupyterSandbox, onAllowDirectToolCallsChange: setAllowDirectToolCalls, onEnableToolRerankerChange: setEnableToolReranker, onSelectedSkillsChange: setSelectedSkills, onSelectedMcpServersChange: setSelectedMcpServers })) : (
644
- /* Chat Interface */
645
- _jsx(Box, { sx: { flex: 1, minHeight: 0 }, children: _jsx(ChatWithJupyterStatus, { baseUrl: baseUrl, isConfigured: isConfigured, enableCodemode: enableCodemode, useJupyterSandbox: useJupyterSandbox, chatProps: {
646
- protocol: currentAgent?.protocol || transport,
647
- extensions: extensions,
648
- wsUrl: wsUrl,
649
- baseUrl: baseUrl,
650
- agentId: currentAgent?.id || agentName,
651
- title: currentAgent?.name || agentName || 'AI Assistant',
652
- autoConnect: true,
653
- autoFocus: true,
654
- placeholder: 'Type your message to the agent...',
655
- height: 'calc(100vh - 150px)',
656
- showModelSelector: true,
657
- showToolsMenu: true,
658
- showSkillsMenu: true,
659
- codemodeEnabled: enableCodemode,
660
- initialModel: model,
661
- mcpServers: selectedMcpServers,
662
- initialSkills: selectedSkills,
663
- identityProviders: oauthProvidersConfig,
664
- onIdentityConnect: handleIdentityConnect,
665
- onIdentityDisconnect: handleIdentityDisconnect,
666
- suggestions: [
667
- {
668
- title: '👋 Say hello',
669
- message: 'Hello! What can you help me with today?',
670
- },
671
- {
672
- title: '💡 Get ideas',
673
- message: 'Can you suggest some creative project ideas?',
674
- },
675
- {
676
- title: '📝 Explain concepts',
677
- message: 'Can you explain how AI agents work?',
678
- },
679
- {
680
- title: '🔧 Help with code',
681
- message: 'Can you help me write some Python code?',
682
- },
683
- ],
684
- onDisconnect: handleReset,
685
- onMessageSent: (_content) => {
686
- // Message sent
687
- },
688
- onMessageReceived: (_message) => {
689
- // Message received
690
- },
691
- } }) })) }) })] })) : (_jsx(Box, { sx: {
692
- position: 'fixed',
693
- right: 0,
694
- top: '50%',
695
- transform: 'translateY(-50%)',
696
- zIndex: 100,
697
- }, children: _jsx(IconButton, { icon: SidebarExpandIcon, "aria-label": "Expand right pane", size: "small", onClick: () => setRightPaneVisible(true), sx: {
698
- borderRadius: '6px 0 0 6px',
699
- bg: 'canvas.default',
700
- border: '1px solid',
701
- borderRight: 'none',
702
- borderColor: 'border.default',
703
- } }) }))] }) }) }));
704
- };
705
- export default AgentRuntimeFormExample;