@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.
Files changed (291) hide show
  1. package/README.md +2 -1
  2. package/lib/{examples/components → components}/AgentConfiguration.d.ts +54 -9
  3. package/lib/components/AgentConfiguration.js +585 -0
  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 +472 -22
  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 +13 -6
  30. package/lib/components/chat/components/ContextInspector.d.ts +81 -0
  31. package/lib/components/chat/components/ContextInspector.js +263 -0
  32. package/lib/components/chat/components/ContextPanel.d.ts +112 -0
  33. package/lib/components/chat/components/ContextPanel.js +368 -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/code-ai/agents.d.ts +25 -0
  53. package/lib/config/agents/code-ai/agents.js +70 -0
  54. package/lib/config/agents/code-ai/index.d.ts +1 -0
  55. package/lib/config/agents/code-ai/index.js +5 -0
  56. package/lib/config/agents/codemode-paper/agents.d.ts +29 -0
  57. package/lib/config/agents/codemode-paper/agents.js +288 -0
  58. package/lib/config/agents/codemode-paper/index.d.ts +1 -0
  59. package/lib/config/agents/codemode-paper/index.js +5 -0
  60. package/lib/config/agents/datalayer-ai/agents.d.ts +29 -0
  61. package/lib/config/agents/datalayer-ai/agents.js +267 -0
  62. package/lib/config/agents/datalayer-ai/index.d.ts +1 -0
  63. package/lib/config/agents/datalayer-ai/index.js +5 -0
  64. package/lib/config/agents/index.d.ts +19 -0
  65. package/lib/config/agents/index.js +38 -0
  66. package/lib/config/envvars.d.ts +28 -0
  67. package/lib/config/envvars.js +115 -0
  68. package/lib/config/index.d.ts +5 -0
  69. package/lib/config/index.js +9 -0
  70. package/lib/config/mcpServers.d.ts +18 -0
  71. package/lib/config/mcpServers.js +153 -0
  72. package/lib/config/skills.d.ts +27 -0
  73. package/lib/config/skills.js +60 -0
  74. package/lib/{lib → config}/utils.d.ts +1 -1
  75. package/lib/{lib → config}/utils.js +2 -2
  76. package/lib/examples/AgentRuntimeLexical2Example.d.ts +1 -0
  77. package/lib/examples/AgentRuntimeLexical2Example.js +3 -2
  78. package/lib/examples/AgentRuntimeLexicalExample.d.ts +1 -0
  79. package/lib/examples/AgentRuntimeLexicalExample.js +5 -3
  80. package/lib/examples/AgentRuntimeLexicalSidebarExample.d.ts +1 -0
  81. package/lib/examples/AgentRuntimeLexicalSidebarExample.js +3 -3
  82. package/lib/examples/AgentRuntimeNotebookExample.js +1 -1
  83. package/lib/examples/AgentSpaceFormExample.d.ts +2 -2
  84. package/lib/examples/AgentSpaceFormExample.js +215 -35
  85. package/lib/examples/CopilotKitLexicalExample.d.ts +1 -0
  86. package/lib/examples/CopilotKitLexicalExample.js +3 -2
  87. package/lib/examples/index.d.ts +1 -0
  88. package/lib/examples/stores/notebooks/NotebookExample2.ipynb.json +43 -43
  89. package/lib/hooks/useAGUI.d.ts +1 -1
  90. package/lib/hooks/useAGUI.js +1 -1
  91. package/lib/identity/types.d.ts +1 -1
  92. package/lib/index.d.ts +2 -0
  93. package/lib/index.js +1 -0
  94. package/lib/runtime/index.d.ts +3 -0
  95. package/lib/runtime/runtimeStore.d.ts +3 -4
  96. package/lib/runtime/useAgentConnection.d.ts +2 -3
  97. package/lib/runtime/useAgentRuntime.d.ts +2 -3
  98. package/lib/stories/Cell.stories.js +1 -1
  99. package/lib/tools/adapters/agent-runtimes/notebookHooks.js +1 -0
  100. package/lib/tools/adapters/copilotkit/notebookHooks.js +1 -0
  101. package/lib/types.d.ts +158 -0
  102. package/package.json +5 -6
  103. package/scripts/apply-patches.sh +1 -1
  104. package/scripts/codegen/generate_agents.py +863 -0
  105. package/scripts/codegen/generate_envvars.py +302 -0
  106. package/scripts/codegen/generate_mcp_servers.py +436 -0
  107. package/scripts/codegen/generate_skills.py +334 -0
  108. package/scripts/download-ai-elements.py +35 -20
  109. package/scripts/sync-jupyter.sh +6 -0
  110. package/lib/components/ui/accordion.d.ts +0 -7
  111. package/lib/components/ui/accordion.js +0 -22
  112. package/lib/components/ui/alert-dialog.d.ts +0 -14
  113. package/lib/components/ui/alert-dialog.js +0 -43
  114. package/lib/components/ui/alert.d.ts +0 -9
  115. package/lib/components/ui/alert.js +0 -24
  116. package/lib/components/ui/aspect-ratio.d.ts +0 -3
  117. package/lib/components/ui/aspect-ratio.js +0 -11
  118. package/lib/components/ui/avatar.d.ts +0 -6
  119. package/lib/components/ui/avatar.js +0 -18
  120. package/lib/components/ui/badge.d.ts +0 -9
  121. package/lib/components/ui/badge.js +0 -22
  122. package/lib/components/ui/breadcrumb.d.ts +0 -11
  123. package/lib/components/ui/breadcrumb.js +0 -27
  124. package/lib/components/ui/button-group.d.ts +0 -11
  125. package/lib/components/ui/button-group.js +0 -31
  126. package/lib/components/ui/button.d.ts +0 -13
  127. package/lib/components/ui/button.js +0 -39
  128. package/lib/components/ui/calendar.d.ts +0 -8
  129. package/lib/components/ui/calendar.js +0 -80
  130. package/lib/components/ui/card.d.ts +0 -9
  131. package/lib/components/ui/card.js +0 -24
  132. package/lib/components/ui/carousel.d.ts +0 -19
  133. package/lib/components/ui/carousel.js +0 -95
  134. package/lib/components/ui/chart.d.ts +0 -53
  135. package/lib/components/ui/chart.js +0 -136
  136. package/lib/components/ui/checkbox.d.ts +0 -4
  137. package/lib/components/ui/checkbox.js +0 -13
  138. package/lib/components/ui/collapsible.d.ts +0 -5
  139. package/lib/components/ui/collapsible.js +0 -17
  140. package/lib/components/ui/command.d.ts +0 -18
  141. package/lib/components/ui/command.js +0 -38
  142. package/lib/components/ui/context-menu.d.ts +0 -25
  143. package/lib/components/ui/context-menu.js +0 -55
  144. package/lib/components/ui/dialog.d.ts +0 -15
  145. package/lib/components/ui/dialog.js +0 -40
  146. package/lib/components/ui/drawer.d.ts +0 -13
  147. package/lib/components/ui/drawer.js +0 -39
  148. package/lib/components/ui/dropdown-menu.d.ts +0 -25
  149. package/lib/components/ui/dropdown-menu.js +0 -55
  150. package/lib/components/ui/empty.d.ts +0 -11
  151. package/lib/components/ui/empty.js +0 -37
  152. package/lib/components/ui/field.d.ts +0 -24
  153. package/lib/components/ui/field.js +0 -80
  154. package/lib/components/ui/form.d.ts +0 -24
  155. package/lib/components/ui/form.js +0 -63
  156. package/lib/components/ui/hover-card.d.ts +0 -6
  157. package/lib/components/ui/hover-card.js +0 -18
  158. package/lib/components/ui/input-group.d.ts +0 -19
  159. package/lib/components/ui/input-group.js +0 -69
  160. package/lib/components/ui/input-otp.d.ts +0 -11
  161. package/lib/components/ui/input-otp.js +0 -25
  162. package/lib/components/ui/input.d.ts +0 -3
  163. package/lib/components/ui/input.js +0 -6
  164. package/lib/components/ui/item.d.ts +0 -23
  165. package/lib/components/ui/item.js +0 -66
  166. package/lib/components/ui/kbd.d.ts +0 -3
  167. package/lib/components/ui/kbd.js +0 -13
  168. package/lib/components/ui/label.d.ts +0 -4
  169. package/lib/components/ui/label.js +0 -12
  170. package/lib/components/ui/menubar.d.ts +0 -26
  171. package/lib/components/ui/menubar.js +0 -58
  172. package/lib/components/ui/navigation-menu.d.ts +0 -14
  173. package/lib/components/ui/navigation-menu.js +0 -31
  174. package/lib/components/ui/pagination.d.ts +0 -13
  175. package/lib/components/ui/pagination.js +0 -29
  176. package/lib/components/ui/popover.d.ts +0 -7
  177. package/lib/components/ui/popover.js +0 -21
  178. package/lib/components/ui/progress.d.ts +0 -4
  179. package/lib/components/ui/progress.js +0 -12
  180. package/lib/components/ui/radio-group.d.ts +0 -5
  181. package/lib/components/ui/radio-group.js +0 -16
  182. package/lib/components/ui/resizable.d.ts +0 -8
  183. package/lib/components/ui/resizable.js +0 -19
  184. package/lib/components/ui/scroll-area.d.ts +0 -5
  185. package/lib/components/ui/scroll-area.js +0 -17
  186. package/lib/components/ui/select.d.ts +0 -15
  187. package/lib/components/ui/select.js +0 -42
  188. package/lib/components/ui/separator.d.ts +0 -4
  189. package/lib/components/ui/separator.js +0 -12
  190. package/lib/components/ui/sheet.d.ts +0 -13
  191. package/lib/components/ui/sheet.js +0 -44
  192. package/lib/components/ui/sidebar.d.ts +0 -69
  193. package/lib/components/ui/sidebar.js +0 -216
  194. package/lib/components/ui/skeleton.d.ts +0 -2
  195. package/lib/components/ui/skeleton.js +0 -10
  196. package/lib/components/ui/slider.d.ts +0 -4
  197. package/lib/components/ui/slider.js +0 -18
  198. package/lib/components/ui/sonner.d.ts +0 -3
  199. package/lib/components/ui/sonner.js +0 -25
  200. package/lib/components/ui/spinner.d.ts +0 -2
  201. package/lib/components/ui/spinner.js +0 -11
  202. package/lib/components/ui/switch.d.ts +0 -4
  203. package/lib/components/ui/switch.js +0 -12
  204. package/lib/components/ui/table.d.ts +0 -10
  205. package/lib/components/ui/table.js +0 -32
  206. package/lib/components/ui/tabs.d.ts +0 -7
  207. package/lib/components/ui/tabs.js +0 -21
  208. package/lib/components/ui/textarea.d.ts +0 -3
  209. package/lib/components/ui/textarea.js +0 -6
  210. package/lib/components/ui/toast.d.ts +0 -15
  211. package/lib/components/ui/toast.js +0 -38
  212. package/lib/components/ui/toaster.d.ts +0 -1
  213. package/lib/components/ui/toaster.js +0 -14
  214. package/lib/components/ui/toggle-group.d.ts +0 -9
  215. package/lib/components/ui/toggle-group.js +0 -26
  216. package/lib/components/ui/toggle.d.ts +0 -9
  217. package/lib/components/ui/toggle.js +0 -30
  218. package/lib/components/ui/tooltip.d.ts +0 -7
  219. package/lib/components/ui/tooltip.js +0 -21
  220. package/lib/components/vercel-ai-elements/artifact.d.ts +0 -23
  221. package/lib/components/vercel-ai-elements/artifact.js +0 -24
  222. package/lib/components/vercel-ai-elements/code-block.d.ts +0 -17
  223. package/lib/components/vercel-ai-elements/code-block.js +0 -94
  224. package/lib/components/vercel-ai-elements/conversation.d.ts +0 -15
  225. package/lib/components/vercel-ai-elements/conversation.js +0 -21
  226. package/lib/components/vercel-ai-elements/loader.d.ts +0 -5
  227. package/lib/components/vercel-ai-elements/loader.js +0 -8
  228. package/lib/components/vercel-ai-elements/message.d.ts +0 -46
  229. package/lib/components/vercel-ai-elements/message.js +0 -109
  230. package/lib/components/vercel-ai-elements/model-selector.d.ts +0 -35
  231. package/lib/components/vercel-ai-elements/model-selector.js +0 -22
  232. package/lib/components/vercel-ai-elements/prompt-input.d.ts +0 -195
  233. package/lib/components/vercel-ai-elements/prompt-input.js +0 -589
  234. package/lib/components/vercel-ai-elements/reasoning.d.ts +0 -26
  235. package/lib/components/vercel-ai-elements/reasoning.js +0 -80
  236. package/lib/components/vercel-ai-elements/shimmer.d.ts +0 -9
  237. package/lib/components/vercel-ai-elements/shimmer.js +0 -22
  238. package/lib/components/vercel-ai-elements/sources.d.ts +0 -12
  239. package/lib/components/vercel-ai-elements/sources.js +0 -13
  240. package/lib/components/vercel-ai-elements/suggestion.d.ts +0 -10
  241. package/lib/components/vercel-ai-elements/suggestion.js +0 -16
  242. package/lib/components/vercel-ai-elements/tool.d.ts +0 -23
  243. package/lib/components/vercel-ai-elements/tool.js +0 -52
  244. package/lib/examples/components/AgentConfiguration.js +0 -382
  245. package/lib/examples/components/MainContent.d.ts +0 -19
  246. package/lib/examples/components/index.d.ts +0 -10
  247. package/lib/examples/components/index.js +0 -13
  248. package/lib/examples/vercel-ai-elements/VercelAiElementsShowcase.d.ts +0 -12
  249. package/lib/examples/vercel-ai-elements/VercelAiElementsShowcase.js +0 -69
  250. package/lib/examples/vercel-ai-elements/components/ArtifactShowcase.d.ts +0 -1
  251. package/lib/examples/vercel-ai-elements/components/ArtifactShowcase.js +0 -85
  252. package/lib/examples/vercel-ai-elements/components/CodeBlockShowcase.d.ts +0 -1
  253. package/lib/examples/vercel-ai-elements/components/CodeBlockShowcase.js +0 -62
  254. package/lib/examples/vercel-ai-elements/components/ConversationShowcase.d.ts +0 -1
  255. package/lib/examples/vercel-ai-elements/components/ConversationShowcase.js +0 -51
  256. package/lib/examples/vercel-ai-elements/components/LoaderShowcase.d.ts +0 -1
  257. package/lib/examples/vercel-ai-elements/components/LoaderShowcase.js +0 -9
  258. package/lib/examples/vercel-ai-elements/components/MessageShowcase.d.ts +0 -1
  259. package/lib/examples/vercel-ai-elements/components/MessageShowcase.js +0 -56
  260. package/lib/examples/vercel-ai-elements/components/ModelSelectorShowcase.d.ts +0 -1
  261. package/lib/examples/vercel-ai-elements/components/ModelSelectorShowcase.js +0 -50
  262. package/lib/examples/vercel-ai-elements/components/PromptInputShowcase.d.ts +0 -1
  263. package/lib/examples/vercel-ai-elements/components/PromptInputShowcase.js +0 -16
  264. package/lib/examples/vercel-ai-elements/components/ReasoningShowcase.d.ts +0 -1
  265. package/lib/examples/vercel-ai-elements/components/ReasoningShowcase.js +0 -72
  266. package/lib/examples/vercel-ai-elements/components/ShimmerShowcase.d.ts +0 -1
  267. package/lib/examples/vercel-ai-elements/components/ShimmerShowcase.js +0 -9
  268. package/lib/examples/vercel-ai-elements/components/SourcesShowcase.d.ts +0 -1
  269. package/lib/examples/vercel-ai-elements/components/SourcesShowcase.js +0 -43
  270. package/lib/examples/vercel-ai-elements/components/SuggestionShowcase.d.ts +0 -1
  271. package/lib/examples/vercel-ai-elements/components/SuggestionShowcase.js +0 -31
  272. package/lib/examples/vercel-ai-elements/components/ToolShowcase.d.ts +0 -1
  273. package/lib/examples/vercel-ai-elements/components/ToolShowcase.js +0 -54
  274. package/lib/examples/vercel-ai-elements/index.d.ts +0 -13
  275. package/lib/examples/vercel-ai-elements/index.js +0 -17
  276. package/lib/examples/vercel-ai-elements/main.d.ts +0 -1
  277. package/lib/examples/vercel-ai-elements/main.js +0 -9
  278. package/lib/examples/vercel-ai-elements/showcase.css +0 -128
  279. package/lib/hooks/useToast.d.ts +0 -44
  280. package/lib/hooks/useToast.js +0 -128
  281. package/patches/@datalayer+jupyter-lexical+1.0.8.patch +0 -11628
  282. package/patches/@datalayer+jupyter-react+2.0.2.patch +0 -5338
  283. package/style/showcase-vercel-ai.css +0 -137
  284. /package/lib/{examples/components → components}/FooterMetrics.js +0 -0
  285. /package/lib/{examples/components → components}/MockFileBrowser.js +0 -0
  286. /package/lib/{examples/components → components}/SessionTabs.js +0 -0
  287. /package/lib/{examples/components → components}/TimeTravel.js +0 -0
  288. /package/lib/{models → types}/AIAgent.d.ts +0 -0
  289. /package/lib/{models → types}/AIAgent.js +0 -0
  290. /package/lib/{models → types}/index.d.ts +0 -0
  291. /package/lib/{models → types}/index.js +0 -0
