drizzle-cube 0.4.13 → 0.4.14

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 (116) hide show
  1. package/README.md +1 -0
  2. package/dist/adapters/express/index.cjs +6 -6
  3. package/dist/adapters/express/index.js +73 -72
  4. package/dist/adapters/fastify/index.cjs +5 -5
  5. package/dist/adapters/fastify/index.js +110 -109
  6. package/dist/adapters/{handler-CQkIwtxp.js → handler-DZnCbydH.js} +719 -272
  7. package/dist/adapters/handler-ZDYlokiM.cjs +25 -0
  8. package/dist/adapters/hono/index.cjs +6 -6
  9. package/dist/adapters/hono/index.js +121 -120
  10. package/dist/adapters/nextjs/index.cjs +5 -5
  11. package/dist/adapters/nextjs/index.js +92 -91
  12. package/dist/client/charts.js +67 -59
  13. package/dist/client/charts.js.map +1 -1
  14. package/dist/client/chunks/{RetentionCombinedChart-CEI8KQ3t.js → RetentionCombinedChart-CLq89aOJ.js} +2 -2
  15. package/dist/client/chunks/{RetentionCombinedChart-CEI8KQ3t.js.map → RetentionCombinedChart-CLq89aOJ.js.map} +1 -1
  16. package/dist/client/chunks/{analysis-builder-BMmWeFPr.js → analysis-builder-C5e52Z3p.js} +419 -411
  17. package/dist/client/chunks/analysis-builder-C5e52Z3p.js.map +1 -0
  18. package/dist/client/chunks/{analysis-builder-shared-D56zYeV0.js → analysis-builder-shared-EnM-8plh.js} +2 -2
  19. package/dist/client/chunks/{analysis-builder-shared-D56zYeV0.js.map → analysis-builder-shared-EnM-8plh.js.map} +1 -1
  20. package/dist/client/chunks/{chart-activity-grid-CE7xGFQo.js → chart-activity-grid-CPGcTSuh.js} +2 -2
  21. package/dist/client/chunks/{chart-activity-grid-CE7xGFQo.js.map → chart-activity-grid-CPGcTSuh.js.map} +1 -1
  22. package/dist/client/chunks/{chart-area-BJAgusst.js → chart-area-ByJQ7NZd.js} +3 -3
  23. package/dist/client/chunks/{chart-area-BJAgusst.js.map → chart-area-ByJQ7NZd.js.map} +1 -1
  24. package/dist/client/chunks/{chart-bar-Blypx8O4.js → chart-bar-dj14frMt.js} +2 -2
  25. package/dist/client/chunks/{chart-bar-Blypx8O4.js.map → chart-bar-dj14frMt.js.map} +1 -1
  26. package/dist/client/chunks/chart-box-plot-ZatBpatq.js +322 -0
  27. package/dist/client/chunks/chart-box-plot-ZatBpatq.js.map +1 -0
  28. package/dist/client/chunks/{chart-bubble-Bf42A1-B.js → chart-bubble-CemotLx-.js} +2 -2
  29. package/dist/client/chunks/{chart-bubble-Bf42A1-B.js.map → chart-bubble-CemotLx-.js.map} +1 -1
  30. package/dist/client/chunks/chart-candlestick-BIR4uGGt.js +269 -0
  31. package/dist/client/chunks/chart-candlestick-BIR4uGGt.js.map +1 -0
  32. package/dist/client/chunks/chart-config-box-plot-D_E_SSc2.js +38 -0
  33. package/dist/client/chunks/chart-config-box-plot-D_E_SSc2.js.map +1 -0
  34. package/dist/client/chunks/chart-config-candlestick-CRCpD43-.js +70 -0
  35. package/dist/client/chunks/chart-config-candlestick-CRCpD43-.js.map +1 -0
  36. package/dist/client/chunks/chart-config-gauge-CQx9w3d4.js +64 -0
  37. package/dist/client/chunks/chart-config-gauge-CQx9w3d4.js.map +1 -0
  38. package/dist/client/chunks/chart-config-measure-profile-ZYaMrtws.js +70 -0
  39. package/dist/client/chunks/chart-config-measure-profile-ZYaMrtws.js.map +1 -0
  40. package/dist/client/chunks/chart-config-waterfall-DTyXV_fo.js +60 -0
  41. package/dist/client/chunks/chart-config-waterfall-DTyXV_fo.js.map +1 -0
  42. package/dist/client/chunks/{chart-data-table-Ba_6tuJw.js → chart-data-table-D5G8nMnb.js} +2 -2
  43. package/dist/client/chunks/{chart-data-table-Ba_6tuJw.js.map → chart-data-table-D5G8nMnb.js.map} +1 -1
  44. package/dist/client/chunks/{chart-funnel-C9kenCpp.js → chart-funnel-dofnhD24.js} +2 -2
  45. package/dist/client/chunks/{chart-funnel-C9kenCpp.js.map → chart-funnel-dofnhD24.js.map} +1 -1
  46. package/dist/client/chunks/chart-gauge-CKJJ8m3b.js +374 -0
  47. package/dist/client/chunks/chart-gauge-CKJJ8m3b.js.map +1 -0
  48. package/dist/client/chunks/{chart-heat-map-CYGemyPB.js → chart-heat-map-BVuPUKHT.js} +2 -2
  49. package/dist/client/chunks/{chart-heat-map-CYGemyPB.js.map → chart-heat-map-BVuPUKHT.js.map} +1 -1
  50. package/dist/client/chunks/{chart-kpi-delta-D9XJoKuA.js → chart-kpi-delta-Dgg2eYRl.js} +3 -3
  51. package/dist/client/chunks/{chart-kpi-delta-D9XJoKuA.js.map → chart-kpi-delta-Dgg2eYRl.js.map} +1 -1
  52. package/dist/client/chunks/{chart-kpi-number-C29Vj2g8.js → chart-kpi-number-DkoO99c1.js} +2 -2
  53. package/dist/client/chunks/{chart-kpi-number-C29Vj2g8.js.map → chart-kpi-number-DkoO99c1.js.map} +1 -1
  54. package/dist/client/chunks/{chart-kpi-text-CgjjrurK.js → chart-kpi-text-1O6_lmz7.js} +3 -3
  55. package/dist/client/chunks/{chart-kpi-text-CgjjrurK.js.map → chart-kpi-text-1O6_lmz7.js.map} +1 -1
  56. package/dist/client/chunks/{chart-line-zi6olZet.js → chart-line-DzyZkugh.js} +3 -3
  57. package/dist/client/chunks/{chart-line-zi6olZet.js.map → chart-line-DzyZkugh.js.map} +1 -1
  58. package/dist/client/chunks/chart-measure-profile-C2IkBG3V.js +114 -0
  59. package/dist/client/chunks/chart-measure-profile-C2IkBG3V.js.map +1 -0
  60. package/dist/client/chunks/{chart-pie-C4SuxKSN.js → chart-pie-akbfRfb9.js} +2 -2
  61. package/dist/client/chunks/{chart-pie-C4SuxKSN.js.map → chart-pie-akbfRfb9.js.map} +1 -1
  62. package/dist/client/chunks/{chart-radar-BW3Z_-Ly.js → chart-radar-BaN-Kjww.js} +2 -2
  63. package/dist/client/chunks/{chart-radar-BW3Z_-Ly.js.map → chart-radar-BaN-Kjww.js.map} +1 -1
  64. package/dist/client/chunks/{chart-radial-bar-0Fa3aeP5.js → chart-radial-bar-DpptEL3s.js} +2 -2
  65. package/dist/client/chunks/{chart-radial-bar-0Fa3aeP5.js.map → chart-radial-bar-DpptEL3s.js.map} +1 -1
  66. package/dist/client/chunks/{chart-sankey-DBghfbg1.js → chart-sankey-CG-3hHmX.js} +2 -2
  67. package/dist/client/chunks/{chart-sankey-DBghfbg1.js.map → chart-sankey-CG-3hHmX.js.map} +1 -1
  68. package/dist/client/chunks/{chart-scatter-DOVu1TNq.js → chart-scatter-l_yTVxF3.js} +2 -2
  69. package/dist/client/chunks/{chart-scatter-DOVu1TNq.js.map → chart-scatter-l_yTVxF3.js.map} +1 -1
  70. package/dist/client/chunks/{chart-sunburst-LfNthFlZ.js → chart-sunburst-KhDcKhmZ.js} +2 -2
  71. package/dist/client/chunks/{chart-sunburst-LfNthFlZ.js.map → chart-sunburst-KhDcKhmZ.js.map} +1 -1
  72. package/dist/client/chunks/{chart-tree-map-DZtQPyWX.js → chart-tree-map-CBbiaBXV.js} +2 -2
  73. package/dist/client/chunks/{chart-tree-map-DZtQPyWX.js.map → chart-tree-map-CBbiaBXV.js.map} +1 -1
  74. package/dist/client/chunks/chart-waterfall-CX3vx_lI.js +191 -0
  75. package/dist/client/chunks/chart-waterfall-CX3vx_lI.js.map +1 -0
  76. package/dist/client/chunks/{charts-core-DmGfleFz.js → charts-core-CU9u_HtL.js} +2 -1
  77. package/dist/client/chunks/charts-core-CU9u_HtL.js.map +1 -0
  78. package/dist/client/chunks/{charts-loader-CH0_S06T.js → charts-loader-AW3T1nv5.js} +58 -42
  79. package/dist/client/chunks/charts-loader-AW3T1nv5.js.map +1 -0
  80. package/dist/client/chunks/{components-ClQziOcT.js → components-BkeSy9xv.js} +4 -4
  81. package/dist/client/chunks/components-BkeSy9xv.js.map +1 -0
  82. package/dist/client/components/AgenticNotebook/AgentChatPanel.d.ts +10 -0
  83. package/dist/client/components/AgenticNotebook/ChatMessage.d.ts +2 -0
  84. package/dist/client/components/AgenticNotebook/index.d.ts +11 -1
  85. package/dist/client/components/LoadingIndicator.d.ts +2 -2
  86. package/dist/client/components/charts/BoxPlotChart.config.d.ts +1 -7
  87. package/dist/client/components/charts/CandlestickChart.config.d.ts +5 -0
  88. package/dist/client/components/charts/CandlestickChart.d.ts +4 -0
  89. package/dist/client/components/charts/GaugeChart.config.d.ts +5 -0
  90. package/dist/client/components/charts/GaugeChart.d.ts +4 -0
  91. package/dist/client/components/charts/MeasureProfileChart.config.d.ts +5 -0
  92. package/dist/client/components/charts/MeasureProfileChart.d.ts +4 -0
  93. package/dist/client/components/charts/WaterfallChart.config.d.ts +5 -0
  94. package/dist/client/components/charts/WaterfallChart.d.ts +4 -0
  95. package/dist/client/components/charts/index.d.ts +4 -0
  96. package/dist/client/components.js +1 -1
  97. package/dist/client/hooks/useAgentChat.d.ts +20 -2
  98. package/dist/client/index.js +583 -522
  99. package/dist/client/index.js.map +1 -1
  100. package/dist/client/styles.css +1 -1
  101. package/dist/client/types.d.ts +19 -1
  102. package/dist/client/utils.js +4 -4
  103. package/dist/client-bundle-stats.html +1 -1
  104. package/dist/server/index.cjs +47 -45
  105. package/dist/server/index.d.ts +37 -0
  106. package/dist/server/index.js +1745 -1298
  107. package/package.json +4 -1
  108. package/dist/adapters/handler-dnkqpznh.cjs +0 -23
  109. package/dist/client/chunks/analysis-builder-BMmWeFPr.js.map +0 -1
  110. package/dist/client/chunks/chart-box-plot-Dja4LS3O.js +0 -313
  111. package/dist/client/chunks/chart-box-plot-Dja4LS3O.js.map +0 -1
  112. package/dist/client/chunks/chart-config-box-plot-D3DA7_pr.js +0 -85
  113. package/dist/client/chunks/chart-config-box-plot-D3DA7_pr.js.map +0 -1
  114. package/dist/client/chunks/charts-core-DmGfleFz.js.map +0 -1
  115. package/dist/client/chunks/charts-loader-CH0_S06T.js.map +0 -1
  116. package/dist/client/chunks/components-ClQziOcT.js.map +0 -1
