drizzle-cube 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/dist/adapters/express/index.cjs +2 -2
  2. package/dist/adapters/express/index.js +105 -104
  3. package/dist/adapters/fastify/index.cjs +2 -2
  4. package/dist/adapters/fastify/index.js +107 -106
  5. package/dist/adapters/{google-CBfBGU4F.js → google-CT4kgmBf.js} +1 -1
  6. package/dist/adapters/{google-BOAwi9Ib.cjs → google-Dgo9-Kb5.cjs} +1 -1
  7. package/dist/adapters/{handler-Cqf-CqAS.cjs → handler-CNn3q29F.cjs} +13 -13
  8. package/dist/adapters/{handler-BC3nFNxV.js → handler-_TKfigrZ.js} +33 -34
  9. package/dist/adapters/hono/index.cjs +1 -1
  10. package/dist/adapters/hono/index.js +99 -98
  11. package/dist/adapters/{locale-D9VQkLXt.js → locale-BQQrZYhz.js} +1 -1
  12. package/dist/adapters/{locale-BoiA6WiV.cjs → locale-Dl_3R6hP.cjs} +7 -7
  13. package/dist/adapters/mcp-tools.cjs +1 -1
  14. package/dist/adapters/mcp-tools.js +2 -2
  15. package/dist/adapters/mcp-transport-CkyawtUT.cjs +40 -0
  16. package/dist/adapters/mcp-transport-DSbd6M_u.js +586 -0
  17. package/dist/adapters/mcp-transport.d.ts +22 -0
  18. package/dist/adapters/nextjs/index.cjs +1 -1
  19. package/dist/adapters/nextjs/index.js +136 -135
  20. package/dist/adapters/{openai-B4N3KfTG.cjs → openai-BjLV_Wjx.cjs} +1 -1
  21. package/dist/adapters/{openai-BWdm0JvG.js → openai-DQawCWQb.js} +1 -1
  22. package/dist/adapters/{utils-CTYvfZ3I.js → utils-DG8ti3FT.js} +1097 -661
  23. package/dist/adapters/utils-DrWvXf0G.cjs +128 -0
  24. package/dist/adapters/utils.cjs +1 -1
  25. package/dist/adapters/utils.d.ts +46 -4
  26. package/dist/adapters/utils.js +1 -1
  27. package/dist/client/charts.js +12 -12
  28. package/dist/client/chunks/{DashboardEditModal-IU_0dgfC.js → DashboardEditModal-BBcB0E2g.js} +10 -10
  29. package/dist/client/chunks/{DashboardEditModal-IU_0dgfC.js.map → DashboardEditModal-BBcB0E2g.js.map} +1 -1
  30. package/dist/client/chunks/{FieldSearchModal-BCWanpPX.js → FieldSearchModal-CisOov-_.js} +4 -4
  31. package/dist/client/chunks/{FieldSearchModal-BCWanpPX.js.map → FieldSearchModal-CisOov-_.js.map} +1 -1
  32. package/dist/client/chunks/KpiDelta-D09hA_UJ.js +2 -0
  33. package/dist/client/chunks/KpiNumber-B7F9F9fC.js +2 -0
  34. package/dist/client/chunks/KpiText-C3ZXOF8b.js +2 -0
  35. package/dist/client/chunks/{RetentionCombinedChart-CQMBODsK.js → RetentionCombinedChart-DiyZwiPv.js} +3 -3
  36. package/dist/client/chunks/{RetentionCombinedChart-CQMBODsK.js.map → RetentionCombinedChart-DiyZwiPv.js.map} +1 -1
  37. package/dist/client/chunks/{RetentionHeatmap-B_5sewwi.js → RetentionHeatmap-usGF7BCo.js} +2 -2
  38. package/dist/client/chunks/{RetentionHeatmap-B_5sewwi.js.map → RetentionHeatmap-usGF7BCo.js.map} +1 -1
  39. package/dist/client/chunks/SchemaVisualization-DP4k1fPp.js +2 -0
  40. package/dist/client/chunks/SchemaVisualizationLazy-Brqv_PY9.js +2 -0
  41. package/dist/client/chunks/{analysis-builder-Dm6eD_AX.js → analysis-builder-0o1W-k3K.js} +8 -8
  42. package/dist/client/chunks/{analysis-builder-Dm6eD_AX.js.map → analysis-builder-0o1W-k3K.js.map} +1 -1
  43. package/dist/client/chunks/{analysis-builder-shared-DT5bXwCA.js → analysis-builder-shared-Cz4KAlIC.js} +9 -9
  44. package/dist/client/chunks/{analysis-builder-shared-DT5bXwCA.js.map → analysis-builder-shared-Cz4KAlIC.js.map} +1 -1
  45. package/dist/client/chunks/{chart-activity-grid-CWT0gLv4.js → chart-activity-grid-VFFm85hC.js} +18 -3
  46. package/dist/client/chunks/{chart-activity-grid-CWT0gLv4.js.map → chart-activity-grid-VFFm85hC.js.map} +1 -1
  47. package/dist/client/chunks/{chart-area-DDti9Qtp.js → chart-area-CwwIHTmK.js} +2 -2
  48. package/dist/client/chunks/{chart-area-DDti9Qtp.js.map → chart-area-CwwIHTmK.js.map} +1 -1
  49. package/dist/client/chunks/{chart-bar-B3s9qDlh.js → chart-bar-Bmny922L.js} +3 -3
  50. package/dist/client/chunks/{chart-bar-B3s9qDlh.js.map → chart-bar-Bmny922L.js.map} +1 -1
  51. package/dist/client/chunks/{chart-box-plot-o-h9MRX5.js → chart-box-plot-DM7GwtCV.js} +2 -2
  52. package/dist/client/chunks/{chart-box-plot-o-h9MRX5.js.map → chart-box-plot-DM7GwtCV.js.map} +1 -1
  53. package/dist/client/chunks/{chart-bubble-CMDp4Pfm.js → chart-bubble-DJOq4IpT.js} +2 -2
  54. package/dist/client/chunks/{chart-bubble-CMDp4Pfm.js.map → chart-bubble-DJOq4IpT.js.map} +1 -1
  55. package/dist/client/chunks/{chart-candlestick-WyANJ0Ky.js → chart-candlestick-C2nzVCv1.js} +2 -2
  56. package/dist/client/chunks/{chart-candlestick-WyANJ0Ky.js.map → chart-candlestick-C2nzVCv1.js.map} +1 -1
  57. package/dist/client/chunks/{chart-data-table-Qrt6EAno.js → chart-data-table-zZtwLf55.js} +30 -30
  58. package/dist/client/chunks/chart-data-table-zZtwLf55.js.map +1 -0
  59. package/dist/client/chunks/{chart-funnel-C7pgktN5.js → chart-funnel-COTJy8BP.js} +2 -2
  60. package/dist/client/chunks/{chart-funnel-C7pgktN5.js.map → chart-funnel-COTJy8BP.js.map} +1 -1
  61. package/dist/client/chunks/{chart-gauge-D2r2B_AR.js → chart-gauge-C8lIneI0.js} +2 -2
  62. package/dist/client/chunks/{chart-gauge-D2r2B_AR.js.map → chart-gauge-C8lIneI0.js.map} +1 -1
  63. package/dist/client/chunks/{chart-heat-map-Dw2yjwfO.js → chart-heat-map-BJXt3RMt.js} +2 -2
  64. package/dist/client/chunks/{chart-heat-map-Dw2yjwfO.js.map → chart-heat-map-BJXt3RMt.js.map} +1 -1
  65. package/dist/client/chunks/{chart-kpi-delta-CgldZ7zO.js → chart-kpi-delta-DHkNqufb.js} +3 -3
  66. package/dist/client/chunks/{chart-kpi-delta-CgldZ7zO.js.map → chart-kpi-delta-DHkNqufb.js.map} +1 -1
  67. package/dist/client/chunks/{chart-kpi-number-ByfuX1ki.js → chart-kpi-number-BrXw7m-S.js} +5 -5
  68. package/dist/client/chunks/{chart-kpi-number-ByfuX1ki.js.map → chart-kpi-number-BrXw7m-S.js.map} +1 -1
  69. package/dist/client/chunks/{chart-kpi-text-DeNuDraJ.js → chart-kpi-text-D0plngLV.js} +3 -3
  70. package/dist/client/chunks/{chart-kpi-text-DeNuDraJ.js.map → chart-kpi-text-D0plngLV.js.map} +1 -1
  71. package/dist/client/chunks/{chart-line-RdZwtk27.js → chart-line-DKvW32U-.js} +3 -3
  72. package/dist/client/chunks/{chart-line-RdZwtk27.js.map → chart-line-DKvW32U-.js.map} +1 -1
  73. package/dist/client/chunks/{chart-markdown-CiGRZdJj.js → chart-markdown-CJU2hUq3.js} +2 -2
  74. package/dist/client/chunks/{chart-markdown-CiGRZdJj.js.map → chart-markdown-CJU2hUq3.js.map} +1 -1
  75. package/dist/client/chunks/{chart-measure-profile-Ckjw9bX6.js → chart-measure-profile-DNT_tbh4.js} +3 -3
  76. package/dist/client/chunks/{chart-measure-profile-Ckjw9bX6.js.map → chart-measure-profile-DNT_tbh4.js.map} +1 -1
  77. package/dist/client/chunks/{chart-pie-BvY4FY__.js → chart-pie-CzYnncO-.js} +3 -3
  78. package/dist/client/chunks/{chart-pie-BvY4FY__.js.map → chart-pie-CzYnncO-.js.map} +1 -1
  79. package/dist/client/chunks/{chart-radar-DjiiEAmc.js → chart-radar-8iAt3QZl.js} +3 -3
  80. package/dist/client/chunks/{chart-radar-DjiiEAmc.js.map → chart-radar-8iAt3QZl.js.map} +1 -1
  81. package/dist/client/chunks/{chart-radial-bar-lla_JEYu.js → chart-radial-bar-CJbG7RIe.js} +3 -3
  82. package/dist/client/chunks/{chart-radial-bar-lla_JEYu.js.map → chart-radial-bar-CJbG7RIe.js.map} +1 -1
  83. package/dist/client/chunks/{chart-sankey-WwkZAhLy.js → chart-sankey-C-wLBUmb.js} +2 -2
  84. package/dist/client/chunks/{chart-sankey-WwkZAhLy.js.map → chart-sankey-C-wLBUmb.js.map} +1 -1
  85. package/dist/client/chunks/{chart-scatter-DwXnI0rr.js → chart-scatter-NMjD1lbW.js} +3 -3
  86. package/dist/client/chunks/{chart-scatter-DwXnI0rr.js.map → chart-scatter-NMjD1lbW.js.map} +1 -1
  87. package/dist/client/chunks/{chart-sunburst-CIDB_pTl.js → chart-sunburst-HtJ-LJ7n.js} +3 -3
  88. package/dist/client/chunks/{chart-sunburst-CIDB_pTl.js.map → chart-sunburst-HtJ-LJ7n.js.map} +1 -1
  89. package/dist/client/chunks/{chart-tree-map-DJHoA26f.js → chart-tree-map-CetaLMt8.js} +3 -3
  90. package/dist/client/chunks/{chart-tree-map-DJHoA26f.js.map → chart-tree-map-CetaLMt8.js.map} +1 -1
  91. package/dist/client/chunks/{chart-waterfall-Y7c8csO5.js → chart-waterfall-ontNp1Sd.js} +3 -3
  92. package/dist/client/chunks/{chart-waterfall-Y7c8csO5.js.map → chart-waterfall-ontNp1Sd.js.map} +1 -1
  93. package/dist/client/chunks/{charts-core-BXOqaYFn.js → charts-core-B5UXUg6_.js} +2 -2
  94. package/dist/client/chunks/{charts-core-BXOqaYFn.js.map → charts-core-B5UXUg6_.js.map} +1 -1
  95. package/dist/client/chunks/{nl-NL-vCifBijs.js → nl-NL-DDf0OdfW.js} +17 -2
  96. package/dist/client/chunks/{nl-NL-vCifBijs.js.map → nl-NL-DDf0OdfW.js.map} +1 -1
  97. package/dist/client/chunks/{schema-visualization-DWwJukK7.js → schema-visualization-cnB2xZxn.js} +4 -4
  98. package/dist/client/chunks/{schema-visualization-DWwJukK7.js.map → schema-visualization-cnB2xZxn.js.map} +1 -1
  99. package/dist/client/chunks/{useDebounce-DyJVREop.js → useDebounce-BOBSvhHy.js} +4 -4
  100. package/dist/client/chunks/{useDebounce-DyJVREop.js.map → useDebounce-BOBSvhHy.js.map} +1 -1
  101. package/dist/client/chunks/{useExplainAI-CxSkjocM.js → useExplainAI-B_Pi4eXW.js} +4 -4
  102. package/dist/client/chunks/{useExplainAI-CxSkjocM.js.map → useExplainAI-B_Pi4eXW.js.map} +1 -1
  103. package/dist/client/chunks/{utils-BHZdKxua.js → utils-BIuqPQuJ.js} +2 -2
  104. package/dist/client/chunks/{utils-BHZdKxua.js.map → utils-BIuqPQuJ.js.map} +1 -1
  105. package/dist/client/chunks/{vendor-CBD_Olr0.js → vendor-BxLCTfvm.js} +2 -2
  106. package/dist/client/chunks/{vendor-CBD_Olr0.js.map → vendor-BxLCTfvm.js.map} +1 -1
  107. package/dist/client/components.js +3 -3
  108. package/dist/client/hooks.js +3 -3
  109. package/dist/client/icons.js +1 -1
  110. package/dist/client/index.js +14 -14
  111. package/dist/client/providers.js +1 -1
  112. package/dist/client/schema.js +1 -1
  113. package/dist/client/utils.js +5 -5
  114. package/dist/client-bundle-stats.html +1 -1
  115. package/dist/mcp-app/mcp-app.html +23 -23
  116. package/dist/server/index.cjs +134 -133
  117. package/dist/server/index.js +1000 -946
  118. package/package.json +1 -1
  119. package/dist/adapters/mcp-prompts-BUFyQLHQ.js +0 -377
  120. package/dist/adapters/mcp-prompts-B_NvEJT_.cjs +0 -111
  121. package/dist/adapters/mcp-transport-B0mgxRnJ.js +0 -579
  122. package/dist/adapters/mcp-transport-irsahKmD.cjs +0 -39
  123. package/dist/adapters/utils-XPOzzMdY.cjs +0 -17
  124. package/dist/client/chunks/KpiDelta-_igN6cJa.js +0 -2
  125. package/dist/client/chunks/KpiNumber-t5n8PtRU.js +0 -2
  126. package/dist/client/chunks/KpiText-BCZJJ6a0.js +0 -2
  127. package/dist/client/chunks/SchemaVisualization-BUUhlOvG.js +0 -2
  128. package/dist/client/chunks/SchemaVisualizationLazy-CwaPCUL0.js +0 -2
  129. package/dist/client/chunks/chart-data-table-Qrt6EAno.js.map +0 -1
  130. /package/dist/adapters/{anthropic-Cto4Jxqt.cjs → anthropic-BIva8k1r.cjs} +0 -0
  131. /package/dist/adapters/{anthropic-DpEbCVvF.js → anthropic-B_rg0BhK.js} +0 -0
  132. /package/dist/adapters/{dist-BnyV9wfA.cjs → dist-Boc63-1q.cjs} +0 -0
  133. /package/dist/adapters/{dist-DjVh2RFz.js → dist-De5fzUEM.js} +0 -0
  134. /package/dist/adapters/{openai-CoqT_FM5.cjs → openai-Bgri5TJc.cjs} +0 -0
  135. /package/dist/adapters/{openai-D0Nsvc9L.js → openai-CuUGrKaK.js} +0 -0
