@vertesia/ui 0.80.0-dev.20251121 → 0.80.0

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 (277) hide show
  1. package/README.md +105 -0
  2. package/lib/esm/core/components/MenuList.js +2 -5
  3. package/lib/esm/core/components/MenuList.js.map +1 -1
  4. package/lib/esm/core/components/MessageBox.js +1 -1
  5. package/lib/esm/core/components/MessageBox.js.map +1 -1
  6. package/lib/esm/core/components/shadcn/dialog.js +16 -2
  7. package/lib/esm/core/components/shadcn/dialog.js.map +1 -1
  8. package/lib/esm/core/components/shadcn/filters/filter/SelectFilter.js +6 -9
  9. package/lib/esm/core/components/shadcn/filters/filter/SelectFilter.js.map +1 -1
  10. package/lib/esm/core/components/shadcn/filters/filterBar.js +1 -1
  11. package/lib/esm/core/components/shadcn/filters/filterBar.js.map +1 -1
  12. package/lib/esm/core/components/shadcn/selectBox.js +23 -5
  13. package/lib/esm/core/components/shadcn/selectBox.js.map +1 -1
  14. package/lib/esm/core/components/shadcn/tabs.js +3 -3
  15. package/lib/esm/core/components/shadcn/tabs.js.map +1 -1
  16. package/lib/esm/env/index.js +3 -0
  17. package/lib/esm/env/index.js.map +1 -1
  18. package/lib/esm/features/agent/chat/AgentChart.js +184 -0
  19. package/lib/esm/features/agent/chat/AgentChart.js.map +1 -0
  20. package/lib/esm/features/agent/chat/ModernAgentConversation.js +87 -10
  21. package/lib/esm/features/agent/chat/ModernAgentConversation.js.map +1 -1
  22. package/lib/esm/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js +6 -2
  23. package/lib/esm/features/agent/chat/ModernAgentOutput/AllMessagesMixed.js.map +1 -1
  24. package/lib/esm/features/agent/chat/ModernAgentOutput/Header.js +4 -4
  25. package/lib/esm/features/agent/chat/ModernAgentOutput/Header.js.map +1 -1
  26. package/lib/esm/features/agent/chat/ModernAgentOutput/InlineSlidingPlanPanel.js +4 -1
  27. package/lib/esm/features/agent/chat/ModernAgentOutput/InlineSlidingPlanPanel.js.map +1 -1
  28. package/lib/esm/features/agent/chat/ModernAgentOutput/MessageInput.js +12 -4
  29. package/lib/esm/features/agent/chat/ModernAgentOutput/MessageInput.js.map +1 -1
  30. package/lib/esm/features/agent/chat/ModernAgentOutput/MessageItem.js +60 -56
  31. package/lib/esm/features/agent/chat/ModernAgentOutput/MessageItem.js.map +1 -1
  32. package/lib/esm/features/agent/chat/index.js +1 -0
  33. package/lib/esm/features/agent/chat/index.js.map +1 -1
  34. package/lib/esm/features/agent/createChartTool.js +354 -0
  35. package/lib/esm/features/agent/createChartTool.js.map +1 -0
  36. package/lib/esm/features/agent/examples.js +295 -0
  37. package/lib/esm/features/agent/examples.js.map +1 -0
  38. package/lib/esm/features/agent/index.js +2 -0
  39. package/lib/esm/features/agent/index.js.map +1 -1
  40. package/lib/esm/features/agent/visualization.js +165 -0
  41. package/lib/esm/features/agent/visualization.js.map +1 -0
  42. package/lib/esm/features/facets/CollectionsFacetsNav.js +5 -1
  43. package/lib/esm/features/facets/CollectionsFacetsNav.js.map +1 -1
  44. package/lib/esm/features/index.js +1 -0
  45. package/lib/esm/features/index.js.map +1 -1
  46. package/lib/esm/features/layout/GenericPageNavHeader.js +14 -4
  47. package/lib/esm/features/layout/GenericPageNavHeader.js.map +1 -1
  48. package/lib/esm/features/magic-pdf/AnnotatedImageSlider.js +268 -0
  49. package/lib/esm/features/magic-pdf/AnnotatedImageSlider.js.map +1 -0
  50. package/lib/esm/features/magic-pdf/DownloadPopover.js +11 -11
  51. package/lib/esm/features/magic-pdf/DownloadPopover.js.map +1 -1
  52. package/lib/esm/features/magic-pdf/ExtractedContentView.js +77 -0
  53. package/lib/esm/features/magic-pdf/ExtractedContentView.js.map +1 -0
  54. package/lib/esm/features/magic-pdf/MagicPdfProvider.js +242 -0
  55. package/lib/esm/features/magic-pdf/MagicPdfProvider.js.map +1 -0
  56. package/lib/esm/features/magic-pdf/MagicPdfView.js +41 -47
  57. package/lib/esm/features/magic-pdf/MagicPdfView.js.map +1 -1
  58. package/lib/esm/features/pdf-viewer/PdfPageRenderer.js +261 -0
  59. package/lib/esm/features/pdf-viewer/PdfPageRenderer.js.map +1 -0
  60. package/lib/esm/features/pdf-viewer/PdfPageSlider.js +276 -0
  61. package/lib/esm/features/pdf-viewer/PdfPageSlider.js.map +1 -0
  62. package/lib/esm/features/pdf-viewer/SimplePdfViewer.js +71 -0
  63. package/lib/esm/features/pdf-viewer/SimplePdfViewer.js.map +1 -0
  64. package/lib/esm/features/pdf-viewer/index.js +4 -0
  65. package/lib/esm/features/pdf-viewer/index.js.map +1 -0
  66. package/lib/esm/features/store/collections/EditCollectionView.js +3 -5
  67. package/lib/esm/features/store/collections/EditCollectionView.js.map +1 -1
  68. package/lib/esm/features/store/collections/SharedPropsEditor.js +1 -2
  69. package/lib/esm/features/store/collections/SharedPropsEditor.js.map +1 -1
  70. package/lib/esm/features/store/objects/DocumentSearchResults.js +0 -7
  71. package/lib/esm/features/store/objects/DocumentSearchResults.js.map +1 -1
  72. package/lib/esm/features/store/objects/components/ContentOverview.js +273 -83
  73. package/lib/esm/features/store/objects/components/ContentOverview.js.map +1 -1
  74. package/lib/esm/features/store/objects/components/useContentPanelHooks.js +153 -0
  75. package/lib/esm/features/store/objects/components/useContentPanelHooks.js.map +1 -0
  76. package/lib/esm/features/store/objects/layout/DocumentTableColumn.js +3 -3
  77. package/lib/esm/features/store/objects/layout/DocumentTableColumn.js.map +1 -1
  78. package/lib/esm/features/store/objects/layout/renderers.js +13 -0
  79. package/lib/esm/features/store/objects/layout/renderers.js.map +1 -1
  80. package/lib/esm/features/utils/index.js +2 -0
  81. package/lib/esm/features/utils/index.js.map +1 -1
  82. package/lib/esm/features/utils/mimeType.js +8 -0
  83. package/lib/esm/features/utils/mimeType.js.map +1 -1
  84. package/lib/esm/features/utils/print.js +181 -0
  85. package/lib/esm/features/utils/print.js.map +1 -0
  86. package/lib/esm/features/utils/workflowStatus.js +43 -0
  87. package/lib/esm/features/utils/workflowStatus.js.map +1 -0
  88. package/lib/esm/router/HistoryNavigator.js +22 -2
  89. package/lib/esm/router/HistoryNavigator.js.map +1 -1
  90. package/lib/esm/shell/login/UserInfo.js +2 -1
  91. package/lib/esm/shell/login/UserInfo.js.map +1 -1
  92. package/lib/esm/shell/login/UserSessionMenu.js +7 -1
  93. package/lib/esm/shell/login/UserSessionMenu.js.map +1 -1
  94. package/lib/esm/widgets/form/Form.js +6 -2
  95. package/lib/esm/widgets/form/Form.js.map +1 -1
  96. package/lib/esm/widgets/markdown/MarkdownRenderer.js +226 -4
  97. package/lib/esm/widgets/markdown/MarkdownRenderer.js.map +1 -1
  98. package/lib/esm/widgets/schema-editor/ManagedSchema.js +0 -3
  99. package/lib/esm/widgets/schema-editor/ManagedSchema.js.map +1 -1
  100. package/lib/esm/widgets/schema-editor/json-schema4-utils.js +1 -1
  101. package/lib/esm/widgets/schema-editor/json-schema4-utils.js.map +1 -1
  102. package/lib/esm/widgets/xml-viewer/components/XMLViewer.js +18 -9
  103. package/lib/esm/widgets/xml-viewer/components/XMLViewer.js.map +1 -1
  104. package/lib/esm/widgets/xml-viewer/constants/index.js +10 -0
  105. package/lib/esm/widgets/xml-viewer/constants/index.js.map +1 -1
  106. package/lib/tsconfig.tsbuildinfo +1 -1
  107. package/lib/types/core/components/MessageBox.d.ts.map +1 -1
  108. package/lib/types/core/components/shadcn/dialog.d.ts +2 -1
  109. package/lib/types/core/components/shadcn/dialog.d.ts.map +1 -1
  110. package/lib/types/core/components/shadcn/filters/filterBar.d.ts.map +1 -1
  111. package/lib/types/core/components/shadcn/selectBox.d.ts +5 -1
  112. package/lib/types/core/components/shadcn/selectBox.d.ts.map +1 -1
  113. package/lib/types/core/components/shadcn/tabs.d.ts +3 -1
  114. package/lib/types/core/components/shadcn/tabs.d.ts.map +1 -1
  115. package/lib/types/env/index.d.ts +2 -0
  116. package/lib/types/env/index.d.ts.map +1 -1
  117. package/lib/types/features/agent/chat/AgentChart.d.ts +48 -0
  118. package/lib/types/features/agent/chat/AgentChart.d.ts.map +1 -0
  119. package/lib/types/features/agent/chat/ModernAgentConversation.d.ts.map +1 -1
  120. package/lib/types/features/agent/chat/ModernAgentOutput/AllMessagesMixed.d.ts +3 -2
  121. package/lib/types/features/agent/chat/ModernAgentOutput/AllMessagesMixed.d.ts.map +1 -1
  122. package/lib/types/features/agent/chat/ModernAgentOutput/Header.d.ts +2 -1
  123. package/lib/types/features/agent/chat/ModernAgentOutput/Header.d.ts.map +1 -1
  124. package/lib/types/features/agent/chat/ModernAgentOutput/InlineSlidingPlanPanel.d.ts +4 -2
  125. package/lib/types/features/agent/chat/ModernAgentOutput/InlineSlidingPlanPanel.d.ts.map +1 -1
  126. package/lib/types/features/agent/chat/ModernAgentOutput/MessageInput.d.ts +2 -4
  127. package/lib/types/features/agent/chat/ModernAgentOutput/MessageInput.d.ts.map +1 -1
  128. package/lib/types/features/agent/chat/ModernAgentOutput/MessageItem.d.ts.map +1 -1
  129. package/lib/types/features/agent/chat/index.d.ts +1 -0
  130. package/lib/types/features/agent/chat/index.d.ts.map +1 -1
  131. package/lib/types/features/agent/createChartTool.d.ts +178 -0
  132. package/lib/types/features/agent/createChartTool.d.ts.map +1 -0
  133. package/lib/types/features/agent/examples.d.ts +59 -0
  134. package/lib/types/features/agent/examples.d.ts.map +1 -0
  135. package/lib/types/features/agent/index.d.ts +2 -0
  136. package/lib/types/features/agent/index.d.ts.map +1 -1
  137. package/lib/types/features/agent/visualization.d.ts +95 -0
  138. package/lib/types/features/agent/visualization.d.ts.map +1 -0
  139. package/lib/types/features/facets/CollectionsFacetsNav.d.ts.map +1 -1
  140. package/lib/types/features/index.d.ts +1 -0
  141. package/lib/types/features/index.d.ts.map +1 -1
  142. package/lib/types/features/layout/GenericPageNavHeader.d.ts.map +1 -1
  143. package/lib/types/features/magic-pdf/AnnotatedImageSlider.d.ts +13 -0
  144. package/lib/types/features/magic-pdf/AnnotatedImageSlider.d.ts.map +1 -0
  145. package/lib/types/features/magic-pdf/DownloadPopover.d.ts.map +1 -1
  146. package/lib/types/features/magic-pdf/ExtractedContentView.d.ts +8 -0
  147. package/lib/types/features/magic-pdf/ExtractedContentView.d.ts.map +1 -0
  148. package/lib/types/features/magic-pdf/MagicPdfProvider.d.ts +58 -0
  149. package/lib/types/features/magic-pdf/MagicPdfProvider.d.ts.map +1 -0
  150. package/lib/types/features/magic-pdf/MagicPdfView.d.ts +1 -1
  151. package/lib/types/features/magic-pdf/MagicPdfView.d.ts.map +1 -1
  152. package/lib/types/features/pdf-viewer/PdfPageRenderer.d.ts +83 -0
  153. package/lib/types/features/pdf-viewer/PdfPageRenderer.d.ts.map +1 -0
  154. package/lib/types/features/pdf-viewer/PdfPageSlider.d.ts +29 -0
  155. package/lib/types/features/pdf-viewer/PdfPageSlider.d.ts.map +1 -0
  156. package/lib/types/features/pdf-viewer/SimplePdfViewer.d.ts +19 -0
  157. package/lib/types/features/pdf-viewer/SimplePdfViewer.d.ts.map +1 -0
  158. package/lib/types/features/pdf-viewer/index.d.ts +4 -0
  159. package/lib/types/features/pdf-viewer/index.d.ts.map +1 -0
  160. package/lib/types/features/store/collections/EditCollectionView.d.ts.map +1 -1
  161. package/lib/types/features/store/collections/SharedPropsEditor.d.ts.map +1 -1
  162. package/lib/types/features/store/objects/DocumentSearchResults.d.ts.map +1 -1
  163. package/lib/types/features/store/objects/components/ContentOverview.d.ts.map +1 -1
  164. package/lib/types/features/store/objects/components/useContentPanelHooks.d.ts +30 -0
  165. package/lib/types/features/store/objects/components/useContentPanelHooks.d.ts.map +1 -0
  166. package/lib/types/features/store/objects/layout/renderers.d.ts.map +1 -1
  167. package/lib/types/features/utils/index.d.ts +2 -0
  168. package/lib/types/features/utils/index.d.ts.map +1 -1
  169. package/lib/types/features/utils/mimeType.d.ts +1 -0
  170. package/lib/types/features/utils/mimeType.d.ts.map +1 -1
  171. package/lib/types/features/utils/print.d.ts +10 -0
  172. package/lib/types/features/utils/print.d.ts.map +1 -0
  173. package/lib/types/features/utils/workflowStatus.d.ts +10 -0
  174. package/lib/types/features/utils/workflowStatus.d.ts.map +1 -0
  175. package/lib/types/router/HistoryNavigator.d.ts +3 -0
  176. package/lib/types/router/HistoryNavigator.d.ts.map +1 -1
  177. package/lib/types/shell/login/UserInfo.d.ts.map +1 -1
  178. package/lib/types/shell/login/UserSessionMenu.d.ts.map +1 -1
  179. package/lib/types/widgets/form/Form.d.ts.map +1 -1
  180. package/lib/types/widgets/markdown/MarkdownRenderer.d.ts +5 -1
  181. package/lib/types/widgets/markdown/MarkdownRenderer.d.ts.map +1 -1
  182. package/lib/types/widgets/schema-editor/ManagedSchema.d.ts.map +1 -1
  183. package/lib/types/widgets/xml-viewer/components/XMLViewer.d.ts.map +1 -1
  184. package/lib/types/widgets/xml-viewer/constants/index.d.ts +10 -0
  185. package/lib/types/widgets/xml-viewer/constants/index.d.ts.map +1 -1
  186. package/lib/vertesia-ui-core.js +1 -1
  187. package/lib/vertesia-ui-core.js.map +1 -1
  188. package/lib/vertesia-ui-env.js +1 -1
  189. package/lib/vertesia-ui-env.js.map +1 -1
  190. package/lib/vertesia-ui-features.js +1 -1
  191. package/lib/vertesia-ui-features.js.map +1 -1
  192. package/lib/vertesia-ui-layout.js +1 -1
  193. package/lib/vertesia-ui-layout.js.map +1 -1
  194. package/lib/vertesia-ui-router.js +1 -1
  195. package/lib/vertesia-ui-router.js.map +1 -1
  196. package/lib/vertesia-ui-session.js +1 -1
  197. package/lib/vertesia-ui-session.js.map +1 -1
  198. package/lib/vertesia-ui-shell.js +1 -1
  199. package/lib/vertesia-ui-shell.js.map +1 -1
  200. package/lib/vertesia-ui-widgets.js +1 -1
  201. package/lib/vertesia-ui-widgets.js.map +1 -1
  202. package/package.json +11 -8
  203. package/src/core/components/MenuList.tsx +3 -6
  204. package/src/core/components/MessageBox.tsx +7 -2
  205. package/src/core/components/SelectBox.tsx +1 -1
  206. package/src/core/components/shadcn/dialog.tsx +19 -1
  207. package/src/core/components/shadcn/filters/filter/SelectFilter.tsx +31 -31
  208. package/src/core/components/shadcn/filters/filterBar.tsx +1 -0
  209. package/src/core/components/shadcn/selectBox.tsx +32 -6
  210. package/src/core/components/shadcn/tabs.tsx +3 -2
  211. package/src/env/index.ts +5 -0
  212. package/src/features/agent/CHART_INSTRUCTIONS.md +228 -0
  213. package/src/features/agent/chat/AgentChart.tsx +601 -0
  214. package/src/features/agent/chat/ModernAgentConversation.tsx +123 -11
  215. package/src/features/agent/chat/ModernAgentOutput/AllMessagesMixed.tsx +8 -2
  216. package/src/features/agent/chat/ModernAgentOutput/Header.tsx +12 -2
  217. package/src/features/agent/chat/ModernAgentOutput/InlineSlidingPlanPanel.tsx +6 -1
  218. package/src/features/agent/chat/ModernAgentOutput/MessageInput.tsx +15 -10
  219. package/src/features/agent/chat/ModernAgentOutput/MessageItem.tsx +122 -87
  220. package/src/features/agent/chat/index.ts +1 -0
  221. package/src/features/agent/createChartTool.ts +364 -0
  222. package/src/features/agent/examples.ts +321 -0
  223. package/src/features/agent/index.ts +2 -0
  224. package/src/features/agent/visualization.ts +227 -0
  225. package/src/features/facets/CollectionsFacetsNav.tsx +5 -1
  226. package/src/features/index.ts +1 -0
  227. package/src/features/layout/GenericPageNavHeader.tsx +15 -4
  228. package/src/features/magic-pdf/AnnotatedImageSlider.tsx +482 -0
  229. package/src/features/magic-pdf/DownloadPopover.tsx +45 -40
  230. package/src/features/magic-pdf/ExtractedContentView.tsx +132 -0
  231. package/src/features/magic-pdf/MagicPdfProvider.tsx +297 -0
  232. package/src/features/magic-pdf/MagicPdfView.tsx +184 -91
  233. package/src/features/pdf-viewer/PdfPageRenderer.tsx +612 -0
  234. package/src/features/pdf-viewer/PdfPageSlider.tsx +473 -0
  235. package/src/features/pdf-viewer/SimplePdfViewer.tsx +142 -0
  236. package/src/features/pdf-viewer/index.ts +3 -0
  237. package/src/features/store/collections/EditCollectionView.tsx +3 -5
  238. package/src/features/store/collections/SharedPropsEditor.tsx +1 -2
  239. package/src/features/store/objects/DocumentSearchResults.tsx +0 -7
  240. package/src/features/store/objects/components/ContentOverview.tsx +677 -210
  241. package/src/features/store/objects/components/useContentPanelHooks.ts +169 -0
  242. package/src/features/store/objects/layout/DocumentTableColumn.tsx +3 -3
  243. package/src/features/store/objects/layout/knowledge.md +1 -0
  244. package/src/features/store/objects/layout/renderers.tsx +25 -0
  245. package/src/features/utils/index.ts +3 -1
  246. package/src/features/utils/mimeType.ts +10 -1
  247. package/src/features/utils/print.ts +189 -0
  248. package/src/features/utils/workflowStatus.ts +44 -0
  249. package/src/router/HistoryNavigator.ts +30 -2
  250. package/src/shell/login/UserInfo.tsx +2 -0
  251. package/src/shell/login/UserSessionMenu.tsx +12 -1
  252. package/src/widgets/form/Form.tsx +8 -3
  253. package/src/widgets/markdown/MarkdownRenderer.tsx +350 -6
  254. package/src/widgets/schema-editor/ManagedSchema.ts +0 -3
  255. package/src/widgets/schema-editor/json-schema4-utils.ts +1 -1
  256. package/src/widgets/xml-viewer/components/XMLViewer.tsx +22 -10
  257. package/src/widgets/xml-viewer/constants/index.ts +11 -0
  258. package/lib/esm/features/magic-pdf/PageSlider.js +0 -70
  259. package/lib/esm/features/magic-pdf/PageSlider.js.map +0 -1
  260. package/lib/esm/features/magic-pdf/PdfPageProvider.js +0 -188
  261. package/lib/esm/features/magic-pdf/PdfPageProvider.js.map +0 -1
  262. package/lib/esm/features/magic-pdf/TextPageView.js +0 -62
  263. package/lib/esm/features/magic-pdf/TextPageView.js.map +0 -1
  264. package/lib/esm/features/magic-pdf/useResizeOnDrag.js +0 -34
  265. package/lib/esm/features/magic-pdf/useResizeOnDrag.js.map +0 -1
  266. package/lib/types/features/magic-pdf/PageSlider.d.ts +0 -9
  267. package/lib/types/features/magic-pdf/PageSlider.d.ts.map +0 -1
  268. package/lib/types/features/magic-pdf/PdfPageProvider.d.ts +0 -39
  269. package/lib/types/features/magic-pdf/PdfPageProvider.d.ts.map +0 -1
  270. package/lib/types/features/magic-pdf/TextPageView.d.ts +0 -8
  271. package/lib/types/features/magic-pdf/TextPageView.d.ts.map +0 -1
  272. package/lib/types/features/magic-pdf/useResizeOnDrag.d.ts +0 -9
  273. package/lib/types/features/magic-pdf/useResizeOnDrag.d.ts.map +0 -1
  274. package/src/features/magic-pdf/PageSlider.tsx +0 -142
  275. package/src/features/magic-pdf/PdfPageProvider.tsx +0 -310
  276. package/src/features/magic-pdf/TextPageView.tsx +0 -91
  277. package/src/features/magic-pdf/useResizeOnDrag.ts +0 -42
