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