@sqlrooms/mosaic 0.29.0-rc.7 → 0.29.0-rc.8
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.
- package/LICENSE.md +2 -1
- package/README.md +134 -0
- package/dist/MosaicSlice.d.ts +1 -0
- package/dist/MosaicSlice.d.ts.map +1 -1
- package/dist/MosaicSlice.js.map +1 -1
- package/dist/VgPlotChart.d.ts.map +1 -1
- package/dist/VgPlotChart.js +9 -3
- package/dist/VgPlotChart.js.map +1 -1
- package/dist/ai/ai.d.ts +9 -4
- package/dist/ai/ai.d.ts.map +1 -1
- package/dist/ai/ai.js +91 -49
- package/dist/ai/ai.js.map +1 -1
- package/dist/ai.d.ts.map +1 -1
- package/dist/ai.js.map +1 -1
- package/dist/charts/MosaicChart.d.ts +3 -1
- package/dist/charts/MosaicChart.d.ts.map +1 -1
- package/dist/charts/MosaicChart.js +2 -2
- package/dist/charts/MosaicChart.js.map +1 -1
- package/dist/charts/MosaicChartError.d.ts +8 -2
- package/dist/charts/MosaicChartError.d.ts.map +1 -1
- package/dist/charts/MosaicChartError.js +29 -3
- package/dist/charts/MosaicChartError.js.map +1 -1
- package/dist/charts/MosaicChartSettingsButton.d.ts +15 -0
- package/dist/charts/MosaicChartSettingsButton.d.ts.map +1 -0
- package/dist/charts/MosaicChartSettingsButton.js +7 -0
- package/dist/charts/MosaicChartSettingsButton.js.map +1 -0
- package/dist/charts/MosaicChartView.d.ts +2 -0
- package/dist/charts/MosaicChartView.d.ts.map +1 -1
- package/dist/charts/MosaicChartView.js +20 -7
- package/dist/charts/MosaicChartView.js.map +1 -1
- package/dist/charts/chart-settings/MosaicChartSettings.d.ts.map +1 -1
- package/dist/charts/chart-settings/MosaicChartSettings.js +3 -3
- package/dist/charts/chart-settings/MosaicChartSettings.js.map +1 -1
- package/dist/charts/chart-settings/MosaicChartSettingsPanel.js +1 -1
- package/dist/charts/chart-settings/MosaicChartSettingsPanel.js.map +1 -1
- package/dist/charts/chart-settings/MosaicChartTypeSelector.d.ts.map +1 -1
- package/dist/charts/chart-settings/MosaicChartTypeSelector.js +11 -4
- package/dist/charts/chart-settings/MosaicChartTypeSelector.js.map +1 -1
- package/dist/charts/chart-types/base-types.d.ts +17 -6
- package/dist/charts/chart-types/base-types.d.ts.map +1 -1
- package/dist/charts/chart-types/base-types.js +3 -0
- package/dist/charts/chart-types/base-types.js.map +1 -1
- package/dist/charts/chart-types/box-plot/renderer/BoxPlotClient.d.ts.map +1 -1
- package/dist/charts/chart-types/box-plot/renderer/BoxPlotClient.js +3 -8
- package/dist/charts/chart-types/box-plot/renderer/BoxPlotClient.js.map +1 -1
- package/dist/charts/chart-types/chart-config.d.ts +3 -1
- package/dist/charts/chart-types/chart-config.d.ts.map +1 -1
- package/dist/charts/chart-types/chart-config.js +2 -2
- package/dist/charts/chart-types/chart-config.js.map +1 -1
- package/dist/charts/chart-types/count-plot/spec.d.ts +2 -1
- package/dist/charts/chart-types/count-plot/spec.d.ts.map +1 -1
- package/dist/charts/chart-types/count-plot/spec.js +65 -34
- package/dist/charts/chart-types/count-plot/spec.js.map +1 -1
- package/dist/charts/chart-types/count-plot/tool.js +1 -1
- package/dist/charts/chart-types/count-plot/tool.js.map +1 -1
- package/dist/charts/chart-types/createDefaultChartTypes.js +2 -2
- package/dist/charts/chart-types/createDefaultChartTypes.js.map +1 -1
- package/dist/charts/chart-types/custom-spec/spec.d.ts +2 -1
- package/dist/charts/chart-types/custom-spec/spec.d.ts.map +1 -1
- package/dist/charts/chart-types/custom-spec/spec.js +16 -12
- package/dist/charts/chart-types/custom-spec/spec.js.map +1 -1
- package/dist/charts/chart-types/errors.d.ts +25 -0
- package/dist/charts/chart-types/errors.d.ts.map +1 -1
- package/dist/charts/chart-types/errors.js +38 -0
- package/dist/charts/chart-types/errors.js.map +1 -1
- package/dist/charts/chart-types/heatmap/spec.d.ts +2 -1
- package/dist/charts/chart-types/heatmap/spec.d.ts.map +1 -1
- package/dist/charts/chart-types/heatmap/spec.js +53 -21
- package/dist/charts/chart-types/heatmap/spec.js.map +1 -1
- package/dist/charts/chart-types/heatmap/tool.js +2 -2
- package/dist/charts/chart-types/heatmap/tool.js.map +1 -1
- package/dist/charts/chart-types/histogram/HistogramSettings.d.ts.map +1 -1
- package/dist/charts/chart-types/histogram/HistogramSettings.js +3 -1
- package/dist/charts/chart-types/histogram/HistogramSettings.js.map +1 -1
- package/dist/charts/chart-types/histogram/schema.d.ts +2 -0
- package/dist/charts/chart-types/histogram/schema.d.ts.map +1 -1
- package/dist/charts/chart-types/histogram/schema.js +1 -0
- package/dist/charts/chart-types/histogram/schema.js.map +1 -1
- package/dist/charts/chart-types/histogram/spec.d.ts +2 -1
- package/dist/charts/chart-types/histogram/spec.d.ts.map +1 -1
- package/dist/charts/chart-types/histogram/spec.js +50 -27
- package/dist/charts/chart-types/histogram/spec.js.map +1 -1
- package/dist/charts/chart-types/histogram/tool.d.ts +2 -0
- package/dist/charts/chart-types/histogram/tool.d.ts.map +1 -1
- package/dist/charts/chart-types/histogram/tool.js +1 -1
- package/dist/charts/chart-types/histogram/tool.js.map +1 -1
- package/dist/charts/chart-types/index.d.ts +4 -4
- package/dist/charts/chart-types/index.js +4 -4
- package/dist/charts/chart-types/index.js.map +1 -1
- package/dist/charts/chart-types/line-chart/LineChartSettings.d.ts.map +1 -1
- package/dist/charts/chart-types/line-chart/LineChartSettings.js +4 -13
- package/dist/charts/chart-types/line-chart/LineChartSettings.js.map +1 -1
- package/dist/charts/chart-types/line-chart/LineChartXFieldSelector.d.ts +7 -0
- package/dist/charts/chart-types/line-chart/LineChartXFieldSelector.d.ts.map +1 -0
- package/dist/charts/chart-types/line-chart/LineChartXFieldSelector.js +22 -0
- package/dist/charts/chart-types/line-chart/LineChartXFieldSelector.js.map +1 -0
- package/dist/charts/chart-types/line-chart/LineChartYFieldsSelector.d.ts +7 -0
- package/dist/charts/chart-types/line-chart/LineChartYFieldsSelector.d.ts.map +1 -0
- package/dist/charts/chart-types/line-chart/LineChartYFieldsSelector.js +42 -0
- package/dist/charts/chart-types/line-chart/LineChartYFieldsSelector.js.map +1 -0
- package/dist/charts/chart-types/line-chart/schema.d.ts +2 -0
- package/dist/charts/chart-types/line-chart/schema.d.ts.map +1 -1
- package/dist/charts/chart-types/line-chart/schema.js +5 -0
- package/dist/charts/chart-types/line-chart/schema.js.map +1 -1
- package/dist/charts/chart-types/line-chart/spec.d.ts +2 -1
- package/dist/charts/chart-types/line-chart/spec.d.ts.map +1 -1
- package/dist/charts/chart-types/line-chart/spec.js +97 -65
- package/dist/charts/chart-types/line-chart/spec.js.map +1 -1
- package/dist/charts/chart-types/line-chart/tool.d.ts +2 -0
- package/dist/charts/chart-types/line-chart/tool.d.ts.map +1 -1
- package/dist/charts/chart-types/line-chart/tool.js +1 -1
- package/dist/charts/chart-types/line-chart/tool.js.map +1 -1
- package/dist/charts/chart-types/line-chart/utils.d.ts +7 -0
- package/dist/charts/chart-types/line-chart/utils.d.ts.map +1 -0
- package/dist/charts/chart-types/line-chart/utils.js +17 -0
- package/dist/charts/chart-types/line-chart/utils.js.map +1 -0
- package/dist/charts/chart-types/mosaicChartTypes.d.ts +4 -2
- package/dist/charts/chart-types/mosaicChartTypes.d.ts.map +1 -1
- package/dist/charts/chart-types/mosaicChartTypes.js +2 -2
- package/dist/charts/chart-types/mosaicChartTypes.js.map +1 -1
- package/dist/charts/chart-types/scatter-plot/ScatterPlotSettings.d.ts +3 -0
- package/dist/charts/chart-types/scatter-plot/ScatterPlotSettings.d.ts.map +1 -0
- package/dist/charts/chart-types/{bubble-chart/BubbleChartSettings.js → scatter-plot/ScatterPlotSettings.js} +4 -4
- package/dist/charts/chart-types/scatter-plot/ScatterPlotSettings.js.map +1 -0
- package/dist/charts/chart-types/scatter-plot/definition.d.ts +4 -0
- package/dist/charts/chart-types/scatter-plot/definition.d.ts.map +1 -0
- package/dist/charts/chart-types/scatter-plot/definition.js +24 -0
- package/dist/charts/chart-types/scatter-plot/definition.js.map +1 -0
- package/dist/charts/chart-types/{bubble-chart → scatter-plot}/schema.d.ts +5 -5
- package/dist/charts/chart-types/scatter-plot/schema.d.ts.map +1 -0
- package/dist/charts/chart-types/{bubble-chart → scatter-plot}/schema.js +5 -5
- package/dist/charts/chart-types/scatter-plot/schema.js.map +1 -0
- package/dist/charts/chart-types/scatter-plot/spec.d.ts +5 -0
- package/dist/charts/chart-types/scatter-plot/spec.d.ts.map +1 -0
- package/dist/charts/chart-types/scatter-plot/spec.js +81 -0
- package/dist/charts/chart-types/scatter-plot/spec.js.map +1 -0
- package/dist/charts/chart-types/{bubble-chart → scatter-plot}/tool.d.ts +3 -3
- package/dist/charts/chart-types/{bubble-chart → scatter-plot}/tool.d.ts.map +1 -1
- package/dist/charts/chart-types/{bubble-chart → scatter-plot}/tool.js +17 -13
- package/dist/charts/chart-types/scatter-plot/tool.js.map +1 -0
- package/dist/charts/dashboard/MosaicDashboardChartHeaderActions.d.ts.map +1 -1
- package/dist/charts/dashboard/MosaicDashboardChartHeaderActions.js +12 -5
- package/dist/charts/dashboard/MosaicDashboardChartHeaderActions.js.map +1 -1
- package/dist/charts/dashboard/MosaicDashboardChartRenderer.d.ts.map +1 -1
- package/dist/charts/dashboard/MosaicDashboardChartRenderer.js +2 -2
- package/dist/charts/dashboard/MosaicDashboardChartRenderer.js.map +1 -1
- package/dist/charts/useChartDataPolicy.d.ts.map +1 -1
- package/dist/charts/useChartDataPolicy.js +2 -1
- package/dist/charts/useChartDataPolicy.js.map +1 -1
- package/dist/charts/useChartPanelClients.d.ts +8 -0
- package/dist/charts/useChartPanelClients.d.ts.map +1 -0
- package/dist/charts/useChartPanelClients.js +22 -0
- package/dist/charts/useChartPanelClients.js.map +1 -0
- package/dist/charts/useMosaicChartRenderContext.d.ts +2 -3
- package/dist/charts/useMosaicChartRenderContext.d.ts.map +1 -1
- package/dist/charts/useMosaicChartRenderContext.js +15 -15
- package/dist/charts/useMosaicChartRenderContext.js.map +1 -1
- package/dist/charts/worksheet/ChartBlockHeader.d.ts.map +1 -1
- package/dist/charts/worksheet/ChartBlockHeader.js +4 -3
- package/dist/charts/worksheet/ChartBlockHeader.js.map +1 -1
- package/dist/charts/worksheet/ChartBlockRenderer.d.ts.map +1 -1
- package/dist/charts/worksheet/ChartBlockRenderer.js +3 -13
- package/dist/charts/worksheet/ChartBlockRenderer.js.map +1 -1
- package/dist/column-types-utils.d.ts.map +1 -1
- package/dist/column-types-utils.js +12 -4
- package/dist/column-types-utils.js.map +1 -1
- package/dist/components/AggregationSelector.d.ts.map +1 -1
- package/dist/components/AggregationSelector.js +9 -2
- package/dist/components/AggregationSelector.js.map +1 -1
- package/dist/components/BlockCaptionEditor.d.ts +20 -0
- package/dist/components/BlockCaptionEditor.d.ts.map +1 -0
- package/dist/components/BlockCaptionEditor.js +15 -0
- package/dist/components/BlockCaptionEditor.js.map +1 -0
- package/dist/components/ColorSelector.d.ts +12 -0
- package/dist/components/ColorSelector.d.ts.map +1 -0
- package/dist/components/ColorSelector.js +14 -0
- package/dist/components/ColorSelector.js.map +1 -0
- package/dist/components/ColumnSelector.d.ts +1 -0
- package/dist/components/ColumnSelector.d.ts.map +1 -1
- package/dist/components/ColumnSelector.js +2 -2
- package/dist/components/ColumnSelector.js.map +1 -1
- package/dist/components/Combobox.d.ts +45 -0
- package/dist/components/Combobox.d.ts.map +1 -0
- package/dist/components/Combobox.js +58 -0
- package/dist/components/Combobox.js.map +1 -0
- package/dist/components/FieldSelectorInput.d.ts +1 -0
- package/dist/components/FieldSelectorInput.d.ts.map +1 -1
- package/dist/components/FieldSelectorInput.js +4 -9
- package/dist/components/FieldSelectorInput.js.map +1 -1
- package/dist/components/MultiFieldSelector.d.ts +4 -1
- package/dist/components/MultiFieldSelector.d.ts.map +1 -1
- package/dist/components/MultiFieldSelector.js +4 -13
- package/dist/components/MultiFieldSelector.js.map +1 -1
- package/dist/components/TemporalGranularitySelector.d.ts.map +1 -1
- package/dist/components/TemporalGranularitySelector.js +13 -9
- package/dist/components/TemporalGranularitySelector.js.map +1 -1
- package/dist/components/useCombobox.d.ts +23 -0
- package/dist/components/useCombobox.d.ts.map +1 -0
- package/dist/components/useCombobox.js +26 -0
- package/dist/components/useCombobox.js.map +1 -0
- package/dist/constants/chart-colors.d.ts +3 -0
- package/dist/constants/chart-colors.d.ts.map +1 -0
- package/dist/constants/chart-colors.js +5 -0
- package/dist/constants/chart-colors.js.map +1 -0
- package/dist/dashboard/DefaultMosaicDashboardBlock.d.ts +2 -1
- package/dist/dashboard/DefaultMosaicDashboardBlock.d.ts.map +1 -1
- package/dist/dashboard/DefaultMosaicDashboardBlock.js +1 -1
- package/dist/dashboard/DefaultMosaicDashboardBlock.js.map +1 -1
- package/dist/dashboard/MosaicDashboardSlice.d.ts +22 -4
- package/dist/dashboard/MosaicDashboardSlice.d.ts.map +1 -1
- package/dist/dashboard/MosaicDashboardSlice.js +55 -0
- package/dist/dashboard/MosaicDashboardSlice.js.map +1 -1
- package/dist/dashboard/components/ResetFiltersButton.d.ts +14 -0
- package/dist/dashboard/components/ResetFiltersButton.d.ts.map +1 -0
- package/dist/dashboard/components/ResetFiltersButton.js +15 -0
- package/dist/dashboard/components/ResetFiltersButton.js.map +1 -0
- package/dist/dashboard/dashboard-types.d.ts +9 -3
- package/dist/dashboard/dashboard-types.d.ts.map +1 -1
- package/dist/dashboard/hooks/useDashboardResetFilters.d.ts +14 -0
- package/dist/dashboard/hooks/useDashboardResetFilters.d.ts.map +1 -0
- package/dist/dashboard/hooks/useDashboardResetFilters.js +39 -0
- package/dist/dashboard/hooks/useDashboardResetFilters.js.map +1 -0
- package/dist/dashboard/hooks/usePanelResetFilters.d.ts +16 -0
- package/dist/dashboard/hooks/usePanelResetFilters.d.ts.map +1 -0
- package/dist/dashboard/hooks/usePanelResetFilters.js +47 -0
- package/dist/dashboard/hooks/usePanelResetFilters.js.map +1 -0
- package/dist/dashboard/toolbar/MosaicDashboardAddPanelDropdown.d.ts.map +1 -1
- package/dist/dashboard/toolbar/MosaicDashboardAddPanelDropdown.js +3 -3
- package/dist/dashboard/toolbar/MosaicDashboardAddPanelDropdown.js.map +1 -1
- package/dist/dashboard/toolbar/MosaicDashboardDataTableSelector.d.ts +7 -0
- package/dist/dashboard/toolbar/MosaicDashboardDataTableSelector.d.ts.map +1 -0
- package/dist/dashboard/toolbar/MosaicDashboardDataTableSelector.js +18 -0
- package/dist/dashboard/toolbar/MosaicDashboardDataTableSelector.js.map +1 -0
- package/dist/dashboard/toolbar/MosaicDashboardResetFiltersButton.d.ts.map +1 -1
- package/dist/dashboard/toolbar/MosaicDashboardResetFiltersButton.js +4 -32
- package/dist/dashboard/toolbar/MosaicDashboardResetFiltersButton.js.map +1 -1
- package/dist/dashboard/toolbar/MosaicDashboardToolbar.d.ts +2 -2
- package/dist/dashboard/toolbar/MosaicDashboardToolbar.d.ts.map +1 -1
- package/dist/dashboard/toolbar/MosaicDashboardToolbar.js +12 -10
- package/dist/dashboard/toolbar/MosaicDashboardToolbar.js.map +1 -1
- package/dist/dashboard/usePanelClientRegistration.d.ts +7 -0
- package/dist/dashboard/usePanelClientRegistration.d.ts.map +1 -0
- package/dist/dashboard/usePanelClientRegistration.js +30 -0
- package/dist/dashboard/usePanelClientRegistration.js.map +1 -0
- package/dist/dashboard/usePanelClients.d.ts +7 -0
- package/dist/dashboard/usePanelClients.d.ts.map +1 -0
- package/dist/dashboard/usePanelClients.js +13 -0
- package/dist/dashboard/usePanelClients.js.map +1 -0
- package/dist/data-table-explorer/DataTableExplorer.d.ts +4 -2
- package/dist/data-table-explorer/DataTableExplorer.d.ts.map +1 -1
- package/dist/data-table-explorer/DataTableExplorer.js +4 -4
- package/dist/data-table-explorer/DataTableExplorer.js.map +1 -1
- package/dist/data-table-explorer/DataTableExplorerCategoryClient.d.ts.map +1 -1
- package/dist/data-table-explorer/DataTableExplorerCategoryClient.js +1 -0
- package/dist/data-table-explorer/DataTableExplorerCategoryClient.js.map +1 -1
- package/dist/data-table-explorer/createDataTableExplorerStore.d.ts +3 -0
- package/dist/data-table-explorer/createDataTableExplorerStore.d.ts.map +1 -1
- package/dist/data-table-explorer/createDataTableExplorerStore.js +6 -0
- package/dist/data-table-explorer/createDataTableExplorerStore.js.map +1 -1
- package/dist/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerHeaderActions.d.ts +4 -0
- package/dist/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerHeaderActions.d.ts.map +1 -0
- package/dist/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerHeaderActions.js +13 -0
- package/dist/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerHeaderActions.js.map +1 -0
- package/dist/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerPanelRenderer.d.ts.map +1 -1
- package/dist/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerPanelRenderer.js +22 -7
- package/dist/data-table-explorer/dashboard/MosaicDashboardDataTableExplorerPanelRenderer.js.map +1 -1
- package/dist/data-table-explorer/dashboard/useDataTableExplorerPanelClients.d.ts +13 -0
- package/dist/data-table-explorer/dashboard/useDataTableExplorerPanelClients.d.ts.map +1 -0
- package/dist/data-table-explorer/dashboard/useDataTableExplorerPanelClients.js +32 -0
- package/dist/data-table-explorer/dashboard/useDataTableExplorerPanelClients.js.map +1 -0
- package/dist/data-table-explorer/dataTableExplorerController.d.ts +5 -1
- package/dist/data-table-explorer/dataTableExplorerController.d.ts.map +1 -1
- package/dist/data-table-explorer/dataTableExplorerController.js +5 -2
- package/dist/data-table-explorer/dataTableExplorerController.js.map +1 -1
- package/dist/data-table-explorer/hooks/useDataTableExplorerColumns.d.ts +12 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerColumns.d.ts.map +1 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerColumns.js +19 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerColumns.js.map +1 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerLifecycles.d.ts +30 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerLifecycles.d.ts.map +1 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerLifecycles.js +120 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerLifecycles.js.map +1 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerQueryState.d.ts +28 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerQueryState.d.ts.map +1 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerQueryState.js +40 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerQueryState.js.map +1 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerSelection.d.ts +13 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerSelection.d.ts.map +1 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerSelection.js +40 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerSelection.js.map +1 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerStatus.d.ts +18 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerStatus.d.ts.map +1 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerStatus.js +23 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerStatus.js.map +1 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerStoreState.d.ts +27 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerStoreState.d.ts.map +1 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerStoreState.js +28 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerStoreState.js.map +1 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerVisiblePage.d.ts +15 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerVisiblePage.d.ts.map +1 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerVisiblePage.js +21 -0
- package/dist/data-table-explorer/hooks/useDataTableExplorerVisiblePage.js.map +1 -0
- package/dist/data-table-explorer/types.d.ts +6 -3
- package/dist/data-table-explorer/types.d.ts.map +1 -1
- package/dist/data-table-explorer/types.js.map +1 -1
- package/dist/data-table-explorer/useDataTableExplorer.d.ts.map +1 -1
- package/dist/data-table-explorer/useDataTableExplorer.js +12 -275
- package/dist/data-table-explorer/useDataTableExplorer.js.map +1 -1
- package/dist/data-table-explorer/worksheet/DataTableBlockHeader.d.ts +1 -0
- package/dist/data-table-explorer/worksheet/DataTableBlockHeader.d.ts.map +1 -1
- package/dist/data-table-explorer/worksheet/DataTableBlockHeader.js +4 -2
- package/dist/data-table-explorer/worksheet/DataTableBlockHeader.js.map +1 -1
- package/dist/data-table-explorer/worksheet/DataTableBlockRenderer.d.ts.map +1 -1
- package/dist/data-table-explorer/worksheet/DataTableBlockRenderer.js +3 -3
- package/dist/data-table-explorer/worksheet/DataTableBlockRenderer.js.map +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/useVgPlotChartRender.d.ts.map +1 -1
- package/dist/useVgPlotChartRender.js +125 -24
- package/dist/useVgPlotChartRender.js.map +1 -1
- package/dist/useVgPlotChartRetention.d.ts +11 -0
- package/dist/useVgPlotChartRetention.d.ts.map +1 -1
- package/dist/useVgPlotChartRetention.js.map +1 -1
- package/package.json +14 -14
- package/dist/charts/chart-types/bubble-chart/BubbleChartSettings.d.ts +0 -3
- package/dist/charts/chart-types/bubble-chart/BubbleChartSettings.d.ts.map +0 -1
- package/dist/charts/chart-types/bubble-chart/BubbleChartSettings.js.map +0 -1
- package/dist/charts/chart-types/bubble-chart/definition.d.ts +0 -4
- package/dist/charts/chart-types/bubble-chart/definition.d.ts.map +0 -1
- package/dist/charts/chart-types/bubble-chart/definition.js +0 -24
- package/dist/charts/chart-types/bubble-chart/definition.js.map +0 -1
- package/dist/charts/chart-types/bubble-chart/schema.d.ts.map +0 -1
- package/dist/charts/chart-types/bubble-chart/schema.js.map +0 -1
- package/dist/charts/chart-types/bubble-chart/spec.d.ts +0 -4
- package/dist/charts/chart-types/bubble-chart/spec.d.ts.map +0 -1
- package/dist/charts/chart-types/bubble-chart/spec.js +0 -31
- package/dist/charts/chart-types/bubble-chart/spec.js.map +0 -1
- package/dist/charts/chart-types/bubble-chart/tool.js.map +0 -1
- package/dist/hooks/useDataTable.d.ts +0 -3
- package/dist/hooks/useDataTable.d.ts.map +0 -1
- package/dist/hooks/useDataTable.js +0 -28
- package/dist/hooks/useDataTable.js.map +0 -1
package/dist/ai/ai.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* @packageDocumentation
|
|
8
8
|
*/
|
|
9
|
+
import { resolveTableReference } from '@sqlrooms/duckdb';
|
|
9
10
|
import { ToolLoopAgent, stepCountIs, tool, } from 'ai';
|
|
10
11
|
import { z } from 'zod';
|
|
11
12
|
import { createChartTools, createDefaultChartTypes, createListPanelsTool, createDataTableExplorerTool, createRemovePanelTool, } from '../charts/chart-types';
|
|
@@ -26,7 +27,7 @@ Dashboard authoring:
|
|
|
26
27
|
- "update the histogram to use 30 bins"
|
|
27
28
|
|
|
28
29
|
**Individual dashboard chart tools:**
|
|
29
|
-
- create_dashboard_histogram, create_dashboard_line_chart, create_dashboard_box_plot,
|
|
30
|
+
- create_dashboard_histogram, create_dashboard_line_chart, create_dashboard_box_plot, create_dashboard_scatter_plot, create_dashboard_count_plot, create_dashboard_heatmap
|
|
30
31
|
- Each chart type has its own tool with specific parameters.
|
|
31
32
|
- For line charts with aggregation, use yFields array with {field: string, aggregate: "sum"|"avg"|"min"|"max"}.
|
|
32
33
|
- Set xInterval for temporal binning (year, month, day, hour, etc.).
|
|
@@ -34,7 +35,7 @@ Dashboard authoring:
|
|
|
34
35
|
- Use \`set_dashboard_vgplot\` with complete JSON only when no chart tool fits your needs.
|
|
35
36
|
- When calling \`create_dashboard_artifact\`, \`layoutType\` may be \`grid\` or \`dock\`; omitted values default to \`grid\`.
|
|
36
37
|
- Ensure specs are valid JSON objects compatible with https://idl.uw.edu/mosaic/schema/latest.json.
|
|
37
|
-
- \`list_dashboard_panels\` includes runtime issues when a chart failed. Use those issues to repair panels in place: convert too-large
|
|
38
|
+
- \`list_dashboard_panels\` includes runtime issues when a chart failed. Use those issues to repair panels in place: convert too-large scatter charts to heatmaps, add \`xInterval\` to too-large line charts, and inspect columns/settings for SQL errors.
|
|
38
39
|
`;
|
|
39
40
|
export const DASHBOARD_AGENT_INSTRUCTIONS = `You are a dashboard builder agent that creates and modifies interactive data dashboards.
|
|
40
41
|
|
|
@@ -48,7 +49,7 @@ You analyze data and create insightful dashboards with multiple visualizations (
|
|
|
48
49
|
- create_dashboard_histogram - distribution of numeric values (always safe, aggregates automatically)
|
|
49
50
|
- create_dashboard_line_chart - trends over time or ordered variable (use with aggregations for >10k rows)
|
|
50
51
|
- create_dashboard_box_plot - compare distributions across categories
|
|
51
|
-
-
|
|
52
|
+
- create_dashboard_scatter_plot - relationship between two numeric columns (avoid for >10k rows, use heatmap instead)
|
|
52
53
|
- create_dashboard_count_plot - frequency of categorical values (always safe, aggregates automatically)
|
|
53
54
|
- create_dashboard_heatmap - density/patterns across two dimensions (preferred for large datasets)
|
|
54
55
|
|
|
@@ -82,7 +83,7 @@ When user asks to discover insights:
|
|
|
82
83
|
- Find correlations: CORR(col1, col2)
|
|
83
84
|
- Identify outliers and patterns
|
|
84
85
|
2. Create targeted charts based on discoveries:
|
|
85
|
-
- If dataset has >10k rows: avoid
|
|
86
|
+
- If dataset has >10k rows: avoid scatter charts and unaggregated line charts
|
|
86
87
|
- Use histogram, count plot, heatmap, or aggregated visualizations instead
|
|
87
88
|
3. Stop when dashboard tells coherent story
|
|
88
89
|
|
|
@@ -107,8 +108,8 @@ To update existing panels:
|
|
|
107
108
|
|
|
108
109
|
## Best Practices
|
|
109
110
|
|
|
110
|
-
- **Avoid unaggregated charts for large datasets:** For datasets >10k rows, DO NOT use
|
|
111
|
-
- For scatter
|
|
111
|
+
- **Avoid unaggregated charts for large datasets:** For datasets >10k rows, DO NOT use scatter charts or line charts without aggregations. Use aggregated alternatives instead:
|
|
112
|
+
- For scatter plots: use heatmap or binned aggregations
|
|
112
113
|
- For line charts: use GROUP BY with time buckets or aggregations
|
|
113
114
|
- Histograms and count plots are always safe (they aggregate automatically)
|
|
114
115
|
- **Check before update:** Always call list_dashboard_panels before updating/removing panels
|
|
@@ -157,19 +158,46 @@ class DashboardAgentException extends Error {
|
|
|
157
158
|
function getTablesWithColumns(state, adapter) {
|
|
158
159
|
return adapter
|
|
159
160
|
.getTables(state)
|
|
161
|
+
.map(normalizeDashboardAiTable)
|
|
160
162
|
.filter((table) => table.columns && table.columns.length > 0);
|
|
161
163
|
}
|
|
162
|
-
function
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
164
|
+
function normalizeDashboardAiTable(table) {
|
|
165
|
+
const { qualifiedName } = table;
|
|
166
|
+
const tableId = qualifiedName.toString();
|
|
167
|
+
return {
|
|
168
|
+
table: qualifiedName,
|
|
169
|
+
tableName: qualifiedName.table,
|
|
170
|
+
tableId,
|
|
171
|
+
columns: table.columns,
|
|
172
|
+
rowCount: table.rowCount,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
function formatAmbiguousTableError(tableName, matches) {
|
|
176
|
+
return `Ambiguous table "${tableName}". Matching tables: ${matches
|
|
177
|
+
.map((table) => table.tableId)
|
|
178
|
+
.join(', ')}.`;
|
|
179
|
+
}
|
|
180
|
+
function getResolvedTable(table) {
|
|
181
|
+
if (!table.columns) {
|
|
182
|
+
throw new Error(`Table "${table.tableName}" has no column metadata.`);
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
tableName: table.tableId,
|
|
186
|
+
qualifiedName: table.table,
|
|
187
|
+
columns: table.columns.map((column) => ({
|
|
188
|
+
name: column.name,
|
|
189
|
+
type: column.type,
|
|
190
|
+
})),
|
|
191
|
+
};
|
|
170
192
|
}
|
|
171
193
|
function formatAvailableTables(tables) {
|
|
172
|
-
return tables
|
|
194
|
+
return (tables
|
|
195
|
+
.map((table) => {
|
|
196
|
+
return table.tableId === table.tableName
|
|
197
|
+
? table.tableName
|
|
198
|
+
: `${table.tableName} (${table.tableId})`;
|
|
199
|
+
})
|
|
200
|
+
.join(', ') || '(none)');
|
|
173
201
|
}
|
|
174
202
|
export function createDashboardToolDeps({ store, adapter, }) {
|
|
175
203
|
const resolveArtifact = (artifactId, createIfMissing, context) => {
|
|
@@ -202,34 +230,39 @@ export function createDashboardToolDeps({ store, adapter, }) {
|
|
|
202
230
|
const state = store.getState();
|
|
203
231
|
const tables = getTablesWithColumns(state, adapter);
|
|
204
232
|
const dashboard = adapter.getDashboard(state, artifactId);
|
|
205
|
-
const explicitTableName = tableName
|
|
233
|
+
const explicitTableName = typeof tableName === 'string' ? tableName.trim() || undefined : tableName;
|
|
206
234
|
if (explicitTableName) {
|
|
207
|
-
const
|
|
208
|
-
if (
|
|
209
|
-
|
|
235
|
+
const { table, ambiguousMatches } = resolveTableReference(tables, explicitTableName);
|
|
236
|
+
if (ambiguousMatches) {
|
|
237
|
+
const requestedTableName = typeof explicitTableName === 'string'
|
|
238
|
+
? explicitTableName
|
|
239
|
+
: explicitTableName.toString();
|
|
240
|
+
throw new Error(formatAmbiguousTableError(requestedTableName, ambiguousMatches));
|
|
241
|
+
}
|
|
242
|
+
if (!table) {
|
|
243
|
+
const requestedTableName = typeof explicitTableName === 'string'
|
|
244
|
+
? explicitTableName
|
|
245
|
+
: explicitTableName.toString();
|
|
246
|
+
throw new Error(`Unknown table "${requestedTableName}". Available tables: ${formatAvailableTables(tables)}.`);
|
|
210
247
|
}
|
|
211
|
-
|
|
212
|
-
|
|
248
|
+
const resolvedTable = getResolvedTable(table);
|
|
249
|
+
adapter.setSelectedTable(state, artifactId, resolvedTable.tableName);
|
|
250
|
+
return resolvedTable;
|
|
213
251
|
}
|
|
214
252
|
if (dashboard?.selectedTable) {
|
|
215
|
-
const
|
|
216
|
-
if (
|
|
217
|
-
return
|
|
253
|
+
const { table } = resolveTableReference(tables, dashboard.selectedTable);
|
|
254
|
+
if (table) {
|
|
255
|
+
return getResolvedTable(table);
|
|
218
256
|
}
|
|
219
257
|
}
|
|
220
258
|
if (tables.length === 1) {
|
|
221
259
|
const onlyTable = tables[0];
|
|
222
|
-
if (!onlyTable
|
|
260
|
+
if (!onlyTable) {
|
|
223
261
|
throw new Error('The only available table has no column metadata.');
|
|
224
262
|
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
columns: onlyTable.columns.map((column) => ({
|
|
229
|
-
name: column.name,
|
|
230
|
-
type: column.type,
|
|
231
|
-
})),
|
|
232
|
-
};
|
|
263
|
+
const resolvedTable = getResolvedTable(onlyTable);
|
|
264
|
+
adapter.setSelectedTable(state, artifactId, resolvedTable.tableName);
|
|
265
|
+
return resolvedTable;
|
|
233
266
|
}
|
|
234
267
|
throw new Error(`No dashboard table is selected. Provide tableName using one of: ${formatAvailableTables(tables)}.`);
|
|
235
268
|
};
|
|
@@ -305,35 +338,43 @@ export function createDashboardAiTools({ store, adapter, chartTypes, extraTools,
|
|
|
305
338
|
};
|
|
306
339
|
}
|
|
307
340
|
function buildAgentPrompt(userPrompt, tableName, state, adapter) {
|
|
308
|
-
const table = adapter
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
341
|
+
const table = resolveTableReference(adapter.getTables(state).map(normalizeDashboardAiTable), tableName).table;
|
|
342
|
+
const resolvedTableName = table ? table.tableId : tableName;
|
|
343
|
+
const tableIdInfo = table && table.tableName !== resolvedTableName
|
|
344
|
+
? `\n- Table ID for tool calls: ${resolvedTableName}`
|
|
345
|
+
: '';
|
|
346
|
+
const columnNames = table?.columns
|
|
347
|
+
?.map((column) => column.type ? `${column.name} (${column.type})` : column.name)
|
|
348
|
+
.join(', ') || 'unknown';
|
|
312
349
|
const rowInfo = table?.rowCount !== undefined ? `Approximate rows: ${table.rowCount}` : '';
|
|
313
|
-
return `Analyze the "${tableName}" table.
|
|
350
|
+
return `Analyze the "${table?.tableName ?? tableName}" table.
|
|
314
351
|
|
|
315
352
|
Table info:
|
|
316
|
-
- Columns: ${columnNames}${rowInfo ? `\n- ${rowInfo}` : ''}
|
|
353
|
+
- Columns: ${columnNames}${tableIdInfo}${rowInfo ? `\n- ${rowInfo}` : ''}
|
|
317
354
|
|
|
318
355
|
User request: ${userPrompt}
|
|
319
356
|
|
|
320
357
|
Focus on discovering meaningful patterns and creating visualizations that tell a clear story.`;
|
|
321
358
|
}
|
|
322
359
|
function validateTableExists(state, adapter, tableName) {
|
|
323
|
-
const tables = adapter.getTables(state);
|
|
324
|
-
const table = tables
|
|
360
|
+
const tables = adapter.getTables(state).map(normalizeDashboardAiTable);
|
|
361
|
+
const { table, ambiguousMatches } = resolveTableReference(tables, tableName);
|
|
362
|
+
if (ambiguousMatches) {
|
|
363
|
+
throw new DashboardAgentException(formatAmbiguousTableError(tableName, ambiguousMatches));
|
|
364
|
+
}
|
|
325
365
|
if (!table) {
|
|
326
366
|
throw new DashboardAgentException(`Table "${tableName}" not found. Available tables: ${formatAvailableTables(tables)}`);
|
|
327
367
|
}
|
|
368
|
+
return table;
|
|
328
369
|
}
|
|
329
|
-
function getOrCreateDashboard(state, adapter,
|
|
370
|
+
function getOrCreateDashboard(state, adapter, displayTableName, dashboardTitle) {
|
|
330
371
|
const dashboardId = adapter.getCurrentDashboardArtifactId(state);
|
|
331
372
|
if (dashboardId) {
|
|
332
373
|
adapter.ensureDashboard(state, dashboardId);
|
|
333
374
|
return dashboardId;
|
|
334
375
|
}
|
|
335
376
|
const suggestedTitle = dashboardTitle ||
|
|
336
|
-
`${
|
|
377
|
+
`${displayTableName.charAt(0).toUpperCase() + displayTableName.slice(1)} Insights`;
|
|
337
378
|
const newDashboardId = adapter.createDashboardArtifact(state, suggestedTitle, 'grid');
|
|
338
379
|
adapter.setCurrentArtifact(state, newDashboardId);
|
|
339
380
|
return newDashboardId;
|
|
@@ -366,14 +407,15 @@ IMPORTANT: Always provide tableName parameter when the user mentions a specific
|
|
|
366
407
|
let dashboardId = '';
|
|
367
408
|
try {
|
|
368
409
|
const state = store.getState();
|
|
369
|
-
validateTableExists(state, adapter, tableName);
|
|
370
|
-
|
|
371
|
-
|
|
410
|
+
const table = validateTableExists(state, adapter, tableName);
|
|
411
|
+
const resolvedTableName = table.tableId;
|
|
412
|
+
dashboardId = getOrCreateDashboard(state, adapter, table.tableName, dashboardTitle);
|
|
413
|
+
adapter.setSelectedTable(state, dashboardId, resolvedTableName);
|
|
372
414
|
const queryTools = options.createQueryTools?.({ store });
|
|
373
415
|
const dashboardAgent = new ToolLoopAgent({
|
|
374
416
|
model: options.getModel({ state }),
|
|
375
417
|
tools: {
|
|
376
|
-
...(queryTools
|
|
418
|
+
...(queryTools ?? {}),
|
|
377
419
|
...createDashboardAiTools({
|
|
378
420
|
store,
|
|
379
421
|
adapter,
|
|
@@ -387,13 +429,13 @@ IMPORTANT: Always provide tableName parameter when the user mentions a specific
|
|
|
387
429
|
});
|
|
388
430
|
const result = await options.runSubAgent({
|
|
389
431
|
agent: dashboardAgent,
|
|
390
|
-
prompt: buildAgentPrompt(prompt,
|
|
432
|
+
prompt: buildAgentPrompt(prompt, resolvedTableName, state, adapter),
|
|
391
433
|
store,
|
|
392
434
|
parentToolCallId: toolOptions?.toolCallId || '',
|
|
393
435
|
abortSignal: toolOptions?.abortSignal,
|
|
394
436
|
});
|
|
395
437
|
const finalState = store.getState();
|
|
396
|
-
const metadata = calculateAgentMetadata(finalState, adapter, dashboardId,
|
|
438
|
+
const metadata = calculateAgentMetadata(finalState, adapter, dashboardId, resolvedTableName, result.agentToolCalls || []);
|
|
397
439
|
return {
|
|
398
440
|
success: true,
|
|
399
441
|
finalOutput: result.finalOutput || 'Dashboard created successfully.',
|
package/dist/ai/ai.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../../src/ai/ai.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAGL,aAAa,EACb,WAAW,EACX,IAAI,GACL,MAAM,IAAI,CA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MAAM,QAAQ,GAAG,sBAAsB,CACrC,UAAU,EACV,OAAO,EACP,WAAW,EACX,SAAS,EACT,MAAM,CAAC,cAAc,IAAI,EAAE,CAC5B,CAAC;gBAEF,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,iCAAiC;oBACpE,WAAW;oBACX,QAAQ;iBACT,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACzD,MAAM,eAAe,GACnB,KAAK,YAAY,uBAAuB;oBACtC,CAAC,CAAC,YAAY;oBACd,CAAC,CAAC,mCAAmC,CAAC;gBAE1C,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,WAAW,EAAE,eAAe;oBAC5B,WAAW;oBACX,KAAK,EAAE,YAAY;iBACpB,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Reusable AI helpers for Mosaic dashboards.\n *\n * Host apps provide a narrow adapter for their store/artifact model; Mosaic owns\n * the dashboard tool behavior and prompts.\n *\n * @packageDocumentation\n */\n\nimport {\n type LanguageModel,\n type Tool,\n ToolLoopAgent,\n stepCountIs,\n tool,\n} from 'ai';\nimport {z} from 'zod';\nimport {\n createChartTools,\n createDefaultChartTypes,\n createListPanelsTool,\n createDataTableExplorerTool,\n createRemovePanelTool,\n type ChartBuilderColumn,\n type ChartToolExecutionContext,\n type DashboardToolDeps,\n type PanelPatch,\n type ChartTypeDefinition,\n} from '../charts/chart-types';\nimport type {\n MosaicDashboardEntry,\n MosaicDashboardPanelConfig,\n} from '../dashboard/dashboard-types';\nimport type {MosaicDashboardLayoutType} from '../dashboard/core-types';\nimport {\n DEFAULT_CHART_MAX_DATA_POINTS,\n type ChartRuntimeIssue,\n} from '../chart-runtime';\n\nexport type {ChartToolExecutionContext} from '../charts/chart-types';\n\nexport type DashboardAiStore<TState> = {\n getState: () => TState;\n};\n\nexport type DashboardAiTable = {\n tableName: string;\n columns?: ChartBuilderColumn[];\n rowCount?: number;\n};\n\nexport type DashboardAiAdapter<TState> = {\n getTables: (state: TState) => DashboardAiTable[];\n hasRunContext?: (\n state: TState,\n context?: ChartToolExecutionContext,\n ) => boolean;\n resolveContextDashboardArtifactId?: (\n state: TState,\n context?: ChartToolExecutionContext,\n ) => string | undefined;\n makeDashboardPrimaryForRun?: (\n state: TState,\n dashboardId: string,\n context?: ChartToolExecutionContext,\n ) => void;\n getCurrentDashboardArtifactId: (state: TState) => string | undefined;\n createDashboardArtifact: (\n state: TState,\n title?: string,\n layoutType?: MosaicDashboardLayoutType,\n ) => string;\n isDashboardArtifact: (state: TState, artifactId: string) => boolean;\n setCurrentArtifact: (state: TState, artifactId: string) => void;\n ensureDashboard: (\n state: TState,\n dashboardId: string,\n title?: string,\n layoutType?: MosaicDashboardLayoutType,\n ) => void;\n getDashboard: (\n state: TState,\n dashboardId: string,\n ) => MosaicDashboardEntry | undefined;\n getPanelIssue?: (\n state: TState,\n dashboardId: string,\n panelId: string,\n ) => ChartRuntimeIssue | undefined;\n setSelectedTable: (\n state: TState,\n dashboardId: string,\n tableName: string,\n ) => void;\n addPanel: (\n state: TState,\n dashboardId: string,\n panel: MosaicDashboardPanelConfig,\n ) => string;\n updatePanel: (\n state: TState,\n dashboardId: string,\n panelId: string,\n patch: Partial<PanelPatch>,\n ) => void;\n removePanel: (state: TState, dashboardId: string, panelId: string) => void;\n};\n\nexport type CreateDashboardToolDepsOptions<TState> = {\n store: DashboardAiStore<TState>;\n adapter: DashboardAiAdapter<TState>;\n};\n\nexport type CreateDashboardAiToolsOptions<TState> =\n CreateDashboardToolDepsOptions<TState> & {\n chartTypes?: ChartTypeDefinition<any>[];\n /**\n * Host-provided dashboard tools keyed by their registered tool name.\n * Register geospatial map tools under MAP_TOOL_KEY so prompts and tools\n * stay in sync.\n */\n extraTools?: (deps: DashboardToolDeps) => Record<string, Tool>;\n };\n\nexport type DashboardAgentToolCall = {\n toolName: string;\n};\n\nexport type DashboardAgentRunResult = {\n finalOutput?: string;\n agentToolCalls?: DashboardAgentToolCall[];\n};\n\nexport type DashboardAgentResult = {\n success: boolean;\n finalOutput: string;\n dashboardId: string;\n error?: string;\n metadata?: {\n tableName: string;\n panelsCreated: number;\n stepsExecuted: number;\n queriesRun: number;\n };\n};\n\nexport type CreateDashboardAgentToolOptions<TState> =\n CreateDashboardToolDepsOptions<TState> & {\n getModel: (args: {state: TState}) => LanguageModel;\n createQueryTools?: (args: {store: DashboardAiStore<TState>}) => {\n query: Tool;\n };\n runSubAgent: (args: {\n agent: ToolLoopAgent<any, any, any>;\n prompt: string;\n store: DashboardAiStore<TState>;\n parentToolCallId: string;\n abortSignal?: AbortSignal;\n }) => Promise<DashboardAgentRunResult>;\n instructions?: string;\n chartTypes?: ChartTypeDefinition<any>[];\n /**\n * Host-provided dashboard tools keyed by their registered tool name.\n * Register geospatial map tools under MAP_TOOL_KEY so prompts and tools\n * stay in sync.\n */\n extraTools?: (deps: DashboardToolDeps) => Record<string, Tool>;\n };\n\nexport const MAP_TOOL_KEY = 'create_dashboard_map';\n\nexport const DASHBOARD_AI_INSTRUCTIONS = `\nDashboard authoring:\n\n**When to use dashboard_agent vs individual tools:**\n- Use \\`dashboard_agent\\` for exploratory requests that require data analysis and discovery:\n - \"analyze the earthquakes dataset\"\n - \"create insights dashboard for sales data\"\n - \"find interesting patterns in customer behavior\"\n - Any request asking to \"discover\", \"explore\", \"find insights\", or \"analyze\"\n- Use individual chart tools for direct, specific requests:\n - \"create histogram of magnitude with 20 bins\"\n - \"add a line chart showing sales over time\"\n - \"update the histogram to use 30 bins\"\n\n**Individual dashboard chart tools:**\n- create_dashboard_histogram, create_dashboard_line_chart, create_dashboard_box_plot, create_dashboard_bubble_chart, create_dashboard_count_plot, create_dashboard_heatmap\n- Each chart type has its own tool with specific parameters.\n- For line charts with aggregation, use yFields array with {field: string, aggregate: \"sum\"|\"avg\"|\"min\"|\"max\"}.\n- Set xInterval for temporal binning (year, month, day, hour, etc.).\n- If the host app provides \\`${MAP_TOOL_KEY}\\`, use it for map/geospatial/location requests and tables with longitude/latitude or geometry columns. Author its config as native Deck JSON with layer classes in \\`spec.layers[].@@type\\`, dataset bindings in \\`_sqlroomsBinding.dataset\\`, and table/query sources in \\`config.datasets\\`. For data-driven map colors, use color accessors such as \\`getFillColor\\`, \\`getLineColor\\`, \\`getColor\\`, \\`getSourceColor\\`, or \\`getTargetColor\\` with \\`{\"@@function\":\"colorScale\", \"field\":\"...\", \"type\":\"sequential\"|\"diverging\"|\"quantize\"|\"quantile\"|\"categorical\", \"scheme\":\"Viridis\", \"domain\":\"auto\"}\\`.\n- Use \\`set_dashboard_vgplot\\` with complete JSON only when no chart tool fits your needs.\n- When calling \\`create_dashboard_artifact\\`, \\`layoutType\\` may be \\`grid\\` or \\`dock\\`; omitted values default to \\`grid\\`.\n- Ensure specs are valid JSON objects compatible with https://idl.uw.edu/mosaic/schema/latest.json.\n- \\`list_dashboard_panels\\` includes runtime issues when a chart failed. Use those issues to repair panels in place: convert too-large bubble charts to heatmaps, add \\`xInterval\\` to too-large line charts, and inspect columns/settings for SQL errors.\n`;\n\nexport const DASHBOARD_AGENT_INSTRUCTIONS = `You are a dashboard builder agent that creates and modifies interactive data dashboards.\n\n## Your Role\n\nYou analyze data and create insightful dashboards with multiple visualizations (charts, Data Table Explorers). You can handle both direct requests (\"create histogram of magnitude\") and exploratory requests (\"find interesting insights in earthquakes dataset\").\n\n## Available Tools\n\n**Chart Tools:**\n- create_dashboard_histogram - distribution of numeric values (always safe, aggregates automatically)\n- create_dashboard_line_chart - trends over time or ordered variable (use with aggregations for >10k rows)\n- create_dashboard_box_plot - compare distributions across categories\n- create_dashboard_bubble_chart - relationship between two numeric columns (avoid for >10k rows, use heatmap instead)\n- create_dashboard_count_plot - frequency of categorical values (always safe, aggregates automatically)\n- create_dashboard_heatmap - density/patterns across two dimensions (preferred for large datasets)\n\n**Panel Tools:**\n- create_dashboard_data_table_explorer - table statistics and column summaries\n- ${MAP_TOOL_KEY} - native Deck JSON geospatial map panel (if provided by the host app)\n\n**Data Tools:**\n- query - execute SQL queries for data exploration\n\n**Management Tools:**\n- list_dashboard_panels - discover panel IDs and what's on the dashboard\n- remove_dashboard_panel - delete a panel by ID\n\n## Workflows\n\n### Direct Requests\nWhen user provides specific instructions:\n1. Parse intent -> identify chart type\n2. Call appropriate tool with settings\n3. Done\n\nExample: \"create histogram of magnitude with 20 bins\"\n-> create_dashboard_histogram(settings: {field: \"magnitude\", bins: 20})\n\n### Exploratory Requests\nWhen user asks to discover insights:\n1. Use query tool to explore data:\n - Start with simple stats: COUNT, MIN, MAX, AVG, DISTINCT (check total row count!)\n - Check distributions: GROUP BY with COUNT\n - Find correlations: CORR(col1, col2)\n - Identify outliers and patterns\n2. Create targeted charts based on discoveries:\n - If dataset has >10k rows: avoid bubble charts and unaggregated line charts\n - Use histogram, count plot, heatmap, or aggregated visualizations instead\n3. Stop when dashboard tells coherent story\n\n### Update Requests\nTo update existing panels:\n1. Call list_dashboard_panels() to discover panel IDs\n2. Call appropriate create tool with panelId parameter\n3. Panel is updated in-place\n\n## Query Guidelines\n\n**Keep queries simple:**\n- Start with aggregations: COUNT, MIN, MAX, AVG, SUM\n- Use GROUP BY for breakdowns and distributions\n- Use LIMIT to control result size (especially with GROUP BY)\n- Avoid expensive operations: large JOINs, full table scans\n\n**Exploration strategy:**\n- Limit exploration to 5-10 queries per request\n- Start broad (overall stats), then narrow (specific patterns)\n- Stop when you have enough insights for a coherent dashboard\n\n## Best Practices\n\n- **Avoid unaggregated charts for large datasets:** For datasets >10k rows, DO NOT use bubble charts or line charts without aggregations. Use aggregated alternatives instead:\n - For scatter/bubble plots: use heatmap or binned aggregations\n - For line charts: use GROUP BY with time buckets or aggregations\n - Histograms and count plots are always safe (they aggregate automatically)\n- **Check before update:** Always call list_dashboard_panels before updating/removing panels\n- **Repair broken charts:** list_dashboard_panels may return an \\`issue\\` per panel. For \\`too-much-data\\`, switch to an aggregated chart or add aggregation. For \\`sql-error\\`, inspect available columns/types and update the broken panel in place.\n- **Validate columns:** Query tools will validate column existence and types\n- **Handle errors gracefully:** If a query or chart creation fails, try alternative approach`;\n\nconst DashboardCreateArtifactToolParameters = z.object({\n title: z.string().optional(),\n layoutType: z\n .enum(['dock', 'grid'])\n .optional()\n .default('grid')\n .describe('Dashboard layout node type to use at creation time.'),\n});\ntype DashboardCreateArtifactToolParameters = z.infer<\n typeof DashboardCreateArtifactToolParameters\n>;\n\nconst DashboardAgentInputSchema = z.object({\n reasoning: z\n .string()\n .describe('Reasoning for why the dashboard agent is being called'),\n prompt: z\n .string()\n .describe('The exploratory data analysis prompt for the agent'),\n tableName: z\n .string()\n .describe('REQUIRED: The name of the table/dataset to analyze.'),\n dashboardTitle: z\n .string()\n .optional()\n .describe('Optional title for the dashboard artifact'),\n maxSteps: z\n .number()\n .optional()\n .default(20)\n .describe('Maximum exploration steps (default: 20, range: 5-50)'),\n temperature: z\n .number()\n .optional()\n .default(0.7)\n .describe(\n 'Model temperature for creativity vs consistency (default: 0.7, range: 0.0-1.0)',\n ),\n});\ntype DashboardAgentInputSchema = z.infer<typeof DashboardAgentInputSchema>;\n\nclass DashboardAgentException extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'DashboardAgentException';\n }\n}\n\nfunction getTablesWithColumns<TState>(\n state: TState,\n adapter: DashboardAiAdapter<TState>,\n): DashboardAiTable[] {\n return adapter\n .getTables(state)\n .filter((table) => table.columns && table.columns.length > 0);\n}\n\nfunction findTableColumns<TState>(\n state: TState,\n adapter: DashboardAiAdapter<TState>,\n tableName: string,\n): ChartBuilderColumn[] | null {\n const table = getTablesWithColumns(state, adapter).find(\n (candidate) => candidate.tableName === tableName,\n );\n if (!table?.columns) return null;\n return table.columns.map((column) => ({\n name: column.name,\n type: column.type,\n }));\n}\n\nfunction formatAvailableTables(tables: DashboardAiTable[]): string {\n return tables.map((table) => table.tableName).join(', ') || '(none)';\n}\n\nexport function createDashboardToolDeps<TState>({\n store,\n adapter,\n}: CreateDashboardToolDepsOptions<TState>): DashboardToolDeps {\n const resolveArtifact = (\n artifactId?: string,\n createIfMissing?: boolean,\n context?: ChartToolExecutionContext,\n ): string => {\n const state = store.getState();\n const hasRunContext = adapter.hasRunContext?.(state, context) ?? false;\n const contextDashboardArtifactId =\n adapter.resolveContextDashboardArtifactId?.(state, context);\n let targetArtifactId =\n artifactId ??\n contextDashboardArtifactId ??\n (!hasRunContext\n ? adapter.getCurrentDashboardArtifactId(state)\n : undefined);\n\n if (!targetArtifactId && hasRunContext) {\n throw new Error(\n 'No primary dashboard artifact is available in the current run context. Pass artifactId explicitly or use set_primary_context_artifact first.',\n );\n }\n\n if (!targetArtifactId && createIfMissing) {\n targetArtifactId = adapter.createDashboardArtifact(\n state,\n undefined,\n 'grid',\n );\n adapter.setCurrentArtifact(state, targetArtifactId);\n adapter.makeDashboardPrimaryForRun?.(state, targetArtifactId, context);\n }\n\n if (!targetArtifactId) {\n throw new Error(\n 'No dashboard artifact is available. Set createArtifactIfMissing=true or create one first.',\n );\n }\n\n if (!adapter.isDashboardArtifact(state, targetArtifactId)) {\n throw new Error(\n `Artifact \"${targetArtifactId}\" is not a dashboard artifact.`,\n );\n }\n\n adapter.ensureDashboard(state, targetArtifactId);\n return targetArtifactId;\n };\n\n const resolveTable = (artifactId: string, tableName?: string) => {\n const state = store.getState();\n const tables = getTablesWithColumns(state, adapter);\n const dashboard = adapter.getDashboard(state, artifactId);\n const explicitTableName = tableName?.trim() || undefined;\n\n if (explicitTableName) {\n const columns = findTableColumns(state, adapter, explicitTableName);\n if (!columns) {\n throw new Error(\n `Unknown table \"${explicitTableName}\". Available tables: ${formatAvailableTables(tables)}.`,\n );\n }\n adapter.setSelectedTable(state, artifactId, explicitTableName);\n return {tableName: explicitTableName, columns};\n }\n\n if (dashboard?.selectedTable) {\n const columns = findTableColumns(state, adapter, dashboard.selectedTable);\n if (columns) {\n return {tableName: dashboard.selectedTable, columns};\n }\n }\n\n if (tables.length === 1) {\n const onlyTable = tables[0];\n if (!onlyTable?.columns) {\n throw new Error('The only available table has no column metadata.');\n }\n adapter.setSelectedTable(state, artifactId, onlyTable.tableName);\n return {\n tableName: onlyTable.tableName,\n columns: onlyTable.columns.map((column) => ({\n name: column.name,\n type: column.type,\n })),\n };\n }\n\n throw new Error(\n `No dashboard table is selected. Provide tableName using one of: ${formatAvailableTables(tables)}.`,\n );\n };\n\n const deps: DashboardToolDeps = {\n maxDataPoints: DEFAULT_CHART_MAX_DATA_POINTS,\n resolveArtifact,\n resolveTable,\n addPanel: (dashboardId, panel) => {\n const state = store.getState();\n return adapter.addPanel(state, dashboardId, panel);\n },\n updatePanel: (dashboardId, panelId, patch) => {\n const state = store.getState();\n adapter.updatePanel(state, dashboardId, panelId, patch);\n },\n getDashboard: (dashboardId) => {\n const state = store.getState();\n return adapter.getDashboard(state, dashboardId);\n },\n removePanel: (dashboardId, panelId) => {\n const state = store.getState();\n adapter.removePanel(state, dashboardId, panelId);\n },\n setCurrentArtifact: (artifactId) => {\n const state = store.getState();\n adapter.setCurrentArtifact(state, artifactId);\n },\n };\n\n if (adapter.getPanelIssue) {\n deps.getPanelIssue = (dashboardId, panelId) => {\n const state = store.getState();\n return adapter.getPanelIssue?.(state, dashboardId, panelId);\n };\n }\n\n return deps;\n}\n\nexport function createDashboardAiTools<TState>({\n store,\n adapter,\n chartTypes,\n extraTools,\n}: CreateDashboardAiToolsOptions<TState>): Record<string, Tool> {\n const deps = createDashboardToolDeps({store, adapter});\n const resolvedChartTypes =\n chartTypes ?? createDefaultChartTypes({includeCustomSpec: false});\n const chartTools = createChartTools(resolvedChartTypes, deps);\n const hostTools = extraTools?.(deps) ?? {};\n\n const builtInTools = {\n create_dashboard_artifact: tool({\n description:\n 'Create a new dashboard artifact with a dock or grid layout and make it the active artifact. Use when no dashboard artifact exists yet.',\n inputSchema: DashboardCreateArtifactToolParameters,\n execute: async (\n params: DashboardCreateArtifactToolParameters,\n context,\n ) => {\n const state = store.getState();\n const artifactId = adapter.createDashboardArtifact(\n state,\n params.title,\n params.layoutType,\n );\n adapter.setCurrentArtifact(state, artifactId);\n adapter.makeDashboardPrimaryForRun?.(state, artifactId, context);\n return {\n llmResult: {\n success: true,\n details: `Created dashboard artifact \"${artifactId}\".`,\n data: {artifactId},\n },\n };\n },\n }),\n ...chartTools,\n create_dashboard_data_table_explorer: createDataTableExplorerTool(deps),\n list_dashboard_panels: createListPanelsTool(deps),\n remove_dashboard_panel: createRemovePanelTool(deps),\n };\n\n for (const key of Object.keys(hostTools)) {\n if (key in builtInTools) {\n throw new Error(\n `Dashboard extraTools cannot override built-in tool \"${key}\". Register the host tool under a unique key.`,\n );\n }\n }\n\n return {\n ...builtInTools,\n ...hostTools,\n };\n}\n\nfunction buildAgentPrompt<TState>(\n userPrompt: string,\n tableName: string,\n state: TState,\n adapter: DashboardAiAdapter<TState>,\n): string {\n const table = adapter\n .getTables(state)\n .find((candidate) => candidate.tableName === tableName);\n const columnNames =\n table?.columns?.map((column) => column.name).join(', ') || 'unknown';\n const rowInfo =\n table?.rowCount !== undefined ? `Approximate rows: ${table.rowCount}` : '';\n\n return `Analyze the \"${tableName}\" table.\n\nTable info:\n- Columns: ${columnNames}${rowInfo ? `\\n- ${rowInfo}` : ''}\n\nUser request: ${userPrompt}\n\nFocus on discovering meaningful patterns and creating visualizations that tell a clear story.`;\n}\n\nfunction validateTableExists<TState>(\n state: TState,\n adapter: DashboardAiAdapter<TState>,\n tableName: string,\n): void {\n const tables = adapter.getTables(state);\n const table = tables.find((candidate) => candidate.tableName === tableName);\n if (!table) {\n throw new DashboardAgentException(\n `Table \"${tableName}\" not found. Available tables: ${formatAvailableTables(tables)}`,\n );\n }\n}\n\nfunction getOrCreateDashboard<TState>(\n state: TState,\n adapter: DashboardAiAdapter<TState>,\n tableName: string,\n dashboardTitle?: string,\n): string {\n const dashboardId = adapter.getCurrentDashboardArtifactId(state);\n if (dashboardId) {\n adapter.ensureDashboard(state, dashboardId);\n return dashboardId;\n }\n\n const suggestedTitle =\n dashboardTitle ||\n `${tableName.charAt(0).toUpperCase() + tableName.slice(1)} Insights`;\n const newDashboardId = adapter.createDashboardArtifact(\n state,\n suggestedTitle,\n 'grid',\n );\n adapter.setCurrentArtifact(state, newDashboardId);\n return newDashboardId;\n}\n\nfunction calculateAgentMetadata<TState>(\n state: TState,\n adapter: DashboardAiAdapter<TState>,\n dashboardId: string,\n tableName: string,\n agentToolCalls: DashboardAgentToolCall[],\n): DashboardAgentResult['metadata'] {\n const dashboard = adapter.getDashboard(state, dashboardId);\n return {\n tableName,\n panelsCreated: dashboard?.panels?.length || 0,\n stepsExecuted: agentToolCalls.length,\n queriesRun: agentToolCalls.filter((call) => call.toolName === 'query')\n .length,\n };\n}\n\nexport function createDashboardAgentTool<TState>(\n options: CreateDashboardAgentToolOptions<TState>,\n): Tool {\n const {store, adapter} = options;\n\n return tool({\n description: `An AI agent that explores datasets and creates comprehensive dashboards with multiple visualizations.\n\nUse this for exploratory data analysis tasks like \"analyze the earthquakes dataset\" or \"create insights dashboard for sales data\".\n\nThe agent will query the data, discover patterns, and create charts and Data Table Explorers with findings.\n\nFor simple tasks like \"create a histogram of magnitude\", use the individual chart tools instead.\n\nIMPORTANT: Always provide tableName parameter when the user mentions a specific dataset.`,\n inputSchema: DashboardAgentInputSchema,\n execute: async (params, toolOptions): Promise<DashboardAgentResult> => {\n const {prompt, tableName, dashboardTitle, maxSteps, temperature} = params;\n\n let dashboardId = '';\n\n try {\n const state = store.getState();\n validateTableExists(state, adapter, tableName);\n\n dashboardId = getOrCreateDashboard(\n state,\n adapter,\n tableName,\n dashboardTitle,\n );\n adapter.setSelectedTable(state, dashboardId, tableName);\n const queryTools = options.createQueryTools?.({store});\n\n const dashboardAgent = new ToolLoopAgent({\n model: options.getModel({state}),\n tools: {\n ...(queryTools ? {query: queryTools.query} : {}),\n ...createDashboardAiTools({\n store,\n adapter,\n chartTypes: options.chartTypes,\n extraTools: options.extraTools,\n }),\n },\n temperature: Math.max(0, Math.min(1, temperature ?? 0.7)),\n stopWhen: [stepCountIs(Math.max(5, Math.min(50, maxSteps ?? 20)))],\n instructions: options.instructions ?? DASHBOARD_AGENT_INSTRUCTIONS,\n });\n\n const result = await options.runSubAgent({\n agent: dashboardAgent,\n prompt: buildAgentPrompt(prompt, tableName, state, adapter),\n store,\n parentToolCallId: toolOptions?.toolCallId || '',\n abortSignal: toolOptions?.abortSignal,\n });\n\n const finalState = store.getState();\n const metadata = calculateAgentMetadata(\n finalState,\n adapter,\n dashboardId,\n tableName,\n result.agentToolCalls || [],\n );\n\n return {\n success: true,\n finalOutput: result.finalOutput || 'Dashboard created successfully.',\n dashboardId,\n metadata,\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n const friendlyMessage =\n error instanceof DashboardAgentException\n ? errorMessage\n : 'Dashboard agent execution failed.';\n\n return {\n success: false,\n finalOutput: friendlyMessage,\n dashboardId,\n error: errorMessage,\n };\n }\n },\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../../src/ai/ai.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAC,qBAAqB,EAA0B,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAGL,aAAa,EACb,WAAW,EACX,IAAI,GACL,MAAM,IAAI,CAAC;AACZ,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AACtB,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,oBAAoB,EACpB,2BAA2B,EAC3B,qBAAqB,GAMtB,MAAM,uBAAuB,CAAC;AAM/B,OAAO,EACL,6BAA6B,GAE9B,MAAM,kBAAkB,CAAC;AAgJ1B,MAAM,CAAC,MAAM,YAAY,GAAG,sBAAsB,CAAC;AAEnD,MAAM,CAAC,MAAM,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AAM,UAAU,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;gBACpC,MAAM,QAAQ,GAAG,sBAAsB,CACrC,UAAU,EACV,OAAO,EACP,WAAW,EACX,iBAAiB,EACjB,MAAM,CAAC,cAAc,IAAI,EAAE,CAC5B,CAAC;gBAEF,OAAO;oBACL,OAAO,EAAE,IAAI;oBACb,WAAW,EAAE,MAAM,CAAC,WAAW,IAAI,iCAAiC;oBACpE,WAAW;oBACX,QAAQ;iBACT,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,YAAY,GAChB,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;gBACzD,MAAM,eAAe,GACnB,KAAK,YAAY,uBAAuB;oBACtC,CAAC,CAAC,YAAY;oBACd,CAAC,CAAC,mCAAmC,CAAC;gBAE1C,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,WAAW,EAAE,eAAe;oBAC5B,WAAW;oBACX,KAAK,EAAE,YAAY;iBACpB,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["/**\n * Reusable AI helpers for Mosaic dashboards.\n *\n * Host apps provide a narrow adapter for their store/artifact model; Mosaic owns\n * the dashboard tool behavior and prompts.\n *\n * @packageDocumentation\n */\n\nimport {resolveTableReference, type QualifiedTableName} from '@sqlrooms/duckdb';\nimport {\n type LanguageModel,\n type Tool,\n ToolLoopAgent,\n stepCountIs,\n tool,\n} from 'ai';\nimport {z} from 'zod';\nimport {\n createChartTools,\n createDefaultChartTypes,\n createListPanelsTool,\n createDataTableExplorerTool,\n createRemovePanelTool,\n type ChartBuilderColumn,\n type ChartToolExecutionContext,\n type DashboardToolDeps,\n type PanelPatch,\n type ChartTypeDefinition,\n} from '../charts/chart-types';\nimport type {\n MosaicDashboardEntry,\n MosaicDashboardPanelConfig,\n} from '../dashboard/dashboard-types';\nimport type {MosaicDashboardLayoutType} from '../dashboard/core-types';\nimport {\n DEFAULT_CHART_MAX_DATA_POINTS,\n type ChartRuntimeIssue,\n} from '../chart-runtime';\n\nexport type {ChartToolExecutionContext} from '../charts/chart-types';\n\nexport type DashboardAiStore<TState> = {\n getState: () => TState;\n};\n\nexport type DashboardAiTable = {\n /**\n * Canonical table identity used for routing after natural-language table\n * selection resolves to a concrete table.\n */\n qualifiedName: QualifiedTableName;\n columns?: ChartBuilderColumn[];\n rowCount?: number;\n};\n\ntype ResolvedDashboardAiTable = {\n table: QualifiedTableName;\n tableName: string;\n tableId: string;\n columns?: ChartBuilderColumn[];\n rowCount?: number;\n};\n\nexport type DashboardAiAdapter<TState> = {\n getTables: (state: TState) => DashboardAiTable[];\n hasRunContext?: (\n state: TState,\n context?: ChartToolExecutionContext,\n ) => boolean;\n resolveContextDashboardArtifactId?: (\n state: TState,\n context?: ChartToolExecutionContext,\n ) => string | undefined;\n makeDashboardPrimaryForRun?: (\n state: TState,\n dashboardId: string,\n context?: ChartToolExecutionContext,\n ) => void;\n getCurrentDashboardArtifactId: (state: TState) => string | undefined;\n createDashboardArtifact: (\n state: TState,\n title?: string,\n layoutType?: MosaicDashboardLayoutType,\n ) => string;\n isDashboardArtifact: (state: TState, artifactId: string) => boolean;\n setCurrentArtifact: (state: TState, artifactId: string) => void;\n ensureDashboard: (\n state: TState,\n dashboardId: string,\n title?: string,\n layoutType?: MosaicDashboardLayoutType,\n ) => void;\n getDashboard: (\n state: TState,\n dashboardId: string,\n ) => MosaicDashboardEntry | undefined;\n getPanelIssue?: (\n state: TState,\n dashboardId: string,\n panelId: string,\n ) => ChartRuntimeIssue | undefined;\n setSelectedTable: (\n state: TState,\n dashboardId: string,\n tableName: string,\n ) => void;\n addPanel: (\n state: TState,\n dashboardId: string,\n panel: MosaicDashboardPanelConfig,\n ) => string;\n updatePanel: (\n state: TState,\n dashboardId: string,\n panelId: string,\n patch: Partial<PanelPatch>,\n ) => void;\n removePanel: (state: TState, dashboardId: string, panelId: string) => void;\n};\n\nexport type CreateDashboardToolDepsOptions<TState> = {\n store: DashboardAiStore<TState>;\n adapter: DashboardAiAdapter<TState>;\n};\n\nexport type CreateDashboardAiToolsOptions<TState> =\n CreateDashboardToolDepsOptions<TState> & {\n chartTypes?: ChartTypeDefinition<any>[];\n /**\n * Host-provided dashboard tools keyed by their registered tool name.\n * Register geospatial map tools under MAP_TOOL_KEY so prompts and tools\n * stay in sync.\n */\n extraTools?: (deps: DashboardToolDeps) => Record<string, Tool>;\n };\n\nexport type DashboardAgentToolCall = {\n toolName: string;\n};\n\nexport type DashboardAgentRunResult = {\n finalOutput?: string;\n agentToolCalls?: DashboardAgentToolCall[];\n};\n\nexport type DashboardAgentResult = {\n success: boolean;\n finalOutput: string;\n dashboardId: string;\n error?: string;\n metadata?: {\n tableName: string;\n panelsCreated: number;\n stepsExecuted: number;\n queriesRun: number;\n };\n};\n\nexport type CreateDashboardAgentToolOptions<TState> =\n CreateDashboardToolDepsOptions<TState> & {\n getModel: (args: {state: TState}) => LanguageModel;\n createQueryTools?: (args: {store: DashboardAiStore<TState>}) => {\n query: Tool;\n } & Record<string, Tool>;\n runSubAgent: (args: {\n agent: ToolLoopAgent<any, any, any>;\n prompt: string;\n store: DashboardAiStore<TState>;\n parentToolCallId: string;\n abortSignal?: AbortSignal;\n }) => Promise<DashboardAgentRunResult>;\n instructions?: string;\n chartTypes?: ChartTypeDefinition<any>[];\n /**\n * Host-provided dashboard tools keyed by their registered tool name.\n * Register geospatial map tools under MAP_TOOL_KEY so prompts and tools\n * stay in sync.\n */\n extraTools?: (deps: DashboardToolDeps) => Record<string, Tool>;\n };\n\nexport const MAP_TOOL_KEY = 'create_dashboard_map';\n\nexport const DASHBOARD_AI_INSTRUCTIONS = `\nDashboard authoring:\n\n**When to use dashboard_agent vs individual tools:**\n- Use \\`dashboard_agent\\` for exploratory requests that require data analysis and discovery:\n - \"analyze the earthquakes dataset\"\n - \"create insights dashboard for sales data\"\n - \"find interesting patterns in customer behavior\"\n - Any request asking to \"discover\", \"explore\", \"find insights\", or \"analyze\"\n- Use individual chart tools for direct, specific requests:\n - \"create histogram of magnitude with 20 bins\"\n - \"add a line chart showing sales over time\"\n - \"update the histogram to use 30 bins\"\n\n**Individual dashboard chart tools:**\n- create_dashboard_histogram, create_dashboard_line_chart, create_dashboard_box_plot, create_dashboard_scatter_plot, create_dashboard_count_plot, create_dashboard_heatmap\n- Each chart type has its own tool with specific parameters.\n- For line charts with aggregation, use yFields array with {field: string, aggregate: \"sum\"|\"avg\"|\"min\"|\"max\"}.\n- Set xInterval for temporal binning (year, month, day, hour, etc.).\n- If the host app provides \\`${MAP_TOOL_KEY}\\`, use it for map/geospatial/location requests and tables with longitude/latitude or geometry columns. Author its config as native Deck JSON with layer classes in \\`spec.layers[].@@type\\`, dataset bindings in \\`_sqlroomsBinding.dataset\\`, and table/query sources in \\`config.datasets\\`. For data-driven map colors, use color accessors such as \\`getFillColor\\`, \\`getLineColor\\`, \\`getColor\\`, \\`getSourceColor\\`, or \\`getTargetColor\\` with \\`{\"@@function\":\"colorScale\", \"field\":\"...\", \"type\":\"sequential\"|\"diverging\"|\"quantize\"|\"quantile\"|\"categorical\", \"scheme\":\"Viridis\", \"domain\":\"auto\"}\\`.\n- Use \\`set_dashboard_vgplot\\` with complete JSON only when no chart tool fits your needs.\n- When calling \\`create_dashboard_artifact\\`, \\`layoutType\\` may be \\`grid\\` or \\`dock\\`; omitted values default to \\`grid\\`.\n- Ensure specs are valid JSON objects compatible with https://idl.uw.edu/mosaic/schema/latest.json.\n- \\`list_dashboard_panels\\` includes runtime issues when a chart failed. Use those issues to repair panels in place: convert too-large scatter charts to heatmaps, add \\`xInterval\\` to too-large line charts, and inspect columns/settings for SQL errors.\n`;\n\nexport const DASHBOARD_AGENT_INSTRUCTIONS = `You are a dashboard builder agent that creates and modifies interactive data dashboards.\n\n## Your Role\n\nYou analyze data and create insightful dashboards with multiple visualizations (charts, Data Table Explorers). You can handle both direct requests (\"create histogram of magnitude\") and exploratory requests (\"find interesting insights in earthquakes dataset\").\n\n## Available Tools\n\n**Chart Tools:**\n- create_dashboard_histogram - distribution of numeric values (always safe, aggregates automatically)\n- create_dashboard_line_chart - trends over time or ordered variable (use with aggregations for >10k rows)\n- create_dashboard_box_plot - compare distributions across categories\n- create_dashboard_scatter_plot - relationship between two numeric columns (avoid for >10k rows, use heatmap instead)\n- create_dashboard_count_plot - frequency of categorical values (always safe, aggregates automatically)\n- create_dashboard_heatmap - density/patterns across two dimensions (preferred for large datasets)\n\n**Panel Tools:**\n- create_dashboard_data_table_explorer - table statistics and column summaries\n- ${MAP_TOOL_KEY} - native Deck JSON geospatial map panel (if provided by the host app)\n\n**Data Tools:**\n- query - execute SQL queries for data exploration\n\n**Management Tools:**\n- list_dashboard_panels - discover panel IDs and what's on the dashboard\n- remove_dashboard_panel - delete a panel by ID\n\n## Workflows\n\n### Direct Requests\nWhen user provides specific instructions:\n1. Parse intent -> identify chart type\n2. Call appropriate tool with settings\n3. Done\n\nExample: \"create histogram of magnitude with 20 bins\"\n-> create_dashboard_histogram(settings: {field: \"magnitude\", bins: 20})\n\n### Exploratory Requests\nWhen user asks to discover insights:\n1. Use query tool to explore data:\n - Start with simple stats: COUNT, MIN, MAX, AVG, DISTINCT (check total row count!)\n - Check distributions: GROUP BY with COUNT\n - Find correlations: CORR(col1, col2)\n - Identify outliers and patterns\n2. Create targeted charts based on discoveries:\n - If dataset has >10k rows: avoid scatter charts and unaggregated line charts\n - Use histogram, count plot, heatmap, or aggregated visualizations instead\n3. Stop when dashboard tells coherent story\n\n### Update Requests\nTo update existing panels:\n1. Call list_dashboard_panels() to discover panel IDs\n2. Call appropriate create tool with panelId parameter\n3. Panel is updated in-place\n\n## Query Guidelines\n\n**Keep queries simple:**\n- Start with aggregations: COUNT, MIN, MAX, AVG, SUM\n- Use GROUP BY for breakdowns and distributions\n- Use LIMIT to control result size (especially with GROUP BY)\n- Avoid expensive operations: large JOINs, full table scans\n\n**Exploration strategy:**\n- Limit exploration to 5-10 queries per request\n- Start broad (overall stats), then narrow (specific patterns)\n- Stop when you have enough insights for a coherent dashboard\n\n## Best Practices\n\n- **Avoid unaggregated charts for large datasets:** For datasets >10k rows, DO NOT use scatter charts or line charts without aggregations. Use aggregated alternatives instead:\n - For scatter plots: use heatmap or binned aggregations\n - For line charts: use GROUP BY with time buckets or aggregations\n - Histograms and count plots are always safe (they aggregate automatically)\n- **Check before update:** Always call list_dashboard_panels before updating/removing panels\n- **Repair broken charts:** list_dashboard_panels may return an \\`issue\\` per panel. For \\`too-much-data\\`, switch to an aggregated chart or add aggregation. For \\`sql-error\\`, inspect available columns/types and update the broken panel in place.\n- **Validate columns:** Query tools will validate column existence and types\n- **Handle errors gracefully:** If a query or chart creation fails, try alternative approach`;\n\nconst DashboardCreateArtifactToolParameters = z.object({\n title: z.string().optional(),\n layoutType: z\n .enum(['dock', 'grid'])\n .optional()\n .default('grid')\n .describe('Dashboard layout node type to use at creation time.'),\n});\ntype DashboardCreateArtifactToolParameters = z.infer<\n typeof DashboardCreateArtifactToolParameters\n>;\n\nconst DashboardAgentInputSchema = z.object({\n reasoning: z\n .string()\n .describe('Reasoning for why the dashboard agent is being called'),\n prompt: z\n .string()\n .describe('The exploratory data analysis prompt for the agent'),\n tableName: z\n .string()\n .describe('REQUIRED: The name of the table/dataset to analyze.'),\n dashboardTitle: z\n .string()\n .optional()\n .describe('Optional title for the dashboard artifact'),\n maxSteps: z\n .number()\n .optional()\n .default(20)\n .describe('Maximum exploration steps (default: 20, range: 5-50)'),\n temperature: z\n .number()\n .optional()\n .default(0.7)\n .describe(\n 'Model temperature for creativity vs consistency (default: 0.7, range: 0.0-1.0)',\n ),\n});\ntype DashboardAgentInputSchema = z.infer<typeof DashboardAgentInputSchema>;\n\nclass DashboardAgentException extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'DashboardAgentException';\n }\n}\n\nfunction getTablesWithColumns<TState>(\n state: TState,\n adapter: DashboardAiAdapter<TState>,\n): ResolvedDashboardAiTable[] {\n return adapter\n .getTables(state)\n .map(normalizeDashboardAiTable)\n .filter((table) => table.columns && table.columns.length > 0);\n}\n\nfunction normalizeDashboardAiTable(\n table: DashboardAiTable,\n): ResolvedDashboardAiTable {\n const {qualifiedName} = table;\n const tableId = qualifiedName.toString();\n\n return {\n table: qualifiedName,\n tableName: qualifiedName.table,\n tableId,\n columns: table.columns,\n rowCount: table.rowCount,\n };\n}\n\nfunction formatAmbiguousTableError(\n tableName: string,\n matches: ResolvedDashboardAiTable[],\n): string {\n return `Ambiguous table \"${tableName}\". Matching tables: ${matches\n .map((table) => table.tableId)\n .join(', ')}.`;\n}\n\nfunction getResolvedTable(table: ResolvedDashboardAiTable) {\n if (!table.columns) {\n throw new Error(`Table \"${table.tableName}\" has no column metadata.`);\n }\n return {\n tableName: table.tableId,\n qualifiedName: table.table,\n columns: table.columns.map((column) => ({\n name: column.name,\n type: column.type,\n })),\n };\n}\n\nfunction formatAvailableTables(tables: ResolvedDashboardAiTable[]): string {\n return (\n tables\n .map((table) => {\n return table.tableId === table.tableName\n ? table.tableName\n : `${table.tableName} (${table.tableId})`;\n })\n .join(', ') || '(none)'\n );\n}\n\nexport function createDashboardToolDeps<TState>({\n store,\n adapter,\n}: CreateDashboardToolDepsOptions<TState>): DashboardToolDeps {\n const resolveArtifact = (\n artifactId?: string,\n createIfMissing?: boolean,\n context?: ChartToolExecutionContext,\n ): string => {\n const state = store.getState();\n const hasRunContext = adapter.hasRunContext?.(state, context) ?? false;\n const contextDashboardArtifactId =\n adapter.resolveContextDashboardArtifactId?.(state, context);\n let targetArtifactId =\n artifactId ??\n contextDashboardArtifactId ??\n (!hasRunContext\n ? adapter.getCurrentDashboardArtifactId(state)\n : undefined);\n\n if (!targetArtifactId && hasRunContext) {\n throw new Error(\n 'No primary dashboard artifact is available in the current run context. Pass artifactId explicitly or use set_primary_context_artifact first.',\n );\n }\n\n if (!targetArtifactId && createIfMissing) {\n targetArtifactId = adapter.createDashboardArtifact(\n state,\n undefined,\n 'grid',\n );\n adapter.setCurrentArtifact(state, targetArtifactId);\n adapter.makeDashboardPrimaryForRun?.(state, targetArtifactId, context);\n }\n\n if (!targetArtifactId) {\n throw new Error(\n 'No dashboard artifact is available. Set createArtifactIfMissing=true or create one first.',\n );\n }\n\n if (!adapter.isDashboardArtifact(state, targetArtifactId)) {\n throw new Error(\n `Artifact \"${targetArtifactId}\" is not a dashboard artifact.`,\n );\n }\n\n adapter.ensureDashboard(state, targetArtifactId);\n return targetArtifactId;\n };\n\n const resolveTable = (\n artifactId: string,\n tableName?: string | QualifiedTableName,\n ) => {\n const state = store.getState();\n const tables = getTablesWithColumns(state, adapter);\n const dashboard = adapter.getDashboard(state, artifactId);\n const explicitTableName =\n typeof tableName === 'string' ? tableName.trim() || undefined : tableName;\n\n if (explicitTableName) {\n const {table, ambiguousMatches} = resolveTableReference(\n tables,\n explicitTableName,\n );\n if (ambiguousMatches) {\n const requestedTableName =\n typeof explicitTableName === 'string'\n ? explicitTableName\n : explicitTableName.toString();\n throw new Error(\n formatAmbiguousTableError(requestedTableName, ambiguousMatches),\n );\n }\n if (!table) {\n const requestedTableName =\n typeof explicitTableName === 'string'\n ? explicitTableName\n : explicitTableName.toString();\n throw new Error(\n `Unknown table \"${requestedTableName}\". Available tables: ${formatAvailableTables(tables)}.`,\n );\n }\n const resolvedTable = getResolvedTable(table);\n adapter.setSelectedTable(state, artifactId, resolvedTable.tableName);\n return resolvedTable;\n }\n\n if (dashboard?.selectedTable) {\n const {table} = resolveTableReference(tables, dashboard.selectedTable);\n if (table) {\n return getResolvedTable(table);\n }\n }\n\n if (tables.length === 1) {\n const onlyTable = tables[0];\n if (!onlyTable) {\n throw new Error('The only available table has no column metadata.');\n }\n const resolvedTable = getResolvedTable(onlyTable);\n adapter.setSelectedTable(state, artifactId, resolvedTable.tableName);\n return resolvedTable;\n }\n\n throw new Error(\n `No dashboard table is selected. Provide tableName using one of: ${formatAvailableTables(tables)}.`,\n );\n };\n\n const deps: DashboardToolDeps = {\n maxDataPoints: DEFAULT_CHART_MAX_DATA_POINTS,\n resolveArtifact,\n resolveTable,\n addPanel: (dashboardId, panel) => {\n const state = store.getState();\n return adapter.addPanel(state, dashboardId, panel);\n },\n updatePanel: (dashboardId, panelId, patch) => {\n const state = store.getState();\n adapter.updatePanel(state, dashboardId, panelId, patch);\n },\n getDashboard: (dashboardId) => {\n const state = store.getState();\n return adapter.getDashboard(state, dashboardId);\n },\n removePanel: (dashboardId, panelId) => {\n const state = store.getState();\n adapter.removePanel(state, dashboardId, panelId);\n },\n setCurrentArtifact: (artifactId) => {\n const state = store.getState();\n adapter.setCurrentArtifact(state, artifactId);\n },\n };\n\n if (adapter.getPanelIssue) {\n deps.getPanelIssue = (dashboardId, panelId) => {\n const state = store.getState();\n return adapter.getPanelIssue?.(state, dashboardId, panelId);\n };\n }\n\n return deps;\n}\n\nexport function createDashboardAiTools<TState>({\n store,\n adapter,\n chartTypes,\n extraTools,\n}: CreateDashboardAiToolsOptions<TState>): Record<string, Tool> {\n const deps = createDashboardToolDeps({store, adapter});\n const resolvedChartTypes =\n chartTypes ?? createDefaultChartTypes({includeCustomSpec: false});\n const chartTools = createChartTools(resolvedChartTypes, deps);\n const hostTools = extraTools?.(deps) ?? {};\n\n const builtInTools = {\n create_dashboard_artifact: tool({\n description:\n 'Create a new dashboard artifact with a dock or grid layout and make it the active artifact. Use when no dashboard artifact exists yet.',\n inputSchema: DashboardCreateArtifactToolParameters,\n execute: async (\n params: DashboardCreateArtifactToolParameters,\n context,\n ) => {\n const state = store.getState();\n const artifactId = adapter.createDashboardArtifact(\n state,\n params.title,\n params.layoutType,\n );\n adapter.setCurrentArtifact(state, artifactId);\n adapter.makeDashboardPrimaryForRun?.(state, artifactId, context);\n return {\n llmResult: {\n success: true,\n details: `Created dashboard artifact \"${artifactId}\".`,\n data: {artifactId},\n },\n };\n },\n }),\n ...chartTools,\n create_dashboard_data_table_explorer: createDataTableExplorerTool(deps),\n list_dashboard_panels: createListPanelsTool(deps),\n remove_dashboard_panel: createRemovePanelTool(deps),\n };\n\n for (const key of Object.keys(hostTools)) {\n if (key in builtInTools) {\n throw new Error(\n `Dashboard extraTools cannot override built-in tool \"${key}\". Register the host tool under a unique key.`,\n );\n }\n }\n\n return {\n ...builtInTools,\n ...hostTools,\n };\n}\n\nfunction buildAgentPrompt<TState>(\n userPrompt: string,\n tableName: string,\n state: TState,\n adapter: DashboardAiAdapter<TState>,\n): string {\n const table = resolveTableReference(\n adapter.getTables(state).map(normalizeDashboardAiTable),\n tableName,\n ).table;\n const resolvedTableName = table ? table.tableId : tableName;\n const tableIdInfo =\n table && table.tableName !== resolvedTableName\n ? `\\n- Table ID for tool calls: ${resolvedTableName}`\n : '';\n const columnNames =\n table?.columns\n ?.map((column) =>\n column.type ? `${column.name} (${column.type})` : column.name,\n )\n .join(', ') || 'unknown';\n const rowInfo =\n table?.rowCount !== undefined ? `Approximate rows: ${table.rowCount}` : '';\n\n return `Analyze the \"${table?.tableName ?? tableName}\" table.\n\nTable info:\n- Columns: ${columnNames}${tableIdInfo}${rowInfo ? `\\n- ${rowInfo}` : ''}\n\nUser request: ${userPrompt}\n\nFocus on discovering meaningful patterns and creating visualizations that tell a clear story.`;\n}\n\nfunction validateTableExists<TState>(\n state: TState,\n adapter: DashboardAiAdapter<TState>,\n tableName: string,\n): ResolvedDashboardAiTable {\n const tables = adapter.getTables(state).map(normalizeDashboardAiTable);\n const {table, ambiguousMatches} = resolveTableReference(tables, tableName);\n if (ambiguousMatches) {\n throw new DashboardAgentException(\n formatAmbiguousTableError(tableName, ambiguousMatches),\n );\n }\n if (!table) {\n throw new DashboardAgentException(\n `Table \"${tableName}\" not found. Available tables: ${formatAvailableTables(tables)}`,\n );\n }\n return table;\n}\n\nfunction getOrCreateDashboard<TState>(\n state: TState,\n adapter: DashboardAiAdapter<TState>,\n displayTableName: string,\n dashboardTitle?: string,\n): string {\n const dashboardId = adapter.getCurrentDashboardArtifactId(state);\n if (dashboardId) {\n adapter.ensureDashboard(state, dashboardId);\n return dashboardId;\n }\n\n const suggestedTitle =\n dashboardTitle ||\n `${displayTableName.charAt(0).toUpperCase() + displayTableName.slice(1)} Insights`;\n const newDashboardId = adapter.createDashboardArtifact(\n state,\n suggestedTitle,\n 'grid',\n );\n adapter.setCurrentArtifact(state, newDashboardId);\n return newDashboardId;\n}\n\nfunction calculateAgentMetadata<TState>(\n state: TState,\n adapter: DashboardAiAdapter<TState>,\n dashboardId: string,\n tableName: string,\n agentToolCalls: DashboardAgentToolCall[],\n): DashboardAgentResult['metadata'] {\n const dashboard = adapter.getDashboard(state, dashboardId);\n return {\n tableName,\n panelsCreated: dashboard?.panels?.length || 0,\n stepsExecuted: agentToolCalls.length,\n queriesRun: agentToolCalls.filter((call) => call.toolName === 'query')\n .length,\n };\n}\n\nexport function createDashboardAgentTool<TState>(\n options: CreateDashboardAgentToolOptions<TState>,\n): Tool {\n const {store, adapter} = options;\n\n return tool({\n description: `An AI agent that explores datasets and creates comprehensive dashboards with multiple visualizations.\n\nUse this for exploratory data analysis tasks like \"analyze the earthquakes dataset\" or \"create insights dashboard for sales data\".\n\nThe agent will query the data, discover patterns, and create charts and Data Table Explorers with findings.\n\nFor simple tasks like \"create a histogram of magnitude\", use the individual chart tools instead.\n\nIMPORTANT: Always provide tableName parameter when the user mentions a specific dataset.`,\n inputSchema: DashboardAgentInputSchema,\n execute: async (params, toolOptions): Promise<DashboardAgentResult> => {\n const {prompt, tableName, dashboardTitle, maxSteps, temperature} = params;\n\n let dashboardId = '';\n\n try {\n const state = store.getState();\n const table = validateTableExists(state, adapter, tableName);\n const resolvedTableName = table.tableId;\n\n dashboardId = getOrCreateDashboard(\n state,\n adapter,\n table.tableName,\n dashboardTitle,\n );\n adapter.setSelectedTable(state, dashboardId, resolvedTableName);\n const queryTools = options.createQueryTools?.({store});\n\n const dashboardAgent = new ToolLoopAgent({\n model: options.getModel({state}),\n tools: {\n ...(queryTools ?? {}),\n ...createDashboardAiTools({\n store,\n adapter,\n chartTypes: options.chartTypes,\n extraTools: options.extraTools,\n }),\n },\n temperature: Math.max(0, Math.min(1, temperature ?? 0.7)),\n stopWhen: [stepCountIs(Math.max(5, Math.min(50, maxSteps ?? 20)))],\n instructions: options.instructions ?? DASHBOARD_AGENT_INSTRUCTIONS,\n });\n\n const result = await options.runSubAgent({\n agent: dashboardAgent,\n prompt: buildAgentPrompt(prompt, resolvedTableName, state, adapter),\n store,\n parentToolCallId: toolOptions?.toolCallId || '',\n abortSignal: toolOptions?.abortSignal,\n });\n\n const finalState = store.getState();\n const metadata = calculateAgentMetadata(\n finalState,\n adapter,\n dashboardId,\n resolvedTableName,\n result.agentToolCalls || [],\n );\n\n return {\n success: true,\n finalOutput: result.finalOutput || 'Dashboard created successfully.',\n dashboardId,\n metadata,\n };\n } catch (error) {\n const errorMessage =\n error instanceof Error ? error.message : String(error);\n const friendlyMessage =\n error instanceof DashboardAgentException\n ? errorMessage\n : 'Dashboard agent execution failed.';\n\n return {\n success: false,\n finalOutput: friendlyMessage,\n dashboardId,\n error: errorMessage,\n };\n }\n },\n });\n}\n"]}
|
package/dist/ai.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,SAAS,CAAC"}
|
package/dist/ai.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,SAAS,CAAC","sourcesContent":["/**\n * AI tools and utilities for Mosaic dashboards\n * @packageDocumentation\n */\n\nexport * from './ai/ai';\n"]}
|
|
@@ -3,10 +3,12 @@ import type { ChartConfig } from './chart-types/chart-config';
|
|
|
3
3
|
import { DataTable } from '@sqlrooms/db';
|
|
4
4
|
export type MosaicChartProps = {
|
|
5
5
|
dataTable?: DataTable;
|
|
6
|
-
selectionName
|
|
6
|
+
selectionName?: string;
|
|
7
7
|
config: ChartConfig;
|
|
8
8
|
runtimeKey: string;
|
|
9
9
|
onConfigChange?: (config: ChartConfig) => void;
|
|
10
|
+
dashboardId?: string;
|
|
11
|
+
panelId?: string;
|
|
10
12
|
};
|
|
11
13
|
export declare const MosaicChart: FC<MosaicChartProps>;
|
|
12
14
|
//# sourceMappingURL=MosaicChart.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MosaicChart.d.ts","sourceRoot":"","sources":["../../src/charts/MosaicChart.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,EAAc,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAEvC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"MosaicChart.d.ts","sourceRoot":"","sources":["../../src/charts/MosaicChart.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAE,EAAc,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,4BAA4B,CAAC;AAE5D,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAEvC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,WAAW,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAoD5C,CAAC"}
|
|
@@ -3,11 +3,11 @@ import { useCallback } from 'react';
|
|
|
3
3
|
import { MosaicDashboardPanelLayout } from '../dashboard/panel/MosaicDashboardPanelLayout';
|
|
4
4
|
import { MosaicChartSettingsPanel } from './MosaicChartSettingsPanel';
|
|
5
5
|
import { MosaicChartView } from './MosaicChartView';
|
|
6
|
-
export const MosaicChart = ({ dataTable, selectionName, config, runtimeKey, onConfigChange, }) => {
|
|
6
|
+
export const MosaicChart = ({ dataTable, selectionName, config, runtimeKey, onConfigChange, dashboardId, panelId, }) => {
|
|
7
7
|
const handleOpenChange = useCallback((isOpen) => onConfigChange?.({ ...config, settingsOpen: isOpen }), [config, onConfigChange]);
|
|
8
8
|
const handleConfigChange = useCallback((newConfig) => onConfigChange?.(newConfig), [onConfigChange]);
|
|
9
9
|
const settingsContent = (_jsx(MosaicChartSettingsPanel, { dataTable: dataTable, config: config, onChange: handleConfigChange, onClose: () => handleOpenChange(false) }));
|
|
10
|
-
const chartContent = (_jsx("div", { className: "h-full overflow-auto p-2", children: _jsx(MosaicChartView, { dataTable: dataTable, config: config, selectionName: selectionName, retentionKey: runtimeKey, runtimeIssueKey: runtimeKey }) }));
|
|
10
|
+
const chartContent = (_jsx("div", { className: "h-full overflow-auto p-2", children: _jsx(MosaicChartView, { dataTable: dataTable, config: config, selectionName: selectionName, retentionKey: runtimeKey, runtimeIssueKey: runtimeKey, dashboardId: dashboardId, panelId: panelId }) }));
|
|
11
11
|
return (_jsx("div", { className: "h-full min-h-0", children: _jsx(MosaicDashboardPanelLayout, { isOpen: config.settingsOpen, onIsOpenChange: handleOpenChange, settings: settingsContent, content: chartContent }) }));
|
|
12
12
|
};
|
|
13
13
|
//# sourceMappingURL=MosaicChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MosaicChart.js","sourceRoot":"","sources":["../../src/charts/MosaicChart.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAU,WAAW,EAAC,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAC,0BAA0B,EAAC,MAAM,+CAA+C,CAAC;AACzF,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"MosaicChart.js","sourceRoot":"","sources":["../../src/charts/MosaicChart.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAU,WAAW,EAAC,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAC,0BAA0B,EAAC,MAAM,+CAA+C,CAAC;AACzF,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AAEpE,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAalD,MAAM,CAAC,MAAM,WAAW,GAAyB,CAAC,EAChD,SAAS,EACT,aAAa,EACb,MAAM,EACN,UAAU,EACV,cAAc,EACd,WAAW,EACX,OAAO,GACR,EAAE,EAAE;IACH,MAAM,gBAAgB,GAAG,WAAW,CAClC,CAAC,MAAe,EAAE,EAAE,CAAC,cAAc,EAAE,CAAC,EAAC,GAAG,MAAM,EAAE,YAAY,EAAE,MAAM,EAAC,CAAC,EACxE,CAAC,MAAM,EAAE,cAAc,CAAC,CACzB,CAAC;IAEF,MAAM,kBAAkB,GAAG,WAAW,CACpC,CAAC,SAAsB,EAAE,EAAE,CAAC,cAAc,EAAE,CAAC,SAAS,CAAC,EACvD,CAAC,cAAc,CAAC,CACjB,CAAC;IAEF,MAAM,eAAe,GAAG,CACtB,KAAC,wBAAwB,IACvB,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,kBAAkB,EAC5B,OAAO,EAAE,GAAG,EAAE,CAAC,gBAAgB,CAAC,KAAK,CAAC,GACtC,CACH,CAAC;IAEF,MAAM,YAAY,GAAG,CACnB,cAAK,SAAS,EAAC,0BAA0B,YACvC,KAAC,eAAe,IACd,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,EAC5B,YAAY,EAAE,UAAU,EACxB,eAAe,EAAE,UAAU,EAC3B,WAAW,EAAE,WAAW,EACxB,OAAO,EAAE,OAAO,GAChB,GACE,CACP,CAAC;IAEF,OAAO,CACL,cAAK,SAAS,EAAC,gBAAgB,YAC7B,KAAC,0BAA0B,IACzB,MAAM,EAAE,MAAM,CAAC,YAAY,EAC3B,cAAc,EAAE,gBAAgB,EAChC,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,YAAY,GACrB,GACE,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {type FC, useCallback} from 'react';\nimport {MosaicDashboardPanelLayout} from '../dashboard/panel/MosaicDashboardPanelLayout';\nimport {MosaicChartSettingsPanel} from './MosaicChartSettingsPanel';\nimport type {ChartConfig} from './chart-types/chart-config';\nimport {MosaicChartView} from './MosaicChartView';\nimport {DataTable} from '@sqlrooms/db';\n\nexport type MosaicChartProps = {\n dataTable?: DataTable;\n selectionName?: string;\n config: ChartConfig;\n runtimeKey: string;\n onConfigChange?: (config: ChartConfig) => void;\n dashboardId?: string;\n panelId?: string;\n};\n\nexport const MosaicChart: FC<MosaicChartProps> = ({\n dataTable,\n selectionName,\n config,\n runtimeKey,\n onConfigChange,\n dashboardId,\n panelId,\n}) => {\n const handleOpenChange = useCallback(\n (isOpen: boolean) => onConfigChange?.({...config, settingsOpen: isOpen}),\n [config, onConfigChange],\n );\n\n const handleConfigChange = useCallback(\n (newConfig: ChartConfig) => onConfigChange?.(newConfig),\n [onConfigChange],\n );\n\n const settingsContent = (\n <MosaicChartSettingsPanel\n dataTable={dataTable}\n config={config}\n onChange={handleConfigChange}\n onClose={() => handleOpenChange(false)}\n />\n );\n\n const chartContent = (\n <div className=\"h-full overflow-auto p-2\">\n <MosaicChartView\n dataTable={dataTable}\n config={config}\n selectionName={selectionName}\n retentionKey={runtimeKey}\n runtimeIssueKey={runtimeKey}\n dashboardId={dashboardId}\n panelId={panelId}\n />\n </div>\n );\n\n return (\n <div className=\"h-full min-h-0\">\n <MosaicDashboardPanelLayout\n isOpen={config.settingsOpen}\n onIsOpenChange={handleOpenChange}\n settings={settingsContent}\n content={chartContent}\n />\n </div>\n );\n};\n"]}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { type FC } from 'react';
|
|
2
2
|
type MosaicChartErrorProps = {
|
|
3
|
-
|
|
4
|
-
message: string;
|
|
3
|
+
error: Error;
|
|
5
4
|
};
|
|
5
|
+
/**
|
|
6
|
+
* Displays user-friendly error messages for chart configuration and validation errors.
|
|
7
|
+
* Renders specialized UI for known error types (RequiredFieldsError, MissingColumnsError,
|
|
8
|
+
* InvalidColumnTypeError) and a generic message for other errors.
|
|
9
|
+
*
|
|
10
|
+
* @param error - The error to display, typically from chart validation or creation
|
|
11
|
+
*/
|
|
6
12
|
export declare const MosaicChartError: FC<MosaicChartErrorProps>;
|
|
7
13
|
export {};
|
|
8
14
|
//# sourceMappingURL=MosaicChartError.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MosaicChartError.d.ts","sourceRoot":"","sources":["../../src/charts/MosaicChartError.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"MosaicChartError.d.ts","sourceRoot":"","sources":["../../src/charts/MosaicChartError.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,EAAE,EAAC,MAAM,OAAO,CAAC;AAQjD,KAAK,qBAAqB,GAAG;IAC3B,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CAwDtD,CAAC"}
|
|
@@ -1,5 +1,31 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { ChartSpecError, InvalidColumnTypeError, MissingColumnsError, RequiredFieldsError, } from './chart-types';
|
|
3
|
+
/**
|
|
4
|
+
* Displays user-friendly error messages for chart configuration and validation errors.
|
|
5
|
+
* Renders specialized UI for known error types (RequiredFieldsError, MissingColumnsError,
|
|
6
|
+
* InvalidColumnTypeError) and a generic message for other errors.
|
|
7
|
+
*
|
|
8
|
+
* @param error - The error to display, typically from chart validation or creation
|
|
9
|
+
*/
|
|
10
|
+
export const MosaicChartError = ({ error }) => {
|
|
11
|
+
if (error instanceof RequiredFieldsError) {
|
|
12
|
+
return (_jsxs(ErrorPanel, { title: "Configure chart to display visualization", children: [_jsx("span", { children: "Required fields are missing: " }), error.fieldNames.map((fieldName, index) => (_jsxs("span", { children: [_jsx(Pill, { children: fieldName }), ' '] }, index)))] }));
|
|
13
|
+
}
|
|
14
|
+
if (error instanceof MissingColumnsError) {
|
|
15
|
+
return (_jsxs(ErrorPanel, { title: "The visualization can't be displayed", children: [_jsx("span", { children: "Selected columns are missing in the dataset: " }), error.columnNames.map((column, idx) => (_jsxs("span", { children: [_jsx(Pill, { children: column }), ' '] }, idx)))] }));
|
|
16
|
+
}
|
|
17
|
+
if (error instanceof InvalidColumnTypeError) {
|
|
18
|
+
return (_jsxs(ErrorPanel, { title: "The visualization can't be displayed", children: [_jsxs("p", { children: [_jsx("span", { children: "Selected columns have invalid type: " }), error.columnNames.map((column, idx) => (_jsxs("span", { children: [_jsx(Pill, { children: column }), ' '] }, idx)))] }), _jsxs("p", { children: ["Expected type is ", _jsx(Pill, { children: error.expectedType }), "."] })] }));
|
|
19
|
+
}
|
|
20
|
+
if (error instanceof ChartSpecError) {
|
|
21
|
+
return (_jsx(ErrorPanel, { title: "Configure chart to display visualization", children: error.message }));
|
|
22
|
+
}
|
|
23
|
+
return (_jsx(ErrorPanel, { title: "Ooops! Something went wrong", children: error.message }));
|
|
24
|
+
};
|
|
25
|
+
const ErrorPanel = ({ title, children }) => {
|
|
26
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "text-center font-medium", children: title }), _jsx("div", { className: "text-center text-xs", children: children })] }));
|
|
27
|
+
};
|
|
28
|
+
const Pill = ({ children }) => {
|
|
29
|
+
return (_jsx("span", { className: "inline-flex items-center rounded-md border border-gray-600 bg-gray-800 px-1 py-0.5 text-xs font-medium text-gray-300", children: children }));
|
|
4
30
|
};
|
|
5
31
|
//# sourceMappingURL=MosaicChartError.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MosaicChartError.js","sourceRoot":"","sources":["../../src/charts/MosaicChartError.tsx"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"MosaicChartError.js","sourceRoot":"","sources":["../../src/charts/MosaicChartError.tsx"],"names":[],"mappings":";AACA,OAAO,EACL,cAAc,EACd,sBAAsB,EACtB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AAMvB;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA8B,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE;IACrE,IAAI,KAAK,YAAY,mBAAmB,EAAE,CAAC;QACzC,OAAO,CACL,MAAC,UAAU,IAAC,KAAK,EAAC,0CAA0C,aAC1D,2DAA0C,EACzC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC,CAC1C,2BACE,KAAC,IAAI,cAAE,SAAS,GAAQ,EAAC,GAAG,KADnB,KAAK,CAET,CACR,CAAC,IACS,CACd,CAAC;IACJ,CAAC;IAED,IAAI,KAAK,YAAY,mBAAmB,EAAE,CAAC;QACzC,OAAO,CACL,MAAC,UAAU,IAA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ACJ,CACR,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {PropsWithChildren, type FC} from 'react';\nimport {\n ChartSpecError,\n InvalidColumnTypeError,\n MissingColumnsError,\n RequiredFieldsError,\n} from './chart-types';\n\ntype MosaicChartErrorProps = {\n error: Error;\n};\n\n/**\n * Displays user-friendly error messages for chart configuration and validation errors.\n * Renders specialized UI for known error types (RequiredFieldsError, MissingColumnsError,\n * InvalidColumnTypeError) and a generic message for other errors.\n *\n * @param error - The error to display, typically from chart validation or creation\n */\nexport const MosaicChartError: FC<MosaicChartErrorProps> = ({error}) => {\n if (error instanceof RequiredFieldsError) {\n return (\n <ErrorPanel title=\"Configure chart to display visualization\">\n <span>Required fields are missing: </span>\n {error.fieldNames.map((fieldName, index) => (\n <span key={index}>\n <Pill>{fieldName}</Pill>{' '}\n </span>\n ))}\n </ErrorPanel>\n );\n }\n\n if (error instanceof MissingColumnsError) {\n return (\n <ErrorPanel title=\"The visualization can't be displayed\">\n <span>Selected columns are missing in the dataset: </span>\n {error.columnNames.map((column, idx) => (\n <span key={idx}>\n <Pill>{column}</Pill>{' '}\n </span>\n ))}\n </ErrorPanel>\n );\n }\n\n if (error instanceof InvalidColumnTypeError) {\n return (\n <ErrorPanel title=\"The visualization can't be displayed\">\n <p>\n <span>Selected columns have invalid type: </span>\n {error.columnNames.map((column, idx) => (\n <span key={idx}>\n <Pill>{column}</Pill>{' '}\n </span>\n ))}\n </p>\n <p>\n Expected type is <Pill>{error.expectedType}</Pill>.\n </p>\n </ErrorPanel>\n );\n }\n\n if (error instanceof ChartSpecError) {\n return (\n <ErrorPanel title=\"Configure chart to display visualization\">\n {error.message}\n </ErrorPanel>\n );\n }\n\n return (\n <ErrorPanel title=\"Ooops! Something went wrong\">{error.message}</ErrorPanel>\n );\n};\n\ntype ErrorPanelProps = PropsWithChildren<{\n title: string;\n}>;\n\nconst ErrorPanel: FC<ErrorPanelProps> = ({title, children}) => {\n return (\n <>\n <div className=\"text-center font-medium\">{title}</div>\n <div className=\"text-center text-xs\">{children}</div>\n </>\n );\n};\n\nconst Pill: FC<PropsWithChildren> = ({children}) => {\n return (\n <span className=\"inline-flex items-center rounded-md border border-gray-600 bg-gray-800 px-1 py-0.5 text-xs font-medium text-gray-300\">\n {children}\n </span>\n );\n};\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type FC } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Props for MosaicChartSettingsButton.
|
|
4
|
+
*
|
|
5
|
+
* @param className - Optional CSS class name
|
|
6
|
+
* @param isSettingsOpen - Whether settings panel is currently open
|
|
7
|
+
* @param onToggleSettings - Callback to toggle settings panel visibility
|
|
8
|
+
*/
|
|
9
|
+
export type MosaicChartSettingsButtonProps = {
|
|
10
|
+
className?: string;
|
|
11
|
+
isSettingsOpen?: boolean;
|
|
12
|
+
onToggleSettings: () => void;
|
|
13
|
+
};
|
|
14
|
+
export declare const MosaicChartSettingsButton: FC<MosaicChartSettingsButtonProps>;
|
|
15
|
+
//# sourceMappingURL=MosaicChartSettingsButton.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MosaicChartSettingsButton.d.ts","sourceRoot":"","sources":["../../src/charts/MosaicChartSettingsButton.tsx"],"names":[],"mappings":"AASA,OAAO,EAAC,KAAK,EAAE,EAAC,MAAM,OAAO,CAAC;AAE9B;;;;;;GAMG;AACH,MAAM,MAAM,8BAA8B,GAAG;IAC3C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,yBAAyB,EAAE,EAAE,CAAC,8BAA8B,CAuBxE,CAAC"}
|