drizzle-cube 0.4.20 → 0.4.22

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 (123) hide show
  1. package/dist/adapters/anthropic-BTkjgFpT.cjs +1 -0
  2. package/dist/adapters/anthropic-CTu9E801.js +126 -0
  3. package/dist/adapters/express/index.cjs +6 -6
  4. package/dist/adapters/express/index.js +119 -116
  5. package/dist/adapters/fastify/index.cjs +6 -6
  6. package/dist/adapters/fastify/index.js +113 -110
  7. package/dist/adapters/google-BAK9pnQf.cjs +2 -0
  8. package/dist/adapters/google-DficVAsJ.js +146 -0
  9. package/dist/adapters/{handler-CbDMdSY5.js → handler-9Rdn7zM2.js} +534 -461
  10. package/dist/adapters/handler-B-tEntiU.cjs +39 -0
  11. package/dist/adapters/hono/index.cjs +6 -6
  12. package/dist/adapters/hono/index.js +199 -196
  13. package/dist/adapters/index-BIMhF5KZ.cjs +23 -0
  14. package/dist/adapters/index-BgCeQBuN.cjs +2 -0
  15. package/dist/adapters/index-C45_meK_.js +719 -0
  16. package/dist/adapters/index-CFEJ62GJ.js +5337 -0
  17. package/dist/adapters/nextjs/index.cjs +5 -5
  18. package/dist/adapters/nextjs/index.js +245 -242
  19. package/dist/adapters/openai-CUSRuKTk.js +131 -0
  20. package/dist/adapters/openai-mLo2MCat.cjs +1 -0
  21. package/dist/client/charts.js +12 -12
  22. package/dist/client/chunks/{RetentionCombinedChart-CLq89aOJ.js → RetentionCombinedChart-BK3NPsHP.js} +2 -2
  23. package/dist/client/chunks/{RetentionCombinedChart-CLq89aOJ.js.map → RetentionCombinedChart-BK3NPsHP.js.map} +1 -1
  24. package/dist/client/chunks/{analysis-builder-3z9fHE2F.js → analysis-builder-DVrv9Q4n.js} +9 -9
  25. package/dist/client/chunks/{analysis-builder-3z9fHE2F.js.map → analysis-builder-DVrv9Q4n.js.map} +1 -1
  26. package/dist/client/chunks/{analysis-builder-shared-Da-vlQa_.js → analysis-builder-shared-CrENEvEk.js} +6 -6
  27. package/dist/client/chunks/{analysis-builder-shared-Da-vlQa_.js.map → analysis-builder-shared-CrENEvEk.js.map} +1 -1
  28. package/dist/client/chunks/{chart-activity-grid-CPGcTSuh.js → chart-activity-grid-OG6he4YS.js} +2 -2
  29. package/dist/client/chunks/{chart-activity-grid-CPGcTSuh.js.map → chart-activity-grid-OG6he4YS.js.map} +1 -1
  30. package/dist/client/chunks/{chart-area-ByJQ7NZd.js → chart-area-TawAd2k9.js} +3 -3
  31. package/dist/client/chunks/{chart-area-ByJQ7NZd.js.map → chart-area-TawAd2k9.js.map} +1 -1
  32. package/dist/client/chunks/{chart-bar-dj14frMt.js → chart-bar-D3vtCNQG.js} +2 -2
  33. package/dist/client/chunks/{chart-bar-dj14frMt.js.map → chart-bar-D3vtCNQG.js.map} +1 -1
  34. package/dist/client/chunks/{chart-box-plot-ZatBpatq.js → chart-box-plot-BXwN2rO5.js} +2 -2
  35. package/dist/client/chunks/{chart-box-plot-ZatBpatq.js.map → chart-box-plot-BXwN2rO5.js.map} +1 -1
  36. package/dist/client/chunks/{chart-bubble-CemotLx-.js → chart-bubble-ZfNe8t5k.js} +2 -2
  37. package/dist/client/chunks/{chart-bubble-CemotLx-.js.map → chart-bubble-ZfNe8t5k.js.map} +1 -1
  38. package/dist/client/chunks/{chart-candlestick-BIR4uGGt.js → chart-candlestick-DmF3haFu.js} +2 -2
  39. package/dist/client/chunks/{chart-candlestick-BIR4uGGt.js.map → chart-candlestick-DmF3haFu.js.map} +1 -1
  40. package/dist/client/chunks/{chart-data-table-BsAjHe7o.js → chart-data-table-DJZPkArt.js} +4 -4
  41. package/dist/client/chunks/{chart-data-table-BsAjHe7o.js.map → chart-data-table-DJZPkArt.js.map} +1 -1
  42. package/dist/client/chunks/{chart-funnel-dofnhD24.js → chart-funnel-CE9x0Io9.js} +2 -2
  43. package/dist/client/chunks/{chart-funnel-dofnhD24.js.map → chart-funnel-CE9x0Io9.js.map} +1 -1
  44. package/dist/client/chunks/{chart-gauge-CKJJ8m3b.js → chart-gauge-Djs5FWxB.js} +2 -2
  45. package/dist/client/chunks/{chart-gauge-CKJJ8m3b.js.map → chart-gauge-Djs5FWxB.js.map} +1 -1
  46. package/dist/client/chunks/{chart-heat-map-BVuPUKHT.js → chart-heat-map-CqtMkdxd.js} +2 -2
  47. package/dist/client/chunks/{chart-heat-map-BVuPUKHT.js.map → chart-heat-map-CqtMkdxd.js.map} +1 -1
  48. package/dist/client/chunks/{chart-kpi-delta-DUD3f8vL.js → chart-kpi-delta-DEzA74cL.js} +4 -4
  49. package/dist/client/chunks/{chart-kpi-delta-DUD3f8vL.js.map → chart-kpi-delta-DEzA74cL.js.map} +1 -1
  50. package/dist/client/chunks/{chart-kpi-number-iJh-PzsM.js → chart-kpi-number-Bab-BZtX.js} +3 -3
  51. package/dist/client/chunks/{chart-kpi-number-iJh-PzsM.js.map → chart-kpi-number-Bab-BZtX.js.map} +1 -1
  52. package/dist/client/chunks/{chart-kpi-text-x6pV9v9Q.js → chart-kpi-text-BkTgckDJ.js} +3 -3
  53. package/dist/client/chunks/{chart-kpi-text-x6pV9v9Q.js.map → chart-kpi-text-BkTgckDJ.js.map} +1 -1
  54. package/dist/client/chunks/{chart-line-DzyZkugh.js → chart-line-DhM-Hvu0.js} +3 -3
  55. package/dist/client/chunks/{chart-line-DzyZkugh.js.map → chart-line-DhM-Hvu0.js.map} +1 -1
  56. package/dist/client/chunks/{chart-measure-profile-C2IkBG3V.js → chart-measure-profile-4vQxFm69.js} +3 -3
  57. package/dist/client/chunks/{chart-measure-profile-C2IkBG3V.js.map → chart-measure-profile-4vQxFm69.js.map} +1 -1
  58. package/dist/client/chunks/{chart-pie-akbfRfb9.js → chart-pie-B86KRcHI.js} +2 -2
  59. package/dist/client/chunks/{chart-pie-akbfRfb9.js.map → chart-pie-B86KRcHI.js.map} +1 -1
  60. package/dist/client/chunks/{chart-radar-BaN-Kjww.js → chart-radar-BhDBmJRh.js} +2 -2
  61. package/dist/client/chunks/{chart-radar-BaN-Kjww.js.map → chart-radar-BhDBmJRh.js.map} +1 -1
  62. package/dist/client/chunks/{chart-radial-bar-DpptEL3s.js → chart-radial-bar-Brugya8X.js} +2 -2
  63. package/dist/client/chunks/{chart-radial-bar-DpptEL3s.js.map → chart-radial-bar-Brugya8X.js.map} +1 -1
  64. package/dist/client/chunks/{chart-sankey-CG-3hHmX.js → chart-sankey-D2L8ympI.js} +2 -2
  65. package/dist/client/chunks/{chart-sankey-CG-3hHmX.js.map → chart-sankey-D2L8ympI.js.map} +1 -1
  66. package/dist/client/chunks/{chart-scatter-l_yTVxF3.js → chart-scatter-CAkbBDkK.js} +2 -2
  67. package/dist/client/chunks/{chart-scatter-l_yTVxF3.js.map → chart-scatter-CAkbBDkK.js.map} +1 -1
  68. package/dist/client/chunks/{chart-sunburst-KhDcKhmZ.js → chart-sunburst-DaxJ-cob.js} +2 -2
  69. package/dist/client/chunks/{chart-sunburst-KhDcKhmZ.js.map → chart-sunburst-DaxJ-cob.js.map} +1 -1
  70. package/dist/client/chunks/{chart-tree-map-CBbiaBXV.js → chart-tree-map-CrDJAvZU.js} +2 -2
  71. package/dist/client/chunks/{chart-tree-map-CBbiaBXV.js.map → chart-tree-map-CrDJAvZU.js.map} +1 -1
  72. package/dist/client/chunks/{chart-waterfall-CX3vx_lI.js → chart-waterfall-BBwSfEKT.js} +3 -3
  73. package/dist/client/chunks/{chart-waterfall-CX3vx_lI.js.map → chart-waterfall-BBwSfEKT.js.map} +1 -1
  74. package/dist/client/chunks/{charts-core-CU9u_HtL.js → charts-core-B4Rbfdcn.js} +2 -2
  75. package/dist/client/chunks/{charts-core-CU9u_HtL.js.map → charts-core-B4Rbfdcn.js.map} +1 -1
  76. package/dist/client/chunks/{charts-loader-B3tt5oKG.js → charts-loader-DbrwgvCK.js} +25 -25
  77. package/dist/client/chunks/{charts-loader-B3tt5oKG.js.map → charts-loader-DbrwgvCK.js.map} +1 -1
  78. package/dist/client/chunks/{components-CMGGxqOB.js → components-GzooQM5J.js} +9 -9
  79. package/dist/client/chunks/{components-CMGGxqOB.js.map → components-GzooQM5J.js.map} +1 -1
  80. package/dist/client/chunks/{core-D_8mkGpQ.js → core-Y9e-sNfb.js} +2 -2
  81. package/dist/client/chunks/{core-D_8mkGpQ.js.map → core-Y9e-sNfb.js.map} +1 -1
  82. package/dist/client/chunks/{icons-M7shurcH.js → icons-DFJw-2HU.js} +6 -6
  83. package/dist/client/chunks/{icons-M7shurcH.js.map → icons-DFJw-2HU.js.map} +1 -1
  84. package/dist/client/chunks/{providers-CgxXm6Ll.js → providers-CCw8Kjlc.js} +2 -2
  85. package/dist/client/chunks/{providers-CgxXm6Ll.js.map → providers-CCw8Kjlc.js.map} +1 -1
  86. package/dist/client/chunks/{syntaxHighlighting-BQfjio-i.js → syntaxHighlighting-DAMSW_A6.js} +2 -2
  87. package/dist/client/chunks/{syntaxHighlighting-BQfjio-i.js.map → syntaxHighlighting-DAMSW_A6.js.map} +1 -1
  88. package/dist/client/chunks/{useDirtyStateTracking-Cu1HSjmo.js → useDirtyStateTracking-CjhwBXRw.js} +20 -20
  89. package/dist/client/chunks/{useDirtyStateTracking-Cu1HSjmo.js.map → useDirtyStateTracking-CjhwBXRw.js.map} +1 -1
  90. package/dist/client/chunks/useExplainAI-IiW55BaQ.js +182 -0
  91. package/dist/client/chunks/useExplainAI-IiW55BaQ.js.map +1 -0
  92. package/dist/client/chunks/{vendor-AVsJ2ni0.js → vendor-B2EH3V58.js} +7 -7
  93. package/dist/client/chunks/{vendor-AVsJ2ni0.js.map → vendor-B2EH3V58.js.map} +1 -1
  94. package/dist/client/components/AgenticNotebook/AgentChatPanel.d.ts +3 -0
  95. package/dist/client/components/AgenticNotebook/index.d.ts +6 -0
  96. package/dist/client/components.js +1 -1
  97. package/dist/client/hooks/useAgentChat.d.ts +6 -0
  98. package/dist/client/hooks/useNotebookLayout.d.ts +8 -0
  99. package/dist/client/hooks.d.ts +2 -0
  100. package/dist/client/hooks.js +51 -190
  101. package/dist/client/hooks.js.map +1 -1
  102. package/dist/client/icons.js +1 -1
  103. package/dist/client/index.js +926 -764
  104. package/dist/client/index.js.map +1 -1
  105. package/dist/client/providers.js +1 -1
  106. package/dist/client/styles.css +1 -1
  107. package/dist/client/utils.js +7 -7
  108. package/dist/client-bundle-stats.html +1 -1
  109. package/dist/server/anthropic-BTkjgFpT.cjs +1 -0
  110. package/dist/server/anthropic-CTu9E801.js +126 -0
  111. package/dist/server/google-BAK9pnQf.cjs +2 -0
  112. package/dist/server/google-DficVAsJ.js +146 -0
  113. package/dist/server/index-BIMhF5KZ.cjs +23 -0
  114. package/dist/server/index-BgCeQBuN.cjs +2 -0
  115. package/dist/server/index-C45_meK_.js +719 -0
  116. package/dist/server/index-CFEJ62GJ.js +5337 -0
  117. package/dist/server/index.cjs +48 -46
  118. package/dist/server/index.d.ts +37 -10
  119. package/dist/server/index.js +1974 -1901
  120. package/dist/server/openai-CUSRuKTk.js +131 -0
  121. package/dist/server/openai-mLo2MCat.cjs +1 -0
  122. package/package.json +12 -2
  123. package/dist/adapters/handler-DtdjM1Vx.cjs +0 -37
