drizzle-cube 0.5.8 → 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 (388) 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/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/adapters/{google-CFYljAOF.js → google-CvKM9yVM.js} +83 -71
  13. package/dist/adapters/{handler-Cx8QYLk6.js → handler-CfgE0JSL.js} +499 -576
  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 +205 -175
  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/adapters/{openai-BZdAA7Ji.js → openai-cDlFSTk6.js} +60 -58
  26. package/dist/adapters/openai-vXvLni8v.cjs +1 -0
  27. package/dist/adapters/{utils-D9JPLmfl.js → utils-BPWZsX7k.js} +1271 -1218
  28. package/dist/adapters/utils-_whV4fXL.cjs +128 -0
  29. package/dist/adapters/utils.cjs +1 -1
  30. package/dist/adapters/utils.js +2 -2
  31. package/dist/client/charts/ChartLoader.d.ts +2 -16
  32. package/dist/client/charts/chartComponentRegistry.d.ts +46 -0
  33. package/dist/client/charts/chartConfigHelpers.d.ts +38 -0
  34. package/dist/client/charts.js +14 -13
  35. package/dist/client/chunks/{DashboardEditModal-CjCIAT-J.js → DashboardEditModal-okVfH8ZK.js} +5296 -4544
  36. package/dist/client/chunks/DashboardEditModal-okVfH8ZK.js.map +1 -0
  37. package/dist/client/chunks/{RetentionCombinedChart-BPkfcTa8.js → RetentionCombinedChart-BgbDhsPz.js} +10 -10
  38. package/dist/client/chunks/{RetentionCombinedChart-BPkfcTa8.js.map → RetentionCombinedChart-BgbDhsPz.js.map} +1 -1
  39. package/dist/client/chunks/{RetentionHeatmap-DGzLzr7h.js → RetentionHeatmap-DjXZaTPq.js} +5 -5
  40. package/dist/client/chunks/{RetentionHeatmap-DGzLzr7h.js.map → RetentionHeatmap-DjXZaTPq.js.map} +1 -1
  41. package/dist/client/chunks/analysis-builder-DB88FojM.js +5674 -0
  42. package/dist/client/chunks/analysis-builder-DB88FojM.js.map +1 -0
  43. package/dist/client/chunks/{analysis-builder-shared-CYVwSPqt.js → analysis-builder-shared-BVK4TYfR.js} +1578 -1292
  44. package/dist/client/chunks/analysis-builder-shared-BVK4TYfR.js.map +1 -0
  45. package/dist/client/chunks/{chart-activity-grid-DmruKPab.js → chart-activity-grid-DX0SJbxs.js} +635 -492
  46. package/dist/client/chunks/chart-activity-grid-DX0SJbxs.js.map +1 -0
  47. package/dist/client/chunks/chart-area-of01_62R.js +775 -0
  48. package/dist/client/chunks/chart-area-of01_62R.js.map +1 -0
  49. package/dist/client/chunks/chart-bar-BqelQE_I.js +194 -0
  50. package/dist/client/chunks/chart-bar-BqelQE_I.js.map +1 -0
  51. package/dist/client/chunks/{chart-box-plot-DYKfyOI8.js → chart-box-plot-kkBixZ27.js} +2 -2
  52. package/dist/client/chunks/{chart-box-plot-DYKfyOI8.js.map → chart-box-plot-kkBixZ27.js.map} +1 -1
  53. package/dist/client/chunks/chart-bubble-B2he1--4.js +221 -0
  54. package/dist/client/chunks/chart-bubble-B2he1--4.js.map +1 -0
  55. package/dist/client/chunks/{chart-candlestick-Dwc92Mrj.js → chart-candlestick-DZp19Tzh.js} +2 -2
  56. package/dist/client/chunks/{chart-candlestick-Dwc92Mrj.js.map → chart-candlestick-DZp19Tzh.js.map} +1 -1
  57. package/dist/client/chunks/chart-config-area-BNigHUy8.js +124 -0
  58. package/dist/client/chunks/chart-config-area-BNigHUy8.js.map +1 -0
  59. package/dist/client/chunks/chart-config-bar-DSO_LRTx.js +54 -0
  60. package/dist/client/chunks/chart-config-bar-DSO_LRTx.js.map +1 -0
  61. package/dist/client/chunks/{chart-config-box-plot-DJ-dWWXA.js → chart-config-box-plot-oW8axV2q.js} +5 -10
  62. package/dist/client/chunks/chart-config-box-plot-oW8axV2q.js.map +1 -0
  63. package/dist/client/chunks/{chart-config-gauge-DSwC04l0.js → chart-config-gauge-Dq-_H9UN.js} +5 -7
  64. package/dist/client/chunks/chart-config-gauge-Dq-_H9UN.js.map +1 -0
  65. package/dist/client/chunks/{chart-config-kpi-delta-D6BIkHL3.js → chart-config-kpi-delta-DSQbvqu_.js} +5 -10
  66. package/dist/client/chunks/chart-config-kpi-delta-DSQbvqu_.js.map +1 -0
  67. package/dist/client/chunks/{chart-config-kpi-number-Bx-V9a62.js → chart-config-kpi-number-EFSWY1We.js} +5 -7
  68. package/dist/client/chunks/chart-config-kpi-number-EFSWY1We.js.map +1 -0
  69. package/dist/client/chunks/{chart-config-kpi-text-CcqC1u-8.js → chart-config-kpi-text-KM3V5X2u.js} +5 -7
  70. package/dist/client/chunks/chart-config-kpi-text-KM3V5X2u.js.map +1 -0
  71. package/dist/client/chunks/{chart-config-line-Db3jDsWc.js → chart-config-line-D6jG8PCH.js} +9 -36
  72. package/dist/client/chunks/chart-config-line-D6jG8PCH.js.map +1 -0
  73. package/dist/client/chunks/{chart-config-pie-DD4SmRTF.js → chart-config-pie-BhzW-fdn.js} +6 -16
  74. package/dist/client/chunks/chart-config-pie-BhzW-fdn.js.map +1 -0
  75. package/dist/client/chunks/{chart-config-radar-CC2XAaGr.js → chart-config-radar-D7REP1q_.js} +6 -16
  76. package/dist/client/chunks/chart-config-radar-D7REP1q_.js.map +1 -0
  77. package/dist/client/chunks/{chart-config-radial-bar-DmxKx1R0.js → chart-config-radial-bar-Byx6qOPU.js} +6 -16
  78. package/dist/client/chunks/chart-config-radial-bar-Byx6qOPU.js.map +1 -0
  79. package/dist/client/chunks/{chart-config-tree-map-BI-oQStO.js → chart-config-tree-map-DVrvf3yQ.js} +6 -16
  80. package/dist/client/chunks/chart-config-tree-map-DVrvf3yQ.js.map +1 -0
  81. package/dist/client/chunks/{chart-config-waterfall-DSnyixbI.js → chart-config-waterfall-DmFeQdIk.js} +5 -10
  82. package/dist/client/chunks/chart-config-waterfall-DmFeQdIk.js.map +1 -0
  83. package/dist/client/chunks/{chart-data-table-BO4sXsim.js → chart-data-table-CKauQXme.js} +1046 -1121
  84. package/dist/client/chunks/chart-data-table-CKauQXme.js.map +1 -0
  85. package/dist/client/chunks/{chart-funnel-DnWRsmnS.js → chart-funnel-CToKSBaL.js} +184 -222
  86. package/dist/client/chunks/chart-funnel-CToKSBaL.js.map +1 -0
  87. package/dist/client/chunks/chart-gauge-DTVezSk7.js +403 -0
  88. package/dist/client/chunks/chart-gauge-DTVezSk7.js.map +1 -0
  89. package/dist/client/chunks/chart-heat-map-DTuUl0BR.js +236 -0
  90. package/dist/client/chunks/chart-heat-map-DTuUl0BR.js.map +1 -0
  91. package/dist/client/chunks/chart-kpi-delta-Dn-jjO-2.js +408 -0
  92. package/dist/client/chunks/chart-kpi-delta-Dn-jjO-2.js.map +1 -0
  93. package/dist/client/chunks/chart-kpi-number-P_WBiO5S.js +244 -0
  94. package/dist/client/chunks/chart-kpi-number-P_WBiO5S.js.map +1 -0
  95. package/dist/client/chunks/chart-kpi-text-C-Y4eb5H.js +185 -0
  96. package/dist/client/chunks/chart-kpi-text-C-Y4eb5H.js.map +1 -0
  97. package/dist/client/chunks/chart-line-DKgrQA6c.js +101 -0
  98. package/dist/client/chunks/chart-line-DKgrQA6c.js.map +1 -0
  99. package/dist/client/chunks/{chart-markdown-dgUetjyM.js → chart-markdown-CV75S_zL.js} +2 -2
  100. package/dist/client/chunks/{chart-markdown-dgUetjyM.js.map → chart-markdown-CV75S_zL.js.map} +1 -1
  101. package/dist/client/chunks/{chart-measure-profile-ClfpLs4q.js → chart-measure-profile-Ket8fJyf.js} +7 -7
  102. package/dist/client/chunks/{chart-measure-profile-ClfpLs4q.js.map → chart-measure-profile-Ket8fJyf.js.map} +1 -1
  103. package/dist/client/chunks/chart-pie-ByieAX5H.js +119 -0
  104. package/dist/client/chunks/chart-pie-ByieAX5H.js.map +1 -0
  105. package/dist/client/chunks/chart-radar-CiSwHWp4.js +138 -0
  106. package/dist/client/chunks/chart-radar-CiSwHWp4.js.map +1 -0
  107. package/dist/client/chunks/chart-radial-bar-BF6Mhl6f.js +122 -0
  108. package/dist/client/chunks/chart-radial-bar-BF6Mhl6f.js.map +1 -0
  109. package/dist/client/chunks/{chart-sankey-M3XpO_ah.js → chart-sankey-DjrvKw6K.js} +36 -39
  110. package/dist/client/chunks/{chart-sankey-M3XpO_ah.js.map → chart-sankey-DjrvKw6K.js.map} +1 -1
  111. package/dist/client/chunks/chart-scatter-Dd9WFqnS.js +258 -0
  112. package/dist/client/chunks/chart-scatter-Dd9WFqnS.js.map +1 -0
  113. package/dist/client/chunks/{chart-sunburst-A_u6lqlS.js → chart-sunburst-leGpuDj7.js} +3 -3
  114. package/dist/client/chunks/{chart-sunburst-A_u6lqlS.js.map → chart-sunburst-leGpuDj7.js.map} +1 -1
  115. package/dist/client/chunks/chart-tree-map-Ceq5sLZA.js +323 -0
  116. package/dist/client/chunks/chart-tree-map-Ceq5sLZA.js.map +1 -0
  117. package/dist/client/chunks/{chart-waterfall-BuhMoagf.js → chart-waterfall-DyvQReN5.js} +7 -7
  118. package/dist/client/chunks/{chart-waterfall-BuhMoagf.js.map → chart-waterfall-DyvQReN5.js.map} +1 -1
  119. package/dist/client/chunks/{charts-core-jRtb0S2M.js → charts-core-DaXSt1Dd.js} +2 -2
  120. package/dist/client/chunks/{charts-core-jRtb0S2M.js.map → charts-core-DaXSt1Dd.js.map} +1 -1
  121. package/dist/client/chunks/charts-loader-DdTeCeNo.js +84 -0
  122. package/dist/client/chunks/charts-loader-DdTeCeNo.js.map +1 -0
  123. package/dist/client/chunks/{nl-NL-CpVs7ox3.js → nl-NL-2zTAWTej.js} +2 -1
  124. package/dist/client/chunks/{nl-NL-CpVs7ox3.js.map → nl-NL-2zTAWTej.js.map} +1 -1
  125. package/dist/client/chunks/retention-ChW9jYdy.js.map +1 -1
  126. package/dist/client/chunks/{schema-visualization-DE09kQE3.js → schema-visualization-Cb_E9_Gd.js} +12 -12
  127. package/dist/client/chunks/{schema-visualization-DE09kQE3.js.map → schema-visualization-Cb_E9_Gd.js.map} +1 -1
  128. package/dist/client/chunks/{useDirtyStateTracking-CoeQbprt.js → useDirtyStateTracking-MbpxH_v6.js} +95 -84
  129. package/dist/client/chunks/useDirtyStateTracking-MbpxH_v6.js.map +1 -0
  130. package/dist/client/chunks/{useExplainAI-DlnXWdmz.js → useExplainAI-evnZkjCY.js} +14 -14
  131. package/dist/client/chunks/{useExplainAI-DlnXWdmz.js.map → useExplainAI-evnZkjCY.js.map} +1 -1
  132. package/dist/client/chunks/{utils-CTKNaXS8.js → utils-3P6z1vz5.js} +2 -2
  133. package/dist/client/chunks/{utils-CTKNaXS8.js.map → utils-3P6z1vz5.js.map} +1 -1
  134. package/dist/client/chunks/{vendor-CPIYyeuD.js → vendor-DSpR0IW6.js} +43 -43
  135. package/dist/client/chunks/{vendor-CPIYyeuD.js.map → vendor-DSpR0IW6.js.map} +1 -1
  136. package/dist/client/components/AgenticNotebook/agentChatParts.d.ts +34 -0
  137. package/dist/client/components/AgenticNotebook/chatMessageParts.d.ts +39 -0
  138. package/dist/client/components/AgenticNotebook/useAgentChatController.d.ts +25 -0
  139. package/dist/client/components/AgenticNotebook/useNotebookAutosave.d.ts +12 -0
  140. package/dist/client/components/AnalysisBuilder/AnalysisQueryPanelParts.d.ts +64 -0
  141. package/dist/client/components/AnalysisBuilder/AnalysisResultsHeader.d.ts +67 -0
  142. package/dist/client/components/AnalysisBuilder/BreakdownComparisonToggle.d.ts +13 -0
  143. package/dist/client/components/AnalysisBuilder/BreakdownRow.d.ts +26 -0
  144. package/dist/client/components/AnalysisBuilder/DisplayOptionControl.d.ts +10 -0
  145. package/dist/client/components/AnalysisBuilder/ExecutionPlanPanelParts.d.ts +22 -0
  146. package/dist/client/components/AnalysisBuilder/FieldSearchResults.d.ts +16 -0
  147. package/dist/client/components/AnalysisBuilder/FilterValueInput.d.ts +63 -0
  148. package/dist/client/components/AnalysisBuilder/FlowDepthControls.d.ts +10 -0
  149. package/dist/client/components/AnalysisBuilder/FlowVisualizationPicker.d.ts +7 -0
  150. package/dist/client/components/AnalysisBuilder/LegacyBooleanOptions.d.ts +8 -0
  151. package/dist/client/components/AnalysisBuilder/MetricRow.d.ts +23 -0
  152. package/dist/client/components/AnalysisBuilder/SortToggleButton.d.ts +13 -0
  153. package/dist/client/components/AnalysisBuilder/StringArrayInput.d.ts +17 -0
  154. package/dist/client/components/AnalysisBuilder/filterConfigModalUtils.d.ts +30 -0
  155. package/dist/client/components/AnalysisBuilder/hooks/useAnalysisBuilderImperativeHandle.d.ts +13 -0
  156. package/dist/client/components/AnalysisBuilder/hooks/useDragReorder.d.ts +25 -0
  157. package/dist/client/components/AnalysisBuilder/hooks/useFieldSearchKeyboard.d.ts +11 -0
  158. package/dist/client/components/AnalysisBuilder/utils/axisConfigUtils.d.ts +23 -0
  159. package/dist/client/components/AnalysisBuilder/utils/executionPlanMarkdown.d.ts +8 -0
  160. package/dist/client/components/AnalysisBuilder/utils/fieldUtils.d.ts +5 -0
  161. package/dist/client/components/AnalysisBuilder/utils/resultsPanelDerive.d.ts +68 -0
  162. package/dist/client/components/AnalysisBuilder/utils/shareStateUtils.d.ts +68 -0
  163. package/dist/client/components/AnalysisBuilder/utils/sortUtils.d.ts +7 -0
  164. package/dist/client/components/DashboardFilters/CompactFilterBarParts.d.ts +26 -0
  165. package/dist/client/components/DashboardFilters/DashboardFilterConfigModalParts.d.ts +27 -0
  166. package/dist/client/components/DashboardFilters/DashboardFilterValueInput.d.ts +39 -0
  167. package/dist/client/components/DashboardFilters/dashboardFilterConfigModalUtils.d.ts +21 -0
  168. package/dist/client/components/DashboardFilters/useCompactFilterBar.d.ts +19 -0
  169. package/dist/client/components/DashboardFilters/useDashboardFilterConfigModal.d.ts +69 -0
  170. package/dist/client/components/DashboardFilters/useDateRangeState.d.ts +19 -0
  171. package/dist/client/components/DashboardFilters/useFilterDropdowns.d.ts +21 -0
  172. package/dist/client/components/DashboardFilters/useFilterValueFetch.d.ts +23 -0
  173. package/dist/client/components/DashboardPortletCard.d.ts +2 -57
  174. package/dist/client/components/analyticsPortlet/PortletChart.d.ts +31 -0
  175. package/dist/client/components/analyticsPortlet/PortletChartView.d.ts +35 -0
  176. package/dist/client/components/analyticsPortlet/PortletStates.d.ts +65 -0
  177. package/dist/client/components/analyticsPortlet/parsePortletQuery.d.ts +22 -0
  178. package/dist/client/components/analyticsPortlet/portletRenderState.d.ts +31 -0
  179. package/dist/client/components/analyticsPortlet/usePortletDebugData.d.ts +37 -0
  180. package/dist/client/components/analyticsPortlet/usePortletDrillState.d.ts +17 -0
  181. package/dist/client/components/analyticsPortlet/usePortletQueryResults.d.ts +37 -0
  182. package/dist/client/components/charts/ActivityGridChart.helpers.d.ts +33 -0
  183. package/dist/client/components/charts/ActivityGridChart.render.d.ts +31 -0
  184. package/dist/client/components/charts/AxisFormatControls.d.ts +3 -1
  185. package/dist/client/components/charts/BarChart.helpers.d.ts +23 -0
  186. package/dist/client/components/charts/BarSeries.d.ts +29 -0
  187. package/dist/client/components/charts/BubbleChart.helpers.d.ts +43 -0
  188. package/dist/client/components/charts/BubbleChart.render.d.ts +21 -0
  189. package/dist/client/components/charts/ChartStates.d.ts +38 -0
  190. package/dist/client/components/charts/FunnelChart.helpers.d.ts +25 -0
  191. package/dist/client/components/charts/FunnelViews.d.ts +16 -0
  192. package/dist/client/components/charts/HeatMapCanvas.d.ts +25 -0
  193. package/dist/client/components/charts/HeatMapChart.helpers.d.ts +64 -0
  194. package/dist/client/components/charts/KpiDelta.helpers.d.ts +20 -0
  195. package/dist/client/components/charts/KpiNumber.helpers.d.ts +30 -0
  196. package/dist/client/components/charts/KpiStates.d.ts +19 -0
  197. package/dist/client/components/charts/ScatterChart.helpers.d.ts +43 -0
  198. package/dist/client/components/charts/ScatterSeries.d.ts +17 -0
  199. package/dist/client/components/charts/ScatterTooltip.d.ts +21 -0
  200. package/dist/client/components/charts/TreeMapChart.helpers.d.ts +37 -0
  201. package/dist/client/components/charts/TreeMapContent.d.ts +24 -0
  202. package/dist/client/components/charts/TreeMapLegend.d.ts +13 -0
  203. package/dist/client/components/charts/cartesianChartHelpers.d.ts +126 -0
  204. package/dist/client/components/charts/chartAxisResolution.d.ts +32 -0
  205. package/dist/client/components/charts/chartScaffolding.d.ts +77 -0
  206. package/dist/client/components/charts/gaugeChartHelpers.d.ts +36 -0
  207. package/dist/client/components/charts/kpiTextHelpers.d.ts +46 -0
  208. package/dist/client/components/charts/radarChartHelpers.d.ts +14 -0
  209. package/dist/client/components/charts/radialBarChartHelpers.d.ts +22 -0
  210. package/dist/client/components/charts/useChartDimensions.d.ts +20 -0
  211. package/dist/client/components/charts/useKpiDimensions.d.ts +30 -0
  212. package/dist/client/components/dashboard/DashboardEditBar.d.ts +5 -0
  213. package/dist/client/components/dashboard/LayoutModeToggle.d.ts +10 -0
  214. package/dist/client/components/dashboardPortletCard/FilterFieldChip.d.ts +12 -0
  215. package/dist/client/components/dashboardPortletCard/PortletCardHeader.d.ts +43 -0
  216. package/dist/client/components/dashboardPortletCard/cardStyles.d.ts +33 -0
  217. package/dist/client/components/dashboardPortletCard/filterField.d.ts +12 -0
  218. package/dist/client/components/dashboardPortletCard/propsEqual.d.ts +55 -0
  219. package/dist/client/components/dashboardPortletCard/usePortletCardActions.d.ts +16 -0
  220. package/dist/client/components/portletAnalysisModal/saveValidation.d.ts +8 -0
  221. package/dist/client/components/shared/dateRangeUtils.d.ts +40 -0
  222. package/dist/client/components/shared/filterDisplayUtils.d.ts +10 -0
  223. package/dist/client/components/shared/filterItem/FilterDateRangeSelector.d.ts +17 -0
  224. package/dist/client/components/shared/filterItem/FilterFieldDropdown.d.ts +16 -0
  225. package/dist/client/components/shared/filterItem/dateRangeSync.d.ts +14 -0
  226. package/dist/client/components/shared/filterItem/fieldVisuals.d.ts +5 -0
  227. package/dist/client/components/shared/filterValueSelector/FilterValueInputs.d.ts +55 -0
  228. package/dist/client/components/shared/filterValueSelector/useFilterValueSelectorState.d.ts +25 -0
  229. package/dist/client/components/shared/queryFieldUtils.d.ts +21 -0
  230. package/dist/client/components/shared/utils.d.ts +4 -43
  231. package/dist/client/components.js +3 -3
  232. package/dist/client/hooks/agentChatStream.d.ts +39 -0
  233. package/dist/client/hooks/analysisQueryExecutionModes.d.ts +133 -0
  234. package/dist/client/hooks/drillNavigation.d.ts +25 -0
  235. package/dist/client/hooks.js +3 -3
  236. package/dist/client/icons.js +2 -2
  237. package/dist/client/index.js +816 -669
  238. package/dist/client/index.js.map +1 -1
  239. package/dist/client/providers.js +3 -3
  240. package/dist/client/schema.js +1 -1
  241. package/dist/client/shared/chartConfigBuilders.d.ts +18 -0
  242. package/dist/client/shared/components/QueryAnalysisPanel.sections.d.ts +41 -0
  243. package/dist/client/shared/queryTransforms.d.ts +20 -0
  244. package/dist/client/shared/utils.d.ts +2 -4
  245. package/dist/client/stores/optionsToAnalysisConfig.d.ts +17 -0
  246. package/dist/client/styles.css +1 -1
  247. package/dist/client/utils/axisValueFormatting.d.ts +32 -0
  248. package/dist/client/utils/timeValueFormatting.d.ts +32 -0
  249. package/dist/client/utils.js +6 -6
  250. package/dist/client-bundle-stats.html +1 -1
  251. package/dist/mcp-app/mcp-app.html +55 -55
  252. package/dist/server/google-BOnRIN1w.cjs +2 -0
  253. package/dist/server/{google-CFYljAOF.js → google-CvKM9yVM.js} +83 -71
  254. package/dist/server/index.cjs +179 -211
  255. package/dist/server/index.js +6330 -6458
  256. package/dist/server/{openai-BZdAA7Ji.js → openai-cDlFSTk6.js} +60 -58
  257. package/dist/server/openai-vXvLni8v.cjs +1 -0
  258. package/dist/server/server/adapters/base-adapter.d.ts +80 -35
  259. package/dist/server/server/adapters/databend-adapter.d.ts +8 -59
  260. package/dist/server/server/adapters/duckdb-adapter.d.ts +5 -59
  261. package/dist/server/server/adapters/mysql-adapter.d.ts +13 -70
  262. package/dist/server/server/adapters/postgres-adapter.d.ts +1 -65
  263. package/dist/server/server/adapters/snowflake-adapter.d.ts +5 -68
  264. package/dist/server/server/adapters/sqlite-adapter.d.ts +12 -32
  265. package/dist/server/server/adapters/window-function-builder.d.ts +11 -0
  266. package/dist/server/server/agent/chart-validation.d.ts +0 -5
  267. package/dist/server/server/agent/handler-steps.d.ts +37 -0
  268. package/dist/server/server/ai/discovery-helpers.d.ts +29 -0
  269. package/dist/server/server/ai/discovery.d.ts +4 -0
  270. package/dist/server/server/ai/suggestion-helpers.d.ts +33 -0
  271. package/dist/server/server/ai/suggestion.d.ts +0 -3
  272. package/dist/server/server/ai/validation-helpers.d.ts +21 -0
  273. package/dist/server/server/ai/validation.d.ts +0 -3
  274. package/dist/server/server/builders/analysis-utils.d.ts +106 -0
  275. package/dist/server/server/builders/cte-builder.d.ts +46 -0
  276. package/dist/server/server/builders/date-time-builder.d.ts +5 -0
  277. package/dist/server/server/builders/date-time-helpers.d.ts +34 -0
  278. package/dist/server/server/builders/filter-builder.d.ts +2 -0
  279. package/dist/server/server/builders/filter-operators.d.ts +23 -0
  280. package/dist/server/server/builders/flow-query-builder.d.ts +46 -19
  281. package/dist/server/server/builders/funnel-query-builder.d.ts +16 -5
  282. package/dist/server/server/builders/group-by-builder.d.ts +11 -0
  283. package/dist/server/server/builders/measure-builder.d.ts +43 -0
  284. package/dist/server/server/builders/retention-query-builder.d.ts +12 -14
  285. package/dist/server/server/cache-utils.d.ts +25 -5
  286. package/dist/server/server/compiler-metadata.d.ts +11 -0
  287. package/dist/server/server/compiler.d.ts +8 -14
  288. package/dist/server/server/cube-utils.d.ts +29 -4
  289. package/dist/server/server/execution/annotation-builder.d.ts +12 -0
  290. package/dist/server/server/execution/filter-cache-preloader.d.ts +19 -0
  291. package/dist/server/server/execution/mode-router.d.ts +25 -0
  292. package/dist/server/server/execution/query-result-cache.d.ts +21 -0
  293. package/dist/server/server/execution/result-post-processor.d.ts +10 -0
  294. package/dist/server/server/executor.d.ts +33 -30
  295. package/dist/server/server/executors/explain-utils.d.ts +28 -0
  296. package/dist/server/server/explain/explain-tree.d.ts +20 -0
  297. package/dist/server/server/filter-cache.d.ts +2 -2
  298. package/dist/server/server/gap-filler.d.ts +6 -0
  299. package/dist/server/server/index.d.ts +3 -1
  300. package/dist/server/server/logical-plan/cte-planner-helpers.d.ts +37 -0
  301. package/dist/server/server/logical-plan/cte-planner.d.ts +104 -0
  302. package/dist/server/server/logical-plan/filter-propagation.d.ts +44 -0
  303. package/dist/server/server/logical-plan/index.d.ts +6 -1
  304. package/dist/server/server/logical-plan/join-planner.d.ts +27 -0
  305. package/dist/server/server/logical-plan/logical-planner.d.ts +7 -200
  306. package/dist/server/server/logical-plan/optimiser.d.ts +3 -1
  307. package/dist/server/server/logical-plan/plan-analysis-reporter.d.ts +59 -0
  308. package/dist/server/server/logical-plan/planner-utils.d.ts +20 -0
  309. package/dist/server/server/logical-plan/types.d.ts +17 -9
  310. package/dist/server/server/measure-classification.d.ts +40 -0
  311. package/dist/server/server/physical-plan/drizzle-plan-builder.d.ts +21 -21
  312. package/dist/server/server/physical-plan/drizzle-sql-builder.d.ts +11 -0
  313. package/dist/server/server/physical-plan/processors/index.d.ts +2 -0
  314. package/dist/server/server/physical-plan/processors/keys-dedup-processor.d.ts +13 -0
  315. package/dist/server/server/physical-plan/processors/multi-fact-processor.d.ts +13 -0
  316. package/dist/server/server/physical-plan/processors/shared.d.ts +5 -0
  317. package/dist/server/server/query-handlers.d.ts +79 -0
  318. package/dist/server/server/query-modes.d.ts +28 -0
  319. package/dist/server/server/query-validator.d.ts +9 -0
  320. package/dist/server/server/resolvers/calculated-measure-resolver.d.ts +5 -0
  321. package/dist/server/server/resolvers/join-path-resolver.d.ts +6 -0
  322. package/dist/server/server/sql-format.d.ts +11 -0
  323. package/dist/server/server/types/cube.d.ts +18 -4
  324. package/dist/server/server/types/flow.d.ts +6 -5
  325. package/dist/server/server/types/index.d.ts +1 -1
  326. package/dist/server/server/types/validation.d.ts +14 -0
  327. package/package.json +11 -4
  328. package/dist/adapters/google-DUlXeeDA.cjs +0 -2
  329. package/dist/adapters/handler-CzbCuS6_.cjs +0 -25
  330. package/dist/adapters/locale-BPB7flIG.js +0 -8249
  331. package/dist/adapters/locale-tIMrNcCr.cjs +0 -198
  332. package/dist/adapters/mcp-transport-C2QzXm6h.cjs +0 -40
  333. package/dist/adapters/mcp-transport-D0B3S1tB.js +0 -579
  334. package/dist/adapters/openai-D_U4V0kT.cjs +0 -1
  335. package/dist/adapters/utils-KV37IBIv.cjs +0 -128
  336. package/dist/client/chunks/DashboardEditModal-CjCIAT-J.js.map +0 -1
  337. package/dist/client/chunks/analysis-builder-MuMIzoRq.js +0 -5367
  338. package/dist/client/chunks/analysis-builder-MuMIzoRq.js.map +0 -1
  339. package/dist/client/chunks/analysis-builder-shared-CYVwSPqt.js.map +0 -1
  340. package/dist/client/chunks/chart-activity-grid-DmruKPab.js.map +0 -1
  341. package/dist/client/chunks/chart-area-DHCPM4Em.js +0 -450
  342. package/dist/client/chunks/chart-area-DHCPM4Em.js.map +0 -1
  343. package/dist/client/chunks/chart-bar-KddciGDv.js +0 -271
  344. package/dist/client/chunks/chart-bar-KddciGDv.js.map +0 -1
  345. package/dist/client/chunks/chart-bubble-CfqiB538.js +0 -273
  346. package/dist/client/chunks/chart-bubble-CfqiB538.js.map +0 -1
  347. package/dist/client/chunks/chart-config-area-Bq_UsW3x.js +0 -101
  348. package/dist/client/chunks/chart-config-area-Bq_UsW3x.js.map +0 -1
  349. package/dist/client/chunks/chart-config-bar-_JEGZnAu.js +0 -95
  350. package/dist/client/chunks/chart-config-bar-_JEGZnAu.js.map +0 -1
  351. package/dist/client/chunks/chart-config-box-plot-DJ-dWWXA.js.map +0 -1
  352. package/dist/client/chunks/chart-config-gauge-DSwC04l0.js.map +0 -1
  353. package/dist/client/chunks/chart-config-kpi-delta-D6BIkHL3.js.map +0 -1
  354. package/dist/client/chunks/chart-config-kpi-number-Bx-V9a62.js.map +0 -1
  355. package/dist/client/chunks/chart-config-kpi-text-CcqC1u-8.js.map +0 -1
  356. package/dist/client/chunks/chart-config-line-Db3jDsWc.js.map +0 -1
  357. package/dist/client/chunks/chart-config-pie-DD4SmRTF.js.map +0 -1
  358. package/dist/client/chunks/chart-config-radar-CC2XAaGr.js.map +0 -1
  359. package/dist/client/chunks/chart-config-radial-bar-DmxKx1R0.js.map +0 -1
  360. package/dist/client/chunks/chart-config-tree-map-BI-oQStO.js.map +0 -1
  361. package/dist/client/chunks/chart-config-waterfall-DSnyixbI.js.map +0 -1
  362. package/dist/client/chunks/chart-data-table-BO4sXsim.js.map +0 -1
  363. package/dist/client/chunks/chart-funnel-DnWRsmnS.js.map +0 -1
  364. package/dist/client/chunks/chart-gauge-CgMeqeGb.js +0 -424
  365. package/dist/client/chunks/chart-gauge-CgMeqeGb.js.map +0 -1
  366. package/dist/client/chunks/chart-heat-map-DcGm9SWK.js +0 -231
  367. package/dist/client/chunks/chart-heat-map-DcGm9SWK.js.map +0 -1
  368. package/dist/client/chunks/chart-kpi-delta-C2wKPqCb.js +0 -343
  369. package/dist/client/chunks/chart-kpi-delta-C2wKPqCb.js.map +0 -1
  370. package/dist/client/chunks/chart-kpi-number-gWYF44ol.js +0 -322
  371. package/dist/client/chunks/chart-kpi-number-gWYF44ol.js.map +0 -1
  372. package/dist/client/chunks/chart-kpi-text-DIYtJtk4.js +0 -149
  373. package/dist/client/chunks/chart-kpi-text-DIYtJtk4.js.map +0 -1
  374. package/dist/client/chunks/chart-line-9BEGN5Ti.js +0 -433
  375. package/dist/client/chunks/chart-line-9BEGN5Ti.js.map +0 -1
  376. package/dist/client/chunks/chart-pie-BjAIhyOi.js +0 -172
  377. package/dist/client/chunks/chart-pie-BjAIhyOi.js.map +0 -1
  378. package/dist/client/chunks/chart-radar-Dgkcl2bN.js +0 -154
  379. package/dist/client/chunks/chart-radar-Dgkcl2bN.js.map +0 -1
  380. package/dist/client/chunks/chart-radial-bar-DdWJjAhK.js +0 -148
  381. package/dist/client/chunks/chart-radial-bar-DdWJjAhK.js.map +0 -1
  382. package/dist/client/chunks/chart-scatter-DaHYP_OL.js +0 -255
  383. package/dist/client/chunks/chart-scatter-DaHYP_OL.js.map +0 -1
  384. package/dist/client/chunks/chart-tree-map-uiwUU4nb.js +0 -298
  385. package/dist/client/chunks/chart-tree-map-uiwUU4nb.js.map +0 -1
  386. package/dist/client/chunks/useDirtyStateTracking-CoeQbprt.js.map +0 -1
  387. package/dist/server/google-DUlXeeDA.cjs +0 -2
  388. package/dist/server/openai-D_U4V0kT.cjs +0 -1