@@ -1,8 +1,8 @@
1
- const e=require(`./utils-XPOzzMdY.cjs`),t=require(`./mcp-prompts-B_NvEJT_.cjs`);function n(e){if(e.length===0)return`No cubes are currently available.`;let t=[`## Available Cubes`,``];for(let n of e){if(t.push(`### ${n.name}`),n.description&&t.push(n.description),n.measures&&n.measures.length>0){t.push(``),t.push(`**Measures:**`);for(let e of n.measures){let r=e.description?` - ${e.description}`:``;t.push(`- \`${n.name}.${e.name}\` (${e.type})${r}`)}}if(n.dimensions&&n.dimensions.length>0){t.push(``),t.push(`**Dimensions:**`);for(let e of n.dimensions){let r=e.description?` - ${e.description}`:``;t.push(`- \`${n.name}.${e.name}\` (${e.type})${r}`)}}if(n.relationships&&n.relationships.length>0){t.push(``),t.push(`**Joins:**`);for(let e of n.relationships)t.push(`- → \`${e.targetCube}\` (${e.relationship})`)}n.meta?.eventStream&&(t.push(``),t.push(`**Event Stream:** Yes (supports funnel, flow, retention queries)`),n.meta.eventStream.bindingKey&&t.push(`- Binding key: \`${n.name}.${n.meta.eventStream.bindingKey}\``),n.meta.eventStream.timeDimension&&t.push(`- Time dimension: \`${n.name}.${n.meta.eventStream.timeDimension}\``)),t.push(``)}return t.join(`
2
- `)}function r(e){return e.messages.map(e=>e.content.text).join(`
1
+ const e=require(`./utils-DrWvXf0G.cjs`);function t(e){if(e.length===0)return`No cubes are currently available.`;let t=[`## Available Cubes`,``];for(let n of e){if(t.push(`### ${n.name}`),n.description&&t.push(n.description),n.measures&&n.measures.length>0){t.push(``),t.push(`**Measures:**`);for(let e of n.measures){let r=e.description?` - ${e.description}`:``;t.push(`- \`${n.name}.${e.name}\` (${e.type})${r}`)}}if(n.dimensions&&n.dimensions.length>0){t.push(``),t.push(`**Dimensions:**`);for(let e of n.dimensions){let r=e.description?` - ${e.description}`:``;t.push(`- \`${n.name}.${e.name}\` (${e.type})${r}`)}}if(n.relationships&&n.relationships.length>0){t.push(``),t.push(`**Joins:**`);for(let e of n.relationships)t.push(`- → \`${e.targetCube}\` (${e.relationship})`)}n.meta?.eventStream&&(t.push(``),t.push(`**Event Stream:** Yes (supports funnel, flow, retention queries)`),n.meta.eventStream.bindingKey&&t.push(`- Binding key: \`${n.name}.${n.meta.eventStream.bindingKey}\``),n.meta.eventStream.timeDimension&&t.push(`- Time dimension: \`${n.name}.${n.meta.eventStream.timeDimension}\``)),t.push(``)}return t.join(`
2
+ `)}function n(e){return e.messages.map(e=>e.content.text).join(`
3
3
 
4
- `)}function i(e){return[`# Drizzle Cube Analytics Agent`,``,`You are an analytics agent that helps users explore and visualize data.`,`You have access to a semantic layer with cubes (data models) that you can query.`,``,`## Your Workflow`,``,`For EACH insight, follow this cycle — do NOT batch all queries first:`,``,"1. **Discover** available cubes using `discover_cubes` (once at the start)",`2. **For each analysis point**, repeat this cycle:`," a. `execute_query` — get the data"," b. `add_markdown` — explain the results and insight"," c. `add_portlet` — visualize the results",``,`Call all three (query → markdown → portlet) in a single turn before moving on to the next analysis.`,`Do NOT run multiple queries first and add charts later — the user sees results in real-time.`,``,`## Important Guidelines`,``,`- ALWAYS discover cubes first before attempting queries`,"- Field names MUST be EXACTLY `CubeName.fieldName` — two parts separated by a single dot. Examples: `PullRequests.count`, `Teams.name`, `Employees.department`."," WRONG patterns that WILL FAIL: `Teams.Teams.name` (double-prefixed), `PullRequests.PullRequests.count` (double-prefixed), `PullRequests` (bare cube), `Teams_count` (underscore). Use the EXACT field names from discover results — copy them verbatim, do not prefix them again.",`- Order keys MUST be one of the measures or dimensions already listed in that query. You CANNOT order by a field that is not in measures or dimensions — add it to measures first, or remove it from order.`,"- After EVERY `execute_query`, IMMEDIATELY call `add_markdown` and `add_portlet` in the SAME turn — never defer visualizations to a later turn",`- Choose appropriate chart types: bar for categories, line for trends, table for detailed data`,`- If a query fails, explain the error and try an alternative approach`,``,`## Output Format Rules`,``,`### CRITICAL: Always think before acting`,`- EVERY single turn MUST begin with a text message (1-2 sentences) BEFORE any tool calls. This is your #1 rule — never violate it.`,`- This applies to EVERY turn, including turns where you are adding visualizations or explanations to the notebook.`,`- Even when adding multiple charts in sequence, each turn must start with a brief status like "Now I'll chart the productivity breakdown." or "Next, let me show the department comparison."`,`- Example good turn: "Let me see what data is available." → discover_cubes`,`- Example good turn: "I'll add a chart showing the top employees." → add_markdown → add_portlet`,`- Example bad turn: (no text) → add_portlet ← NEVER do this`,``,`### Text vs Notebook`,"- ALL analysis, findings, methodology, and insights MUST go through `add_markdown` tool calls — never in your text responses",`- Your text responses must be 1-2 short sentences (under 50 words) summarizing what you are about to do next — status updates only`,`- Never use markdown formatting (headers, bullets, bold, code blocks) in text responses — plain sentences only`,`- Write text responses as a friendly analyst would — use plain business language the user understands`,`- NEVER mention internal terms like "cube", "query syntax", "field names", "measures", "dimensions", "portlet", "prefix format", or tool names in text responses`,`- Instead of "Let me correct the query syntax and retry" → "Let me fix that and try again"`,`- Instead of "I'll query the PullRequests cube" → "I'll look at the pull request data"`,`- Instead of "Adding a portlet with the results" → "Here's a chart of the results"`,``,`### Notebook content rules`,"- Before each `add_portlet`, ALWAYS call `add_markdown` first to explain WHY you are adding this visualization and what it shows","- Before calling `add_portlet`, verify the query is valid: all fields in `order` must also appear in `measures` or `dimensions`",'- Never put data tables in markdown blocks — use `add_portlet` with chartType "table" instead',"- Think out loud in the notebook: use `add_markdown` to share your reasoning at each step so users can follow along",`- NEVER use emojis in text responses or markdown content — no 📊, 📈, ✅, 🔍, etc. Write in plain, professional language.`,``,`## Chart Selection Guide`,``,`Choose the chart type that best communicates the answer to the user's question. Think about what the data represents and what insight the user needs — do NOT default to the first option in this table. Consider the number of data points, whether values are categorical or temporal, and whether the user is comparing, trending, or summarizing.`,``,`| Intent / Data Shape | Chart Type |`,`|---|---|`,"| Compare discrete categories or rankings | `bar` |","| Trend over time (one or few series) | `line` |","| Trend over time showing volume/magnitude | `area` |","| Part-of-whole breakdown | `pie` (≤7 slices) |","| Correlation between two measures | `scatter` |","| Correlation with size/color third dimension | `bubble` |","| Intensity across two categorical dimensions | `heatmap` |","| Multi-variable comparison across categories | `radar` |","| Distribution/spread of values | `boxPlot` |","| Detailed row-level data or many columns | `table` |","| Single headline number — ONLY when user explicitly asks for a KPI card or single number | `kpiNumber` |","| Headline metric with period-over-period change — ONLY when user asks about change in a single metric | `kpiDelta` |",``,`Analysis-mode-specific chart types (require the corresponding analysis mode):`,``,`| Analysis Mode | Chart Type | Description |`,`|---|---|---|`,"| Funnel | `funnel` | Sequential step conversion bars with conversion rates |","| Flow | `sankey` | Flow diagram showing paths between states/steps |","| Flow | `sunburst` | Radial rings showing forward paths from a starting event |","| Retention | `retentionHeatmap` | Cohort × period retention matrix |","| Retention | `retentionCombined` | Retention with line chart, heatmap, or combined modes |",``,'**Chart selection priorities:** Default to `bar` for categories, `line` for time series, `table` for exploratory data. Use `kpiNumber`/`kpiDelta` only as a last resort — they are appropriate only when the user explicitly asks for a single headline number or KPI card. If the query returns multiple rows or the user asks a general question like "show me revenue", prefer `bar` or `table` over `kpiNumber`.',``,`## Chart Axis Configuration Rules`,``,"**Bar charts MUST have an xAxis.** Put a dimension in `chartConfig.xAxis` so bars have category labels. If your query has no dimensions, add one or use `table` instead.",``,"**Never duplicate xAxis in series.** Putting the same dimension in both `xAxis` and `series` creates a sparse, broken-looking chart. The `series` field is ONLY for splitting bars into grouped/stacked sub-series by a SECOND dimension.",``,`Correct bar chart examples:`,'- Categories only: `xAxis: ["Cube.category"], yAxis: ["Cube.count"]` — no series needed','- Grouped bars: `xAxis: ["Cube.category"], yAxis: ["Cube.count"], series: ["Cube.status"]` — series is a DIFFERENT dimension','- Multiple measures: `xAxis: ["Cube.category"], yAxis: ["Cube.count", "Cube.total"]` — each measure becomes a bar group',``,`Wrong:`,'- `xAxis: [], yAxis: ["Cube.avg1", "Cube.avg2"]` — missing xAxis, bars have no labels','- `xAxis: ["Cube.size"], series: ["Cube.size"]` — same field in both, creates sparse chart',``,"**Dual Y-axis for multi-measure charts.** When a `bar`, `line`, or `area` chart has 2+ measures with different scales (e.g. revenue in thousands vs conversion rate as a percentage), use `chartConfig.yAxisAssignment` to put them on separate axes:","```json",`{`,` "xAxis": ["Sales.month"],`,` "yAxis": ["Sales.revenue", "Sales.conversionRate"],`,` "yAxisAssignment": { "Sales.revenue": "left", "Sales.conversionRate": "right" }`,`}`,"```",`Only use dual axis when measures have genuinely different scales. If both measures share the same unit/scale, keep them on the same (left) axis — omit yAxisAssignment entirely.`,``,`## Analysis Mode Decision Tree`,``,`The default mode is **query** (standard measures/dimensions). Switch to a special mode only when the user's question matches:`,``,`- **Funnel mode** — "What is the conversion rate from step A → B → C?"`," - Requires: an event-stream cube with `capabilities.funnel = true` from `discover_cubes`"," - Execute: `execute_query` with `funnel` param:",' `{ bindingKey: "Events.userId", timeDimension: "Events.timestamp", steps: [{ name: "Signup", filter: { member: "Events.eventName", operator: "equals", values: ["signup"] }}, { name: "Purchase", filter: { member: "Events.eventName", operator: "equals", values: ["purchase"] }}] }`',' - Visualize: `add_portlet` with `chartType: "funnel"` and `query` as JSON string containing `{ "funnel": { ... } }`',``,`- **Flow mode** — "What paths do users take after signup?"`," - Requires: `capabilities.flow = true` from `discover_cubes`"," - Execute: `execute_query` with `flow` param:",' `{ bindingKey: "Events.userId", timeDimension: "Events.timestamp", eventDimension: "Events.eventName", startingStep: { name: "Signup", filter: { member: "Events.eventName", operator: "equals", values: ["signup"] }}, stepsBefore: 0, stepsAfter: 3 }`',' - Visualize: `add_portlet` with `chartType: "sankey"` (or `"sunburst"`) and `query` as JSON string containing `{ "flow": { ... } }`',``,`- **Retention mode** — "What % of users come back after 7 days?"`," - Requires: `capabilities.retention = true` from `discover_cubes`"," - Execute: `execute_query` with `retention` param:",' `{ timeDimension: "Events.timestamp", bindingKey: "Events.userId", dateRange: { start: "2024-01-01", end: "2024-03-31" }, granularity: "week", periods: 8, retentionType: "classic" }`',' - Visualize: `add_portlet` with `chartType: "retentionCombined"` (or `"retentionHeatmap"`) and `query` as JSON string containing `{ "retention": { ... } }`',``,"Before using funnel/flow/retention, check the `capabilities` object returned by `discover_cubes`. If the required capability is `false`, explain to the user that the data model does not support that analysis mode.",``,`Event-stream cubes are marked in the Available Cubes section below with **Event Stream: Yes** and list their binding key and time dimension.`,``,`---`,``,r(t.n),``,`---`,``,r(t.r),``,`---`,``,r(t.t),``,`---`,``,`## Save as Dashboard`,``,"ONLY call `save_as_dashboard` when the user EXPLICITLY asks to save, export, or convert the notebook into a dashboard. NEVER save a dashboard on your own initiative — wait for the user to request it.",``,`### Layout Rules`,`- Dashboard grid is 12 columns wide`,`- KPI cards: w=3, h=3 — place at the top in a row of 4`,`- Overview charts (bar, line, area): w=6, h=4`,`- Wide charts (heatmap, table): w=12, h=5`,`- Section headers (markdown): w=12, h=1`,``,`### Section Headers`,'Use `chartType: "markdown"` portlets as section headers to organize the dashboard:',"```json",`{`,` "id": "header-overview",`,` "title": "Overview",`,` "chartType": "markdown",`,` "displayConfig": {`,` "content": "## Overview",`,` "hideHeader": true,`,` "transparentBackground": true,`,` "autoHeight": true`,` },`,` "w": 12, "h": 1, "x": 0, "y": 0`,`}`,"```",``,`### Dashboard Filters`,"- ALWAYS include a universal date filter with `isUniversalTime: true`",`- Add dimension filters for key fields used across portlets (e.g., department, status, region)`,`- Use human-readable labels (e.g., "Department" not "Employees.departmentName")`,"- Map filters to portlets using `dashboardFilterMapping` — list the filter IDs that apply",`- When promoting a hardcoded filter to a dashboard filter, REMOVE that filter from the portlet query`,``,`### Analysis Types`,'- Standard query portlets: `analysisType: "query"` (default)','- Funnel portlets: `analysisType: "funnel"`, query contains `{ "funnel": {...} }`, chartType `"funnel"`','- Flow portlets: `analysisType: "flow"`, query contains `{ "flow": {...} }`, chartType `"sankey"` or `"sunburst"`','- Retention portlets: `analysisType: "retention"`, query contains `{ "retention": {...} }`, chartType `"retentionHeatmap"` or `"retentionCombined"`',``,`### CRITICAL: Only use portlets from the notebook`,"- ONLY include portlets that you already added to the notebook via `add_portlet` during this conversation",`- Do NOT invent new queries or charts that were not part of the analysis — the dashboard is a direct conversion of the notebook`,`- Reuse the exact same queries, chart types, and chart configs from the notebook portlets`,`- Arrange the existing portlets in a sensible layout (KPIs at top, charts in middle, tables at bottom)`,`- You may add section header markdown portlets to organize the layout, but do not add new data portlets`,``,`---`,``,n(e)].join(`
5
- `)}var a={bar:{label:`chart.bar.label`,description:`chart.bar.description`,useCase:`chart.bar.useCase`,clickableElements:{bar:!0},dropZones:[{key:`xAxis`,label:`chart.dropZone.xAxis.label`,description:`chart.dropZone.xAxis.description`,mandatory:!1,acceptTypes:[`dimension`,`timeDimension`],emptyText:`chart.bar.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.dropZone.yAxis.label`,description:`chart.configText.measures_for_bar_heights`,mandatory:!0,acceptTypes:[`measure`],emptyText:`chart.bar.dropZone.yAxis.empty`,enableDualAxis:!0},{key:`series`,label:`chart.dropZone.series.label`,description:`chart.dropZone.series.description`,mandatory:!1,acceptTypes:[`dimension`],emptyText:`chart.bar.dropZone.series.empty`}],displayOptions:[`showLegend`,`showGrid`,`showTooltip`,`hideHeader`],displayOptionsConfig:[{key:`stackType`,label:`chart.option.stacking.label`,type:`select`,defaultValue:`none`,options:[{value:`none`,label:`chart.option.accentBorder.none`},{value:`normal`,label:`chart.option.stacking.stacked`},{value:`percent`,label:`chart.option.stacking.percent`}],description:`chart.configText.how_to_stack_multiple_bar_series`},{key:`target`,label:`chart.option.target.label`,type:`string`,placeholder:`e.g., 100 or 50,75 for spread`,description:`chart.option.target.description`},{key:`leftYAxisFormat`,label:`chart.option.leftYAxisFormat.label`,type:`axisFormat`,description:`chart.option.leftYAxisFormat.description`},{key:`rightYAxisFormat`,label:`chart.option.rightYAxisFormat.label`,type:`axisFormat`,description:`chart.option.rightYAxisFormat.description`}]},line:{label:`chart.line.label`,description:`chart.line.description`,useCase:`chart.line.useCase`,clickableElements:{point:!0},dropZones:[{key:`xAxis`,label:`chart.configText.x_axis_time_categories`,description:`chart.configText.time_dimensions_or_dimensions_for_x_axis`,mandatory:!0,acceptTypes:[`dimension`,`timeDimension`],emptyText:`chart.line.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.dropZone.yAxis.label`,description:`chart.configText.measures_for_line_values`,mandatory:!0,acceptTypes:[`measure`],emptyText:`chart.line.dropZone.yAxis.empty`,enableDualAxis:!0},{key:`series`,label:`chart.configText.series_multiple_lines`,description:`chart.configText.dimensions_to_create_separate_lines`,mandatory:!1,acceptTypes:[`dimension`],emptyText:`chart.line.dropZone.series.empty`}],displayOptions:[`showLegend`,`showGrid`,`showTooltip`,`hideHeader`],displayOptionsConfig:[{key:`connectNulls`,label:`chart.option.connectNulls.label`,type:`boolean`,defaultValue:!1,description:`chart.option.connectNulls.description`},{key:`target`,label:`chart.option.target.label`,type:`string`,placeholder:`e.g., 100 or 50,75 for spread`,description:`chart.option.target.description`},{key:`priorPeriodStyle`,label:`chart.option.priorPeriodStyle.label`,type:`select`,defaultValue:`dashed`,options:[{value:`dashed`,label:`chart.option.priorPeriodStyle.dashed`},{value:`dotted`,label:`chart.option.priorPeriodStyle.dotted`},{value:`solid`,label:`chart.option.priorPeriodStyle.solid`}],description:`chart.option.priorPeriodStyle.description`},{key:`priorPeriodOpacity`,label:`chart.option.priorPeriodOpacity.label`,type:`number`,defaultValue:.5,min:.1,max:1,step:.1,description:`chart.option.priorPeriodOpacity.description`},{key:`leftYAxisFormat`,label:`chart.option.leftYAxisFormat.label`,type:`axisFormat`,description:`chart.option.leftYAxisFormat.description`},{key:`rightYAxisFormat`,label:`chart.option.rightYAxisFormat.label`,type:`axisFormat`,description:`chart.option.rightYAxisFormat.description`}]},area:{label:`chart.area.label`,description:`chart.area.description`,useCase:`chart.area.useCase`,dropZones:[{key:`xAxis`,label:`chart.configText.x_axis_time_categories`,description:`chart.configText.time_dimensions_or_dimensions_for_x_axis`,mandatory:!0,acceptTypes:[`dimension`,`timeDimension`],emptyText:`chart.area.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.dropZone.yAxis.label`,description:`chart.configText.measures_for_area_values`,mandatory:!0,acceptTypes:[`measure`],emptyText:`chart.area.dropZone.yAxis.empty`,enableDualAxis:!0},{key:`series`,label:`chart.configText.series_stack_areas`,description:`chart.configText.dimensions_to_create_stacked_areas`,mandatory:!1,acceptTypes:[`dimension`],emptyText:`chart.area.dropZone.series.empty`}],displayOptions:[`showLegend`,`showGrid`,`showTooltip`,`hideHeader`],displayOptionsConfig:[{key:`stackType`,label:`chart.option.stacking.label`,type:`select`,defaultValue:`none`,options:[{value:`none`,label:`chart.option.accentBorder.none`},{value:`normal`,label:`chart.option.stacking.stacked`},{value:`percent`,label:`chart.option.stacking.percent`}],description:`chart.configText.how_to_stack_multiple_area_series`},{key:`connectNulls`,label:`chart.option.connectNulls.label`,type:`boolean`,defaultValue:!1,description:`chart.option.connectNulls.description`},{key:`target`,label:`chart.option.target.label`,type:`string`,placeholder:`e.g., 100 or 50,75 for spread`,description:`chart.option.target.description`},{key:`leftYAxisFormat`,label:`chart.option.leftYAxisFormat.label`,type:`axisFormat`,description:`chart.option.leftYAxisFormat.description`},{key:`rightYAxisFormat`,label:`chart.option.rightYAxisFormat.label`,type:`axisFormat`,description:`chart.option.rightYAxisFormat.description`}]},pie:{label:`chart.pie.label`,description:`chart.pie.description`,useCase:`chart.pie.useCase`,clickableElements:{slice:!0},dropZones:[{key:`xAxis`,label:`chart.configText.categories`,description:`chart.configText.dimension_for_pie_slices`,mandatory:!0,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.pie.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.values`,description:`chart.configText.measure_for_slice_sizes`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.pie.dropZone.yAxis.empty`}],displayOptions:[`showLegend`,`showTooltip`,`hideHeader`],displayOptionsConfig:[{key:`innerRadius`,label:`chart.option.innerRadius.label`,type:`select`,description:`chart.configText.hollow_center_size_0_percent_solid_pie_higher_donut_style`,defaultValue:`0%`,options:[{value:`0%`,label:`chart.configText.none_pie`},{value:`20%`,label:`chart.configText.20_percent`},{value:`40%`,label:`chart.configText.40_percent`},{value:`60%`,label:`chart.configText.60_percent`},{value:`80%`,label:`chart.configText.80_percent`}]},{key:`leftYAxisFormat`,label:`chart.option.valueFormat.label`,type:`axisFormat`,description:`chart.option.valueFormat.description`}]},scatter:{label:`chart.scatter.label`,description:`chart.scatter.description`,useCase:`chart.scatter.useCase`,dropZones:[{key:`xAxis`,label:`chart.runtime.axisFormat.xAxis`,description:`chart.configText.measure_or_dimension_for_x_position`,mandatory:!0,maxItems:1,acceptTypes:[`dimension`,`timeDimension`,`measure`],emptyText:`chart.scatter.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.y_axis`,description:`chart.configText.measure_for_y_position`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.scatter.dropZone.yAxis.empty`},{key:`series`,label:`chart.configText.series_color_groups`,description:`chart.configText.dimension_to_color_points_by_category`,mandatory:!1,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.scatter.dropZone.series.empty`}],displayOptions:[`showLegend`,`showGrid`,`showTooltip`,`hideHeader`],displayOptionsConfig:[{key:`xAxisFormat`,label:`chart.option.xAxisFormat.label`,type:`axisFormat`,description:`chart.option.xAxisFormat.description`},{key:`leftYAxisFormat`,label:`chart.option.yAxisFormat.label`,type:`axisFormat`,description:`chart.option.yAxisFormat.description`}]},bubble:{label:`chart.bubble.label`,description:`chart.bubble.description`,useCase:`chart.bubble.useCase`,dropZones:[{key:`xAxis`,label:`chart.runtime.axisFormat.xAxis`,description:`chart.configText.horizontal_axis_position`,mandatory:!0,maxItems:1,acceptTypes:[`dimension`,`timeDimension`,`measure`],emptyText:`chart.bubble.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.y_axis`,description:`chart.configText.vertical_axis_position`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.bubble.dropZone.yAxis.empty`},{key:`sizeField`,label:`chart.configText.bubble_radius`,description:`chart.configText.size_of_bubbles_based_on_this_measure`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.bubble.dropZone.sizeField.empty`},{key:`series`,label:`chart.configText.bubble_labels`,description:`chart.configText.field_to_use_for_bubble_labels_and_identification`,mandatory:!0,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.bubble.dropZone.series.empty`},{key:`colorField`,label:`chart.configText.bubble_colour`,description:`chart.configText.color_bubbles_by_this_field_optional`,mandatory:!1,maxItems:1,acceptTypes:[`dimension`,`measure`],emptyText:`chart.bubble.dropZone.colorField.empty`}],displayOptions:[`showLegend`,`showGrid`,`showTooltip`,`minBubbleSize`,`maxBubbleSize`,`bubbleOpacity`,`hideHeader`],displayOptionsConfig:[{key:`xAxisFormat`,label:`chart.option.xAxisFormat.label`,type:`axisFormat`,description:`chart.option.xAxisFormat.description`},{key:`leftYAxisFormat`,label:`chart.option.yAxisFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_y_axis_and_values`}]},radar:{label:`chart.radar.label`,description:`chart.radar.description`,useCase:`chart.radar.useCase`,dropZones:[{key:`xAxis`,label:`chart.configText.axes_categories`,description:`chart.configText.dimensions_for_radar_axes`,mandatory:!0,acceptTypes:[`dimension`],emptyText:`chart.radar.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.values`,description:`chart.configText.measures_for_radar_values`,mandatory:!0,acceptTypes:[`measure`],emptyText:`chart.radar.dropZone.yAxis.empty`},{key:`series`,label:`chart.configText.series_multiple_shapes`,description:`chart.configText.dimensions_to_create_multiple_radar_shapes`,mandatory:!1,acceptTypes:[`dimension`],emptyText:`chart.radar.dropZone.series.empty`}],displayOptions:[`showLegend`,`showGrid`,`showTooltip`,`hideHeader`],displayOptionsConfig:[{key:`leftYAxisFormat`,label:`chart.option.valueFormat.label`,type:`axisFormat`,description:`chart.option.valueFormat.description`}]},radialBar:{label:`chart.radialBar.label`,description:`chart.radialBar.description`,useCase:`chart.radialBar.useCase`,dropZones:[{key:`xAxis`,label:`chart.configText.categories`,description:`chart.configText.dimensions_for_radial_segments`,mandatory:!0,acceptTypes:[`dimension`],emptyText:`chart.radialBar.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.values`,description:`chart.configText.measures_for_radial_bar_lengths`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.radialBar.dropZone.yAxis.empty`}],displayOptions:[`showLegend`,`showTooltip`,`hideHeader`],displayOptionsConfig:[{key:`leftYAxisFormat`,label:`chart.option.valueFormat.label`,type:`axisFormat`,description:`chart.option.valueFormat.description`}]},treemap:{label:`chart.treemap.label`,description:`chart.treemap.description`,useCase:`chart.treemap.useCase`,dropZones:[{key:`xAxis`,label:`chart.configText.categories`,description:`chart.configText.dimensions_for_treemap_rectangles`,mandatory:!0,acceptTypes:[`dimension`],emptyText:`chart.treemap.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.size`,description:`chart.configText.measure_for_rectangle_sizes`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.treemap.dropZone.yAxis.empty`},{key:`series`,label:`chart.configText.color_groups`,description:`chart.configText.dimension_to_color_rectangles_by_category`,mandatory:!1,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.treemap.dropZone.series.empty`}],displayOptions:[`showLegend`,`showTooltip`,`hideHeader`],displayOptionsConfig:[{key:`leftYAxisFormat`,label:`chart.option.valueFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_size_values`}],clickableElements:{cell:!0}},table:{label:`chart.table.label`,description:`chart.table.description`,useCase:`chart.table.useCase`,dropZones:[{key:`xAxis`,label:`chart.configText.columns`,description:`chart.configText.all_fields_to_display_as_columns`,mandatory:!1,acceptTypes:[`dimension`,`timeDimension`,`measure`],emptyText:`chart.table.dropZone.xAxis.empty`}],displayOptions:[`hideHeader`],displayOptionsConfig:[{key:`leftYAxisFormat`,label:`chart.option.valueFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_numeric_values`}]},activityGrid:{label:`chart.activityGrid.label`,description:`chart.activityGrid.description`,useCase:`chart.activityGrid.useCase`,dropZones:[{key:`dateField`,label:`chart.configText.time_dimension`,description:`chart.configText.time_field_that_determines_grid_structure_granularity_affects_layout`,mandatory:!0,maxItems:1,acceptTypes:[`timeDimension`],emptyText:`chart.activityGrid.dropZone.dateField.empty`},{key:`valueField`,label:`chart.configText.activity_measure`,description:`chart.configText.measure_used_for_activity_intensity_color_coding`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.activityGrid.dropZone.valueField.empty`}],displayOptions:[`showLabels`,`showTooltip`,`hideHeader`],displayOptionsConfig:[{key:`fitToWidth`,label:`chart.option.fitToWidth.label`,type:`boolean`,defaultValue:!1,description:`chart.option.fitToWidth.description`}],validate:e=>{let{dateField:t,valueField:n}=e;return!t||Array.isArray(t)&&t.length===0?{isValid:!1,message:`chart.activityGrid.validation.timeDimensionRequired`}:!n||Array.isArray(n)&&n.length===0?{isValid:!1,message:`chart.activityGrid.validation.measureRequired`}:{isValid:!0}},clickableElements:{cell:!0}},kpiNumber:{label:`chart.kpiNumber.label`,description:`chart.kpiNumber.description`,useCase:`chart.kpiNumber.useCase`,dropZones:[{key:`yAxis`,label:`chart.configText.value`,description:`chart.configText.measure_to_display_as_kpi_number`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.kpiNumber.dropZone.yAxis.empty`}],displayOptionsConfig:[{key:`target`,label:`chart.runtime.tooltip.targetValue`,type:`string`,placeholder:`e.g., 100`,description:`chart.configText.target_value_to_compare_against_first_value_used_if_multiple_provided`},{key:`prefix`,label:`chart.option.prefix.label`,type:`string`,placeholder:`e.g., $, €, #`,description:`chart.option.prefix.description`},{key:`suffix`,label:`chart.option.suffix.label`,type:`string`,placeholder:`e.g., %, units, items`,description:`chart.option.suffix.description`},{key:`decimals`,label:`chart.option.decimals.label`,type:`number`,defaultValue:0,min:0,max:10,step:1,description:`chart.option.decimals.description`},{key:`valueColorIndex`,label:`chart.configText.value_color`,type:`paletteColor`,defaultValue:0,description:`chart.configText.color_from_the_dashboard_palette_for_the_kpi_value_text`},{key:`useLastCompletePeriod`,label:`chart.option.useLastCompletePeriod.label`,type:`boolean`,defaultValue:!0,description:`chart.configText.exclude_current_incomplete_period_from_aggregation_e_g_partial_week_mont`},{key:`skipLastPeriod`,label:`chart.option.skipLastPeriod.label`,type:`boolean`,defaultValue:!1,description:`chart.option.skipLastPeriod.description`}],displayOptions:[`hideHeader`]},kpiDelta:{label:`chart.kpiDelta.label`,description:`chart.kpiDelta.description`,useCase:`chart.kpiDelta.useCase`,dropZones:[{key:`yAxis`,label:`chart.configText.value`,description:`chart.configText.measure_to_track_changes_for`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.kpiDelta.dropZone.yAxis.empty`},{key:`xAxis`,label:`chart.configText.dimension_optional`,description:`chart.configText.dimension_for_ordering_data_typically_time`,mandatory:!1,maxItems:1,acceptTypes:[`dimension`,`timeDimension`],emptyText:`chart.kpiDelta.dropZone.xAxis.empty`}],displayOptionsConfig:[{key:`prefix`,label:`chart.option.prefix.label`,type:`string`,placeholder:`e.g., $, €, #`,description:`chart.option.prefix.description`},{key:`suffix`,label:`chart.option.suffix.label`,type:`string`,placeholder:`e.g., %, units, items`,description:`chart.option.suffix.description`},{key:`decimals`,label:`chart.option.decimals.label`,type:`number`,defaultValue:1,min:0,max:10,step:1,description:`chart.option.decimals.description`},{key:`positiveColorIndex`,label:`chart.configText.positive_change_color`,type:`paletteColor`,defaultValue:2,description:`chart.configText.color_for_positive_changes_increases`},{key:`negativeColorIndex`,label:`chart.configText.negative_change_color`,type:`paletteColor`,defaultValue:3,description:`chart.configText.color_for_negative_changes_decreases`},{key:`showHistogram`,label:`chart.option.showHistogram.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showHistogram.description`},{key:`useLastCompletePeriod`,label:`chart.option.useLastCompletePeriod.label`,type:`boolean`,defaultValue:!0,description:`chart.configText.exclude_current_incomplete_period_from_delta_calculation_e_g_partial_wee`},{key:`skipLastPeriod`,label:`chart.option.skipLastPeriod.label`,type:`boolean`,defaultValue:!1,description:`chart.option.skipLastPeriod.description`}],displayOptions:[`hideHeader`],validate:e=>!e.yAxis||Array.isArray(e.yAxis)&&e.yAxis.length===0?{isValid:!1,message:`chart.kpiDelta.validation.measureRequired`}:{isValid:!0}},kpiText:{label:`chart.kpiText.label`,description:`chart.kpiText.description`,useCase:`chart.kpiText.useCase`,dropZones:[{key:`yAxis`,label:`chart.configText.value`,description:`chart.configText.measure_to_display_in_the_kpi_text_template`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.kpiText.dropZone.yAxis.empty`}],displayOptionsConfig:[{key:`template`,label:`chart.configText.text_template`,type:`string`,placeholder:"e.g., Total Revenue: ${value}",description:`chart.configText.template_for_displaying_the_text_use_value_to_insert_the_measure_value`},{key:`decimals`,label:`chart.option.decimals.label`,type:`number`,defaultValue:0,min:0,max:10,step:1,description:`chart.configText.number_of_decimal_places_to_display_for_numeric_values`},{key:`valueColorIndex`,label:`chart.configText.value_color`,type:`paletteColor`,defaultValue:0,description:`chart.configText.color_from_the_dashboard_palette_for_the_kpi_value_text`}],displayOptions:[`hideHeader`]},markdown:{label:`chart.markdown.label`,description:`chart.markdown.description`,useCase:`chart.markdown.useCase`,skipQuery:!0,dropZones:[],displayOptionsConfig:[{key:`content`,label:`chart.configText.markdown_content`,type:`string`,placeholder:`# Welcome
4
+ `)}function r(r){return[`# Drizzle Cube Analytics Agent`,``,`You are an analytics agent that helps users explore and visualize data.`,`You have access to a semantic layer with cubes (data models) that you can query.`,``,`## Your Workflow`,``,`For EACH insight, follow this cycle — do NOT batch all queries first:`,``,"1. **Discover** available cubes using `discover_cubes` (once at the start)",`2. **For each analysis point**, repeat this cycle:`," a. `execute_query` — get the data"," b. `add_markdown` — explain the results and insight"," c. `add_portlet` — visualize the results",``,`Call all three (query → markdown → portlet) in a single turn before moving on to the next analysis.`,`Do NOT run multiple queries first and add charts later — the user sees results in real-time.`,``,`## Important Guidelines`,``,`- ALWAYS discover cubes first before attempting queries`,"- Field names MUST be EXACTLY `CubeName.fieldName` — two parts separated by a single dot. Examples: `PullRequests.count`, `Teams.name`, `Employees.department`."," WRONG patterns that WILL FAIL: `Teams.Teams.name` (double-prefixed), `PullRequests.PullRequests.count` (double-prefixed), `PullRequests` (bare cube), `Teams_count` (underscore). Use the EXACT field names from discover results — copy them verbatim, do not prefix them again.",`- Order keys MUST be one of the measures or dimensions already listed in that query. You CANNOT order by a field that is not in measures or dimensions — add it to measures first, or remove it from order.`,"- After EVERY `execute_query`, IMMEDIATELY call `add_markdown` and `add_portlet` in the SAME turn — never defer visualizations to a later turn",`- Choose appropriate chart types: bar for categories, line for trends, table for detailed data`,`- If a query fails, explain the error and try an alternative approach`,``,`## Output Format Rules`,``,`### CRITICAL: Always think before acting`,`- EVERY single turn MUST begin with a text message (1-2 sentences) BEFORE any tool calls. This is your #1 rule — never violate it.`,`- This applies to EVERY turn, including turns where you are adding visualizations or explanations to the notebook.`,`- Even when adding multiple charts in sequence, each turn must start with a brief status like "Now I'll chart the productivity breakdown." or "Next, let me show the department comparison."`,`- Example good turn: "Let me see what data is available." → discover_cubes`,`- Example good turn: "I'll add a chart showing the top employees." → add_markdown → add_portlet`,`- Example bad turn: (no text) → add_portlet ← NEVER do this`,``,`### Text vs Notebook`,"- ALL analysis, findings, methodology, and insights MUST go through `add_markdown` tool calls — never in your text responses",`- Your text responses must be 1-2 short sentences (under 50 words) summarizing what you are about to do next — status updates only`,`- Never use markdown formatting (headers, bullets, bold, code blocks) in text responses — plain sentences only`,`- Write text responses as a friendly analyst would — use plain business language the user understands`,`- NEVER mention internal terms like "cube", "query syntax", "field names", "measures", "dimensions", "portlet", "prefix format", or tool names in text responses`,`- Instead of "Let me correct the query syntax and retry" → "Let me fix that and try again"`,`- Instead of "I'll query the PullRequests cube" → "I'll look at the pull request data"`,`- Instead of "Adding a portlet with the results" → "Here's a chart of the results"`,``,`### Notebook content rules`,"- Before each `add_portlet`, ALWAYS call `add_markdown` first to explain WHY you are adding this visualization and what it shows","- Before calling `add_portlet`, verify the query is valid: all fields in `order` must also appear in `measures` or `dimensions`",'- Never put data tables in markdown blocks — use `add_portlet` with chartType "table" instead',"- Think out loud in the notebook: use `add_markdown` to share your reasoning at each step so users can follow along",`- NEVER use emojis in text responses or markdown content — no 📊, 📈, ✅, 🔍, etc. Write in plain, professional language.`,``,`## Chart Selection Guide`,``,`Choose the chart type that best communicates the answer to the user's question. Think about what the data represents and what insight the user needs — do NOT default to the first option in this table. Consider the number of data points, whether values are categorical or temporal, and whether the user is comparing, trending, or summarizing.`,``,`| Intent / Data Shape | Chart Type |`,`|---|---|`,"| Compare discrete categories or rankings | `bar` |","| Trend over time (one or few series) | `line` |","| Trend over time showing volume/magnitude | `area` |","| Part-of-whole breakdown | `pie` (≤7 slices) |","| Correlation between two measures | `scatter` |","| Correlation with size/color third dimension | `bubble` |","| Intensity across two categorical dimensions | `heatmap` |","| Multi-variable comparison across categories | `radar` |","| Distribution/spread of values | `boxPlot` |","| Detailed row-level data or many columns | `table` |","| Single headline number — ONLY when user explicitly asks for a KPI card or single number | `kpiNumber` |","| Headline metric with period-over-period change — ONLY when user asks about change in a single metric | `kpiDelta` |",``,`Analysis-mode-specific chart types (require the corresponding analysis mode):`,``,`| Analysis Mode | Chart Type | Description |`,`|---|---|---|`,"| Funnel | `funnel` | Sequential step conversion bars with conversion rates |","| Flow | `sankey` | Flow diagram showing paths between states/steps |","| Flow | `sunburst` | Radial rings showing forward paths from a starting event |","| Retention | `retentionHeatmap` | Cohort × period retention matrix |","| Retention | `retentionCombined` | Retention with line chart, heatmap, or combined modes |",``,'**Chart selection priorities:** Default to `bar` for categories, `line` for time series, `table` for exploratory data. Use `kpiNumber`/`kpiDelta` only as a last resort — they are appropriate only when the user explicitly asks for a single headline number or KPI card. If the query returns multiple rows or the user asks a general question like "show me revenue", prefer `bar` or `table` over `kpiNumber`.',``,`## Chart Axis Configuration Rules`,``,"**Bar charts MUST have an xAxis.** Put a dimension in `chartConfig.xAxis` so bars have category labels. If your query has no dimensions, add one or use `table` instead.",``,"**Never duplicate xAxis in series.** Putting the same dimension in both `xAxis` and `series` creates a sparse, broken-looking chart. The `series` field is ONLY for splitting bars into grouped/stacked sub-series by a SECOND dimension.",``,`Correct bar chart examples:`,'- Categories only: `xAxis: ["Cube.category"], yAxis: ["Cube.count"]` — no series needed','- Grouped bars: `xAxis: ["Cube.category"], yAxis: ["Cube.count"], series: ["Cube.status"]` — series is a DIFFERENT dimension','- Multiple measures: `xAxis: ["Cube.category"], yAxis: ["Cube.count", "Cube.total"]` — each measure becomes a bar group',``,`Wrong:`,'- `xAxis: [], yAxis: ["Cube.avg1", "Cube.avg2"]` — missing xAxis, bars have no labels','- `xAxis: ["Cube.size"], series: ["Cube.size"]` — same field in both, creates sparse chart',``,"**Dual Y-axis for multi-measure charts.** When a `bar`, `line`, or `area` chart has 2+ measures with different scales (e.g. revenue in thousands vs conversion rate as a percentage), use `chartConfig.yAxisAssignment` to put them on separate axes:","```json",`{`,` "xAxis": ["Sales.month"],`,` "yAxis": ["Sales.revenue", "Sales.conversionRate"],`,` "yAxisAssignment": { "Sales.revenue": "left", "Sales.conversionRate": "right" }`,`}`,"```",`Only use dual axis when measures have genuinely different scales. If both measures share the same unit/scale, keep them on the same (left) axis — omit yAxisAssignment entirely.`,``,`## Analysis Mode Decision Tree`,``,`The default mode is **query** (standard measures/dimensions). Switch to a special mode only when the user's question matches:`,``,`- **Funnel mode** — "What is the conversion rate from step A → B → C?"`," - Requires: an event-stream cube with `capabilities.funnel = true` from `discover_cubes`"," - Execute: `execute_query` with `funnel` param:",' `{ bindingKey: "Events.userId", timeDimension: "Events.timestamp", steps: [{ name: "Signup", filter: { member: "Events.eventName", operator: "equals", values: ["signup"] }}, { name: "Purchase", filter: { member: "Events.eventName", operator: "equals", values: ["purchase"] }}] }`',' - Visualize: `add_portlet` with `chartType: "funnel"` and `query` as JSON string containing `{ "funnel": { ... } }`',``,`- **Flow mode** — "What paths do users take after signup?"`," - Requires: `capabilities.flow = true` from `discover_cubes`"," - Execute: `execute_query` with `flow` param:",' `{ bindingKey: "Events.userId", timeDimension: "Events.timestamp", eventDimension: "Events.eventName", startingStep: { name: "Signup", filter: { member: "Events.eventName", operator: "equals", values: ["signup"] }}, stepsBefore: 0, stepsAfter: 3 }`',' - Visualize: `add_portlet` with `chartType: "sankey"` (or `"sunburst"`) and `query` as JSON string containing `{ "flow": { ... } }`',``,`- **Retention mode** — "What % of users come back after 7 days?"`," - Requires: `capabilities.retention = true` from `discover_cubes`"," - Execute: `execute_query` with `retention` param:",' `{ timeDimension: "Events.timestamp", bindingKey: "Events.userId", dateRange: { start: "2024-01-01", end: "2024-03-31" }, granularity: "week", periods: 8, retentionType: "classic" }`',' - Visualize: `add_portlet` with `chartType: "retentionCombined"` (or `"retentionHeatmap"`) and `query` as JSON string containing `{ "retention": { ... } }`',``,"Before using funnel/flow/retention, check the `capabilities` object returned by `discover_cubes`. If the required capability is `false`, explain to the user that the data model does not support that analysis mode.",``,`Event-stream cubes are marked in the Available Cubes section below with **Event Stream: Yes** and list their binding key and time dimension.`,``,`---`,``,n(e.v),``,`---`,``,n(e.y),``,`---`,``,n(e._),``,`---`,``,`## Save as Dashboard`,``,"ONLY call `save_as_dashboard` when the user EXPLICITLY asks to save, export, or convert the notebook into a dashboard. NEVER save a dashboard on your own initiative — wait for the user to request it.",``,`### Layout Rules`,`- Dashboard grid is 12 columns wide`,`- KPI cards: w=3, h=3 — place at the top in a row of 4`,`- Overview charts (bar, line, area): w=6, h=4`,`- Wide charts (heatmap, table): w=12, h=5`,`- Section headers (markdown): w=12, h=1`,``,`### Section Headers`,'Use `chartType: "markdown"` portlets as section headers to organize the dashboard:',"```json",`{`,` "id": "header-overview",`,` "title": "Overview",`,` "chartType": "markdown",`,` "displayConfig": {`,` "content": "## Overview",`,` "hideHeader": true,`,` "transparentBackground": true,`,` "autoHeight": true`,` },`,` "w": 12, "h": 1, "x": 0, "y": 0`,`}`,"```",``,`### Dashboard Filters`,"- ALWAYS include a universal date filter with `isUniversalTime: true`",`- Add dimension filters for key fields used across portlets (e.g., department, status, region)`,`- Use human-readable labels (e.g., "Department" not "Employees.departmentName")`,"- Map filters to portlets using `dashboardFilterMapping` — list the filter IDs that apply",`- When promoting a hardcoded filter to a dashboard filter, REMOVE that filter from the portlet query`,``,`### Analysis Types`,'- Standard query portlets: `analysisType: "query"` (default)','- Funnel portlets: `analysisType: "funnel"`, query contains `{ "funnel": {...} }`, chartType `"funnel"`','- Flow portlets: `analysisType: "flow"`, query contains `{ "flow": {...} }`, chartType `"sankey"` or `"sunburst"`','- Retention portlets: `analysisType: "retention"`, query contains `{ "retention": {...} }`, chartType `"retentionHeatmap"` or `"retentionCombined"`',``,`### CRITICAL: Only use portlets from the notebook`,"- ONLY include portlets that you already added to the notebook via `add_portlet` during this conversation",`- Do NOT invent new queries or charts that were not part of the analysis — the dashboard is a direct conversion of the notebook`,`- Reuse the exact same queries, chart types, and chart configs from the notebook portlets`,`- Arrange the existing portlets in a sensible layout (KPIs at top, charts in middle, tables at bottom)`,`- You may add section header markdown portlets to organize the layout, but do not add new data portlets`,``,`---`,``,t(r)].join(`
5
+ `)}var i={bar:{label:`chart.bar.label`,description:`chart.bar.description`,useCase:`chart.bar.useCase`,clickableElements:{bar:!0},dropZones:[{key:`xAxis`,label:`chart.dropZone.xAxis.label`,description:`chart.dropZone.xAxis.description`,mandatory:!1,acceptTypes:[`dimension`,`timeDimension`],emptyText:`chart.bar.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.dropZone.yAxis.label`,description:`chart.configText.measures_for_bar_heights`,mandatory:!0,acceptTypes:[`measure`],emptyText:`chart.bar.dropZone.yAxis.empty`,enableDualAxis:!0},{key:`series`,label:`chart.dropZone.series.label`,description:`chart.dropZone.series.description`,mandatory:!1,acceptTypes:[`dimension`],emptyText:`chart.bar.dropZone.series.empty`}],displayOptions:[`showLegend`,`showGrid`,`showTooltip`,`hideHeader`],displayOptionsConfig:[{key:`stackType`,label:`chart.option.stacking.label`,type:`select`,defaultValue:`none`,options:[{value:`none`,label:`chart.option.accentBorder.none`},{value:`normal`,label:`chart.option.stacking.stacked`},{value:`percent`,label:`chart.option.stacking.percent`}],description:`chart.configText.how_to_stack_multiple_bar_series`},{key:`target`,label:`chart.option.target.label`,type:`string`,placeholder:`e.g., 100 or 50,75 for spread`,description:`chart.option.target.description`},{key:`leftYAxisFormat`,label:`chart.option.leftYAxisFormat.label`,type:`axisFormat`,description:`chart.option.leftYAxisFormat.description`},{key:`rightYAxisFormat`,label:`chart.option.rightYAxisFormat.label`,type:`axisFormat`,description:`chart.option.rightYAxisFormat.description`}]},line:{label:`chart.line.label`,description:`chart.line.description`,useCase:`chart.line.useCase`,clickableElements:{point:!0},dropZones:[{key:`xAxis`,label:`chart.configText.x_axis_time_categories`,description:`chart.configText.time_dimensions_or_dimensions_for_x_axis`,mandatory:!0,acceptTypes:[`dimension`,`timeDimension`],emptyText:`chart.line.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.dropZone.yAxis.label`,description:`chart.configText.measures_for_line_values`,mandatory:!0,acceptTypes:[`measure`],emptyText:`chart.line.dropZone.yAxis.empty`,enableDualAxis:!0},{key:`series`,label:`chart.configText.series_multiple_lines`,description:`chart.configText.dimensions_to_create_separate_lines`,mandatory:!1,acceptTypes:[`dimension`],emptyText:`chart.line.dropZone.series.empty`}],displayOptions:[`showLegend`,`showGrid`,`showTooltip`,`hideHeader`],displayOptionsConfig:[{key:`connectNulls`,label:`chart.option.connectNulls.label`,type:`boolean`,defaultValue:!1,description:`chart.option.connectNulls.description`},{key:`target`,label:`chart.option.target.label`,type:`string`,placeholder:`e.g., 100 or 50,75 for spread`,description:`chart.option.target.description`},{key:`priorPeriodStyle`,label:`chart.option.priorPeriodStyle.label`,type:`select`,defaultValue:`dashed`,options:[{value:`dashed`,label:`chart.option.priorPeriodStyle.dashed`},{value:`dotted`,label:`chart.option.priorPeriodStyle.dotted`},{value:`solid`,label:`chart.option.priorPeriodStyle.solid`}],description:`chart.option.priorPeriodStyle.description`},{key:`priorPeriodOpacity`,label:`chart.option.priorPeriodOpacity.label`,type:`number`,defaultValue:.5,min:.1,max:1,step:.1,description:`chart.option.priorPeriodOpacity.description`},{key:`leftYAxisFormat`,label:`chart.option.leftYAxisFormat.label`,type:`axisFormat`,description:`chart.option.leftYAxisFormat.description`},{key:`rightYAxisFormat`,label:`chart.option.rightYAxisFormat.label`,type:`axisFormat`,description:`chart.option.rightYAxisFormat.description`}]},area:{label:`chart.area.label`,description:`chart.area.description`,useCase:`chart.area.useCase`,dropZones:[{key:`xAxis`,label:`chart.configText.x_axis_time_categories`,description:`chart.configText.time_dimensions_or_dimensions_for_x_axis`,mandatory:!0,acceptTypes:[`dimension`,`timeDimension`],emptyText:`chart.area.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.dropZone.yAxis.label`,description:`chart.configText.measures_for_area_values`,mandatory:!0,acceptTypes:[`measure`],emptyText:`chart.area.dropZone.yAxis.empty`,enableDualAxis:!0},{key:`series`,label:`chart.configText.series_stack_areas`,description:`chart.configText.dimensions_to_create_stacked_areas`,mandatory:!1,acceptTypes:[`dimension`],emptyText:`chart.area.dropZone.series.empty`}],displayOptions:[`showLegend`,`showGrid`,`showTooltip`,`hideHeader`],displayOptionsConfig:[{key:`stackType`,label:`chart.option.stacking.label`,type:`select`,defaultValue:`none`,options:[{value:`none`,label:`chart.option.accentBorder.none`},{value:`normal`,label:`chart.option.stacking.stacked`},{value:`percent`,label:`chart.option.stacking.percent`}],description:`chart.configText.how_to_stack_multiple_area_series`},{key:`connectNulls`,label:`chart.option.connectNulls.label`,type:`boolean`,defaultValue:!1,description:`chart.option.connectNulls.description`},{key:`target`,label:`chart.option.target.label`,type:`string`,placeholder:`e.g., 100 or 50,75 for spread`,description:`chart.option.target.description`},{key:`leftYAxisFormat`,label:`chart.option.leftYAxisFormat.label`,type:`axisFormat`,description:`chart.option.leftYAxisFormat.description`},{key:`rightYAxisFormat`,label:`chart.option.rightYAxisFormat.label`,type:`axisFormat`,description:`chart.option.rightYAxisFormat.description`}]},pie:{label:`chart.pie.label`,description:`chart.pie.description`,useCase:`chart.pie.useCase`,clickableElements:{slice:!0},dropZones:[{key:`xAxis`,label:`chart.configText.categories`,description:`chart.configText.dimension_for_pie_slices`,mandatory:!0,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.pie.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.values`,description:`chart.configText.measure_for_slice_sizes`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.pie.dropZone.yAxis.empty`}],displayOptions:[`showLegend`,`showTooltip`,`hideHeader`],displayOptionsConfig:[{key:`innerRadius`,label:`chart.option.innerRadius.label`,type:`select`,description:`chart.configText.hollow_center_size_0_percent_solid_pie_higher_donut_style`,defaultValue:`0%`,options:[{value:`0%`,label:`chart.configText.none_pie`},{value:`20%`,label:`chart.configText.20_percent`},{value:`40%`,label:`chart.configText.40_percent`},{value:`60%`,label:`chart.configText.60_percent`},{value:`80%`,label:`chart.configText.80_percent`}]},{key:`leftYAxisFormat`,label:`chart.option.valueFormat.label`,type:`axisFormat`,description:`chart.option.valueFormat.description`}]},scatter:{label:`chart.scatter.label`,description:`chart.scatter.description`,useCase:`chart.scatter.useCase`,dropZones:[{key:`xAxis`,label:`chart.runtime.axisFormat.xAxis`,description:`chart.configText.measure_or_dimension_for_x_position`,mandatory:!0,maxItems:1,acceptTypes:[`dimension`,`timeDimension`,`measure`],emptyText:`chart.scatter.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.y_axis`,description:`chart.configText.measure_for_y_position`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.scatter.dropZone.yAxis.empty`},{key:`series`,label:`chart.configText.series_color_groups`,description:`chart.configText.dimension_to_color_points_by_category`,mandatory:!1,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.scatter.dropZone.series.empty`}],displayOptions:[`showLegend`,`showGrid`,`showTooltip`,`hideHeader`],displayOptionsConfig:[{key:`xAxisFormat`,label:`chart.option.xAxisFormat.label`,type:`axisFormat`,description:`chart.option.xAxisFormat.description`},{key:`leftYAxisFormat`,label:`chart.option.yAxisFormat.label`,type:`axisFormat`,description:`chart.option.yAxisFormat.description`}]},bubble:{label:`chart.bubble.label`,description:`chart.bubble.description`,useCase:`chart.bubble.useCase`,dropZones:[{key:`xAxis`,label:`chart.runtime.axisFormat.xAxis`,description:`chart.configText.horizontal_axis_position`,mandatory:!0,maxItems:1,acceptTypes:[`dimension`,`timeDimension`,`measure`],emptyText:`chart.bubble.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.y_axis`,description:`chart.configText.vertical_axis_position`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.bubble.dropZone.yAxis.empty`},{key:`sizeField`,label:`chart.configText.bubble_radius`,description:`chart.configText.size_of_bubbles_based_on_this_measure`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.bubble.dropZone.sizeField.empty`},{key:`series`,label:`chart.configText.bubble_labels`,description:`chart.configText.field_to_use_for_bubble_labels_and_identification`,mandatory:!0,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.bubble.dropZone.series.empty`},{key:`colorField`,label:`chart.configText.bubble_colour`,description:`chart.configText.color_bubbles_by_this_field_optional`,mandatory:!1,maxItems:1,acceptTypes:[`dimension`,`measure`],emptyText:`chart.bubble.dropZone.colorField.empty`}],displayOptions:[`showLegend`,`showGrid`,`showTooltip`,`minBubbleSize`,`maxBubbleSize`,`bubbleOpacity`,`hideHeader`],displayOptionsConfig:[{key:`xAxisFormat`,label:`chart.option.xAxisFormat.label`,type:`axisFormat`,description:`chart.option.xAxisFormat.description`},{key:`leftYAxisFormat`,label:`chart.option.yAxisFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_y_axis_and_values`}]},radar:{label:`chart.radar.label`,description:`chart.radar.description`,useCase:`chart.radar.useCase`,dropZones:[{key:`xAxis`,label:`chart.configText.axes_categories`,description:`chart.configText.dimensions_for_radar_axes`,mandatory:!0,acceptTypes:[`dimension`],emptyText:`chart.radar.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.values`,description:`chart.configText.measures_for_radar_values`,mandatory:!0,acceptTypes:[`measure`],emptyText:`chart.radar.dropZone.yAxis.empty`},{key:`series`,label:`chart.configText.series_multiple_shapes`,description:`chart.configText.dimensions_to_create_multiple_radar_shapes`,mandatory:!1,acceptTypes:[`dimension`],emptyText:`chart.radar.dropZone.series.empty`}],displayOptions:[`showLegend`,`showGrid`,`showTooltip`,`hideHeader`],displayOptionsConfig:[{key:`leftYAxisFormat`,label:`chart.option.valueFormat.label`,type:`axisFormat`,description:`chart.option.valueFormat.description`}]},radialBar:{label:`chart.radialBar.label`,description:`chart.radialBar.description`,useCase:`chart.radialBar.useCase`,dropZones:[{key:`xAxis`,label:`chart.configText.categories`,description:`chart.configText.dimensions_for_radial_segments`,mandatory:!0,acceptTypes:[`dimension`],emptyText:`chart.radialBar.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.values`,description:`chart.configText.measures_for_radial_bar_lengths`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.radialBar.dropZone.yAxis.empty`}],displayOptions:[`showLegend`,`showTooltip`,`hideHeader`],displayOptionsConfig:[{key:`leftYAxisFormat`,label:`chart.option.valueFormat.label`,type:`axisFormat`,description:`chart.option.valueFormat.description`}]},treemap:{label:`chart.treemap.label`,description:`chart.treemap.description`,useCase:`chart.treemap.useCase`,dropZones:[{key:`xAxis`,label:`chart.configText.categories`,description:`chart.configText.dimensions_for_treemap_rectangles`,mandatory:!0,acceptTypes:[`dimension`],emptyText:`chart.treemap.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.size`,description:`chart.configText.measure_for_rectangle_sizes`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.treemap.dropZone.yAxis.empty`},{key:`series`,label:`chart.configText.color_groups`,description:`chart.configText.dimension_to_color_rectangles_by_category`,mandatory:!1,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.treemap.dropZone.series.empty`}],displayOptions:[`showLegend`,`showTooltip`,`hideHeader`],displayOptionsConfig:[{key:`leftYAxisFormat`,label:`chart.option.valueFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_size_values`}],clickableElements:{cell:!0}},table:{label:`chart.table.label`,description:`chart.table.description`,useCase:`chart.table.useCase`,dropZones:[{key:`xAxis`,label:`chart.configText.columns`,description:`chart.configText.all_fields_to_display_as_columns`,mandatory:!1,acceptTypes:[`dimension`,`timeDimension`,`measure`],emptyText:`chart.table.dropZone.xAxis.empty`}],displayOptions:[`hideHeader`],displayOptionsConfig:[{key:`leftYAxisFormat`,label:`chart.option.valueFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_numeric_values`}]},activityGrid:{label:`chart.activityGrid.label`,description:`chart.activityGrid.description`,useCase:`chart.activityGrid.useCase`,dropZones:[{key:`dateField`,label:`chart.configText.time_dimension`,description:`chart.configText.time_field_that_determines_grid_structure_granularity_affects_layout`,mandatory:!0,maxItems:1,acceptTypes:[`timeDimension`],emptyText:`chart.activityGrid.dropZone.dateField.empty`},{key:`valueField`,label:`chart.configText.activity_measure`,description:`chart.configText.measure_used_for_activity_intensity_color_coding`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.activityGrid.dropZone.valueField.empty`}],displayOptions:[`showLabels`,`showTooltip`,`hideHeader`],displayOptionsConfig:[{key:`fitToWidth`,label:`chart.option.fitToWidth.label`,type:`boolean`,defaultValue:!1,description:`chart.option.fitToWidth.description`}],validate:e=>{let{dateField:t,valueField:n}=e;return!t||Array.isArray(t)&&t.length===0?{isValid:!1,message:`chart.activityGrid.validation.timeDimensionRequired`}:!n||Array.isArray(n)&&n.length===0?{isValid:!1,message:`chart.activityGrid.validation.measureRequired`}:{isValid:!0}},clickableElements:{cell:!0}},kpiNumber:{label:`chart.kpiNumber.label`,description:`chart.kpiNumber.description`,useCase:`chart.kpiNumber.useCase`,dropZones:[{key:`yAxis`,label:`chart.configText.value`,description:`chart.configText.measure_to_display_as_kpi_number`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.kpiNumber.dropZone.yAxis.empty`}],displayOptionsConfig:[{key:`target`,label:`chart.runtime.tooltip.targetValue`,type:`string`,placeholder:`e.g., 100`,description:`chart.configText.target_value_to_compare_against_first_value_used_if_multiple_provided`},{key:`prefix`,label:`chart.option.prefix.label`,type:`string`,placeholder:`e.g., $, €, #`,description:`chart.option.prefix.description`},{key:`suffix`,label:`chart.option.suffix.label`,type:`string`,placeholder:`e.g., %, units, items`,description:`chart.option.suffix.description`},{key:`decimals`,label:`chart.option.decimals.label`,type:`number`,defaultValue:0,min:0,max:10,step:1,description:`chart.option.decimals.description`},{key:`valueColorIndex`,label:`chart.configText.value_color`,type:`paletteColor`,defaultValue:0,description:`chart.configText.color_from_the_dashboard_palette_for_the_kpi_value_text`},{key:`useLastCompletePeriod`,label:`chart.option.useLastCompletePeriod.label`,type:`boolean`,defaultValue:!0,description:`chart.configText.exclude_current_incomplete_period_from_aggregation_e_g_partial_week_mont`},{key:`skipLastPeriod`,label:`chart.option.skipLastPeriod.label`,type:`boolean`,defaultValue:!1,description:`chart.option.skipLastPeriod.description`}],displayOptions:[`hideHeader`]},kpiDelta:{label:`chart.kpiDelta.label`,description:`chart.kpiDelta.description`,useCase:`chart.kpiDelta.useCase`,dropZones:[{key:`yAxis`,label:`chart.configText.value`,description:`chart.configText.measure_to_track_changes_for`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.kpiDelta.dropZone.yAxis.empty`},{key:`xAxis`,label:`chart.configText.dimension_optional`,description:`chart.configText.dimension_for_ordering_data_typically_time`,mandatory:!1,maxItems:1,acceptTypes:[`dimension`,`timeDimension`],emptyText:`chart.kpiDelta.dropZone.xAxis.empty`}],displayOptionsConfig:[{key:`prefix`,label:`chart.option.prefix.label`,type:`string`,placeholder:`e.g., $, €, #`,description:`chart.option.prefix.description`},{key:`suffix`,label:`chart.option.suffix.label`,type:`string`,placeholder:`e.g., %, units, items`,description:`chart.option.suffix.description`},{key:`decimals`,label:`chart.option.decimals.label`,type:`number`,defaultValue:1,min:0,max:10,step:1,description:`chart.option.decimals.description`},{key:`positiveColorIndex`,label:`chart.configText.positive_change_color`,type:`paletteColor`,defaultValue:2,description:`chart.configText.color_for_positive_changes_increases`},{key:`negativeColorIndex`,label:`chart.configText.negative_change_color`,type:`paletteColor`,defaultValue:3,description:`chart.configText.color_for_negative_changes_decreases`},{key:`showHistogram`,label:`chart.option.showHistogram.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showHistogram.description`},{key:`useLastCompletePeriod`,label:`chart.option.useLastCompletePeriod.label`,type:`boolean`,defaultValue:!0,description:`chart.configText.exclude_current_incomplete_period_from_delta_calculation_e_g_partial_wee`},{key:`skipLastPeriod`,label:`chart.option.skipLastPeriod.label`,type:`boolean`,defaultValue:!1,description:`chart.option.skipLastPeriod.description`}],displayOptions:[`hideHeader`],validate:e=>!e.yAxis||Array.isArray(e.yAxis)&&e.yAxis.length===0?{isValid:!1,message:`chart.kpiDelta.validation.measureRequired`}:{isValid:!0}},kpiText:{label:`chart.kpiText.label`,description:`chart.kpiText.description`,useCase:`chart.kpiText.useCase`,dropZones:[{key:`yAxis`,label:`chart.configText.value`,description:`chart.configText.measure_to_display_in_the_kpi_text_template`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.kpiText.dropZone.yAxis.empty`}],displayOptionsConfig:[{key:`template`,label:`chart.configText.text_template`,type:`string`,placeholder:"e.g., Total Revenue: ${value}",description:`chart.configText.template_for_displaying_the_text_use_value_to_insert_the_measure_value`},{key:`decimals`,label:`chart.option.decimals.label`,type:`number`,defaultValue:0,min:0,max:10,step:1,description:`chart.configText.number_of_decimal_places_to_display_for_numeric_values`},{key:`valueColorIndex`,label:`chart.configText.value_color`,type:`paletteColor`,defaultValue:0,description:`chart.configText.color_from_the_dashboard_palette_for_the_kpi_value_text`}],displayOptions:[`hideHeader`]},markdown:{label:`chart.markdown.label`,description:`chart.markdown.description`,useCase:`chart.markdown.useCase`,skipQuery:!0,dropZones:[],displayOptionsConfig:[{key:`content`,label:`chart.configText.markdown_content`,type:`string`,placeholder:`# Welcome
6
6
 
7
7
  Add your **markdown** content here:
8
8
 
@@ -12,14 +12,14 @@ Add your **markdown** content here:
12
12
 
13
13
  ---
14
14
 
15
- Use --- for horizontal rules.`,description:`chart.configText.enter_markdown_text_supports_headers_bold_text_italic_text_links_text_ur`},{key:`accentColorIndex`,label:`chart.configText.accent_color`,type:`paletteColor`,defaultValue:0,description:`chart.configText.color_from_the_dashboard_palette_for_headers_bullets_and_links`},{key:`fontSize`,label:`chart.option.fontSize.label`,type:`select`,defaultValue:`medium`,options:[{value:`small`,label:`chart.option.fontSize.small`},{value:`medium`,label:`chart.option.fontSize.medium`},{value:`large`,label:`chart.option.fontSize.large`}],description:`chart.configText.overall_text_size_for_the_markdown_content`},{key:`alignment`,label:`chart.option.alignment.label`,type:`select`,defaultValue:`left`,options:[{value:`left`,label:`chart.option.accentBorder.left`},{value:`center`,label:`chart.option.alignment.center`},{value:`right`,label:`chart.option.alignment.right`}],description:`chart.configText.horizontal_alignment_of_the_markdown_content`},{key:`hideHeader`,label:`chart.option.hideHeader.label`,type:`boolean`,defaultValue:!0,description:`chart.option.hideHeader.description`},{key:`transparentBackground`,label:`chart.option.transparentBackground.label`,type:`boolean`,defaultValue:!1,description:`chart.option.transparentBackground.description`},{key:`autoHeight`,label:`chart.option.autoHeight.label`,type:`boolean`,defaultValue:!0,description:`chart.option.autoHeight.description`},{key:`accentBorder`,label:`chart.option.accentBorder.label`,type:`select`,defaultValue:`none`,options:[{value:`none`,label:`chart.option.accentBorder.none`},{value:`left`,label:`chart.option.accentBorder.left`},{value:`top`,label:`chart.option.accentBorder.top`},{value:`bottom`,label:`chart.option.accentBorder.bottom`}],description:`chart.configText.add_an_accent_colored_border_on_one_side_of_the_content`}]},funnel:{label:`chart.funnel.label`,description:`chart.funnel.description`,useCase:`chart.funnel.useCase`,dropZones:[{key:`xAxis`,label:`chart.configText.step_name`,description:`chart.configText.step_names_auto_populated_from_funnel_steps`,mandatory:!1,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.funnel.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.step_count`,description:`chart.configText.count_at_each_step_auto_calculated`,mandatory:!1,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.funnel.dropZone.yAxis.empty`}],displayOptions:[`hideHeader`],displayOptionsConfig:[{key:`funnelStyle`,label:`chart.option.funnelStyle.label`,type:`buttonGroup`,defaultValue:`bars`,options:[{value:`bars`,label:`chart.option.funnelStyle.bars`},{value:`funnel`,label:`chart.option.funnelStyle.funnel`}],description:`chart.configText.visualization_style`},{key:`funnelOrientation`,label:`chart.option.funnelOrientation.label`,type:`buttonGroup`,defaultValue:`horizontal`,options:[{value:`horizontal`,label:`chart.option.funnelOrientation.horizontal`},{value:`vertical`,label:`chart.option.funnelOrientation.vertical`}]},{key:`hideSummaryFooter`,label:`chart.option.hideSummaryFooter.label`,type:`boolean`,defaultValue:!1,description:`chart.option.hideSummaryFooter.description`},{key:`showFunnelConversion`,label:`chart.option.showConversion.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showConversion.description`},{key:`showFunnelAvgTime`,label:`chart.option.showAvgTime.label`,type:`boolean`,defaultValue:!1,description:`chart.option.showAvgTime.description`},{key:`showFunnelMedianTime`,label:`chart.option.showMedianTime.label`,type:`boolean`,defaultValue:!1,description:`chart.option.showMedianTime.description`},{key:`showFunnelP90Time`,label:`chart.option.showP90Time.label`,type:`boolean`,defaultValue:!1,description:`chart.option.showP90Time.description`}]},sankey:{label:`chart.sankey.label`,description:`chart.sankey.description`,useCase:`chart.sankey.useCase`,dropZones:[{key:`xAxis`,label:`chart.configText.event_type`,description:`chart.configText.event_dimension_that_categorizes_flow_nodes`,mandatory:!1,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.sankey.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.flow_count`,description:`chart.configText.count_of_entities_following_each_path`,mandatory:!1,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.sankey.dropZone.yAxis.empty`}],displayOptions:[`hideHeader`],displayOptionsConfig:[{key:`linkOpacity`,label:`chart.option.linkOpacity.label`,type:`buttonGroup`,defaultValue:`0.5`,options:[{value:`0.3`,label:`chart.option.linkOpacity.light`},{value:`0.5`,label:`chart.option.fontSize.medium`},{value:`0.7`,label:`chart.option.linkOpacity.dark`}],description:`chart.configText.opacity_of_flow_links`},{key:`showNodeLabels`,label:`chart.option.showNodeLabels.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showNodeLabels.description`},{key:`hideSummaryFooter`,label:`chart.option.hideSummaryFooter.label`,type:`boolean`,defaultValue:!0,description:`chart.configText.hide_the_statistics_footer_below_the_chart`}]},sunburst:{label:`chart.sunburst.label`,description:`chart.sunburst.description`,useCase:`chart.sunburst.useCase`,dropZones:[{key:`xAxis`,label:`chart.configText.event_type`,description:`chart.configText.event_dimension_that_categorizes_flow_nodes`,mandatory:!1,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.sunburst.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.flow_count`,description:`chart.configText.count_of_entities_following_each_path`,mandatory:!1,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.sunburst.dropZone.yAxis.empty`}],displayOptions:[`hideHeader`],displayOptionsConfig:[{key:`innerRadius`,label:`chart.option.innerRadius.label`,type:`number`,defaultValue:40,min:0,max:100,step:10,description:`chart.configText.size_of_the_center_hole_0_for_full_circle`},{key:`hideSummaryFooter`,label:`chart.option.hideSummaryFooter.label`,type:`boolean`,defaultValue:!0,description:`chart.configText.hide_the_statistics_footer_below_the_chart`}]},heatmap:{label:`chart.heatmap.label`,description:`chart.heatmap.description`,useCase:`chart.heatmap.useCase`,dropZones:[{key:`xAxis`,label:`chart.configText.columns_x_axis`,description:`chart.configText.dimension_for_column_categories`,mandatory:!0,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.heatmap.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.rows_y_axis`,description:`chart.configText.dimension_for_row_categories`,mandatory:!0,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.heatmap.dropZone.yAxis.empty`},{key:`valueField`,label:`chart.configText.value_color_intensity`,description:`chart.configText.measure_that_determines_cell_color`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.heatmap.dropZone.valueField.empty`}],displayOptions:[`showLegend`,`showTooltip`],displayOptionsConfig:[{key:`showLabels`,label:`chart.option.showLabels.label`,type:`boolean`,defaultValue:!1,description:`chart.option.showLabels.description`},{key:`cellShape`,label:`chart.option.cellShape.label`,type:`select`,defaultValue:`rect`,options:[{value:`rect`,label:`chart.option.cellShape.rectangle`},{value:`circle`,label:`chart.option.cellShape.circle`}]},{key:`xAxisFormat`,label:`chart.option.xAxisFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_x_axis_labels`},{key:`yAxisFormat`,label:`chart.option.yAxisFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_y_axis_labels`},{key:`valueFormat`,label:`chart.option.valueFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_cell_values_and_legend`}],validate:e=>e.xAxis?.length?e.yAxis?.length?e.valueField?.length?{isValid:!0}:{isValid:!1,message:`chart.heatmap.validation.valueRequired`}:{isValid:!1,message:`chart.heatmap.validation.yAxisRequired`}:{isValid:!1,message:`chart.heatmap.validation.xAxisRequired`}},retentionHeatmap:{label:`chart.retentionHeatmap.label`,dropZones:[],displayOptionsConfig:[{key:`showLegend`,label:`chart.option.showLegend.label`,type:`boolean`,defaultValue:!0,description:`chart.configText.show_the_color_intensity_legend`},{key:`showTooltip`,label:`chart.option.showTooltip.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showTooltip.description`}],description:`chart.retentionHeatmap.description`,useCase:`chart.retentionHeatmap.useCase`},retentionCombined:{label:`chart.retentionCombined.label`,dropZones:[],displayOptionsConfig:[{key:`retentionDisplayMode`,label:`chart.option.retentionDisplayMode.label`,type:`select`,defaultValue:`line`,options:[{value:`line`,label:`chart.option.retentionDisplayMode.lineChart`},{value:`heatmap`,label:`chart.option.retentionDisplayMode.heatmapTable`},{value:`combined`,label:`chart.option.retentionDisplayMode.combined`}],description:`chart.configText.choose_how_to_visualize_retention_data`},{key:`showLegend`,label:`chart.option.showLegend.label`,type:`boolean`,defaultValue:!0,description:`chart.configText.show_the_legend_for_breakdown_segments`},{key:`showGrid`,label:`chart.option.showGrid.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showGrid.description`},{key:`showTooltip`,label:`chart.option.showTooltip.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showTooltip.description`}],description:`chart.retentionCombined.description`,useCase:`chart.retentionCombined.useCase`},boxPlot:{label:`chart.boxPlot.label`,description:`chart.boxPlot.description`,useCase:`chart.boxPlot.useCase`,displayOptions:[`hideHeader`],dropZones:[{key:`xAxis`,label:`chart.configText.x_axis_groups`,description:`chart.configText.dimension_to_group_boxes_by_e_g_symbol_platform`,mandatory:!0,maxItems:1,acceptTypes:[`dimension`,`timeDimension`],emptyText:`chart.boxPlot.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.y_axis_measures`,description:`chart.configText.drop_1_measure_for_auto_mode_3_for_avg_stddev_median_mode_or_5_for_min_q`,mandatory:!0,maxItems:5,acceptTypes:[`measure`],emptyText:`chart.boxPlot.dropZone.yAxis.empty`}],displayOptionsConfig:[{key:`leftYAxisFormat`,label:`chart.option.yAxisFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_the_value_axis`}]},waterfall:{label:`chart.waterfall.label`,description:`chart.waterfall.description`,useCase:`chart.waterfall.useCase`,clickableElements:{bar:!0},displayOptions:[`showTooltip`,`hideHeader`],dropZones:[{key:`xAxis`,label:`chart.dropZone.xAxis.label`,description:`chart.configText.dimension_labels_for_each_bar_segment_e_g_symbol_transaction_type`,mandatory:!0,maxItems:1,acceptTypes:[`dimension`,`timeDimension`],emptyText:`chart.waterfall.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.y_axis_value`,description:`chart.configText.single_measure_whose_values_are_summed_cumulatively`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.waterfall.dropZone.yAxis.empty`}],displayOptionsConfig:[{key:`showTotal`,label:`chart.option.showTotal.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showTotal.description`},{key:`showConnectorLine`,label:`chart.option.showConnectorLine.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showConnectorLine.description`},{key:`showDataLabels`,label:`chart.option.showDataLabels.label`,type:`boolean`,defaultValue:!1,description:`chart.configText.display_the_value_above_each_bar_segment`},{key:`leftYAxisFormat`,label:`chart.option.yAxisFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_the_y_axis`}]},candlestick:{label:`chart.candlestick.label`,description:`chart.candlestick.description`,useCase:`chart.candlestick.useCase`,clickableElements:{bar:!0},displayOptions:[`hideHeader`],dropZones:[{key:`xAxis`,label:`chart.configText.x_axis_time_category`,description:`chart.configText.time_dimension_or_category_for_each_candle_e_g_date_symbol`,mandatory:!0,maxItems:1,acceptTypes:[`timeDimension`,`dimension`],emptyText:`chart.candlestick.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.ohlc_measures_open_close_high_low`,description:`chart.configText.drop_2_4_measures_in_order_open_close_high_low_ohlc_mode_for_range_mode_`,mandatory:!0,acceptTypes:[`measure`],emptyText:`chart.candlestick.dropZone.yAxis.empty`}],displayOptionsConfig:[{key:`rangeMode`,label:`chart.option.rangeMode.label`,type:`select`,defaultValue:`ohlc`,options:[{value:`ohlc`,label:`chart.option.rangeMode.ohlc`},{value:`range`,label:`chart.option.rangeMode.range`}],description:`chart.option.rangeMode.description`},{key:`bullColor`,label:`chart.option.bullColor.label`,type:`color`,defaultValue:`#22c55e`,description:`chart.option.bullColor.description`},{key:`bearColor`,label:`chart.option.bearColor.label`,type:`color`,defaultValue:`#ef4444`,description:`chart.option.bearColor.description`},{key:`showWicks`,label:`chart.option.showWicks.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showWicks.description`},{key:`leftYAxisFormat`,label:`chart.option.yAxisFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_the_price_axis`}]},measureProfile:{label:`chart.measureProfile.label`,description:`chart.measureProfile.description`,useCase:`chart.measureProfile.useCase`,displayOptions:[`showLegend`,`showTooltip`,`hideHeader`],dropZones:[{key:`yAxis`,label:`chart.configText.measures_x_axis_order`,description:`chart.configText.add_2_or_more_measures_they_become_the_x_axis_categories_in_the_order_li`,mandatory:!0,acceptTypes:[`measure`],emptyText:`chart.measureProfile.dropZone.yAxis.empty`},{key:`series`,label:`chart.configText.series_split_into_multiple_lines`,description:`chart.configText.dimension_to_split_data_into_separate_profile_lines_e_g_symbol_platform`,mandatory:!1,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.measureProfile.dropZone.series.empty`}],displayOptionsConfig:[{key:`showReferenceLineAtZero`,label:`chart.option.showReferenceLineAtZero.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showReferenceLineAtZero.description`},{key:`showDataLabels`,label:`chart.option.showDataLabels.label`,type:`boolean`,defaultValue:!1,description:`chart.configText.display_value_at_each_data_point`},{key:`showLegend`,label:`chart.option.showLegend.label`,type:`boolean`,defaultValue:!0,description:`chart.configText.show_series_legend_only_visible_with_a_series_dimension`},{key:`lineType`,label:`chart.option.lineType.label`,type:`select`,defaultValue:`monotone`,options:[{value:`monotone`,label:`chart.option.lineType.smooth`},{value:`linear`,label:`chart.option.lineType.linear`},{value:`step`,label:`chart.option.lineType.step`}],description:`chart.option.lineType.description`},{key:`leftYAxisFormat`,label:`chart.option.yAxisFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_the_y_axis`}]},gauge:{label:`chart.gauge.label`,description:`chart.gauge.description`,useCase:`chart.gauge.useCase`,clickableElements:{},displayOptions:[`hideHeader`],dropZones:[{key:`yAxis`,label:`chart.configText.value_measure`,description:`chart.configText.current_value_to_display_on_the_gauge_e_g_current_equity_margin_used`,mandatory:!0,maxItems:2,acceptTypes:[`measure`],emptyText:`chart.gauge.dropZone.yAxis.empty`}],displayOptionsConfig:[{key:`minValue`,label:`chart.option.minValue.label`,type:`number`,defaultValue:0,description:`chart.option.minValue.description`},{key:`maxValue`,label:`chart.option.maxValue.label`,type:`number`,description:`chart.option.maxValue.description`},{key:`thresholds`,label:`chart.configText.threshold_bands`,type:`string`,placeholder:`[{"value":0.33,"color":"#22c55e"},{"value":0.66,"color":"#f59e0b"},{"value":1,"color":"#ef4444"}]`,description:`chart.configText.array_of_value_0_1_fraction_color_bands_shown_as_outer_arc_markers`},{key:`showCenterLabel`,label:`chart.option.showCentreLabel.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showCentreLabel.description`},{key:`showPercentage`,label:`chart.option.showPercentage.label`,type:`boolean`,defaultValue:!1,description:`chart.option.showPercentage.description`},{key:`leftYAxisFormat`,label:`chart.option.valueFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_the_displayed_value_and_axis_labels`}]}};function o(t,n,r){let i=a[t];if(!i||i.skipQuery)return{isValid:!0,errors:[]};let o=[];for(let r of i.dropZones){if(!r.mandatory)continue;let i=n?.[r.key];if(!(Array.isArray(i)?i.length>0:i)){let n=r.acceptTypes?.join(`/`)??`fields`;o.push(e._(`server.validation.chart.dropZoneRequired`,{key:r.key,chartType:t,label:r.label,acceptDesc:n}))}}if(t===`bar`){let t=n?.xAxis;if(!(Array.isArray(t)?t.length>0:t)){let t=r.dimensions??[],n=r.timeDimensions??[];t.length>0||n.length>0?o.push(e._(`server.validation.chart.barXAxisRequired`)):o.push(e._(`server.validation.chart.barNeedsDimension`))}}if(n?.xAxis&&n?.series){let t=new Set(Array.isArray(n.xAxis)?n.xAxis:[n.xAxis]),r=(Array.isArray(n.series)?n.series:[n.series]).filter(e=>t.has(e));r.length>0&&o.push(e._(`server.validation.chart.seriesDuplicatesXAxis`,{duplicates:r.join(`, `)}))}return{isValid:o.length===0,errors:o}}function s(e,t,n){let r=a[e];if(!r)return t??{};let i={...t},o=n.measures??[],s=n.dimensions??[],c=(n.timeDimensions??[]).map(e=>e.dimension);for(let e of r.dropZones){let t=i[e.key];if(Array.isArray(t)?t.length>0:t)continue;let n=e.acceptTypes??[];if(e.key===`sizeField`||e.key===`colorField`){if(n.includes(`measure`)){let t=new Set;for(let n of r.dropZones){if(n.key===e.key)continue;let r=i[n.key];Array.isArray(r)?r.forEach(e=>t.add(e)):typeof r==`string`&&t.add(r)}let n=o.filter(e=>!t.has(e));n.length>0&&(i[e.key]=n[0])}continue}let a=[];if(n.includes(`dimension`)&&a.push(...s),n.includes(`timeDimension`)&&a.push(...c),n.includes(`measure`)&&a.push(...o),a.length===0)continue;let l=a;if(e.key===`series`){let e=new Set(Array.isArray(i.xAxis)?i.xAxis:i.xAxis?[i.xAxis]:[]);if(l=a.filter(t=>!e.has(t)),l.length===0)continue}let u=e.maxItems??1/0,d=l.slice(0,u);d.length>0&&(i[e.key]=d)}return i}function c(e){let t=[`
16
- Chart config requirements by type:`];for(let n of e){let e=a[n];if(!e)continue;let r=[e.description??``,e.useCase??``].filter(Boolean).join(`. `),i=r?` — ${r}.`:``,o=e.dropZones.filter(e=>e.mandatory);if(o.length===0&&!e.skipQuery){t.push(` ${n}${i} chartConfig auto-inferred from query.`);continue}if(e.skipQuery){t.push(` ${n}${i} No query needed.`);continue}let s=o.map(e=>{let t=e.acceptTypes?.join(`/`)??`any`,n=e.maxItems?` (max ${e.maxItems})`:``;return`${e.key}=[${t}]${n}`});t.push(` ${n}${i} Requires ${s.join(`, `)}.`)}return t.join(`
17
- `)}var l=[`bar`,`line`,`area`,`pie`,`scatter`,`radar`,`bubble`,`table`,`kpiNumber`,`kpiDelta`,`funnel`,`heatmap`,`sankey`,`sunburst`,`retentionHeatmap`,`retentionCombined`,`boxPlot`,`markdown`];function u(){return[{name:`discover_cubes`,description:`Search for available data cubes by topic or intent. Call this FIRST to understand what data is available. Returns cube names, measures, dimensions, and relationships.`,parameters:{type:`object`,properties:{topic:{type:`string`,description:`Keyword to search (e.g., "sales", "employees")`},intent:{type:`string`,description:`Natural language goal (e.g., "analyze productivity trends")`},limit:{type:`number`,description:`Max results (default: 10)`},minScore:{type:`number`,description:`Min relevance 0-1 (default: 0.1)`}}}},{name:`get_cube_metadata`,description:`Get full metadata for all registered cubes including all measures, dimensions, types, and relationships. Use this for detailed schema information.`,parameters:{type:`object`,properties:{}}},{name:`execute_query`,description:`Execute a semantic query and return data results. Supports standard queries (measures/dimensions) and analysis modes (funnel/flow/retention). Only provide ONE mode per call.`,parameters:{type:`object`,properties:t.a}},{name:`add_portlet`,description:`Add a chart visualization to the notebook.
18
- `+c(l)+`
19
- The query is validated before adding. The portlet fetches its own data.`,parameters:{type:`object`,properties:{title:{type:`string`,description:`Title for the visualization`},query:{type:`string`,description:`JSON string of the query. Standard: {"measures":[...],"dimensions":[...]}. Funnel: {"funnel":{"bindingKey":"...","timeDimension":"...","steps":[...]}}. Flow: {"flow":{"bindingKey":"...","timeDimension":"...","eventDimension":"...","startingStep":{...}}}. Retention: {"retention":{"timeDimension":"...","bindingKey":"...","dateRange":{"start":"...","end":"..."},"granularity":"...","periods":N}}.`},chartType:{type:`string`,enum:l,description:`Chart type to render`},chartConfig:{type:`object`,properties:{xAxis:{type:`array`,items:{type:`string`}},yAxis:{type:`array`,items:{type:`string`}},series:{type:`array`,items:{type:`string`}},sizeField:{type:`string`},colorField:{type:`string`},yAxisAssignment:{type:`object`,description:`Dual Y-axis: map measure fields to "left" or "right" axis. Only for bar, line, area charts with 2+ measures of different scales. Example: {"Sales.revenue": "left", "Sales.conversionRate": "right"}`}},description:`Chart axis configuration`},displayConfig:{type:`object`,properties:{showLegend:{type:`boolean`},showGrid:{type:`boolean`},showTooltip:{type:`boolean`},stacked:{type:`boolean`},orientation:{type:`string`,enum:[`horizontal`,`vertical`]}},description:`Chart display configuration`}},required:[`title`,`query`,`chartType`]}},{name:`add_markdown`,description:`Add an explanation or analysis text block to the notebook. Use markdown formatting. Use this to explain findings, methodology, and insights alongside visualizations.`,parameters:{type:`object`,properties:{title:{type:`string`,description:`Optional title for the text block`},content:{type:`string`,description:`Markdown content to display`}},required:[`content`]}},{name:`save_as_dashboard`,description:`Convert the current notebook analysis into a persistent dashboard. Constructs a professional DashboardConfig with proper grid layout, section headers (markdown portlets), and dashboard-level filters. Call this when the user asks to save/export the notebook as a dashboard.`,parameters:{type:`object`,properties:{title:{type:`string`,description:`Dashboard title`},description:{type:`string`,description:`Optional dashboard description`},portlets:{type:`array`,items:{type:`object`,properties:{id:{type:`string`,description:`Unique portlet ID`},title:{type:`string`,description:`Portlet title`},chartType:{type:`string`,enum:l,description:`Chart type. Use "markdown" for section headers.`},query:{type:`string`,description:`JSON string of the query. Omit or leave empty for markdown portlets.`},chartConfig:{type:`object`,properties:{xAxis:{type:`array`,items:{type:`string`}},yAxis:{type:`array`,items:{type:`string`}},series:{type:`array`,items:{type:`string`}},sizeField:{type:`string`},colorField:{type:`string`}},description:`Chart axis configuration`},displayConfig:{type:`object`,description:`Chart display configuration (for markdown: { content, hideHeader, transparentBackground, autoHeight })`},dashboardFilterMapping:{type:`array`,items:{type:`string`},description:`Array of dashboard filter IDs that apply to this portlet`},analysisType:{type:`string`,enum:[`query`,`funnel`,`flow`,`retention`],description:`Analysis type (default: "query")`},w:{type:`number`,description:`Grid width (1-12)`},h:{type:`number`,description:`Grid height in row units`},x:{type:`number`,description:`Grid x position (0-11)`},y:{type:`number`,description:`Grid y position`}},required:[`id`,`title`,`chartType`,`w`,`h`,`x`,`y`]},description:`Array of portlet configurations for the dashboard`},filters:{type:`array`,items:{type:`object`,properties:{id:{type:`string`,description:`Unique filter ID`},label:{type:`string`,description:`Display label for the filter`},filter:{type:`object`,properties:{member:{type:`string`},operator:{type:`string`},values:{type:`array`,items:{}}},required:[`member`,`operator`],description:`The filter definition`},isUniversalTime:{type:`boolean`,description:`When true, applies to all time dimensions in portlets`}},required:[`id`,`label`,`filter`]},description:`Dashboard-level filters`},colorPalette:{type:`string`,description:`Color palette name`}},required:[`title`,`portlets`]}}]}function d(t){let{semanticLayer:n,securityContext:r}=t,i=new Map;i.set(`discover_cubes`,async t=>{let r={cubes:(await e.d(n,{topic:t.topic,intent:t.intent,limit:t.limit,minScore:t.minScore})).cubes.map(e=>({cube:e.cube,title:e.title,description:e.description,relevanceScore:e.relevanceScore,suggestedMeasures:e.suggestedMeasures,suggestedDimensions:e.suggestedDimensions,capabilities:e.capabilities,...e.capabilities.funnel||e.capabilities.flow||e.capabilities.retention?{analysisConfig:{candidateBindingKeys:e.analysisConfig?.candidateBindingKeys?.map(e=>e.dimension)??[],candidateTimeDimensions:e.analysisConfig?.candidateTimeDimensions?.map(e=>e.dimension)??[],...e.analysisConfig?.candidateEventDimensions?.length?{candidateEventDimensions:e.analysisConfig.candidateEventDimensions.map(e=>e.dimension)}:{}}}:{}}))};return{result:JSON.stringify(r)+`
20
- [IMPORTANT: Your next response MUST start with a brief text message BEFORE any tool calls.]`}}),i.set(`get_cube_metadata`,async()=>{let e=n.getMetadata();return{result:JSON.stringify(e)}});let a=new Map;for(let e of n.getMetadata())a.set(e.name,{measures:(e.measures||[]).map(e=>e.name),dimensions:(e.dimensions||[]).map(e=>e.name)});let c=(e,t)=>{let n=a.get(e),r=t===`measures`?n?.measures:n?.dimensions;return!r||r.length===0?``:` Available ${t}: ${r.slice(0,5).map(e=>`"${e}"`).join(`, `)}`};return i.set(`execute_query`,async t=>{try{let i=(e,t)=>{if(!Array.isArray(e))return;let n=[];for(let r of e){if(typeof r!=`string`)continue;let e=r.split(`.`);e.length===1?n.push(`"${r}" is not valid — must be "CubeName.fieldName".${c(r,t)}`):e.length===2&&e[0]===e[1]&&n.push(`"${r}" is WRONG — "${e[0]}" is the cube name, not a ${t.replace(/s$/,``)}.${c(e[0],t)}`)}if(n.length>0)throw Error(`Invalid ${t}:\n${n.join(`
15
+ Use --- for horizontal rules.`,description:`chart.configText.enter_markdown_text_supports_headers_bold_text_italic_text_links_text_ur`},{key:`accentColorIndex`,label:`chart.configText.accent_color`,type:`paletteColor`,defaultValue:0,description:`chart.configText.color_from_the_dashboard_palette_for_headers_bullets_and_links`},{key:`fontSize`,label:`chart.option.fontSize.label`,type:`select`,defaultValue:`medium`,options:[{value:`small`,label:`chart.option.fontSize.small`},{value:`medium`,label:`chart.option.fontSize.medium`},{value:`large`,label:`chart.option.fontSize.large`}],description:`chart.configText.overall_text_size_for_the_markdown_content`},{key:`alignment`,label:`chart.option.alignment.label`,type:`select`,defaultValue:`left`,options:[{value:`left`,label:`chart.option.accentBorder.left`},{value:`center`,label:`chart.option.alignment.center`},{value:`right`,label:`chart.option.alignment.right`}],description:`chart.configText.horizontal_alignment_of_the_markdown_content`},{key:`hideHeader`,label:`chart.option.hideHeader.label`,type:`boolean`,defaultValue:!0,description:`chart.option.hideHeader.description`},{key:`transparentBackground`,label:`chart.option.transparentBackground.label`,type:`boolean`,defaultValue:!1,description:`chart.option.transparentBackground.description`},{key:`autoHeight`,label:`chart.option.autoHeight.label`,type:`boolean`,defaultValue:!0,description:`chart.option.autoHeight.description`},{key:`accentBorder`,label:`chart.option.accentBorder.label`,type:`select`,defaultValue:`none`,options:[{value:`none`,label:`chart.option.accentBorder.none`},{value:`left`,label:`chart.option.accentBorder.left`},{value:`top`,label:`chart.option.accentBorder.top`},{value:`bottom`,label:`chart.option.accentBorder.bottom`}],description:`chart.configText.add_an_accent_colored_border_on_one_side_of_the_content`}]},funnel:{label:`chart.funnel.label`,description:`chart.funnel.description`,useCase:`chart.funnel.useCase`,dropZones:[{key:`xAxis`,label:`chart.configText.step_name`,description:`chart.configText.step_names_auto_populated_from_funnel_steps`,mandatory:!1,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.funnel.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.step_count`,description:`chart.configText.count_at_each_step_auto_calculated`,mandatory:!1,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.funnel.dropZone.yAxis.empty`}],displayOptions:[`hideHeader`],displayOptionsConfig:[{key:`funnelStyle`,label:`chart.option.funnelStyle.label`,type:`buttonGroup`,defaultValue:`bars`,options:[{value:`bars`,label:`chart.option.funnelStyle.bars`},{value:`funnel`,label:`chart.option.funnelStyle.funnel`}],description:`chart.configText.visualization_style`},{key:`funnelOrientation`,label:`chart.option.funnelOrientation.label`,type:`buttonGroup`,defaultValue:`horizontal`,options:[{value:`horizontal`,label:`chart.option.funnelOrientation.horizontal`},{value:`vertical`,label:`chart.option.funnelOrientation.vertical`}]},{key:`hideSummaryFooter`,label:`chart.option.hideSummaryFooter.label`,type:`boolean`,defaultValue:!1,description:`chart.option.hideSummaryFooter.description`},{key:`showFunnelConversion`,label:`chart.option.showConversion.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showConversion.description`},{key:`showFunnelAvgTime`,label:`chart.option.showAvgTime.label`,type:`boolean`,defaultValue:!1,description:`chart.option.showAvgTime.description`},{key:`showFunnelMedianTime`,label:`chart.option.showMedianTime.label`,type:`boolean`,defaultValue:!1,description:`chart.option.showMedianTime.description`},{key:`showFunnelP90Time`,label:`chart.option.showP90Time.label`,type:`boolean`,defaultValue:!1,description:`chart.option.showP90Time.description`}]},sankey:{label:`chart.sankey.label`,description:`chart.sankey.description`,useCase:`chart.sankey.useCase`,dropZones:[{key:`xAxis`,label:`chart.configText.event_type`,description:`chart.configText.event_dimension_that_categorizes_flow_nodes`,mandatory:!1,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.sankey.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.flow_count`,description:`chart.configText.count_of_entities_following_each_path`,mandatory:!1,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.sankey.dropZone.yAxis.empty`}],displayOptions:[`hideHeader`],displayOptionsConfig:[{key:`linkOpacity`,label:`chart.option.linkOpacity.label`,type:`buttonGroup`,defaultValue:`0.5`,options:[{value:`0.3`,label:`chart.option.linkOpacity.light`},{value:`0.5`,label:`chart.option.fontSize.medium`},{value:`0.7`,label:`chart.option.linkOpacity.dark`}],description:`chart.configText.opacity_of_flow_links`},{key:`showNodeLabels`,label:`chart.option.showNodeLabels.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showNodeLabels.description`},{key:`hideSummaryFooter`,label:`chart.option.hideSummaryFooter.label`,type:`boolean`,defaultValue:!0,description:`chart.configText.hide_the_statistics_footer_below_the_chart`}]},sunburst:{label:`chart.sunburst.label`,description:`chart.sunburst.description`,useCase:`chart.sunburst.useCase`,dropZones:[{key:`xAxis`,label:`chart.configText.event_type`,description:`chart.configText.event_dimension_that_categorizes_flow_nodes`,mandatory:!1,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.sunburst.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.flow_count`,description:`chart.configText.count_of_entities_following_each_path`,mandatory:!1,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.sunburst.dropZone.yAxis.empty`}],displayOptions:[`hideHeader`],displayOptionsConfig:[{key:`innerRadius`,label:`chart.option.innerRadius.label`,type:`number`,defaultValue:40,min:0,max:100,step:10,description:`chart.configText.size_of_the_center_hole_0_for_full_circle`},{key:`hideSummaryFooter`,label:`chart.option.hideSummaryFooter.label`,type:`boolean`,defaultValue:!0,description:`chart.configText.hide_the_statistics_footer_below_the_chart`}]},heatmap:{label:`chart.heatmap.label`,description:`chart.heatmap.description`,useCase:`chart.heatmap.useCase`,dropZones:[{key:`xAxis`,label:`chart.configText.columns_x_axis`,description:`chart.configText.dimension_for_column_categories`,mandatory:!0,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.heatmap.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.rows_y_axis`,description:`chart.configText.dimension_for_row_categories`,mandatory:!0,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.heatmap.dropZone.yAxis.empty`},{key:`valueField`,label:`chart.configText.value_color_intensity`,description:`chart.configText.measure_that_determines_cell_color`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.heatmap.dropZone.valueField.empty`}],displayOptions:[`showLegend`,`showTooltip`],displayOptionsConfig:[{key:`showLabels`,label:`chart.option.showLabels.label`,type:`boolean`,defaultValue:!1,description:`chart.option.showLabels.description`},{key:`cellShape`,label:`chart.option.cellShape.label`,type:`select`,defaultValue:`rect`,options:[{value:`rect`,label:`chart.option.cellShape.rectangle`},{value:`circle`,label:`chart.option.cellShape.circle`}]},{key:`xAxisFormat`,label:`chart.option.xAxisFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_x_axis_labels`},{key:`yAxisFormat`,label:`chart.option.yAxisFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_y_axis_labels`},{key:`valueFormat`,label:`chart.option.valueFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_cell_values_and_legend`}],validate:e=>e.xAxis?.length?e.yAxis?.length?e.valueField?.length?{isValid:!0}:{isValid:!1,message:`chart.heatmap.validation.valueRequired`}:{isValid:!1,message:`chart.heatmap.validation.yAxisRequired`}:{isValid:!1,message:`chart.heatmap.validation.xAxisRequired`}},retentionHeatmap:{label:`chart.retentionHeatmap.label`,dropZones:[],displayOptionsConfig:[{key:`showLegend`,label:`chart.option.showLegend.label`,type:`boolean`,defaultValue:!0,description:`chart.configText.show_the_color_intensity_legend`},{key:`showTooltip`,label:`chart.option.showTooltip.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showTooltip.description`}],description:`chart.retentionHeatmap.description`,useCase:`chart.retentionHeatmap.useCase`},retentionCombined:{label:`chart.retentionCombined.label`,dropZones:[],displayOptionsConfig:[{key:`retentionDisplayMode`,label:`chart.option.retentionDisplayMode.label`,type:`select`,defaultValue:`line`,options:[{value:`line`,label:`chart.option.retentionDisplayMode.lineChart`},{value:`heatmap`,label:`chart.option.retentionDisplayMode.heatmapTable`},{value:`combined`,label:`chart.option.retentionDisplayMode.combined`}],description:`chart.configText.choose_how_to_visualize_retention_data`},{key:`showLegend`,label:`chart.option.showLegend.label`,type:`boolean`,defaultValue:!0,description:`chart.configText.show_the_legend_for_breakdown_segments`},{key:`showGrid`,label:`chart.option.showGrid.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showGrid.description`},{key:`showTooltip`,label:`chart.option.showTooltip.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showTooltip.description`}],description:`chart.retentionCombined.description`,useCase:`chart.retentionCombined.useCase`},boxPlot:{label:`chart.boxPlot.label`,description:`chart.boxPlot.description`,useCase:`chart.boxPlot.useCase`,displayOptions:[`hideHeader`],dropZones:[{key:`xAxis`,label:`chart.configText.x_axis_groups`,description:`chart.configText.dimension_to_group_boxes_by_e_g_symbol_platform`,mandatory:!0,maxItems:1,acceptTypes:[`dimension`,`timeDimension`],emptyText:`chart.boxPlot.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.y_axis_measures`,description:`chart.configText.drop_1_measure_for_auto_mode_3_for_avg_stddev_median_mode_or_5_for_min_q`,mandatory:!0,maxItems:5,acceptTypes:[`measure`],emptyText:`chart.boxPlot.dropZone.yAxis.empty`}],displayOptionsConfig:[{key:`leftYAxisFormat`,label:`chart.option.yAxisFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_the_value_axis`}]},waterfall:{label:`chart.waterfall.label`,description:`chart.waterfall.description`,useCase:`chart.waterfall.useCase`,clickableElements:{bar:!0},displayOptions:[`showTooltip`,`hideHeader`],dropZones:[{key:`xAxis`,label:`chart.dropZone.xAxis.label`,description:`chart.configText.dimension_labels_for_each_bar_segment_e_g_symbol_transaction_type`,mandatory:!0,maxItems:1,acceptTypes:[`dimension`,`timeDimension`],emptyText:`chart.waterfall.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.y_axis_value`,description:`chart.configText.single_measure_whose_values_are_summed_cumulatively`,mandatory:!0,maxItems:1,acceptTypes:[`measure`],emptyText:`chart.waterfall.dropZone.yAxis.empty`}],displayOptionsConfig:[{key:`showTotal`,label:`chart.option.showTotal.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showTotal.description`},{key:`showConnectorLine`,label:`chart.option.showConnectorLine.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showConnectorLine.description`},{key:`showDataLabels`,label:`chart.option.showDataLabels.label`,type:`boolean`,defaultValue:!1,description:`chart.configText.display_the_value_above_each_bar_segment`},{key:`leftYAxisFormat`,label:`chart.option.yAxisFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_the_y_axis`}]},candlestick:{label:`chart.candlestick.label`,description:`chart.candlestick.description`,useCase:`chart.candlestick.useCase`,clickableElements:{bar:!0},displayOptions:[`hideHeader`],dropZones:[{key:`xAxis`,label:`chart.configText.x_axis_time_category`,description:`chart.configText.time_dimension_or_category_for_each_candle_e_g_date_symbol`,mandatory:!0,maxItems:1,acceptTypes:[`timeDimension`,`dimension`],emptyText:`chart.candlestick.dropZone.xAxis.empty`},{key:`yAxis`,label:`chart.configText.ohlc_measures_open_close_high_low`,description:`chart.configText.drop_2_4_measures_in_order_open_close_high_low_ohlc_mode_for_range_mode_`,mandatory:!0,acceptTypes:[`measure`],emptyText:`chart.candlestick.dropZone.yAxis.empty`}],displayOptionsConfig:[{key:`rangeMode`,label:`chart.option.rangeMode.label`,type:`select`,defaultValue:`ohlc`,options:[{value:`ohlc`,label:`chart.option.rangeMode.ohlc`},{value:`range`,label:`chart.option.rangeMode.range`}],description:`chart.option.rangeMode.description`},{key:`bullColor`,label:`chart.option.bullColor.label`,type:`color`,defaultValue:`#22c55e`,description:`chart.option.bullColor.description`},{key:`bearColor`,label:`chart.option.bearColor.label`,type:`color`,defaultValue:`#ef4444`,description:`chart.option.bearColor.description`},{key:`showWicks`,label:`chart.option.showWicks.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showWicks.description`},{key:`leftYAxisFormat`,label:`chart.option.yAxisFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_the_price_axis`}]},measureProfile:{label:`chart.measureProfile.label`,description:`chart.measureProfile.description`,useCase:`chart.measureProfile.useCase`,displayOptions:[`showLegend`,`showTooltip`,`hideHeader`],dropZones:[{key:`yAxis`,label:`chart.configText.measures_x_axis_order`,description:`chart.configText.add_2_or_more_measures_they_become_the_x_axis_categories_in_the_order_li`,mandatory:!0,acceptTypes:[`measure`],emptyText:`chart.measureProfile.dropZone.yAxis.empty`},{key:`series`,label:`chart.configText.series_split_into_multiple_lines`,description:`chart.configText.dimension_to_split_data_into_separate_profile_lines_e_g_symbol_platform`,mandatory:!1,maxItems:1,acceptTypes:[`dimension`],emptyText:`chart.measureProfile.dropZone.series.empty`}],displayOptionsConfig:[{key:`showReferenceLineAtZero`,label:`chart.option.showReferenceLineAtZero.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showReferenceLineAtZero.description`},{key:`showDataLabels`,label:`chart.option.showDataLabels.label`,type:`boolean`,defaultValue:!1,description:`chart.configText.display_value_at_each_data_point`},{key:`showLegend`,label:`chart.option.showLegend.label`,type:`boolean`,defaultValue:!0,description:`chart.configText.show_series_legend_only_visible_with_a_series_dimension`},{key:`lineType`,label:`chart.option.lineType.label`,type:`select`,defaultValue:`monotone`,options:[{value:`monotone`,label:`chart.option.lineType.smooth`},{value:`linear`,label:`chart.option.lineType.linear`},{value:`step`,label:`chart.option.lineType.step`}],description:`chart.option.lineType.description`},{key:`leftYAxisFormat`,label:`chart.option.yAxisFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_the_y_axis`}]},gauge:{label:`chart.gauge.label`,description:`chart.gauge.description`,useCase:`chart.gauge.useCase`,clickableElements:{},displayOptions:[`hideHeader`],dropZones:[{key:`yAxis`,label:`chart.configText.value_measure`,description:`chart.configText.current_value_to_display_on_the_gauge_e_g_current_equity_margin_used`,mandatory:!0,maxItems:2,acceptTypes:[`measure`],emptyText:`chart.gauge.dropZone.yAxis.empty`}],displayOptionsConfig:[{key:`minValue`,label:`chart.option.minValue.label`,type:`number`,defaultValue:0,description:`chart.option.minValue.description`},{key:`maxValue`,label:`chart.option.maxValue.label`,type:`number`,description:`chart.option.maxValue.description`},{key:`thresholds`,label:`chart.configText.threshold_bands`,type:`string`,placeholder:`[{"value":0.33,"color":"#22c55e"},{"value":0.66,"color":"#f59e0b"},{"value":1,"color":"#ef4444"}]`,description:`chart.configText.array_of_value_0_1_fraction_color_bands_shown_as_outer_arc_markers`},{key:`showCenterLabel`,label:`chart.option.showCentreLabel.label`,type:`boolean`,defaultValue:!0,description:`chart.option.showCentreLabel.description`},{key:`showPercentage`,label:`chart.option.showPercentage.label`,type:`boolean`,defaultValue:!1,description:`chart.option.showPercentage.description`},{key:`leftYAxisFormat`,label:`chart.option.valueFormat.label`,type:`axisFormat`,description:`chart.configText.number_formatting_for_the_displayed_value_and_axis_labels`}]}};function a(t,n,r){let a=i[t];if(!a||a.skipQuery)return{isValid:!0,errors:[]};let o=[];for(let r of a.dropZones){if(!r.mandatory)continue;let i=n?.[r.key];if(!(Array.isArray(i)?i.length>0:i)){let n=r.acceptTypes?.join(`/`)??`fields`;o.push(e.C(`server.validation.chart.dropZoneRequired`,{key:r.key,chartType:t,label:r.label,acceptDesc:n}))}}if(t===`bar`){let t=n?.xAxis;if(!(Array.isArray(t)?t.length>0:t)){let t=r.dimensions??[],n=r.timeDimensions??[];t.length>0||n.length>0?o.push(e.C(`server.validation.chart.barXAxisRequired`)):o.push(e.C(`server.validation.chart.barNeedsDimension`))}}if(n?.xAxis&&n?.series){let t=new Set(Array.isArray(n.xAxis)?n.xAxis:[n.xAxis]),r=(Array.isArray(n.series)?n.series:[n.series]).filter(e=>t.has(e));r.length>0&&o.push(e.C(`server.validation.chart.seriesDuplicatesXAxis`,{duplicates:r.join(`, `)}))}return{isValid:o.length===0,errors:o}}function o(e,t,n){let r=i[e];if(!r)return t??{};let a={...t},o=n.measures??[],s=n.dimensions??[],c=(n.timeDimensions??[]).map(e=>e.dimension);for(let e of r.dropZones){let t=a[e.key];if(Array.isArray(t)?t.length>0:t)continue;let n=e.acceptTypes??[];if(e.key===`sizeField`||e.key===`colorField`){if(n.includes(`measure`)){let t=new Set;for(let n of r.dropZones){if(n.key===e.key)continue;let r=a[n.key];Array.isArray(r)?r.forEach(e=>t.add(e)):typeof r==`string`&&t.add(r)}let n=o.filter(e=>!t.has(e));n.length>0&&(a[e.key]=n[0])}continue}let i=[];if(n.includes(`dimension`)&&i.push(...s),n.includes(`timeDimension`)&&i.push(...c),n.includes(`measure`)&&i.push(...o),i.length===0)continue;let l=i;if(e.key===`series`){let e=new Set(Array.isArray(a.xAxis)?a.xAxis:a.xAxis?[a.xAxis]:[]);if(l=i.filter(t=>!e.has(t)),l.length===0)continue}let u=e.maxItems??1/0,d=l.slice(0,u);d.length>0&&(a[e.key]=d)}return a}function s(e){let t=[`
16
+ Chart config requirements by type:`];for(let n of e){let e=i[n];if(!e)continue;let r=[e.description??``,e.useCase??``].filter(Boolean).join(`. `),a=r?` — ${r}.`:``,o=e.dropZones.filter(e=>e.mandatory);if(o.length===0&&!e.skipQuery){t.push(` ${n}${a} chartConfig auto-inferred from query.`);continue}if(e.skipQuery){t.push(` ${n}${a} No query needed.`);continue}let s=o.map(e=>{let t=e.acceptTypes?.join(`/`)??`any`,n=e.maxItems?` (max ${e.maxItems})`:``;return`${e.key}=[${t}]${n}`});t.push(` ${n}${a} Requires ${s.join(`, `)}.`)}return t.join(`
17
+ `)}var c=[`bar`,`line`,`area`,`pie`,`scatter`,`radar`,`bubble`,`table`,`kpiNumber`,`kpiDelta`,`funnel`,`heatmap`,`sankey`,`sunburst`,`retentionHeatmap`,`retentionCombined`,`boxPlot`,`markdown`];function l(){return[{name:`discover_cubes`,description:`Search for available data cubes by topic or intent. Call this FIRST to understand what data is available. Returns cube names, measures, dimensions, and relationships.`,parameters:{type:`object`,properties:{topic:{type:`string`,description:`Keyword to search (e.g., "sales", "employees")`},intent:{type:`string`,description:`Natural language goal (e.g., "analyze productivity trends")`},limit:{type:`number`,description:`Max results (default: 10)`},minScore:{type:`number`,description:`Min relevance 0-1 (default: 0.1)`}}}},{name:`get_cube_metadata`,description:`Get full metadata for all registered cubes including all measures, dimensions, types, and relationships. Use this for detailed schema information.`,parameters:{type:`object`,properties:{}}},{name:`execute_query`,description:`Execute a semantic query and return data results. Supports standard queries (measures/dimensions) and analysis modes (funnel/flow/retention). Only provide ONE mode per call.`,parameters:{type:`object`,properties:e.S}},{name:`add_portlet`,description:`Add a chart visualization to the notebook.
18
+ `+s(c)+`
19
+ The query is validated before adding. The portlet fetches its own data.`,parameters:{type:`object`,properties:{title:{type:`string`,description:`Title for the visualization`},query:{type:`string`,description:`JSON string of the query. Standard: {"measures":[...],"dimensions":[...]}. Funnel: {"funnel":{"bindingKey":"...","timeDimension":"...","steps":[...]}}. Flow: {"flow":{"bindingKey":"...","timeDimension":"...","eventDimension":"...","startingStep":{...}}}. Retention: {"retention":{"timeDimension":"...","bindingKey":"...","dateRange":{"start":"...","end":"..."},"granularity":"...","periods":N}}.`},chartType:{type:`string`,enum:c,description:`Chart type to render`},chartConfig:{type:`object`,properties:{xAxis:{type:`array`,items:{type:`string`}},yAxis:{type:`array`,items:{type:`string`}},series:{type:`array`,items:{type:`string`}},sizeField:{type:`string`},colorField:{type:`string`},yAxisAssignment:{type:`object`,description:`Dual Y-axis: map measure fields to "left" or "right" axis. Only for bar, line, area charts with 2+ measures of different scales. Example: {"Sales.revenue": "left", "Sales.conversionRate": "right"}`}},description:`Chart axis configuration`},displayConfig:{type:`object`,properties:{showLegend:{type:`boolean`},showGrid:{type:`boolean`},showTooltip:{type:`boolean`},stacked:{type:`boolean`},orientation:{type:`string`,enum:[`horizontal`,`vertical`]}},description:`Chart display configuration`}},required:[`title`,`query`,`chartType`]}},{name:`add_markdown`,description:`Add an explanation or analysis text block to the notebook. Use markdown formatting. Use this to explain findings, methodology, and insights alongside visualizations.`,parameters:{type:`object`,properties:{title:{type:`string`,description:`Optional title for the text block`},content:{type:`string`,description:`Markdown content to display`}},required:[`content`]}},{name:`save_as_dashboard`,description:`Convert the current notebook analysis into a persistent dashboard. Constructs a professional DashboardConfig with proper grid layout, section headers (markdown portlets), and dashboard-level filters. Call this when the user asks to save/export the notebook as a dashboard.`,parameters:{type:`object`,properties:{title:{type:`string`,description:`Dashboard title`},description:{type:`string`,description:`Optional dashboard description`},portlets:{type:`array`,items:{type:`object`,properties:{id:{type:`string`,description:`Unique portlet ID`},title:{type:`string`,description:`Portlet title`},chartType:{type:`string`,enum:c,description:`Chart type. Use "markdown" for section headers.`},query:{type:`string`,description:`JSON string of the query. Omit or leave empty for markdown portlets.`},chartConfig:{type:`object`,properties:{xAxis:{type:`array`,items:{type:`string`}},yAxis:{type:`array`,items:{type:`string`}},series:{type:`array`,items:{type:`string`}},sizeField:{type:`string`},colorField:{type:`string`}},description:`Chart axis configuration`},displayConfig:{type:`object`,description:`Chart display configuration (for markdown: { content, hideHeader, transparentBackground, autoHeight })`},dashboardFilterMapping:{type:`array`,items:{type:`string`},description:`Array of dashboard filter IDs that apply to this portlet`},analysisType:{type:`string`,enum:[`query`,`funnel`,`flow`,`retention`],description:`Analysis type (default: "query")`},w:{type:`number`,description:`Grid width (1-12)`},h:{type:`number`,description:`Grid height in row units`},x:{type:`number`,description:`Grid x position (0-11)`},y:{type:`number`,description:`Grid y position`}},required:[`id`,`title`,`chartType`,`w`,`h`,`x`,`y`]},description:`Array of portlet configurations for the dashboard`},filters:{type:`array`,items:{type:`object`,properties:{id:{type:`string`,description:`Unique filter ID`},label:{type:`string`,description:`Display label for the filter`},filter:{type:`object`,properties:{member:{type:`string`},operator:{type:`string`},values:{type:`array`,items:{}}},required:[`member`,`operator`],description:`The filter definition`},isUniversalTime:{type:`boolean`,description:`When true, applies to all time dimensions in portlets`}},required:[`id`,`label`,`filter`]},description:`Dashboard-level filters`},colorPalette:{type:`string`,description:`Color palette name`}},required:[`title`,`portlets`]}}]}function u(t){let{semanticLayer:n,securityContext:r}=t,i=new Map;i.set(`discover_cubes`,async t=>{let r={cubes:(await e.d(n,{topic:t.topic,intent:t.intent,limit:t.limit,minScore:t.minScore})).cubes.map(e=>({cube:e.cube,title:e.title,description:e.description,relevanceScore:e.relevanceScore,suggestedMeasures:e.suggestedMeasures,suggestedDimensions:e.suggestedDimensions,capabilities:e.capabilities,...e.capabilities.funnel||e.capabilities.flow||e.capabilities.retention?{analysisConfig:{candidateBindingKeys:e.analysisConfig?.candidateBindingKeys?.map(e=>e.dimension)??[],candidateTimeDimensions:e.analysisConfig?.candidateTimeDimensions?.map(e=>e.dimension)??[],...e.analysisConfig?.candidateEventDimensions?.length?{candidateEventDimensions:e.analysisConfig.candidateEventDimensions.map(e=>e.dimension)}:{}}}:{}}))};return{result:JSON.stringify(r)+`
20
+ [IMPORTANT: Your next response MUST start with a brief text message BEFORE any tool calls.]`}}),i.set(`get_cube_metadata`,async()=>{let e=n.getMetadata();return{result:JSON.stringify(e)}});let s=new Map;for(let e of n.getMetadata())s.set(e.name,{measures:(e.measures||[]).map(e=>e.name),dimensions:(e.dimensions||[]).map(e=>e.name)});let c=(e,t)=>{let n=s.get(e),r=t===`measures`?n?.measures:n?.dimensions;return!r||r.length===0?``:` Available ${t}: ${r.slice(0,5).map(e=>`"${e}"`).join(`, `)}`};return i.set(`execute_query`,async t=>{try{let i=(e,t)=>{if(!Array.isArray(e))return;let n=[];for(let r of e){if(typeof r!=`string`)continue;let e=r.split(`.`);e.length===1?n.push(`"${r}" is not valid — must be "CubeName.fieldName".${c(r,t)}`):e.length===2&&e[0]===e[1]&&n.push(`"${r}" is WRONG — "${e[0]}" is the cube name, not a ${t.replace(/s$/,``)}.${c(e[0],t)}`)}if(n.length>0)throw Error(`Invalid ${t}:\n${n.join(`
21
21
  `)}`)};i(t.measures,`measures`),i(t.dimensions,`dimensions`);let a;a=t.funnel?{funnel:t.funnel}:t.flow?{flow:t.flow}:t.retention?{retention:t.retention}:{measures:t.measures,dimensions:t.dimensions,filters:t.filters,timeDimensions:t.timeDimensions,order:t.order,limit:t.limit,offset:t.offset,ungrouped:t.ungrouped};let o=await e.p(n,r,{query:a});return{result:JSON.stringify({rowCount:o.data.length,data:o.data,annotation:o.annotation})+`
22
- [IMPORTANT: Your next response MUST start with a brief text message BEFORE any tool calls. Now call add_markdown and add_portlet to visualize these results.]`}}catch(e){let n={measures:t.measures,dimensions:t.dimensions,filters:t.filters,timeDimensions:t.timeDimensions,order:t.order,limit:t.limit,...t.funnel?{funnel:t.funnel}:{},...t.flow?{flow:t.flow}:{},...t.retention?{retention:t.retention}:{}};return{result:`Query execution failed: ${e instanceof Error?e.message:`Unknown error`}\n\nAttempted query:\n${JSON.stringify(n,null,2)}`,isError:!0}}}),i.set(`add_portlet`,async t=>{let r={number:`kpiNumber`,retention:`retentionHeatmap`}[t.chartType]??t.chartType,i;try{i=JSON.parse(t.query)}catch{return{result:"Invalid query: could not parse JSON string. Ensure `query` is a valid JSON string.",isError:!0}}i=e.g(i);let a=n.validateQuery(i);if(!a.isValid)return{result:`Invalid query — fix these errors and retry:\n${a.errors.join(`
23
- `)}\n\nAttempted query:\n${JSON.stringify(i,null,2)}`,isError:!0};let c=!!(i.funnel||i.flow||i.retention),l;if(c)l=t.chartConfig??{};else{let e=s(r,t.chartConfig,i),n=o(r,e,i);if(!n.isValid)return{result:`Chart config invalid — fix these errors and retry:\n${n.errors.join(`
22
+ [IMPORTANT: Your next response MUST start with a brief text message BEFORE any tool calls. Now call add_markdown and add_portlet to visualize these results.]`}}catch(e){let n={measures:t.measures,dimensions:t.dimensions,filters:t.filters,timeDimensions:t.timeDimensions,order:t.order,limit:t.limit,...t.funnel?{funnel:t.funnel}:{},...t.flow?{flow:t.flow}:{},...t.retention?{retention:t.retention}:{}};return{result:`Query execution failed: ${e instanceof Error?e.message:`Unknown error`}\n\nAttempted query:\n${JSON.stringify(n,null,2)}`,isError:!0}}}),i.set(`add_portlet`,async t=>{let r={number:`kpiNumber`,retention:`retentionHeatmap`}[t.chartType]??t.chartType,i;try{i=JSON.parse(t.query)}catch{return{result:"Invalid query: could not parse JSON string. Ensure `query` is a valid JSON string.",isError:!0}}i=e.g(i);let s=n.validateQuery(i);if(!s.isValid)return{result:`Invalid query — fix these errors and retry:\n${s.errors.join(`
23
+ `)}\n\nAttempted query:\n${JSON.stringify(i,null,2)}`,isError:!0};let c=!!(i.funnel||i.flow||i.retention),l;if(c)l=t.chartConfig??{};else{let e=o(r,t.chartConfig,i),n=a(r,e,i);if(!n.isValid)return{result:`Chart config invalid — fix these errors and retry:\n${n.errors.join(`
24
24
  `)}`,isError:!0};l=e}let u=`portlet-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,d={id:u,title:t.title,query:t.query,chartType:r,chartConfig:l,displayConfig:t.displayConfig};return{result:`Portlet "${t.title}" added to notebook (id: ${u}, chart: ${r}). [Reminder: in your next response, start with a brief sentence about what you will do next BEFORE making any tool calls.]`,sideEffect:{type:`add_portlet`,data:d}}}),i.set(`add_markdown`,async e=>{let t=`markdown-${Date.now()}-${Math.random().toString(36).slice(2,7)}`,n=e.content||e.text||e.markdown||``,r={id:t,title:e.title,content:n};return{result:`Markdown block added to notebook (id: ${t}). [Reminder: in your next response, start with a brief sentence about what you will do next BEFORE making any tool calls.]`,sideEffect:{type:`add_markdown`,data:r}}}),i.set(`save_as_dashboard`,async t=>{try{let r=t.portlets;if(!r||r.length===0)return{result:`Dashboard must contain at least one portlet.`,isError:!0};let i=[];for(let t of r){if(t.chartType===`markdown`)continue;let r=t.query;if(!r){i.push(`Portlet "${t.title}": missing query`);continue}let a;try{a=JSON.parse(r)}catch{i.push(`Portlet "${t.title}": invalid JSON query`);continue}a=e.g(a);let o=n.validateQuery(a);o.isValid||i.push(`Portlet "${t.title}": ${o.errors.join(`, `)}`)}if(i.length>0)return{result:`Dashboard has invalid portlets — fix these errors and retry:\n${i.join(`
25
- `)}`,isError:!0};let a={portlets:r.map(e=>{let t=e.chartType,n=t===`markdown`,r=n?`query`:e.analysisType||`query`,i=r===`funnel`?`funnel`:r===`flow`?`flow`:r===`retention`?`retention`:`query`,a=e.query||`{}`,o;try{o=JSON.parse(a)}catch{o={}}let s={version:1,analysisType:i,activeView:`chart`,charts:{[i]:{chartType:t,chartConfig:e.chartConfig||{},displayConfig:e.displayConfig||{}}},query:n?{}:o};return{id:e.id,title:e.title,analysisConfig:s,dashboardFilterMapping:e.dashboardFilterMapping,w:e.w,h:e.h,x:e.x,y:e.y}}),filters:t.filters,colorPalette:t.colorPalette},o=t.title;return{result:`Dashboard "${o}" created with ${a.portlets.length} portlets and ${a.filters?.length||0} filters.`,sideEffect:{type:`dashboard_saved`,data:{title:o,description:t.description,dashboardConfig:a}}}}catch(e){return{result:`Failed to save dashboard: ${e instanceof Error?e.message:`Unknown error`}`,isError:!0}}}),i}async function f(e,t,n){switch(e){case`anthropic`:{let{AnthropicProvider:e}=await Promise.resolve().then(()=>require(`./anthropic-Cto4Jxqt.cjs`));return new e(t)}case`openai`:{let{OpenAIProvider:e}=await Promise.resolve().then(()=>require(`./openai-B4N3KfTG.cjs`));return new e(t,n)}case`google`:{let{GoogleProvider:e}=await Promise.resolve().then(()=>require(`./google-BOAwi9Ib.cjs`));return new e(t)}default:throw Error(`Unknown LLM provider: "${e}". Supported providers: anthropic, openai, google`)}}var p={anthropic:`claude-sonnet-4-6`,openai:`gpt-4.1-mini`,google:`gemini-3-flash-preview`};async function*m(t){let{message:n,history:r,semanticLayer:a,securityContext:o,agentConfig:s,apiKey:c}=t,l=t.sessionId||crypto.randomUUID(),m=s.observability,h=crypto.randomUUID(),g=Date.now(),_=t.providerOverride||s.provider||`anthropic`,v=t.modelOverride||s.model||p[_]||`claude-sonnet-4-6`,y=t.baseURLOverride||s.baseURL,b=s.maxTurns||25,x=s.maxTokens||4096,S;try{S=await f(_,c,{baseURL:y})}catch(t){console.error(`[agent] Failed to create %s provider: %s`,String(_).replace(/\n|\r/g,``),String(t instanceof Error?t.message:t).replace(/\n|\r/g,``)),yield{type:`error`,data:{message:t instanceof Error?t.message:e._(`server.errors.llmInitFailed`)}};return}let C=u(),w=d({semanticLayer:a,securityContext:o}),T=i(a.getMetadata());t.systemContext&&(T+=`\n\n## User Context\n\n${t.systemContext}`);try{m?.onChatStart?.({traceId:h,sessionId:l,message:n,model:v,historyLength:r?.length??0})}catch{}let E=[];if(r&&r.length>0){for(let e of r)if(e.role===`user`)E.push({role:`user`,content:e.content});else if(e.role===`assistant`){let t=[];if(e.content&&t.push({type:`text`,text:e.content}),e.toolCalls&&e.toolCalls.length>0){for(let n of e.toolCalls)t.push({type:`tool_use`,id:n.id,name:n.name,input:n.input||{}});E.push({role:`assistant`,content:t});let n=e.toolCalls.map(e=>({toolUseId:e.id,toolName:e.name,content:typeof e.result==`string`?e.result:JSON.stringify(e.result??``),isError:e.status===`error`})),r=S.formatToolResults(n);if(Array.isArray(r))for(let e of r)E.push(e);else E.push(r)}else t.length>0&&E.push({role:`assistant`,content:e.content})}}E.push({role:`user`,content:n});let D=0;try{for(let e=0;e<b;e++){D=e+1;let t=await S.createStream({model:v,maxTokens:x,system:T,tools:C,messages:E}),n=[],r=``,i=``,a,o,s=Date.now(),c=!1;for await(let e of S.parseStreamEvents(t)){let t=e;switch(t.type){case`text_delta`:{let e=n[n.length-1];e&&e.type===`text`?e.text=(e.text||``)+t.text:n.push({type:`text`,text:t.text}),yield{type:`text_delta`,data:t.text};break}case`tool_use_start`:if(c&&r){let e=n[n.length-1];if(e?.type===`tool_use`)try{e.input=JSON.parse(r)}catch{}}n.push({type:`tool_use`,id:t.id,name:t.name,input:{},...t.metadata?{metadata:t.metadata}:{}}),r=``,c=!0,yield{type:`tool_use_start`,data:{id:t.id,name:t.name,input:void 0}};break;case`tool_input_delta`:r+=t.json;break;case`tool_use_end`:if(t.id&&t.input){let e=n.find(e=>e.type===`tool_use`&&e.id===t.id);e&&(e.input=t.input)}else if(c){let e=n[n.length-1];if(e?.type===`tool_use`&&r){try{e.input=JSON.parse(r)}catch{e.input={}}r=``}c=!1}break;case`message_meta`:t.inputTokens!=null&&(a=t.inputTokens),t.outputTokens!=null&&(o=t.outputTokens),t.stopReason&&(i=t.stopReason);break}}try{m?.onGenerationEnd?.({traceId:h,turn:e,model:v,stopReason:i,inputTokens:a,outputTokens:o,durationMs:Date.now()-s,input:E,output:n})}catch{}if(E.push({role:`assistant`,content:n}),!S.shouldContinue(i))break;let l=[];for(let t of n){if(t.type!==`tool_use`)continue;let n=t.name,r=t.input||{},i=t.id,a=w.get(n);if(!a){l.push({toolUseId:i,toolName:n,content:`Unknown tool: ${n}`,isError:!0}),yield{type:`tool_use_result`,data:{id:i,name:n,result:`Unknown tool: ${n}`,isError:!0}};continue}let o=Date.now();try{let t=await a(r);t.sideEffect&&(yield t.sideEffect),l.push({toolUseId:i,toolName:n,content:t.result,...t.isError?{isError:!0}:{}}),yield{type:`tool_use_result`,data:{id:i,name:n,result:t.result,...t.isError?{isError:!0}:{}}};try{m?.onToolEnd?.({traceId:h,turn:e,toolName:n,toolUseId:i,isError:!!t.isError,durationMs:Date.now()-o})}catch{}}catch(t){let r=t instanceof Error?t.message:`Tool execution failed`;l.push({toolUseId:i,toolName:n,content:r,isError:!0}),yield{type:`tool_use_result`,data:{id:i,name:n,result:r,isError:!0}};try{m?.onToolEnd?.({traceId:h,turn:e,toolName:n,toolUseId:i,isError:!0,durationMs:Date.now()-o})}catch{}}}yield{type:`turn_complete`,data:{}};let u=S.formatToolResults(l);if(Array.isArray(u))for(let e of u)E.push(e);else E.push(u)}try{m?.onChatEnd?.({traceId:h,sessionId:l,totalTurns:D,durationMs:Date.now()-g})}catch{}yield{type:`done`,data:{sessionId:l||``,traceId:h}}}catch(e){try{m?.onChatEnd?.({traceId:h,sessionId:l,totalTurns:0,durationMs:Date.now()-g,error:e instanceof Error?e.message:`Unknown error`})}catch{}console.error(`[agent] Chat error (provider=%s, model=%s): %s`,String(_).replace(/\n|\r/g,``),String(v).replace(/\n|\r/g,``),String(e instanceof Error?e.message:e).replace(/\n|\r/g,``)),yield{type:`error`,data:{message:S.formatError(e)}}}}exports.handleAgentChat=m;
25
+ `)}`,isError:!0};let a={portlets:r.map(e=>{let t=e.chartType,n=t===`markdown`,r=n?`query`:e.analysisType||`query`,i=r===`funnel`?`funnel`:r===`flow`?`flow`:r===`retention`?`retention`:`query`,a=e.query||`{}`,o;try{o=JSON.parse(a)}catch{o={}}let s={version:1,analysisType:i,activeView:`chart`,charts:{[i]:{chartType:t,chartConfig:e.chartConfig||{},displayConfig:e.displayConfig||{}}},query:n?{}:o};return{id:e.id,title:e.title,analysisConfig:s,dashboardFilterMapping:e.dashboardFilterMapping,w:e.w,h:e.h,x:e.x,y:e.y}}),filters:t.filters,colorPalette:t.colorPalette},o=t.title;return{result:`Dashboard "${o}" created with ${a.portlets.length} portlets and ${a.filters?.length||0} filters.`,sideEffect:{type:`dashboard_saved`,data:{title:o,description:t.description,dashboardConfig:a}}}}catch(e){return{result:`Failed to save dashboard: ${e instanceof Error?e.message:`Unknown error`}`,isError:!0}}}),i}async function d(e,t,n){switch(e){case`anthropic`:{let{AnthropicProvider:e}=await Promise.resolve().then(()=>require(`./anthropic-BIva8k1r.cjs`));return new e(t)}case`openai`:{let{OpenAIProvider:e}=await Promise.resolve().then(()=>require(`./openai-BjLV_Wjx.cjs`));return new e(t,n)}case`google`:{let{GoogleProvider:e}=await Promise.resolve().then(()=>require(`./google-Dgo9-Kb5.cjs`));return new e(t)}default:throw Error(`Unknown LLM provider: "${e}". Supported providers: anthropic, openai, google`)}}var f={anthropic:`claude-sonnet-4-6`,openai:`gpt-4.1-mini`,google:`gemini-3-flash-preview`};async function*p(t){let{message:n,history:i,semanticLayer:a,securityContext:o,agentConfig:s,apiKey:c}=t,p=t.sessionId||crypto.randomUUID(),m=s.observability,h=crypto.randomUUID(),g=Date.now(),_=t.providerOverride||s.provider||`anthropic`,v=t.modelOverride||s.model||f[_]||`claude-sonnet-4-6`,y=t.baseURLOverride||s.baseURL,b=s.maxTurns||25,x=s.maxTokens||4096,S;try{S=await d(_,c,{baseURL:y})}catch(t){console.error(`[agent] Failed to create %s provider: %s`,String(_).replace(/\n|\r/g,``),String(t instanceof Error?t.message:t).replace(/\n|\r/g,``)),yield{type:`error`,data:{message:t instanceof Error?t.message:e.C(`server.errors.llmInitFailed`)}};return}let C=l(),w=u({semanticLayer:a,securityContext:o}),T=r(a.getMetadata());t.systemContext&&(T+=`\n\n## User Context\n\n${t.systemContext}`);try{m?.onChatStart?.({traceId:h,sessionId:p,message:n,model:v,historyLength:i?.length??0})}catch{}let E=[];if(i&&i.length>0){for(let e of i)if(e.role===`user`)E.push({role:`user`,content:e.content});else if(e.role===`assistant`){let t=[];if(e.content&&t.push({type:`text`,text:e.content}),e.toolCalls&&e.toolCalls.length>0){for(let n of e.toolCalls)t.push({type:`tool_use`,id:n.id,name:n.name,input:n.input||{}});E.push({role:`assistant`,content:t});let n=e.toolCalls.map(e=>({toolUseId:e.id,toolName:e.name,content:typeof e.result==`string`?e.result:JSON.stringify(e.result??``),isError:e.status===`error`})),r=S.formatToolResults(n);if(Array.isArray(r))for(let e of r)E.push(e);else E.push(r)}else t.length>0&&E.push({role:`assistant`,content:e.content})}}E.push({role:`user`,content:n});let D=0;try{for(let e=0;e<b;e++){D=e+1;let t=await S.createStream({model:v,maxTokens:x,system:T,tools:C,messages:E}),n=[],r=``,i=``,a,o,s=Date.now(),c=!1;for await(let e of S.parseStreamEvents(t)){let t=e;switch(t.type){case`text_delta`:{let e=n[n.length-1];e&&e.type===`text`?e.text=(e.text||``)+t.text:n.push({type:`text`,text:t.text}),yield{type:`text_delta`,data:t.text};break}case`tool_use_start`:if(c&&r){let e=n[n.length-1];if(e?.type===`tool_use`)try{e.input=JSON.parse(r)}catch{}}n.push({type:`tool_use`,id:t.id,name:t.name,input:{},...t.metadata?{metadata:t.metadata}:{}}),r=``,c=!0,yield{type:`tool_use_start`,data:{id:t.id,name:t.name,input:void 0}};break;case`tool_input_delta`:r+=t.json;break;case`tool_use_end`:if(t.id&&t.input){let e=n.find(e=>e.type===`tool_use`&&e.id===t.id);e&&(e.input=t.input)}else if(c){let e=n[n.length-1];if(e?.type===`tool_use`&&r){try{e.input=JSON.parse(r)}catch{e.input={}}r=``}c=!1}break;case`message_meta`:t.inputTokens!=null&&(a=t.inputTokens),t.outputTokens!=null&&(o=t.outputTokens),t.stopReason&&(i=t.stopReason);break}}try{m?.onGenerationEnd?.({traceId:h,turn:e,model:v,stopReason:i,inputTokens:a,outputTokens:o,durationMs:Date.now()-s,input:E,output:n})}catch{}if(E.push({role:`assistant`,content:n}),!S.shouldContinue(i))break;let l=[];for(let t of n){if(t.type!==`tool_use`)continue;let n=t.name,r=t.input||{},i=t.id,a=w.get(n);if(!a){l.push({toolUseId:i,toolName:n,content:`Unknown tool: ${n}`,isError:!0}),yield{type:`tool_use_result`,data:{id:i,name:n,result:`Unknown tool: ${n}`,isError:!0}};continue}let o=Date.now();try{let t=await a(r);t.sideEffect&&(yield t.sideEffect),l.push({toolUseId:i,toolName:n,content:t.result,...t.isError?{isError:!0}:{}}),yield{type:`tool_use_result`,data:{id:i,name:n,result:t.result,...t.isError?{isError:!0}:{}}};try{m?.onToolEnd?.({traceId:h,turn:e,toolName:n,toolUseId:i,isError:!!t.isError,durationMs:Date.now()-o})}catch{}}catch(t){let r=t instanceof Error?t.message:`Tool execution failed`;l.push({toolUseId:i,toolName:n,content:r,isError:!0}),yield{type:`tool_use_result`,data:{id:i,name:n,result:r,isError:!0}};try{m?.onToolEnd?.({traceId:h,turn:e,toolName:n,toolUseId:i,isError:!0,durationMs:Date.now()-o})}catch{}}}yield{type:`turn_complete`,data:{}};let u=S.formatToolResults(l);if(Array.isArray(u))for(let e of u)E.push(e);else E.push(u)}try{m?.onChatEnd?.({traceId:h,sessionId:p,totalTurns:D,durationMs:Date.now()-g})}catch{}yield{type:`done`,data:{sessionId:p||``,traceId:h}}}catch(e){try{m?.onChatEnd?.({traceId:h,sessionId:p,totalTurns:0,durationMs:Date.now()-g,error:e instanceof Error?e.message:`Unknown error`})}catch{}console.error(`[agent] Chat error (provider=%s, model=%s): %s`,String(_).replace(/\n|\r/g,``),String(v).replace(/\n|\r/g,``),String(e instanceof Error?e.message:e).replace(/\n|\r/g,``)),yield{type:`error`,data:{message:S.formatError(e)}}}}exports.handleAgentChat=p;
@@ -1,5 +1,4 @@
1
- import { _ as e, d as t, g as n, p as r } from "./utils-CTYvfZ3I.js";
2
- import { a as i, n as a, r as o, t as s } from "./mcp-prompts-BUFyQLHQ.js";
1
+ import { C as e, S as t, _ as n, d as r, g as i, p as a, v as o, y as s } from "./utils-DG8ti3FT.js";
3
2
  //#region src/server/agent/system-prompt.ts