@@ -0,0 +1,263 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ // Copyright (c) 2025-2026 Datalayer, Inc.
3
+ // Distributed under the terms of the Modified BSD License.
4
+ /**
5
+ * ContextInspector component - Shows detailed context snapshot with full tool schemas,
6
+ * message history with in_context flags, and model configuration.
7
+ */
8
+ import { Text, Spinner, Button, Label, ProgressBar } from '@primer/react';
9
+ import { Box } from '@datalayer/primer-addons';
10
+ import { AiModelIcon, TerminalIcon, CommentDiscussionIcon, DatabaseIcon, KeyIcon, CodeIcon, CheckCircleIcon, XCircleIcon, ChevronDownIcon, ChevronRightIcon, InfoIcon, } from '@primer/octicons-react';
11
+ import { useQuery } from '@tanstack/react-query';
12
+ import React, { useState, useMemo } from 'react';
13
+ /**
14
+ * Get the API base URL for fetching context data.
15
+ * If apiBase prop is provided, use it.
16
+ * Otherwise, fall back to localhost for local development.
17
+ */
18
+ function getApiBase(apiBase) {
19
+ if (apiBase) {
20
+ return apiBase;
21
+ }
22
+ if (typeof window === 'undefined') {
23
+ return '';
24
+ }
25
+ const host = window.location.hostname;
26
+ return host === 'localhost' || host === '127.0.0.1'
27
+ ? 'http://127.0.0.1:8765'
28
+ : '';
29
+ }
30
+ /**
31
+ * Format token count for display
32
+ */
33
+ function formatTokens(tokens) {
34
+ if (tokens >= 1000000) {
35
+ return `${(tokens / 1000000).toFixed(1)}M`;
36
+ }
37
+ if (tokens >= 1000) {
38
+ return `${(tokens / 1000).toFixed(1)}K`;
39
+ }
40
+ return tokens.toString();
41
+ }
42
+ /**
43
+ * Collapsible section component
44
+ */
45
+ function CollapsibleSection({ title, icon, count, tokens, defaultExpanded = false, children, }) {
46
+ const [expanded, setExpanded] = useState(defaultExpanded);
47
+ return (_jsxs(Box, { sx: { mb: 2 }, children: [_jsxs(Box, { as: "button", onClick: () => setExpanded(!expanded), sx: {
48
+ display: 'flex',
49
+ alignItems: 'center',
50
+ gap: 2,
51
+ width: '100%',
52
+ p: 2,
53
+ bg: 'canvas.subtle',
54
+ border: '1px solid',
55
+ borderColor: 'border.default',
56
+ borderRadius: 2,
57
+ cursor: 'pointer',
58
+ '&:hover': {
59
+ bg: 'canvas.inset',
60
+ },
61
+ }, children: [expanded ? (_jsx(ChevronDownIcon, { size: 16 })) : (_jsx(ChevronRightIcon, { size: 16 })), React.createElement(icon, { size: 16 }), _jsx(Text, { sx: { fontWeight: 'semibold', flex: 1, textAlign: 'left' }, children: title }), count !== undefined && (_jsx(Label, { variant: "secondary", size: "small", children: count })), tokens !== undefined && tokens > 0 && (_jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [formatTokens(tokens), " tokens"] }))] }), expanded && (_jsx(Box, { sx: {
62
+ border: '1px solid',
63
+ borderColor: 'border.default',
64
+ borderTop: 'none',
65
+ borderRadius: '0 0 6px 6px',
66
+ p: 2,
67
+ }, children: children }))] }));
68
+ }
69
+ /**
70
+ * Tool detail view component
71
+ */
72
+ function ToolDetailView({ tool }) {
73
+ const [showSchema, setShowSchema] = useState(false);
74
+ const [showSource, setShowSource] = useState(false);
75
+ return (_jsxs(Box, { sx: {
76
+ p: 2,
77
+ mb: 2,
78
+ bg: 'canvas.default',
79
+ border: '1px solid',
80
+ borderColor: 'border.muted',
81
+ borderRadius: 2,
82
+ }, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2, mb: 1 }, children: [_jsx(Text, { sx: { fontWeight: 'bold', fontFamily: 'mono', fontSize: 1 }, children: tool.name }), _jsx(Label, { size: "small", variant: "secondary", children: tool.sourceType }), tool.isAsync && (_jsx(Label, { size: "small", variant: "accent", children: "async" })), tool.requiresApproval && (_jsx(Label, { size: "small", variant: "attention", children: "requires approval" })), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted', ml: 'auto' }, children: [formatTokens(tool.totalTokens), " tokens"] })] }), tool.description && (_jsx(Text, { sx: { fontSize: 1, color: 'fg.muted', display: 'block', mb: 2 }, children: tool.description })), _jsxs(Box, { sx: { display: 'flex', gap: 2 }, children: [_jsxs(Button, { size: "small", variant: "invisible", onClick: () => setShowSchema(!showSchema), children: [showSchema ? 'Hide' : 'Show', " Schema"] }), tool.sourceCode && (_jsxs(Button, { size: "small", variant: "invisible", onClick: () => setShowSource(!showSource), children: [showSource ? 'Hide' : 'Show', " Source"] }))] }), showSchema && (_jsx(Box, { as: "pre", sx: {
83
+ mt: 2,
84
+ p: 2,
85
+ bg: 'canvas.inset',
86
+ borderRadius: 2,
87
+ fontSize: 0,
88
+ overflow: 'auto',
89
+ maxHeight: 200,
90
+ }, children: JSON.stringify(tool.parametersSchema, null, 2) })), showSource && tool.sourceCode && (_jsx(Box, { as: "pre", sx: {
91
+ mt: 2,
92
+ p: 2,
93
+ bg: 'canvas.inset',
94
+ borderRadius: 2,
95
+ fontSize: 0,
96
+ overflow: 'auto',
97
+ maxHeight: 300,
98
+ }, children: tool.sourceCode }))] }));
99
+ }
100
+ /**
101
+ * Message detail view component
102
+ */
103
+ function MessageDetailView({ message }) {
104
+ const roleColors = {
105
+ user: 'accent.fg',
106
+ assistant: 'success.fg',
107
+ system: 'attention.fg',
108
+ tool: 'done.fg',
109
+ };
110
+ const roleIcons = {
111
+ user: CommentDiscussionIcon,
112
+ assistant: AiModelIcon,
113
+ system: InfoIcon,
114
+ tool: TerminalIcon,
115
+ };
116
+ const RoleIcon = roleIcons[message.role] || CommentDiscussionIcon;
117
+ return (_jsxs(Box, { sx: {
118
+ p: 2,
119
+ mb: 1,
120
+ bg: message.inContext ? 'canvas.default' : 'canvas.inset',
121
+ border: '1px solid',
122
+ borderColor: message.inContext ? 'border.default' : 'border.muted',
123
+ borderRadius: 2,
124
+ opacity: message.inContext ? 1 : 0.7,
125
+ }, children: [_jsxs(Box, { sx: { display: 'flex', alignItems: 'center', gap: 2, mb: 1 }, children: [_jsx(RoleIcon, { size: 14 }), _jsx(Text, { sx: {
126
+ fontWeight: 'semibold',
127
+ fontSize: 0,
128
+ color: roleColors[message.role] || 'fg.default',
129
+ textTransform: 'capitalize',
130
+ }, children: message.role }), message.toolName && (_jsx(Label, { size: "small", variant: "secondary", children: message.toolName })), message.isToolCall && (_jsx(Label, { size: "small", variant: "accent", children: "call" })), message.isToolResult && (_jsx(Label, { size: "small", variant: "success", children: "result" })), message.inContext ? (_jsx(CheckCircleIcon, { size: 12, fill: "var(--fgColor-success)" })) : (_jsx(XCircleIcon, { size: 12, fill: "var(--fgColor-muted)" })), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted', ml: 'auto' }, children: [formatTokens(message.estimatedTokens), " tokens"] })] }), _jsx(Text, { sx: {
131
+ fontSize: 0,
132
+ fontFamily: 'mono',
133
+ display: 'block',
134
+ whiteSpace: 'pre-wrap',
135
+ wordBreak: 'break-word',
136
+ maxHeight: 100,
137
+ overflow: 'auto',
138
+ }, children: message.content.length > 500
139
+ ? message.content.slice(0, 500) + '...'
140
+ : message.content })] }));
141
+ }
142
+ /**
143
+ * ContextInspector component displays full detailed context snapshot.
144
+ */
145
+ export function ContextInspector({ agentId, apiBase }) {
146
+ const { data: contextData, isLoading, error, } = useQuery({
147
+ queryKey: ['full-context', agentId, apiBase],
148
+ queryFn: async () => {
149
+ const base = getApiBase(apiBase);
150
+ const response = await fetch(`${base}/api/v1/configure/agents/${encodeURIComponent(agentId)}/full-context`);
151
+ if (!response.ok) {
152
+ throw new Error('Failed to fetch full context');
153
+ }
154
+ return response.json();
155
+ },
156
+ refetchInterval: 30000, // Refresh every 30 seconds (less frequent than snapshot)
157
+ refetchOnMount: 'always',
158
+ staleTime: 0,
159
+ });
160
+ // Separate messages by in_context status
161
+ const { inContextMessages, outOfContextMessages } = useMemo(() => {
162
+ if (!contextData?.messages) {
163
+ return { inContextMessages: [], outOfContextMessages: [] };
164
+ }
165
+ return {
166
+ inContextMessages: contextData.messages.filter(m => m.inContext),
167
+ outOfContextMessages: contextData.messages.filter(m => !m.inContext),
168
+ };
169
+ }, [contextData?.messages]);
170
+ if (isLoading) {
171
+ return (_jsxs(Box, { sx: {
172
+ p: 3,
173
+ display: 'flex',
174
+ alignItems: 'center',
175
+ justifyContent: 'center',
176
+ }, children: [_jsx(Spinner, { size: "small" }), _jsx(Text, { sx: { ml: 2, color: 'fg.muted' }, children: "Loading full context snapshot..." })] }));
177
+ }
178
+ if (error || !contextData) {
179
+ return (_jsx(Box, { sx: {
180
+ p: 3,
181
+ bg: 'danger.subtle',
182
+ borderRadius: 2,
183
+ border: '1px solid',
184
+ borderColor: 'danger.muted',
185
+ }, children: _jsx(Text, { sx: { color: 'danger.fg' }, children: "Failed to load context snapshot" }) }));
186
+ }
187
+ if (contextData.error) {
188
+ return (_jsx(Box, { sx: {
189
+ p: 3,
190
+ bg: 'attention.subtle',
191
+ borderRadius: 2,
192
+ border: '1px solid',
193
+ borderColor: 'attention.muted',
194
+ }, children: _jsx(Text, { sx: { color: 'attention.fg' }, children: contextData.error }) }));
195
+ }
196
+ const { tokenSummary, modelConfiguration } = contextData;
197
+ return (_jsxs(Box, { children: [_jsxs(Box, { sx: { mb: 3 }, children: [_jsxs(Text, { sx: { fontSize: 1, fontWeight: 'semibold' }, children: ["Total usage: ", formatTokens(tokenSummary.total), " /", ' ', formatTokens(tokenSummary.contextWindow), " (", Math.round(tokenSummary.usagePercent), "%)"] }), _jsx(ProgressBar, { progress: Math.min(tokenSummary.usagePercent, 100), sx: { mt: 2, height: 8 }, bg: tokenSummary.usagePercent > 90
198
+ ? 'danger.emphasis'
199
+ : tokenSummary.usagePercent > 70
200
+ ? 'attention.emphasis'
201
+ : 'success.emphasis' }), _jsxs(Box, { sx: {
202
+ display: 'flex',
203
+ gap: 3,
204
+ mt: 2,
205
+ flexWrap: 'wrap',
206
+ fontSize: 0,
207
+ color: 'fg.muted',
208
+ }, children: [_jsxs(Text, { children: ["System: ", formatTokens(tokenSummary.systemPrompts)] }), _jsxs(Text, { children: ["Tools: ", formatTokens(tokenSummary.tools)] }), tokenSummary.memory > 0 && (_jsxs(Text, { children: ["Memory: ", formatTokens(tokenSummary.memory)] })), _jsxs(Text, { children: ["History: ", formatTokens(tokenSummary.history)] }), _jsxs(Text, { children: ["Current: ", formatTokens(tokenSummary.current)] })] })] }), _jsx(CollapsibleSection, { title: "Model Configuration", icon: AiModelIcon, defaultExpanded: true, children: _jsxs(Box, { sx: { display: 'grid', gridTemplateColumns: '1fr 2fr', gap: 2 }, children: [_jsx(Text, { sx: { fontWeight: 'semibold', fontSize: 1 }, children: "Model:" }), _jsx(Text, { sx: { fontSize: 1, fontFamily: 'mono' }, children: modelConfiguration.modelName || 'Not specified' }), _jsx(Text, { sx: { fontWeight: 'semibold', fontSize: 1 }, children: "Context Window:" }), _jsxs(Text, { sx: { fontSize: 1 }, children: [formatTokens(modelConfiguration.contextWindow), " tokens"] }), Object.keys(modelConfiguration.settings).length > 0 && (_jsxs(_Fragment, { children: [_jsx(Text, { sx: { fontWeight: 'semibold', fontSize: 1 }, children: "Settings:" }), _jsx(Box, { as: "pre", sx: {
209
+ fontSize: 0,
210
+ p: 2,
211
+ bg: 'canvas.inset',
212
+ borderRadius: 2,
213
+ overflow: 'auto',
214
+ }, children: JSON.stringify(modelConfiguration.settings, null, 2) })] }))] }) }), _jsx(CollapsibleSection, { title: "System Prompts", icon: InfoIcon, count: contextData.systemPrompts.length, tokens: contextData.systemPromptTokens, children: contextData.systemPrompts.length === 0 ? (_jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: "No system prompts configured" })) : (contextData.systemPrompts.map((prompt, idx) => (_jsxs(Box, { sx: {
215
+ p: 2,
216
+ mb: 2,
217
+ bg: 'canvas.inset',
218
+ borderRadius: 2,
219
+ border: '1px solid',
220
+ borderColor: 'border.muted',
221
+ }, children: [_jsxs(Box, { sx: {
222
+ display: 'flex',
223
+ justifyContent: 'space-between',
224
+ mb: 1,
225
+ }, children: [_jsxs(Text, { sx: { fontWeight: 'semibold', fontSize: 0 }, children: ["Prompt ", idx + 1] }), _jsxs(Text, { sx: { fontSize: 0, color: 'fg.muted' }, children: [formatTokens(prompt.tokens), " tokens"] })] }), _jsx(Text, { as: "pre", sx: {
226
+ fontSize: 0,
227
+ whiteSpace: 'pre-wrap',
228
+ wordBreak: 'break-word',
229
+ maxHeight: 200,
230
+ overflow: 'auto',
231
+ }, children: prompt.content })] }, idx)))) }), _jsx(CollapsibleSection, { title: "Tools", icon: TerminalIcon, count: contextData.tools.length, tokens: contextData.toolTokens, children: contextData.tools.length === 0 ? (_jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: "No tools configured" })) : (contextData.tools.map((tool, idx) => (_jsx(ToolDetailView, { tool: tool }, idx)))) }), _jsx(CollapsibleSection, { title: "Message History", icon: CommentDiscussionIcon, count: contextData.messages.length, children: contextData.messages.length === 0 ? (_jsx(Text, { sx: { color: 'fg.muted', fontSize: 1 }, children: "No messages yet" })) : (_jsxs(_Fragment, { children: [outOfContextMessages.length > 0 && (_jsxs(Box, { sx: { mb: 3 }, children: [_jsxs(Text, { sx: {
232
+ fontWeight: 'semibold',
233
+ fontSize: 1,
234
+ color: 'fg.muted',
235
+ mb: 2,
236
+ display: 'block',
237
+ }, children: ["Out of Context (", outOfContextMessages.length, ")"] }), outOfContextMessages.map((msg, idx) => (_jsx(MessageDetailView, { message: msg }, `out-${idx}`)))] })), inContextMessages.length > 0 && (_jsxs(Box, { children: [_jsxs(Text, { sx: {
238
+ fontWeight: 'semibold',
239
+ fontSize: 1,
240
+ color: 'success.fg',
241
+ mb: 2,
242
+ display: 'block',
243
+ }, children: ["In Context (", inContextMessages.length, ")"] }), inContextMessages.map((msg, idx) => (_jsx(MessageDetailView, { message: msg }, `in-${idx}`)))] }))] })) }), contextData.memoryBlocks.length > 0 && (_jsx(CollapsibleSection, { title: "Memory Blocks", icon: DatabaseIcon, count: contextData.memoryBlocks.length, tokens: contextData.memoryTokens, children: contextData.memoryBlocks.map((block, idx) => (_jsx(Box, { as: "pre", sx: {
244
+ p: 2,
245
+ mb: 2,
246
+ bg: 'canvas.inset',
247
+ borderRadius: 2,
248
+ fontSize: 0,
249
+ overflow: 'auto',
250
+ }, children: JSON.stringify(block, null, 2) }, idx))) })), Object.keys(contextData.toolEnvironment).length > 0 && (_jsx(CollapsibleSection, { title: "Tool Environment", icon: KeyIcon, count: Object.keys(contextData.toolEnvironment).length, children: _jsx(Box, { sx: { display: 'grid', gridTemplateColumns: '1fr 2fr', gap: 2 }, children: Object.entries(contextData.toolEnvironment).map(([key, value]) => (_jsxs(React.Fragment, { children: [_jsx(Text, { sx: {
251
+ fontFamily: 'mono',
252
+ fontSize: 1,
253
+ fontWeight: 'semibold',
254
+ }, children: key }), _jsx(Text, { sx: { fontFamily: 'mono', fontSize: 1, color: 'fg.muted' }, children: value })] }, key))) }) })), contextData.toolRules.length > 0 && (_jsx(CollapsibleSection, { title: "Tool Rules", icon: CodeIcon, count: contextData.toolRules.length, children: contextData.toolRules.map((rule, idx) => (_jsx(Box, { as: "pre", sx: {
255
+ p: 2,
256
+ mb: 2,
257
+ bg: 'canvas.inset',
258
+ borderRadius: 2,
259
+ fontSize: 0,
260
+ overflow: 'auto',
261
+ }, children: JSON.stringify(rule, null, 2) }, idx))) }))] }));
262
+ }
263
+ export default ContextInspector;
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Distribution child item for treemap
3
+ */
4
+ interface DistributionChild {
5
+ name: string;
6
+ value: number;
7
+ children?: DistributionChild[];
8
+ }
9
+ /**
10
+ * Distribution data for treemap
11
+ */
12
+ interface Distribution {
13
+ name: string;
14
+ value: number;
15
+ children: DistributionChild[];
16
+ }
17
+ /**
18
+ * Request usage snapshot - historic per-request data
19
+ */
20
+ interface RequestUsageSnapshot {
21
+ requestNum: number;
22
+ inputTokens: number;
23
+ outputTokens: number;
24
+ toolNames: string[];
25
+ timestamp: string | null;
26
+ turnId: string | null;
27
+ durationMs: number;
28
+ }
29
+ /**
30
+ * Tool snapshot
31
+ */
32
+ interface ToolSnapshot {
33
+ name: string;
34
+ description: string | null;
35
+ parametersTokens: number;
36
+ totalTokens: number;
37
+ }
38
+ /**
39
+ * Turn usage
40
+ */
41
+ interface TurnUsage {
42
+ inputTokens: number;
43
+ outputTokens: number;
44
+ requests: number;
45
+ toolCalls: number;
46
+ toolNames: string[];
47
+ durationSeconds: number;
48
+ }
49
+ /**
50
+ * Session usage
51
+ */
52
+ interface SessionUsage {
53
+ inputTokens: number;
54
+ outputTokens: number;
55
+ requests: number;
56
+ toolCalls: number;
57
+ turns: number;
58
+ durationSeconds: number;
59
+ }
60
+ /**
61
+ * Context snapshot response from API
62
+ */
63
+ export interface ContextSnapshotResponse {
64
+ agentId: string;
65
+ systemPrompts: string[];
66
+ systemPromptTokens: number;
67
+ tools: ToolSnapshot[];
68
+ toolTokens: number;
69
+ historyToolCallTokens: number;
70
+ historyToolReturnTokens: number;
71
+ currentToolCallTokens: number;
72
+ currentToolReturnTokens: number;
73
+ toolCallTokens: number;
74
+ toolReturnTokens: number;
75
+ historyUserTokens: number;
76
+ historyAssistantTokens: number;
77
+ currentUserTokens: number;
78
+ currentAssistantTokens: number;
79
+ historyTokens: number;
80
+ currentMessageTokens: number;
81
+ userMessageTokens: number;
82
+ assistantMessageTokens: number;
83
+ totalTokens: number;
84
+ modelInputTokens: number | null;
85
+ modelOutputTokens: number | null;
86
+ sumResponseInputTokens: number;
87
+ sumResponseOutputTokens: number;
88
+ perRequestUsage: RequestUsageSnapshot[];
89
+ contextWindow: number;
90
+ turnUsage: TurnUsage | null;
91
+ sessionUsage: SessionUsage | null;
92
+ distribution: Distribution;
93
+ error?: string;
94
+ }
95
+ type ViewMode = 'overview' | 'distribution' | 'history';
96
+ export interface ContextPanelProps {
97
+ /** Agent ID for fetching context details (required) */
98
+ agentId: string;
99
+ /** API base URL for fetching context data */
100
+ apiBase?: string;
101
+ /** Number of messages in conversation (from chat store) */
102
+ messageCount?: number;
103
+ /** Default view mode */
104
+ defaultView?: ViewMode;
105
+ /** Height for charts */
106
+ chartHeight?: string;
107
+ }
108
+ /**
109
+ * ContextPanel component - unified context usage display.
110
+ */
111
+ export declare function ContextPanel({ agentId, apiBase, messageCount, defaultView, chartHeight, }: ContextPanelProps): import("react/jsx-runtime").JSX.Element;
112
+ export default ContextPanel;