@@ -0,0 +1,364 @@
1
+ /**
2
+ * Chart creation tool definition for AI agents.
3
+ *
4
+ * This provides a tool schema that AI agents can use to understand
5
+ * how to create charts in their responses.
6
+ */
7
+
8
+ import type { AgentChartSpec } from './chat/AgentChart';
9
+
10
+ /**
11
+ * Tool definition for creating charts.
12
+ * Can be used with Claude, OpenAI, or other LLM tool-calling systems.
13
+ */
14
+ export const createChartToolDefinition = {
15
+ name: 'create_chart',
16
+ description: `Create an interactive chart visualization that will be rendered in the UI.
17
+
18
+ IMPORTANT: You don't actually "call" this tool. Instead, you include a markdown code block with language "chart" in your response.
19
+
20
+ Charts are created using JSON specifications in markdown code blocks:
21
+
22
+ \`\`\`chart
23
+ {
24
+ "chart": "bar|line|area|composed|pie|scatter|radar|radialBar|funnel|treemap",
25
+ "title": "Chart Title",
26
+ "data": [...],
27
+ ...
28
+ }
29
+ \`\`\`
30
+
31
+ ## CHART TYPES & WHEN TO USE
32
+
33
+ | Type | Use Case | Data Shape |
34
+ |------|----------|------------|
35
+ | bar | Category comparisons | \`[{x, y1, y2}]\` |
36
+ | line | Trends over time | \`[{x, y1, y2}]\` |
37
+ | area | Trends with volume emphasis | \`[{x, y1, y2}]\` |
38
+ | composed | Mix bars + lines | \`[{x, y1, y2}]\` with series.type |
39
+ | pie | Part-to-whole (%) | \`[{name, value}]\` |
40
+ | scatter | Correlation analysis | \`[{x, y}]\` |
41
+ | radar | Multi-dimensional comparison | \`[{axis, A, B}]\` |
42
+ | radialBar | Progress/gauges | \`[{name, value}]\` |
43
+ | funnel | Conversion stages | \`[{name, value}]\` |
44
+ | treemap | Hierarchical proportions | \`[{name, value}]\` |
45
+
46
+ ## EXAMPLES
47
+
48
+ ### Bar Chart
49
+ \`\`\`chart
50
+ {"chart":"bar","title":"Revenue by Quarter","data":[{"quarter":"Q1","revenue":100000},{"quarter":"Q2","revenue":150000}],"xKey":"quarter","series":[{"key":"revenue","label":"Revenue"}]}
51
+ \`\`\`
52
+
53
+ ### Line Chart
54
+ \`\`\`chart
55
+ {"chart":"line","title":"Performance","data":[{"period":"Q1","tvpi":1.2},{"period":"Q2","tvpi":1.5}],"xKey":"period","series":[{"key":"tvpi","label":"TVPI","color":"#4f46e5"}]}
56
+ \`\`\`
57
+
58
+ ### Area Chart
59
+ \`\`\`chart
60
+ {"chart":"area","title":"Sales Volume","data":[{"month":"Jan","sales":1000},{"month":"Feb","sales":1500}],"xKey":"month","series":[{"key":"sales","label":"Sales"}],"options":{"stacked":true}}
61
+ \`\`\`
62
+
63
+ ### Composed Chart (Bar + Line)
64
+ \`\`\`chart
65
+ {"chart":"composed","title":"Cashflow","data":[{"period":"Q1","calls":1000000,"net":-500000}],"xKey":"period","series":[{"key":"calls","type":"bar","color":"#ef4444"},{"key":"net","type":"line","yAxisId":"right"}],"yAxis":{"left":{"label":"Amount"},"right":{"label":"Net"}}}
66
+ \`\`\`
67
+
68
+ ### Pie Chart
69
+ \`\`\`chart
70
+ {"chart":"pie","title":"Market Share","data":[{"name":"Product A","value":400},{"name":"Product B","value":300},{"name":"Product C","value":200}],"nameKey":"name","valueKey":"value"}
71
+ \`\`\`
72
+
73
+ ### Donut Chart (Pie with innerRadius)
74
+ \`\`\`chart
75
+ {"chart":"pie","title":"Revenue Split","data":[{"name":"Services","value":60},{"name":"Products","value":40}],"nameKey":"name","valueKey":"value","options":{"innerRadius":50}}
76
+ \`\`\`
77
+
78
+ ### Scatter Chart
79
+ \`\`\`chart
80
+ {"chart":"scatter","title":"Price vs Volume","data":[{"price":100,"volume":500},{"price":150,"volume":400}],"xKey":"price","yKey":"volume","series":[{"key":"data","label":"Products"}]}
81
+ \`\`\`
82
+
83
+ ### Radar Chart
84
+ \`\`\`chart
85
+ {"chart":"radar","title":"Skills Comparison","data":[{"skill":"Speed","A":120,"B":110},{"skill":"Power","A":98,"B":130}],"axisKey":"skill","series":[{"key":"A","label":"Team A"},{"key":"B","label":"Team B"}]}
86
+ \`\`\`
87
+
88
+ ### RadialBar Chart (Progress)
89
+ \`\`\`chart
90
+ {"chart":"radialBar","title":"Goal Progress","data":[{"name":"Sales","value":80},{"name":"Users","value":65}],"nameKey":"name","valueKey":"value"}
91
+ \`\`\`
92
+
93
+ ### Funnel Chart
94
+ \`\`\`chart
95
+ {"chart":"funnel","title":"Conversion Funnel","data":[{"name":"Visits","value":5000},{"name":"Cart","value":2500},{"name":"Purchase","value":1000}],"nameKey":"name","valueKey":"value"}
96
+ \`\`\`
97
+
98
+ ### Treemap
99
+ \`\`\`chart
100
+ {"chart":"treemap","title":"Budget Allocation","data":[{"name":"Engineering","value":500000},{"name":"Marketing","value":200000},{"name":"Sales","value":300000}],"nameKey":"name","dataKey":"value"}
101
+ \`\`\`
102
+
103
+ ## CONFIGURATION
104
+
105
+ ### Series (for bar/line/area/composed/radar)
106
+ - key: (required) Field name in data
107
+ - label: Display name
108
+ - type: "bar"|"line"|"area" (composed only)
109
+ - color: Hex color
110
+ - yAxisId: "left"|"right"
111
+ - dot: Show dots on lines
112
+
113
+ ### Keys (for pie/scatter/radar/funnel/treemap)
114
+ - nameKey: Field for labels (default: "name")
115
+ - valueKey: Field for values (default: "value")
116
+ - xKey/yKey: For scatter charts
117
+ - axisKey: For radar axis labels
118
+ - dataKey: For treemap values
119
+
120
+ ### Options
121
+ - stacked: Stack bars/areas
122
+ - referenceZero: Show y=0 line
123
+ - innerRadius: For donut charts (0-100)
124
+ - showLabels: Show value labels
125
+ - startAngle/endAngle: For radialBar
126
+
127
+ ## COLORS
128
+ - Blue #4f46e5 - Primary
129
+ - Cyan #06b6d4 - Secondary
130
+ - Green #22c55e - Positive
131
+ - Amber #f59e0b - Warning
132
+ - Red #ef4444 - Negative
133
+ - Purple #8b5cf6 - Accent
134
+ - Pink #ec4899 - Highlight
135
+ - Teal #14b8a6 - Alternative
136
+
137
+ Numbers auto-format: 1K, 1M, 1B`,
138
+
139
+ input_schema: {
140
+ type: 'object',
141
+ properties: {
142
+ chart: {
143
+ type: 'string',
144
+ enum: ['bar', 'line', 'area', 'composed', 'pie', 'scatter', 'radar', 'radialBar', 'funnel', 'treemap'],
145
+ description: 'Type of chart to create',
146
+ },
147
+ title: {
148
+ type: 'string',
149
+ description: 'Chart title',
150
+ },
151
+ description: {
152
+ type: 'string',
153
+ description: 'Optional description shown below the title',
154
+ },
155
+ data: {
156
+ type: 'array',
157
+ description: 'Array of data objects',
158
+ items: {
159
+ type: 'object',
160
+ additionalProperties: true,
161
+ },
162
+ },
163
+ xKey: {
164
+ type: 'string',
165
+ description: 'Field name to use for X-axis (for bar/line/area/composed/scatter)',
166
+ },
167
+ yKey: {
168
+ type: 'string',
169
+ description: 'Field name for Y values (for scatter charts)',
170
+ },
171
+ nameKey: {
172
+ type: 'string',
173
+ description: 'Field name for labels (for pie/funnel/radialBar/treemap, default: "name")',
174
+ },
175
+ valueKey: {
176
+ type: 'string',
177
+ description: 'Field name for values (for pie/funnel/radialBar, default: "value")',
178
+ },
179
+ axisKey: {
180
+ type: 'string',
181
+ description: 'Field name for radar axis labels',
182
+ },
183
+ dataKey: {
184
+ type: 'string',
185
+ description: 'Field name for treemap values',
186
+ },
187
+ series: {
188
+ type: 'array',
189
+ description: 'Array of series to plot (for bar/line/area/composed/radar)',
190
+ items: {
191
+ type: 'object',
192
+ properties: {
193
+ key: {
194
+ type: 'string',
195
+ description: 'Field name in data',
196
+ },
197
+ label: {
198
+ type: 'string',
199
+ description: 'Display name',
200
+ },
201
+ type: {
202
+ type: 'string',
203
+ enum: ['bar', 'line', 'area'],
204
+ description: 'Series type (for composed charts)',
205
+ },
206
+ color: {
207
+ type: 'string',
208
+ description: 'Hex color code',
209
+ },
210
+ yAxisId: {
211
+ type: 'string',
212
+ enum: ['left', 'right'],
213
+ description: 'Which Y-axis to use',
214
+ },
215
+ dot: {
216
+ type: 'boolean',
217
+ description: 'Show dots on line (default: false)',
218
+ },
219
+ },
220
+ required: ['key'],
221
+ },
222
+ },
223
+ yAxis: {
224
+ type: 'object',
225
+ description: 'Y-axis configuration',
226
+ properties: {
227
+ left: {
228
+ type: 'object',
229
+ properties: {
230
+ label: { type: 'string' },
231
+ },
232
+ },
233
+ right: {
234
+ type: 'object',
235
+ properties: {
236
+ label: { type: 'string' },
237
+ },
238
+ },
239
+ },
240
+ },
241
+ options: {
242
+ type: 'object',
243
+ description: 'Chart options',
244
+ properties: {
245
+ stacked: {
246
+ type: 'boolean',
247
+ description: 'Stack bars/areas',
248
+ },
249
+ referenceZero: {
250
+ type: 'boolean',
251
+ description: 'Show reference line at y=0',
252
+ },
253
+ collapsible: {
254
+ type: 'boolean',
255
+ description: 'Allow user to collapse chart',
256
+ },
257
+ collapseInitially: {
258
+ type: 'boolean',
259
+ description: 'Start collapsed',
260
+ },
261
+ innerRadius: {
262
+ type: 'number',
263
+ description: 'Inner radius for donut/radialBar charts (0-100)',
264
+ },
265
+ showLabels: {
266
+ type: 'boolean',
267
+ description: 'Show value labels on pie/funnel',
268
+ },
269
+ startAngle: {
270
+ type: 'number',
271
+ description: 'Start angle for radialBar (default: 180)',
272
+ },
273
+ endAngle: {
274
+ type: 'number',
275
+ description: 'End angle for radialBar (default: 0)',
276
+ },
277
+ },
278
+ },
279
+ },
280
+ required: ['chart', 'data'],
281
+ },
282
+ };
283
+
284
+ /**
285
+ * System prompt addition for chart capabilities.
286
+ * Include this in your agent's system prompt to enable chart creation.
287
+ */
288
+ export const chartSystemPromptAddition = `
289
+ # Chart Visualization Capability
290
+
291
+ You can create interactive charts by including markdown code blocks with the language "chart".
292
+
293
+ ## Chart Types
294
+
295
+ | Type | Use Case | Required Fields |
296
+ |------|----------|-----------------|
297
+ | bar | Category comparisons | xKey, series |
298
+ | line | Trends over time | xKey, series |
299
+ | area | Trends with volume | xKey, series |
300
+ | composed | Mix bars + lines | xKey, series with type |
301
+ | pie | Part-to-whole | nameKey, valueKey |
302
+ | scatter | Correlation | xKey, yKey |
303
+ | radar | Multi-dimensional | axisKey, series |
304
+ | radialBar | Progress/gauges | nameKey, valueKey |
305
+ | funnel | Conversion stages | nameKey, valueKey |
306
+ | treemap | Hierarchical data | nameKey, dataKey |
307
+
308
+ ## Quick Examples
309
+
310
+ Bar: \`{"chart":"bar","data":[{"x":"A","y":10}],"xKey":"x","series":[{"key":"y"}]}\`
311
+ Pie: \`{"chart":"pie","data":[{"name":"A","value":60},{"name":"B","value":40}]}\`
312
+ Scatter: \`{"chart":"scatter","data":[{"x":1,"y":2}],"xKey":"x","yKey":"y"}\`
313
+
314
+ Use charts when:
315
+ - User requests visualization
316
+ - 3+ data points to display
317
+ - Visual form clarifies comparisons/trends
318
+
319
+ Colors: Blue #4f46e5 (primary), Green #22c55e (positive), Red #ef4444 (negative)
320
+ `;
321
+
322
+ /**
323
+ * Type-safe chart specification builder.
324
+ * Use this when you want to build charts programmatically.
325
+ */
326
+ export function buildChartSpec(spec: AgentChartSpec): string {
327
+ // Validate the spec
328
+ if (!spec.chart || !spec.data || !spec.xKey || !spec.series) {
329
+ throw new Error('Invalid chart spec: missing required fields (chart, data, xKey, series)');
330
+ }
331
+
332
+ if (!Array.isArray(spec.data)) {
333
+ throw new Error('Invalid chart spec: data must be an array');
334
+ }
335
+
336
+ if (!Array.isArray(spec.series) || spec.series.length === 0) {
337
+ throw new Error('Invalid chart spec: series must be a non-empty array');
338
+ }
339
+
340
+ // Return as markdown code block
341
+ const json = JSON.stringify(spec, null, 2);
342
+ return `\`\`\`chart\n${json}\n\`\`\``;
343
+ }
344
+
345
+ /**
346
+ * Extract chart specifications from markdown text.
347
+ * Useful for parsing agent responses.
348
+ */
349
+ export function extractChartSpecs(markdown: string): AgentChartSpec[] {
350
+ const chartBlockRegex = /```chart\s*\n([\s\S]*?)\n```/g;
351
+ const specs: AgentChartSpec[] = [];
352
+
353
+ let match;
354
+ while ((match = chartBlockRegex.exec(markdown)) !== null) {
355
+ try {
356
+ const spec = JSON.parse(match[1]) as AgentChartSpec;
357
+ specs.push(spec);
358
+ } catch (e) {
359
+ console.warn('Failed to parse chart spec:', e);
360
+ }
361
+ }
362
+
363
+ return specs;
364
+ }
@@ -0,0 +1,321 @@
1
+ /**
2
+ * Chart creation examples for testing and reference.
3
+ *
4
+ * These examples demonstrate how to use the chart functionality
5
+ * from both AI agents and TypeScript code.
6
+ */
7
+
8
+ import {
9
+ buildCashflowComposedChart,
10
+ buildPerformanceLineChart,
11
+ buildScenarioComparisonBarChart,
12
+ buildScenarioDeltaPercentChart,
13
+ buildNavLineChart,
14
+ toChartMarkdown,
15
+ } from './visualization';
16
+
17
+ /**
18
+ * Example 1: Simple bar chart (markdown)
19
+ */
20
+ export const exampleBarChartMarkdown = `
21
+ Here's a comparison of revenue across quarters:
22
+
23
+ \`\`\`chart
24
+ {
25
+ "version": "1.0",
26
+ "chart": "bar",
27
+ "title": "Quarterly Revenue",
28
+ "description": "Revenue performance by quarter",
29
+ "data": [
30
+ { "quarter": "Q1 2024", "revenue": 125000 },
31
+ { "quarter": "Q2 2024", "revenue": 145000 },
32
+ { "quarter": "Q3 2024", "revenue": 160000 },
33
+ { "quarter": "Q4 2024", "revenue": 180000 }
34
+ ],
35
+ "xKey": "quarter",
36
+ "series": [
37
+ {
38
+ "key": "revenue",
39
+ "label": "Revenue",
40
+ "type": "bar",
41
+ "color": "#4f46e5"
42
+ }
43
+ ],
44
+ "yAxis": {
45
+ "left": { "label": "Amount ($)" }
46
+ }
47
+ }
48
+ \`\`\`
49
+
50
+ Revenue shows consistent growth throughout 2024.
51
+ `;
52
+
53
+ /**
54
+ * Example 2: Line chart with multiple series (markdown)
55
+ */
56
+ export const exampleLineChartMarkdown = `
57
+ Here's the fund performance over time:
58
+
59
+ \`\`\`chart
60
+ {
61
+ "version": "1.0",
62
+ "chart": "line",
63
+ "title": "Fund Performance Metrics",
64
+ "description": "TVPI, DPI, and RVPI over time",
65
+ "data": [
66
+ { "period": "2024-Q1", "tvpi": 1.2, "dpi": 0.3, "rvpi": 0.9 },
67
+ { "period": "2024-Q2", "tvpi": 1.4, "dpi": 0.5, "rvpi": 0.9 },
68
+ { "period": "2024-Q3", "tvpi": 1.6, "dpi": 0.7, "rvpi": 0.9 },
69
+ { "period": "2024-Q4", "tvpi": 1.8, "dpi": 0.9, "rvpi": 0.9 }
70
+ ],
71
+ "xKey": "period",
72
+ "series": [
73
+ {
74
+ "key": "tvpi",
75
+ "label": "TVPI",
76
+ "type": "line",
77
+ "color": "#4f46e5",
78
+ "dot": false
79
+ },
80
+ {
81
+ "key": "dpi",
82
+ "label": "DPI",
83
+ "type": "line",
84
+ "color": "#16a34a",
85
+ "dot": false
86
+ },
87
+ {
88
+ "key": "rvpi",
89
+ "label": "RVPI",
90
+ "type": "line",
91
+ "color": "#f59e0b",
92
+ "dot": false
93
+ }
94
+ ],
95
+ "yAxis": {
96
+ "left": { "label": "Multiple (x)" }
97
+ },
98
+ "options": {
99
+ "referenceZero": false
100
+ }
101
+ }
102
+ \`\`\`
103
+
104
+ The fund shows strong performance with TVPI growing to 1.8x.
105
+ `;
106
+
107
+ /**
108
+ * Example 3: Composed chart with dual Y-axis (markdown)
109
+ */
110
+ export const exampleComposedChartMarkdown = `
111
+ Here's the cashflow analysis:
112
+
113
+ \`\`\`chart
114
+ {
115
+ "version": "1.0",
116
+ "chart": "composed",
117
+ "title": "Fund Cashflow Timeline",
118
+ "description": "Capital calls, distributions, and net cashflow",
119
+ "data": [
120
+ { "period": "2024-Q1", "calls": 2000000, "distributions": 500000, "net": -1500000 },
121
+ { "period": "2024-Q2", "calls": 1500000, "distributions": 800000, "net": -700000 },
122
+ { "period": "2024-Q3", "calls": 1000000, "distributions": 1200000, "net": 200000 },
123
+ { "period": "2024-Q4", "calls": 500000, "distributions": 1800000, "net": 1300000 }
124
+ ],
125
+ "xKey": "period",
126
+ "series": [
127
+ {
128
+ "key": "calls",
129
+ "label": "Capital Calls",
130
+ "type": "bar",
131
+ "color": "#ef4444"
132
+ },
133
+ {
134
+ "key": "distributions",
135
+ "label": "Distributions",
136
+ "type": "bar",
137
+ "color": "#22c55e"
138
+ },
139
+ {
140
+ "key": "net",
141
+ "label": "Net Cashflow",
142
+ "type": "line",
143
+ "color": "#0ea5e9",
144
+ "yAxisId": "right",
145
+ "dot": false
146
+ }
147
+ ],
148
+ "yAxis": {
149
+ "left": { "label": "Amount ($)" },
150
+ "right": { "label": "Net CF ($)" }
151
+ },
152
+ "options": {
153
+ "referenceZero": true
154
+ }
155
+ }
156
+ \`\`\`
157
+
158
+ The fund transitions from net negative to net positive cashflow in Q3.
159
+ `;
160
+
161
+ /**
162
+ * Example 4: Using TypeScript builders
163
+ */
164
+ export function generateCashflowChart() {
165
+ const chart = buildCashflowComposedChart({
166
+ title: 'Fund Cashflow Analysis',
167
+ description: 'Quarterly cashflows with net overlay',
168
+ rows: [
169
+ { period: '2024-Q1', calls: 2000000, distributions: 500000 },
170
+ { period: '2024-Q2', calls: 1500000, distributions: 800000 },
171
+ { period: '2024-Q3', calls: 1000000, distributions: 1200000 },
172
+ { period: '2024-Q4', calls: 500000, distributions: 1800000 },
173
+ ],
174
+ collapseInitially: false,
175
+ });
176
+
177
+ return toChartMarkdown(chart);
178
+ }
179
+
180
+ /**
181
+ * Example 5: Performance chart with TypeScript
182
+ */
183
+ export function generatePerformanceChart() {
184
+ const chart = buildPerformanceLineChart({
185
+ title: 'Fund Performance',
186
+ description: 'TVPI, DPI, and RVPI over time',
187
+ rows: [
188
+ { period: '2024-Q1', tvpi: 1.2, dpi: 0.3, rvpi: 0.9 },
189
+ { period: '2024-Q2', tvpi: 1.4, dpi: 0.5, rvpi: 0.9 },
190
+ { period: '2024-Q3', tvpi: 1.6, dpi: 0.7, rvpi: 0.9 },
191
+ { period: '2024-Q4', tvpi: 1.8, dpi: 0.9, rvpi: 0.9 },
192
+ ],
193
+ });
194
+
195
+ return toChartMarkdown(chart);
196
+ }
197
+
198
+ /**
199
+ * Example 6: Scenario comparison
200
+ */
201
+ export function generateScenarioComparisonChart() {
202
+ const chart = buildScenarioComparisonBarChart({
203
+ title: 'Base vs Optimistic Scenario',
204
+ leftLabel: 'Base Case',
205
+ rightLabel: 'Optimistic Case',
206
+ metrics: [
207
+ { label: 'Final TVPI', left: 2.5, right: 3.2 },
208
+ { label: 'IRR (%)', left: 18, right: 25 },
209
+ { label: 'Total Distributions ($M)', left: 125, right: 160 },
210
+ ],
211
+ description: 'Comparison of key metrics across scenarios',
212
+ });
213
+
214
+ return toChartMarkdown(chart);
215
+ }
216
+
217
+ /**
218
+ * Example 7: Delta percentage chart
219
+ */
220
+ export function generateDeltaChart() {
221
+ const chart = buildScenarioDeltaPercentChart({
222
+ title: 'Performance vs Plan',
223
+ metrics: [
224
+ { label: 'Revenue', left: 1000000, right: 1200000 },
225
+ { label: 'EBITDA', left: 250000, right: 320000 },
226
+ { label: 'Net Income', left: 150000, right: 180000 },
227
+ ],
228
+ description: 'Percentage change from plan',
229
+ });
230
+
231
+ return toChartMarkdown(chart);
232
+ }
233
+
234
+ /**
235
+ * Example 8: NAV timeline
236
+ */
237
+ export function generateNavChart() {
238
+ const chart = buildNavLineChart({
239
+ title: 'Fund NAV Over Time',
240
+ description: 'Net Asset Value progression',
241
+ rows: [
242
+ { period: '2024-Q1', nav: 10000000 },
243
+ { period: '2024-Q2', nav: 12000000 },
244
+ { period: '2024-Q3', nav: 15000000 },
245
+ { period: '2024-Q4', nav: 18000000 },
246
+ ],
247
+ });
248
+
249
+ return toChartMarkdown(chart);
250
+ }
251
+
252
+ /**
253
+ * Example 9: Complete agent response with chart
254
+ */
255
+ export const exampleAgentResponseWithChart = `
256
+ I've analyzed the fund performance for Q1-Q4 2024. Here are the key findings:
257
+
258
+ ## Performance Summary
259
+
260
+ - **Final TVPI:** 1.8x
261
+ - **Final DPI:** 0.9x
262
+ - **Net Cashflow:** Positive since Q3
263
+
264
+ ## Visual Analysis
265
+
266
+ ${generatePerformanceChart()}
267
+
268
+ ## Cashflow Breakdown
269
+
270
+ ${generateCashflowChart()}
271
+
272
+ ## Recommendations
273
+
274
+ 1. The fund is performing well above industry benchmarks
275
+ 2. Cashflow turned positive in Q3, indicating maturity
276
+ 3. Consider planning distributions for Q1 2025
277
+
278
+ Would you like me to run a Monte Carlo simulation to project future scenarios?
279
+ `;
280
+
281
+ /**
282
+ * Example 10: Error handling example
283
+ */
284
+ export const exampleInvalidChart = `
285
+ This will fall back to a code block because the JSON is invalid:
286
+
287
+ \`\`\`chart
288
+ {
289
+ "chart": "bar",
290
+ // Missing required fields
291
+ "title": "Invalid Chart"
292
+ }
293
+ \`\`\`
294
+
295
+ The UI will render this as a regular code block.
296
+ `;
297
+
298
+ /**
299
+ * Test data generator for interactive testing
300
+ */
301
+ export function generateTestData(periods: number) {
302
+ const data = [];
303
+
304
+ for (let i = 0; i < periods; i++) {
305
+ const quarter = Math.floor(i / 3) + 1;
306
+ const year = 2024 + Math.floor(i / 4);
307
+ const period = `${year}-Q${quarter}`;
308
+
309
+ data.push({
310
+ period,
311
+ tvpi: 1.0 + (i * 0.15) + (Math.random() * 0.1),
312
+ dpi: 0.2 + (i * 0.08) + (Math.random() * 0.05),
313
+ rvpi: 0.8 + (i * 0.07) + (Math.random() * 0.05),
314
+ calls: Math.floor(500000 + Math.random() * 1500000),
315
+ distributions: Math.floor(300000 + Math.random() * 2000000),
316
+ nav: Math.floor(5000000 + (i * 1000000) + (Math.random() * 500000)),
317
+ });
318
+ }
319
+
320
+ return data;
321
+ }
@@ -1,2 +1,4 @@
1
1
  export * from "./chat";
2
2
  export * from "./PayloadBuilder";
3
+ export * from "./visualization";
4
+ export * from "./createChartTool";