@@ -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-D9JPLmfl.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
  "",
@@ -233,24 +240,89 @@ function u(e) {
233
240
  "",
234
241
  "---",
235
242
  "",
236
- c(e)
243
+ f(e)
237
244
  ].join("\n");
238
245
  }
239
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
240
318
  //#region src/client/charts/chartConfigRegistry.ts
241
- var d = {
319
+ var C = {
242
320
  bar: {
243
321
  label: "chart.bar.label",
244
322
  description: "chart.bar.description",
245
323
  useCase: "chart.bar.useCase",
246
324
  clickableElements: { bar: !0 },
247
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
248
- available: !1,
249
- reason: "chart.availability.requiresMeasure"
250
- } : t < 1 ? {
251
- available: !1,
252
- reason: "chart.availability.requiresDimension"
253
- } : { available: !0 },
325
+ isAvailable: h,
254
326
  dropZones: [
255
327
  {
256
328
  key: "xAxis",
@@ -286,46 +358,10 @@ var d = {
286
358
  "hideHeader"
287
359
  ],
288
360
  displayOptionsConfig: [
289
- {
290
- key: "stackType",
291
- label: "chart.option.stacking.label",
292
- type: "select",
293
- defaultValue: "none",
294
- options: [
295
- {
296
- value: "none",
297
- label: "chart.option.accentBorder.none"
298
- },
299
- {
300
- value: "normal",
301
- label: "chart.option.stacking.stacked"
302
- },
303
- {
304
- value: "percent",
305
- label: "chart.option.stacking.percent"
306
- }
307
- ],
308
- description: "chart.configText.how_to_stack_multiple_bar_series"
309
- },
310
- {
311
- key: "target",
312
- label: "chart.option.target.label",
313
- type: "string",
314
- placeholder: "e.g., 100 or 50,75 for spread",
315
- description: "chart.option.target.description"
316
- },
317
- {
318
- key: "leftYAxisFormat",
319
- label: "chart.option.leftYAxisFormat.label",
320
- type: "axisFormat",
321
- description: "chart.option.leftYAxisFormat.description"
322
- },
323
- {
324
- key: "rightYAxisFormat",
325
- label: "chart.option.rightYAxisFormat.label",
326
- type: "axisFormat",
327
- description: "chart.option.rightYAxisFormat.description"
328
- }
361
+ S("chart.configText.how_to_stack_multiple_bar_series"),
362
+ _,
363
+ y,
364
+ b
329
365
  ]
330
366
  },
331
367
  line: {
@@ -333,13 +369,7 @@ var d = {
333
369
  description: "chart.line.description",
334
370
  useCase: "chart.line.useCase",
335
371
  clickableElements: { point: !0 },
336
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
337
- available: !1,
338
- reason: "chart.availability.requiresMeasure"
339
- } : t < 1 ? {
340
- available: !1,
341
- reason: "chart.availability.requiresDimension"
342
- } : { available: !0 },
372
+ isAvailable: h,
343
373
  dropZones: [
344
374
  {
345
375
  key: "xAxis",
@@ -375,20 +405,8 @@ var d = {
375
405
  "hideHeader"
376
406
  ],
377
407
  displayOptionsConfig: [
378
- {
379
- key: "connectNulls",
380
- label: "chart.option.connectNulls.label",
381
- type: "boolean",
382
- defaultValue: !1,
383
- description: "chart.option.connectNulls.description"
384
- },
385
- {
386
- key: "target",
387
- label: "chart.option.target.label",
388
- type: "string",
389
- placeholder: "e.g., 100 or 50,75 for spread",
390
- description: "chart.option.target.description"
391
- },
408
+ v,
409
+ _,
392
410
  {
393
411
  key: "priorPeriodStyle",
394
412
  label: "chart.option.priorPeriodStyle.label",
@@ -420,31 +438,15 @@ var d = {
420
438
  step: .1,
421
439
  description: "chart.option.priorPeriodOpacity.description"
422
440
  },
423
- {
424
- key: "leftYAxisFormat",
425
- label: "chart.option.leftYAxisFormat.label",
426
- type: "axisFormat",
427
- description: "chart.option.leftYAxisFormat.description"
428
- },
429
- {
430
- key: "rightYAxisFormat",
431
- label: "chart.option.rightYAxisFormat.label",
432
- type: "axisFormat",
433
- description: "chart.option.rightYAxisFormat.description"
434
- }
441
+ y,
442
+ b
435
443
  ]
436
444
  },
437
445
  area: {
438
446
  label: "chart.area.label",
439
447
  description: "chart.area.description",
440
448
  useCase: "chart.area.useCase",
441
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
442
- available: !1,
443
- reason: "chart.availability.requiresMeasure"
444
- } : t < 1 ? {
445
- available: !1,
446
- reason: "chart.availability.requiresDimension"
447
- } : { available: !0 },
449
+ isAvailable: h,
448
450
  dropZones: [
449
451
  {
450
452
  key: "xAxis",
@@ -480,53 +482,11 @@ var d = {
480
482
  "hideHeader"
481
483
  ],
482
484
  displayOptionsConfig: [
483
- {
484
- key: "stackType",
485
- label: "chart.option.stacking.label",
486
- type: "select",
487
- defaultValue: "none",
488
- options: [
489
- {
490
- value: "none",
491
- label: "chart.option.accentBorder.none"
492
- },
493
- {
494
- value: "normal",
495
- label: "chart.option.stacking.stacked"
496
- },
497
- {
498
- value: "percent",
499
- label: "chart.option.stacking.percent"
500
- }
501
- ],
502
- description: "chart.configText.how_to_stack_multiple_area_series"
503
- },
504
- {
505
- key: "connectNulls",
506
- label: "chart.option.connectNulls.label",
507
- type: "boolean",
508
- defaultValue: !1,
509
- description: "chart.option.connectNulls.description"
510
- },
511
- {
512
- key: "target",
513
- label: "chart.option.target.label",
514
- type: "string",
515
- placeholder: "e.g., 100 or 50,75 for spread",
516
- description: "chart.option.target.description"
517
- },
518
- {
519
- key: "leftYAxisFormat",
520
- label: "chart.option.leftYAxisFormat.label",
521
- type: "axisFormat",
522
- description: "chart.option.leftYAxisFormat.description"
523
- },
524
- {
525
- key: "rightYAxisFormat",
526
- label: "chart.option.rightYAxisFormat.label",
527
- type: "axisFormat",
528
- description: "chart.option.rightYAxisFormat.description"
529
- }
485
+ S("chart.configText.how_to_stack_multiple_area_series"),
486
+ v,
487
+ _,
488
+ y,
489
+ b
530
490
  ]
531
491
  },
532
492
  pie: {
@@ -534,13 +494,7 @@ var d = {
534
494
  description: "chart.pie.description",
535
495
  useCase: "chart.pie.useCase",
536
496
  clickableElements: { slice: !0 },
537
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
538
- available: !1,
539
- reason: "chart.availability.requiresMeasure"
540
- } : t < 1 ? {
541
- available: !1,
542
- reason: "chart.availability.requiresDimension"
543
- } : { available: !0 },
497
+ isAvailable: h,
544
498
  dropZones: [{
545
499
  key: "xAxis",
546
500
  label: "chart.configText.categories",
@@ -591,12 +545,7 @@ var d = {
591
545
  label: "chart.configText.80_percent"
592
546
  }
593
547
  ]
594
- }, {
595
- key: "leftYAxisFormat",
596
- label: "chart.option.valueFormat.label",
597
- type: "axisFormat",
598
- description: "chart.option.valueFormat.description"
599
- }]
548
+ }, x()]
600
549
  },
601
550
  scatter: {
602
551
  label: "chart.scatter.label",
@@ -747,13 +696,7 @@ var d = {
747
696
  label: "chart.radar.label",
748
697
  description: "chart.radar.description",
749
698
  useCase: "chart.radar.useCase",
750
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
751
- available: !1,
752
- reason: "chart.availability.requiresMeasure"
753
- } : t < 1 ? {
754
- available: !1,
755
- reason: "chart.availability.requiresDimension"
756
- } : { available: !0 },
699
+ isAvailable: h,
757
700
  dropZones: [
758
701
  {
759
702
  key: "xAxis",
@@ -786,24 +729,13 @@ var d = {
786
729
  "showTooltip",
787
730
  "hideHeader"
788
731
  ],
789
- displayOptionsConfig: [{
790
- key: "leftYAxisFormat",
791
- label: "chart.option.valueFormat.label",
792
- type: "axisFormat",
793
- description: "chart.option.valueFormat.description"
794
- }]
732
+ displayOptionsConfig: [x()]
795
733
  },
796
734
  radialBar: {
797
735
  label: "chart.radialBar.label",
798
736
  description: "chart.radialBar.description",
799
737
  useCase: "chart.radialBar.useCase",
800
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
801
- available: !1,
802
- reason: "chart.availability.requiresMeasure"
803
- } : t < 1 ? {
804
- available: !1,
805
- reason: "chart.availability.requiresDimension"
806
- } : { available: !0 },
738
+ isAvailable: h,
807
739
  dropZones: [{
808
740
  key: "xAxis",
809
741
  label: "chart.configText.categories",
@@ -825,24 +757,13 @@ var d = {
825
757
  "showTooltip",
826
758
  "hideHeader"
827
759
  ],
828
- displayOptionsConfig: [{
829
- key: "leftYAxisFormat",
830
- label: "chart.option.valueFormat.label",
831
- type: "axisFormat",
832
- description: "chart.option.valueFormat.description"
833
- }]
760
+ displayOptionsConfig: [x()]
834
761
  },
835
762
  treemap: {
836
763
  label: "chart.treemap.label",
837
764
  description: "chart.treemap.description",
838
765
  useCase: "chart.treemap.useCase",
839
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
840
- available: !1,
841
- reason: "chart.availability.requiresMeasure"
842
- } : t < 1 ? {
843
- available: !1,
844
- reason: "chart.availability.requiresDimension"
845
- } : { available: !0 },
766
+ isAvailable: h,
846
767
  dropZones: [
847
768
  {
848
769
  key: "xAxis",
@@ -876,12 +797,7 @@ var d = {
876
797
  "showTooltip",
877
798
  "hideHeader"
878
799
  ],
879
- displayOptionsConfig: [{
880
- key: "leftYAxisFormat",
881
- label: "chart.option.valueFormat.label",
882
- type: "axisFormat",
883
- description: "chart.configText.number_formatting_for_size_values"
884
- }],
800
+ displayOptionsConfig: [x("chart.configText.number_formatting_for_size_values")],
885
801
  clickableElements: { cell: !0 }
886
802
  },
887
803
  table: {
@@ -964,10 +880,7 @@ var d = {
964
880
  label: "chart.kpiNumber.label",
965
881
  description: "chart.kpiNumber.description",
966
882
  useCase: "chart.kpiNumber.useCase",
967
- isAvailable: ({ measureCount: e }) => e < 1 ? {
968
- available: !1,
969
- reason: "chart.availability.requiresMeasure"
970
- } : { available: !0 },
883
+ isAvailable: g,
971
884
  dropZones: [{
972
885
  key: "yAxis",
973
886
  label: "chart.configText.value",
@@ -1037,13 +950,7 @@ var d = {
1037
950
  label: "chart.kpiDelta.label",
1038
951
  description: "chart.kpiDelta.description",
1039
952
  useCase: "chart.kpiDelta.useCase",
1040
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
1041
- available: !1,
1042
- reason: "chart.availability.requiresMeasure"
1043
- } : t < 1 ? {
1044
- available: !1,
1045
- reason: "chart.availability.requiresDimension"
1046
- } : { available: !0 },
953
+ isAvailable: h,
1047
954
  dropZones: [{
1048
955
  key: "yAxis",
1049
956
  label: "chart.configText.value",
@@ -1132,10 +1039,7 @@ var d = {
1132
1039
  label: "chart.kpiText.label",
1133
1040
  description: "chart.kpiText.description",
1134
1041
  useCase: "chart.kpiText.useCase",
1135
- isAvailable: ({ measureCount: e }) => e < 1 ? {
1136
- available: !1,
1137
- reason: "chart.availability.requiresMeasure"
1138
- } : { available: !0 },
1042
+ isAvailable: g,
1139
1043
  dropZones: [{
1140
1044
  key: "yAxis",
1141
1045
  label: "chart.configText.value",
@@ -1635,13 +1539,7 @@ var d = {
1635
1539
  label: "chart.boxPlot.label",
1636
1540
  description: "chart.boxPlot.description",
1637
1541
  useCase: "chart.boxPlot.useCase",
1638
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
1639
- available: !1,
1640
- reason: "chart.availability.requiresMeasure"
1641
- } : t < 1 ? {
1642
- available: !1,
1643
- reason: "chart.availability.requiresDimension"
1644
- } : { available: !0 },
1542
+ isAvailable: h,
1645
1543
  displayOptions: ["hideHeader"],
1646
1544
  dropZones: [{
1647
1545
  key: "xAxis",
@@ -1672,13 +1570,7 @@ var d = {
1672
1570
  description: "chart.waterfall.description",
1673
1571
  useCase: "chart.waterfall.useCase",
1674
1572
  clickableElements: { bar: !0 },
1675
- isAvailable: ({ measureCount: e, dimensionCount: t }) => e < 1 ? {
1676
- available: !1,
1677
- reason: "chart.availability.requiresMeasure"
1678
- } : t < 1 ? {
1679
- available: !1,
1680
- reason: "chart.availability.requiresDimension"
1681
- } : { available: !0 },
1573
+ isAvailable: h,
1682
1574
  displayOptions: ["showTooltip", "hideHeader"],
1683
1575
  dropZones: [{
1684
1576
  key: "xAxis",
@@ -1886,10 +1778,7 @@ var d = {
1886
1778
  useCase: "chart.gauge.useCase",
1887
1779
  clickableElements: {},
1888
1780
  displayOptions: ["hideHeader"],
1889
- isAvailable: ({ measureCount: e }) => e < 1 ? {
1890
- available: !1,
1891
- reason: "chart.availability.requiresMeasure"
1892
- } : { available: !0 },
1781
+ isAvailable: g,
1893
1782
  dropZones: [{
1894
1783
  key: "yAxis",
1895
1784
  label: "chart.configText.value_measure",
@@ -1945,79 +1834,83 @@ var d = {
1945
1834
  };
1946
1835
  //#endregion
1947
1836
  //#region src/server/agent/chart-validation.ts
1948
- function f(t, n, r) {
1949
- let i = d[t];
1950
- 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 {
1951
1868
  isValid: !0,
1952
1869
  errors: []
1953
1870
  };
1954
- let a = [];
1955
- for (let r of i.dropZones) {
1956
- if (!r.mandatory) continue;
1957
- let i = n?.[r.key];
1958
- if (!(Array.isArray(i) ? i.length > 0 : i)) {
1959
- let n = r.acceptTypes?.join("/") ?? "fields";
1960
- a.push(e("server.validation.chart.dropZoneRequired", {
1961
- key: r.key,
1962
- chartType: t,
1963
- label: r.label,
1964
- acceptDesc: n
1965
- }));
1966
- }
1967
- }
1968
- if (t === "bar") {
1969
- let t = n?.xAxis;
1970
- if (!(Array.isArray(t) ? t.length > 0 : t)) {
1971
- let t = r.dimensions ?? [], n = r.timeDimensions ?? [];
1972
- t.length > 0 || n.length > 0 ? a.push(e("server.validation.chart.barXAxisRequired")) : a.push(e("server.validation.chart.barNeedsDimension"));
1973
- }
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);
1974
1884
  }
1975
- if (n?.xAxis && n?.series) {
1976
- 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));
1977
- 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;
1978
1895
  }
1979
- return {
1980
- isValid: a.length === 0,
1981
- errors: a
1982
- };
1896
+ let o = e.maxItems ?? Infinity, s = a.slice(0, o);
1897
+ s.length > 0 && (t[e.key] = s);
1983
1898
  }
1984
- function p(e, t, n) {
1985
- let r = d[e];
1899
+ function M(e, t, n) {
1900
+ let r = C[e];
1986
1901
  if (!r) return t ?? {};
1987
- let i = { ...t }, a = n.measures ?? [], o = n.dimensions ?? [], s = (n.timeDimensions ?? []).map((e) => e.dimension);
1988
- for (let e of r.dropZones) {
1989
- let t = i[e.key];
1990
- if (Array.isArray(t) ? t.length > 0 : t) continue;
1991
- let n = e.acceptTypes ?? [];
1992
- if (e.key === "sizeField" || e.key === "colorField") {
1993
- if (n.includes("measure")) {
1994
- let t = /* @__PURE__ */ new Set();
1995
- for (let n of r.dropZones) {
1996
- if (n.key === e.key) continue;
1997
- let r = i[n.key];
1998
- Array.isArray(r) ? r.forEach((e) => t.add(e)) : typeof r == "string" && t.add(r);
1999
- }
2000
- let n = a.filter((e) => !t.has(e));
2001
- n.length > 0 && (i[e.key] = n[0]);
2002
- }
2003
- continue;
2004
- }
2005
- let c = [];
2006
- if (n.includes("dimension") && c.push(...o), n.includes("timeDimension") && c.push(...s), n.includes("measure") && c.push(...a), c.length === 0) continue;
2007
- let l = c;
2008
- if (e.key === "series") {
2009
- let e = new Set(Array.isArray(i.xAxis) ? i.xAxis : i.xAxis ? [i.xAxis] : []);
2010
- if (l = c.filter((t) => !e.has(t)), l.length === 0) continue;
2011
- }
2012
- let u = e.maxItems ?? Infinity, d = l.slice(0, u);
2013
- d.length > 0 && (i[e.key] = d);
2014
- }
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));
2015
1908
  return i;
2016
1909
  }
2017
- function m(e) {
1910
+ function N(e) {
2018
1911
  let t = ["\nChart config requirements by type:"];
2019
1912
  for (let n of e) {
2020
- let e = d[n];
1913
+ let e = C[n];
2021
1914
  if (!e) continue;
2022
1915
  let r = [e.description ?? "", e.useCase ?? ""].filter(Boolean).join(". "), i = r ? ` — ${r}.` : "", a = e.dropZones.filter((e) => e.mandatory);
2023
1916
  if (a.length === 0 && !e.skipQuery) {
@@ -2038,7 +1931,7 @@ function m(e) {
2038
1931
  }
2039
1932
  //#endregion
2040
1933
  //#region src/server/agent/tools.ts
2041
- var h = [
1934
+ var P = [
2042
1935
  "bar",
2043
1936
  "line",
2044
1937
  "area",
@@ -2058,7 +1951,7 @@ var h = [
2058
1951
  "boxPlot",
2059
1952
  "markdown"
2060
1953
  ];
2061
- function g() {
1954
+ function F() {
2062
1955
  return [
2063
1956
  {
2064
1957
  name: "discover_cubes",
@@ -2098,12 +1991,12 @@ function g() {
2098
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.",
2099
1992
  parameters: {
2100
1993
  type: "object",
2101
- properties: t
1994
+ properties: s
2102
1995
  }
2103
1996
  },
2104
1997
  {
2105
1998
  name: "add_portlet",
2106
- 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.",
2107
2000
  parameters: {
2108
2001
  type: "object",
2109
2002
  properties: {
@@ -2117,7 +2010,7 @@ function g() {
2117
2010
  },
2118
2011
  chartType: {
2119
2012
  type: "string",
2120
- enum: h,
2013
+ enum: P,
2121
2014
  description: "Chart type to render"
2122
2015
  },
2123
2016
  chartConfig: {
@@ -2213,7 +2106,7 @@ function g() {
2213
2106
  },
2214
2107
  chartType: {
2215
2108
  type: "string",
2216
- enum: h,
2109
+ enum: P,
2217
2110
  description: "Chart type. Use \"markdown\" for section headers."
2218
2111
  },
2219
2112
  query: {
@@ -2350,10 +2243,10 @@ function g() {
2350
2243
  }
2351
2244
  ];
2352
2245
  }
2353
- function _(e) {
2246
+ function I(e) {
2354
2247
  let { semanticLayer: t, securityContext: n } = e, o = /* @__PURE__ */ new Map();
2355
2248
  o.set("discover_cubes", async (e) => {
2356
- let n = { cubes: (await r(t, {
2249
+ let n = { cubes: (await a(t, {
2357
2250
  topic: e.topic,
2358
2251
  intent: e.intent,
2359
2252
  limit: e.limit,
@@ -2399,8 +2292,8 @@ function _(e) {
2399
2292
  if (n.length > 0) throw Error(`Invalid ${t}:\n${n.join("\n")}`);
2400
2293
  };
2401
2294
  r(e.measures, "measures"), r(e.dimensions, "dimensions");
2402
- let i;
2403
- 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 } : {
2404
2297
  measures: e.measures,
2405
2298
  dimensions: e.dimensions,
2406
2299
  filters: e.filters,
@@ -2410,7 +2303,7 @@ function _(e) {
2410
2303
  offset: e.offset,
2411
2304
  ungrouped: e.ungrouped
2412
2305
  };
2413
- let o = await a(t, n, { query: i });
2306
+ let o = await i(t, n, { query: a });
2414
2307
  return { result: JSON.stringify({
2415
2308
  rowCount: o.data.length,
2416
2309
  data: o.data,
@@ -2437,27 +2330,27 @@ function _(e) {
2437
2330
  let n = {
2438
2331
  number: "kpiNumber",
2439
2332
  retention: "retentionHeatmap"
2440
- }[e.chartType] ?? e.chartType, r;
2333
+ }[e.chartType] ?? e.chartType, i;
2441
2334
  try {
2442
- r = JSON.parse(e.query);
2335
+ i = JSON.parse(e.query);
2443
2336
  } catch {
2444
2337
  return {
2445
2338
  result: "Invalid query: could not parse JSON string. Ensure `query` is a valid JSON string.",
2446
2339
  isError: !0
2447
2340
  };
2448
2341
  }
2449
- r = i(r);
2450
- let a = t.validateQuery(r);
2342
+ i = r(i);
2343
+ let a = t.validateQuery(i);
2451
2344
  if (!a.isValid) return {
2452
- 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)}`,
2453
2346
  isError: !0
2454
2347
  };
2455
- let o = !!(r.funnel || r.flow || r.retention), s;
2348
+ let o = !!(i.funnel || i.flow || i.retention), s;
2456
2349
  if (o) s = e.chartConfig ?? {};
2457
2350
  else {
2458
- let t = p(n, e.chartConfig, r), i = f(n, t, r);
2459
- if (!i.isValid) return {
2460
- 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")}`,
2461
2354
  isError: !0
2462
2355
  };
2463
2356
  s = t;
@@ -2497,27 +2390,27 @@ function _(e) {
2497
2390
  result: "Dashboard must contain at least one portlet.",
2498
2391
  isError: !0
2499
2392
  };
2500
- let r = [];
2393
+ let i = [];
2501
2394
  for (let e of n) {
2502
2395
  if (e.chartType === "markdown") continue;
2503
2396
  let n = e.query;
2504
2397
  if (!n) {
2505
- r.push(`Portlet "${e.title}": missing query`);
2398
+ i.push(`Portlet "${e.title}": missing query`);
2506
2399
  continue;
2507
2400
  }
2508
2401
  let a;
2509
2402
  try {
2510
2403
  a = JSON.parse(n);
2511
2404
  } catch {
2512
- r.push(`Portlet "${e.title}": invalid JSON query`);
2405
+ i.push(`Portlet "${e.title}": invalid JSON query`);
2513
2406
  continue;
2514
2407
  }
2515
- a = i(a);
2408
+ a = r(a);
2516
2409
  let o = t.validateQuery(a);
2517
- o.isValid || r.push(`Portlet "${e.title}": ${o.errors.join(", ")}`);
2410
+ o.isValid || i.push(`Portlet "${e.title}": ${o.errors.join(", ")}`);
2518
2411
  }
2519
- if (r.length > 0) return {
2520
- 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")}`,
2521
2414
  isError: !0
2522
2415
  };
2523
2416
  let a = {
@@ -2574,298 +2467,328 @@ function _(e) {
2574
2467
  }
2575
2468
  //#endregion
2576
2469
  //#region src/server/agent/providers/factory.ts
2577
- async function v(e, t, n) {
2470
+ async function L(e, t, n) {
2578
2471
  switch (e) {
2579
2472
  case "anthropic": {
2580
2473
  let { AnthropicProvider: e } = await import("./anthropic-CZh4hB-m.js");
2581
2474
  return new e(t);
2582
2475
  }
2583
2476
  case "openai": {
2584
- let { OpenAIProvider: e } = await import("./openai-BZdAA7Ji.js");
2477
+ let { OpenAIProvider: e } = await import("./openai-cDlFSTk6.js");
2585
2478
  return new e(t, n);
2586
2479
  }
2587
2480
  case "google": {
2588
- let { GoogleProvider: e } = await import("./google-CFYljAOF.js");
2481
+ let { GoogleProvider: e } = await import("./google-CvKM9yVM.js");
2589
2482
  return new e(t);
2590
2483
  }
2591
2484
  default: throw Error(`Unknown LLM provider: "${e}". Supported providers: anthropic, openai, google`);
2592
2485
  }
2593
2486
  }
2594
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
2595
2696
  //#region src/server/agent/handler.ts
2596
- var y = {
2697
+ var J = {
2597
2698
  anthropic: "claude-sonnet-4-6",
2598
2699
  openai: "gpt-4.1-mini",
2599
2700
  google: "gemini-3-flash-preview"
2600
2701
  };
2601
- async function* b(t) {
2602
- 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;
2603
2704
  try {
2604
- S = await v(p, s, { baseURL: h });
2705
+ v = await L(f, s, { baseURL: h });
2605
2706
  } catch (t) {
2606
- 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 {
2607
2708
  type: "error",
2608
2709
  data: { message: t instanceof Error ? t.message : e("server.errors.llmInitFailed") }
2609
2710
  };
2610
2711
  return;
2611
2712
  }
2612
- let C = g(), w = _({
2713
+ let y = F(), b = I({
2613
2714
  semanticLayer: i,
2614
2715
  securityContext: a
2615
- }), T = u(i.getMetadata());
2616
- t.systemContext && (T += `\n\n## User Context\n\n${t.systemContext}`);
2617
- try {
2618
- l?.onChatStart?.({
2619
- traceId: d,
2620
- sessionId: c,
2621
- message: n,
2622
- model: m,
2623
- historyLength: r?.length ?? 0
2624
- });
2625
- } catch {}
2626
- let E = [];
2627
- if (r && r.length > 0) {
2628
- for (let e of r) if (e.role === "user") E.push({
2629
- role: "user",
2630
- content: e.content
2631
- });
2632
- else if (e.role === "assistant") {
2633
- let t = [];
2634
- if (e.content && t.push({
2635
- type: "text",
2636
- text: e.content
2637
- }), e.toolCalls && e.toolCalls.length > 0) {
2638
- for (let n of e.toolCalls) t.push({
2639
- type: "tool_use",
2640
- id: n.id,
2641
- name: n.name,
2642
- input: n.input || {}
2643
- });
2644
- E.push({
2645
- role: "assistant",
2646
- content: t
2647
- });
2648
- let n = e.toolCalls.map((e) => ({
2649
- toolUseId: e.id,
2650
- toolName: e.name,
2651
- content: typeof e.result == "string" ? e.result : JSON.stringify(e.result ?? ""),
2652
- isError: e.status === "error"
2653
- })), r = S.formatToolResults(n);
2654
- if (Array.isArray(r)) for (let e of r) E.push(e);
2655
- else E.push(r);
2656
- } else t.length > 0 && E.push({
2657
- role: "assistant",
2658
- content: e.content
2659
- });
2660
- }
2661
- }
2662
- 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({
2663
2726
  role: "user",
2664
2727
  content: n
2665
2728
  });
2666
- let D = 0;
2729
+ let C = 0;
2667
2730
  try {
2668
- for (let e = 0; e < b; e++) {
2669
- D = e + 1;
2670
- let t = await S.createStream({
2671
- model: m,
2672
- maxTokens: x,
2673
- system: T,
2674
- tools: C,
2675
- messages: E
2676
- }), n = [], r = "", i = "", a, o, s = Date.now(), c = !1;
2677
- for await (let e of S.parseStreamEvents(t)) {
2678
- let t = e;
2679
- switch (t.type) {
2680
- case "text_delta": {
2681
- let e = n[n.length - 1];
2682
- e && e.type === "text" ? e.text = (e.text || "") + t.text : n.push({
2683
- type: "text",
2684
- text: t.text
2685
- }), yield {
2686
- type: "text_delta",
2687
- data: t.text
2688
- };
2689
- break;
2690
- }
2691
- case "tool_use_start":
2692
- if (c && r) {
2693
- let e = n[n.length - 1];
2694
- if (e?.type === "tool_use") try {
2695
- e.input = JSON.parse(r);
2696
- } catch {}
2697
- }
2698
- n.push({
2699
- type: "tool_use",
2700
- id: t.id,
2701
- name: t.name,
2702
- input: {},
2703
- ...t.metadata ? { metadata: t.metadata } : {}
2704
- }), r = "", c = !0, yield {
2705
- type: "tool_use_start",
2706
- data: {
2707
- id: t.id,
2708
- name: t.name,
2709
- input: void 0
2710
- }
2711
- };
2712
- break;
2713
- case "tool_input_delta":
2714
- r += t.json;
2715
- break;
2716
- case "tool_use_end":
2717
- if (t.id && t.input) {
2718
- let e = n.find((e) => e.type === "tool_use" && e.id === t.id);
2719
- e && (e.input = t.input);
2720
- } else if (c) {
2721
- let e = n[n.length - 1];
2722
- if (e?.type === "tool_use" && r) {
2723
- try {
2724
- e.input = JSON.parse(r);
2725
- } catch {
2726
- e.input = {};
2727
- }
2728
- r = "";
2729
- }
2730
- c = !1;
2731
- }
2732
- break;
2733
- case "message_meta":
2734
- t.inputTokens != null && (a = t.inputTokens), t.outputTokens != null && (o = t.outputTokens), t.stopReason && (i = t.stopReason);
2735
- break;
2736
- }
2737
- }
2738
- try {
2739
- l?.onGenerationEnd?.({
2740
- traceId: d,
2741
- turn: e,
2742
- model: m,
2743
- stopReason: i,
2744
- inputTokens: a,
2745
- outputTokens: o,
2746
- durationMs: Date.now() - s,
2747
- input: E,
2748
- output: n
2749
- });
2750
- } catch {}
2751
- 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({
2752
2751
  role: "assistant",
2753
- content: n
2754
- }), !S.shouldContinue(i)) break;
2755
- let u = [];
2756
- for (let t of n) {
2757
- if (t.type !== "tool_use") continue;
2758
- let n = t.name, r = t.input || {}, i = t.id, a = w.get(n);
2759
- if (!a) {
2760
- u.push({
2761
- toolUseId: i,
2762
- toolName: n,
2763
- content: `Unknown tool: ${n}`,
2764
- isError: !0
2765
- }), yield {
2766
- type: "tool_use_result",
2767
- data: {
2768
- id: i,
2769
- name: n,
2770
- result: `Unknown tool: ${n}`,
2771
- isError: !0
2772
- }
2773
- };
2774
- continue;
2775
- }
2776
- let o = Date.now();
2777
- try {
2778
- let t = await a(r);
2779
- t.sideEffect && (yield t.sideEffect), u.push({
2780
- toolUseId: i,
2781
- toolName: n,
2782
- content: t.result,
2783
- ...t.isError ? { isError: !0 } : {}
2784
- }), yield {
2785
- type: "tool_use_result",
2786
- data: {
2787
- id: i,
2788
- name: n,
2789
- result: t.result,
2790
- ...t.isError ? { isError: !0 } : {}
2791
- }
2792
- };
2793
- try {
2794
- l?.onToolEnd?.({
2795
- traceId: d,
2796
- turn: e,
2797
- toolName: n,
2798
- toolUseId: i,
2799
- isError: !!t.isError,
2800
- durationMs: Date.now() - o
2801
- });
2802
- } catch {}
2803
- } catch (t) {
2804
- let r = t instanceof Error ? t.message : "Tool execution failed";
2805
- u.push({
2806
- toolUseId: i,
2807
- toolName: n,
2808
- content: r,
2809
- isError: !0
2810
- }), yield {
2811
- type: "tool_use_result",
2812
- data: {
2813
- id: i,
2814
- name: n,
2815
- result: r,
2816
- isError: !0
2817
- }
2818
- };
2819
- try {
2820
- l?.onToolEnd?.({
2821
- traceId: d,
2822
- turn: e,
2823
- toolName: n,
2824
- toolUseId: i,
2825
- isError: !0,
2826
- durationMs: Date.now() - o
2827
- });
2828
- } catch {}
2829
- }
2830
- }
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
+ });
2831
2760
  yield {
2832
2761
  type: "turn_complete",
2833
2762
  data: {}
2834
- };
2835
- let f = S.formatToolResults(u);
2836
- if (Array.isArray(f)) for (let e of f) E.push(e);
2837
- else E.push(f);
2763
+ }, R(S, v.formatToolResults(s));
2838
2764
  }
2839
- try {
2840
- l?.onChatEnd?.({
2841
- traceId: d,
2842
- sessionId: c,
2843
- totalTurns: D,
2844
- durationMs: Date.now() - f
2845
- });
2846
- } catch {}
2847
- yield {
2765
+ z(() => l?.onChatEnd?.({
2766
+ traceId: u,
2767
+ sessionId: c,
2768
+ totalTurns: C,
2769
+ durationMs: Date.now() - d
2770
+ })), yield {
2848
2771
  type: "done",
2849
2772
  data: {
2850
2773
  sessionId: c || "",
2851
- traceId: d
2774
+ traceId: u
2852
2775
  }
2853
2776
  };
2854
2777
  } catch (e) {
2855
2778
  try {
2856
2779
  l?.onChatEnd?.({
2857
- traceId: d,
2780
+ traceId: u,
2858
2781
  sessionId: c,
2859
2782
  totalTurns: 0,
2860
- durationMs: Date.now() - f,
2783
+ durationMs: Date.now() - d,
2861
2784
  error: e instanceof Error ? e.message : "Unknown error"
2862
2785
  });
2863
2786
  } catch {}
2864
- 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 {
2865
2788
  type: "error",
2866
- data: { message: S.formatError(e) }
2789
+ data: { message: v.formatError(e) }
2867
2790
  };
2868
2791
  }
2869
2792
  }
2870
2793
  //#endregion
2871
- export { b as handleAgentChat };
2794
+ export { Y as handleAgentChat };