drizzle-cube 0.5.7 → 0.6.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 (541) hide show
  1. package/README.md +2 -0
  2. package/dist/adapters/adapters/hono/agent-handler.d.ts +9 -0
  3. package/dist/adapters/adapters/hono/mcp-handler.d.ts +37 -0
  4. package/dist/adapters/adapters/mcp-tools-handlers.d.ts +18 -0
  5. package/dist/adapters/adapters/nextjs/mcp-handler.d.ts +36 -0
  6. package/dist/adapters/{utils.d.ts → adapters/utils.d.ts} +6 -81
  7. package/dist/adapters/express/index.cjs +1 -1
  8. package/dist/adapters/express/index.js +50 -50
  9. package/dist/adapters/fastify/index.cjs +1 -1
  10. package/dist/adapters/fastify/index.js +78 -78
  11. package/dist/adapters/google-BOnRIN1w.cjs +2 -0
  12. package/dist/{server/google-CFYljAOF.js → adapters/google-CvKM9yVM.js} +83 -71
  13. package/dist/adapters/{handler-Dz1F4iwf.js → handler-CfgE0JSL.js} +515 -578
  14. package/dist/adapters/handler-Cn0dOctE.cjs +25 -0
  15. package/dist/adapters/hono/index.cjs +2 -2
  16. package/dist/adapters/hono/index.js +208 -178
  17. package/dist/adapters/locale-DDvZDFVn.js +8114 -0
  18. package/dist/adapters/locale-ZLUUNUxr.cjs +166 -0
  19. package/dist/adapters/mcp-tools.cjs +1 -1
  20. package/dist/adapters/mcp-tools.js +49 -38
  21. package/dist/adapters/mcp-transport-Chiaj4ll.cjs +40 -0
  22. package/dist/adapters/mcp-transport-H96VG3WY.js +591 -0
  23. package/dist/adapters/nextjs/index.cjs +1 -1
  24. package/dist/adapters/nextjs/index.js +190 -197
  25. package/dist/{server/openai-y7GhJNdn.js → adapters/openai-B5jEiqiB.js} +776 -719
  26. package/dist/adapters/openai-D0musiYP.cjs +17 -0
  27. package/dist/{server/openai-DiVskd89.js → adapters/openai-cDlFSTk6.js} +61 -59
  28. package/dist/adapters/openai-vXvLni8v.cjs +1 -0
  29. package/dist/adapters/{utils-DosuoabY.js → utils-BPWZsX7k.js} +1285 -1220
  30. package/dist/adapters/utils-_whV4fXL.cjs +128 -0
  31. package/dist/adapters/utils.cjs +1 -1
  32. package/dist/adapters/utils.js +2 -2
  33. package/dist/client/charts/ChartLoader.d.ts +3 -17
  34. package/dist/client/charts/chartComponentRegistry.d.ts +46 -0
  35. package/dist/client/charts/chartConfigHelpers.d.ts +38 -0
  36. package/dist/client/charts.js +14 -13
  37. package/dist/client/chunks/{DashboardEditModal-6KRE36mm.js → DashboardEditModal-okVfH8ZK.js} +5446 -4486
  38. package/dist/client/chunks/DashboardEditModal-okVfH8ZK.js.map +1 -0
  39. package/dist/client/chunks/{RetentionCombinedChart-CCpu0C-s.js → RetentionCombinedChart-BgbDhsPz.js} +10 -10
  40. package/dist/client/chunks/{RetentionCombinedChart-CCpu0C-s.js.map → RetentionCombinedChart-BgbDhsPz.js.map} +1 -1
  41. package/dist/client/chunks/{RetentionHeatmap-B24PiIfr.js → RetentionHeatmap-DjXZaTPq.js} +5 -5
  42. package/dist/client/chunks/{RetentionHeatmap-B24PiIfr.js.map → RetentionHeatmap-DjXZaTPq.js.map} +1 -1
  43. package/dist/client/chunks/analysis-builder-DB88FojM.js +5674 -0
  44. package/dist/client/chunks/analysis-builder-DB88FojM.js.map +1 -0
  45. package/dist/client/chunks/{analysis-builder-shared-x576-O5p.js → analysis-builder-shared-BVK4TYfR.js} +1578 -1292
  46. package/dist/client/chunks/analysis-builder-shared-BVK4TYfR.js.map +1 -0
  47. package/dist/client/chunks/{chart-activity-grid-CiHrLH6Y.js → chart-activity-grid-DX0SJbxs.js} +642 -494
  48. package/dist/client/chunks/chart-activity-grid-DX0SJbxs.js.map +1 -0
  49. package/dist/client/chunks/chart-area-of01_62R.js +775 -0
  50. package/dist/client/chunks/chart-area-of01_62R.js.map +1 -0
  51. package/dist/client/chunks/chart-bar-BqelQE_I.js +194 -0
  52. package/dist/client/chunks/chart-bar-BqelQE_I.js.map +1 -0
  53. package/dist/client/chunks/{chart-box-plot-Bu9hy-17.js → chart-box-plot-kkBixZ27.js} +2 -2
  54. package/dist/client/chunks/{chart-box-plot-Bu9hy-17.js.map → chart-box-plot-kkBixZ27.js.map} +1 -1
  55. package/dist/client/chunks/chart-bubble-B2he1--4.js +221 -0
  56. package/dist/client/chunks/chart-bubble-B2he1--4.js.map +1 -0
  57. package/dist/client/chunks/{chart-candlestick-Dau5AF4E.js → chart-candlestick-DZp19Tzh.js} +2 -2
  58. package/dist/client/chunks/{chart-candlestick-Dau5AF4E.js.map → chart-candlestick-DZp19Tzh.js.map} +1 -1
  59. package/dist/client/chunks/chart-config-area-BNigHUy8.js +124 -0
  60. package/dist/client/chunks/chart-config-area-BNigHUy8.js.map +1 -0
  61. package/dist/client/chunks/chart-config-bar-DSO_LRTx.js +54 -0
  62. package/dist/client/chunks/chart-config-bar-DSO_LRTx.js.map +1 -0
  63. package/dist/client/chunks/{chart-config-box-plot-DJ-dWWXA.js → chart-config-box-plot-oW8axV2q.js} +5 -10
  64. package/dist/client/chunks/chart-config-box-plot-oW8axV2q.js.map +1 -0
  65. package/dist/client/chunks/{chart-config-gauge-DSwC04l0.js → chart-config-gauge-Dq-_H9UN.js} +5 -7
  66. package/dist/client/chunks/chart-config-gauge-Dq-_H9UN.js.map +1 -0
  67. package/dist/client/chunks/{chart-config-kpi-delta-D6BIkHL3.js → chart-config-kpi-delta-DSQbvqu_.js} +5 -10
  68. package/dist/client/chunks/chart-config-kpi-delta-DSQbvqu_.js.map +1 -0
  69. package/dist/client/chunks/{chart-config-kpi-number-Bx-V9a62.js → chart-config-kpi-number-EFSWY1We.js} +5 -7
  70. package/dist/client/chunks/chart-config-kpi-number-EFSWY1We.js.map +1 -0
  71. package/dist/client/chunks/{chart-config-kpi-text-CcqC1u-8.js → chart-config-kpi-text-KM3V5X2u.js} +5 -7
  72. package/dist/client/chunks/chart-config-kpi-text-KM3V5X2u.js.map +1 -0
  73. package/dist/client/chunks/{chart-config-line-Db3jDsWc.js → chart-config-line-D6jG8PCH.js} +9 -36
  74. package/dist/client/chunks/chart-config-line-D6jG8PCH.js.map +1 -0
  75. package/dist/client/chunks/{chart-config-pie-DD4SmRTF.js → chart-config-pie-BhzW-fdn.js} +6 -16
  76. package/dist/client/chunks/chart-config-pie-BhzW-fdn.js.map +1 -0
  77. package/dist/client/chunks/{chart-config-radar-CC2XAaGr.js → chart-config-radar-D7REP1q_.js} +6 -16
  78. package/dist/client/chunks/chart-config-radar-D7REP1q_.js.map +1 -0
  79. package/dist/client/chunks/{chart-config-radial-bar-DmxKx1R0.js → chart-config-radial-bar-Byx6qOPU.js} +6 -16
  80. package/dist/client/chunks/chart-config-radial-bar-Byx6qOPU.js.map +1 -0
  81. package/dist/client/chunks/{chart-config-tree-map-BI-oQStO.js → chart-config-tree-map-DVrvf3yQ.js} +6 -16
  82. package/dist/client/chunks/chart-config-tree-map-DVrvf3yQ.js.map +1 -0
  83. package/dist/client/chunks/{chart-config-waterfall-DSnyixbI.js → chart-config-waterfall-DmFeQdIk.js} +5 -10
  84. package/dist/client/chunks/chart-config-waterfall-DmFeQdIk.js.map +1 -0
  85. package/dist/client/chunks/{chart-data-table-Cm5jrpaw.js → chart-data-table-CKauQXme.js} +1046 -1121
  86. package/dist/client/chunks/chart-data-table-CKauQXme.js.map +1 -0
  87. package/dist/client/chunks/{chart-funnel-Eke8IPtG.js → chart-funnel-CToKSBaL.js} +184 -222
  88. package/dist/client/chunks/chart-funnel-CToKSBaL.js.map +1 -0
  89. package/dist/client/chunks/chart-gauge-DTVezSk7.js +403 -0
  90. package/dist/client/chunks/chart-gauge-DTVezSk7.js.map +1 -0
  91. package/dist/client/chunks/chart-heat-map-DTuUl0BR.js +236 -0
  92. package/dist/client/chunks/chart-heat-map-DTuUl0BR.js.map +1 -0
  93. package/dist/client/chunks/chart-kpi-delta-Dn-jjO-2.js +408 -0
  94. package/dist/client/chunks/chart-kpi-delta-Dn-jjO-2.js.map +1 -0
  95. package/dist/client/chunks/chart-kpi-number-P_WBiO5S.js +244 -0
  96. package/dist/client/chunks/chart-kpi-number-P_WBiO5S.js.map +1 -0
  97. package/dist/client/chunks/chart-kpi-text-C-Y4eb5H.js +185 -0
  98. package/dist/client/chunks/chart-kpi-text-C-Y4eb5H.js.map +1 -0
  99. package/dist/client/chunks/chart-line-DKgrQA6c.js +101 -0
  100. package/dist/client/chunks/chart-line-DKgrQA6c.js.map +1 -0
  101. package/dist/client/chunks/{chart-markdown-BPW-EAm9.js → chart-markdown-CV75S_zL.js} +1359 -1240
  102. package/dist/client/chunks/chart-markdown-CV75S_zL.js.map +1 -0
  103. package/dist/client/chunks/{chart-measure-profile-BI3kADCp.js → chart-measure-profile-Ket8fJyf.js} +7 -7
  104. package/dist/client/chunks/{chart-measure-profile-BI3kADCp.js.map → chart-measure-profile-Ket8fJyf.js.map} +1 -1
  105. package/dist/client/chunks/chart-pie-ByieAX5H.js +119 -0
  106. package/dist/client/chunks/chart-pie-ByieAX5H.js.map +1 -0
  107. package/dist/client/chunks/chart-radar-CiSwHWp4.js +138 -0
  108. package/dist/client/chunks/chart-radar-CiSwHWp4.js.map +1 -0
  109. package/dist/client/chunks/chart-radial-bar-BF6Mhl6f.js +122 -0
  110. package/dist/client/chunks/chart-radial-bar-BF6Mhl6f.js.map +1 -0
  111. package/dist/client/chunks/{chart-sankey-CFzjGvZX.js → chart-sankey-DjrvKw6K.js} +36 -39
  112. package/dist/client/chunks/{chart-sankey-CFzjGvZX.js.map → chart-sankey-DjrvKw6K.js.map} +1 -1
  113. package/dist/client/chunks/chart-scatter-Dd9WFqnS.js +258 -0
  114. package/dist/client/chunks/chart-scatter-Dd9WFqnS.js.map +1 -0
  115. package/dist/client/chunks/{chart-sunburst-91Q2tzaB.js → chart-sunburst-leGpuDj7.js} +3 -3
  116. package/dist/client/chunks/{chart-sunburst-91Q2tzaB.js.map → chart-sunburst-leGpuDj7.js.map} +1 -1
  117. package/dist/client/chunks/chart-tree-map-Ceq5sLZA.js +323 -0
  118. package/dist/client/chunks/chart-tree-map-Ceq5sLZA.js.map +1 -0
  119. package/dist/client/chunks/{chart-waterfall-DcHbbPaG.js → chart-waterfall-DyvQReN5.js} +7 -7
  120. package/dist/client/chunks/{chart-waterfall-DcHbbPaG.js.map → chart-waterfall-DyvQReN5.js.map} +1 -1
  121. package/dist/client/chunks/{charts-core-CrBDYN6N.js → charts-core-DaXSt1Dd.js} +2 -2
  122. package/dist/client/chunks/{charts-core-CrBDYN6N.js.map → charts-core-DaXSt1Dd.js.map} +1 -1
  123. package/dist/client/chunks/charts-loader-DdTeCeNo.js +84 -0
  124. package/dist/client/chunks/charts-loader-DdTeCeNo.js.map +1 -0
  125. package/dist/client/chunks/{core-DsAWNRRv.js → core-D7vPfUIe.js} +2 -2
  126. package/dist/client/chunks/{core-DsAWNRRv.js.map → core-D7vPfUIe.js.map} +1 -1
  127. package/dist/client/chunks/{nl-NL-oyr2wENY.js → nl-NL-2zTAWTej.js} +8 -2
  128. package/dist/client/chunks/{nl-NL-oyr2wENY.js.map → nl-NL-2zTAWTej.js.map} +1 -1
  129. package/dist/client/chunks/retention-ChW9jYdy.js.map +1 -1
  130. package/dist/client/chunks/{schema-visualization-BszcrmZX.js → schema-visualization-Cb_E9_Gd.js} +12 -12
  131. package/dist/client/chunks/{schema-visualization-BszcrmZX.js.map → schema-visualization-Cb_E9_Gd.js.map} +1 -1
  132. package/dist/client/chunks/{useDirtyStateTracking-B5wCDJSj.js → useDirtyStateTracking-MbpxH_v6.js} +95 -84
  133. package/dist/client/chunks/useDirtyStateTracking-MbpxH_v6.js.map +1 -0
  134. package/dist/client/chunks/{useExplainAI-CCeCYzDm.js → useExplainAI-evnZkjCY.js} +14 -14
  135. package/dist/client/chunks/{useExplainAI-CCeCYzDm.js.map → useExplainAI-evnZkjCY.js.map} +1 -1
  136. package/dist/client/chunks/{utils-kqa-JIMg.js → utils-3P6z1vz5.js} +3 -3
  137. package/dist/client/chunks/{utils-kqa-JIMg.js.map → utils-3P6z1vz5.js.map} +1 -1
  138. package/dist/client/chunks/{vendor-0hJNlZXQ.js → vendor-DSpR0IW6.js} +43 -43
  139. package/dist/client/chunks/{vendor-0hJNlZXQ.js.map → vendor-DSpR0IW6.js.map} +1 -1
  140. package/dist/client/components/AgenticNotebook/agentChatParts.d.ts +34 -0
  141. package/dist/client/components/AgenticNotebook/chatMessageParts.d.ts +39 -0
  142. package/dist/client/components/AgenticNotebook/useAgentChatController.d.ts +25 -0
  143. package/dist/client/components/AgenticNotebook/useNotebookAutosave.d.ts +12 -0
  144. package/dist/client/components/AnalysisBuilder/AnalysisAIPanel.d.ts +1 -1
  145. package/dist/client/components/AnalysisBuilder/AnalysisAxisDropZone.d.ts +1 -1
  146. package/dist/client/components/AnalysisBuilder/AnalysisChartConfigPanel.d.ts +1 -1
  147. package/dist/client/components/AnalysisBuilder/AnalysisDisplayConfigPanel.d.ts +1 -1
  148. package/dist/client/components/AnalysisBuilder/AnalysisFilterGroup.d.ts +1 -1
  149. package/dist/client/components/AnalysisBuilder/AnalysisFilterItem.d.ts +1 -1
  150. package/dist/client/components/AnalysisBuilder/AnalysisFilterSection.d.ts +1 -1
  151. package/dist/client/components/AnalysisBuilder/AnalysisModeErrorBoundary.d.ts +1 -1
  152. package/dist/client/components/AnalysisBuilder/AnalysisQueryPanelParts.d.ts +64 -0
  153. package/dist/client/components/AnalysisBuilder/AnalysisResultsHeader.d.ts +67 -0
  154. package/dist/client/components/AnalysisBuilder/BreakdownComparisonToggle.d.ts +13 -0
  155. package/dist/client/components/AnalysisBuilder/BreakdownRow.d.ts +26 -0
  156. package/dist/client/components/AnalysisBuilder/DisplayOptionControl.d.ts +10 -0
  157. package/dist/client/components/AnalysisBuilder/ExecutionPlanPanelParts.d.ts +22 -0
  158. package/dist/client/components/AnalysisBuilder/ExplainAIPanel.d.ts +2 -1
  159. package/dist/client/components/AnalysisBuilder/FieldDetailPanel.d.ts +1 -1
  160. package/dist/client/components/AnalysisBuilder/FieldSearchItem.d.ts +1 -1
  161. package/dist/client/components/AnalysisBuilder/FieldSearchModal.d.ts +1 -1
  162. package/dist/client/components/AnalysisBuilder/FieldSearchResults.d.ts +16 -0
  163. package/dist/client/components/AnalysisBuilder/FilterConfigModal.d.ts +2 -1
  164. package/dist/client/components/AnalysisBuilder/FilterValueInput.d.ts +63 -0
  165. package/dist/client/components/AnalysisBuilder/FlowDepthControls.d.ts +10 -0
  166. package/dist/client/components/AnalysisBuilder/FlowVisualizationPicker.d.ts +7 -0
  167. package/dist/client/components/AnalysisBuilder/LegacyBooleanOptions.d.ts +8 -0
  168. package/dist/client/components/AnalysisBuilder/LimitSection.d.ts +1 -1
  169. package/dist/client/components/AnalysisBuilder/MetricRow.d.ts +23 -0
  170. package/dist/client/components/AnalysisBuilder/SectionHeading.d.ts +1 -1
  171. package/dist/client/components/AnalysisBuilder/SortToggleButton.d.ts +13 -0
  172. package/dist/client/components/AnalysisBuilder/StringArrayInput.d.ts +17 -0
  173. package/dist/client/components/AnalysisBuilder/filterConfigModalUtils.d.ts +30 -0
  174. package/dist/client/components/AnalysisBuilder/hooks/useAnalysisBuilderImperativeHandle.d.ts +13 -0
  175. package/dist/client/components/AnalysisBuilder/hooks/useDragReorder.d.ts +25 -0
  176. package/dist/client/components/AnalysisBuilder/hooks/useFieldSearchKeyboard.d.ts +11 -0
  177. package/dist/client/components/AnalysisBuilder/utils/axisConfigUtils.d.ts +23 -0
  178. package/dist/client/components/AnalysisBuilder/utils/executionPlanMarkdown.d.ts +8 -0
  179. package/dist/client/components/AnalysisBuilder/utils/fieldUtils.d.ts +5 -0
  180. package/dist/client/components/AnalysisBuilder/utils/resultsPanelDerive.d.ts +68 -0
  181. package/dist/client/components/AnalysisBuilder/utils/shareStateUtils.d.ts +68 -0
  182. package/dist/client/components/AnalysisBuilder/utils/sortUtils.d.ts +7 -0
  183. package/dist/client/components/AnalyticsDashboard.d.ts +1 -1
  184. package/dist/client/components/AnalyticsPage.d.ts +1 -1
  185. package/dist/client/components/ChartErrorBoundary.d.ts +1 -1
  186. package/dist/client/components/ChartTypeSelector.d.ts +1 -1
  187. package/dist/client/components/ColorPaletteSelector.d.ts +1 -1
  188. package/dist/client/components/DashboardEditModal.d.ts +2 -1
  189. package/dist/client/components/DashboardFilters/CompactFilterBarParts.d.ts +26 -0
  190. package/dist/client/components/DashboardFilters/DashboardFilterConfigModal.d.ts +1 -1
  191. package/dist/client/components/DashboardFilters/DashboardFilterConfigModalParts.d.ts +27 -0
  192. package/dist/client/components/DashboardFilters/DashboardFilterItem.d.ts +1 -1
  193. package/dist/client/components/DashboardFilters/DashboardFilterValueInput.d.ts +39 -0
  194. package/dist/client/components/DashboardFilters/dashboardFilterConfigModalUtils.d.ts +21 -0
  195. package/dist/client/components/DashboardFilters/useCompactFilterBar.d.ts +19 -0
  196. package/dist/client/components/DashboardFilters/useDashboardFilterConfigModal.d.ts +69 -0
  197. package/dist/client/components/DashboardFilters/useDateRangeState.d.ts +19 -0
  198. package/dist/client/components/DashboardFilters/useFilterDropdowns.d.ts +21 -0
  199. package/dist/client/components/DashboardFilters/useFilterValueFetch.d.ts +23 -0
  200. package/dist/client/components/DashboardGrid.d.ts +1 -1
  201. package/dist/client/components/DashboardPortletCard.d.ts +2 -57
  202. package/dist/client/components/DashboardThumbnailPlaceholder.d.ts +1 -1
  203. package/dist/client/components/DataBrowser/DataBrowserSidebar.d.ts +1 -1
  204. package/dist/client/components/DataBrowser/DataBrowserToolbar.d.ts +1 -1
  205. package/dist/client/components/DataBrowser/index.d.ts +1 -1
  206. package/dist/client/components/DataHistogram.d.ts +1 -1
  207. package/dist/client/components/DebugModal.d.ts +1 -1
  208. package/dist/client/components/DrillBreadcrumb.d.ts +2 -1
  209. package/dist/client/components/LoadingIndicator.d.ts +1 -1
  210. package/dist/client/components/MobileStackedLayout.d.ts +1 -1
  211. package/dist/client/components/PortletAnalysisModal.d.ts +1 -1
  212. package/dist/client/components/PortletContainer.d.ts +1 -1
  213. package/dist/client/components/PortletFilterConfigModal.d.ts +6 -4
  214. package/dist/client/components/RowManagedLayout.d.ts +1 -1
  215. package/dist/client/components/ScaledGridWrapper.d.ts +1 -1
  216. package/dist/client/components/SchemaVisualization/CubeNode.d.ts +1 -1
  217. package/dist/client/components/SchemaVisualization/FieldDetailPanel.d.ts +1 -1
  218. package/dist/client/components/SchemaVisualization/RelationshipEdge.d.ts +1 -1
  219. package/dist/client/components/SchemaVisualization/SchemaVisualizationLazy.d.ts +1 -1
  220. package/dist/client/components/SchemaVisualization/index.d.ts +1 -1
  221. package/dist/client/components/TextPortletModal.d.ts +1 -1
  222. package/dist/client/components/analyticsPortlet/PortletChart.d.ts +31 -0
  223. package/dist/client/components/analyticsPortlet/PortletChartView.d.ts +35 -0
  224. package/dist/client/components/analyticsPortlet/PortletStates.d.ts +65 -0
  225. package/dist/client/components/analyticsPortlet/parsePortletQuery.d.ts +22 -0
  226. package/dist/client/components/analyticsPortlet/portletRenderState.d.ts +31 -0
  227. package/dist/client/components/analyticsPortlet/usePortletDebugData.d.ts +37 -0
  228. package/dist/client/components/analyticsPortlet/usePortletDrillState.d.ts +17 -0
  229. package/dist/client/components/analyticsPortlet/usePortletQueryResults.d.ts +37 -0
  230. package/dist/client/components/charts/ActivityGridChart.helpers.d.ts +33 -0
  231. package/dist/client/components/charts/ActivityGridChart.render.d.ts +31 -0
  232. package/dist/client/components/charts/AxisFormatControls.d.ts +5 -3
  233. package/dist/client/components/charts/BarChart.helpers.d.ts +23 -0
  234. package/dist/client/components/charts/BarSeries.d.ts +29 -0
  235. package/dist/client/components/charts/BubbleChart.helpers.d.ts +43 -0
  236. package/dist/client/components/charts/BubbleChart.render.d.ts +21 -0
  237. package/dist/client/components/charts/ChartContainer.d.ts +1 -1
  238. package/dist/client/components/charts/ChartLegend.d.ts +1 -1
  239. package/dist/client/components/charts/ChartStates.d.ts +38 -0
  240. package/dist/client/components/charts/ChartTooltip.d.ts +1 -1
  241. package/dist/client/components/charts/FunnelChart.helpers.d.ts +25 -0
  242. package/dist/client/components/charts/FunnelViews.d.ts +16 -0
  243. package/dist/client/components/charts/HeatMapCanvas.d.ts +25 -0
  244. package/dist/client/components/charts/HeatMapChart.helpers.d.ts +64 -0
  245. package/dist/client/components/charts/KpiDelta.helpers.d.ts +20 -0
  246. package/dist/client/components/charts/KpiNumber.helpers.d.ts +30 -0
  247. package/dist/client/components/charts/KpiStates.d.ts +19 -0
  248. package/dist/client/components/charts/MissingDependencyFallback.d.ts +1 -1
  249. package/dist/client/components/charts/ScatterChart.helpers.d.ts +43 -0
  250. package/dist/client/components/charts/ScatterSeries.d.ts +17 -0
  251. package/dist/client/components/charts/ScatterTooltip.d.ts +21 -0
  252. package/dist/client/components/charts/TreeMapChart.helpers.d.ts +37 -0
  253. package/dist/client/components/charts/TreeMapContent.d.ts +24 -0
  254. package/dist/client/components/charts/TreeMapLegend.d.ts +13 -0
  255. package/dist/client/components/charts/cartesianChartHelpers.d.ts +126 -0
  256. package/dist/client/components/charts/chartAxisResolution.d.ts +32 -0
  257. package/dist/client/components/charts/chartScaffolding.d.ts +77 -0
  258. package/dist/client/components/charts/gaugeChartHelpers.d.ts +36 -0
  259. package/dist/client/components/charts/kpiTextHelpers.d.ts +46 -0
  260. package/dist/client/components/charts/radarChartHelpers.d.ts +14 -0
  261. package/dist/client/components/charts/radialBarChartHelpers.d.ts +22 -0
  262. package/dist/client/components/charts/useChartDimensions.d.ts +20 -0
  263. package/dist/client/components/charts/useKpiDimensions.d.ts +30 -0
  264. package/dist/client/components/dashboard/DashboardContext.d.ts +2 -2
  265. package/dist/client/components/dashboard/DashboardCoordinator.d.ts +1 -1
  266. package/dist/client/components/dashboard/DashboardEditBar.d.ts +5 -0
  267. package/dist/client/components/dashboard/DashboardFilterBar.d.ts +1 -1
  268. package/dist/client/components/dashboard/DashboardGridSurface.d.ts +1 -1
  269. package/dist/client/components/dashboard/DashboardModals.d.ts +1 -1
  270. package/dist/client/components/dashboard/DashboardProvider.d.ts +1 -1
  271. package/dist/client/components/dashboard/DashboardToolbar.d.ts +1 -1
  272. package/dist/client/components/dashboard/LayoutModeToggle.d.ts +10 -0
  273. package/dist/client/components/dashboard/dashboardGridUtils.d.ts +1 -1
  274. package/dist/client/components/dashboardPortletCard/FilterFieldChip.d.ts +12 -0
  275. package/dist/client/components/dashboardPortletCard/PortletCardHeader.d.ts +43 -0
  276. package/dist/client/components/dashboardPortletCard/cardStyles.d.ts +33 -0
  277. package/dist/client/components/dashboardPortletCard/filterField.d.ts +12 -0
  278. package/dist/client/components/dashboardPortletCard/propsEqual.d.ts +55 -0
  279. package/dist/client/components/dashboardPortletCard/usePortletCardActions.d.ts +16 -0
  280. package/dist/client/components/portletAnalysisModal/saveValidation.d.ts +8 -0
  281. package/dist/client/components/shared/dateRangeUtils.d.ts +40 -0
  282. package/dist/client/components/shared/filterDisplayUtils.d.ts +10 -0
  283. package/dist/client/components/shared/filterItem/FilterDateRangeSelector.d.ts +17 -0
  284. package/dist/client/components/shared/filterItem/FilterFieldDropdown.d.ts +16 -0
  285. package/dist/client/components/shared/filterItem/dateRangeSync.d.ts +14 -0
  286. package/dist/client/components/shared/filterItem/fieldVisuals.d.ts +5 -0
  287. package/dist/client/components/shared/filterValueSelector/FilterValueInputs.d.ts +55 -0
  288. package/dist/client/components/shared/filterValueSelector/useFilterValueSelectorState.d.ts +25 -0
  289. package/dist/client/components/shared/queryFieldUtils.d.ts +21 -0
  290. package/dist/client/components/shared/utils.d.ts +4 -43
  291. package/dist/client/components.js +3 -3
  292. package/dist/client/hooks/agentChatStream.d.ts +39 -0
  293. package/dist/client/hooks/analysisQueryExecutionModes.d.ts +133 -0
  294. package/dist/client/hooks/dashboard/useDashboardController.d.ts +2 -2
  295. package/dist/client/hooks/drillNavigation.d.ts +25 -0
  296. package/dist/client/hooks/useDashboardHook.d.ts +2 -2
  297. package/dist/client/hooks.js +3 -3
  298. package/dist/client/icons.d.ts +1 -1
  299. package/dist/client/icons.js +2 -2
  300. package/dist/client/index.js +816 -669
  301. package/dist/client/index.js.map +1 -1
  302. package/dist/client/providers/CubeApiProvider.d.ts +1 -1
  303. package/dist/client/providers/CubeFeaturesProvider.d.ts +1 -1
  304. package/dist/client/providers/CubeMetaProvider.d.ts +1 -1
  305. package/dist/client/providers/CubeProvider.d.ts +1 -1
  306. package/dist/client/providers/I18nProvider.d.ts +1 -1
  307. package/dist/client/providers.js +3 -3
  308. package/dist/client/schema.js +1 -1
  309. package/dist/client/shared/chartConfigBuilders.d.ts +18 -0
  310. package/dist/client/shared/components/QueryAnalysisPanel.sections.d.ts +41 -0
  311. package/dist/client/shared/queryTransforms.d.ts +20 -0
  312. package/dist/client/shared/utils.d.ts +2 -4
  313. package/dist/client/stores/analysisBuilderStore.d.ts +1 -1
  314. package/dist/client/stores/dashboardStore.d.ts +1 -1
  315. package/dist/client/stores/dataBrowserStore.d.ts +1 -1
  316. package/dist/client/stores/notebookStore.d.ts +1 -1
  317. package/dist/client/stores/optionsToAnalysisConfig.d.ts +17 -0
  318. package/dist/client/styles.css +1 -1
  319. package/dist/client/types/drill.d.ts +1 -1
  320. package/dist/client/types.d.ts +7 -2
  321. package/dist/client/utils/axisValueFormatting.d.ts +32 -0
  322. package/dist/client/utils/drillQueryBuilder.d.ts +2 -2
  323. package/dist/client/utils/filterUtils.d.ts +33 -5
  324. package/dist/client/utils/joinReachability.d.ts +27 -0
  325. package/dist/client/utils/timeValueFormatting.d.ts +32 -0
  326. package/dist/client/utils.js +6 -6
  327. package/dist/client-bundle-stats.html +1 -1
  328. package/dist/mcp-app/mcp-app.html +55 -55
  329. package/dist/server/google-BOnRIN1w.cjs +2 -0
  330. package/dist/{adapters/google-CFYljAOF.js → server/google-CvKM9yVM.js} +83 -71
  331. package/dist/server/index.cjs +179 -211
  332. package/dist/server/index.d.ts +2 -5050
  333. package/dist/server/index.js +6360 -6462
  334. package/dist/{adapters/openai-y7GhJNdn.js → server/openai-B5jEiqiB.js} +776 -719
  335. package/dist/server/openai-D0musiYP.cjs +17 -0
  336. package/dist/{adapters/openai-DiVskd89.js → server/openai-cDlFSTk6.js} +61 -59
  337. package/dist/server/openai-vXvLni8v.cjs +1 -0
  338. package/dist/server/server/adapters/base-adapter.d.ts +332 -0
  339. package/dist/server/server/adapters/databend-adapter.d.ts +63 -0
  340. package/dist/server/server/adapters/duckdb-adapter.d.ts +68 -0
  341. package/dist/server/server/adapters/mysql-adapter.d.ts +65 -0
  342. package/dist/server/server/adapters/postgres-adapter.d.ts +55 -0
  343. package/dist/server/server/adapters/singlestore-adapter.d.ts +4 -0
  344. package/dist/server/server/adapters/snowflake-adapter.d.ts +53 -0
  345. package/dist/server/server/adapters/sqlite-adapter.d.ts +120 -0
  346. package/dist/server/server/adapters/window-function-builder.d.ts +11 -0
  347. package/dist/server/server/agent/chart-validation.d.ts +22 -0
  348. package/dist/server/server/agent/handler-steps.d.ts +37 -0
  349. package/dist/server/server/agent/handler.d.ts +25 -0
  350. package/dist/server/server/agent/index.d.ts +11 -0
  351. package/dist/server/server/agent/providers/anthropic.d.ts +24 -0
  352. package/dist/server/server/agent/providers/factory.d.ts +12 -0
  353. package/dist/server/server/agent/providers/google.d.ts +23 -0
  354. package/dist/server/server/agent/providers/index.d.ts +6 -0
  355. package/dist/server/server/agent/providers/openai.d.ts +26 -0
  356. package/dist/server/server/agent/providers/types.d.ts +95 -0
  357. package/dist/server/server/agent/system-prompt.d.ts +5 -0
  358. package/dist/server/server/agent/tools.d.ts +28 -0
  359. package/dist/server/server/agent/types.d.ts +192 -0
  360. package/dist/server/server/ai/discovery-helpers.d.ts +29 -0
  361. package/dist/server/server/ai/discovery.d.ts +66 -0
  362. package/dist/server/server/ai/index.d.ts +10 -0
  363. package/dist/server/server/ai/mcp-prompts.d.ts +83 -0
  364. package/dist/server/server/ai/query-schema.d.ts +258 -0
  365. package/dist/server/server/ai/schemas.d.ts +63 -0
  366. package/dist/server/server/ai/suggestion-helpers.d.ts +33 -0
  367. package/dist/server/server/ai/suggestion.d.ts +16 -0
  368. package/dist/server/server/ai/validation-helpers.d.ts +21 -0
  369. package/dist/server/server/ai/validation.d.ts +31 -0
  370. package/dist/server/server/builders/analysis-utils.d.ts +106 -0
  371. package/dist/server/server/builders/comparison-query-builder.d.ts +70 -0
  372. package/dist/server/server/builders/cte-builder.d.ts +108 -0
  373. package/dist/server/server/builders/date-time-builder.d.ts +34 -0
  374. package/dist/server/server/builders/date-time-helpers.d.ts +34 -0
  375. package/dist/server/server/builders/filter-builder.d.ts +25 -0
  376. package/dist/server/server/builders/filter-operators.d.ts +23 -0
  377. package/dist/server/server/builders/flow-query-builder.d.ts +136 -0
  378. package/dist/server/server/builders/funnel-query-builder.d.ts +145 -0
  379. package/dist/server/server/builders/group-by-builder.d.ts +38 -0
  380. package/dist/server/server/builders/index.d.ts +13 -0
  381. package/dist/server/server/builders/measure-builder.d.ts +185 -0
  382. package/dist/server/server/builders/retention-query-builder.d.ts +98 -0
  383. package/dist/server/server/cache-providers/index.d.ts +5 -0
  384. package/dist/server/server/cache-providers/memory.d.ts +105 -0
  385. package/dist/server/server/cache-utils.d.ts +85 -0
  386. package/dist/server/server/compiler-metadata.d.ts +11 -0
  387. package/dist/server/server/compiler.d.ts +212 -0
  388. package/dist/server/server/cube-utils.d.ts +158 -0
  389. package/dist/server/server/database-utils.d.ts +18 -0
  390. package/dist/server/server/execution/annotation-builder.d.ts +12 -0
  391. package/dist/server/server/execution/filter-cache-preloader.d.ts +19 -0
  392. package/dist/server/server/execution/mode-router.d.ts +25 -0
  393. package/dist/server/server/execution/query-result-cache.d.ts +21 -0
  394. package/dist/server/server/execution/result-post-processor.d.ts +10 -0
  395. package/dist/server/server/executor.d.ts +186 -0
  396. package/dist/server/server/executors/base-executor.d.ts +16 -0
  397. package/dist/server/server/executors/databend-executor.d.ts +33 -0
  398. package/dist/server/server/executors/duckdb-executor.d.ts +33 -0
  399. package/dist/server/server/executors/explain-utils.d.ts +28 -0
  400. package/dist/server/server/executors/index.d.ts +21 -0
  401. package/dist/server/server/executors/mysql-executor.d.ts +27 -0
  402. package/dist/server/server/executors/postgres-executor.d.ts +27 -0
  403. package/dist/server/server/executors/singlestore-executor.d.ts +9 -0
  404. package/dist/server/server/executors/snowflake-executor.d.ts +33 -0
  405. package/dist/server/server/executors/sqlite-executor.d.ts +28 -0
  406. package/dist/server/server/explain/databend-parser.d.ts +16 -0
  407. package/dist/server/server/explain/duckdb-parser.d.ts +28 -0
  408. package/dist/server/server/explain/explain-tree.d.ts +20 -0
  409. package/dist/server/server/explain/index.d.ts +9 -0
  410. package/dist/server/server/explain/mysql-parser.d.ts +38 -0
  411. package/dist/server/server/explain/postgres-parser.d.ts +18 -0
  412. package/dist/server/server/explain/snowflake-parser.d.ts +17 -0
  413. package/dist/server/server/explain/sqlite-parser.d.ts +23 -0
  414. package/dist/server/server/filter-cache.d.ts +73 -0
  415. package/dist/server/server/gap-filler.d.ts +48 -0
  416. package/dist/server/server/index.d.ts +38 -0
  417. package/dist/server/server/logical-plan/cte-planner-helpers.d.ts +37 -0
  418. package/dist/server/server/logical-plan/cte-planner.d.ts +104 -0
  419. package/dist/server/server/logical-plan/filter-propagation.d.ts +44 -0
  420. package/dist/server/server/logical-plan/index.d.ts +19 -0
  421. package/dist/server/server/logical-plan/join-planner.d.ts +27 -0
  422. package/dist/server/server/logical-plan/logical-plan-builder.d.ts +58 -0
  423. package/dist/server/server/logical-plan/logical-planner.d.ts +39 -0
  424. package/dist/server/server/logical-plan/optimiser.d.ts +34 -0
  425. package/dist/server/server/logical-plan/plan-analysis-reporter.d.ts +59 -0
  426. package/dist/server/server/logical-plan/planner-utils.d.ts +20 -0
  427. package/dist/server/server/logical-plan/types.d.ts +199 -0
  428. package/dist/server/server/measure-classification.d.ts +40 -0
  429. package/dist/server/server/physical-plan/drizzle-plan-builder.d.ts +50 -0
  430. package/dist/server/server/physical-plan/drizzle-sql-builder.d.ts +118 -0
  431. package/dist/server/server/physical-plan/index.d.ts +2 -0
  432. package/dist/server/server/physical-plan/processors/cte-processor.d.ts +6 -0
  433. package/dist/server/server/physical-plan/processors/index.d.ts +8 -0
  434. package/dist/server/server/physical-plan/processors/joins-processor.d.ts +6 -0
  435. package/dist/server/server/physical-plan/processors/keys-dedup-processor.d.ts +13 -0
  436. package/dist/server/server/physical-plan/processors/multi-fact-processor.d.ts +13 -0
  437. package/dist/server/server/physical-plan/processors/predicates-processor.d.ts +6 -0
  438. package/dist/server/server/physical-plan/processors/selection-processor.d.ts +6 -0
  439. package/dist/server/server/physical-plan/processors/shared.d.ts +38 -0
  440. package/dist/server/server/physical-plan/processors/window-processor.d.ts +6 -0
  441. package/dist/server/server/prompts/explain-analysis-prompt.d.ts +47 -0
  442. package/dist/server/server/prompts/index.d.ts +27 -0
  443. package/dist/server/server/prompts/single-step-prompt.d.ts +31 -0
  444. package/dist/server/server/prompts/step0-validation-prompt.d.ts +39 -0
  445. package/dist/server/server/prompts/step1-shape-prompt.d.ts +29 -0
  446. package/dist/server/server/prompts/step2-complete-prompt.d.ts +19 -0
  447. package/dist/server/server/prompts/types.d.ts +37 -0
  448. package/dist/server/server/query-handlers.d.ts +79 -0
  449. package/dist/server/server/query-modes.d.ts +28 -0
  450. package/dist/server/server/query-validator.d.ts +9 -0
  451. package/dist/server/server/resolvers/calculated-measure-resolver.d.ts +98 -0
  452. package/dist/server/server/resolvers/index.d.ts +6 -0
  453. package/dist/server/server/resolvers/join-path-resolver.d.ts +158 -0
  454. package/dist/server/server/sql-format.d.ts +11 -0
  455. package/dist/server/server/template-substitution.d.ts +57 -0
  456. package/dist/server/server/types/analysis.d.ts +189 -0
  457. package/dist/server/server/types/cache.d.ts +132 -0
  458. package/dist/server/server/types/core.d.ts +164 -0
  459. package/dist/server/server/types/cube.d.ts +544 -0
  460. package/dist/server/server/types/executor.d.ts +156 -0
  461. package/dist/server/server/types/flow.d.ts +144 -0
  462. package/dist/server/server/types/funnel.d.ts +118 -0
  463. package/dist/server/server/types/index.d.ts +11 -0
  464. package/dist/server/server/types/metadata.d.ts +113 -0
  465. package/dist/server/server/types/query.d.ts +153 -0
  466. package/dist/server/server/types/retention.d.ts +141 -0
  467. package/dist/server/server/types/utils.d.ts +11 -0
  468. package/dist/server/server/types/validation.d.ts +14 -0
  469. package/package.json +15 -8
  470. package/dist/adapters/google-DUlXeeDA.cjs +0 -2
  471. package/dist/adapters/handler-C63rJUUK.cjs +0 -25
  472. package/dist/adapters/locale-CTNwPVZI.cjs +0 -198
  473. package/dist/adapters/locale-gU_d1Wja.js +0 -8249
  474. package/dist/adapters/mcp-transport-C4J4SAcn.cjs +0 -40
  475. package/dist/adapters/mcp-transport-CVUiifEc.js +0 -579
  476. package/dist/adapters/openai-6wrBvAnv.cjs +0 -1
  477. package/dist/adapters/openai-BDwb2u7y.cjs +0 -17
  478. package/dist/adapters/utils-CkEkU8Bo.cjs +0 -128
  479. package/dist/client/chunks/DashboardEditModal-6KRE36mm.js.map +0 -1
  480. package/dist/client/chunks/analysis-builder-shared-x576-O5p.js.map +0 -1
  481. package/dist/client/chunks/analysis-builder-zd48FVJO.js +0 -5367
  482. package/dist/client/chunks/analysis-builder-zd48FVJO.js.map +0 -1
  483. package/dist/client/chunks/chart-activity-grid-CiHrLH6Y.js.map +0 -1
  484. package/dist/client/chunks/chart-area-CXFK-Grv.js +0 -450
  485. package/dist/client/chunks/chart-area-CXFK-Grv.js.map +0 -1
  486. package/dist/client/chunks/chart-bar-DKXfLoGG.js +0 -271
  487. package/dist/client/chunks/chart-bar-DKXfLoGG.js.map +0 -1
  488. package/dist/client/chunks/chart-bubble-DGkTQlxM.js +0 -273
  489. package/dist/client/chunks/chart-bubble-DGkTQlxM.js.map +0 -1
  490. package/dist/client/chunks/chart-config-area-Bq_UsW3x.js +0 -101
  491. package/dist/client/chunks/chart-config-area-Bq_UsW3x.js.map +0 -1
  492. package/dist/client/chunks/chart-config-bar-_JEGZnAu.js +0 -95
  493. package/dist/client/chunks/chart-config-bar-_JEGZnAu.js.map +0 -1
  494. package/dist/client/chunks/chart-config-box-plot-DJ-dWWXA.js.map +0 -1
  495. package/dist/client/chunks/chart-config-gauge-DSwC04l0.js.map +0 -1
  496. package/dist/client/chunks/chart-config-kpi-delta-D6BIkHL3.js.map +0 -1
  497. package/dist/client/chunks/chart-config-kpi-number-Bx-V9a62.js.map +0 -1
  498. package/dist/client/chunks/chart-config-kpi-text-CcqC1u-8.js.map +0 -1
  499. package/dist/client/chunks/chart-config-line-Db3jDsWc.js.map +0 -1
  500. package/dist/client/chunks/chart-config-pie-DD4SmRTF.js.map +0 -1
  501. package/dist/client/chunks/chart-config-radar-CC2XAaGr.js.map +0 -1
  502. package/dist/client/chunks/chart-config-radial-bar-DmxKx1R0.js.map +0 -1
  503. package/dist/client/chunks/chart-config-tree-map-BI-oQStO.js.map +0 -1
  504. package/dist/client/chunks/chart-config-waterfall-DSnyixbI.js.map +0 -1
  505. package/dist/client/chunks/chart-data-table-Cm5jrpaw.js.map +0 -1
  506. package/dist/client/chunks/chart-funnel-Eke8IPtG.js.map +0 -1
  507. package/dist/client/chunks/chart-gauge-DeRZNsyl.js +0 -424
  508. package/dist/client/chunks/chart-gauge-DeRZNsyl.js.map +0 -1
  509. package/dist/client/chunks/chart-heat-map-C86thSJ4.js +0 -231
  510. package/dist/client/chunks/chart-heat-map-C86thSJ4.js.map +0 -1
  511. package/dist/client/chunks/chart-kpi-delta-CxOYD2f1.js +0 -343
  512. package/dist/client/chunks/chart-kpi-delta-CxOYD2f1.js.map +0 -1
  513. package/dist/client/chunks/chart-kpi-number-C6gWz-x4.js +0 -322
  514. package/dist/client/chunks/chart-kpi-number-C6gWz-x4.js.map +0 -1
  515. package/dist/client/chunks/chart-kpi-text-dDONrhS-.js +0 -149
  516. package/dist/client/chunks/chart-kpi-text-dDONrhS-.js.map +0 -1
  517. package/dist/client/chunks/chart-line-r4iWevKZ.js +0 -433
  518. package/dist/client/chunks/chart-line-r4iWevKZ.js.map +0 -1
  519. package/dist/client/chunks/chart-markdown-BPW-EAm9.js.map +0 -1
  520. package/dist/client/chunks/chart-pie-yqH2YVEI.js +0 -172
  521. package/dist/client/chunks/chart-pie-yqH2YVEI.js.map +0 -1
  522. package/dist/client/chunks/chart-radar-B-_3v-rE.js +0 -154
  523. package/dist/client/chunks/chart-radar-B-_3v-rE.js.map +0 -1
  524. package/dist/client/chunks/chart-radial-bar-C0EgzfAF.js +0 -148
  525. package/dist/client/chunks/chart-radial-bar-C0EgzfAF.js.map +0 -1
  526. package/dist/client/chunks/chart-scatter-DZPirzwX.js +0 -255
  527. package/dist/client/chunks/chart-scatter-DZPirzwX.js.map +0 -1
  528. package/dist/client/chunks/chart-tree-map-Bi4axCvh.js +0 -298
  529. package/dist/client/chunks/chart-tree-map-Bi4axCvh.js.map +0 -1
  530. package/dist/client/chunks/useDirtyStateTracking-B5wCDJSj.js.map +0 -1
  531. package/dist/server/google-DUlXeeDA.cjs +0 -2
  532. package/dist/server/openai-6wrBvAnv.cjs +0 -1
  533. package/dist/server/openai-BDwb2u7y.cjs +0 -17
  534. /package/dist/adapters/{express → adapters/express}/index.d.ts +0 -0
  535. /package/dist/adapters/{fastify → adapters/fastify}/index.d.ts +0 -0
  536. /package/dist/adapters/{hono → adapters/hono}/index.d.ts +0 -0
  537. /package/dist/adapters/{locale.d.ts → adapters/locale.d.ts} +0 -0
  538. /package/dist/adapters/{mcp-tools.d.ts → adapters/mcp-tools.d.ts} +0 -0
  539. /package/dist/adapters/{mcp-transport.d.ts → adapters/mcp-transport.d.ts} +0 -0
  540. /package/dist/adapters/{nextjs → adapters/nextjs}/index.d.ts +0 -0
  541. /package/dist/adapters/{types.d.ts → adapters/types.d.ts} +0 -0