@@ -1,19 +1,19 @@
1
1
  import { S as D, v as K, b as x, a as T, n as V, p as z, w as _, d as B, i as j, M as F, c as U, e as E, s as P } from "../mcp-transport-m1X1GtwG.js";
2
- import { formatErrorResponse as d, formatCubeResponse as A, handleBatchRequest as X, formatMetaResponse as G, formatSqlResponse as I, handleDryRun as M } from "../utils.js";
2
+ import { formatErrorResponse as u, formatCubeResponse as A, handleBatchRequest as X, formatMetaResponse as G, formatSqlResponse as I, handleDryRun as M } from "../utils.js";
3
3
  const N = function(i, k, R) {
4
4
  const {
5
5
  cubes: S,
6
6
  drizzle: O,
7
7
  schema: J,
8
- extractSecurityContext: p,
8
+ extractSecurityContext: y,
9
9
  engineType: L,
10
10
  cors: q,
11
- basePath: m = "/cubejs-api/v1",
12
- bodyLimit: g = 10485760,
11
+ basePath: p = "/cubejs-api/v1",
12
+ bodyLimit: m = 10485760,
13
13
  // 10MB
14
14
  cache: H,
15
- mcp: b = { enabled: !0 },
16
- agent: f
15
+ mcp: f = { enabled: !0 },
16
+ agent: v
17
17
  } = k;
18
18
  if (!S || S.length === 0)
19
19
  return R(new Error("At least one cube must be provided in the cubes array"));
@@ -28,8 +28,8 @@ const N = function(i, k, R) {
28
28
  });