4
3
  function c(e) {
5
4
  if (e.length === 0) return "No cubes are currently available.";
@@ -171,15 +170,15 @@ function u(e) {
171
170
  "",
172
171
  "---",
173
172
  "",
174
- l(a),
173
+ l(o),
175
174
  "",
176
175
  "---",
177
176
  "",
178
- l(o),
177
+ l(s),
179
178
  "",
180
179
  "---",
181
180
  "",
182
- l(s),
181
+ l(n),
183
182
  "",
184
183
  "---",
185
184
  "",
@@ -1974,7 +1973,7 @@ function g() {
1974
1973
  description: "Execute a semantic query and return data results. Supports standard queries (measures/dimensions) and analysis modes (funnel/flow/retention). Only provide ONE mode per call.",
1975
1974
  parameters: {
1976
1975
  type: "object",
1977
- properties: i
1976
+ properties: t
1978
1977
  }
1979
1978
  },
1980
1979
  {
@@ -2214,9 +2213,9 @@ function g() {
2214
2213
  ];
2215
2214
  }
2216
2215
  function _(e) {
2217
- let { semanticLayer: i, securityContext: a } = e, o = /* @__PURE__ */ new Map();
2216
+ let { semanticLayer: t, securityContext: n } = e, o = /* @__PURE__ */ new Map();
2218
2217
  o.set("discover_cubes", async (e) => {
2219
- let n = { cubes: (await t(i, {
2218
+ let n = { cubes: (await r(t, {
2220
2219
  topic: e.topic,
2221
2220
  intent: e.intent,
2222
2221
  limit: e.limit,
@@ -2237,11 +2236,11 @@ function _(e) {
2237
2236
  })) };
2238
2237
  return { result: JSON.stringify(n) + "\n[IMPORTANT: Your next response MUST start with a brief text message BEFORE any tool calls.]" };
2239
2238
  }), o.set("get_cube_metadata", async () => {
2240
- let e = i.getMetadata();
2239
+ let e = t.getMetadata();
2241
2240
  return { result: JSON.stringify(e) };
2242
2241
  });
2243
2242
  let s = /* @__PURE__ */ new Map();
2244
- for (let e of i.getMetadata()) s.set(e.name, {
2243
+ for (let e of t.getMetadata()) s.set(e.name, {
2245
2244
  measures: (e.measures || []).map((e) => e.name),
2246
2245
  dimensions: (e.dimensions || []).map((e) => e.name)
2247
2246
  });
@@ -2251,7 +2250,7 @@ function _(e) {
2251
2250
  };
2252
2251
  return o.set("execute_query", async (e) => {
2253
2252
  try {
2254
- let t = (e, t) => {
2253
+ let r = (e, t) => {
2255
2254
  if (!Array.isArray(e)) return;
2256
2255
  let n = [];
2257
2256
  for (let r of e) {
@@ -2261,9 +2260,9 @@ function _(e) {
2261
2260
  }
2262
2261
  if (n.length > 0) throw Error(`Invalid ${t}:\n${n.join("\n")}`);
2263
2262
  };
2264
- t(e.measures, "measures"), t(e.dimensions, "dimensions");
2265
- let n;
2266
- n = e.funnel ? { funnel: e.funnel } : e.flow ? { flow: e.flow } : e.retention ? { retention: e.retention } : {
2263
+ r(e.measures, "measures"), r(e.dimensions, "dimensions");
2264
+ let i;
2265
+ i = e.funnel ? { funnel: e.funnel } : e.flow ? { flow: e.flow } : e.retention ? { retention: e.retention } : {
2267
2266
  measures: e.measures,
2268
2267
  dimensions: e.dimensions,
2269
2268
  filters: e.filters,
@@ -2273,7 +2272,7 @@ function _(e) {
2273
2272
  offset: e.offset,
2274
2273
  ungrouped: e.ungrouped
2275
2274
  };
2276
- let o = await r(i, a, { query: n });
2275
+ let o = await a(t, n, { query: i });
2277
2276
  return { result: JSON.stringify({
2278
2277
  rowCount: o.data.length,
2279
2278
  data: o.data,
@@ -2297,7 +2296,7 @@ function _(e) {
2297
2296
  };
2298
2297
  }
2299
2298
  }), o.set("add_portlet", async (e) => {
2300
- let t = {
2299
+ let n = {
2301
2300
  number: "kpiNumber",
2302
2301
  retention: "retentionHeatmap"
2303
2302
  }[e.chartType] ?? e.chartType, r;
@@ -2309,8 +2308,8 @@ function _(e) {
2309
2308
  isError: !0
2310
2309
  };
2311
2310
  }
2312
- r = n(r);
2313
- let a = i.validateQuery(r);
2311
+ r = i(r);
2312
+ let a = t.validateQuery(r);
2314
2313
  if (!a.isValid) return {
2315
2314
  result: `Invalid query — fix these errors and retry:\n${a.errors.join("\n")}\n\nAttempted query:\n${JSON.stringify(r, null, 2)}`,
2316
2315
  isError: !0
@@ -2318,23 +2317,23 @@ function _(e) {
2318
2317
  let o = !!(r.funnel || r.flow || r.retention), s;
2319
2318
  if (o) s = e.chartConfig ?? {};
2320
2319
  else {
2321
- let n = p(t, e.chartConfig, r), i = f(t, n, r);
2320
+ let t = p(n, e.chartConfig, r), i = f(n, t, r);
2322
2321
  if (!i.isValid) return {
2323
2322
  result: `Chart config invalid — fix these errors and retry:\n${i.errors.join("\n")}`,
2324
2323
  isError: !0
2325
2324
  };
2326
- s = n;
2325
+ s = t;
2327
2326
  }
2328
2327
  let c = `portlet-${Date.now()}-${Math.random().toString(36).slice(2, 7)}`, l = {
2329
2328
  id: c,
2330
2329
  title: e.title,
2331
2330
  query: e.query,
2332
- chartType: t,
2331
+ chartType: n,
2333
2332
  chartConfig: s,
2334
2333
  displayConfig: e.displayConfig
2335
2334
  };
2336
2335
  return {
2337
- result: `Portlet "${e.title}" added to notebook (id: ${c}, chart: ${t}). [Reminder: in your next response, start with a brief sentence about what you will do next BEFORE making any tool calls.]`,
2336
+ result: `Portlet "${e.title}" added to notebook (id: ${c}, chart: ${n}). [Reminder: in your next response, start with a brief sentence about what you will do next BEFORE making any tool calls.]`,
2338
2337
  sideEffect: {
2339
2338
  type: "add_portlet",
2340
2339
  data: l
@@ -2355,28 +2354,28 @@ function _(e) {
2355
2354
  };
2356
2355
  }), o.set("save_as_dashboard", async (e) => {
2357
2356
  try {
2358
- let t = e.portlets;
2359
- if (!t || t.length === 0) return {
2357
+ let n = e.portlets;
2358
+ if (!n || n.length === 0) return {
2360
2359
  result: "Dashboard must contain at least one portlet.",
2361
2360
  isError: !0
2362
2361
  };
2363
2362
  let r = [];
2364
- for (let e of t) {
2363
+ for (let e of n) {
2365
2364
  if (e.chartType === "markdown") continue;
2366
- let t = e.query;
2367
- if (!t) {
2365
+ let n = e.query;
2366
+ if (!n) {
2368
2367
  r.push(`Portlet "${e.title}": missing query`);
2369
2368
  continue;
2370
2369
  }
2371
2370
  let a;
2372
2371
  try {
2373
- a = JSON.parse(t);
2372
+ a = JSON.parse(n);
2374
2373
  } catch {
2375
2374
  r.push(`Portlet "${e.title}": invalid JSON query`);
2376
2375
  continue;
2377
2376
  }
2378
- a = n(a);
2379
- let o = i.validateQuery(a);
2377
+ a = i(a);
2378
+ let o = t.validateQuery(a);
2380
2379
  o.isValid || r.push(`Portlet "${e.title}": ${o.errors.join(", ")}`);
2381
2380
  }
2382
2381
  if (r.length > 0) return {
@@ -2384,7 +2383,7 @@ function _(e) {
2384
2383
  isError: !0
2385
2384
  };
2386
2385
  let a = {
2387
- portlets: t.map((e) => {
2386
+ portlets: n.map((e) => {
2388
2387
  let t = e.chartType, n = t === "markdown", r = n ? "query" : e.analysisType || "query", i = r === "funnel" ? "funnel" : r === "flow" ? "flow" : r === "retention" ? "retention" : "query", a = e.query || "{}", o;
2389
2388
  try {
2390
2389
  o = JSON.parse(a);
@@ -2440,15 +2439,15 @@ function _(e) {
2440
2439
  async function v(e, t, n) {
2441
2440
  switch (e) {
2442
2441
  case "anthropic": {
2443
- let { AnthropicProvider: e } = await import("./anthropic-DpEbCVvF.js");
2442
+ let { AnthropicProvider: e } = await import("./anthropic-B_rg0BhK.js");
2444
2443
  return new e(t);
2445
2444
  }
2446
2445
  case "openai": {
2447
- let { OpenAIProvider: e } = await import("./openai-BWdm0JvG.js");
2446
+ let { OpenAIProvider: e } = await import("./openai-DQawCWQb.js");
2448
2447
  return new e(t, n);
2449
2448
  }
2450
2449
  case "google": {
2451
- let { GoogleProvider: e } = await import("./google-CBfBGU4F.js");
2450
+ let { GoogleProvider: e } = await import("./google-CT4kgmBf.js");
2452
2451
  return new e(t);
2453
2452
  }
2454
2453
  default: throw Error(`Unknown LLM provider: "${e}". Supported providers: anthropic, openai, google`);
@@ -1,3 +1,3 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../utils-XPOzzMdY.cjs`),t=require(`../locale-BoiA6WiV.cjs`),n=require(`../mcp-transport-irsahKmD.cjs`);let r=require(`hono`);var i=e=>{let t={origin:`*`,allowMethods:[`GET`,`HEAD`,`PUT`,`POST`,`DELETE`,`PATCH`],allowHeaders:[],exposeHeaders:[],...e},n=(e=>typeof e==`string`?e===`*`?t.credentials?e=>e||null:()=>e:t=>e===t?t:null:typeof e==`function`?e:t=>e.includes(t)?t:null)(t.origin),r=(e=>typeof e==`function`?e:Array.isArray(e)?()=>e:()=>[])(t.allowMethods);return async function(e,i){function a(t,n){e.res.headers.set(t,n)}let o=await n(e.req.header(`origin`)||``,e);if(o&&a(`Access-Control-Allow-Origin`,o),t.credentials&&a(`Access-Control-Allow-Credentials`,`true`),t.exposeHeaders?.length&&a(`Access-Control-Expose-Headers`,t.exposeHeaders.join(`,`)),e.req.method===`OPTIONS`){(t.origin!==`*`||t.credentials)&&a(`Vary`,`Origin`),t.maxAge!=null&&a(`Access-Control-Max-Age`,t.maxAge.toString());let n=await r(e.req.header(`origin`)||``,e);n.length&&a(`Access-Control-Allow-Methods`,n.join(`,`));let i=t.allowHeaders;if(!i?.length){let t=e.req.header(`Access-Control-Request-Headers`);t&&(i=t.split(/\s*,\s*/))}return i?.length&&(a(`Access-Control-Allow-Headers`,i.join(`,`)),e.res.headers.append(`Vary`,`Access-Control-Request-Headers`)),e.res.headers.delete(`Content-Length`),e.res.headers.delete(`Content-Type`),new Response(null,{headers:e.res.headers,status:204,statusText:`No Content`})}await i(),(t.origin!==`*`||t.credentials)&&e.header(`Vary`,`Origin`,{append:!0})}};function a(a){let{cubes:o,drizzle:s,schema:c,extractSecurityContext:l,engineType:u,cors:d,basePath:f=`/cubejs-api/v1`,cache:p,mcp:m={enabled:!0},agent:h}=a;if(!a.semanticLayer&&(!o||o.length===0))throw Error(`Either semanticLayer or a non-empty cubes array must be provided`);let g=new r.Hono,_=async e=>t.r(await l(e),t.n(t=>e.req.header(t)));if(d){let e={...d,allowHeaders:t.t(d.allowHeaders)};g.use(`/*`,i(e))}let v=a.semanticLayer??new t.i({drizzle:s,schema:c,engineType:u,cache:p,rlsSetup:a.rlsSetup});if(!a.semanticLayer&&o&&o.forEach(e=>{v.registerCube(e)}),g.post(`${f}/load`,async t=>{try{let n=await t.req.json(),r=n.query||n,i=await _(t),a=v.validateQuery(r);if(!a.isValid)return t.json({error:`Query validation failed: ${a.errors.join(`, `)}`},400);let o=t.req.header(`x-cache-control`)===`no-cache`,s=await v.executeMultiCubeQuery(r,i,{skipCache:o});return t.json(e.r(r,s,v))}catch(e){return console.error(`Query execution error:`,e),t.json({error:e instanceof Error?e.message:`Query execution failed`},500)}}),g.get(`${f}/load`,async t=>{try{let n=t.req.query(`query`);if(!n)return t.json({error:`Query parameter is required`},400);let r;try{r=JSON.parse(n)}catch{return t.json({error:`Invalid JSON in query parameter`},400)}let i=await _(t),a=v.validateQuery(r);if(!a.isValid)return t.json({error:`Query validation failed: ${a.errors.join(`, `)}`},400);let o=t.req.header(`x-cache-control`)===`no-cache`,s=await v.executeMultiCubeQuery(r,i,{skipCache:o});return t.json(e.r(r,s,v))}catch(e){return console.error(`Query execution error:`,e),t.json({error:e instanceof Error?e.message:`Query execution failed`},500)}}),g.post(`${f}/batch`,async t=>{try{let{queries:n}=await t.req.json();if(!n||!Array.isArray(n))return t.json({error:`Request body must contain a "queries" array`},400);if(n.length===0)return t.json({error:`Queries array cannot be empty`},400);let r=await e.u(n,await _(t),v,{skipCache:t.req.header(`x-cache-control`)===`no-cache`});return t.json(r)}catch(e){return console.error(`Batch execution error:`,e),t.json({error:e instanceof Error?e.message:`Batch execution failed`},500)}}),g.get(`${f}/meta`,t=>{try{let n=v.getMetadata();return t.json(e.a(n))}catch(e){return console.error(`Metadata error:`,e),t.json({error:e instanceof Error?e.message:`Failed to fetch metadata`},500)}}),g.post(`${f}/sql`,async t=>{try{let n=await t.req.json(),r=await _(t),i=v.validateQuery(n);if(!i.isValid)return t.json({error:`Query validation failed: ${i.errors.join(`, `)}`},400);let a=n.measures?.[0]||n.dimensions?.[0];if(!a)return t.json({error:`No measures or dimensions specified`},400);let o=a.split(`.`)[0],s=await v.generateSQL(o,n,r);return t.json(e.o(n,s))}catch(e){return console.error(`SQL generation error:`,e),t.json({error:e instanceof Error?e.message:`SQL generation failed`},500)}}),g.get(`${f}/sql`,async t=>{try{let n=t.req.query(`query`);if(!n)return t.json({error:`Query parameter is required`},400);let r=JSON.parse(n),i=await _(t),a=v.validateQuery(r);if(!a.isValid)return t.json({error:`Query validation failed: ${a.errors.join(`, `)}`},400);let o=r.measures?.[0]||r.dimensions?.[0];if(!o)return t.json({error:`No measures or dimensions specified`},400);let s=o.split(`.`)[0],c=await v.generateSQL(s,r,i);return t.json(e.o(r,c))}catch(e){return console.error(`SQL generation error:`,e),t.json({error:e instanceof Error?e.message:`SQL generation failed`},500)}}),g.post(`${f}/dry-run`,async t=>{try{let n=await t.req.json(),r=await e.f(n.query||n,await _(t),v);return t.json(r)}catch(e){return console.error(`Dry-run error:`,e),t.json({error:e instanceof Error?e.message:`Dry-run validation failed`,valid:!1},400)}}),g.get(`${f}/dry-run`,async t=>{try{let n=t.req.query(`query`);if(!n)return t.json({error:`Query parameter is required`,valid:!1},400);let r=await e.f(JSON.parse(n),await _(t),v);return t.json(r)}catch(e){return console.error(`Dry-run error:`,e),t.json({error:e instanceof Error?e.message:`Dry-run validation failed`,valid:!1},400)}}),g.post(`${f}/explain`,async e=>{try{let t=await e.req.json(),n=t.query||t,r=t.options||{},i=await _(e),a=v.validateQuery(n);if(!a.isValid)return e.json({error:`Query validation failed: ${a.errors.join(`, `)}`},400);let o=await v.explainQuery(n,i,r);return e.json(o)}catch(t){return console.error(`Explain error:`,t),e.json({error:t instanceof Error?t.message:`Explain query failed`},500)}}),h&&g.post(`${f}/agent/chat`,async e=>{try{let{handleAgentChat:t}=await Promise.resolve().then(()=>require(`../handler-Cqf-CqAS.cjs`)),{message:n,sessionId:r,history:i}=await e.req.json();if(!n||typeof n!=`string`)return e.json({error:`message is required and must be a string`},400);let a=(h.apiKey||``).trim();if(h.allowClientApiKey){let t=e.req.header(`x-agent-api-key`);t&&(a=t.trim())}if(!a)return e.json({error:`No API key configured. Set agent.apiKey in server config or send X-Agent-Api-Key header.`},401);let o=h.allowClientApiKey?e.req.header(`x-agent-provider`):void 0,s=h.allowClientApiKey?e.req.header(`x-agent-model`):void 0,c=h.allowClientApiKey?e.req.header(`x-agent-provider-endpoint`):void 0,l=await _(e),u=h.buildSystemContext?.(l),d=new TextEncoder,f=new ReadableStream({async start(e){try{let f=t({message:n,sessionId:r,history:i,semanticLayer:v,securityContext:l,agentConfig:h,apiKey:a,systemContext:u,providerOverride:o,modelOverride:s,baseURLOverride:c});for await(let t of f){let n=`data: ${JSON.stringify(t)}\n\n`;e.enqueue(d.encode(n))}}catch(t){let n={type:`error`,data:{message:t instanceof Error?t.message:`Stream failed`}};e.enqueue(d.encode(`data: ${JSON.stringify(n)}\n\n`))}finally{e.close()}}});return new Response(f,{status:200,headers:{"Content-Type":`text/event-stream`,"Cache-Control":`no-cache`,Connection:`keep-alive`}})}catch(t){return console.error(`Agent chat error:`,t),e.json({error:t instanceof Error?t.message:`Agent chat failed`},500)}}),m.enabled!==!1){let e=n.o(v,m.resources),t=n.v(m.prompts),r=m.basePath??`/mcp`;g.post(`${r}`,async r=>{if(m.resourceMetadataUrl&&!n.u(r.req.header(`authorization`)))return r.header(`WWW-Authenticate`,n.c(m.resourceMetadataUrl)),r.json({error:`Bearer token required`},401);let i=n.x(r.req.header(`origin`),m.allowedOrigins?{allowedOrigins:m.allowedOrigins}:{});if(!i.valid)return r.json(n.i(null,-32600,i.reason),403);let a=r.req.header(`accept`);if(!n.b(a))return r.json(n.i(null,-32600,`Accept header must include both application/json and text/event-stream`),400);let o=n.h(r.req.header());if(!o.ok)return r.json({error:`Unsupported MCP protocol version`,supported:o.supported},426);let s=n.g(await r.req.json().catch(()=>null));if(!s)return r.json(n.i(null,-32600,`Invalid JSON-RPC 2.0 request`),400);let c=n.S(a),l=s.method===`initialize`;try{let i=await n.l(s.method,s.params,{semanticLayer:v,extractSecurityContext:(e,t)=>_(e),rawRequest:r,rawResponse:null,negotiatedProtocol:o.negotiated,resources:e,prompts:t,appEnabled:!!m.app,appConfig:typeof m.app==`object`?m.app:void 0,serverName:m.serverName});if(n.m(s))return r.body(null,202);let a=n.a(s.id??null,i),u=l&&i&&typeof i==`object`&&`sessionId`in i?i.sessionId:void 0,d={};if(u&&(d[n.r]=u),c){let e=new TextEncoder,t=n._(),r=new ReadableStream({start(r){r.enqueue(e.encode(`id: ${t}\n\n`)),r.enqueue(e.encode(n.y(a,t))),r.close()}});return new Response(r,{status:200,headers:{"Content-Type":`text/event-stream`,"Cache-Control":`no-cache`,Connection:`keep-alive`,...d}})}return r.json(a,200,d)}catch(e){if(n.m(s))return console.error(`MCP notification processing error:`,e),r.body(null,202);console.error(`MCP RPC error:`,e);let t=e?.code??-32603,i=e?.data,a=e.message||`MCP request failed`,o=n.i(s.id??null,t,a,i);if(c){let e=new TextEncoder,t=n._(),r=new ReadableStream({start(r){r.enqueue(e.encode(`id: ${t}\n\n`)),r.enqueue(e.encode(n.y(o,t))),r.close()}});return new Response(r,{status:200,headers:{"Content-Type":`text/event-stream`,"Cache-Control":`no-cache`,Connection:`keep-alive`}})}return r.json(o,200)}}),g.delete(`${r}`,e=>m.resourceMetadataUrl&&!n.u(e.req.header(`authorization`))?(e.header(`WWW-Authenticate`,n.c(m.resourceMetadataUrl)),e.json({error:`Bearer token required`},401)):e.json({error:`Session termination not supported`},405)),g.get(`${r}`,e=>{if(m.resourceMetadataUrl&&!n.u(e.req.header(`authorization`)))return e.header(`WWW-Authenticate`,n.c(m.resourceMetadataUrl)),e.json({error:`Bearer token required`},401);let t=new TextEncoder,r=n._(),i,a=new ReadableStream({start(e){e.enqueue(t.encode(n.y({jsonrpc:`2.0`,method:`mcp/ready`,params:{protocol:`streamable-http`}},r,15e3))),i=setInterval(()=>{e.enqueue(t.encode(`: keep-alive
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../utils-DrWvXf0G.cjs`),t=require(`../locale-Dl_3R6hP.cjs`),n=require(`../mcp-transport-CkyawtUT.cjs`);let r=require(`hono`);var i=e=>{let t={origin:`*`,allowMethods:[`GET`,`HEAD`,`PUT`,`POST`,`DELETE`,`PATCH`],allowHeaders:[],exposeHeaders:[],...e},n=(e=>typeof e==`string`?e===`*`?t.credentials?e=>e||null:()=>e:t=>e===t?t:null:typeof e==`function`?e:t=>e.includes(t)?t:null)(t.origin),r=(e=>typeof e==`function`?e:Array.isArray(e)?()=>e:()=>[])(t.allowMethods);return async function(e,i){function a(t,n){e.res.headers.set(t,n)}let o=await n(e.req.header(`origin`)||``,e);if(o&&a(`Access-Control-Allow-Origin`,o),t.credentials&&a(`Access-Control-Allow-Credentials`,`true`),t.exposeHeaders?.length&&a(`Access-Control-Expose-Headers`,t.exposeHeaders.join(`,`)),e.req.method===`OPTIONS`){(t.origin!==`*`||t.credentials)&&a(`Vary`,`Origin`),t.maxAge!=null&&a(`Access-Control-Max-Age`,t.maxAge.toString());let n=await r(e.req.header(`origin`)||``,e);n.length&&a(`Access-Control-Allow-Methods`,n.join(`,`));let i=t.allowHeaders;if(!i?.length){let t=e.req.header(`Access-Control-Request-Headers`);t&&(i=t.split(/\s*,\s*/))}return i?.length&&(a(`Access-Control-Allow-Headers`,i.join(`,`)),e.res.headers.append(`Vary`,`Access-Control-Request-Headers`)),e.res.headers.delete(`Content-Length`),e.res.headers.delete(`Content-Type`),new Response(null,{headers:e.res.headers,status:204,statusText:`No Content`})}await i(),(t.origin!==`*`||t.credentials)&&e.header(`Vary`,`Origin`,{append:!0})}};function a(a){let{cubes:o,drizzle:s,schema:c,extractSecurityContext:l,engineType:u,cors:d,basePath:f=`/cubejs-api/v1`,cache:p,mcp:m={enabled:!0},agent:h}=a;if(!a.semanticLayer&&(!o||o.length===0))throw Error(`Either semanticLayer or a non-empty cubes array must be provided`);let g=new r.Hono,_=async e=>t.r(await l(e),t.n(t=>e.req.header(t)));if(d){let e={...d,allowHeaders:t.t(d.allowHeaders)};g.use(`/*`,i(e))}let v=a.semanticLayer??new t.i({drizzle:s,schema:c,engineType:u,cache:p,rlsSetup:a.rlsSetup});if(!a.semanticLayer&&o&&o.forEach(e=>{v.registerCube(e)}),g.post(`${f}/load`,async t=>{try{let n=await t.req.json(),r=n.query||n,i=await _(t),a=v.validateQuery(r);if(!a.isValid)return t.json({error:`Query validation failed: ${a.errors.join(`, `)}`},400);let o=t.req.header(`x-cache-control`)===`no-cache`,s=await v.executeMultiCubeQuery(r,i,{skipCache:o});return t.json(e.r(r,s,v))}catch(e){return console.error(`Query execution error:`,e),t.json({error:e instanceof Error?e.message:`Query execution failed`},500)}}),g.get(`${f}/load`,async t=>{try{let n=t.req.query(`query`);if(!n)return t.json({error:`Query parameter is required`},400);let r;try{r=JSON.parse(n)}catch{return t.json({error:`Invalid JSON in query parameter`},400)}let i=await _(t),a=v.validateQuery(r);if(!a.isValid)return t.json({error:`Query validation failed: ${a.errors.join(`, `)}`},400);let o=t.req.header(`x-cache-control`)===`no-cache`,s=await v.executeMultiCubeQuery(r,i,{skipCache:o});return t.json(e.r(r,s,v))}catch(e){return console.error(`Query execution error:`,e),t.json({error:e instanceof Error?e.message:`Query execution failed`},500)}}),g.post(`${f}/batch`,async t=>{try{let{queries:n}=await t.req.json();if(!n||!Array.isArray(n))return t.json({error:`Request body must contain a "queries" array`},400);if(n.length===0)return t.json({error:`Queries array cannot be empty`},400);let r=await e.u(n,await _(t),v,{skipCache:t.req.header(`x-cache-control`)===`no-cache`});return t.json(r)}catch(e){return console.error(`Batch execution error:`,e),t.json({error:e instanceof Error?e.message:`Batch execution failed`},500)}}),g.get(`${f}/meta`,t=>{try{let n=v.getMetadata();return t.json(e.a(n))}catch(e){return console.error(`Metadata error:`,e),t.json({error:e instanceof Error?e.message:`Failed to fetch metadata`},500)}}),g.post(`${f}/sql`,async t=>{try{let n=await t.req.json(),r=await _(t),i=v.validateQuery(n);if(!i.isValid)return t.json({error:`Query validation failed: ${i.errors.join(`, `)}`},400);let a=n.measures?.[0]||n.dimensions?.[0];if(!a)return t.json({error:`No measures or dimensions specified`},400);let o=a.split(`.`)[0],s=await v.generateSQL(o,n,r);return t.json(e.o(n,s))}catch(e){return console.error(`SQL generation error:`,e),t.json({error:e instanceof Error?e.message:`SQL generation failed`},500)}}),g.get(`${f}/sql`,async t=>{try{let n=t.req.query(`query`);if(!n)return t.json({error:`Query parameter is required`},400);let r=JSON.parse(n),i=await _(t),a=v.validateQuery(r);if(!a.isValid)return t.json({error:`Query validation failed: ${a.errors.join(`, `)}`},400);let o=r.measures?.[0]||r.dimensions?.[0];if(!o)return t.json({error:`No measures or dimensions specified`},400);let s=o.split(`.`)[0],c=await v.generateSQL(s,r,i);return t.json(e.o(r,c))}catch(e){return console.error(`SQL generation error:`,e),t.json({error:e instanceof Error?e.message:`SQL generation failed`},500)}}),g.post(`${f}/dry-run`,async t=>{try{let n=await t.req.json(),r=await e.f(n.query||n,await _(t),v);return t.json(r)}catch(e){return console.error(`Dry-run error:`,e),t.json({error:e instanceof Error?e.message:`Dry-run validation failed`,valid:!1},400)}}),g.get(`${f}/dry-run`,async t=>{try{let n=t.req.query(`query`);if(!n)return t.json({error:`Query parameter is required`,valid:!1},400);let r=await e.f(JSON.parse(n),await _(t),v);return t.json(r)}catch(e){return console.error(`Dry-run error:`,e),t.json({error:e instanceof Error?e.message:`Dry-run validation failed`,valid:!1},400)}}),g.post(`${f}/explain`,async e=>{try{let t=await e.req.json(),n=t.query||t,r=t.options||{},i=await _(e),a=v.validateQuery(n);if(!a.isValid)return e.json({error:`Query validation failed: ${a.errors.join(`, `)}`},400);let o=await v.explainQuery(n,i,r);return e.json(o)}catch(t){return console.error(`Explain error:`,t),e.json({error:t instanceof Error?t.message:`Explain query failed`},500)}}),h&&g.post(`${f}/agent/chat`,async e=>{try{let{handleAgentChat:t}=await Promise.resolve().then(()=>require(`../handler-CNn3q29F.cjs`)),{message:n,sessionId:r,history:i}=await e.req.json();if(!n||typeof n!=`string`)return e.json({error:`message is required and must be a string`},400);let a=(h.apiKey||``).trim();if(h.allowClientApiKey){let t=e.req.header(`x-agent-api-key`);t&&(a=t.trim())}if(!a)return e.json({error:`No API key configured. Set agent.apiKey in server config or send X-Agent-Api-Key header.`},401);let o=h.allowClientApiKey?e.req.header(`x-agent-provider`):void 0,s=h.allowClientApiKey?e.req.header(`x-agent-model`):void 0,c=h.allowClientApiKey?e.req.header(`x-agent-provider-endpoint`):void 0,l=await _(e),u=h.buildSystemContext?.(l),d=new TextEncoder,f=new ReadableStream({async start(e){try{let f=t({message:n,sessionId:r,history:i,semanticLayer:v,securityContext:l,agentConfig:h,apiKey:a,systemContext:u,providerOverride:o,modelOverride:s,baseURLOverride:c});for await(let t of f){let n=`data: ${JSON.stringify(t)}\n\n`;e.enqueue(d.encode(n))}}catch(t){let n={type:`error`,data:{message:t instanceof Error?t.message:`Stream failed`}};e.enqueue(d.encode(`data: ${JSON.stringify(n)}\n\n`))}finally{e.close()}}});return new Response(f,{status:200,headers:{"Content-Type":`text/event-stream`,"Cache-Control":`no-cache`,Connection:`keep-alive`}})}catch(t){return console.error(`Agent chat error:`,t),e.json({error:t instanceof Error?t.message:`Agent chat failed`},500)}}),m.enabled!==!1){let e=n.o(v,m.resources),t=n.y(m.prompts),r=n.v(m.instructions),i=m.basePath??`/mcp`;g.post(`${i}`,async i=>{if(m.resourceMetadataUrl&&!n.u(i.req.header(`authorization`)))return i.header(`WWW-Authenticate`,n.c(m.resourceMetadataUrl)),i.json({error:`Bearer token required`},401);let a=n.S(i.req.header(`origin`),m.allowedOrigins?{allowedOrigins:m.allowedOrigins}:{});if(!a.valid)return i.json(n.i(null,-32600,a.reason),403);let o=i.req.header(`accept`);if(!n.x(o))return i.json(n.i(null,-32600,`Accept header must include both application/json and text/event-stream`),400);let s=n.h(i.req.header());if(!s.ok)return i.json({error:`Unsupported MCP protocol version`,supported:s.supported},426);let c=n.g(await i.req.json().catch(()=>null));if(!c)return i.json(n.i(null,-32600,`Invalid JSON-RPC 2.0 request`),400);let l=n.C(o),u=c.method===`initialize`;try{let a=await n.l(c.method,c.params,{semanticLayer:v,extractSecurityContext:(e,t)=>_(e),rawRequest:i,rawResponse:null,negotiatedProtocol:s.negotiated,resources:e,prompts:t,instructions:r,appEnabled:!!m.app,appConfig:typeof m.app==`object`?m.app:void 0,serverName:m.serverName});if(n.m(c))return i.body(null,202);let o=n.a(c.id??null,a),d=u&&a&&typeof a==`object`&&`sessionId`in a?a.sessionId:void 0,f={};if(d&&(f[n.r]=d),l){let e=new TextEncoder,t=n._(),r=new ReadableStream({start(r){r.enqueue(e.encode(`id: ${t}\n\n`)),r.enqueue(e.encode(n.b(o,t))),r.close()}});return new Response(r,{status:200,headers:{"Content-Type":`text/event-stream`,"Cache-Control":`no-cache`,Connection:`keep-alive`,...f}})}return i.json(o,200,f)}catch(e){if(n.m(c))return console.error(`MCP notification processing error:`,e),i.body(null,202);console.error(`MCP RPC error:`,e);let t=e?.code??-32603,r=e?.data,a=e.message||`MCP request failed`,o=n.i(c.id??null,t,a,r);if(l){let e=new TextEncoder,t=n._(),r=new ReadableStream({start(r){r.enqueue(e.encode(`id: ${t}\n\n`)),r.enqueue(e.encode(n.b(o,t))),r.close()}});return new Response(r,{status:200,headers:{"Content-Type":`text/event-stream`,"Cache-Control":`no-cache`,Connection:`keep-alive`}})}return i.json(o,200)}}),g.delete(`${i}`,e=>m.resourceMetadataUrl&&!n.u(e.req.header(`authorization`))?(e.header(`WWW-Authenticate`,n.c(m.resourceMetadataUrl)),e.json({error:`Bearer token required`},401)):e.json({error:`Session termination not supported`},405)),g.get(`${i}`,e=>{if(m.resourceMetadataUrl&&!n.u(e.req.header(`authorization`)))return e.header(`WWW-Authenticate`,n.c(m.resourceMetadataUrl)),e.json({error:`Bearer token required`},401);let t=new TextEncoder,r=n._(),i,a=new ReadableStream({start(e){e.enqueue(t.encode(n.b({jsonrpc:`2.0`,method:`mcp/ready`,params:{protocol:`streamable-http`}},r,15e3))),i=setInterval(()=>{e.enqueue(t.encode(`: keep-alive
2
2
 
3
3
  `))},15e3)},cancel(){clearInterval(i)}});return new Response(a,{status:200,headers:{"Content-Type":`text/event-stream`,"Cache-Control":`no-cache`,Connection:`keep-alive`}})})}return g}function o(e,t){let n=a(t);return e.route(`/`,n),e}function s(e){return o(new r.Hono,e)}exports.createCubeApp=s,exports.createCubeRoutes=a,exports.mountCubeRoutes=o;