@@ -1,35 +1,42 @@
1
- import { C as e, S as t, _ as n, d as r, g as i, p as a, v as o, y as s } from "./utils-DosuoabY.js";
1
+ import { O as e, _ as t, g as n, h as r, m as i, p as a, v as o, x as s } from "./utils-BPWZsX7k.js";
2
2
  //#region src/server/agent/system-prompt.ts
3
- function c(e) {
4
- if (e.length === 0) return "No cubes are currently available.";
5
- let t = ["## Available Cubes", ""];
6
- for (let n of e) {
7
- if (t.push(`### ${n.name}`), n.description && t.push(n.description), n.measures && n.measures.length > 0) {
8
- t.push(""), t.push("**Measures:**");
9
- for (let e of n.measures) {
10
- let r = e.description ? ` - ${e.description}` : "";
11
- t.push(`- \`${n.name}.${e.name}\` (${e.type})${r}`);
12
- }
13
- }
14
- if (n.dimensions && n.dimensions.length > 0) {
15
- t.push(""), t.push("**Dimensions:**");
16
- for (let e of n.dimensions) {
17
- let r = e.description ? ` - ${e.description}` : "";
18
- t.push(`- \`${n.name}.${e.name}\` (${e.type})${r}`);
19
- }
3
+ function c(e, t) {
4
+ if (!(!t.measures || t.measures.length === 0)) {
5
+ e.push(""), e.push("**Measures:**");
6
+ for (let n of t.measures) {
7
+ let r = n.description ? ` - ${n.description}` : "";
8
+ e.push(`- \`${t.name}.${n.name}\` (${n.type})${r}`);
20
9
  }
21
- if (n.relationships && n.relationships.length > 0) {
22
- t.push(""), t.push("**Joins:**");
23
- for (let e of n.relationships) t.push(`- → \`${e.targetCube}\` (${e.relationship})`);
10
+ }
11
+ }
12
+ function l(e, t) {
13
+ if (!(!t.dimensions || t.dimensions.length === 0)) {
14
+ e.push(""), e.push("**Dimensions:**");
15
+ for (let n of t.dimensions) {
16
+ let r = n.description ? ` - ${n.description}` : "";
17
+ e.push(`- \`${t.name}.${n.name}\` (${n.type})${r}`);
24
18
  }
25
- n.meta?.eventStream && (t.push(""), t.push("**Event Stream:** Yes (supports funnel, flow, retention queries)"), n.meta.eventStream.bindingKey && t.push(`- Binding key: \`${n.name}.${n.meta.eventStream.bindingKey}\``), n.meta.eventStream.timeDimension && t.push(`- Time dimension: \`${n.name}.${n.meta.eventStream.timeDimension}\``)), t.push("");
26
19
  }
20
+ }
21
+ function u(e, t) {
22
+ if (!(!t.relationships || t.relationships.length === 0)) {
23
+ e.push(""), e.push("**Joins:**");
24
+ for (let n of t.relationships) e.push(`- → \`${n.targetCube}\` (${n.relationship})`);
25
+ }
26
+ }
27
+ function d(e, t) {
28
+ t.meta?.eventStream && (e.push(""), e.push("**Event Stream:** Yes (supports funnel, flow, retention queries)"), t.meta.eventStream.bindingKey && e.push(`- Binding key: \`${t.name}.${t.meta.eventStream.bindingKey}\``), t.meta.eventStream.timeDimension && e.push(`- Time dimension: \`${t.name}.${t.meta.eventStream.timeDimension}\``));
29
+ }
30
+ function f(e) {
31
+ if (e.length === 0) return "No cubes are currently available.";
32
+ let t = ["## Available Cubes", ""];
33
+ for (let n of e) t.push(`### ${n.name}`), n.description && t.push(n.description), c(t, n), l(t, n), u(t, n), d(t, n), t.push("");
27
34
  return t.join("\n");
28
35
  }
29
- function l(e) {
36
+ function p(e) {
30
37
  return e.messages.map((e) => e.content.text).join("\n\n");
31
38
  }
32
- function u(e) {
39
+ function m(e) {
33
40
  return [
34
41
  "# Drizzle Cube Analytics Agent",
35
42
  "",
@@ -170,15 +177,15 @@ function u(e) {
170
177
  "",
171
178
  "---",
172
179
  "",
173
- l(o),
180
+ p(t),
174
181
  "",
175
182
  "---",
176
183
  "",
177
- l(s),
184
+ p(o),
178
185
  "",
179
186
  "---",
180
187
  "",
181
- l(n),
188
+ p(n),
182
189
  "",
183
190
  "---",
184
191
  "",
@@ -215,6 +222,7 @@ function u(e) {
215
222
  "- Add dimension filters for key fields used across portlets (e.g., department, status, region)",
216
223
  "- Use human-readable labels (e.g., \"Department\" not \"Employees.departmentName\")",
217
224
  "- Map filters to portlets using `dashboardFilterMapping` — list the filter IDs that apply",
225
+ "- To apply a filter to a different field for one portlet, use `{ filterId, member }` instead of a plain ID (e.g. remap a Customer filter to `Invoices.customerId`); the target field must be join-reachable from the portlet query",
218
226
  "- When promoting a hardcoded filter to a dashboard filter, REMOVE that filter from the portlet query",
219
227
  "",
220
228
  "### Analysis Types",
@@ -232,24 +240,89 @@ function u(e) {
232
240
  "",
233
241
  "---",
234
242
  "",
235
- c(e)
243
+ f(e)
236
244
  ].join("\n");
237
245
  }
238
246
  //#endregion
247
+ //#region src/client/charts/chartConfigHelpers.ts
248
+ function h({ measureCount: e, dimensionCount: t }) {
249
+ return e < 1 ? {
250
+ available: !1,
251
+ reason: "chart.availability.requiresMeasure"
252
+ } : t < 1 ? {
253
+ available: !1,
254
+ reason: "chart.availability.requiresDimension"
255
+ } : { available: !0 };
256
+ }
257
+ function g({ measureCount: e }) {
258
+ return e < 1 ? {
259
+ available: !1,
260
+ reason: "chart.availability.requiresMeasure"
261
+ } : { available: !0 };
262
+ }
263
+ var _ = {
264
+ key: "target",
265
+ label: "chart.option.target.label",
266
+ type: "string",
267
+ placeholder: "e.g., 100 or 50,75 for spread",
268
+ description: "chart.option.target.description"
269
+ }, v = {
270
+ key: "connectNulls",
271
+ label: "chart.option.connectNulls.label",
272
+ type: "boolean",
273
+ defaultValue: !1,
274
+ description: "chart.option.connectNulls.description"
275
+ }, y = {
276
+ key: "leftYAxisFormat",
277
+ label: "chart.option.leftYAxisFormat.label",
278
+ type: "axisFormat",
279
+ description: "chart.option.leftYAxisFormat.description"
280
+ }, b = {
281
+ key: "rightYAxisFormat",
282
+ label: "chart.option.rightYAxisFormat.label",
283
+ type: "axisFormat",
284
+ description: "chart.option.rightYAxisFormat.description"
285
+ };
286
+ function x(e = "chart.option.valueFormat.description") {
287
+ return {
288
+ key: "leftYAxisFormat",
289
+ label: "chart.option.valueFormat.label",
290
+ type: "axisFormat",
291
+ description: e
292
+ };
293
+ }
294
+ function S(e) {
295
+ return {
296
+ key: "stackType",
297
+ label: "chart.option.stacking.label",
298
+ type: "select",
299
+ defaultValue: "none",
300
+ options: [
301
+ {
302
+ value: "none",
303
+ label: "chart.option.accentBorder.none"
304
+ },
305
+ {
306
+ value: "normal",
307
+ label: "chart.option.stacking.stacked"
308
+ },
309
+ {
310
+ value: "percent",
311
+ label: "chart.option.stacking.percent"
312
+ }
313
+ ],
314
+ description: e
315
+ };
316
+ }
317
+ //#endregion
239
318
  //#region src/client/charts/chartConfigRegistry.ts
240
- var d = {
319
+ var C = {
241
320
  bar: {
242
321
  label: "chart.bar.label",
243
322
  description: "chart.bar.description",
244
323
  useCase: "chart.bar.useCase",
245
324
  clickableElements: { bar: !0 },
246
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
247
- available: !1,
248
- reason: "chart.availability.requiresMeasure"
249
- } : t < 1 ? {
250
- available: !1,
251
- reason: "chart.availability.requiresDimension"
252
- } : { available: !0 },
325
+ isAvailable: h,
253
326
  dropZones: [
254
327
  {
255
328
  key: "xAxis",
@@ -285,46 +358,10 @@ var d = {
285
358
  "hideHeader"
286
359
  ],
287
360
  displayOptionsConfig: [
288
- {
289
- key: "stackType",
290
- label: "chart.option.stacking.label",
291
- type: "select",
292
- defaultValue: "none",
293
- options: [
294
- {
295
- value: "none",
296
- label: "chart.option.accentBorder.none"
297
- },
298
- {
299
- value: "normal",
300
- label: "chart.option.stacking.stacked"
301
- },
302
- {
303
- value: "percent",
304
- label: "chart.option.stacking.percent"
305
- }
306
- ],
307
- description: "chart.configText.how_to_stack_multiple_bar_series"
308
- },
309
- {
310
- key: "target",
311
- label: "chart.option.target.label",
312
- type: "string",
313
- placeholder: "e.g., 100 or 50,75 for spread",
314
- description: "chart.option.target.description"
315
- },
316
- {
317
- key: "leftYAxisFormat",
318
- label: "chart.option.leftYAxisFormat.label",
319
- type: "axisFormat",
320
- description: "chart.option.leftYAxisFormat.description"
321
- },
322
- {
323
- key: "rightYAxisFormat",
324
- label: "chart.option.rightYAxisFormat.label",
325
- type: "axisFormat",
326
- description: "chart.option.rightYAxisFormat.description"
327
- }
361
+ S("chart.configText.how_to_stack_multiple_bar_series"),
362
+ _,
363
+ y,
364
+ b
328
365
  ]
329
366
  },
330
367
  line: {
@@ -332,13 +369,7 @@ var d = {
332
369
  description: "chart.line.description",
333
370
  useCase: "chart.line.useCase",
334
371
  clickableElements: { point: !0 },
335
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
336
- available: !1,
337
- reason: "chart.availability.requiresMeasure"
338
- } : t < 1 ? {
339
- available: !1,
340
- reason: "chart.availability.requiresDimension"
341
- } : { available: !0 },
372
+ isAvailable: h,
342
373
  dropZones: [
343
374
  {
344
375
  key: "xAxis",
@@ -374,20 +405,8 @@ var d = {
374
405
  "hideHeader"
375
406
  ],
376
407
  displayOptionsConfig: [
377
- {
378
- key: "connectNulls",
379
- label: "chart.option.connectNulls.label",
380
- type: "boolean",
381
- defaultValue: !1,
382
- description: "chart.option.connectNulls.description"
383
- },
384
- {
385
- key: "target",
386
- label: "chart.option.target.label",
387
- type: "string",
388
- placeholder: "e.g., 100 or 50,75 for spread",
389
- description: "chart.option.target.description"
390
- },
408
+ v,
409
+ _,
391
410
  {
392
411
  key: "priorPeriodStyle",
393
412
  label: "chart.option.priorPeriodStyle.label",
@@ -419,31 +438,15 @@ var d = {
419
438
  step: .1,
420
439
  description: "chart.option.priorPeriodOpacity.description"
421
440
  },
422
- {
423
- key: "leftYAxisFormat",
424
- label: "chart.option.leftYAxisFormat.label",
425
- type: "axisFormat",
426
- description: "chart.option.leftYAxisFormat.description"
427
- },
428
- {
429
- key: "rightYAxisFormat",
430
- label: "chart.option.rightYAxisFormat.label",
431
- type: "axisFormat",
432
- description: "chart.option.rightYAxisFormat.description"
433
- }
441
+ y,
442
+ b
434
443
  ]
435
444
  },
436
445
  area: {
437
446
  label: "chart.area.label",
438
447
  description: "chart.area.description",
439
448
  useCase: "chart.area.useCase",
440
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
441
- available: !1,
442
- reason: "chart.availability.requiresMeasure"
443
- } : t < 1 ? {
444
- available: !1,
445
- reason: "chart.availability.requiresDimension"
446
- } : { available: !0 },
449
+ isAvailable: h,
447
450
  dropZones: [
448
451
  {
449
452
  key: "xAxis",
@@ -479,53 +482,11 @@ var d = {
479
482
  "hideHeader"
480
483
  ],
481
484
  displayOptionsConfig: [
482
- {
483
- key: "stackType",
484
- label: "chart.option.stacking.label",
485
- type: "select",
486
- defaultValue: "none",
487
- options: [
488
- {
489
- value: "none",
490
- label: "chart.option.accentBorder.none"
491
- },
492
- {
493
- value: "normal",
494
- label: "chart.option.stacking.stacked"
495
- },
496
- {
497
- value: "percent",
498
- label: "chart.option.stacking.percent"
499
- }
500
- ],
501
- description: "chart.configText.how_to_stack_multiple_area_series"
502
- },
503
- {
504
- key: "connectNulls",
505
- label: "chart.option.connectNulls.label",
506
- type: "boolean",
507
- defaultValue: !1,
508
- description: "chart.option.connectNulls.description"
509
- },
510
- {
511
- key: "target",
512
- label: "chart.option.target.label",
513
- type: "string",
514
- placeholder: "e.g., 100 or 50,75 for spread",
515
- description: "chart.option.target.description"
516
- },
517
- {
518
- key: "leftYAxisFormat",
519
- label: "chart.option.leftYAxisFormat.label",
520
- type: "axisFormat",
521
- description: "chart.option.leftYAxisFormat.description"
522
- },
523
- {
524
- key: "rightYAxisFormat",
525
- label: "chart.option.rightYAxisFormat.label",
526
- type: "axisFormat",
527
- description: "chart.option.rightYAxisFormat.description"
528
- }
485
+ S("chart.configText.how_to_stack_multiple_area_series"),
486
+ v,
487
+ _,
488
+ y,
489
+ b
529
490
  ]
530
491
  },
531
492
  pie: {
@@ -533,13 +494,7 @@ var d = {
533
494
  description: "chart.pie.description",
534
495
  useCase: "chart.pie.useCase",
535
496
  clickableElements: { slice: !0 },
536
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
537
- available: !1,
538
- reason: "chart.availability.requiresMeasure"
539
- } : t < 1 ? {
540
- available: !1,
541
- reason: "chart.availability.requiresDimension"
542
- } : { available: !0 },
497
+ isAvailable: h,
543
498
  dropZones: [{
544
499
  key: "xAxis",
545
500
  label: "chart.configText.categories",
@@ -590,12 +545,7 @@ var d = {
590
545
  label: "chart.configText.80_percent"
591
546
  }
592
547
  ]
593
- }, {
594
- key: "leftYAxisFormat",
595
- label: "chart.option.valueFormat.label",
596
- type: "axisFormat",
597
- description: "chart.option.valueFormat.description"
598
- }]
548
+ }, x()]
599
549
  },
600
550
  scatter: {
601
551
  label: "chart.scatter.label",
@@ -746,13 +696,7 @@ var d = {
746
696
  label: "chart.radar.label",
747
697
  description: "chart.radar.description",
748
698
  useCase: "chart.radar.useCase",
749
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
750
- available: !1,
751
- reason: "chart.availability.requiresMeasure"
752
- } : t < 1 ? {
753
- available: !1,
754
- reason: "chart.availability.requiresDimension"
755
- } : { available: !0 },
699
+ isAvailable: h,
756
700
  dropZones: [
757
701
  {
758
702
  key: "xAxis",
@@ -785,24 +729,13 @@ var d = {
785
729
  "showTooltip",
786
730
  "hideHeader"
787
731
  ],
788
- displayOptionsConfig: [{
789
- key: "leftYAxisFormat",
790
- label: "chart.option.valueFormat.label",
791
- type: "axisFormat",
792
- description: "chart.option.valueFormat.description"
793
- }]
732
+ displayOptionsConfig: [x()]
794
733
  },
795
734
  radialBar: {
796
735
  label: "chart.radialBar.label",
797
736
  description: "chart.radialBar.description",
798
737
  useCase: "chart.radialBar.useCase",
799
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
800
- available: !1,
801
- reason: "chart.availability.requiresMeasure"
802
- } : t < 1 ? {
803
- available: !1,
804
- reason: "chart.availability.requiresDimension"
805
- } : { available: !0 },
738
+ isAvailable: h,
806
739
  dropZones: [{
807
740
  key: "xAxis",
808
741
  label: "chart.configText.categories",
@@ -824,24 +757,13 @@ var d = {
824
757
  "showTooltip",
825
758
  "hideHeader"
826
759
  ],
827
- displayOptionsConfig: [{
828
- key: "leftYAxisFormat",
829
- label: "chart.option.valueFormat.label",
830
- type: "axisFormat",
831
- description: "chart.option.valueFormat.description"
832
- }]
760
+ displayOptionsConfig: [x()]
833
761
  },
834
762
  treemap: {
835
763
  label: "chart.treemap.label",
836
764
  description: "chart.treemap.description",
837
765
  useCase: "chart.treemap.useCase",
838
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
839
- available: !1,
840
- reason: "chart.availability.requiresMeasure"
841
- } : t < 1 ? {
842
- available: !1,
843
- reason: "chart.availability.requiresDimension"
844
- } : { available: !0 },
766
+ isAvailable: h,
845
767
  dropZones: [
846
768
  {
847
769
  key: "xAxis",
@@ -875,12 +797,7 @@ var d = {
875
797
  "showTooltip",
876
798
  "hideHeader"
877
799
  ],
878
- displayOptionsConfig: [{
879
- key: "leftYAxisFormat",
880
- label: "chart.option.valueFormat.label",
881
- type: "axisFormat",
882
- description: "chart.configText.number_formatting_for_size_values"
883
- }],
800
+ displayOptionsConfig: [x("chart.configText.number_formatting_for_size_values")],
884
801
  clickableElements: { cell: !0 }
885
802
  },
886
803
  table: {
@@ -963,10 +880,7 @@ var d = {
963
880
  label: "chart.kpiNumber.label",
964
881
  description: "chart.kpiNumber.description",
965
882
  useCase: "chart.kpiNumber.useCase",
966
- isAvailable: ({ measureCount: e }) => e < 1 ? {
967
- available: !1,
968
- reason: "chart.availability.requiresMeasure"
969
- } : { available: !0 },
883
+ isAvailable: g,
970
884
  dropZones: [{
971
885
  key: "yAxis",
972
886
  label: "chart.configText.value",
@@ -1036,13 +950,7 @@ var d = {
1036
950
  label: "chart.kpiDelta.label",
1037
951
  description: "chart.kpiDelta.description",
1038
952
  useCase: "chart.kpiDelta.useCase",
1039
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
1040
- available: !1,
1041
- reason: "chart.availability.requiresMeasure"
1042
- } : t < 1 ? {
1043
- available: !1,
1044
- reason: "chart.availability.requiresDimension"
1045
- } : { available: !0 },
953
+ isAvailable: h,
1046
954
  dropZones: [{
1047
955
  key: "yAxis",
1048
956
  label: "chart.configText.value",
@@ -1131,10 +1039,7 @@ var d = {
1131
1039
  label: "chart.kpiText.label",
1132
1040
  description: "chart.kpiText.description",
1133
1041
  useCase: "chart.kpiText.useCase",
1134
- isAvailable: ({ measureCount: e }) => e < 1 ? {
1135
- available: !1,
1136
- reason: "chart.availability.requiresMeasure"
1137
- } : { available: !0 },
1042
+ isAvailable: g,
1138
1043
  dropZones: [{
1139
1044
  key: "yAxis",
1140
1045
  label: "chart.configText.value",
@@ -1634,13 +1539,7 @@ var d = {
1634
1539
  label: "chart.boxPlot.label",
1635
1540
  description: "chart.boxPlot.description",
1636
1541
  useCase: "chart.boxPlot.useCase",
1637
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
1638
- available: !1,
1639
- reason: "chart.availability.requiresMeasure"
1640
- } : t < 1 ? {
1641
- available: !1,
1642
- reason: "chart.availability.requiresDimension"
1643
- } : { available: !0 },
1542
+ isAvailable: h,
1644
1543
  displayOptions: ["hideHeader"],
1645
1544
  dropZones: [{
1646
1545
  key: "xAxis",
@@ -1671,13 +1570,7 @@ var d = {
1671
1570
  description: "chart.waterfall.description",
1672
1571
  useCase: "chart.waterfall.useCase",
1673
1572
  clickableElements: { bar: !0 },
1674
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
1675
- available: !1,
1676
- reason: "chart.availability.requiresMeasure"
1677
- } : t < 1 ? {
1678
- available: !1,
1679
- reason: "chart.availability.requiresDimension"
1680
- } : { available: !0 },
1573
+ isAvailable: h,
1681
1574
  displayOptions: ["showTooltip", "hideHeader"],
1682
1575
  dropZones: [{
1683
1576
  key: "xAxis",
@@ -1885,10 +1778,7 @@ var d = {
1885
1778
  useCase: "chart.gauge.useCase",
1886
1779
  clickableElements: {},
1887
1780
  displayOptions: ["hideHeader"],
1888
- isAvailable: ({ measureCount: e }) => e < 1 ? {
1889
- available: !1,
1890
- reason: "chart.availability.requiresMeasure"
1891
- } : { available: !0 },
1781
+ isAvailable: g,
1892
1782
  dropZones: [{
1893
1783
  key: "yAxis",
1894
1784
  label: "chart.configText.value_measure",
@@ -1944,79 +1834,83 @@ var d = {
1944
1834
  };
1945
1835
  //#endregion
1946
1836
  //#region src/server/agent/chart-validation.ts
1947
- function f(t, n, r) {
1948
- let i = d[t];
1949
- if (!i || i.skipQuery) return {
1837
+ function w(e) {
1838
+ return Array.isArray(e) ? e.length > 0 : !!e;
1839
+ }
1840
+ function T(t, n, r, i) {
1841
+ for (let a of t.dropZones) {
1842
+ if (!a.mandatory || w(r?.[a.key])) continue;
1843
+ let t = a.acceptTypes?.join("/") ?? "fields";
1844
+ i.push(e("server.validation.chart.dropZoneRequired", {
1845
+ key: a.key,
1846
+ chartType: n,
1847
+ label: a.label,
1848
+ acceptDesc: t
1849
+ }));
1850
+ }
1851
+ }
1852
+ function E(t, n, r) {
1853
+ if (w(t?.xAxis)) return;
1854
+ let i = n.dimensions ?? [], a = n.timeDimensions ?? [], o = i.length > 0 || a.length > 0;
1855
+ r.push(e(o ? "server.validation.chart.barXAxisRequired" : "server.validation.chart.barNeedsDimension"));
1856
+ }
1857
+ function D(e) {
1858
+ return Array.isArray(e) ? e : [e];
1859
+ }
1860
+ function O(t, n) {
1861
+ if (!t?.xAxis || !t?.series) return;
1862
+ let r = new Set(D(t.xAxis)), i = D(t.series).filter((e) => r.has(e));
1863
+ i.length > 0 && n.push(e("server.validation.chart.seriesDuplicatesXAxis", { duplicates: i.join(", ") }));
1864
+ }
1865
+ function k(e, t, n) {
1866
+ let r = C[e];
1867
+ if (!r || r.skipQuery) return {
1950
1868
  isValid: !0,
1951
1869
  errors: []
1952
1870
  };
1953
- let a = [];
1954
- for (let r of i.dropZones) {
1955
- if (!r.mandatory) continue;
1956
- let i = n?.[r.key];
1957
- if (!(Array.isArray(i) ? i.length > 0 : i)) {
1958
- let n = r.acceptTypes?.join("/") ?? "fields";
1959
- a.push(e("server.validation.chart.dropZoneRequired", {
1960
- key: r.key,
1961
- chartType: t,
1962
- label: r.label,
1963
- acceptDesc: n
1964
- }));
1965
- }
1966
- }
1967
- if (t === "bar") {
1968
- let t = n?.xAxis;
1969
- if (!(Array.isArray(t) ? t.length > 0 : t)) {
1970
- let t = r.dimensions ?? [], n = r.timeDimensions ?? [];
1971
- t.length > 0 || n.length > 0 ? a.push(e("server.validation.chart.barXAxisRequired")) : a.push(e("server.validation.chart.barNeedsDimension"));
1972
- }
1871
+ let i = [];
1872
+ return T(r, e, t, i), e === "bar" && E(t, n, i), O(t, i), {
1873
+ isValid: i.length === 0,
1874
+ errors: i
1875
+ };
1876
+ }
1877
+ function A(e, t, n, r) {
1878
+ if (!(e.acceptTypes ?? []).includes("measure")) return;
1879
+ let i = /* @__PURE__ */ new Set();
1880
+ for (let r of t.dropZones) {
1881
+ if (r.key === e.key) continue;
1882
+ let t = n[r.key];
1883
+ Array.isArray(t) ? t.forEach((e) => i.add(e)) : typeof t == "string" && i.add(t);
1973
1884
  }
1974
- if (n?.xAxis && n?.series) {
1975
- let t = new Set(Array.isArray(n.xAxis) ? n.xAxis : [n.xAxis]), r = (Array.isArray(n.series) ? n.series : [n.series]).filter((e) => t.has(e));
1976
- r.length > 0 && a.push(e("server.validation.chart.seriesDuplicatesXAxis", { duplicates: r.join(", ") }));
1885
+ let a = r.filter((e) => !i.has(e));
1886
+ a.length > 0 && (n[e.key] = a[0]);
1887
+ }
1888
+ function j(e, t, n) {
1889
+ let r = e.acceptTypes ?? [], i = [];
1890
+ if (r.includes("dimension") && i.push(...n.dimensions), r.includes("timeDimension") && i.push(...n.timeDimFields), r.includes("measure") && i.push(...n.measures), i.length === 0) return;
1891
+ let a = i;
1892
+ if (e.key === "series") {
1893
+ let e = new Set(Array.isArray(t.xAxis) ? t.xAxis : t.xAxis ? [t.xAxis] : []);
1894
+ if (a = i.filter((t) => !e.has(t)), a.length === 0) return;
1977
1895
  }
1978
- return {
1979
- isValid: a.length === 0,
1980
- errors: a
1981
- };
1896
+ let o = e.maxItems ?? Infinity, s = a.slice(0, o);
1897
+ s.length > 0 && (t[e.key] = s);
1982
1898
  }
1983
- function p(e, t, n) {
1984
- let r = d[e];
1899
+ function M(e, t, n) {
1900
+ let r = C[e];
1985
1901
  if (!r) return t ?? {};
1986
- let i = { ...t }, a = n.measures ?? [], o = n.dimensions ?? [], s = (n.timeDimensions ?? []).map((e) => e.dimension);
1987
- for (let e of r.dropZones) {
1988
- let t = i[e.key];
1989
- if (Array.isArray(t) ? t.length > 0 : t) continue;
1990
- let n = e.acceptTypes ?? [];
1991
- if (e.key === "sizeField" || e.key === "colorField") {
1992
- if (n.includes("measure")) {
1993
- let t = /* @__PURE__ */ new Set();
1994
- for (let n of r.dropZones) {
1995
- if (n.key === e.key) continue;
1996
- let r = i[n.key];
1997
- Array.isArray(r) ? r.forEach((e) => t.add(e)) : typeof r == "string" && t.add(r);
1998
- }
1999
- let n = a.filter((e) => !t.has(e));
2000
- n.length > 0 && (i[e.key] = n[0]);
2001
- }
2002
- continue;
2003
- }
2004
- let c = [];
2005
- if (n.includes("dimension") && c.push(...o), n.includes("timeDimension") && c.push(...s), n.includes("measure") && c.push(...a), c.length === 0) continue;
2006
- let l = c;
2007
- if (e.key === "series") {
2008
- let e = new Set(Array.isArray(i.xAxis) ? i.xAxis : i.xAxis ? [i.xAxis] : []);
2009
- if (l = c.filter((t) => !e.has(t)), l.length === 0) continue;
2010
- }
2011
- let u = e.maxItems ?? Infinity, d = l.slice(0, u);
2012
- d.length > 0 && (i[e.key] = d);
2013
- }
1902
+ let i = { ...t }, a = n.timeDimensions ?? [], o = {
1903
+ measures: n.measures ?? [],
1904
+ dimensions: n.dimensions ?? [],
1905
+ timeDimFields: a.map((e) => e.dimension)
1906
+ };
1907
+ for (let e of r.dropZones) w(i[e.key]) || (e.key === "sizeField" || e.key === "colorField" ? A(e, r, i, o.measures) : j(e, i, o));
2014
1908
  return i;
2015
1909
  }
2016
- function m(e) {
1910
+ function N(e) {
2017
1911
  let t = ["\nChart config requirements by type:"];
2018
1912
  for (let n of e) {
2019
- let e = d[n];
1913
+ let e = C[n];
2020
1914
  if (!e) continue;
2021
1915
  let r = [e.description ?? "", e.useCase ?? ""].filter(Boolean).join(". "), i = r ? ` — ${r}.` : "", a = e.dropZones.filter((e) => e.mandatory);
2022
1916
  if (a.length === 0 && !e.skipQuery) {
@@ -2037,7 +1931,7 @@ function m(e) {
2037
1931
  }
2038
1932
  //#endregion
2039
1933
  //#region src/server/agent/tools.ts
2040
- var h = [
1934
+ var P = [
2041
1935
  "bar",
2042
1936
  "line",
2043
1937
  "area",
@@ -2057,7 +1951,7 @@ var h = [
2057
1951
  "boxPlot",
2058
1952
  "markdown"
2059
1953
  ];
2060
- function g() {
1954
+ function F() {
2061
1955
  return [
2062
1956
  {
2063
1957
  name: "discover_cubes",
@@ -2097,12 +1991,12 @@ function g() {
2097
1991
  description: "Execute a semantic query and return data results. Supports standard queries (measures/dimensions) and analysis modes (funnel/flow/retention). Only provide ONE mode per call.",
2098
1992
  parameters: {
2099
1993
  type: "object",
2100
- properties: t
1994
+ properties: s
2101
1995
  }
2102
1996
  },
2103
1997
  {
2104
1998
  name: "add_portlet",
2105
- description: "Add a chart visualization to the notebook.\n" + m(h) + "\nThe query is validated before adding. The portlet fetches its own data.",
1999
+ description: "Add a chart visualization to the notebook.\n" + N(P) + "\nThe query is validated before adding. The portlet fetches its own data.",
2106
2000
  parameters: {
2107
2001
  type: "object",
2108
2002
  properties: {
@@ -2116,7 +2010,7 @@ function g() {
2116
2010
  },
2117
2011
  chartType: {
2118
2012
  type: "string",
2119
- enum: h,
2013
+ enum: P,
2120
2014
  description: "Chart type to render"
2121
2015
  },
2122
2016
  chartConfig: {
@@ -2212,7 +2106,7 @@ function g() {
2212
2106
  },
2213
2107
  chartType: {
2214
2108
  type: "string",
2215
- enum: h,
2109
+ enum: P,
2216
2110
  description: "Chart type. Use \"markdown\" for section headers."
2217
2111
  },
2218
2112
  query: {
@@ -2245,8 +2139,21 @@ function g() {
2245
2139
  },
2246
2140
  dashboardFilterMapping: {
2247
2141
  type: "array",
2248
- items: { type: "string" },
2249
- description: "Array of dashboard filter IDs that apply to this portlet"
2142
+ items: { anyOf: [{ type: "string" }, {
2143
+ type: "object",
2144
+ properties: {
2145
+ filterId: {
2146
+ type: "string",
2147
+ description: "Dashboard filter ID"
2148
+ },
2149
+ member: {
2150
+ type: "string",
2151
+ description: "Optional field to remap the filter to for this portlet (e.g. \"Invoices.customerId\")"
2152
+ }
2153
+ },
2154
+ required: ["filterId"]
2155
+ }] },
2156
+ description: "Dashboard filters that apply to this portlet: filter IDs, or { filterId, member } entries to remap a filter to a different field for this portlet"
2250
2157
  },
2251
2158
  analysisType: {
2252
2159
  type: "string",
@@ -2336,10 +2243,10 @@ function g() {
2336
2243
  }
2337
2244
  ];
2338
2245
  }
2339
- function _(e) {
2246
+ function I(e) {
2340
2247
  let { semanticLayer: t, securityContext: n } = e, o = /* @__PURE__ */ new Map();
2341
2248
  o.set("discover_cubes", async (e) => {
2342
- let n = { cubes: (await r(t, {
2249
+ let n = { cubes: (await a(t, {
2343
2250
  topic: e.topic,
2344
2251
  intent: e.intent,
2345
2252
  limit: e.limit,
@@ -2385,8 +2292,8 @@ function _(e) {
2385
2292
  if (n.length > 0) throw Error(`Invalid ${t}:\n${n.join("\n")}`);
2386
2293
  };
2387
2294
  r(e.measures, "measures"), r(e.dimensions, "dimensions");
2388
- let i;
2389
- i = e.funnel ? { funnel: e.funnel } : e.flow ? { flow: e.flow } : e.retention ? { retention: e.retention } : {
2295
+ let a;
2296
+ a = e.funnel ? { funnel: e.funnel } : e.flow ? { flow: e.flow } : e.retention ? { retention: e.retention } : {
2390
2297
  measures: e.measures,
2391
2298
  dimensions: e.dimensions,
2392
2299
  filters: e.filters,
@@ -2396,7 +2303,7 @@ function _(e) {
2396
2303
  offset: e.offset,
2397
2304
  ungrouped: e.ungrouped
2398
2305
  };
2399
- let o = await a(t, n, { query: i });
2306
+ let o = await i(t, n, { query: a });
2400
2307
  return { result: JSON.stringify({
2401
2308
  rowCount: o.data.length,
2402
2309
  data: o.data,
@@ -2423,27 +2330,27 @@ function _(e) {
2423
2330
  let n = {
2424
2331
  number: "kpiNumber",
2425
2332
  retention: "retentionHeatmap"
2426
- }[e.chartType] ?? e.chartType, r;
2333
+ }[e.chartType] ?? e.chartType, i;
2427
2334
  try {
2428
- r = JSON.parse(e.query);
2335
+ i = JSON.parse(e.query);
2429
2336
  } catch {
2430
2337
  return {
2431
2338
  result: "Invalid query: could not parse JSON string. Ensure `query` is a valid JSON string.",
2432
2339
  isError: !0
2433
2340
  };
2434
2341
  }
2435
- r = i(r);
2436
- let a = t.validateQuery(r);
2342
+ i = r(i);
2343
+ let a = t.validateQuery(i);
2437
2344
  if (!a.isValid) return {
2438
- result: `Invalid query — fix these errors and retry:\n${a.errors.join("\n")}\n\nAttempted query:\n${JSON.stringify(r, null, 2)}`,
2345
+ result: `Invalid query — fix these errors and retry:\n${a.errors.join("\n")}\n\nAttempted query:\n${JSON.stringify(i, null, 2)}`,
2439
2346
  isError: !0
2440
2347
  };
2441
- let o = !!(r.funnel || r.flow || r.retention), s;
2348
+ let o = !!(i.funnel || i.flow || i.retention), s;
2442
2349
  if (o) s = e.chartConfig ?? {};
2443
2350
  else {
2444
- let t = p(n, e.chartConfig, r), i = f(n, t, r);
2445
- if (!i.isValid) return {
2446
- result: `Chart config invalid — fix these errors and retry:\n${i.errors.join("\n")}`,
2351
+ let t = M(n, e.chartConfig, i), r = k(n, t, i);
2352
+ if (!r.isValid) return {
2353
+ result: `Chart config invalid — fix these errors and retry:\n${r.errors.join("\n")}`,
2447
2354
  isError: !0
2448
2355
  };
2449
2356
  s = t;
@@ -2483,27 +2390,27 @@ function _(e) {
2483
2390
  result: "Dashboard must contain at least one portlet.",
2484
2391
  isError: !0
2485
2392
  };
2486
- let r = [];
2393
+ let i = [];
2487
2394
  for (let e of n) {
2488
2395
  if (e.chartType === "markdown") continue;
2489
2396
  let n = e.query;
2490
2397
  if (!n) {
2491
- r.push(`Portlet "${e.title}": missing query`);
2398
+ i.push(`Portlet "${e.title}": missing query`);
2492
2399
  continue;
2493
2400
  }
2494
2401
  let a;
2495
2402
  try {
2496
2403
  a = JSON.parse(n);
2497
2404
  } catch {
2498
- r.push(`Portlet "${e.title}": invalid JSON query`);
2405
+ i.push(`Portlet "${e.title}": invalid JSON query`);
2499
2406
  continue;
2500
2407
  }
2501
- a = i(a);
2408
+ a = r(a);
2502
2409
  let o = t.validateQuery(a);
2503
- o.isValid || r.push(`Portlet "${e.title}": ${o.errors.join(", ")}`);
2410
+ o.isValid || i.push(`Portlet "${e.title}": ${o.errors.join(", ")}`);
2504
2411
  }
2505
- if (r.length > 0) return {
2506
- result: `Dashboard has invalid portlets — fix these errors and retry:\n${r.join("\n")}`,
2412
+ if (i.length > 0) return {
2413
+ result: `Dashboard has invalid portlets — fix these errors and retry:\n${i.join("\n")}`,
2507
2414
  isError: !0
2508
2415
  };
2509
2416
  let a = {
@@ -2560,298 +2467,328 @@ function _(e) {
2560
2467
  }
2561
2468
  //#endregion
2562
2469
  //#region src/server/agent/providers/factory.ts
2563
- async function v(e, t, n) {
2470
+ async function L(e, t, n) {
2564
2471
  switch (e) {
2565
2472
  case "anthropic": {
2566
2473
  let { AnthropicProvider: e } = await import("./anthropic-CZh4hB-m.js");
2567
2474
  return new e(t);
2568
2475
  }
2569
2476
  case "openai": {
2570
- let { OpenAIProvider: e } = await import("./openai-DiVskd89.js");
2477
+ let { OpenAIProvider: e } = await import("./openai-cDlFSTk6.js");
2571
2478
  return new e(t, n);
2572
2479
  }
2573
2480
  case "google": {
2574
- let { GoogleProvider: e } = await import("./google-CFYljAOF.js");
2481
+ let { GoogleProvider: e } = await import("./google-CvKM9yVM.js");
2575
2482
  return new e(t);
2576
2483
  }
2577
2484
  default: throw Error(`Unknown LLM provider: "${e}". Supported providers: anthropic, openai, google`);
2578
2485
  }
2579
2486
  }
2580
2487
  //#endregion
2488
+ //#region src/server/agent/handler-steps.ts
2489
+ function R(e, t) {
2490
+ if (Array.isArray(t)) for (let n of t) e.push(n);
2491
+ else e.push(t);
2492
+ }
2493
+ function z(e) {
2494
+ if (e) try {
2495
+ e();
2496
+ } catch {}
2497
+ }
2498
+ function B(e, t) {
2499
+ let n = [];
2500
+ if (!e || e.length === 0) return n;
2501
+ for (let r of e) {
2502
+ if (r.role === "user") {
2503
+ n.push({
2504
+ role: "user",
2505
+ content: r.content
2506
+ });
2507
+ continue;
2508
+ }
2509
+ if (r.role !== "assistant") continue;
2510
+ let e = [];
2511
+ if (r.content && e.push({
2512
+ type: "text",
2513
+ text: r.content
2514
+ }), r.toolCalls && r.toolCalls.length > 0) {
2515
+ for (let t of r.toolCalls) e.push({
2516
+ type: "tool_use",
2517
+ id: t.id,
2518
+ name: t.name,
2519
+ input: t.input || {}
2520
+ });
2521
+ n.push({
2522
+ role: "assistant",
2523
+ content: e
2524
+ });
2525
+ let i = r.toolCalls.map((e) => ({
2526
+ toolUseId: e.id,
2527
+ toolName: e.name,
2528
+ content: typeof e.result == "string" ? e.result : JSON.stringify(e.result ?? ""),
2529
+ isError: e.status === "error"
2530
+ }));
2531
+ R(n, t.formatToolResults(i));
2532
+ } else e.length > 0 && n.push({
2533
+ role: "assistant",
2534
+ content: r.content
2535
+ });
2536
+ }
2537
+ return n;
2538
+ }
2539
+ function V(e, t) {
2540
+ if (!(e?.type !== "tool_use" || !t)) try {
2541
+ e.input = JSON.parse(t);
2542
+ } catch {
2543
+ e.input = {};
2544
+ }
2545
+ }
2546
+ function H(e, t) {
2547
+ let n = e.contentBlocks[e.contentBlocks.length - 1];
2548
+ n && n.type === "text" ? n.text = (n.text || "") + t : e.contentBlocks.push({
2549
+ type: "text",
2550
+ text: t
2551
+ });
2552
+ }
2553
+ function U(e, t) {
2554
+ if (e.currentBlockIsToolUse && e.currentToolInputJson) {
2555
+ let t = e.contentBlocks[e.contentBlocks.length - 1];
2556
+ if (t?.type === "tool_use") try {
2557
+ t.input = JSON.parse(e.currentToolInputJson);
2558
+ } catch {}
2559
+ }
2560
+ e.contentBlocks.push({
2561
+ type: "tool_use",
2562
+ id: t.id,
2563
+ name: t.name,
2564
+ input: {},
2565
+ ...t.metadata ? { metadata: t.metadata } : {}
2566
+ }), e.currentToolInputJson = "", e.currentBlockIsToolUse = !0;
2567
+ }
2568
+ function W(e, t) {
2569
+ if (t.id && t.input) {
2570
+ let n = e.contentBlocks.find((e) => e.type === "tool_use" && e.id === t.id);
2571
+ n && (n.input = t.input);
2572
+ } else if (e.currentBlockIsToolUse) {
2573
+ let t = e.contentBlocks[e.contentBlocks.length - 1];
2574
+ t?.type === "tool_use" && e.currentToolInputJson && (V(t, e.currentToolInputJson), e.currentToolInputJson = ""), e.currentBlockIsToolUse = !1;
2575
+ }
2576
+ }
2577
+ async function* G(e, t) {
2578
+ let n = {
2579
+ contentBlocks: [],
2580
+ currentToolInputJson: "",
2581
+ currentBlockIsToolUse: !1,
2582
+ stopReason: ""
2583
+ };
2584
+ for await (let r of e.parseStreamEvents(t)) {
2585
+ let e = r;
2586
+ switch (e.type) {
2587
+ case "text_delta":
2588
+ H(n, e.text), yield {
2589
+ type: "text_delta",
2590
+ data: e.text
2591
+ };
2592
+ break;
2593
+ case "tool_use_start":
2594
+ U(n, e), yield {
2595
+ type: "tool_use_start",
2596
+ data: {
2597
+ id: e.id,
2598
+ name: e.name,
2599
+ input: void 0
2600
+ }
2601
+ };
2602
+ break;
2603
+ case "tool_input_delta":
2604
+ n.currentToolInputJson += e.json;
2605
+ break;
2606
+ case "tool_use_end":
2607
+ W(n, e);
2608
+ break;
2609
+ case "message_meta":
2610
+ e.inputTokens != null && (n.inputTokens = e.inputTokens), e.outputTokens != null && (n.outputTokens = e.outputTokens), e.stopReason && (n.stopReason = e.stopReason);
2611
+ break;
2612
+ }
2613
+ }
2614
+ return {
2615
+ contentBlocks: n.contentBlocks,
2616
+ stopReason: n.stopReason,
2617
+ inputTokens: n.inputTokens,
2618
+ outputTokens: n.outputTokens
2619
+ };
2620
+ }
2621
+ async function* K(e, t) {
2622
+ let { executor: n, observability: r, traceId: i, turn: a } = t, o = e.name, s = e.input || {}, c = e.id, l = n.get(o);
2623
+ if (!l) return yield {
2624
+ type: "tool_use_result",
2625
+ data: {
2626
+ id: c,
2627
+ name: o,
2628
+ result: `Unknown tool: ${o}`,
2629
+ isError: !0
2630
+ }
2631
+ }, {
2632
+ toolUseId: c,
2633
+ toolName: o,
2634
+ content: `Unknown tool: ${o}`,
2635
+ isError: !0
2636
+ };
2637
+ let u = Date.now();
2638
+ try {
2639
+ let e = await l(s);
2640
+ return e.sideEffect && (yield e.sideEffect), yield {
2641
+ type: "tool_use_result",
2642
+ data: {
2643
+ id: c,
2644
+ name: o,
2645
+ result: e.result,
2646
+ ...e.isError ? { isError: !0 } : {}
2647
+ }
2648
+ }, z(() => r?.onToolEnd?.({
2649
+ traceId: i,
2650
+ turn: a,
2651
+ toolName: o,
2652
+ toolUseId: c,
2653
+ isError: !!e.isError,
2654
+ durationMs: Date.now() - u
2655
+ })), {
2656
+ toolUseId: c,
2657
+ toolName: o,
2658
+ content: e.result,
2659
+ ...e.isError ? { isError: !0 } : {}
2660
+ };
2661
+ } catch (e) {
2662
+ let t = e instanceof Error ? e.message : "Tool execution failed";
2663
+ return yield {
2664
+ type: "tool_use_result",
2665
+ data: {
2666
+ id: c,
2667
+ name: o,
2668
+ result: t,
2669
+ isError: !0
2670
+ }
2671
+ }, z(() => r?.onToolEnd?.({
2672
+ traceId: i,
2673
+ turn: a,
2674
+ toolName: o,
2675
+ toolUseId: c,
2676
+ isError: !0,
2677
+ durationMs: Date.now() - u
2678
+ })), {
2679
+ toolUseId: c,
2680
+ toolName: o,
2681
+ content: t,
2682
+ isError: !0
2683
+ };
2684
+ }
2685
+ }
2686
+ async function* q(e, t) {
2687
+ let n = [];
2688
+ for (let r of e) {
2689
+ if (r.type !== "tool_use") continue;
2690
+ let e = yield* K(r, t);
2691
+ n.push(e);
2692
+ }
2693
+ return n;
2694
+ }
2695
+ //#endregion
2581
2696
  //#region src/server/agent/handler.ts
2582
- var y = {
2697
+ var J = {
2583
2698
  anthropic: "claude-sonnet-4-6",
2584
2699
  openai: "gpt-4.1-mini",
2585
2700
  google: "gemini-3-flash-preview"
2586
2701
  };
2587
- async function* b(t) {
2588
- let { message: n, history: r, semanticLayer: i, securityContext: a, agentConfig: o, apiKey: s } = t, c = t.sessionId || crypto.randomUUID(), l = o.observability, d = crypto.randomUUID(), f = Date.now(), p = t.providerOverride || o.provider || "anthropic", m = t.modelOverride || o.model || y[p] || "claude-sonnet-4-6", h = t.baseURLOverride || o.baseURL, b = o.maxTurns || 25, x = o.maxTokens || 4096, S;
2702
+ async function* Y(t) {
2703
+ let { message: n, history: r, semanticLayer: i, securityContext: a, agentConfig: o, apiKey: s } = t, c = t.sessionId || crypto.randomUUID(), l = o.observability, u = crypto.randomUUID(), d = Date.now(), f = t.providerOverride || o.provider || "anthropic", p = t.modelOverride || o.model || J[f] || "claude-sonnet-4-6", h = t.baseURLOverride || o.baseURL, g = o.maxTurns || 25, _ = o.maxTokens || 4096, v;
2589
2704
  try {
2590
- S = await v(p, s, { baseURL: h });
2705
+ v = await L(f, s, { baseURL: h });
2591
2706
  } catch (t) {
2592
- console.error("[agent] Failed to create %s provider: %s", String(p).replace(/\n|\r/g, ""), String(t instanceof Error ? t.message : t).replace(/\n|\r/g, "")), yield {
2707
+ console.error("[agent] Failed to create %s provider: %s", String(f).replace(/\n|\r/g, ""), String(t instanceof Error ? t.message : t).replace(/\n|\r/g, "")), yield {
2593
2708
  type: "error",
2594
2709
  data: { message: t instanceof Error ? t.message : e("server.errors.llmInitFailed") }
2595
2710
  };
2596
2711
  return;
2597
2712
  }
2598
- let C = g(), w = _({
2713
+ let y = F(), b = I({
2599
2714
  semanticLayer: i,
2600
2715
  securityContext: a
2601
- }), T = u(i.getMetadata());
2602
- t.systemContext && (T += `\n\n## User Context\n\n${t.systemContext}`);
2603
- try {
2604
- l?.onChatStart?.({
2605
- traceId: d,
2606
- sessionId: c,
2607
- message: n,
2608
- model: m,
2609
- historyLength: r?.length ?? 0
2610
- });
2611
- } catch {}
2612
- let E = [];
2613
- if (r && r.length > 0) {
2614
- for (let e of r) if (e.role === "user") E.push({
2615
- role: "user",
2616
- content: e.content
2617
- });
2618
- else if (e.role === "assistant") {
2619
- let t = [];
2620
- if (e.content && t.push({
2621
- type: "text",
2622
- text: e.content
2623
- }), e.toolCalls && e.toolCalls.length > 0) {
2624
- for (let n of e.toolCalls) t.push({
2625
- type: "tool_use",
2626
- id: n.id,
2627
- name: n.name,
2628
- input: n.input || {}
2629
- });
2630
- E.push({
2631
- role: "assistant",
2632
- content: t
2633
- });
2634
- let n = e.toolCalls.map((e) => ({
2635
- toolUseId: e.id,
2636
- toolName: e.name,
2637
- content: typeof e.result == "string" ? e.result : JSON.stringify(e.result ?? ""),
2638
- isError: e.status === "error"
2639
- })), r = S.formatToolResults(n);
2640
- if (Array.isArray(r)) for (let e of r) E.push(e);
2641
- else E.push(r);
2642
- } else t.length > 0 && E.push({
2643
- role: "assistant",
2644
- content: e.content
2645
- });
2646
- }
2647
- }
2648
- E.push({
2716
+ }), x = m(i.getMetadata());
2717
+ t.systemContext && (x += `\n\n## User Context\n\n${t.systemContext}`), z(() => l?.onChatStart?.({
2718
+ traceId: u,
2719
+ sessionId: c,
2720
+ message: n,
2721
+ model: p,
2722
+ historyLength: r?.length ?? 0
2723
+ }));
2724
+ let S = B(r, v);
2725
+ S.push({
2649
2726
  role: "user",
2650
2727
  content: n
2651
2728
  });
2652
- let D = 0;
2729
+ let C = 0;
2653
2730
  try {
2654
- for (let e = 0; e < b; e++) {
2655
- D = e + 1;
2656
- let t = await S.createStream({
2657
- model: m,
2658
- maxTokens: x,
2659
- system: T,
2660
- tools: C,
2661
- messages: E
2662
- }), n = [], r = "", i = "", a, o, s = Date.now(), c = !1;
2663
- for await (let e of S.parseStreamEvents(t)) {
2664
- let t = e;
2665
- switch (t.type) {
2666
- case "text_delta": {
2667
- let e = n[n.length - 1];
2668
- e && e.type === "text" ? e.text = (e.text || "") + t.text : n.push({
2669
- type: "text",
2670
- text: t.text
2671
- }), yield {
2672
- type: "text_delta",
2673
- data: t.text
2674
- };
2675
- break;
2676
- }
2677
- case "tool_use_start":
2678
- if (c && r) {
2679
- let e = n[n.length - 1];
2680
- if (e?.type === "tool_use") try {
2681
- e.input = JSON.parse(r);
2682
- } catch {}
2683
- }
2684
- n.push({
2685
- type: "tool_use",
2686
- id: t.id,
2687
- name: t.name,
2688
- input: {},
2689
- ...t.metadata ? { metadata: t.metadata } : {}
2690
- }), r = "", c = !0, yield {
2691
- type: "tool_use_start",
2692
- data: {
2693
- id: t.id,
2694
- name: t.name,
2695
- input: void 0
2696
- }
2697
- };
2698
- break;
2699
- case "tool_input_delta":
2700
- r += t.json;
2701
- break;
2702
- case "tool_use_end":
2703
- if (t.id && t.input) {
2704
- let e = n.find((e) => e.type === "tool_use" && e.id === t.id);
2705
- e && (e.input = t.input);
2706
- } else if (c) {
2707
- let e = n[n.length - 1];
2708
- if (e?.type === "tool_use" && r) {
2709
- try {
2710
- e.input = JSON.parse(r);
2711
- } catch {
2712
- e.input = {};
2713
- }
2714
- r = "";
2715
- }
2716
- c = !1;
2717
- }
2718
- break;
2719
- case "message_meta":
2720
- t.inputTokens != null && (a = t.inputTokens), t.outputTokens != null && (o = t.outputTokens), t.stopReason && (i = t.stopReason);
2721
- break;
2722
- }
2723
- }
2724
- try {
2725
- l?.onGenerationEnd?.({
2726
- traceId: d,
2727
- turn: e,
2728
- model: m,
2729
- stopReason: i,
2730
- inputTokens: a,
2731
- outputTokens: o,
2732
- durationMs: Date.now() - s,
2733
- input: E,
2734
- output: n
2735
- });
2736
- } catch {}
2737
- if (E.push({
2731
+ for (let e = 0; e < g; e++) {
2732
+ C = e + 1;
2733
+ let t = await v.createStream({
2734
+ model: p,
2735
+ maxTokens: _,
2736
+ system: x,
2737
+ tools: y,
2738
+ messages: S
2739
+ }), n = Date.now(), { contentBlocks: r, stopReason: i, inputTokens: a, outputTokens: o } = yield* G(v, t);
2740
+ if (z(() => l?.onGenerationEnd?.({
2741
+ traceId: u,
2742
+ turn: e,
2743
+ model: p,
2744
+ stopReason: i,
2745
+ inputTokens: a,
2746
+ outputTokens: o,
2747
+ durationMs: Date.now() - n,
2748
+ input: S,
2749
+ output: r
2750
+ })), S.push({
2738
2751
  role: "assistant",
2739
- content: n
2740
- }), !S.shouldContinue(i)) break;
2741
- let u = [];
2742
- for (let t of n) {
2743
- if (t.type !== "tool_use") continue;
2744
- let n = t.name, r = t.input || {}, i = t.id, a = w.get(n);
2745
- if (!a) {
2746
- u.push({
2747
- toolUseId: i,
2748
- toolName: n,
2749
- content: `Unknown tool: ${n}`,
2750
- isError: !0
2751
- }), yield {
2752
- type: "tool_use_result",
2753
- data: {
2754
- id: i,
2755
- name: n,
2756
- result: `Unknown tool: ${n}`,
2757
- isError: !0
2758
- }
2759
- };
2760
- continue;
2761
- }
2762
- let o = Date.now();
2763
- try {
2764
- let t = await a(r);
2765
- t.sideEffect && (yield t.sideEffect), u.push({
2766
- toolUseId: i,
2767
- toolName: n,
2768
- content: t.result,
2769
- ...t.isError ? { isError: !0 } : {}
2770
- }), yield {
2771
- type: "tool_use_result",
2772
- data: {
2773
- id: i,
2774
- name: n,
2775
- result: t.result,
2776
- ...t.isError ? { isError: !0 } : {}
2777
- }
2778
- };
2779
- try {
2780
- l?.onToolEnd?.({
2781
- traceId: d,
2782
- turn: e,
2783
- toolName: n,
2784
- toolUseId: i,
2785
- isError: !!t.isError,
2786
- durationMs: Date.now() - o
2787
- });
2788
- } catch {}
2789
- } catch (t) {
2790
- let r = t instanceof Error ? t.message : "Tool execution failed";
2791
- u.push({
2792
- toolUseId: i,
2793
- toolName: n,
2794
- content: r,
2795
- isError: !0
2796
- }), yield {
2797
- type: "tool_use_result",
2798
- data: {
2799
- id: i,
2800
- name: n,
2801
- result: r,
2802
- isError: !0
2803
- }
2804
- };
2805
- try {
2806
- l?.onToolEnd?.({
2807
- traceId: d,
2808
- turn: e,
2809
- toolName: n,
2810
- toolUseId: i,
2811
- isError: !0,
2812
- durationMs: Date.now() - o
2813
- });
2814
- } catch {}
2815
- }
2816
- }
2752
+ content: r
2753
+ }), !v.shouldContinue(i)) break;
2754
+ let s = yield* q(r, {
2755
+ executor: b,
2756
+ observability: l,
2757
+ traceId: u,
2758
+ turn: e
2759
+ });
2817
2760
  yield {
2818
2761
  type: "turn_complete",
2819
2762
  data: {}
2820
- };
2821
- let f = S.formatToolResults(u);
2822
- if (Array.isArray(f)) for (let e of f) E.push(e);
2823
- else E.push(f);
2763
+ }, R(S, v.formatToolResults(s));
2824
2764
  }
2825
- try {
2826
- l?.onChatEnd?.({
2827
- traceId: d,
2828
- sessionId: c,
2829
- totalTurns: D,
2830
- durationMs: Date.now() - f
2831
- });
2832
- } catch {}
2833
- yield {
2765
+ z(() => l?.onChatEnd?.({
2766
+ traceId: u,
2767
+ sessionId: c,
2768
+ totalTurns: C,
2769
+ durationMs: Date.now() - d
2770
+ })), yield {
2834
2771
  type: "done",
2835
2772
  data: {
2836
2773
  sessionId: c || "",
2837
- traceId: d
2774
+ traceId: u
2838
2775
  }
2839
2776
  };
2840
2777
  } catch (e) {
2841
2778
  try {
2842
2779
  l?.onChatEnd?.({
2843
- traceId: d,
2780
+ traceId: u,
2844
2781
  sessionId: c,
2845
2782
  totalTurns: 0,
2846
- durationMs: Date.now() - f,
2783
+ durationMs: Date.now() - d,
2847
2784
  error: e instanceof Error ? e.message : "Unknown error"
2848
2785
  });
2849
2786
  } catch {}
2850
- console.error("[agent] Chat error (provider=%s, model=%s): %s", String(p).replace(/\n|\r/g, ""), String(m).replace(/\n|\r/g, ""), String(e instanceof Error ? e.message : e).replace(/\n|\r/g, "")), yield {
2787
+ console.error("[agent] Chat error (provider=%s, model=%s): %s", String(f).replace(/\n|\r/g, ""), String(p).replace(/\n|\r/g, ""), String(e instanceof Error ? e.message : e).replace(/\n|\r/g, "")), yield {
2851
2788
  type: "error",
2852
- data: { message: S.formatError(e) }
2789
+ data: { message: v.formatError(e) }
2853
2790
  };
2854
2791
  }
2855
2792
  }
2856
2793
  //#endregion
2857
- export { b as handleAgentChat };
2794
+ export { Y as handleAgentChat };