29
29
  if (S.forEach((t) => {
30
30
  c.registerCube(t);
31
- }), i.post(`${m}/load`, {
32
- bodyLimit: g,
31
+ }), i.post(`${p}/load`, {
32
+ bodyLimit: m,
33
33
  schema: {
34
34
  body: {
35
35
  type: "object",
@@ -38,21 +38,21 @@ const N = function(i, k, R) {
38
38
  }
39
39
  }, async (t, r) => {
40
40
  try {
41
- const e = t.body, a = e.query || e, n = await p(t), o = c.validateQuery(a);
42
- if (!o.isValid)
43
- return r.status(400).send(d(
44
- `Query validation failed: ${o.errors.join(", ")}`,
41
+ const e = t.body, a = e.query || e, n = await y(t), s = c.validateQuery(a);
42
+ if (!s.isValid)
43
+ return r.status(400).send(u(
44
+ `Query validation failed: ${s.errors.join(", ")}`,
45
45
  400
46
46
  ));
47
- const s = t.headers["x-cache-control"] === "no-cache", l = await c.executeMultiCubeQuery(a, n, { skipCache: s });
47
+ const o = t.headers["x-cache-control"] === "no-cache", l = await c.executeMultiCubeQuery(a, n, { skipCache: o });
48
48
  return A(a, l, c);
49
49
  } catch (e) {
50
- return t.log.error(e, "Query execution error"), r.status(500).send(d(
50
+ return t.log.error(e, "Query execution error"), r.status(500).send(u(
51
51
  e instanceof Error ? e.message : "Query execution failed",
52
52
  500
53
53
  ));
54
54
  }
55
- }), i.get(`${m}/load`, {
55
+ }), i.get(`${p}/load`, {
56
56
  schema: {
57
57
  querystring: {
58
58
  type: "object",
@@ -69,27 +69,27 @@ const N = function(i, k, R) {
69
69
  try {
70
70
  a = JSON.parse(e);
71
71
  } catch {
72
- return r.status(400).send(d(
72
+ return r.status(400).send(u(
73
73
  "Invalid JSON in query parameter",
74
74
  400
75
75
  ));
76
76
  }
77
- const n = await p(t), o = c.validateQuery(a);
78
- if (!o.isValid)
79
- return r.status(400).send(d(
80
- `Query validation failed: ${o.errors.join(", ")}`,
77
+ const n = await y(t), s = c.validateQuery(a);
78
+ if (!s.isValid)
79
+ return r.status(400).send(u(
80
+ `Query validation failed: ${s.errors.join(", ")}`,
81
81
  400
82
82
  ));
83
- const s = t.headers["x-cache-control"] === "no-cache", l = await c.executeMultiCubeQuery(a, n, { skipCache: s });
83
+ const o = t.headers["x-cache-control"] === "no-cache", l = await c.executeMultiCubeQuery(a, n, { skipCache: o });
84
84
  return A(a, l, c);
85
85
  } catch (e) {
86
- return t.log.error(e, "Query execution error"), r.status(500).send(d(
86
+ return t.log.error(e, "Query execution error"), r.status(500).send(u(
87
87
  e instanceof Error ? e.message : "Query execution failed",
88
88
  500
89
89
  ));
90
90
  }
91
- }), i.post(`${m}/batch`, {
92
- bodyLimit: g,
91
+ }), i.post(`${p}/batch`, {
92
+ bodyLimit: m,
93
93
  schema: {
94
94
  body: {
95
95
  type: "object",
@@ -106,35 +106,35 @@ const N = function(i, k, R) {
106
106
  try {
107
107
  const { queries: e } = t.body;
108
108
  if (!e || !Array.isArray(e))
109
- return r.status(400).send(d(
109
+ return r.status(400).send(u(
110
110
  'Request body must contain a "queries" array',
111
111
  400
112
112
  ));
113
113
  if (e.length === 0)
114
- return r.status(400).send(d(
114
+ return r.status(400).send(u(
115
115
  "Queries array cannot be empty",
116
116
  400
117
117
  ));
118
- const a = await p(t), n = t.headers["x-cache-control"] === "no-cache";
118
+ const a = await y(t), n = t.headers["x-cache-control"] === "no-cache";
119
119
  return await X(e, a, c, { skipCache: n });
120
120
  } catch (e) {
121
- return t.log.error(e, "Batch execution error"), r.status(500).send(d(
121
+ return t.log.error(e, "Batch execution error"), r.status(500).send(u(
122
122
  e instanceof Error ? e.message : "Batch execution failed",
123
123
  500
124
124
  ));
125
125
  }
126
- }), i.get(`${m}/meta`, async (t, r) => {
126
+ }), i.get(`${p}/meta`, async (t, r) => {
127
127
  try {
128
128
  const e = c.getMetadata();
129
129
  return G(e);
130
130
  } catch (e) {
131
- return t.log.error(e, "Metadata error"), r.status(500).send(d(
131
+ return t.log.error(e, "Metadata error"), r.status(500).send(u(
132
132
  e instanceof Error ? e.message : "Failed to fetch metadata",
133
133
  500
134
134
  ));
135
135
  }
136
- }), i.post(`${m}/sql`, {
137
- bodyLimit: g,
136
+ }), i.post(`${p}/sql`, {
137
+ bodyLimit: m,
138
138
  schema: {
139
139
  body: {
140
140
  type: "object",
@@ -143,27 +143,27 @@ const N = function(i, k, R) {
143
143
  }
144
144
  }, async (t, r) => {
145
145
  try {
146
- const e = t.body, a = await p(t), n = c.validateQuery(e);
146
+ const e = t.body, a = await y(t), n = c.validateQuery(e);
147
147
  if (!n.isValid)
148
- return r.status(400).send(d(
148
+ return r.status(400).send(u(
149
149
  `Query validation failed: ${n.errors.join(", ")}`,
150
150
  400
151
151
  ));
152
- const o = e.measures?.[0] || e.dimensions?.[0];
153
- if (!o)
154
- return r.status(400).send(d(
152
+ const s = e.measures?.[0] || e.dimensions?.[0];
153
+ if (!s)
154
+ return r.status(400).send(u(
155
155
  "No measures or dimensions specified",
156
156
  400
157
157
  ));
158
- const s = o.split(".")[0], l = await c.generateSQL(s, e, a);
158
+ const o = s.split(".")[0], l = await c.generateSQL(o, e, a);
159
159
  return I(e, l);
160
160
  } catch (e) {
161
- return t.log.error(e, "SQL generation error"), r.status(500).send(d(
161
+ return t.log.error(e, "SQL generation error"), r.status(500).send(u(
162
162
  e instanceof Error ? e.message : "SQL generation failed",
163
163
  500
164
164
  ));
165
165
  }
166
- }), i.get(`${m}/sql`, {
166
+ }), i.get(`${p}/sql`, {
167
167
  schema: {
168
168
  querystring: {
169
169
  type: "object",
@@ -175,28 +175,28 @@ const N = function(i, k, R) {
175
175
  }
176
176
  }, async (t, r) => {
177
177
  try {
178
- const { query: e } = t.query, a = JSON.parse(e), n = await p(t), o = c.validateQuery(a);
179
- if (!o.isValid)
180
- return r.status(400).send(d(
181
- `Query validation failed: ${o.errors.join(", ")}`,
178
+ const { query: e } = t.query, a = JSON.parse(e), n = await y(t), s = c.validateQuery(a);
179
+ if (!s.isValid)
180
+ return r.status(400).send(u(
181
+ `Query validation failed: ${s.errors.join(", ")}`,
182
182
  400
183
183
  ));
184
- const s = a.measures?.[0] || a.dimensions?.[0];
185
- if (!s)
186
- return r.status(400).send(d(
184
+ const o = a.measures?.[0] || a.dimensions?.[0];
185
+ if (!o)
186
+ return r.status(400).send(u(
187
187
  "No measures or dimensions specified",
188
188
  400
189
189
  ));
190
- const l = s.split(".")[0], y = await c.generateSQL(l, a, n);
191
- return I(a, y);
190
+ const l = o.split(".")[0], g = await c.generateSQL(l, a, n);
191
+ return I(a, g);
192
192
  } catch (e) {
193
- return t.log.error(e, "SQL generation error"), r.status(500).send(d(
193
+ return t.log.error(e, "SQL generation error"), r.status(500).send(u(
194
194
  e instanceof Error ? e.message : "SQL generation failed",
195
195
  500
196
196
  ));
197
197
  }
198
- }), i.post(`${m}/dry-run`, {
199
- bodyLimit: g,
198
+ }), i.post(`${p}/dry-run`, {
199
+ bodyLimit: m,
200
200
  schema: {
201
201
  body: {
202
202
  type: "object",
@@ -205,7 +205,7 @@ const N = function(i, k, R) {
205
205
  }
206
206
  }, async (t, r) => {
207
207
  try {
208
- const e = t.body, a = e.query || e, n = await p(t);
208
+ const e = t.body, a = e.query || e, n = await y(t);
209
209
  return await M(a, n, c);
210
210
  } catch (e) {
211
211
  return t.log.error(e, "Dry-run error"), r.status(400).send({
@@ -213,7 +213,7 @@ const N = function(i, k, R) {
213
213
  valid: !1
214
214
  });
215
215
  }
216
- }), i.get(`${m}/dry-run`, {
216
+ }), i.get(`${p}/dry-run`, {
217
217
  schema: {
218
218
  querystring: {
219
219
  type: "object",
@@ -225,7 +225,7 @@ const N = function(i, k, R) {
225
225
  }
226
226
  }, async (t, r) => {
227
227
  try {
228
- const { query: e } = t.query, a = JSON.parse(e), n = await p(t);
228
+ const { query: e } = t.query, a = JSON.parse(e), n = await y(t);
229
229
  return await M(a, n, c);
230
230
  } catch (e) {
231
231
  return t.log.error(e, "Dry-run error"), r.status(400).send({
@@ -233,8 +233,8 @@ const N = function(i, k, R) {
233
233
  valid: !1
234
234
  });
235
235
  }
236
- }), i.post(`${m}/explain`, {
237
- bodyLimit: g,
236
+ }), i.post(`${p}/explain`, {
237
+ bodyLimit: m,
238
238
  schema: {
239
239
  body: {
240
240
  type: "object",
@@ -243,17 +243,17 @@ const N = function(i, k, R) {
243
243
  }
244
244
  }, async (t, r) => {
245
245
  try {
246
- const e = t.body, a = e.query || e, n = e.options || {}, o = await p(t), s = c.validateQuery(a);
247
- return s.isValid ? await c.explainQuery(a, o, n) : r.status(400).send({
248
- error: `Query validation failed: ${s.errors.join(", ")}`
246
+ const e = t.body, a = e.query || e, n = e.options || {}, s = await y(t), o = c.validateQuery(a);
247
+ return o.isValid ? await c.explainQuery(a, s, n) : r.status(400).send({
248
+ error: `Query validation failed: ${o.errors.join(", ")}`
249
249
  });
250
250
  } catch (e) {
251
251
  return t.log.error(e, "Explain error"), r.status(500).send({
252
252
  error: e instanceof Error ? e.message : "Explain query failed"
253
253
  });
254
254
  }
255
- }), f && i.post(`${m}/agent/chat`, {
256
- bodyLimit: g,
255
+ }), v && i.post(`${p}/agent/chat`, {
256
+ bodyLimit: m,
257
257
  schema: {
258
258
  body: {
259
259
  type: "object",
@@ -262,43 +262,44 @@ const N = function(i, k, R) {
262
262
  }
263
263
  }, async (t, r) => {
264
264
  try {
265
- const { handleAgentChat: e } = await import("../handler-CQkIwtxp.js"), a = t.body, { message: n, sessionId: o } = a;
265
+ const { handleAgentChat: e } = await import("../handler-DZnCbydH.js"), a = t.body, { message: n, sessionId: s, history: o } = a;
266
266
  if (!n || typeof n != "string")
267
267
  return r.status(400).send({ error: "message is required and must be a string" });
268
- let s = (f.apiKey || "").trim();
269
- if (f.allowClientApiKey) {
270
- const y = t.headers["x-agent-api-key"];
271
- y && (s = y.trim());
268
+ let l = (v.apiKey || "").trim();
269
+ if (v.allowClientApiKey) {
270
+ const d = t.headers["x-agent-api-key"];
271
+ d && (l = d.trim());
272
272
  }
273
- if (!s)
273
+ if (!l)
274
274
  return r.status(401).send({
275
275
  error: "No API key configured. Set agent.apiKey in server config or send X-Agent-Api-Key header."
276
276
  });
277
- const l = await p(t);
277
+ const g = await y(t);
278
278
  r.raw.writeHead(200, {
279
279
  "Content-Type": "text/event-stream",
280
280
  "Cache-Control": "no-cache",
281
281
  Connection: "keep-alive"
282
282
  });
283
283
  try {
284
- const y = e({
284
+ const d = e({
285
285
  message: n,
286
- sessionId: o,
286
+ sessionId: s,
287
+ history: o,
287
288
  semanticLayer: c,
288
- securityContext: l,
289
- agentConfig: f,
290
- apiKey: s
289
+ securityContext: g,
290
+ agentConfig: v,
291
+ apiKey: l
291
292
  });
292
- for await (const u of y)
293
- r.raw.write(`data: ${JSON.stringify(u)}
293
+ for await (const h of d)
294
+ r.raw.write(`data: ${JSON.stringify(h)}
294
295
 
295
296
  `);
296
- } catch (y) {
297
- const u = {
297
+ } catch (d) {
298
+ const h = {
298
299
  type: "error",
299
- data: { message: y instanceof Error ? y.message : "Stream failed" }
300
+ data: { message: d instanceof Error ? d.message : "Stream failed" }
300
301
  };
301
- r.raw.write(`data: ${JSON.stringify(u)}
302
+ r.raw.write(`data: ${JSON.stringify(h)}
302
303
 
303
304
  `);
304
305
  } finally {
@@ -310,10 +311,10 @@ const N = function(i, k, R) {
310
311
  error: e instanceof Error ? e.message : "Agent chat failed"
311
312
  });
312
313
  }
313
- }), b.enabled !== !1) {
314
- const t = b.basePath ?? "/mcp";
314
+ }), f.enabled !== !1) {
315
+ const t = f.basePath ?? "/mcp";
315
316
  i.post(`${t}`, {
316
- bodyLimit: g,
317
+ bodyLimit: m,
317
318
  schema: {
318
319
  body: {
319
320
  type: "object",
@@ -323,40 +324,40 @@ const N = function(i, k, R) {
323
324
  }, async (r, e) => {
324
325
  const a = K(
325
326
  r.headers.origin,
326
- b.allowedOrigins ? { allowedOrigins: b.allowedOrigins } : {}
327
+ f.allowedOrigins ? { allowedOrigins: f.allowedOrigins } : {}
327
328
  );
328
329
  if (!a.valid)
329
330
  return e.status(403).send(x(null, -32600, a.reason));
330
331
  const n = r.headers.accept;
331
332
  if (!T(n))
332
333
  return e.status(400).send(x(null, -32600, "Accept header must include both application/json and text/event-stream"));
333
- const o = V(r.headers);
334
- if (!o.ok)
334
+ const s = V(r.headers);
335
+ if (!s.ok)
335
336
  return e.status(426).send({
336
337
  error: "Unsupported MCP protocol version",
337
- supported: o.supported
338
+ supported: s.supported
338
339
  });
339
- const s = z(r.body);
340
- if (!s)
340
+ const o = z(r.body);
341
+ if (!o)
341
342
  return e.status(400).send(x(null, -32600, "Invalid JSON-RPC 2.0 request"));
342
- const l = _(n), y = s.method === "initialize";
343
+ const l = _(n), g = o.method === "initialize";
343
344
  try {
344
- const u = await B(
345
- s.method,
346
- s.params,
345
+ const d = await B(
346
+ o.method,
347
+ o.params,
347
348
  {
348
349
  semanticLayer: c,
349
- extractSecurityContext: p,
350
+ extractSecurityContext: y,
350
351
  rawRequest: r,
351
352
  rawResponse: e,
352
- negotiatedProtocol: o.negotiated
353
+ negotiatedProtocol: s.negotiated
353
354
  }
354
355
  );
355
- if (j(s))
356
+ if (j(o))
356
357
  return e.status(202).send();
357
- const v = y && u && typeof u == "object" && "sessionId" in u ? u.sessionId : void 0;
358
- v && e.header(F, v);
359
- const C = U(s.id ?? null, u);
358
+ const h = g && d && typeof d == "object" && "sessionId" in d ? d.sessionId : void 0;
359
+ h && e.header(F, h);
360
+ const C = U(o.id ?? null, d);
360
361
  if (l) {
361
362
  const w = E();
362
363
  e.header("Content-Type", "text/event-stream").header("Cache-Control", "no-cache").header("Connection", "keep-alive").send(`id: ${w}
@@ -365,11 +366,11 @@ ${P(C, w)}`);
365
366
  return;
366
367
  }
367
368
  return e.send(C);
368
- } catch (u) {
369
- if (j(s))
370
- return r.log.error(u, "MCP notification processing error"), e.status(202).send();
371
- r.log.error(u, "MCP RPC error");
372
- const v = u?.code ?? -32603, C = u?.data, w = u.message || "MCP request failed", Q = x(s.id ?? null, v, w, C);
369
+ } catch (d) {
370
+ if (j(o))
371
+ return r.log.error(d, "MCP notification processing error"), e.status(202).send();
372
+ r.log.error(d, "MCP RPC error");
373
+ const h = d?.code ?? -32603, C = d?.data, w = d.message || "MCP request failed", Q = x(o.id ?? null, h, w, C);
373
374
  if (l) {
374
375
  const $ = E();
375
376
  e.header("Content-Type", "text/event-stream").header("Cache-Control", "no-cache").header("Connection", "keep-alive").send(`id: ${$}
@@ -403,17 +404,17 @@ ${P(Q, $)}`);
403
404
  i.setErrorHandler(async (t, r, e) => {
404
405
  r.log.error(t, "Fastify cube adapter error"), e.statusCode < 400 && e.status(500);
405
406
  const a = t instanceof Error ? t : String(t);
406
- return d(a, e.statusCode);
407
+ return u(a, e.statusCode);
407
408
  }), R();
408
409
  };
409
- async function Z(h, i) {
410
- await h.register(N, i);
410
+ async function Z(b, i) {
411
+ await b.register(N, i);
411
412
  }
412
- function ee(h) {
413
+ function ee(b) {
413
414
  const i = require("fastify")({
414
415
  logger: !0
415
416
  });
416
- return i.register(N, h), i;
417
+ return i.register(N, b), i;
417
418
  }
418
419
  export {
419
420
  ee as createCubeApp,