@xpert-ai/plugin-live-dashboard 0.6.2 → 0.7.1

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 (283) hide show
  1. package/.xpertai-plugin/plugin.json +1 -1
  2. package/README.md +14 -2
  3. package/assets/explore/PROVENANCE.md +9 -0
  4. package/assets/explore/category-contribution.webp +0 -0
  5. package/assets/explore/ecommerce-operations.webp +0 -0
  6. package/assets/explore/extensions.svg +1 -0
  7. package/assets/explore/generation-prompts.json +107 -0
  8. package/assets/explore/global-assets.webp +0 -0
  9. package/assets/explore/hotel-cancellation.webp +0 -0
  10. package/assets/explore/hotel-operations.webp +0 -0
  11. package/assets/explore/insights.svg +1 -0
  12. package/assets/explore/knowledge.svg +1 -0
  13. package/assets/explore/legal-defense.webp +0 -0
  14. package/assets/explore/order-promotion.webp +0 -0
  15. package/assets/explore/outbound-travel.webp +0 -0
  16. package/assets/explore/schedule.svg +1 -0
  17. package/assets/explore/steam-market.webp +0 -0
  18. package/assets/explore/weather-alerts.webp +0 -0
  19. package/assets/library/catalog/README.md +11 -0
  20. package/assets/library/catalog/analysis-template-conversion-diagnosis.svg +1 -0
  21. package/assets/library/catalog/analysis-template-customer-lifecycle.svg +1 -0
  22. package/assets/library/catalog/analysis-template-growth-attribution.svg +1 -0
  23. package/assets/library/catalog/analysis-template-multi-criteria.svg +1 -0
  24. package/assets/library/catalog/analysis-template-regional-flow.svg +1 -0
  25. package/assets/library/catalog/analysis-template-risk-monitoring.svg +1 -0
  26. package/assets/library/catalog/component-analysis-note.svg +1 -0
  27. package/assets/library/catalog/component-box-plot.svg +1 -0
  28. package/assets/library/catalog/component-bullet.svg +1 -0
  29. package/assets/library/catalog/component-calendar-heatmap.svg +1 -0
  30. package/assets/library/catalog/component-collapsible-panel.svg +1 -0
  31. package/assets/library/catalog/component-combo-chart.svg +1 -0
  32. package/assets/library/catalog/component-content-panel.svg +1 -0
  33. package/assets/library/catalog/component-date-range.svg +1 -0
  34. package/assets/library/catalog/component-detail-table.svg +1 -0
  35. package/assets/library/catalog/component-donut.svg +1 -0
  36. package/assets/library/catalog/component-dumbbell.svg +1 -0
  37. package/assets/library/catalog/component-event-timeline.svg +1 -0
  38. package/assets/library/catalog/component-funnel.svg +1 -0
  39. package/assets/library/catalog/component-histogram.svg +1 -0
  40. package/assets/library/catalog/component-keyword-filter.svg +1 -0
  41. package/assets/library/catalog/component-matrix-heatmap.svg +1 -0
  42. package/assets/library/catalog/component-metric-card.svg +1 -0
  43. package/assets/library/catalog/component-metric-group.svg +1 -0
  44. package/assets/library/catalog/component-multi-series.svg +1 -0
  45. package/assets/library/catalog/component-number-range.svg +1 -0
  46. package/assets/library/catalog/component-option-filter.svg +1 -0
  47. package/assets/library/catalog/component-pareto.svg +1 -0
  48. package/assets/library/catalog/component-percent-stacked.svg +1 -0
  49. package/assets/library/catalog/component-pivot-table.svg +1 -0
  50. package/assets/library/catalog/component-radar.svg +1 -0
  51. package/assets/library/catalog/component-ranking.svg +1 -0
  52. package/assets/library/catalog/component-sankey.svg +1 -0
  53. package/assets/library/catalog/component-scatter-bubble.svg +1 -0
  54. package/assets/library/catalog/component-segmented-filter.svg +1 -0
  55. package/assets/library/catalog/component-small-multiples.svg +1 -0
  56. package/assets/library/catalog/component-sunburst.svg +1 -0
  57. package/assets/library/catalog/component-tabbed-panel.svg +1 -0
  58. package/assets/library/catalog/component-target-progress.svg +1 -0
  59. package/assets/library/catalog/component-toggle-filter.svg +1 -0
  60. package/assets/library/catalog/component-treemap.svg +1 -0
  61. package/assets/library/catalog/component-trend-comparison.svg +1 -0
  62. package/assets/library/catalog/component-waterfall.svg +1 -0
  63. package/assets/library/catalog/provenance.json +524 -0
  64. package/assets/library/catalog/visual-theme-amber-sunset.svg +1 -0
  65. package/assets/library/catalog/visual-theme-art-deco.svg +1 -0
  66. package/assets/library/catalog/visual-theme-bauhaus.svg +1 -0
  67. package/assets/library/catalog/visual-theme-burgundy-night.svg +1 -0
  68. package/assets/library/catalog/visual-theme-cinematic.svg +1 -0
  69. package/assets/library/catalog/visual-theme-clarity-blue.svg +1 -0
  70. package/assets/library/catalog/visual-theme-clay.svg +1 -0
  71. package/assets/library/catalog/visual-theme-cobalt-diagonal.svg +1 -0
  72. package/assets/library/catalog/visual-theme-coral-cream.svg +1 -0
  73. package/assets/library/catalog/visual-theme-crimson-black.svg +1 -0
  74. package/assets/library/catalog/visual-theme-cyberpunk.svg +1 -0
  75. package/assets/library/catalog/visual-theme-dark-olive.svg +1 -0
  76. package/assets/library/catalog/visual-theme-dark-tech.svg +1 -0
  77. package/assets/library/catalog/visual-theme-deep-sea-blue.svg +1 -0
  78. package/assets/library/catalog/visual-theme-deep-sea-mist.svg +1 -0
  79. package/assets/library/catalog/visual-theme-financial-trading.svg +1 -0
  80. package/assets/library/catalog/visual-theme-flat.svg +1 -0
  81. package/assets/library/catalog/visual-theme-frosted-tech.svg +1 -0
  82. package/assets/library/catalog/visual-theme-golden-eye.svg +1 -0
  83. package/assets/library/catalog/visual-theme-hand-drawn.svg +1 -0
  84. package/assets/library/catalog/visual-theme-industrial.svg +1 -0
  85. package/assets/library/catalog/visual-theme-layered-paper.svg +1 -0
  86. package/assets/library/catalog/visual-theme-material.svg +1 -0
  87. package/assets/library/catalog/visual-theme-maximalism.svg +1 -0
  88. package/assets/library/catalog/visual-theme-midnight-emerald.svg +1 -0
  89. package/assets/library/catalog/visual-theme-minimal-modern.svg +1 -0
  90. package/assets/library/catalog/visual-theme-misty-green.svg +1 -0
  91. package/assets/library/catalog/visual-theme-misty-rose.svg +1 -0
  92. package/assets/library/catalog/visual-theme-natural-terrain.svg +1 -0
  93. package/assets/library/catalog/visual-theme-neo-brutalism.svg +1 -0
  94. package/assets/library/catalog/visual-theme-newsprint.svg +1 -0
  95. package/assets/library/catalog/visual-theme-olive-terracotta.svg +1 -0
  96. package/assets/library/catalog/visual-theme-paper-journal.svg +1 -0
  97. package/assets/library/catalog/visual-theme-pastel-matrix.svg +1 -0
  98. package/assets/library/catalog/visual-theme-pixel-dashboard.svg +1 -0
  99. package/assets/library/catalog/visual-theme-premium-business.svg +1 -0
  100. package/assets/library/catalog/visual-theme-redline-brief.svg +1 -0
  101. package/assets/library/catalog/visual-theme-sage.svg +1 -0
  102. package/assets/library/catalog/visual-theme-soft-porcelain.svg +1 -0
  103. package/assets/library/catalog/visual-theme-swiss-grid.svg +1 -0
  104. package/assets/library/catalog/visual-theme-tdesign-enterprise.svg +1 -0
  105. package/assets/library/catalog/visual-theme-terminal-green.svg +1 -0
  106. package/assets/library/catalog/visual-theme-warm-sand.svg +1 -0
  107. package/dist/lib/agent.schema.d.ts +514 -32
  108. package/dist/lib/analysis-scene-chart.d.ts +8 -0
  109. package/dist/lib/analysis-scene-chart.js +61 -0
  110. package/dist/lib/analysis-scene-tool.d.ts +87 -0
  111. package/dist/lib/analysis-scene-tool.js +33 -0
  112. package/dist/lib/analysis-scene-widget.d.ts +6 -0
  113. package/dist/lib/analysis-scene-widget.js +107 -0
  114. package/dist/lib/analysis-scene.schema.d.ts +66 -0
  115. package/dist/lib/analysis-scene.schema.js +20 -0
  116. package/dist/lib/archive.service.d.ts +35 -0
  117. package/dist/lib/artifact-type.provider.d.ts +1 -0
  118. package/dist/lib/artifact-type.provider.js +18 -0
  119. package/dist/lib/bundled-example-source.d.ts +11 -0
  120. package/dist/lib/bundled-example-source.js +60 -0
  121. package/dist/lib/certification.schema.d.ts +4 -0
  122. package/dist/lib/certification.schema.js +14 -0
  123. package/dist/lib/content-capability.js +1 -0
  124. package/dist/lib/content-type.d.ts +2 -0
  125. package/dist/lib/content-type.js +5 -0
  126. package/dist/lib/content.provider.js +5 -3
  127. package/dist/lib/dashboard-archive.d.ts +35 -0
  128. package/dist/lib/dashboard-artifact.d.ts +93 -0
  129. package/dist/lib/dashboard-artifact.js +24 -0
  130. package/dist/lib/dashboard-delivery.d.ts +11 -0
  131. package/dist/lib/dashboard-delivery.js +55 -0
  132. package/dist/lib/dashboard-discovery.schema.d.ts +446 -0
  133. package/dist/lib/dashboard-discovery.schema.js +35 -0
  134. package/dist/lib/dashboard-navigation.d.ts +22 -21
  135. package/dist/lib/dashboard-navigation.js +5 -4
  136. package/dist/lib/dashboard-queries.d.ts +2 -2
  137. package/dist/lib/dashboard-queries.js +2 -2
  138. package/dist/lib/dashboard-receipt.js +1 -1
  139. package/dist/lib/dashboard-view.schema.d.ts +964 -64
  140. package/dist/lib/dashboard.schema.d.ts +738 -23
  141. package/dist/lib/dashboard.schema.js +8 -2
  142. package/dist/lib/dashboard.service.d.ts +155 -2
  143. package/dist/lib/dashboard.service.js +38 -4
  144. package/dist/lib/dataset-artifact.provider.d.ts +13 -0
  145. package/dist/lib/dataset-artifact.provider.js +57 -0
  146. package/dist/lib/dataset.schema.d.ts +195 -0
  147. package/dist/lib/dataset.schema.js +23 -0
  148. package/dist/lib/dataset.service.d.ts +54 -0
  149. package/dist/lib/dataset.service.js +119 -0
  150. package/dist/lib/definition-tools.d.ts +14 -54
  151. package/dist/lib/definition-tools.js +29 -9
  152. package/dist/lib/document-package.d.ts +35 -0
  153. package/dist/lib/editing.d.ts +552 -2
  154. package/dist/lib/evidence/evidence-diff.d.ts +17 -0
  155. package/dist/lib/evidence/evidence-diff.js +30 -0
  156. package/dist/lib/evidence/evidence-transfers.d.ts +14 -0
  157. package/dist/lib/evidence/evidence-transfers.js +41 -0
  158. package/dist/lib/evidence/evidence-view.provider.d.ts +91 -0
  159. package/dist/lib/evidence/evidence-view.provider.js +92 -0
  160. package/dist/lib/evidence/evidence.entity.d.ts +14 -0
  161. package/dist/lib/evidence/evidence.entity.js +62 -0
  162. package/dist/lib/evidence/evidence.provider.d.ts +43 -0
  163. package/dist/lib/evidence/evidence.provider.js +91 -0
  164. package/dist/lib/evidence/evidence.service.d.ts +67 -0
  165. package/dist/lib/evidence/evidence.service.js +218 -0
  166. package/dist/lib/explore-catalog.d.ts +15 -0
  167. package/dist/lib/explore-catalog.js +51 -0
  168. package/dist/lib/explore-catalog.json +131 -0
  169. package/dist/lib/explore.schema.d.ts +69 -0
  170. package/dist/lib/explore.schema.js +9 -0
  171. package/dist/lib/group-sharing.d.ts +17 -0
  172. package/dist/lib/group-sharing.js +39 -0
  173. package/dist/lib/hotel-document.d.ts +3 -0
  174. package/dist/lib/hotel-document.js +26 -0
  175. package/dist/lib/hotel-template.d.ts +246 -0
  176. package/dist/lib/hotel-template.js +77 -0
  177. package/dist/lib/library/access.d.ts +9 -0
  178. package/dist/lib/library/access.js +14 -0
  179. package/dist/lib/library/actions.d.ts +7 -0
  180. package/dist/lib/library/actions.js +55 -0
  181. package/dist/lib/library/archive.d.ts +13 -0
  182. package/dist/lib/library/archive.js +123 -0
  183. package/dist/lib/library/asset-validation.d.ts +4 -0
  184. package/dist/lib/library/asset-validation.js +77 -0
  185. package/dist/lib/library/catalog-blueprints.json +3225 -0
  186. package/dist/lib/library/catalog.service.d.ts +2427 -0
  187. package/dist/lib/library/catalog.service.js +270 -0
  188. package/dist/lib/library/dataset-binding.service.d.ts +65 -0
  189. package/dist/lib/library/dataset-binding.service.js +152 -0
  190. package/dist/lib/library/directory-contract.d.ts +161 -0
  191. package/dist/lib/library/directory-contract.js +19 -0
  192. package/dist/lib/library/directory.service.d.ts +33 -0
  193. package/dist/lib/library/directory.service.js +69 -0
  194. package/dist/lib/library/entities.d.ts +80 -0
  195. package/dist/lib/library/entities.js +280 -0
  196. package/dist/lib/library/execution-contract.d.ts +200 -0
  197. package/dist/lib/library/execution-contract.js +19 -0
  198. package/dist/lib/library/execution-resolution.d.ts +2490 -0
  199. package/dist/lib/library/execution-resolution.js +101 -0
  200. package/dist/lib/library/file-artifact.provider.d.ts +7 -0
  201. package/dist/lib/library/file-artifact.provider.js +35 -0
  202. package/dist/lib/library/files.service.d.ts +20 -0
  203. package/dist/lib/library/files.service.js +112 -0
  204. package/dist/lib/library/origin.schema.d.ts +171 -0
  205. package/dist/lib/library/origin.schema.js +14 -0
  206. package/dist/lib/library/resource-contract.d.ts +2779 -0
  207. package/dist/lib/library/resource-contract.js +167 -0
  208. package/dist/lib/library/resource-json.d.ts +11 -0
  209. package/dist/lib/library/resource-json.js +53 -0
  210. package/dist/lib/library/task-preparation.service.d.ts +14 -0
  211. package/dist/lib/library/task-preparation.service.js +85 -0
  212. package/dist/lib/library/template-compiler.d.ts +19 -0
  213. package/dist/lib/library/template-compiler.js +73 -0
  214. package/dist/lib/library/template-execution.service.d.ts +79 -0
  215. package/dist/lib/library/template-execution.service.js +135 -0
  216. package/dist/lib/library/transfers.service.d.ts +94 -0
  217. package/dist/lib/library/transfers.service.js +193 -0
  218. package/dist/lib/library/zip-container.d.ts +10 -0
  219. package/dist/lib/library/zip-container.js +79 -0
  220. package/dist/lib/library-view.provider.d.ts +88 -0
  221. package/dist/lib/library-view.provider.js +164 -0
  222. package/dist/lib/library.schema.d.ts +347 -0
  223. package/dist/lib/library.schema.js +41 -0
  224. package/dist/lib/middleware.d.ts +8 -2
  225. package/dist/lib/middleware.js +119 -11
  226. package/dist/lib/monitor.js +2 -2
  227. package/dist/lib/plugin.js +21 -1
  228. package/dist/lib/presentation.provider.d.ts +35 -0
  229. package/dist/lib/presentation.provider.js +4 -15
  230. package/dist/lib/projects.schema.d.ts +4 -4
  231. package/dist/lib/query-session.d.ts +1 -1
  232. package/dist/lib/query-session.js +13 -8
  233. package/dist/lib/remote-entry.d.ts +1 -1
  234. package/dist/lib/remote-entry.js +2 -2
  235. package/dist/lib/resource.schema.d.ts +1067 -0
  236. package/dist/lib/resource.schema.js +76 -0
  237. package/dist/lib/runtime-context.d.ts +2 -0
  238. package/dist/lib/runtime-context.js +22 -0
  239. package/dist/lib/sharing.service.d.ts +12 -0
  240. package/dist/lib/sharing.service.js +4 -0
  241. package/dist/lib/source-executions.d.ts +69 -51
  242. package/dist/lib/source-executions.js +2 -1
  243. package/dist/lib/template.schema.d.ts +36 -0
  244. package/dist/lib/template.schema.js +17 -0
  245. package/dist/lib/template.service.d.ts +21 -0
  246. package/dist/lib/template.service.js +56 -0
  247. package/dist/lib/templates.js +5 -5
  248. package/dist/lib/view.provider.d.ts +129 -4
  249. package/dist/lib/view.provider.js +61 -35
  250. package/dist/remote/app.css +1 -1
  251. package/dist/remote/app.js +54 -53
  252. package/dist/remote/build-manifest.json +238 -46
  253. package/dist/sandbox-actions/action.json +1 -1
  254. package/dist/sandbox-actions/bundle/host.js +2 -2
  255. package/docs/content-packages.mdx +43 -0
  256. package/docs/dashboard-starter.mdx +22 -0
  257. package/docs/data-view.mdx +30 -0
  258. package/docs/dataset-generation.mdx +32 -0
  259. package/docs/dataset-storage.mdx +29 -0
  260. package/docs/docs.json +15 -0
  261. package/docs/editing.mdx +6 -0
  262. package/docs/html-mode.md +1 -1
  263. package/docs/index.mdx +8 -0
  264. package/docs/inline-analysis.mdx +62 -0
  265. package/docs/library-browser-verification.mdx +46 -0
  266. package/docs/library-detail-ui.mdx +21 -0
  267. package/docs/library-directory-ui.mdx +24 -0
  268. package/docs/library-execution.mdx +49 -0
  269. package/docs/library-import-ui.mdx +20 -0
  270. package/docs/library-storage.mdx +63 -0
  271. package/docs/proposals/resource-sharing-decoupling.mdx +83 -0
  272. package/docs/standard-theme.mdx +28 -0
  273. package/docs/template-agent-handoff.mdx +37 -0
  274. package/docs/verification.mdx +4 -0
  275. package/package.json +9 -5
  276. package/skills/live-dashboard/SKILL.md +41 -1
  277. package/skills/live-dashboard/examples/README.md +2 -2
  278. package/skills/live-dashboard/examples/production-quality/README.md +2 -2
  279. package/skills/live-dashboard/examples/regional-sales/README.md +3 -3
  280. package/skills/live-dashboard/examples/regional-sales/query.json +49 -1
  281. package/skills/live-dashboard/examples/sales-overview/README.md +2 -2
  282. package/skills/live-dashboard/references/attribution-analysis.md +8 -0
  283. package/skills/live-dashboard/references/pareto-analysis.md +8 -0
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.analysisSceneChart = analysisSceneChart;
4
+ exports.chartNumber = chartNumber;
5
+ /** Static plotting only: no scripts, external resources, HTML labels, source URLs or App sessions. */
6
+ function analysisSceneChart(view, rows, unit) {
7
+ const width = 720, height = view === 'bar' ? Math.max(180, rows.length * 34 + 70) : 300;
8
+ const left = view === 'bar' ? 175 : 70, right = 90, top = 25, bottom = 45;
9
+ const plotWidth = width - left - right, plotHeight = height - top - bottom;
10
+ const values = rows.flatMap(row => row.value === null ? [] : [row.value]);
11
+ const min = Math.min(0, ...values), upper = Math.max(0, ...values);
12
+ const max = upper === min ? min + 1 : upper, range = max - min;
13
+ const x = (value) => left + (value - min) / range * plotWidth;
14
+ const y = (value) => top + (max - value) / range * plotHeight;
15
+ const number = (value) => new Intl.NumberFormat('en', { maximumFractionDigits: 3, notation: Math.abs(value) >= 1000000 ? 'compact' : 'standard' }).format(value);
16
+ const label = (value, max = 18) => xml([...value].slice(0, max).join('') + ([...value].length > max ? '…' : ''));
17
+ const elements = [];
18
+ if (view === 'bar') {
19
+ elements.push(`<line x1="${x(0)}" y1="${top}" x2="${x(0)}" y2="${height - bottom}" stroke="#cbd5e1"/>`);
20
+ rows.forEach((row, index) => {
21
+ const baseline = top + index * 34;
22
+ elements.push(`<text x="${left - 12}" y="${baseline + 16}" text-anchor="end">${label(row.label)}</text>`);
23
+ if (row.value === null)
24
+ return;
25
+ elements.push(`<rect x="${Math.min(x(0), x(row.value))}" y="${baseline}" width="${Math.abs(x(row.value) - x(0))}" height="24" rx="3" fill="#4f79bd"/>`);
26
+ elements.push(`<text x="${width - 6}" y="${baseline + 17}" text-anchor="end">${xml(number(row.value))}</text>`);
27
+ });
28
+ }
29
+ else {
30
+ const position = (index) => left + index / Math.max(1, rows.length - 1) * plotWidth;
31
+ for (let index = 0; index <= 4; index++) {
32
+ const value = min + index / 4 * range, lineY = y(value);
33
+ elements.push(`<line x1="${left}" y1="${lineY}" x2="${width - right}" y2="${lineY}" stroke="#e2e8f0"/><text x="${left - 10}" y="${lineY + 4}" text-anchor="end">${xml(number(value))}</text>`);
34
+ }
35
+ rows.forEach((row, index) => {
36
+ if (row.value !== null) {
37
+ const previous = rows[index - 1];
38
+ if (previous?.value !== null && previous?.value !== undefined)
39
+ elements.push(`<line x1="${position(index - 1)}" y1="${y(previous.value)}" x2="${position(index)}" y2="${y(row.value)}" stroke="#4f79bd" stroke-width="2.5"/>`);
40
+ elements.push(`<circle cx="${position(index)}" cy="${y(row.value)}" r="4" fill="#4f79bd"/>`);
41
+ }
42
+ if (index % Math.max(1, Math.ceil(rows.length / 5)) === 0 || index === rows.length - 1)
43
+ elements.push(`<text x="${position(index)}" y="${height - 18}" text-anchor="middle">${label(row.label, 10)}</text>`);
44
+ });
45
+ }
46
+ elements.push(`<text x="${width - 15}" y="${height - 8}" text-anchor="end">${label(unit, 30)}</text>`);
47
+ // A fixed white plot canvas keeps standalone image labels legible in both light and dark host themes.
48
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${width}" height="${height}" viewBox="0 0 ${width} ${height}" role="img"><rect width="100%" height="100%" rx="8" fill="#fff"/><g fill="#475569" font-family="system-ui,sans-serif" font-size="12">${elements.join('')}</g></svg>`;
49
+ }
50
+ /** Reject unsafe coercion instead of turning identifiers, booleans or imprecise decimals into chart measures. */
51
+ function chartNumber(value, logicalType) {
52
+ if (value === null)
53
+ return null;
54
+ if (logicalType === 'float64' && typeof value === 'number' && Number.isFinite(value))
55
+ return value;
56
+ if (['decimal', 'int64'].includes(logicalType) && typeof value === 'string' && /^-?\d+(?:\.\d+)?$/.test(value)
57
+ && value.replace(/[-.]/g, '').replace(/^0+/, '').length <= 15 && Number.isFinite(Number(value)) && Math.abs(Number(value)) <= Number.MAX_SAFE_INTEGER)
58
+ return Number(value);
59
+ throw new Error('ANALYSIS_SCENE_NUMERIC_PRECISION: choose a numeric measure representable without precision loss, or use a table.');
60
+ }
61
+ function xml(value) { return value.replace(/[&<>"']/g, char => ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&apos;' })[char]); }
@@ -0,0 +1,87 @@
1
+ import { type AnalyticalDataset } from '@xpert-ai/contracts';
2
+ export declare const ANALYSIS_SCENE_GUIDANCE = "For a single interim analysis result, call dashboard_present_analysis after a successful dashboard_preview/dashboard_preview_binding, passing its current-run previewId, an explicit view (bar/line/table/metrics) and exact field IDs. It rechecks access and reruns the same read-only binding, then posts a bounded visual Widget directly in this conversation, including groups. It creates no dashboard, file or project. Do not write HTML or save a whole dashboard just to show an intermediate result. Metrics needs one aggregate row; charts do not infer aggregation or sort order. For top/bottom N, set orderBy to the requested measure and direction BEFORE maxRows; maxRows alone is not ranking. Set language to the conversation language. The visible scene is a result snapshot, not a final reply. Continue analyzing afterward and keep replyStage=progress until ready to answer. Check display.status before claiming the scene was shown.";
3
+ /** The enclosing middleware supplies a current-run receipt resolver bound to the real runtime actor. */
4
+ export declare function createAnalysisSceneTool(query: (previewId: string) => Promise<AnalyticalDataset>, runId: string, locale: () => string): import("@langchain/core/tools").DynamicStructuredTool<import("zod").ZodEffects<import("zod").ZodObject<{
5
+ previewId: import("zod").ZodString;
6
+ title: import("zod").ZodString;
7
+ view: import("zod").ZodEnum<["bar", "line", "table", "metrics"]>;
8
+ fields: import("zod").ZodArray<import("zod").ZodString, "many">;
9
+ orderBy: import("zod").ZodOptional<import("zod").ZodObject<{
10
+ field: import("zod").ZodString;
11
+ direction: import("zod").ZodEnum<["asc", "desc"]>;
12
+ }, "strict", import("zod").ZodTypeAny, {
13
+ field: string;
14
+ direction: "asc" | "desc";
15
+ }, {
16
+ field: string;
17
+ direction: "asc" | "desc";
18
+ }>>;
19
+ language: import("zod").ZodOptional<import("zod").ZodEnum<["zh-Hans", "en"]>>;
20
+ maxRows: import("zod").ZodDefault<import("zod").ZodNumber>;
21
+ }, "strict", import("zod").ZodTypeAny, {
22
+ title: string;
23
+ fields: string[];
24
+ view: "table" | "bar" | "line" | "metrics";
25
+ previewId: string;
26
+ maxRows: number;
27
+ orderBy?: {
28
+ field: string;
29
+ direction: "asc" | "desc";
30
+ } | undefined;
31
+ language?: "en" | "zh-Hans" | undefined;
32
+ }, {
33
+ title: string;
34
+ fields: string[];
35
+ view: "table" | "bar" | "line" | "metrics";
36
+ previewId: string;
37
+ orderBy?: {
38
+ field: string;
39
+ direction: "asc" | "desc";
40
+ } | undefined;
41
+ language?: "en" | "zh-Hans" | undefined;
42
+ maxRows?: number | undefined;
43
+ }>, {
44
+ title: string;
45
+ fields: string[];
46
+ view: "table" | "bar" | "line" | "metrics";
47
+ previewId: string;
48
+ maxRows: number;
49
+ orderBy?: {
50
+ field: string;
51
+ direction: "asc" | "desc";
52
+ } | undefined;
53
+ language?: "en" | "zh-Hans" | undefined;
54
+ }, {
55
+ title: string;
56
+ fields: string[];
57
+ view: "table" | "bar" | "line" | "metrics";
58
+ previewId: string;
59
+ orderBy?: {
60
+ field: string;
61
+ direction: "asc" | "desc";
62
+ } | undefined;
63
+ language?: "en" | "zh-Hans" | undefined;
64
+ maxRows?: number | undefined;
65
+ }>, {
66
+ title: string;
67
+ fields: string[];
68
+ view: "table" | "bar" | "line" | "metrics";
69
+ previewId: string;
70
+ maxRows: number;
71
+ orderBy?: {
72
+ field: string;
73
+ direction: "asc" | "desc";
74
+ } | undefined;
75
+ language?: "en" | "zh-Hans" | undefined;
76
+ }, {
77
+ title: string;
78
+ fields: string[];
79
+ view: "table" | "bar" | "line" | "metrics";
80
+ previewId: string;
81
+ orderBy?: {
82
+ field: string;
83
+ direction: "asc" | "desc";
84
+ } | undefined;
85
+ language?: "en" | "zh-Hans" | undefined;
86
+ maxRows?: number | undefined;
87
+ }, string>;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ANALYSIS_SCENE_GUIDANCE = void 0;
4
+ exports.createAnalysisSceneTool = createAnalysisSceneTool;
5
+ const tools_1 = require("@langchain/core/tools");
6
+ const dispatch_1 = require("@langchain/core/callbacks/dispatch");
7
+ const contracts_1 = require("@xpert-ai/contracts");
8
+ const node_crypto_1 = require("node:crypto");
9
+ const analysis_scene_schema_1 = require("./analysis-scene.schema");
10
+ const analysis_scene_widget_1 = require("./analysis-scene-widget");
11
+ exports.ANALYSIS_SCENE_GUIDANCE = 'For a single interim analysis result, call dashboard_present_analysis after a successful dashboard_preview/dashboard_preview_binding, passing its current-run previewId, an explicit view (bar/line/table/metrics) and exact field IDs. It rechecks access and reruns the same read-only binding, then posts a bounded visual Widget directly in this conversation, including groups. It creates no dashboard, file or project. Do not write HTML or save a whole dashboard just to show an intermediate result. Metrics needs one aggregate row; charts do not infer aggregation or sort order. For top/bottom N, set orderBy to the requested measure and direction BEFORE maxRows; maxRows alone is not ranking. Set language to the conversation language. The visible scene is a result snapshot, not a final reply. Continue analyzing afterward and keep replyStage=progress until ready to answer. Check display.status before claiming the scene was shown.';
12
+ /** The enclosing middleware supplies a current-run receipt resolver bound to the real runtime actor. */
13
+ function createAnalysisSceneTool(query, runId, locale) {
14
+ return (0, tools_1.tool)(async (input, config) => {
15
+ const dataset = await query(input.previewId);
16
+ const sceneId = 'analysis-scene-' + (0, node_crypto_1.createHash)('sha256').update(JSON.stringify([runId, input])).digest('hex').slice(0, 24);
17
+ const widget = (0, analysis_scene_widget_1.analysisSceneWidget)(input, dataset, sceneId, locale());
18
+ await (0, dispatch_1.dispatchCustomEvent)(contracts_1.ChatMessageEventTypeEnum.ON_TOOL_MESSAGE, widget, config);
19
+ return JSON.stringify({ display: { status: 'emitted', sceneId, type: 'Widget' }, title: input.title,
20
+ datasetId: dataset.datasetId, displayedRows: Math.min(dataset.rows.length, input.maxRows),
21
+ omittedRows: Math.max(0, dataset.rows.length - input.maxRows), completeness: dataset.completeness,
22
+ // Give the Agent the same fresh, selected values it showed; the earlier preview may be stale or unranked.
23
+ result: {
24
+ fields: input.fields.map(id => { const field = dataset.fields.find(field => field.id === id); return { id, label: field.label, logicalType: field.logicalType, unit: field.unit }; }),
25
+ rows: (0, analysis_scene_widget_1.selectedSceneRows)(input, dataset).map(row => Object.fromEntries(input.fields.map(id => [id, row[id]])))
26
+ },
27
+ selection: { orderBy: input.orderBy ?? null, scope: 'returned_query_rows', warning: input.orderBy ? 'Ranking covers returned rows only; check source completeness before claiming a global top/bottom N.' : 'No ranking was applied. First rows are not top/bottom N.' },
28
+ queriedAt: dataset.freshness.executedAt, sourceFetchedAt: dataset.freshness.sourceFetchedAt });
29
+ }, { name: 'dashboard_present_analysis', schema: analysis_scene_schema_1.analysisSceneSchema, verboseParsingErrors: true,
30
+ description: 'Display one verified analysis scene inline in chat (including groups) as a read-only Widget: bar, line, table or metrics. Requires a current-run previewId. Revalidates access and reruns that exact read-only binding. Never accepts rows/SQL/URLs/HTML; does not create or save a dashboard. Choose exact returned field IDs; charts require [dimension, measure] and unique categories. Table preserves exact decimal/int64 strings. A scene does not complete the request; continue analysis or send the final answer as appropriate.',
31
+ metadata: { toolName: { en_US: 'Show analysis result', zh_Hans: '展示本次分析结果' } }
32
+ });
33
+ }
@@ -0,0 +1,6 @@
1
+ import type { AnalyticalDataset, TMessageComponentWidget } from '@xpert-ai/contracts';
2
+ import type { AnalysisSceneInput } from './analysis-scene.schema';
3
+ /** Build one inert Widget using only the selected, authorized Dataset fields. Never copy Binding payloads or audit secrets. */
4
+ export declare function analysisSceneWidget(input: AnalysisSceneInput, dataset: AnalyticalDataset, id: string, locale: string): TMessageComponentWidget;
5
+ /** Explicit presentation sorting only, before truncation. No aggregation or claims about unreturned rows. */
6
+ export declare function selectedSceneRows(input: AnalysisSceneInput, dataset: AnalyticalDataset): AnalyticalDataset['rows'];
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.analysisSceneWidget = analysisSceneWidget;
4
+ exports.selectedSceneRows = selectedSceneRows;
5
+ const analysis_scene_chart_1 = require("./analysis-scene-chart");
6
+ const copy = {
7
+ en: { empty: 'No rows returned for this query.', partial: 'Partial result', complete: 'Complete query result', rows: 'Displayed rows', fetched: 'Source fetched', query: 'Query executed', dataset: 'Dataset', null: 'No value', details: 'Exact values' },
8
+ zh: { empty: '本次查询没有返回数据。', partial: '部分查询结果', complete: '完整查询结果', rows: '展示行数', fetched: '数据获取时间', query: '查询时间', dataset: '数据集', null: '无值', details: '精确数值' }
9
+ };
10
+ /** Build one inert Widget using only the selected, authorized Dataset fields. Never copy Binding payloads or audit secrets. */
11
+ function analysisSceneWidget(input, dataset, id, locale) {
12
+ const t = (input.language ?? locale).startsWith('zh') ? copy.zh : copy.en;
13
+ const fields = input.fields.map(id => {
14
+ const field = dataset.fields.find(field => field.id === id);
15
+ if (!field)
16
+ throw new Error('ANALYSIS_SCENE_FIELD: choose exact field IDs from the verified dataset.');
17
+ return field;
18
+ });
19
+ if (input.view === 'metrics' && dataset.rows.length > 1)
20
+ throw new Error('ANALYSIS_SCENE_AGGREGATE_REQUIRED: metrics requires one already-aggregated row; use table or query the intended aggregate.');
21
+ const rows = selectedSceneRows(input, dataset);
22
+ const partial = dataset.completeness.truncated || dataset.completeness.scope !== 'full_query_result' || rows.length < dataset.rows.length;
23
+ const text = (value) => value === null ? t.null : String(value);
24
+ const escape = (value) => value.replace(/[\\`*_{}\[\]<>|!#]/g, '\\$&').replace(/[\r\n]+/g, ' ');
25
+ const components = [];
26
+ const children = [];
27
+ const addText = (key, value, usageHint = 'body') => {
28
+ children.push(key);
29
+ components.push({ id: key, component: { Text: { text: { literalString: value }, usageHint } } });
30
+ };
31
+ addText('title', escape(input.title), 'h3');
32
+ if (!rows.length)
33
+ addText('empty', t.empty);
34
+ else if (input.view === 'metrics') {
35
+ const metrics = [];
36
+ for (const [index, field] of fields.entries()) {
37
+ const metricId = `metric-${index}`;
38
+ const parts = [`${metricId}-label`, `${metricId}-value`];
39
+ metrics.push(metricId);
40
+ components.push({ id: parts[0], component: { Text: { text: { literalString: escape(field.label) }, usageHint: 'caption' } } }, { id: parts[1], component: { Text: { text: { literalString: escape(metricValue(rows[0][field.id], field.logicalType, t.null)) }, usageHint: 'h2' } } });
41
+ if (field.unit) {
42
+ parts.push(`${metricId}-unit`);
43
+ components.push({ id: `${metricId}-unit`, component: { Text: { text: { literalString: escape(field.unit) }, usageHint: 'caption' } } });
44
+ }
45
+ components.push({ id: metricId, component: { Column: { children: { explicitList: parts } } } });
46
+ }
47
+ children.push('metrics');
48
+ components.push({ id: 'metrics', component: { Row: { children: { explicitList: metrics } } } });
49
+ }
50
+ else {
51
+ if (input.view === 'bar' || input.view === 'line') {
52
+ const [dimension, measure] = fields;
53
+ if (!['dimension', 'time', 'identifier'].includes(dimension.role) || measure.role !== 'measure')
54
+ throw new Error('ANALYSIS_SCENE_ROLES: charts require a declared dimension/time/identifier followed by a measure.');
55
+ const labels = rows.map(row => text(row[dimension.id]));
56
+ if (new Set(labels).size !== labels.length)
57
+ throw new Error('ANALYSIS_SCENE_GRAIN: repeated labels need an explicitly aggregated query; no implicit aggregation is performed.');
58
+ const points = rows.map((row, index) => ({ label: labels[index], value: (0, analysis_scene_chart_1.chartNumber)(row[measure.id], measure.logicalType) }));
59
+ const svg = (0, analysis_scene_chart_1.analysisSceneChart)(input.view, points, measure.unit ?? measure.label);
60
+ children.push('chart');
61
+ components.push({ id: 'chart', component: { Image: { url: { literalString: 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(svg) }, alt: { literalString: input.title }, fit: 'contain' } } });
62
+ }
63
+ addText('details-label', t.details, 'caption');
64
+ const table = [`| ${fields.map(field => escape(field.label)).join(' | ')} |`, `| ${fields.map(() => '---').join(' | ')} |`, ...rows.map(row => `| ${fields.map(field => escape(text(row[field.id]))).join(' | ')} |`)].join('\n');
65
+ addText('details', table);
66
+ }
67
+ components.unshift({ id: 'root', component: { Column: { children: { explicitList: children } } } });
68
+ const widget = { id, category: 'Dashboard', type: 'Widget', widgets: [{ name: input.title,
69
+ presentation: {
70
+ summary: partial ? t.partial : t.complete,
71
+ timestamp: dataset.freshness.executedAt,
72
+ timestampLabel: t.query,
73
+ details: [
74
+ { label: t.dataset, value: dataset.datasetId },
75
+ { label: t.rows, value: `${rows.length}/${dataset.rows.length}` },
76
+ { label: t.fetched, value: dataset.freshness.sourceFetchedAt }
77
+ ]
78
+ }, messages: [
79
+ { surfaceUpdate: { surfaceId: id, components } }, { beginRendering: { surfaceId: id, root: 'root' } }
80
+ ] }] };
81
+ if (Buffer.byteLength(JSON.stringify(widget)) > 100000)
82
+ throw new Error('ANALYSIS_SCENE_TOO_LARGE: select fewer fields or a smaller maxRows.');
83
+ return widget;
84
+ }
85
+ /** Group decimal/int64 strings without a Number conversion, preserving every digit and trailing zero. */
86
+ function metricValue(value, logicalType, empty) {
87
+ if (value === null)
88
+ return empty;
89
+ const text = String(value);
90
+ if (!['int64', 'float64', 'decimal'].includes(logicalType) || !/^-?\d+(\.\d+)?$/.test(text))
91
+ return text;
92
+ const [integer, fraction] = text.split('.');
93
+ return integer.replace(/\B(?=(\d{3})+(?!\d))/g, ',') + (fraction === undefined ? '' : `.${fraction}`);
94
+ }
95
+ /** Explicit presentation sorting only, before truncation. No aggregation or claims about unreturned rows. */
96
+ function selectedSceneRows(input, dataset) {
97
+ if (!input.orderBy)
98
+ return dataset.rows.slice(0, input.maxRows);
99
+ const order = input.orderBy;
100
+ const field = dataset.fields.find(field => field.id === order.field);
101
+ if (!field || field.role !== 'measure' || !input.fields.includes(field.id))
102
+ throw new Error('ANALYSIS_SCENE_ORDER: orderBy must select a displayed numeric measure.');
103
+ const direction = order.direction === 'asc' ? 1 : -1;
104
+ return dataset.rows.map(row => ({ row, value: (0, analysis_scene_chart_1.chartNumber)(row[field.id], field.logicalType) }))
105
+ .sort((a, b) => a.value === null ? (b.value === null ? 0 : 1) : b.value === null ? -1 : (a.value - b.value) * direction)
106
+ .slice(0, input.maxRows).map(item => item.row);
107
+ }
@@ -0,0 +1,66 @@
1
+ import { z } from 'zod/v3';
2
+ /** Presentation choices only. Dataset rows, SQL, source identity and execution scope are never model input. */
3
+ export declare const analysisSceneSchema: z.ZodEffects<z.ZodObject<{
4
+ previewId: z.ZodString;
5
+ title: z.ZodString;
6
+ view: z.ZodEnum<["bar", "line", "table", "metrics"]>;
7
+ fields: z.ZodArray<z.ZodString, "many">;
8
+ orderBy: z.ZodOptional<z.ZodObject<{
9
+ field: z.ZodString;
10
+ direction: z.ZodEnum<["asc", "desc"]>;
11
+ }, "strict", z.ZodTypeAny, {
12
+ field: string;
13
+ direction: "asc" | "desc";
14
+ }, {
15
+ field: string;
16
+ direction: "asc" | "desc";
17
+ }>>;
18
+ language: z.ZodOptional<z.ZodEnum<["zh-Hans", "en"]>>;
19
+ maxRows: z.ZodDefault<z.ZodNumber>;
20
+ }, "strict", z.ZodTypeAny, {
21
+ title: string;
22
+ fields: string[];
23
+ view: "table" | "bar" | "line" | "metrics";
24
+ previewId: string;
25
+ maxRows: number;
26
+ orderBy?: {
27
+ field: string;
28
+ direction: "asc" | "desc";
29
+ } | undefined;
30
+ language?: "en" | "zh-Hans" | undefined;
31
+ }, {
32
+ title: string;
33
+ fields: string[];
34
+ view: "table" | "bar" | "line" | "metrics";
35
+ previewId: string;
36
+ orderBy?: {
37
+ field: string;
38
+ direction: "asc" | "desc";
39
+ } | undefined;
40
+ language?: "en" | "zh-Hans" | undefined;
41
+ maxRows?: number | undefined;
42
+ }>, {
43
+ title: string;
44
+ fields: string[];
45
+ view: "table" | "bar" | "line" | "metrics";
46
+ previewId: string;
47
+ maxRows: number;
48
+ orderBy?: {
49
+ field: string;
50
+ direction: "asc" | "desc";
51
+ } | undefined;
52
+ language?: "en" | "zh-Hans" | undefined;
53
+ }, {
54
+ title: string;
55
+ fields: string[];
56
+ view: "table" | "bar" | "line" | "metrics";
57
+ previewId: string;
58
+ orderBy?: {
59
+ field: string;
60
+ direction: "asc" | "desc";
61
+ } | undefined;
62
+ language?: "en" | "zh-Hans" | undefined;
63
+ maxRows?: number | undefined;
64
+ }>;
65
+ /** Current-run query receipt plus explicit presentation; no persistence or query authorization is implied. */
66
+ export type AnalysisSceneInput = z.infer<typeof analysisSceneSchema>;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.analysisSceneSchema = void 0;
4
+ const v3_1 = require("zod/v3");
5
+ const field = v3_1.z.string().min(1).max(160);
6
+ /** Presentation choices only. Dataset rows, SQL, source identity and execution scope are never model input. */
7
+ exports.analysisSceneSchema = v3_1.z.object({
8
+ previewId: v3_1.z.string().min(1).max(128).describe('Exact successful dashboard_preview or dashboard_preview_binding receipt from this run.'),
9
+ title: v3_1.z.string().trim().min(1).max(120),
10
+ view: v3_1.z.enum(['bar', 'line', 'table', 'metrics']).describe('One analysis scene. Metrics requires a single aggregate row; charts never aggregate or sort rows implicitly.'),
11
+ fields: v3_1.z.array(field).min(1).max(6).describe('Exact returned field IDs. Charts require [xField, yField]; tables and metrics use the selected fields.'),
12
+ orderBy: v3_1.z.object({ field, direction: v3_1.z.enum(['asc', 'desc']) }).strict().optional().describe('Explicit numeric measure ordering BEFORE maxRows. Required when asking for top/bottom N; truncation alone is not ranking. Applies only to the returned query result, not omitted source data.'),
13
+ language: v3_1.z.enum(['zh-Hans', 'en']).optional().describe('Use the conversation language for result labels: zh-Hans for Chinese, en for English.'),
14
+ maxRows: v3_1.z.number().int().min(1).max(20).default(10),
15
+ }).strict().superRefine((value, ctx) => {
16
+ if (new Set(value.fields).size !== value.fields.length)
17
+ ctx.addIssue({ code: 'custom', path: ['fields'], message: 'Choose distinct field IDs.' });
18
+ if (['bar', 'line'].includes(value.view) && value.fields.length !== 2)
19
+ ctx.addIssue({ code: 'custom', path: ['fields'], message: 'Charts require exactly [xField, yField].' });
20
+ });
@@ -87,11 +87,46 @@ export declare class DashboardArchiveService {
87
87
  datasetId: string;
88
88
  fields: string[];
89
89
  }[];
90
+ visualTheme?: "system" | "slate" | "contrast" | undefined;
90
91
  sourceMetadata?: {
91
92
  bindingId: string;
92
93
  title: string;
93
94
  description?: string | undefined;
94
95
  }[] | undefined;
96
+ templateOrigin?: {
97
+ schema: "xpert.library.instance";
98
+ version: 1;
99
+ template: {
100
+ version: string;
101
+ logicalId: string;
102
+ sha256: string;
103
+ };
104
+ inputs: {
105
+ slot: string;
106
+ mapping: Record<string, string>;
107
+ source: {
108
+ type: "library";
109
+ version: string;
110
+ logicalId: string;
111
+ sha256: string;
112
+ } | {
113
+ type: "dataset";
114
+ artifactId: string;
115
+ revision: number;
116
+ };
117
+ }[];
118
+ parameters: Record<string, string | number | boolean | null>;
119
+ task?: {
120
+ version: string;
121
+ logicalId: string;
122
+ sha256: string;
123
+ } | undefined;
124
+ theme?: {
125
+ version: string;
126
+ logicalId: string;
127
+ sha256: string;
128
+ } | undefined;
129
+ } | undefined;
95
130
  components?: {
96
131
  title: string;
97
132
  id: string;
@@ -7,6 +7,7 @@ export declare class DashboardArtifactType implements IArtifactTypeProvider {
7
7
  private readonly dashboards;
8
8
  constructor(runtime: RuntimeCapabilityRegistry, dashboards: DashboardService);
9
9
  readonly definition: ArtifactTypeDefinition;
10
+ readonly analytics: NonNullable<IArtifactTypeProvider['analytics']>;
10
11
  authorize(source: ArtifactTypeSource, actor: ArtifactTypeActor, _operation: ContentOperation): Promise<void>;
11
12
  validateContent(content: Buffer, mimeType: string): void;
12
13
  authorizeDraft(source: ArtifactTypeSource, actor: ArtifactTypeActor, operation: ContentOperation): Promise<void>;
@@ -13,25 +13,43 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.DashboardArtifactType = void 0;
16
+ const dashboard_artifact_1 = require("./dashboard-artifact");
17
+ const dashboard_queries_1 = require("./dashboard-queries");
16
18
  const dashboard_service_1 = require("./dashboard.service");
17
19
  const common_1 = require("@nestjs/common");
18
20
  const plugin_sdk_1 = require("@xpert-ai/plugin-sdk");
19
21
  const document_package_1 = require("./document-package");
20
22
  const dashboard_sharing_1 = require("./dashboard-sharing");
23
+ const content_type_1 = require("./content-type");
24
+ const dashboard_icon_1 = require("./dashboard-icon");
21
25
  /** Drafts require Project edit access; explicit authenticated shares may expand formal-version readership. */
22
26
  let DashboardArtifactType = class DashboardArtifactType {
23
27
  constructor(runtime, dashboards) {
24
28
  this.runtime = runtime;
25
29
  this.dashboards = dashboards;
26
30
  this.definition = {
31
+ icon: dashboard_icon_1.dashboardIcon,
32
+ contentTypeId: content_type_1.DASHBOARD_CONTENT_TYPE,
27
33
  versioning: { mode: 'draft-only' },
28
34
  title: { en_US: 'Live dashboard', zh_Hans: '实时看板' },
29
35
  kinds: ['file'], content: { mimeTypes: ['application/json'], maxBytes: document_package_1.MAX_DASHBOARD_PACKAGE_BYTES },
30
36
  collection: { allowCopy: false },
37
+ useGrants: { audience: 'group', permission: 'read', queryOperations: ['query', 'query-binding'] },
31
38
  sharing: { projectAccess: 'link-audience', accessModes: ['organization_all'], versionModes: ['latest', 'version'],
32
39
  allowDownload: false, mutableLinks: true, descriptor: true, shareKey: dashboard_sharing_1.DASHBOARD_SHARE_KEY },
33
40
  presentation: { mode: 'authenticated' }
34
41
  };
42
+ this.analytics = {
43
+ resolveBindings: context => (0, dashboard_artifact_1.readDashboardArtifact)(context).manifest.bindings.map(binding => ({ binding })),
44
+ normalizeControls: (context, datasetKey, input) => {
45
+ const manifest = (0, dashboard_artifact_1.readDashboardArtifact)(context).manifest;
46
+ const binding = manifest.bindings.find(item => item.id === datasetKey);
47
+ if (!binding)
48
+ throw new common_1.ForbiddenException('DASHBOARD_ANALYSIS_DATASET_UNAVAILABLE');
49
+ const values = (0, dashboard_queries_1.validateControls)(manifest, input);
50
+ return Object.fromEntries(Object.entries(values).filter(([key]) => binding.parameters.some(parameter => parameter.controlId === key)));
51
+ }
52
+ };
35
53
  }
36
54
  async authorize(source, actor, _operation) {
37
55
  if (!actor.userId || !actor.tenantId || source.tenantId !== actor.tenantId ||
@@ -0,0 +1,11 @@
1
+ import type { AnalyticsBinding } from '@xpert-ai/contracts';
2
+ import { z } from 'zod/v3';
3
+ import { type AnalyticsDefinitionAuthoringApi, type AnalyticsAuthoringScope, type WorkspaceFilesApi } from '@xpert-ai/plugin-sdk';
4
+ export declare const exampleIdSchema: z.ZodEnum<["regional-sales", "sales-overview", "production-quality"]>;
5
+ export declare const EXAMPLE_SOURCE_GUIDANCE = "For an explicitly requested bundled demo (regional-sales, sales-overview, production-quality), including a choice made earlier in this conversation, first call analytics_definition_register with only exampleId set to that exact key. When the request matches a returned prepared query, pass its previewRequest unchanged to dashboard_preview_binding. For other requests start from the returned canonical binding. Preserve its source, datasetId, revision and contractHash. Use its actual fields as aggregate inputs, and the aggregate alias as output.sourceField. Preview the requested query before saving. A registered source with similar fields or a similar name is a different dataset. For named registered business sources use dashboard_list_sources as usual.";
6
+ export declare function registerExampleSource(exampleId: z.infer<typeof exampleIdSchema>, projectId: string | undefined, runtime: AnalyticsDefinitionAuthoringApi, scope: AnalyticsAuthoringScope, files: WorkspaceFilesApi): Promise<import("@xpert-ai/plugin-sdk").AnalyticsDefinitionReceipt>;
7
+ export declare function exampleSummaryQuery(exampleId: z.infer<typeof exampleIdSchema>, binding: AnalyticsBinding): Promise<{
8
+ key: string;
9
+ description: string;
10
+ binding: AnalyticsBinding;
11
+ } | undefined>;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EXAMPLE_SOURCE_GUIDANCE = exports.exampleIdSchema = void 0;
4
+ exports.registerExampleSource = registerExampleSource;
5
+ exports.exampleSummaryQuery = exampleSummaryQuery;
6
+ const node_crypto_1 = require("node:crypto");
7
+ const promises_1 = require("node:fs/promises");
8
+ const node_path_1 = require("node:path");
9
+ const v3_1 = require("zod/v3");
10
+ const plugin_sdk_1 = require("@xpert-ai/plugin-sdk");
11
+ // These skill recipes ship a synthetic CSV and a file.table definition. The Superstore recipe uses a governed ontology.
12
+ exports.exampleIdSchema = v3_1.z.enum(['regional-sales', 'sales-overview', 'production-quality']);
13
+ exports.EXAMPLE_SOURCE_GUIDANCE = 'For an explicitly requested bundled demo (regional-sales, sales-overview, production-quality), including a choice made earlier in this conversation, first call analytics_definition_register with only exampleId set to that exact key. When the request matches a returned prepared query, pass its previewRequest unchanged to dashboard_preview_binding. For other requests start from the returned canonical binding. Preserve its source, datasetId, revision and contractHash. Use its actual fields as aggregate inputs, and the aggregate alias as output.sourceField. Preview the requested query before saving. A registered source with similar fields or a similar name is a different dataset. For named registered business sources use dashboard_list_sources as usual.';
14
+ const recipeMetadata = v3_1.z.object({ path: v3_1.z.string(), name: v3_1.z.string().min(1) });
15
+ async function registerExampleSource(exampleId, projectId, runtime, scope, files) {
16
+ if (!projectId)
17
+ throw new Error('DASHBOARD_EXAMPLE_PROJECT_REQUIRED');
18
+ const dir = (0, node_path_1.join)(__dirname, '../../skills/live-dashboard/examples', exports.exampleIdSchema.parse(exampleId));
19
+ const [csv, json] = await Promise.all([(0, promises_1.readFile)((0, node_path_1.join)(dir, 'demo.csv')), (0, promises_1.readFile)((0, node_path_1.join)(dir, 'definition.json'), 'utf8')]);
20
+ const definition = plugin_sdk_1.analyticsOptionsSchema.parse(JSON.parse(json));
21
+ const { path, name } = recipeMetadata.parse(definition);
22
+ const selection = (await runtime.catalog(scope)).find(item => item.providerId === 'file.table');
23
+ if (!selection)
24
+ throw new Error('DASHBOARD_EXAMPLE_FILE_PROVIDER_UNAVAILABLE');
25
+ // Recipes belong to the Project root even when the Agent has a conversation-specific working directory.
26
+ const runtimePath = `/workspace/${path}`;
27
+ const ref = await files.resolveRuntimeReference(runtimePath);
28
+ if (ref.catalog !== 'projects' || ref.projectId !== projectId)
29
+ throw new Error('DASHBOARD_EXAMPLE_PROJECT_MISMATCH');
30
+ try {
31
+ const existing = await files.readBuffer(ref);
32
+ if (!existing.buffer.equals(csv))
33
+ throw new Error('DASHBOARD_EXAMPLE_FILE_CHANGED: the project file differs from the packaged sample.');
34
+ }
35
+ catch (error) {
36
+ if (!(error instanceof Error && 'code' in error && error.code === 'ENOENT'))
37
+ throw error;
38
+ await files.writeRuntimeBuffer({ path: runtimePath, buffer: csv, mimeType: 'text/csv' });
39
+ }
40
+ const hash = (0, node_crypto_1.createHash)('sha256').update(json).update(csv).digest('hex');
41
+ return runtime.register(scope, {
42
+ providerId: selection.providerId, connectionKey: selection.connectionKey,
43
+ requestId: `example-${projectId}-${hash}`, name, definition: { ...definition, path: runtimePath }
44
+ });
45
+ }
46
+ // Prepared queries are authored alongside each bundled sample. Attach them to the registered,
47
+ // inspected binding so source and contract identity always come from the active project.
48
+ async function exampleSummaryQuery(exampleId, binding) {
49
+ const path = (0, node_path_1.join)(__dirname, '../../skills/live-dashboard/examples', exports.exampleIdSchema.parse(exampleId), 'query.json');
50
+ const { summary } = JSON.parse(await (0, promises_1.readFile)(path, 'utf8'));
51
+ if (!summary)
52
+ return;
53
+ const prepared = plugin_sdk_1.analyticsBindingSchema.parse({
54
+ ...binding, parameters: [],
55
+ payload: { ...plugin_sdk_1.analyticsOptionsSchema.parse(binding.payload), select: summary.payloadFields.select, groupBy: summary.payloadFields.groupBy,
56
+ aggregates: summary.payloadFields.aggregates, orderBy: summary.payloadFields.orderBy },
57
+ output: { ...binding.output, grain: summary.grain, fields: summary.fields }
58
+ });
59
+ return { key: `${exampleId}/${summary.key}`, description: String(summary.description), binding: prepared };
60
+ }
@@ -0,0 +1,4 @@
1
+ import { z } from 'zod/v3';
2
+ import type { AnalyticsCertification } from '@xpert-ai/contracts';
3
+ /** Host-response boundary only; authored dashboard JSON cannot supply this proof. */
4
+ export declare const certificationSchema: z.ZodType<AnalyticsCertification>;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.certificationSchema = void 0;
4
+ const v3_1 = require("zod/v3");
5
+ /** Host-response boundary only; authored dashboard JSON cannot supply this proof. */
6
+ exports.certificationSchema = v3_1.z.discriminatedUnion('status', [
7
+ v3_1.z.object({ kind: v3_1.z.literal('business_metric'), subjectId: v3_1.z.string().min(1).max(160),
8
+ verifiedAt: v3_1.z.string().datetime(), status: v3_1.z.literal('legacy_unverified') }).strict(),
9
+ v3_1.z.object({ kind: v3_1.z.literal('business_metric'), subjectId: v3_1.z.string().min(1).max(160),
10
+ verifiedAt: v3_1.z.string().datetime(), status: v3_1.z.literal('verified'),
11
+ definitionHash: v3_1.z.string().regex(/^[a-f0-9]{64}$/),
12
+ dependency: v3_1.z.object({ id: v3_1.z.string().min(1).max(160), version: v3_1.z.number().int().nonnegative() }).strict(),
13
+ certifiedBy: v3_1.z.string().min(1).max(160), certifiedAt: v3_1.z.string().datetime() }).strict()
14
+ ]);
@@ -23,6 +23,7 @@ let DashboardCapability = class DashboardCapability {
23
23
  isEnabled(draft) { return (0, plugin_sdk_1.hasAssistantMiddleware)(draft, 'LiveDashboard'); }
24
24
  async check() { return { available: true }; }
25
25
  async apply({ draft }) {
26
+ (0, plugin_sdk_1.applyAssistantMiddleware)(draft, { provider: 'ProjectMiddleware', key: 'Capability_Project', title: 'Projects', instructions: '', preserveToolConcurrency: true });
26
27
  (0, plugin_sdk_1.applyAssistantMiddleware)(draft, { provider: 'LiveDashboard', key: 'Capability_DashboardCapability', title: 'Live dashboards', instructions: 'Maintain live dashboard definitions in the current Project using Live Dashboard tools and registered Analytics providers. Discover and validate current data bindings before saving. Read the current draft revision and handle conflicts without overwriting another editor. Query with the current actor permissions; never copy credentials or query rows into the shared definition. Publishing a definition is separate from saving and refreshing data.' });
27
28
  }
28
29
  };
@@ -0,0 +1,2 @@
1
+ /** Stable semantic identity shared by the authoring catalog and authorized published references. */
2
+ export declare const DASHBOARD_CONTENT_TYPE = "xpert.live-dashboard";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DASHBOARD_CONTENT_TYPE = void 0;
4
+ /** Stable semantic identity shared by the authoring catalog and authorized published references. */
5
+ exports.DASHBOARD_CONTENT_TYPE = 'xpert.live-dashboard';