@sqlrooms/mosaic 0.29.0-rc.4 → 0.29.0-rc.6
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/README.md +43 -39
- package/dist/DataPointLimitError.d.ts +9 -0
- package/dist/DataPointLimitError.d.ts.map +1 -0
- package/dist/DataPointLimitError.js +14 -0
- package/dist/DataPointLimitError.js.map +1 -0
- package/dist/MosaicSlice.d.ts.map +1 -1
- package/dist/MosaicSlice.js +3 -3
- package/dist/MosaicSlice.js.map +1 -1
- package/dist/VgPlotChart.d.ts +8 -11
- package/dist/VgPlotChart.d.ts.map +1 -1
- package/dist/VgPlotChart.js +74 -90
- package/dist/VgPlotChart.js.map +1 -1
- package/dist/VgPlotChartError.d.ts +7 -0
- package/dist/VgPlotChartError.d.ts.map +1 -0
- package/dist/VgPlotChartError.js +9 -0
- package/dist/VgPlotChartError.js.map +1 -0
- package/dist/ai.d.ts +103 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +445 -0
- package/dist/ai.js.map +1 -0
- package/dist/boxplot/BoxPlotClient.d.ts +7 -0
- package/dist/boxplot/BoxPlotClient.d.ts.map +1 -1
- package/dist/boxplot/BoxPlotClient.js +22 -0
- package/dist/boxplot/BoxPlotClient.js.map +1 -1
- package/dist/chart/ChartRuntimeIssuePanel.d.ts +7 -0
- package/dist/chart/ChartRuntimeIssuePanel.d.ts.map +1 -0
- package/dist/chart/ChartRuntimeIssuePanel.js +10 -0
- package/dist/chart/ChartRuntimeIssuePanel.js.map +1 -0
- package/dist/chart/MosaicDashboardChart.d.ts +1 -1
- package/dist/chart/MosaicDashboardChart.d.ts.map +1 -1
- package/dist/chart/MosaicDashboardChart.js +1 -1
- package/dist/chart/MosaicDashboardChart.js.map +1 -1
- package/dist/chart/MosaicDashboardChartContent.d.ts +1 -1
- package/dist/chart/MosaicDashboardChartContent.d.ts.map +1 -1
- package/dist/chart/MosaicDashboardChartContent.js +29 -2
- package/dist/chart/MosaicDashboardChartContent.js.map +1 -1
- package/dist/chart/MosaicDashboardChartRenderer.d.ts +2 -1
- package/dist/chart/MosaicDashboardChartRenderer.d.ts.map +1 -1
- package/dist/chart/MosaicDashboardChartRenderer.js +2 -2
- package/dist/chart/MosaicDashboardChartRenderer.js.map +1 -1
- package/dist/chart/MosaicDashboardComponentChart.d.ts +5 -1
- package/dist/chart/MosaicDashboardComponentChart.d.ts.map +1 -1
- package/dist/chart/MosaicDashboardComponentChart.js +4 -1
- package/dist/chart/MosaicDashboardComponentChart.js.map +1 -1
- package/dist/chart/MosaicDashboardVgPlotChart.d.ts +4 -0
- package/dist/chart/MosaicDashboardVgPlotChart.d.ts.map +1 -1
- package/dist/chart/MosaicDashboardVgPlotChart.js +2 -2
- package/dist/chart/MosaicDashboardVgPlotChart.js.map +1 -1
- package/dist/chart/addChartPanelAction.d.ts +3 -0
- package/dist/chart/addChartPanelAction.d.ts.map +1 -0
- package/dist/chart/addChartPanelAction.js +14 -0
- package/dist/chart/addChartPanelAction.js.map +1 -0
- package/dist/chart/chart-settings/ChartSettings.d.ts.map +1 -1
- package/dist/chart/chart-settings/ChartSettings.js +7 -4
- package/dist/chart/chart-settings/ChartSettings.js.map +1 -1
- package/dist/chart/chart-settings/ChartSettingsContent.d.ts +1 -1
- package/dist/chart/chart-settings/ChartSettingsContent.d.ts.map +1 -1
- package/dist/chart/chart-settings/ChartSettingsContent.js.map +1 -1
- package/dist/chart/chart-settings/ChartSettingsContext.d.ts +0 -2
- package/dist/chart/chart-settings/ChartSettingsContext.d.ts.map +1 -1
- package/dist/chart/chart-settings/ChartSettingsContext.js +6 -7
- package/dist/chart/chart-settings/ChartSettingsContext.js.map +1 -1
- package/dist/chart/chart-settings/ChartSettingsPanel.d.ts +1 -1
- package/dist/chart/chart-settings/ChartSettingsPanel.d.ts.map +1 -1
- package/dist/chart/chart-settings/ChartSettingsPanel.js +1 -1
- package/dist/chart/chart-settings/ChartSettingsPanel.js.map +1 -1
- package/dist/chart/chart-settings/ChartTypeSelector.d.ts.map +1 -1
- package/dist/chart/chart-settings/ChartTypeSelector.js +5 -5
- package/dist/chart/chart-settings/ChartTypeSelector.js.map +1 -1
- package/dist/chart-builders/ColumnSelector.d.ts +0 -2
- package/dist/chart-builders/ColumnSelector.d.ts.map +1 -1
- package/dist/chart-builders/ColumnSelector.js +4 -5
- package/dist/chart-builders/ColumnSelector.js.map +1 -1
- package/dist/chart-builders/ColumnsContext.d.ts +13 -0
- package/dist/chart-builders/ColumnsContext.d.ts.map +1 -0
- package/dist/chart-builders/ColumnsContext.js +15 -0
- package/dist/chart-builders/ColumnsContext.js.map +1 -0
- package/dist/chart-builders/MultiFieldSelector.js +4 -4
- package/dist/chart-builders/MultiFieldSelector.js.map +1 -1
- package/dist/chart-builders/TableSelector.d.ts +14 -0
- package/dist/chart-builders/TableSelector.d.ts.map +1 -0
- package/dist/chart-builders/TableSelector.js +23 -0
- package/dist/chart-builders/TableSelector.js.map +1 -0
- package/dist/chart-runtime.d.ts +50 -0
- package/dist/chart-runtime.d.ts.map +1 -0
- package/dist/chart-runtime.js +76 -0
- package/dist/chart-runtime.js.map +1 -0
- package/dist/chart-types/base-types.d.ts +45 -25
- package/dist/chart-types/base-types.d.ts.map +1 -1
- package/dist/chart-types/base-types.js.map +1 -1
- package/dist/chart-types/box-plot/definition.d.ts.map +1 -1
- package/dist/chart-types/box-plot/definition.js +5 -0
- package/dist/chart-types/box-plot/definition.js.map +1 -1
- package/dist/chart-types/box-plot/renderer/BoxPlotPanelRenderer.d.ts.map +1 -1
- package/dist/chart-types/box-plot/renderer/BoxPlotPanelRenderer.js +4 -1
- package/dist/chart-types/box-plot/renderer/BoxPlotPanelRenderer.js.map +1 -1
- package/dist/chart-types/box-plot/renderer/useBoxPlotClient.d.ts +4 -0
- package/dist/chart-types/box-plot/renderer/useBoxPlotClient.d.ts.map +1 -1
- package/dist/chart-types/box-plot/renderer/useBoxPlotClient.js +13 -2
- package/dist/chart-types/box-plot/renderer/useBoxPlotClient.js.map +1 -1
- package/dist/chart-types/box-plot/schema.d.ts +5 -0
- package/dist/chart-types/box-plot/schema.d.ts.map +1 -1
- package/dist/chart-types/box-plot/schema.js +2 -0
- package/dist/chart-types/box-plot/schema.js.map +1 -1
- package/dist/chart-types/box-plot/tool.d.ts +5 -9
- package/dist/chart-types/box-plot/tool.d.ts.map +1 -1
- package/dist/chart-types/box-plot/tool.js +14 -6
- package/dist/chart-types/box-plot/tool.js.map +1 -1
- package/dist/chart-types/bubble-chart/definition.d.ts.map +1 -1
- package/dist/chart-types/bubble-chart/definition.js +5 -0
- package/dist/chart-types/bubble-chart/definition.js.map +1 -1
- package/dist/chart-types/bubble-chart/schema.d.ts +5 -0
- package/dist/chart-types/bubble-chart/schema.d.ts.map +1 -1
- package/dist/chart-types/bubble-chart/schema.js +2 -0
- package/dist/chart-types/bubble-chart/schema.js.map +1 -1
- package/dist/chart-types/bubble-chart/tool.d.ts +5 -9
- package/dist/chart-types/bubble-chart/tool.d.ts.map +1 -1
- package/dist/chart-types/bubble-chart/tool.js +17 -9
- package/dist/chart-types/bubble-chart/tool.js.map +1 -1
- package/dist/chart-types/chart-config.d.ts +46 -0
- package/dist/chart-types/chart-config.d.ts.map +1 -1
- package/dist/chart-types/chart-config.js +2 -0
- package/dist/chart-types/chart-config.js.map +1 -1
- package/dist/chart-types/count-plot/schema.d.ts +5 -0
- package/dist/chart-types/count-plot/schema.d.ts.map +1 -1
- package/dist/chart-types/count-plot/schema.js +2 -0
- package/dist/chart-types/count-plot/schema.js.map +1 -1
- package/dist/chart-types/count-plot/tool.d.ts +5 -9
- package/dist/chart-types/count-plot/tool.d.ts.map +1 -1
- package/dist/chart-types/count-plot/tool.js +14 -6
- package/dist/chart-types/count-plot/tool.js.map +1 -1
- package/dist/chart-types/custom-spec/definition.d.ts.map +1 -1
- package/dist/chart-types/custom-spec/definition.js +5 -0
- package/dist/chart-types/custom-spec/definition.js.map +1 -1
- package/dist/chart-types/custom-spec/schema.d.ts +5 -0
- package/dist/chart-types/custom-spec/schema.d.ts.map +1 -1
- package/dist/chart-types/custom-spec/schema.js +2 -0
- package/dist/chart-types/custom-spec/schema.js.map +1 -1
- package/dist/chart-types/data-policy-schema.d.ts +8 -0
- package/dist/chart-types/data-policy-schema.d.ts.map +1 -0
- package/dist/chart-types/data-policy-schema.js +7 -0
- package/dist/chart-types/data-policy-schema.js.map +1 -0
- package/dist/chart-types/heatmap/schema.d.ts +5 -0
- package/dist/chart-types/heatmap/schema.d.ts.map +1 -1
- package/dist/chart-types/heatmap/schema.js +2 -0
- package/dist/chart-types/heatmap/schema.js.map +1 -1
- package/dist/chart-types/heatmap/tool.d.ts +5 -9
- package/dist/chart-types/heatmap/tool.d.ts.map +1 -1
- package/dist/chart-types/heatmap/tool.js +16 -8
- package/dist/chart-types/heatmap/tool.js.map +1 -1
- package/dist/chart-types/histogram/HistogramSettings.d.ts.map +1 -1
- package/dist/chart-types/histogram/HistogramSettings.js +4 -2
- package/dist/chart-types/histogram/HistogramSettings.js.map +1 -1
- package/dist/chart-types/histogram/schema.d.ts +10 -0
- package/dist/chart-types/histogram/schema.d.ts.map +1 -1
- package/dist/chart-types/histogram/schema.js +13 -0
- package/dist/chart-types/histogram/schema.js.map +1 -1
- package/dist/chart-types/histogram/spec.d.ts +1 -1
- package/dist/chart-types/histogram/spec.d.ts.map +1 -1
- package/dist/chart-types/histogram/spec.js +4 -3
- package/dist/chart-types/histogram/spec.js.map +1 -1
- package/dist/chart-types/histogram/tool.d.ts +7 -9
- package/dist/chart-types/histogram/tool.d.ts.map +1 -1
- package/dist/chart-types/histogram/tool.js +17 -7
- package/dist/chart-types/histogram/tool.js.map +1 -1
- package/dist/chart-types/index.d.ts +45 -3
- package/dist/chart-types/index.d.ts.map +1 -1
- package/dist/chart-types/index.js +8 -2
- package/dist/chart-types/index.js.map +1 -1
- package/dist/chart-types/line-chart/LineChartSettings.d.ts.map +1 -1
- package/dist/chart-types/line-chart/LineChartSettings.js +3 -1
- package/dist/chart-types/line-chart/LineChartSettings.js.map +1 -1
- package/dist/chart-types/line-chart/definition.d.ts.map +1 -1
- package/dist/chart-types/line-chart/definition.js +7 -0
- package/dist/chart-types/line-chart/definition.js.map +1 -1
- package/dist/chart-types/line-chart/schema.d.ts +5 -0
- package/dist/chart-types/line-chart/schema.d.ts.map +1 -1
- package/dist/chart-types/line-chart/schema.js +2 -0
- package/dist/chart-types/line-chart/schema.js.map +1 -1
- package/dist/chart-types/line-chart/tool.d.ts +5 -9
- package/dist/chart-types/line-chart/tool.d.ts.map +1 -1
- package/dist/chart-types/line-chart/tool.js +16 -8
- package/dist/chart-types/line-chart/tool.js.map +1 -1
- package/dist/chart-types/list-panels-tool.d.ts +35 -0
- package/dist/chart-types/list-panels-tool.d.ts.map +1 -0
- package/dist/chart-types/list-panels-tool.js +66 -0
- package/dist/chart-types/list-panels-tool.js.map +1 -0
- package/dist/chart-types/profiler-tool.d.ts +40 -0
- package/dist/chart-types/profiler-tool.d.ts.map +1 -0
- package/dist/chart-types/profiler-tool.js +73 -0
- package/dist/chart-types/profiler-tool.js.map +1 -0
- package/dist/chart-types/remove-panel-tool.d.ts +31 -0
- package/dist/chart-types/remove-panel-tool.d.ts.map +1 -0
- package/dist/chart-types/remove-panel-tool.js +55 -0
- package/dist/chart-types/remove-panel-tool.js.map +1 -0
- package/dist/chart-types/text-panel-tool.d.ts +42 -0
- package/dist/chart-types/text-panel-tool.d.ts.map +1 -0
- package/dist/chart-types/text-panel-tool.js +71 -0
- package/dist/chart-types/text-panel-tool.js.map +1 -0
- package/dist/chart-types/tool-helpers.d.ts +44 -0
- package/dist/chart-types/tool-helpers.d.ts.map +1 -0
- package/dist/chart-types/tool-helpers.js +129 -0
- package/dist/chart-types/tool-helpers.js.map +1 -0
- package/dist/chart-types/tool-schemas.d.ts +1 -0
- package/dist/chart-types/tool-schemas.d.ts.map +1 -1
- package/dist/chart-types/tool-schemas.js +5 -1
- package/dist/chart-types/tool-schemas.js.map +1 -1
- package/dist/dashboard/MosaicDashboard.d.ts +5 -2
- package/dist/dashboard/MosaicDashboard.d.ts.map +1 -1
- package/dist/dashboard/MosaicDashboard.js +20 -39
- package/dist/dashboard/MosaicDashboard.js.map +1 -1
- package/dist/dashboard/MosaicDashboardContext.d.ts +2 -0
- package/dist/dashboard/MosaicDashboardContext.d.ts.map +1 -1
- package/dist/dashboard/MosaicDashboardContext.js.map +1 -1
- package/dist/dashboard/MosaicDashboardEmptyState.d.ts.map +1 -1
- package/dist/dashboard/MosaicDashboardEmptyState.js +8 -44
- package/dist/dashboard/MosaicDashboardEmptyState.js.map +1 -1
- package/dist/dashboard/MosaicDashboardPanel.d.ts.map +1 -1
- package/dist/dashboard/MosaicDashboardPanel.js +2 -5
- package/dist/dashboard/MosaicDashboardPanel.js.map +1 -1
- package/dist/dashboard/MosaicDashboardPanelHeader.d.ts +2 -2
- package/dist/dashboard/MosaicDashboardPanelHeader.d.ts.map +1 -1
- package/dist/dashboard/MosaicDashboardPanelHeader.js +2 -2
- package/dist/dashboard/MosaicDashboardPanelHeader.js.map +1 -1
- package/dist/dashboard/MosaicDashboardPanels.d.ts.map +1 -1
- package/dist/dashboard/MosaicDashboardPanels.js +3 -2
- package/dist/dashboard/MosaicDashboardPanels.js.map +1 -1
- package/dist/dashboard/MosaicDashboardSlice.d.ts +185 -107
- package/dist/dashboard/MosaicDashboardSlice.d.ts.map +1 -1
- package/dist/dashboard/MosaicDashboardSlice.js +80 -57
- package/dist/dashboard/MosaicDashboardSlice.js.map +1 -1
- package/dist/dashboard/action-types.d.ts +25 -0
- package/dist/dashboard/action-types.d.ts.map +1 -0
- package/dist/dashboard/action-types.js +5 -0
- package/dist/dashboard/action-types.js.map +1 -0
- package/dist/dashboard/core-types.d.ts +26 -0
- package/dist/dashboard/core-types.d.ts.map +1 -0
- package/dist/dashboard/core-types.js +21 -0
- package/dist/dashboard/core-types.js.map +1 -0
- package/dist/dashboard/dashboard-types.d.ts +491 -0
- package/dist/dashboard/dashboard-types.d.ts.map +1 -0
- package/dist/dashboard/dashboard-types.js +54 -0
- package/dist/dashboard/dashboard-types.js.map +1 -0
- package/dist/dashboard/defaultPanelActions.d.ts +3 -0
- package/dist/dashboard/defaultPanelActions.d.ts.map +1 -0
- package/dist/dashboard/defaultPanelActions.js +9 -0
- package/dist/dashboard/defaultPanelActions.js.map +1 -0
- package/dist/dashboard/defaultPanelRenderers.d.ts.map +1 -1
- package/dist/dashboard/defaultPanelRenderers.js +1 -1
- package/dist/dashboard/defaultPanelRenderers.js.map +1 -1
- package/dist/dashboard/initial-state/BuildDashboardManuallyPanel.d.ts +6 -0
- package/dist/dashboard/initial-state/BuildDashboardManuallyPanel.d.ts.map +1 -0
- package/dist/dashboard/initial-state/BuildDashboardManuallyPanel.js +46 -0
- package/dist/dashboard/initial-state/BuildDashboardManuallyPanel.js.map +1 -0
- package/dist/dashboard/initial-state/BuildDashboardWithAIPanel.d.ts +7 -0
- package/dist/dashboard/initial-state/BuildDashboardWithAIPanel.d.ts.map +1 -0
- package/dist/dashboard/initial-state/BuildDashboardWithAIPanel.js +29 -0
- package/dist/dashboard/initial-state/BuildDashboardWithAIPanel.js.map +1 -0
- package/dist/dashboard/initial-state/MosaicDashboardInitialState.d.ts +6 -0
- package/dist/dashboard/initial-state/MosaicDashboardInitialState.d.ts.map +1 -0
- package/dist/dashboard/initial-state/MosaicDashboardInitialState.js +9 -0
- package/dist/dashboard/initial-state/MosaicDashboardInitialState.js.map +1 -0
- package/dist/dashboard/toolbar/MosaicDashboardAddPanelDropdown.d.ts +7 -0
- package/dist/dashboard/toolbar/MosaicDashboardAddPanelDropdown.d.ts.map +1 -0
- package/dist/dashboard/toolbar/MosaicDashboardAddPanelDropdown.js +12 -0
- package/dist/dashboard/toolbar/MosaicDashboardAddPanelDropdown.js.map +1 -0
- package/dist/dashboard/toolbar/MosaicDashboardResetFiltersButton.d.ts +7 -0
- package/dist/dashboard/toolbar/MosaicDashboardResetFiltersButton.d.ts.map +1 -0
- package/dist/dashboard/toolbar/MosaicDashboardResetFiltersButton.js +36 -0
- package/dist/dashboard/toolbar/MosaicDashboardResetFiltersButton.js.map +1 -0
- package/dist/dashboard/toolbar/MosaicDashboardToolbar.d.ts.map +1 -0
- package/dist/dashboard/toolbar/MosaicDashboardToolbar.js +15 -0
- package/dist/dashboard/toolbar/MosaicDashboardToolbar.js.map +1 -0
- package/dist/dashboard/useAddPanelActions.d.ts +10 -0
- package/dist/dashboard/useAddPanelActions.d.ts.map +1 -0
- package/dist/dashboard/useAddPanelActions.js +26 -0
- package/dist/dashboard/useAddPanelActions.js.map +1 -0
- package/dist/dashboard/useMosaicDashboardAddPanelActionContext.d.ts +3 -0
- package/dist/dashboard/useMosaicDashboardAddPanelActionContext.d.ts.map +1 -0
- package/dist/dashboard/useMosaicDashboardAddPanelActionContext.js +18 -0
- package/dist/dashboard/useMosaicDashboardAddPanelActionContext.js.map +1 -0
- package/dist/dashboard/useSelectedOrFirstTable.d.ts +10 -0
- package/dist/dashboard/useSelectedOrFirstTable.d.ts.map +1 -0
- package/dist/dashboard/useSelectedOrFirstTable.js +25 -0
- package/dist/dashboard/useSelectedOrFirstTable.js.map +1 -0
- package/dist/dashboard/useTablesWithColumns.d.ts +9 -0
- package/dist/dashboard/useTablesWithColumns.d.ts.map +1 -0
- package/dist/dashboard/useTablesWithColumns.js +13 -0
- package/dist/dashboard/useTablesWithColumns.js.map +1 -0
- package/dist/index.d.ts +25 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -2
- package/dist/index.js.map +1 -1
- package/dist/profiler/MosaicDashboardProfilerPanelRenderer.d.ts +2 -1
- package/dist/profiler/MosaicDashboardProfilerPanelRenderer.d.ts.map +1 -1
- package/dist/profiler/MosaicDashboardProfilerPanelRenderer.js +3 -3
- package/dist/profiler/MosaicDashboardProfilerPanelRenderer.js.map +1 -1
- package/dist/profiler/addProfilerPanelAction.d.ts +3 -0
- package/dist/profiler/addProfilerPanelAction.d.ts.map +1 -0
- package/dist/profiler/addProfilerPanelAction.js +9 -0
- package/dist/profiler/addProfilerPanelAction.js.map +1 -0
- package/dist/text/MosaicDashboardTextRenderer.d.ts +2 -1
- package/dist/text/MosaicDashboardTextRenderer.d.ts.map +1 -1
- package/dist/text/MosaicDashboardTextRenderer.js +4 -4
- package/dist/text/MosaicDashboardTextRenderer.js.map +1 -1
- package/dist/text/addTextPanelAction.d.ts +3 -0
- package/dist/text/addTextPanelAction.d.ts.map +1 -0
- package/dist/text/addTextPanelAction.js +9 -0
- package/dist/text/addTextPanelAction.js.map +1 -0
- package/dist/useMosaicClient.d.ts +4 -0
- package/dist/useMosaicClient.d.ts.map +1 -1
- package/dist/useMosaicClient.js +33 -3
- package/dist/useMosaicClient.js.map +1 -1
- package/dist/useVgPlotChartError.d.ts +13 -0
- package/dist/useVgPlotChartError.d.ts.map +1 -0
- package/dist/useVgPlotChartError.js +18 -0
- package/dist/useVgPlotChartError.js.map +1 -0
- package/dist/useVgPlotChartRender.d.ts +24 -0
- package/dist/useVgPlotChartRender.d.ts.map +1 -0
- package/dist/useVgPlotChartRender.js +152 -0
- package/dist/useVgPlotChartRender.js.map +1 -0
- package/dist/useVgPlotChartRetention.d.ts +21 -0
- package/dist/useVgPlotChartRetention.d.ts.map +1 -0
- package/dist/useVgPlotChartRetention.js +63 -0
- package/dist/useVgPlotChartRetention.js.map +1 -0
- package/dist/wrapCoordinatorWithValidation.d.ts +11 -0
- package/dist/wrapCoordinatorWithValidation.d.ts.map +1 -0
- package/dist/wrapCoordinatorWithValidation.js +23 -0
- package/dist/wrapCoordinatorWithValidation.js.map +1 -0
- package/package.json +31 -13
- package/dist/dashboard/MosaicDashboardToolbar.d.ts.map +0 -1
- package/dist/dashboard/MosaicDashboardToolbar.js +0 -86
- package/dist/dashboard/MosaicDashboardToolbar.js.map +0 -1
- /package/dist/dashboard/{MosaicDashboardToolbar.d.ts → toolbar/MosaicDashboardToolbar.d.ts} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VgPlotChartError.d.ts","sourceRoot":"","sources":["../src/VgPlotChartError.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,EAAE,EAAC,MAAM,OAAO,CAAC;AAGzB,KAAK,qBAAqB,GAAG;IAC3B,KAAK,EAAE,KAAK,CAAC;CACd,CAAC;AAEF,eAAO,MAAM,gBAAgB,EAAE,EAAE,CAAC,qBAAqB,CActD,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { DataPointLimitError } from './DataPointLimitError';
|
|
3
|
+
export const VgPlotChartError = ({ error }) => {
|
|
4
|
+
const title = error instanceof DataPointLimitError
|
|
5
|
+
? 'Too much data'
|
|
6
|
+
: 'Unable to display chart';
|
|
7
|
+
return (_jsxs("div", { className: "flex h-full min-h-[200px] flex-col items-center justify-center p-4", children: [_jsx("div", { className: "mb-2 text-center font-semibold", children: title }), _jsx("div", { className: "text-center text-sm whitespace-pre-wrap", children: error.message })] }));
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=VgPlotChartError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VgPlotChartError.js","sourceRoot":"","sources":["../src/VgPlotChartError.tsx"],"names":[],"mappings":";AACA,OAAO,EAAC,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAM1D,MAAM,CAAC,MAAM,gBAAgB,GAA8B,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE;IACrE,MAAM,KAAK,GACT,KAAK,YAAY,mBAAmB;QAClC,CAAC,CAAC,eAAe;QACjB,CAAC,CAAC,yBAAyB,CAAC;IAEhC,OAAO,CACL,eAAK,SAAS,EAAC,oEAAoE,aACjF,cAAK,SAAS,EAAC,gCAAgC,YAAE,KAAK,GAAO,EAC7D,cAAK,SAAS,EAAC,yCAAyC,YACrD,KAAK,CAAC,OAAO,GACV,IACF,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {FC} from 'react';\nimport {DataPointLimitError} from './DataPointLimitError';\n\ntype VgPlotChartErrorProps = {\n error: Error;\n};\n\nexport const VgPlotChartError: FC<VgPlotChartErrorProps> = ({error}) => {\n const title =\n error instanceof DataPointLimitError\n ? 'Too much data'\n : 'Unable to display chart';\n\n return (\n <div className=\"flex h-full min-h-[200px] flex-col items-center justify-center p-4\">\n <div className=\"mb-2 text-center font-semibold\">{title}</div>\n <div className=\"text-center text-sm whitespace-pre-wrap\">\n {error.message}\n </div>\n </div>\n );\n};\n"]}
|
package/dist/ai.d.ts
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reusable AI helpers for Mosaic dashboards.
|
|
3
|
+
*
|
|
4
|
+
* Host apps provide a narrow adapter for their store/artifact model; Mosaic owns
|
|
5
|
+
* the dashboard tool behavior and prompts.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { type LanguageModel, type Tool, ToolLoopAgent } from 'ai';
|
|
10
|
+
import { type ChartBuilderColumn, type ChartToolExecutionContext, type DashboardToolDeps, type PanelPatch, type ChartTypeDefinition } from './chart-types';
|
|
11
|
+
import type { MosaicDashboardEntry, MosaicDashboardPanelConfig } from './dashboard/dashboard-types';
|
|
12
|
+
import type { MosaicDashboardLayoutType } from './dashboard/core-types';
|
|
13
|
+
import { type ChartRuntimeIssue } from './chart-runtime';
|
|
14
|
+
export type { ChartToolExecutionContext } from './chart-types';
|
|
15
|
+
export type DashboardAiStore<TState> = {
|
|
16
|
+
getState: () => TState;
|
|
17
|
+
};
|
|
18
|
+
export type DashboardAiTable = {
|
|
19
|
+
tableName: string;
|
|
20
|
+
columns?: ChartBuilderColumn[];
|
|
21
|
+
rowCount?: number;
|
|
22
|
+
};
|
|
23
|
+
export type DashboardAiAdapter<TState> = {
|
|
24
|
+
getTables: (state: TState) => DashboardAiTable[];
|
|
25
|
+
hasRunContext?: (state: TState, context?: ChartToolExecutionContext) => boolean;
|
|
26
|
+
resolveContextDashboardArtifactId?: (state: TState, context?: ChartToolExecutionContext) => string | undefined;
|
|
27
|
+
makeDashboardPrimaryForRun?: (state: TState, dashboardId: string, context?: ChartToolExecutionContext) => void;
|
|
28
|
+
getCurrentDashboardArtifactId: (state: TState) => string | undefined;
|
|
29
|
+
createDashboardArtifact: (state: TState, title?: string, layoutType?: MosaicDashboardLayoutType) => string;
|
|
30
|
+
isDashboardArtifact: (state: TState, artifactId: string) => boolean;
|
|
31
|
+
setCurrentArtifact: (state: TState, artifactId: string) => void;
|
|
32
|
+
ensureDashboard: (state: TState, dashboardId: string, title?: string, layoutType?: MosaicDashboardLayoutType) => void;
|
|
33
|
+
getDashboard: (state: TState, dashboardId: string) => MosaicDashboardEntry | undefined;
|
|
34
|
+
getPanelIssue?: (state: TState, dashboardId: string, panelId: string) => ChartRuntimeIssue | undefined;
|
|
35
|
+
setSelectedTable: (state: TState, dashboardId: string, tableName: string) => void;
|
|
36
|
+
addPanel: (state: TState, dashboardId: string, panel: MosaicDashboardPanelConfig) => string;
|
|
37
|
+
updatePanel: (state: TState, dashboardId: string, panelId: string, patch: Partial<PanelPatch>) => void;
|
|
38
|
+
removePanel: (state: TState, dashboardId: string, panelId: string) => void;
|
|
39
|
+
};
|
|
40
|
+
export type CreateDashboardToolDepsOptions<TState> = {
|
|
41
|
+
store: DashboardAiStore<TState>;
|
|
42
|
+
adapter: DashboardAiAdapter<TState>;
|
|
43
|
+
};
|
|
44
|
+
export type CreateDashboardAiToolsOptions<TState> = CreateDashboardToolDepsOptions<TState> & {
|
|
45
|
+
chartTypes?: ChartTypeDefinition<any>[];
|
|
46
|
+
/**
|
|
47
|
+
* Host-provided dashboard tools keyed by their registered tool name.
|
|
48
|
+
* Register geospatial map tools under MAP_TOOL_KEY so prompts and tools
|
|
49
|
+
* stay in sync.
|
|
50
|
+
*/
|
|
51
|
+
extraTools?: (deps: DashboardToolDeps) => Record<string, Tool>;
|
|
52
|
+
};
|
|
53
|
+
export type DashboardAgentToolCall = {
|
|
54
|
+
toolName: string;
|
|
55
|
+
};
|
|
56
|
+
export type DashboardAgentRunResult = {
|
|
57
|
+
finalOutput?: string;
|
|
58
|
+
agentToolCalls?: DashboardAgentToolCall[];
|
|
59
|
+
};
|
|
60
|
+
export type DashboardAgentResult = {
|
|
61
|
+
success: boolean;
|
|
62
|
+
finalOutput: string;
|
|
63
|
+
dashboardId: string;
|
|
64
|
+
error?: string;
|
|
65
|
+
metadata?: {
|
|
66
|
+
tableName: string;
|
|
67
|
+
panelsCreated: number;
|
|
68
|
+
stepsExecuted: number;
|
|
69
|
+
queriesRun: number;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
export type CreateDashboardAgentToolOptions<TState> = CreateDashboardToolDepsOptions<TState> & {
|
|
73
|
+
getModel: (args: {
|
|
74
|
+
state: TState;
|
|
75
|
+
}) => LanguageModel;
|
|
76
|
+
createQueryTools?: (args: {
|
|
77
|
+
store: DashboardAiStore<TState>;
|
|
78
|
+
}) => {
|
|
79
|
+
query: Tool;
|
|
80
|
+
};
|
|
81
|
+
runSubAgent: (args: {
|
|
82
|
+
agent: ToolLoopAgent<any, any, any>;
|
|
83
|
+
prompt: string;
|
|
84
|
+
store: DashboardAiStore<TState>;
|
|
85
|
+
parentToolCallId: string;
|
|
86
|
+
abortSignal?: AbortSignal;
|
|
87
|
+
}) => Promise<DashboardAgentRunResult>;
|
|
88
|
+
instructions?: string;
|
|
89
|
+
chartTypes?: ChartTypeDefinition<any>[];
|
|
90
|
+
/**
|
|
91
|
+
* Host-provided dashboard tools keyed by their registered tool name.
|
|
92
|
+
* Register geospatial map tools under MAP_TOOL_KEY so prompts and tools
|
|
93
|
+
* stay in sync.
|
|
94
|
+
*/
|
|
95
|
+
extraTools?: (deps: DashboardToolDeps) => Record<string, Tool>;
|
|
96
|
+
};
|
|
97
|
+
export declare const MAP_TOOL_KEY = "create_dashboard_map";
|
|
98
|
+
export declare 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 `create_dashboard_map`, 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";
|
|
99
|
+
export declare 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, profilers, text annotations). 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_profiler - table statistics and column summaries\n- create_dashboard_text_panel - markdown annotations and insights\n- create_dashboard_map - 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. **ALWAYS create ONE text panel** with a concise summary of ALL key findings\n4. Stop when dashboard tells coherent story\n\n**CRITICAL:**\n- Create exactly ONE text panel with insights summary (can be first, last, or in between)\n- Insights should be concise but USEFUL - each bullet should provide actionable or interesting information\n- Include specific numbers, percentages, and comparisons that tell the story\n- Use query tool to discover actual patterns, don't make vague statements\n- Focus on 3-5 most important findings that answer \"what's interesting about this data?\"\n- Do NOT create additional text panels unless absolutely necessary\n\n**Good insight examples:**\n- \"Peak activity between 4-5 magnitude (62% of events)\" - specific, actionable\n- \"Strong correlation (0.73) between depth and magnitude suggests tectonic pattern\" - specific with interpretation\n- \"California accounts for 3,234/5,234 events (62%), followed by Japan (18%)\" - specific comparison\n\n**Bad insight examples:**\n- \"Dataset has data\" - useless\n- \"Various magnitudes observed\" - vague\n- \"Interesting patterns found\" - not specific\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- **ONE text panel for exploratory requests:** Always create exactly ONE text panel with insights summary when exploring data. It can be created at any point in the workflow.\n- **Make insights useful, not just concise:** Each bullet should include specific numbers, percentages, or patterns discovered through queries. Avoid vague statements.\n- **Use queries to find real insights:** Run queries to discover actual patterns (correlations, distributions, outliers, top values). Don't make assumptions.\n- **No additional text panels:** Do NOT create multiple text panels. All insights go in the single summary panel.\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- **Use markdown formatting:** Use headings (##), bullet lists (-), and **bold** in text panels for readability";
|
|
100
|
+
export declare function createDashboardToolDeps<TState>({ store, adapter, }: CreateDashboardToolDepsOptions<TState>): DashboardToolDeps;
|
|
101
|
+
export declare function createDashboardAiTools<TState>({ store, adapter, chartTypes, extraTools, }: CreateDashboardAiToolsOptions<TState>): Record<string, Tool>;
|
|
102
|
+
export declare function createDashboardAgentTool<TState>(options: CreateDashboardAgentToolOptions<TState>): Tool;
|
|
103
|
+
//# sourceMappingURL=ai.d.ts.map
|
package/dist/ai.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../src/ai.ts"],"names":[],"mappings":"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"}
|
package/dist/ai.js
ADDED
|
@@ -0,0 +1,445 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reusable AI helpers for Mosaic dashboards.
|
|
3
|
+
*
|
|
4
|
+
* Host apps provide a narrow adapter for their store/artifact model; Mosaic owns
|
|
5
|
+
* the dashboard tool behavior and prompts.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { ToolLoopAgent, stepCountIs, tool, } from 'ai';
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
import { createChartTools, createDefaultChartTypes, createListPanelsTool, createProfilerTool, createRemovePanelTool, createTextPanelTool, } from './chart-types';
|
|
12
|
+
import { DEFAULT_CHART_MAX_DATA_POINTS, } from './chart-runtime';
|
|
13
|
+
export const MAP_TOOL_KEY = 'create_dashboard_map';
|
|
14
|
+
export const DASHBOARD_AI_INSTRUCTIONS = `
|
|
15
|
+
Dashboard authoring:
|
|
16
|
+
|
|
17
|
+
**When to use dashboard_agent vs individual tools:**
|
|
18
|
+
- Use \`dashboard_agent\` for exploratory requests that require data analysis and discovery:
|
|
19
|
+
- "analyze the earthquakes dataset"
|
|
20
|
+
- "create insights dashboard for sales data"
|
|
21
|
+
- "find interesting patterns in customer behavior"
|
|
22
|
+
- Any request asking to "discover", "explore", "find insights", or "analyze"
|
|
23
|
+
- Use individual chart tools for direct, specific requests:
|
|
24
|
+
- "create histogram of magnitude with 20 bins"
|
|
25
|
+
- "add a line chart showing sales over time"
|
|
26
|
+
- "update the histogram to use 30 bins"
|
|
27
|
+
|
|
28
|
+
**Individual dashboard chart tools:**
|
|
29
|
+
- create_dashboard_histogram, create_dashboard_line_chart, create_dashboard_box_plot, create_dashboard_bubble_chart, create_dashboard_count_plot, create_dashboard_heatmap
|
|
30
|
+
- Each chart type has its own tool with specific parameters.
|
|
31
|
+
- For line charts with aggregation, use yFields array with {field: string, aggregate: "sum"|"avg"|"min"|"max"}.
|
|
32
|
+
- Set xInterval for temporal binning (year, month, day, hour, etc.).
|
|
33
|
+
- 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"}\`.
|
|
34
|
+
- Use \`set_dashboard_vgplot\` with complete JSON only when no chart tool fits your needs.
|
|
35
|
+
- When calling \`create_dashboard_artifact\`, \`layoutType\` may be \`grid\` or \`dock\`; omitted values default to \`grid\`.
|
|
36
|
+
- 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 bubble charts to heatmaps, add \`xInterval\` to too-large line charts, and inspect columns/settings for SQL errors.
|
|
38
|
+
`;
|
|
39
|
+
export const DASHBOARD_AGENT_INSTRUCTIONS = `You are a dashboard builder agent that creates and modifies interactive data dashboards.
|
|
40
|
+
|
|
41
|
+
## Your Role
|
|
42
|
+
|
|
43
|
+
You analyze data and create insightful dashboards with multiple visualizations (charts, profilers, text annotations). You can handle both direct requests ("create histogram of magnitude") and exploratory requests ("find interesting insights in earthquakes dataset").
|
|
44
|
+
|
|
45
|
+
## Available Tools
|
|
46
|
+
|
|
47
|
+
**Chart Tools:**
|
|
48
|
+
- create_dashboard_histogram - distribution of numeric values (always safe, aggregates automatically)
|
|
49
|
+
- create_dashboard_line_chart - trends over time or ordered variable (use with aggregations for >10k rows)
|
|
50
|
+
- create_dashboard_box_plot - compare distributions across categories
|
|
51
|
+
- create_dashboard_bubble_chart - relationship between two numeric columns (avoid for >10k rows, use heatmap instead)
|
|
52
|
+
- create_dashboard_count_plot - frequency of categorical values (always safe, aggregates automatically)
|
|
53
|
+
- create_dashboard_heatmap - density/patterns across two dimensions (preferred for large datasets)
|
|
54
|
+
|
|
55
|
+
**Panel Tools:**
|
|
56
|
+
- create_dashboard_profiler - table statistics and column summaries
|
|
57
|
+
- create_dashboard_text_panel - markdown annotations and insights
|
|
58
|
+
- ${MAP_TOOL_KEY} - native Deck JSON geospatial map panel (if provided by the host app)
|
|
59
|
+
|
|
60
|
+
**Data Tools:**
|
|
61
|
+
- query - execute SQL queries for data exploration
|
|
62
|
+
|
|
63
|
+
**Management Tools:**
|
|
64
|
+
- list_dashboard_panels - discover panel IDs and what's on the dashboard
|
|
65
|
+
- remove_dashboard_panel - delete a panel by ID
|
|
66
|
+
|
|
67
|
+
## Workflows
|
|
68
|
+
|
|
69
|
+
### Direct Requests
|
|
70
|
+
When user provides specific instructions:
|
|
71
|
+
1. Parse intent -> identify chart type
|
|
72
|
+
2. Call appropriate tool with settings
|
|
73
|
+
3. Done
|
|
74
|
+
|
|
75
|
+
Example: "create histogram of magnitude with 20 bins"
|
|
76
|
+
-> create_dashboard_histogram(settings: {field: "magnitude", bins: 20})
|
|
77
|
+
|
|
78
|
+
### Exploratory Requests
|
|
79
|
+
When user asks to discover insights:
|
|
80
|
+
1. Use query tool to explore data:
|
|
81
|
+
- Start with simple stats: COUNT, MIN, MAX, AVG, DISTINCT (check total row count!)
|
|
82
|
+
- Check distributions: GROUP BY with COUNT
|
|
83
|
+
- Find correlations: CORR(col1, col2)
|
|
84
|
+
- Identify outliers and patterns
|
|
85
|
+
2. Create targeted charts based on discoveries:
|
|
86
|
+
- If dataset has >10k rows: avoid bubble charts and unaggregated line charts
|
|
87
|
+
- Use histogram, count plot, heatmap, or aggregated visualizations instead
|
|
88
|
+
3. **ALWAYS create ONE text panel** with a concise summary of ALL key findings
|
|
89
|
+
4. Stop when dashboard tells coherent story
|
|
90
|
+
|
|
91
|
+
**CRITICAL:**
|
|
92
|
+
- Create exactly ONE text panel with insights summary (can be first, last, or in between)
|
|
93
|
+
- Insights should be concise but USEFUL - each bullet should provide actionable or interesting information
|
|
94
|
+
- Include specific numbers, percentages, and comparisons that tell the story
|
|
95
|
+
- Use query tool to discover actual patterns, don't make vague statements
|
|
96
|
+
- Focus on 3-5 most important findings that answer "what's interesting about this data?"
|
|
97
|
+
- Do NOT create additional text panels unless absolutely necessary
|
|
98
|
+
|
|
99
|
+
**Good insight examples:**
|
|
100
|
+
- "Peak activity between 4-5 magnitude (62% of events)" - specific, actionable
|
|
101
|
+
- "Strong correlation (0.73) between depth and magnitude suggests tectonic pattern" - specific with interpretation
|
|
102
|
+
- "California accounts for 3,234/5,234 events (62%), followed by Japan (18%)" - specific comparison
|
|
103
|
+
|
|
104
|
+
**Bad insight examples:**
|
|
105
|
+
- "Dataset has data" - useless
|
|
106
|
+
- "Various magnitudes observed" - vague
|
|
107
|
+
- "Interesting patterns found" - not specific
|
|
108
|
+
|
|
109
|
+
### Update Requests
|
|
110
|
+
To update existing panels:
|
|
111
|
+
1. Call list_dashboard_panels() to discover panel IDs
|
|
112
|
+
2. Call appropriate create tool with panelId parameter
|
|
113
|
+
3. Panel is updated in-place
|
|
114
|
+
|
|
115
|
+
## Query Guidelines
|
|
116
|
+
|
|
117
|
+
**Keep queries simple:**
|
|
118
|
+
- Start with aggregations: COUNT, MIN, MAX, AVG, SUM
|
|
119
|
+
- Use GROUP BY for breakdowns and distributions
|
|
120
|
+
- Use LIMIT to control result size (especially with GROUP BY)
|
|
121
|
+
- Avoid expensive operations: large JOINs, full table scans
|
|
122
|
+
|
|
123
|
+
**Exploration strategy:**
|
|
124
|
+
- Limit exploration to 5-10 queries per request
|
|
125
|
+
- Start broad (overall stats), then narrow (specific patterns)
|
|
126
|
+
- Stop when you have enough insights for a coherent dashboard
|
|
127
|
+
|
|
128
|
+
## Best Practices
|
|
129
|
+
|
|
130
|
+
- **ONE text panel for exploratory requests:** Always create exactly ONE text panel with insights summary when exploring data. It can be created at any point in the workflow.
|
|
131
|
+
- **Make insights useful, not just concise:** Each bullet should include specific numbers, percentages, or patterns discovered through queries. Avoid vague statements.
|
|
132
|
+
- **Use queries to find real insights:** Run queries to discover actual patterns (correlations, distributions, outliers, top values). Don't make assumptions.
|
|
133
|
+
- **No additional text panels:** Do NOT create multiple text panels. All insights go in the single summary panel.
|
|
134
|
+
- **Avoid unaggregated charts for large datasets:** For datasets >10k rows, DO NOT use bubble charts or line charts without aggregations. Use aggregated alternatives instead:
|
|
135
|
+
- For scatter/bubble plots: use heatmap or binned aggregations
|
|
136
|
+
- For line charts: use GROUP BY with time buckets or aggregations
|
|
137
|
+
- Histograms and count plots are always safe (they aggregate automatically)
|
|
138
|
+
- **Check before update:** Always call list_dashboard_panels before updating/removing panels
|
|
139
|
+
- **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.
|
|
140
|
+
- **Validate columns:** Query tools will validate column existence and types
|
|
141
|
+
- **Handle errors gracefully:** If a query or chart creation fails, try alternative approach
|
|
142
|
+
- **Use markdown formatting:** Use headings (##), bullet lists (-), and **bold** in text panels for readability`;
|
|
143
|
+
const DashboardCreateArtifactToolParameters = z.object({
|
|
144
|
+
title: z.string().optional(),
|
|
145
|
+
layoutType: z
|
|
146
|
+
.enum(['dock', 'grid'])
|
|
147
|
+
.optional()
|
|
148
|
+
.default('grid')
|
|
149
|
+
.describe('Dashboard layout node type to use at creation time.'),
|
|
150
|
+
});
|
|
151
|
+
const DashboardAgentInputSchema = z.object({
|
|
152
|
+
reasoning: z
|
|
153
|
+
.string()
|
|
154
|
+
.describe('Reasoning for why the dashboard agent is being called'),
|
|
155
|
+
prompt: z
|
|
156
|
+
.string()
|
|
157
|
+
.describe('The exploratory data analysis prompt for the agent'),
|
|
158
|
+
tableName: z
|
|
159
|
+
.string()
|
|
160
|
+
.describe('REQUIRED: The name of the table/dataset to analyze.'),
|
|
161
|
+
dashboardTitle: z
|
|
162
|
+
.string()
|
|
163
|
+
.optional()
|
|
164
|
+
.describe('Optional title for the dashboard artifact'),
|
|
165
|
+
maxSteps: z
|
|
166
|
+
.number()
|
|
167
|
+
.optional()
|
|
168
|
+
.default(20)
|
|
169
|
+
.describe('Maximum exploration steps (default: 20, range: 5-50)'),
|
|
170
|
+
temperature: z
|
|
171
|
+
.number()
|
|
172
|
+
.optional()
|
|
173
|
+
.default(0.7)
|
|
174
|
+
.describe('Model temperature for creativity vs consistency (default: 0.7, range: 0.0-1.0)'),
|
|
175
|
+
});
|
|
176
|
+
class DashboardAgentException extends Error {
|
|
177
|
+
constructor(message) {
|
|
178
|
+
super(message);
|
|
179
|
+
this.name = 'DashboardAgentException';
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
function getTablesWithColumns(state, adapter) {
|
|
183
|
+
return adapter
|
|
184
|
+
.getTables(state)
|
|
185
|
+
.filter((table) => table.columns && table.columns.length > 0);
|
|
186
|
+
}
|
|
187
|
+
function findTableColumns(state, adapter, tableName) {
|
|
188
|
+
const table = getTablesWithColumns(state, adapter).find((candidate) => candidate.tableName === tableName);
|
|
189
|
+
if (!table?.columns)
|
|
190
|
+
return null;
|
|
191
|
+
return table.columns.map((column) => ({
|
|
192
|
+
name: column.name,
|
|
193
|
+
type: column.type,
|
|
194
|
+
}));
|
|
195
|
+
}
|
|
196
|
+
function formatAvailableTables(tables) {
|
|
197
|
+
return tables.map((table) => table.tableName).join(', ') || '(none)';
|
|
198
|
+
}
|
|
199
|
+
export function createDashboardToolDeps({ store, adapter, }) {
|
|
200
|
+
const resolveArtifact = (artifactId, createIfMissing, context) => {
|
|
201
|
+
const state = store.getState();
|
|
202
|
+
const hasRunContext = adapter.hasRunContext?.(state, context) ?? false;
|
|
203
|
+
const contextDashboardArtifactId = adapter.resolveContextDashboardArtifactId?.(state, context);
|
|
204
|
+
let targetArtifactId = artifactId ??
|
|
205
|
+
contextDashboardArtifactId ??
|
|
206
|
+
(!hasRunContext
|
|
207
|
+
? adapter.getCurrentDashboardArtifactId(state)
|
|
208
|
+
: undefined);
|
|
209
|
+
if (!targetArtifactId && hasRunContext) {
|
|
210
|
+
throw new Error('No primary dashboard artifact is available in the current run context. Pass artifactId explicitly or use set_primary_context_artifact first.');
|
|
211
|
+
}
|
|
212
|
+
if (!targetArtifactId && createIfMissing) {
|
|
213
|
+
targetArtifactId = adapter.createDashboardArtifact(state, undefined, 'grid');
|
|
214
|
+
adapter.setCurrentArtifact(state, targetArtifactId);
|
|
215
|
+
adapter.makeDashboardPrimaryForRun?.(state, targetArtifactId, context);
|
|
216
|
+
}
|
|
217
|
+
if (!targetArtifactId) {
|
|
218
|
+
throw new Error('No dashboard artifact is available. Set createArtifactIfMissing=true or create one first.');
|
|
219
|
+
}
|
|
220
|
+
if (!adapter.isDashboardArtifact(state, targetArtifactId)) {
|
|
221
|
+
throw new Error(`Artifact "${targetArtifactId}" is not a dashboard artifact.`);
|
|
222
|
+
}
|
|
223
|
+
adapter.ensureDashboard(state, targetArtifactId);
|
|
224
|
+
return targetArtifactId;
|
|
225
|
+
};
|
|
226
|
+
const resolveTable = (artifactId, tableName) => {
|
|
227
|
+
const state = store.getState();
|
|
228
|
+
const tables = getTablesWithColumns(state, adapter);
|
|
229
|
+
const dashboard = adapter.getDashboard(state, artifactId);
|
|
230
|
+
const explicitTableName = tableName?.trim() || undefined;
|
|
231
|
+
if (explicitTableName) {
|
|
232
|
+
const columns = findTableColumns(state, adapter, explicitTableName);
|
|
233
|
+
if (!columns) {
|
|
234
|
+
throw new Error(`Unknown table "${explicitTableName}". Available tables: ${formatAvailableTables(tables)}.`);
|
|
235
|
+
}
|
|
236
|
+
adapter.setSelectedTable(state, artifactId, explicitTableName);
|
|
237
|
+
return { tableName: explicitTableName, columns };
|
|
238
|
+
}
|
|
239
|
+
if (dashboard?.selectedTable) {
|
|
240
|
+
const columns = findTableColumns(state, adapter, dashboard.selectedTable);
|
|
241
|
+
if (columns) {
|
|
242
|
+
return { tableName: dashboard.selectedTable, columns };
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (tables.length === 1) {
|
|
246
|
+
const onlyTable = tables[0];
|
|
247
|
+
if (!onlyTable?.columns) {
|
|
248
|
+
throw new Error('The only available table has no column metadata.');
|
|
249
|
+
}
|
|
250
|
+
adapter.setSelectedTable(state, artifactId, onlyTable.tableName);
|
|
251
|
+
return {
|
|
252
|
+
tableName: onlyTable.tableName,
|
|
253
|
+
columns: onlyTable.columns.map((column) => ({
|
|
254
|
+
name: column.name,
|
|
255
|
+
type: column.type,
|
|
256
|
+
})),
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
throw new Error(`No dashboard table is selected. Provide tableName using one of: ${formatAvailableTables(tables)}.`);
|
|
260
|
+
};
|
|
261
|
+
const deps = {
|
|
262
|
+
maxDataPoints: DEFAULT_CHART_MAX_DATA_POINTS,
|
|
263
|
+
resolveArtifact,
|
|
264
|
+
resolveTable,
|
|
265
|
+
addPanel: (dashboardId, panel) => {
|
|
266
|
+
const state = store.getState();
|
|
267
|
+
return adapter.addPanel(state, dashboardId, panel);
|
|
268
|
+
},
|
|
269
|
+
updatePanel: (dashboardId, panelId, patch) => {
|
|
270
|
+
const state = store.getState();
|
|
271
|
+
adapter.updatePanel(state, dashboardId, panelId, patch);
|
|
272
|
+
},
|
|
273
|
+
getDashboard: (dashboardId) => {
|
|
274
|
+
const state = store.getState();
|
|
275
|
+
return adapter.getDashboard(state, dashboardId);
|
|
276
|
+
},
|
|
277
|
+
removePanel: (dashboardId, panelId) => {
|
|
278
|
+
const state = store.getState();
|
|
279
|
+
adapter.removePanel(state, dashboardId, panelId);
|
|
280
|
+
},
|
|
281
|
+
setCurrentArtifact: (artifactId) => {
|
|
282
|
+
const state = store.getState();
|
|
283
|
+
adapter.setCurrentArtifact(state, artifactId);
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
if (adapter.getPanelIssue) {
|
|
287
|
+
deps.getPanelIssue = (dashboardId, panelId) => {
|
|
288
|
+
const state = store.getState();
|
|
289
|
+
return adapter.getPanelIssue?.(state, dashboardId, panelId);
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
return deps;
|
|
293
|
+
}
|
|
294
|
+
export function createDashboardAiTools({ store, adapter, chartTypes, extraTools, }) {
|
|
295
|
+
const deps = createDashboardToolDeps({ store, adapter });
|
|
296
|
+
const resolvedChartTypes = chartTypes ?? createDefaultChartTypes({ includeCustomSpec: false });
|
|
297
|
+
const chartTools = createChartTools(resolvedChartTypes, deps);
|
|
298
|
+
const hostTools = extraTools?.(deps) ?? {};
|
|
299
|
+
const builtInTools = {
|
|
300
|
+
create_dashboard_artifact: tool({
|
|
301
|
+
description: 'Create a new dashboard artifact with a dock or grid layout and make it the active artifact. Use when no dashboard artifact exists yet.',
|
|
302
|
+
inputSchema: DashboardCreateArtifactToolParameters,
|
|
303
|
+
execute: async (params, context) => {
|
|
304
|
+
const state = store.getState();
|
|
305
|
+
const artifactId = adapter.createDashboardArtifact(state, params.title, params.layoutType);
|
|
306
|
+
adapter.setCurrentArtifact(state, artifactId);
|
|
307
|
+
adapter.makeDashboardPrimaryForRun?.(state, artifactId, context);
|
|
308
|
+
return {
|
|
309
|
+
llmResult: {
|
|
310
|
+
success: true,
|
|
311
|
+
details: `Created dashboard artifact "${artifactId}".`,
|
|
312
|
+
data: { artifactId },
|
|
313
|
+
},
|
|
314
|
+
};
|
|
315
|
+
},
|
|
316
|
+
}),
|
|
317
|
+
...chartTools,
|
|
318
|
+
create_dashboard_profiler: createProfilerTool(deps),
|
|
319
|
+
create_dashboard_text_panel: createTextPanelTool(deps),
|
|
320
|
+
list_dashboard_panels: createListPanelsTool(deps),
|
|
321
|
+
remove_dashboard_panel: createRemovePanelTool(deps),
|
|
322
|
+
};
|
|
323
|
+
for (const key of Object.keys(hostTools)) {
|
|
324
|
+
if (key in builtInTools) {
|
|
325
|
+
throw new Error(`Dashboard extraTools cannot override built-in tool "${key}". Register the host tool under a unique key.`);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
return {
|
|
329
|
+
...builtInTools,
|
|
330
|
+
...hostTools,
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
function buildAgentPrompt(userPrompt, tableName, state, adapter) {
|
|
334
|
+
const table = adapter
|
|
335
|
+
.getTables(state)
|
|
336
|
+
.find((candidate) => candidate.tableName === tableName);
|
|
337
|
+
const columnNames = table?.columns?.map((column) => column.name).join(', ') || 'unknown';
|
|
338
|
+
const rowInfo = table?.rowCount !== undefined ? `Approximate rows: ${table.rowCount}` : '';
|
|
339
|
+
return `Analyze the "${tableName}" table.
|
|
340
|
+
|
|
341
|
+
Table info:
|
|
342
|
+
- Columns: ${columnNames}${rowInfo ? `\n- ${rowInfo}` : ''}
|
|
343
|
+
|
|
344
|
+
User request: ${userPrompt}
|
|
345
|
+
|
|
346
|
+
Focus on discovering meaningful patterns and creating visualizations that tell a clear story.`;
|
|
347
|
+
}
|
|
348
|
+
function validateTableExists(state, adapter, tableName) {
|
|
349
|
+
const tables = adapter.getTables(state);
|
|
350
|
+
const table = tables.find((candidate) => candidate.tableName === tableName);
|
|
351
|
+
if (!table) {
|
|
352
|
+
throw new DashboardAgentException(`Table "${tableName}" not found. Available tables: ${formatAvailableTables(tables)}`);
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
function getOrCreateDashboard(state, adapter, tableName, dashboardTitle) {
|
|
356
|
+
const dashboardId = adapter.getCurrentDashboardArtifactId(state);
|
|
357
|
+
if (dashboardId) {
|
|
358
|
+
adapter.ensureDashboard(state, dashboardId);
|
|
359
|
+
return dashboardId;
|
|
360
|
+
}
|
|
361
|
+
const suggestedTitle = dashboardTitle ||
|
|
362
|
+
`${tableName.charAt(0).toUpperCase() + tableName.slice(1)} Insights`;
|
|
363
|
+
const newDashboardId = adapter.createDashboardArtifact(state, suggestedTitle, 'grid');
|
|
364
|
+
adapter.setCurrentArtifact(state, newDashboardId);
|
|
365
|
+
return newDashboardId;
|
|
366
|
+
}
|
|
367
|
+
function calculateAgentMetadata(state, adapter, dashboardId, tableName, agentToolCalls) {
|
|
368
|
+
const dashboard = adapter.getDashboard(state, dashboardId);
|
|
369
|
+
return {
|
|
370
|
+
tableName,
|
|
371
|
+
panelsCreated: dashboard?.panels?.length || 0,
|
|
372
|
+
stepsExecuted: agentToolCalls.length,
|
|
373
|
+
queriesRun: agentToolCalls.filter((call) => call.toolName === 'query')
|
|
374
|
+
.length,
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
export function createDashboardAgentTool(options) {
|
|
378
|
+
const { store, adapter } = options;
|
|
379
|
+
return tool({
|
|
380
|
+
description: `An AI agent that explores datasets and creates comprehensive dashboards with multiple visualizations.
|
|
381
|
+
|
|
382
|
+
Use this for exploratory data analysis tasks like "analyze the earthquakes dataset" or "create insights dashboard for sales data".
|
|
383
|
+
|
|
384
|
+
The agent will query the data, discover patterns, and create charts, profilers, and text panels with findings.
|
|
385
|
+
|
|
386
|
+
For simple tasks like "create a histogram of magnitude", use the individual chart tools instead.
|
|
387
|
+
|
|
388
|
+
IMPORTANT: Always provide tableName parameter when the user mentions a specific dataset.`,
|
|
389
|
+
inputSchema: DashboardAgentInputSchema,
|
|
390
|
+
execute: async (params, toolOptions) => {
|
|
391
|
+
const { prompt, tableName, dashboardTitle, maxSteps, temperature } = params;
|
|
392
|
+
let dashboardId = '';
|
|
393
|
+
try {
|
|
394
|
+
const state = store.getState();
|
|
395
|
+
validateTableExists(state, adapter, tableName);
|
|
396
|
+
dashboardId = getOrCreateDashboard(state, adapter, tableName, dashboardTitle);
|
|
397
|
+
adapter.setSelectedTable(state, dashboardId, tableName);
|
|
398
|
+
const queryTools = options.createQueryTools?.({ store });
|
|
399
|
+
const dashboardAgent = new ToolLoopAgent({
|
|
400
|
+
model: options.getModel({ state }),
|
|
401
|
+
tools: {
|
|
402
|
+
...(queryTools ? { query: queryTools.query } : {}),
|
|
403
|
+
...createDashboardAiTools({
|
|
404
|
+
store,
|
|
405
|
+
adapter,
|
|
406
|
+
chartTypes: options.chartTypes,
|
|
407
|
+
extraTools: options.extraTools,
|
|
408
|
+
}),
|
|
409
|
+
},
|
|
410
|
+
temperature: Math.max(0, Math.min(1, temperature ?? 0.7)),
|
|
411
|
+
stopWhen: [stepCountIs(Math.max(5, Math.min(50, maxSteps ?? 20)))],
|
|
412
|
+
instructions: options.instructions ?? DASHBOARD_AGENT_INSTRUCTIONS,
|
|
413
|
+
});
|
|
414
|
+
const result = await options.runSubAgent({
|
|
415
|
+
agent: dashboardAgent,
|
|
416
|
+
prompt: buildAgentPrompt(prompt, tableName, state, adapter),
|
|
417
|
+
store,
|
|
418
|
+
parentToolCallId: toolOptions?.toolCallId || '',
|
|
419
|
+
abortSignal: toolOptions?.abortSignal,
|
|
420
|
+
});
|
|
421
|
+
const finalState = store.getState();
|
|
422
|
+
const metadata = calculateAgentMetadata(finalState, adapter, dashboardId, tableName, result.agentToolCalls || []);
|
|
423
|
+
return {
|
|
424
|
+
success: true,
|
|
425
|
+
finalOutput: result.finalOutput || 'Dashboard created successfully.',
|
|
426
|
+
dashboardId,
|
|
427
|
+
metadata,
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
catch (error) {
|
|
431
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
432
|
+
const friendlyMessage = error instanceof DashboardAgentException
|
|
433
|
+
? errorMessage
|
|
434
|
+
: 'Dashboard agent execution failed.';
|
|
435
|
+
return {
|
|
436
|
+
success: false,
|
|
437
|
+
finalOutput: friendlyMessage,
|
|
438
|
+
dashboardId,
|
|
439
|
+
error: errorMessage,
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
},
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
//# sourceMappingURL=ai.js.map
|