@@ -0,0 +1 @@
1
+ "use strict";var l=Object.create;var i=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var u=Object.getOwnPropertyNames;var p=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var y=(o,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of u(e))!d.call(o,t)&&t!==r&&i(o,t,{get:()=>e[t],enumerable:!(s=c(e,t))||s.enumerable});return o};var m=(o,e,r)=>(r=o!=null?l(p(o)):{},y(e||!o||!o.__esModule?i(r,"default",{value:o,enumerable:!0}):r,o));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});class _{client;constructor(e){this.apiKey=e}apiKey;initialized=!1;async ensureClient(){if(this.initialized)return;let e;try{const r=await import("@anthropic-ai/sdk");e=r.default||r.Anthropic||r}catch{throw new Error("@anthropic-ai/sdk is required for the Anthropic provider. Install it with: npm install @anthropic-ai/sdk")}this.client=new e({apiKey:this.apiKey}),this.initialized=!0}async createStream(e){await this.ensureClient();const{messages:r,system:s}=this.formatMessages(e.messages,e.system);return this.client.messages.create({model:e.model,max_tokens:e.maxTokens,system:s,tools:this.formatTools(e.tools),messages:r,stream:!0})}async*parseStreamEvents(e){for await(const r of e){const s=r;switch(s.type){case"content_block_start":{const t=s.content_block;t.type==="tool_use"&&(yield{type:"tool_use_start",id:t.id,name:t.name});break}case"content_block_delta":{const t=s.delta;t.type==="text_delta"&&t.text?yield{type:"text_delta",text:t.text}:t.type==="input_json_delta"&&t.partial_json&&(yield{type:"tool_input_delta",json:t.partial_json});break}case"content_block_stop":{yield{type:"tool_use_end"};break}case"message_start":{const t=s.message;t?.usage?.input_tokens!=null&&(yield{type:"message_meta",inputTokens:t.usage.input_tokens,stopReason:""});break}case"message_delta":{const t=s.usage,a=s.delta?.stop_reason||"";yield{type:"message_meta",outputTokens:t?.output_tokens,stopReason:a};break}}}}formatTools(e){return e.map(r=>({name:r.name,description:r.description,input_schema:r.parameters}))}formatMessages(e,r){return{messages:e.map(t=>t.role==="tool_result"?{role:"user",content:t.content}:{role:t.role,content:t.content}),system:r}}formatToolResults(e){return{role:"user",content:e.map(r=>({type:"tool_result",tool_use_id:r.toolUseId,content:r.content,...r.isError?{is_error:!0}:{}}))}}shouldContinue(e){return e==="tool_use"}formatError(e){if(!e||!(e instanceof Error))return"Something went wrong. Please try again.";const r=e.message||"",s={overloaded_error:"The AI service is temporarily overloaded. Please try again in a moment.",rate_limit_error:"Too many requests. Please wait a moment and try again.",api_error:"The AI service encountered an error. Please try again.",authentication_error:"Authentication failed. Please check your API key configuration.",invalid_request_error:"There was a problem with the request. Please try again."},t=e;if(t.status||t.type){const a=t.error?.type||t.type||"";if(s[a])return s[a]}if(r.startsWith("{")||r.startsWith("Error: {")){try{const a=JSON.parse(r.replace(/^Error:\s*/,"")),n=a.error?.type||a.type||"";if(s[n])return s[n]}catch{}return"The AI service encountered an error. Please try again."}return r}}exports.AnthropicProvider=_;
@@ -0,0 +1,126 @@
1
+ class i {
2
+ client;
3
+ constructor(e) {
4
+ this.apiKey = e;
5
+ }
6
+ apiKey;
7
+ initialized = !1;
8
+ async ensureClient() {
9
+ if (this.initialized) return;
10
+ let e;
11
+ try {
12
+ const r = await import(
13
+ /* webpackIgnore: true */
14
+ "@anthropic-ai/sdk"
15
+ );
16
+ e = r.default || r.Anthropic || r;
17
+ } catch {
18
+ throw new Error("@anthropic-ai/sdk is required for the Anthropic provider. Install it with: npm install @anthropic-ai/sdk");
19
+ }
20
+ this.client = new e({ apiKey: this.apiKey }), this.initialized = !0;
21
+ }
22
+ async createStream(e) {
23
+ await this.ensureClient();
24
+ const { messages: r, system: s } = this.formatMessages(e.messages, e.system);
25
+ return this.client.messages.create({
26
+ model: e.model,
27
+ max_tokens: e.maxTokens,
28
+ system: s,
29
+ tools: this.formatTools(e.tools),
30
+ messages: r,
31
+ stream: !0
32
+ });
33
+ }
34
+ async *parseStreamEvents(e) {
35
+ for await (const r of e) {
36
+ const s = r;
37
+ switch (s.type) {
38
+ case "content_block_start": {
39
+ const t = s.content_block;
40
+ t.type === "tool_use" && (yield { type: "tool_use_start", id: t.id, name: t.name });
41
+ break;
42
+ }
43
+ case "content_block_delta": {
44
+ const t = s.delta;
45
+ t.type === "text_delta" && t.text ? yield { type: "text_delta", text: t.text } : t.type === "input_json_delta" && t.partial_json && (yield { type: "tool_input_delta", json: t.partial_json });
46
+ break;
47
+ }
48
+ case "content_block_stop": {
49
+ yield { type: "tool_use_end" };
50
+ break;
51
+ }
52
+ case "message_start": {
53
+ const t = s.message;
54
+ t?.usage?.input_tokens != null && (yield {
55
+ type: "message_meta",
56
+ inputTokens: t.usage.input_tokens,
57
+ stopReason: ""
58
+ });
59
+ break;
60
+ }
61
+ case "message_delta": {
62
+ const t = s.usage, o = s.delta?.stop_reason || "";
63
+ yield {
64
+ type: "message_meta",
65
+ outputTokens: t?.output_tokens,
66
+ stopReason: o
67
+ };
68
+ break;
69
+ }
70
+ }
71
+ }
72
+ }
73
+ formatTools(e) {
74
+ return e.map((r) => ({
75
+ name: r.name,
76
+ description: r.description,
77
+ input_schema: r.parameters
78
+ }));
79
+ }
80
+ formatMessages(e, r) {
81
+ return { messages: e.map((t) => t.role === "tool_result" ? { role: "user", content: t.content } : { role: t.role, content: t.content }), system: r };
82
+ }
83
+ formatToolResults(e) {
84
+ return {
85
+ role: "user",
86
+ content: e.map((r) => ({
87
+ type: "tool_result",
88
+ tool_use_id: r.toolUseId,
89
+ content: r.content,
90
+ ...r.isError ? { is_error: !0 } : {}
91
+ }))
92
+ };
93
+ }
94
+ shouldContinue(e) {
95
+ return e === "tool_use";
96
+ }
97
+ formatError(e) {
98
+ if (!e || !(e instanceof Error))
99
+ return "Something went wrong. Please try again.";
100
+ const r = e.message || "", s = {
101
+ overloaded_error: "The AI service is temporarily overloaded. Please try again in a moment.",
102
+ rate_limit_error: "Too many requests. Please wait a moment and try again.",
103
+ api_error: "The AI service encountered an error. Please try again.",
104
+ authentication_error: "Authentication failed. Please check your API key configuration.",
105
+ invalid_request_error: "There was a problem with the request. Please try again."
106
+ }, t = e;
107
+ if (t.status || t.type) {
108
+ const o = t.error?.type || t.type || "";
109
+ if (s[o])
110
+ return s[o];
111
+ }
112
+ if (r.startsWith("{") || r.startsWith("Error: {")) {
113
+ try {
114
+ const o = JSON.parse(r.replace(/^Error:\s*/, "")), a = o.error?.type || o.type || "";
115
+ if (s[a])
116
+ return s[a];
117
+ } catch {
118
+ }
119
+ return "The AI service encountered an error. Please try again.";
120
+ }
121
+ return r;
122
+ }
123
+ }
124
+ export {
125
+ i as AnthropicProvider
126
+ };
@@ -1,11 +1,11 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("express"),M=require("cors"),c=require("../mcp-transport-8u9G5oNa.cjs"),n=require("../utils.cjs");function $(g){const{cubes:h,drizzle:w,schema:P,extractSecurityContext:p,engineType:A,cors:x,basePath:f="/cubejs-api/v1",jsonLimit:S="10mb",cache:H,mcp:C={enabled:!0},agent:v}=g;if(!h||h.length===0)throw new Error("At least one cube must be provided in the cubes array");const l=R.Router();x&&l.use(M(x)),l.use(R.json({limit:S})),l.use(R.urlencoded({extended:!0,limit:S}));const u=new c.SemanticLayerCompiler({drizzle:w,schema:P,engineType:A,cache:H});if(h.forEach(r=>{u.registerCube(r)}),l.post(`${f}/load`,async(r,t)=>{try{const e=r.body.query||r.body,o=await p(r,t),s=u.validateQuery(e);if(!s.isValid)return t.status(400).json(n.formatErrorResponse(`Query validation failed: ${s.errors.join(", ")}`,400));const a=r.headers["x-cache-control"]==="no-cache",i=await u.executeMultiCubeQuery(e,o,{skipCache:a});t.json(n.formatCubeResponse(e,i,u))}catch(e){console.error("Query execution error:",e),t.status(500).json(n.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500))}}),l.get(`${f}/load`,async(r,t)=>{try{const e=r.query.query;if(!e)return t.status(400).json(n.formatErrorResponse("Query parameter is required",400));let o;try{o=JSON.parse(e)}catch{return t.status(400).json(n.formatErrorResponse("Invalid JSON in query parameter",400))}const s=await p(r,t),a=u.validateQuery(o);if(!a.isValid)return t.status(400).json(n.formatErrorResponse(`Query validation failed: ${a.errors.join(", ")}`,400));const i=r.headers["x-cache-control"]==="no-cache",y=await u.executeMultiCubeQuery(o,s,{skipCache:i});t.json(n.formatCubeResponse(o,y,u))}catch(e){console.error("Query execution error:",e),t.status(500).json(n.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500))}}),l.post(`${f}/batch`,async(r,t)=>{try{const{queries:e}=r.body;if(!e||!Array.isArray(e))return t.status(400).json(n.formatErrorResponse('Request body must contain a "queries" array',400));if(e.length===0)return t.status(400).json(n.formatErrorResponse("Queries array cannot be empty",400));const o=await p(r,t),s=r.headers["x-cache-control"]==="no-cache",a=await n.handleBatchRequest(e,o,u,{skipCache:s});t.json(a)}catch(e){console.error("Batch execution error:",e),t.status(500).json(n.formatErrorResponse(e instanceof Error?e.message:"Batch execution failed",500))}}),l.get(`${f}/meta`,(r,t)=>{try{const e=u.getMetadata();t.json(n.formatMetaResponse(e))}catch(e){console.error("Metadata error:",e),t.status(500).json(n.formatErrorResponse(e instanceof Error?e.message:"Failed to fetch metadata",500))}}),l.post(`${f}/sql`,async(r,t)=>{try{const e=r.body,o=await p(r,t),s=u.validateQuery(e);if(!s.isValid)return t.status(400).json(n.formatErrorResponse(`Query validation failed: ${s.errors.join(", ")}`,400));const a=e.measures?.[0]||e.dimensions?.[0];if(!a)return t.status(400).json(n.formatErrorResponse("No measures or dimensions specified",400));const i=a.split(".")[0],y=await u.generateSQL(i,e,o);t.json(n.formatSqlResponse(e,y))}catch(e){console.error("SQL generation error:",e),t.status(500).json(n.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500))}}),l.get(`${f}/sql`,async(r,t)=>{try{const e=r.query.query;if(!e)return t.status(400).json(n.formatErrorResponse("Query parameter is required",400));const o=JSON.parse(e),s=await p(r,t),a=u.validateQuery(o);if(!a.isValid)return t.status(400).json(n.formatErrorResponse(`Query validation failed: ${a.errors.join(", ")}`,400));const i=o.measures?.[0]||o.dimensions?.[0];if(!i)return t.status(400).json(n.formatErrorResponse("No measures or dimensions specified",400));const y=i.split(".")[0],j=await u.generateSQL(y,o,s);t.json(n.formatSqlResponse(o,j))}catch(e){console.error("SQL generation error:",e),t.status(500).json(n.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500))}}),l.post(`${f}/dry-run`,async(r,t)=>{try{const e=r.body.query||r.body,o=await p(r,t),s=await n.handleDryRun(e,o,u);t.json(s)}catch(e){console.error("Dry-run error:",e),t.status(400).json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1})}}),l.get(`${f}/dry-run`,async(r,t)=>{try{const e=r.query.query;if(!e)return t.status(400).json({error:"Query parameter is required",valid:!1});const o=JSON.parse(e),s=await p(r,t),a=await n.handleDryRun(o,s,u);t.json(a)}catch(e){console.error("Dry-run error:",e),t.status(400).json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1})}}),l.post(`${f}/explain`,async(r,t)=>{try{const e=r.body.query||r.body,o=r.body.options||{},s=await p(r,t),a=u.validateQuery(e);if(!a.isValid)return t.status(400).json({error:`Query validation failed: ${a.errors.join(", ")}`});const i=await u.explainQuery(e,s,o);t.json(i)}catch(e){console.error("Explain error:",e),t.status(500).json({error:e instanceof Error?e.message:"Explain query failed"})}}),v&&l.post(`${f}/agent/chat`,async(r,t)=>{try{const{handleAgentChat:e}=await Promise.resolve().then(()=>require("../handler-DtdjM1Vx.cjs")),{message:o,sessionId:s,history:a}=r.body;if(!o||typeof o!="string")return t.status(400).json({error:"message is required and must be a string"});let i=(v.apiKey||"").trim();if(v.allowClientApiKey){const d=r.headers["x-agent-api-key"];d&&(i=d.trim())}if(!i)return t.status(401).json({error:"No API key configured. Set agent.apiKey in server config or send X-Agent-Api-Key header."});const y=await p(r,t),j=v.buildSystemContext?.(y);t.writeHead(200,{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"});try{const d=e({message:o,sessionId:s,history:a,semanticLayer:u,securityContext:y,agentConfig:v,apiKey:i,systemContext:j});for await(const m of d)t.write(`data: ${JSON.stringify(m)}
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("express"),H=require("cors"),c=require("../mcp-transport-8u9G5oNa.cjs"),n=require("../utils.cjs");function $(C){const{cubes:v,drizzle:x,schema:I,extractSecurityContext:y,engineType:P,cors:S,basePath:f="/cubejs-api/v1",jsonLimit:Q="10mb",cache:O,mcp:E={enabled:!0},agent:h}=C;if(!v||v.length===0)throw new Error("At least one cube must be provided in the cubes array");const d=w.Router();S&&d.use(H(S)),d.use(w.json({limit:Q})),d.use(w.urlencoded({extended:!0,limit:Q}));const u=new c.SemanticLayerCompiler({drizzle:x,schema:I,engineType:P,cache:O});if(v.forEach(r=>{u.registerCube(r)}),d.post(`${f}/load`,async(r,t)=>{try{const e=r.body.query||r.body,o=await y(r,t),s=u.validateQuery(e);if(!s.isValid)return t.status(400).json(n.formatErrorResponse(`Query validation failed: ${s.errors.join(", ")}`,400));const a=r.headers["x-cache-control"]==="no-cache",i=await u.executeMultiCubeQuery(e,o,{skipCache:a});t.json(n.formatCubeResponse(e,i,u))}catch(e){console.error("Query execution error:",e),t.status(500).json(n.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500))}}),d.get(`${f}/load`,async(r,t)=>{try{const e=r.query.query;if(!e)return t.status(400).json(n.formatErrorResponse("Query parameter is required",400));let o;try{o=JSON.parse(e)}catch{return t.status(400).json(n.formatErrorResponse("Invalid JSON in query parameter",400))}const s=await y(r,t),a=u.validateQuery(o);if(!a.isValid)return t.status(400).json(n.formatErrorResponse(`Query validation failed: ${a.errors.join(", ")}`,400));const i=r.headers["x-cache-control"]==="no-cache",m=await u.executeMultiCubeQuery(o,s,{skipCache:i});t.json(n.formatCubeResponse(o,m,u))}catch(e){console.error("Query execution error:",e),t.status(500).json(n.formatErrorResponse(e instanceof Error?e.message:"Query execution failed",500))}}),d.post(`${f}/batch`,async(r,t)=>{try{const{queries:e}=r.body;if(!e||!Array.isArray(e))return t.status(400).json(n.formatErrorResponse('Request body must contain a "queries" array',400));if(e.length===0)return t.status(400).json(n.formatErrorResponse("Queries array cannot be empty",400));const o=await y(r,t),s=r.headers["x-cache-control"]==="no-cache",a=await n.handleBatchRequest(e,o,u,{skipCache:s});t.json(a)}catch(e){console.error("Batch execution error:",e),t.status(500).json(n.formatErrorResponse(e instanceof Error?e.message:"Batch execution failed",500))}}),d.get(`${f}/meta`,(r,t)=>{try{const e=u.getMetadata();t.json(n.formatMetaResponse(e))}catch(e){console.error("Metadata error:",e),t.status(500).json(n.formatErrorResponse(e instanceof Error?e.message:"Failed to fetch metadata",500))}}),d.post(`${f}/sql`,async(r,t)=>{try{const e=r.body,o=await y(r,t),s=u.validateQuery(e);if(!s.isValid)return t.status(400).json(n.formatErrorResponse(`Query validation failed: ${s.errors.join(", ")}`,400));const a=e.measures?.[0]||e.dimensions?.[0];if(!a)return t.status(400).json(n.formatErrorResponse("No measures or dimensions specified",400));const i=a.split(".")[0],m=await u.generateSQL(i,e,o);t.json(n.formatSqlResponse(e,m))}catch(e){console.error("SQL generation error:",e),t.status(500).json(n.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500))}}),d.get(`${f}/sql`,async(r,t)=>{try{const e=r.query.query;if(!e)return t.status(400).json(n.formatErrorResponse("Query parameter is required",400));const o=JSON.parse(e),s=await y(r,t),a=u.validateQuery(o);if(!a.isValid)return t.status(400).json(n.formatErrorResponse(`Query validation failed: ${a.errors.join(", ")}`,400));const i=o.measures?.[0]||o.dimensions?.[0];if(!i)return t.status(400).json(n.formatErrorResponse("No measures or dimensions specified",400));const m=i.split(".")[0],R=await u.generateSQL(m,o,s);t.json(n.formatSqlResponse(o,R))}catch(e){console.error("SQL generation error:",e),t.status(500).json(n.formatErrorResponse(e instanceof Error?e.message:"SQL generation failed",500))}}),d.post(`${f}/dry-run`,async(r,t)=>{try{const e=r.body.query||r.body,o=await y(r,t),s=await n.handleDryRun(e,o,u);t.json(s)}catch(e){console.error("Dry-run error:",e),t.status(400).json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1})}}),d.get(`${f}/dry-run`,async(r,t)=>{try{const e=r.query.query;if(!e)return t.status(400).json({error:"Query parameter is required",valid:!1});const o=JSON.parse(e),s=await y(r,t),a=await n.handleDryRun(o,s,u);t.json(a)}catch(e){console.error("Dry-run error:",e),t.status(400).json({error:e instanceof Error?e.message:"Dry-run validation failed",valid:!1})}}),d.post(`${f}/explain`,async(r,t)=>{try{const e=r.body.query||r.body,o=r.body.options||{},s=await y(r,t),a=u.validateQuery(e);if(!a.isValid)return t.status(400).json({error:`Query validation failed: ${a.errors.join(", ")}`});const i=await u.explainQuery(e,s,o);t.json(i)}catch(e){console.error("Explain error:",e),t.status(500).json({error:e instanceof Error?e.message:"Explain query failed"})}}),h&&d.post(`${f}/agent/chat`,async(r,t)=>{try{const{handleAgentChat:e}=await Promise.resolve().then(()=>require("../handler-B-tEntiU.cjs")),{message:o,sessionId:s,history:a}=r.body;if(!o||typeof o!="string")return t.status(400).json({error:"message is required and must be a string"});let i=(h.apiKey||"").trim();if(h.allowClientApiKey){const p=r.headers["x-agent-api-key"];p&&(i=p.trim())}if(!i)return t.status(401).json({error:"No API key configured. Set agent.apiKey in server config or send X-Agent-Api-Key header."});const m=h.allowClientApiKey?r.headers["x-agent-provider"]:void 0,R=h.allowClientApiKey?r.headers["x-agent-model"]:void 0,l=h.allowClientApiKey?r.headers["x-agent-provider-endpoint"]:void 0,g=await y(r,t),b=h.buildSystemContext?.(g);t.writeHead(200,{"Content-Type":"text/event-stream","Cache-Control":"no-cache",Connection:"keep-alive"});try{const p=e({message:o,sessionId:s,history:a,semanticLayer:u,securityContext:g,agentConfig:h,apiKey:i,systemContext:b,providerOverride:m,modelOverride:R,baseURLOverride:l});for await(const j of p)t.write(`data: ${JSON.stringify(j)}
2
2
 
3
- `)}catch(d){const m={type:"error",data:{message:d instanceof Error?d.message:"Stream failed"}};t.write(`data: ${JSON.stringify(m)}
3
+ `)}catch(p){const j={type:"error",data:{message:p instanceof Error?p.message:"Stream failed"}};t.write(`data: ${JSON.stringify(j)}
4
4
 
5
- `)}finally{t.end()}}catch(e){console.error("Agent chat error:",e),t.headersSent||t.status(500).json({error:e instanceof Error?e.message:"Agent chat failed"})}}),C.enabled!==!1){const r=C.basePath??"/mcp";l.post(`${r}`,async(t,e)=>{const o=c.validateOriginHeader(t.headers.origin,C.allowedOrigins?{allowedOrigins:C.allowedOrigins}:{});if(!o.valid)return e.status(403).json(c.buildJsonRpcError(null,-32600,o.reason));const s=t.headers.accept;if(!c.validateAcceptHeader(s))return e.status(400).json(c.buildJsonRpcError(null,-32600,"Accept header must include both application/json and text/event-stream"));const a=c.negotiateProtocol(t.headers);if(!a.ok)return e.status(426).json({error:"Unsupported MCP protocol version",supported:a.supported});const i=c.parseJsonRpc(t.body);if(!i)return e.status(400).json(c.buildJsonRpcError(null,-32600,"Invalid JSON-RPC 2.0 request"));const y=c.wantsEventStream(s),j=i.method==="initialize";try{const d=await c.dispatchMcpMethod(i.method,i.params,{semanticLayer:u,extractSecurityContext:p,rawRequest:t,rawResponse:e,negotiatedProtocol:a.negotiated});if(c.isNotification(i))return e.status(202).end();const m=j&&d&&typeof d=="object"&&"sessionId"in d?d.sessionId:void 0;m&&e.setHeader(c.MCP_SESSION_ID_HEADER,m);const b=c.buildJsonRpcResult(i.id??null,d);if(y){const E=c.primeEventId();return e.status(200),e.setHeader("Content-Type","text/event-stream"),e.setHeader("Cache-Control","no-cache"),e.setHeader("Connection","keep-alive"),e.write(`id: ${E}
5
+ `)}finally{t.end()}}catch(e){console.error("Agent chat error:",e),t.headersSent||t.status(500).json({error:e instanceof Error?e.message:"Agent chat failed"})}}),E.enabled!==!1){const r=E.basePath??"/mcp";d.post(`${r}`,async(t,e)=>{const o=c.validateOriginHeader(t.headers.origin,E.allowedOrigins?{allowedOrigins:E.allowedOrigins}:{});if(!o.valid)return e.status(403).json(c.buildJsonRpcError(null,-32600,o.reason));const s=t.headers.accept;if(!c.validateAcceptHeader(s))return e.status(400).json(c.buildJsonRpcError(null,-32600,"Accept header must include both application/json and text/event-stream"));const a=c.negotiateProtocol(t.headers);if(!a.ok)return e.status(426).json({error:"Unsupported MCP protocol version",supported:a.supported});const i=c.parseJsonRpc(t.body);if(!i)return e.status(400).json(c.buildJsonRpcError(null,-32600,"Invalid JSON-RPC 2.0 request"));const m=c.wantsEventStream(s),R=i.method==="initialize";try{const l=await c.dispatchMcpMethod(i.method,i.params,{semanticLayer:u,extractSecurityContext:y,rawRequest:t,rawResponse:e,negotiatedProtocol:a.negotiated});if(c.isNotification(i))return e.status(202).end();const g=R&&l&&typeof l=="object"&&"sessionId"in l?l.sessionId:void 0;g&&e.setHeader(c.MCP_SESSION_ID_HEADER,g);const b=c.buildJsonRpcResult(i.id??null,l);if(m){const p=c.primeEventId();return e.status(200),e.setHeader("Content-Type","text/event-stream"),e.setHeader("Cache-Control","no-cache"),e.setHeader("Connection","keep-alive"),e.write(`id: ${p}
6
6
 
7
- `),e.write(c.serializeSseEvent(b,E)),e.end()}return e.json(b)}catch(d){if(c.isNotification(i))return console.error("MCP notification processing error:",d),e.status(202).end();console.error("MCP RPC error:",d);const m=d?.code??-32603,b=d?.data,E=d.message||"MCP request failed",Q=c.buildJsonRpcError(i.id??null,m,E,b);if(y){const q=c.primeEventId();return e.status(200),e.setHeader("Content-Type","text/event-stream"),e.setHeader("Cache-Control","no-cache"),e.setHeader("Connection","keep-alive"),e.write(`id: ${q}
7
+ `),e.write(c.serializeSseEvent(b,p)),e.end()}return e.json(b)}catch(l){if(c.isNotification(i))return console.error("MCP notification processing error:",l),e.status(202).end();console.error("MCP RPC error:",l);const g=l?.code??-32603,b=l?.data,p=l.message||"MCP request failed",j=c.buildJsonRpcError(i.id??null,g,p,b);if(m){const q=c.primeEventId();return e.status(200),e.setHeader("Content-Type","text/event-stream"),e.setHeader("Cache-Control","no-cache"),e.setHeader("Connection","keep-alive"),e.write(`id: ${q}
8
8
 
9
- `),e.write(c.serializeSseEvent(Q,q)),e.end()}return e.status(200).json(Q)}}),l.get(`${r}`,async(t,e)=>{const o=c.primeEventId();e.status(200),e.setHeader("Content-Type","text/event-stream"),e.setHeader("Cache-Control","no-cache"),e.setHeader("Connection","keep-alive"),e.write(c.serializeSseEvent({jsonrpc:"2.0",method:"mcp/ready",params:{protocol:"streamable-http"}},o,15e3));const s=setInterval(()=>{e.write(`: keep-alive
9
+ `),e.write(c.serializeSseEvent(j,q)),e.end()}return e.status(200).json(j)}}),d.get(`${r}`,async(t,e)=>{const o=c.primeEventId();e.status(200),e.setHeader("Content-Type","text/event-stream"),e.setHeader("Cache-Control","no-cache"),e.setHeader("Connection","keep-alive"),e.write(c.serializeSseEvent({jsonrpc:"2.0",method:"mcp/ready",params:{protocol:"streamable-http"}},o,15e3));const s=setInterval(()=>{e.write(`: keep-alive
10
10
 
11
- `)},15e3);t.on("close",()=>{clearInterval(s)})}),l.delete(`${r}`,(t,e)=>e.status(405).json({error:"Session termination not supported"}))}return l.use((r,t,e,o)=>{console.error("Express adapter error:",r),e.headersSent||e.status(500).json(n.formatErrorResponse(r,500))}),l}function I(g,h){const w=$(h);return g.use("/",w),g}function N(g){const h=R();return I(h,g)}exports.createCubeApp=N;exports.createCubeRouter=$;exports.mountCubeRoutes=I;
11
+ `)},15e3);t.on("close",()=>{clearInterval(s)})}),d.delete(`${r}`,(t,e)=>e.status(405).json({error:"Session termination not supported"}))}return d.use((r,t,e,o)=>{console.error("Express adapter error:",r),e.headersSent||e.status(500).json(n.formatErrorResponse(r,500))}),d}function A(C,v){const x=$(v);return C.use("/",x),C}function M(C){const v=w();return A(v,C)}exports.createCubeApp=M;exports.createCubeRouter=$;exports.mountCubeRoutes=A;
@@ -1,54 +1,54 @@
1
- import E, { Router as J } from "express";
1
+ import R, { Router as J } from "express";
2
2
  import L from "cors";
3
- import { S as D, v as _, b as w, a as K, n as V, p as z, w as T, d as B, i as P, M as F, c as U, e as S, s as Q } from "../mcp-transport-m1X1GtwG.js";
4
- import { formatErrorResponse as d, formatCubeResponse as A, handleBatchRequest as X, formatMetaResponse as G, formatSqlResponse as H, handleDryRun as M } from "../utils.js";
5
- function W(h) {
3
+ import { S as K, v as D, b as x, a as _, n as V, p as z, w as T, d as B, i as I, M as U, c as F, e as Q, s as E } from "../mcp-transport-m1X1GtwG.js";
4
+ import { formatErrorResponse as u, formatCubeResponse as P, handleBatchRequest as X, formatMetaResponse as G, formatSqlResponse as H, handleDryRun as M } from "../utils.js";
5
+ function W(v) {
6
6
  const {
7
- cubes: m,
8
- drizzle: x,
9
- schema: N,
7
+ cubes: h,
8
+ drizzle: S,
9
+ schema: O,
10
10
  extractSecurityContext: y,
11
- engineType: k,
12
- cors: R,
11
+ engineType: N,
12
+ cors: $,
13
13
  basePath: p = "/cubejs-api/v1",
14
- jsonLimit: $ = "10mb",
15
- cache: O,
16
- mcp: v = { enabled: !0 },
17
- agent: g
18
- } = h;
19
- if (!m || m.length === 0)
14
+ jsonLimit: A = "10mb",
15
+ cache: k,
16
+ mcp: w = { enabled: !0 },
17
+ agent: m
18
+ } = v;
19
+ if (!h || h.length === 0)
20
20
  throw new Error("At least one cube must be provided in the cubes array");
21
- const u = J();
22
- R && u.use(L(R)), u.use(E.json({ limit: $ })), u.use(E.urlencoded({ extended: !0, limit: $ }));
23
- const i = new D({
24
- drizzle: x,
25
- schema: N,
26
- engineType: k,
27
- cache: O
21
+ const c = J();
22
+ $ && c.use(L($)), c.use(R.json({ limit: A })), c.use(R.urlencoded({ extended: !0, limit: A }));
23
+ const i = new K({
24
+ drizzle: S,
25
+ schema: O,
26
+ engineType: N,
27
+ cache: k
28
28
  });
29
- if (m.forEach((r) => {
29
+ if (h.forEach((r) => {
30
30
  i.registerCube(r);
31
- }), u.post(`${p}/load`, async (r, t) => {
31
+ }), c.post(`${p}/load`, async (r, t) => {
32
32
  try {
33
33
  const e = r.body.query || r.body, o = await y(r, t), a = i.validateQuery(e);
34
34
  if (!a.isValid)
35
- return t.status(400).json(d(
35
+ return t.status(400).json(u(
36
36
  `Query validation failed: ${a.errors.join(", ")}`,
37
37
  400
38
38
  ));
39
39
  const n = r.headers["x-cache-control"] === "no-cache", s = await i.executeMultiCubeQuery(e, o, { skipCache: n });
40
- t.json(A(e, s, i));
40
+ t.json(P(e, s, i));
41
41
  } catch (e) {
42
- console.error("Query execution error:", e), t.status(500).json(d(
42
+ console.error("Query execution error:", e), t.status(500).json(u(
43
43
  e instanceof Error ? e.message : "Query execution failed",
44
44
  500
45
45
  ));
46
46
  }
47
- }), u.get(`${p}/load`, async (r, t) => {
47
+ }), c.get(`${p}/load`, async (r, t) => {
48
48
  try {
49
49
  const e = r.query.query;
50
50
  if (!e)
51
- return t.status(400).json(d(
51
+ return t.status(400).json(u(
52
52
  "Query parameter is required",
53
53
  400
54
54
  ));
@@ -56,107 +56,107 @@ function W(h) {
56
56
  try {
57
57
  o = JSON.parse(e);
58
58
  } catch {
59
- return t.status(400).json(d(
59
+ return t.status(400).json(u(
60
60
  "Invalid JSON in query parameter",
61
61
  400
62
62
  ));
63
63
  }
64
64
  const a = await y(r, t), n = i.validateQuery(o);
65
65
  if (!n.isValid)
66
- return t.status(400).json(d(
66
+ return t.status(400).json(u(
67
67
  `Query validation failed: ${n.errors.join(", ")}`,
68
68
  400
69
69
  ));
70
- const s = r.headers["x-cache-control"] === "no-cache", l = await i.executeMultiCubeQuery(o, a, { skipCache: s });
71
- t.json(A(o, l, i));
70
+ const s = r.headers["x-cache-control"] === "no-cache", f = await i.executeMultiCubeQuery(o, a, { skipCache: s });
71
+ t.json(P(o, f, i));
72
72
  } catch (e) {
73
- console.error("Query execution error:", e), t.status(500).json(d(
73
+ console.error("Query execution error:", e), t.status(500).json(u(
74
74
  e instanceof Error ? e.message : "Query execution failed",
75
75
  500
76
76
  ));
77
77
  }
78
- }), u.post(`${p}/batch`, async (r, t) => {
78
+ }), c.post(`${p}/batch`, async (r, t) => {
79
79
  try {
80
80
  const { queries: e } = r.body;
81
81
  if (!e || !Array.isArray(e))
82
- return t.status(400).json(d(
82
+ return t.status(400).json(u(
83
83
  'Request body must contain a "queries" array',
84
84
  400
85
85
  ));
86
86
  if (e.length === 0)
87
- return t.status(400).json(d(
87
+ return t.status(400).json(u(
88
88
  "Queries array cannot be empty",
89
89
  400
90
90
  ));
91
91
  const o = await y(r, t), a = r.headers["x-cache-control"] === "no-cache", n = await X(e, o, i, { skipCache: a });
92
92
  t.json(n);
93
93
  } catch (e) {
94
- console.error("Batch execution error:", e), t.status(500).json(d(
94
+ console.error("Batch execution error:", e), t.status(500).json(u(
95
95
  e instanceof Error ? e.message : "Batch execution failed",
96
96
  500
97
97
  ));
98
98
  }
99
- }), u.get(`${p}/meta`, (r, t) => {
99
+ }), c.get(`${p}/meta`, (r, t) => {
100
100
  try {
101
101
  const e = i.getMetadata();
102
102
  t.json(G(e));
103
103
  } catch (e) {
104
- console.error("Metadata error:", e), t.status(500).json(d(
104
+ console.error("Metadata error:", e), t.status(500).json(u(
105
105
  e instanceof Error ? e.message : "Failed to fetch metadata",
106
106
  500
107
107
  ));
108
108
  }
109
- }), u.post(`${p}/sql`, async (r, t) => {
109
+ }), c.post(`${p}/sql`, async (r, t) => {
110
110
  try {
111
111
  const e = r.body, o = await y(r, t), a = i.validateQuery(e);
112
112
  if (!a.isValid)
113
- return t.status(400).json(d(
113
+ return t.status(400).json(u(
114
114
  `Query validation failed: ${a.errors.join(", ")}`,
115
115
  400
116
116
  ));
117
117
  const n = e.measures?.[0] || e.dimensions?.[0];
118
118
  if (!n)
119
- return t.status(400).json(d(
119
+ return t.status(400).json(u(
120
120
  "No measures or dimensions specified",
121
121
  400
122
122
  ));
123
- const s = n.split(".")[0], l = await i.generateSQL(s, e, o);
124
- t.json(H(e, l));
123
+ const s = n.split(".")[0], f = await i.generateSQL(s, e, o);
124
+ t.json(H(e, f));
125
125
  } catch (e) {
126
- console.error("SQL generation error:", e), t.status(500).json(d(
126
+ console.error("SQL generation error:", e), t.status(500).json(u(
127
127
  e instanceof Error ? e.message : "SQL generation failed",
128
128
  500
129
129
  ));
130
130
  }
131
- }), u.get(`${p}/sql`, async (r, t) => {
131
+ }), c.get(`${p}/sql`, async (r, t) => {
132
132
  try {
133
133
  const e = r.query.query;
134
134
  if (!e)
135
- return t.status(400).json(d(
135
+ return t.status(400).json(u(
136
136
  "Query parameter is required",
137
137
  400
138
138
  ));
139
139
  const o = JSON.parse(e), a = await y(r, t), n = i.validateQuery(o);
140
140
  if (!n.isValid)
141
- return t.status(400).json(d(
141
+ return t.status(400).json(u(
142
142
  `Query validation failed: ${n.errors.join(", ")}`,
143
143
  400
144
144
  ));
145
145
  const s = o.measures?.[0] || o.dimensions?.[0];
146
146
  if (!s)
147
- return t.status(400).json(d(
147
+ return t.status(400).json(u(
148
148
  "No measures or dimensions specified",
149
149
  400
150
150
  ));
151
- const l = s.split(".")[0], j = await i.generateSQL(l, o, a);
152
- t.json(H(o, j));
151
+ const f = s.split(".")[0], b = await i.generateSQL(f, o, a);
152
+ t.json(H(o, b));
153
153
  } catch (e) {
154
- console.error("SQL generation error:", e), t.status(500).json(d(
154
+ console.error("SQL generation error:", e), t.status(500).json(u(
155
155
  e instanceof Error ? e.message : "SQL generation failed",
156
156
  500
157
157
  ));
158
158
  }
159
- }), u.post(`${p}/dry-run`, async (r, t) => {
159
+ }), c.post(`${p}/dry-run`, async (r, t) => {
160
160
  try {
161
161
  const e = r.body.query || r.body, o = await y(r, t), a = await M(e, o, i);
162
162
  t.json(a);
@@ -166,7 +166,7 @@ function W(h) {
166
166
  valid: !1
167
167
  });
168
168
  }
169
- }), u.get(`${p}/dry-run`, async (r, t) => {
169
+ }), c.get(`${p}/dry-run`, async (r, t) => {
170
170
  try {
171
171
  const e = r.query.query;
172
172
  if (!e)
@@ -182,7 +182,7 @@ function W(h) {
182
182
  valid: !1
183
183
  });
184
184
  }
185
- }), u.post(`${p}/explain`, async (r, t) => {
185
+ }), c.post(`${p}/explain`, async (r, t) => {
186
186
  try {
187
187
  const e = r.body.query || r.body, o = r.body.options || {}, a = await y(r, t), n = i.validateQuery(e);
188
188
  if (!n.isValid)
@@ -196,47 +196,50 @@ function W(h) {
196
196
  error: e instanceof Error ? e.message : "Explain query failed"
197
197
  });
198
198
  }
199
- }), g && u.post(`${p}/agent/chat`, async (r, t) => {
199
+ }), m && c.post(`${p}/agent/chat`, async (r, t) => {
200
200
  try {
201
- const { handleAgentChat: e } = await import("../handler-CbDMdSY5.js"), { message: o, sessionId: a, history: n } = r.body;
201
+ const { handleAgentChat: e } = await import("../handler-9Rdn7zM2.js"), { message: o, sessionId: a, history: n } = r.body;
202
202
  if (!o || typeof o != "string")
203
203
  return t.status(400).json({ error: "message is required and must be a string" });
204
- let s = (g.apiKey || "").trim();
205
- if (g.allowClientApiKey) {
206
- const c = r.headers["x-agent-api-key"];
207
- c && (s = c.trim());
204
+ let s = (m.apiKey || "").trim();
205
+ if (m.allowClientApiKey) {
206
+ const l = r.headers["x-agent-api-key"];
207
+ l && (s = l.trim());
208
208
  }
209
209
  if (!s)
210
210
  return t.status(401).json({
211
211
  error: "No API key configured. Set agent.apiKey in server config or send X-Agent-Api-Key header."
212
212
  });
213
- const l = await y(r, t), j = g.buildSystemContext?.(l);
213
+ const f = m.allowClientApiKey ? r.headers["x-agent-provider"] : void 0, b = m.allowClientApiKey ? r.headers["x-agent-model"] : void 0, d = m.allowClientApiKey ? r.headers["x-agent-provider-endpoint"] : void 0, g = await y(r, t), j = m.buildSystemContext?.(g);
214
214
  t.writeHead(200, {
215
215
  "Content-Type": "text/event-stream",
216
216
  "Cache-Control": "no-cache",
217
217
  Connection: "keep-alive"
218
218
  });
219
219
  try {
220
- const c = e({
220
+ const l = e({
221
221
  message: o,
222
222
  sessionId: a,
223
223
  history: n,
224
224
  semanticLayer: i,
225
- securityContext: l,
226
- agentConfig: g,
225
+ securityContext: g,
226
+ agentConfig: m,
227
227
  apiKey: s,
228
- systemContext: j
228
+ systemContext: j,
229
+ providerOverride: f,
230
+ modelOverride: b,
231
+ baseURLOverride: d
229
232
  });
230
- for await (const f of c)
231
- t.write(`data: ${JSON.stringify(f)}
233
+ for await (const C of l)
234
+ t.write(`data: ${JSON.stringify(C)}
232
235
 
233
236
  `);
234
- } catch (c) {
235
- const f = {
237
+ } catch (l) {
238
+ const C = {
236
239
  type: "error",
237
- data: { message: c instanceof Error ? c.message : "Stream failed" }
240
+ data: { message: l instanceof Error ? l.message : "Stream failed" }
238
241
  };
239
- t.write(`data: ${JSON.stringify(f)}
242
+ t.write(`data: ${JSON.stringify(C)}
240
243
 
241
244
  `);
242
245
  } finally {
@@ -247,18 +250,18 @@ function W(h) {
247
250
  error: e instanceof Error ? e.message : "Agent chat failed"
248
251
  });
249
252
  }
250
- }), v.enabled !== !1) {
251
- const r = v.basePath ?? "/mcp";
252
- u.post(`${r}`, async (t, e) => {
253
- const o = _(
253
+ }), w.enabled !== !1) {
254
+ const r = w.basePath ?? "/mcp";
255
+ c.post(`${r}`, async (t, e) => {
256
+ const o = D(
254
257
  t.headers.origin,
255
- v.allowedOrigins ? { allowedOrigins: v.allowedOrigins } : {}
258
+ w.allowedOrigins ? { allowedOrigins: w.allowedOrigins } : {}
256
259
  );
257
260
  if (!o.valid)
258
- return e.status(403).json(w(null, -32600, o.reason));
261
+ return e.status(403).json(x(null, -32600, o.reason));
259
262
  const a = t.headers.accept;
260
- if (!K(a))
261
- return e.status(400).json(w(null, -32600, "Accept header must include both application/json and text/event-stream"));
263
+ if (!_(a))
264
+ return e.status(400).json(x(null, -32600, "Accept header must include both application/json and text/event-stream"));
262
265
  const n = V(t.headers);
263
266
  if (!n.ok)
264
267
  return e.status(426).json({
@@ -267,10 +270,10 @@ function W(h) {
267
270
  });
268
271
  const s = z(t.body);
269
272
  if (!s)
270
- return e.status(400).json(w(null, -32600, "Invalid JSON-RPC 2.0 request"));
271
- const l = T(a), j = s.method === "initialize";
273
+ return e.status(400).json(x(null, -32600, "Invalid JSON-RPC 2.0 request"));
274
+ const f = T(a), b = s.method === "initialize";
272
275
  try {
273
- const c = await B(
276
+ const d = await B(
274
277
  s.method,
275
278
  s.params,
276
279
  {
@@ -281,34 +284,34 @@ function W(h) {
281
284
  negotiatedProtocol: n.negotiated
282
285
  }
283
286
  );
284
- if (P(s))
287
+ if (I(s))
285
288
  return e.status(202).end();
286
- const f = j && c && typeof c == "object" && "sessionId" in c ? c.sessionId : void 0;
287
- f && e.setHeader(F, f);
288
- const C = U(s.id ?? null, c);
289
- if (l) {
290
- const b = S();
291
- return e.status(200), e.setHeader("Content-Type", "text/event-stream"), e.setHeader("Cache-Control", "no-cache"), e.setHeader("Connection", "keep-alive"), e.write(`id: ${b}
289
+ const g = b && d && typeof d == "object" && "sessionId" in d ? d.sessionId : void 0;
290
+ g && e.setHeader(U, g);
291
+ const j = F(s.id ?? null, d);
292
+ if (f) {
293
+ const l = Q();
294
+ return e.status(200), e.setHeader("Content-Type", "text/event-stream"), e.setHeader("Cache-Control", "no-cache"), e.setHeader("Connection", "keep-alive"), e.write(`id: ${l}
292
295
 
293
- `), e.write(Q(C, b)), e.end();
296
+ `), e.write(E(j, l)), e.end();
294
297
  }
295
- return e.json(C);
296
- } catch (c) {
297
- if (P(s))
298
- return console.error("MCP notification processing error:", c), e.status(202).end();
299
- console.error("MCP RPC error:", c);
300
- const f = c?.code ?? -32603, C = c?.data, b = c.message || "MCP request failed", q = w(s.id ?? null, f, b, C);
301
- if (l) {
302
- const I = S();
303
- return e.status(200), e.setHeader("Content-Type", "text/event-stream"), e.setHeader("Cache-Control", "no-cache"), e.setHeader("Connection", "keep-alive"), e.write(`id: ${I}
298
+ return e.json(j);
299
+ } catch (d) {
300
+ if (I(s))
301
+ return console.error("MCP notification processing error:", d), e.status(202).end();
302
+ console.error("MCP RPC error:", d);
303
+ const g = d?.code ?? -32603, j = d?.data, l = d.message || "MCP request failed", C = x(s.id ?? null, g, l, j);
304
+ if (f) {
305
+ const q = Q();
306
+ return e.status(200), e.setHeader("Content-Type", "text/event-stream"), e.setHeader("Cache-Control", "no-cache"), e.setHeader("Connection", "keep-alive"), e.write(`id: ${q}
304
307
 
305
- `), e.write(Q(q, I)), e.end();
308
+ `), e.write(E(C, q)), e.end();
306
309
  }
307
- return e.status(200).json(q);
310
+ return e.status(200).json(C);
308
311
  }
309
- }), u.get(`${r}`, async (t, e) => {
310
- const o = S();
311
- e.status(200), e.setHeader("Content-Type", "text/event-stream"), e.setHeader("Cache-Control", "no-cache"), e.setHeader("Connection", "keep-alive"), e.write(Q({
312
+ }), c.get(`${r}`, async (t, e) => {
313
+ const o = Q();
314
+ e.status(200), e.setHeader("Content-Type", "text/event-stream"), e.setHeader("Cache-Control", "no-cache"), e.setHeader("Connection", "keep-alive"), e.write(E({
312
315
  jsonrpc: "2.0",
313
316
  method: "mcp/ready",
314
317
  params: { protocol: "streamable-http" }
@@ -321,19 +324,19 @@ function W(h) {
321
324
  t.on("close", () => {
322
325
  clearInterval(a);
323
326
  });
324
- }), u.delete(`${r}`, (t, e) => e.status(405).json({ error: "Session termination not supported" }));
327
+ }), c.delete(`${r}`, (t, e) => e.status(405).json({ error: "Session termination not supported" }));
325
328
  }
326
- return u.use((r, t, e, o) => {
327
- console.error("Express adapter error:", r), e.headersSent || e.status(500).json(d(r, 500));
328
- }), u;
329
+ return c.use((r, t, e, o) => {
330
+ console.error("Express adapter error:", r), e.headersSent || e.status(500).json(u(r, 500));
331
+ }), c;
329
332
  }
330
- function Y(h, m) {
331
- const x = W(m);
332
- return h.use("/", x), h;
333
+ function Y(v, h) {
334
+ const S = W(h);
335
+ return v.use("/", S), v;
333
336
  }
334
- function oe(h) {
335
- const m = E();
336
- return Y(m, h);
337
+ function oe(v) {
338
+ const h = R();
339
+ return Y(h, v);
337
340
  }
338
341
  export {
339
342
  oe as createCubeApp,