@xpert-ai/plugin-live-dashboard 0.0.0-stage → 0.1.0

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 (95) hide show
  1. package/.xpertai-plugin/plugin.json +8 -0
  2. package/README.md +108 -2
  3. package/dist/index.d.ts +3 -0
  4. package/dist/index.js +11 -0
  5. package/dist/lib/agent.schema.d.ts +568 -0
  6. package/dist/lib/agent.schema.js +52 -0
  7. package/dist/lib/dashboard-icon.d.ts +5 -0
  8. package/dist/lib/dashboard-icon.js +8 -0
  9. package/dist/lib/dashboard-navigation.d.ts +38 -0
  10. package/dist/lib/dashboard-navigation.js +18 -0
  11. package/dist/lib/dashboard-queries.d.ts +8 -0
  12. package/dist/lib/dashboard-queries.js +39 -0
  13. package/dist/lib/dashboard-receipt.d.ts +11 -0
  14. package/dist/lib/dashboard-receipt.js +35 -0
  15. package/dist/lib/dashboard.schema.d.ts +816 -0
  16. package/dist/lib/dashboard.schema.js +74 -0
  17. package/dist/lib/dashboard.service.d.ts +243 -0
  18. package/dist/lib/dashboard.service.js +185 -0
  19. package/dist/lib/document-libraries.d.ts +8 -0
  20. package/dist/lib/document-libraries.js +41 -0
  21. package/dist/lib/document-package.d.ts +41 -0
  22. package/dist/lib/document-package.js +25 -0
  23. package/dist/lib/editing.d.ts +403 -0
  24. package/dist/lib/editing.js +114 -0
  25. package/dist/lib/filter-evidence.d.ts +71 -0
  26. package/dist/lib/filter-evidence.js +60 -0
  27. package/dist/lib/html-guidance.d.ts +1 -0
  28. package/dist/lib/html-guidance.js +4 -0
  29. package/dist/lib/html-validation.d.ts +19 -0
  30. package/dist/lib/html-validation.js +136 -0
  31. package/dist/lib/middleware.d.ts +10 -0
  32. package/dist/lib/middleware.js +225 -0
  33. package/dist/lib/plugin.d.ts +2 -0
  34. package/dist/lib/plugin.js +22 -0
  35. package/dist/lib/presentation.provider.d.ts +122 -0
  36. package/dist/lib/presentation.provider.js +72 -0
  37. package/dist/lib/remote-entry.d.ts +4 -0
  38. package/dist/lib/remote-entry.js +12 -0
  39. package/dist/lib/renderer.d.ts +58 -0
  40. package/dist/lib/renderer.js +32 -0
  41. package/dist/lib/resource-card.d.ts +21 -0
  42. package/dist/lib/resource-card.js +33 -0
  43. package/dist/lib/save-evidence.d.ts +24 -0
  44. package/dist/lib/save-evidence.js +99 -0
  45. package/dist/lib/sharing.service.d.ts +93 -0
  46. package/dist/lib/sharing.service.js +71 -0
  47. package/dist/lib/view.provider.d.ts +235 -0
  48. package/dist/lib/view.provider.js +103 -0
  49. package/dist/libraries/ECHARTS-LICENSE.txt +222 -0
  50. package/dist/libraries/ECHARTS-NOTICE.txt +5 -0
  51. package/dist/libraries/THREE-LICENSE.txt +21 -0
  52. package/dist/libraries/catalog.json +1 -0
  53. package/dist/remote/app.css +1 -0
  54. package/dist/remote/app.js +253 -0
  55. package/dist/remote/build-manifest.json +63 -0
  56. package/dist/remote/renderer-source.json +5 -0
  57. package/dist/remote/renderer.html +4653 -0
  58. package/dist/sandbox-actions/action.json +10 -0
  59. package/dist/sandbox-actions/bundle/host.js +149 -0
  60. package/dist/sandbox-actions/bundle/runner.mjs +15 -0
  61. package/dist/sandbox-actions/bundle/validate.mjs +140 -0
  62. package/dist/validation/host-entry.d.ts +1 -0
  63. package/dist/validation/host-entry.js +6 -0
  64. package/docs/AGENTS.md +9 -0
  65. package/docs/acceptance.md +89 -0
  66. package/docs/agent-acceptance.md +96 -0
  67. package/docs/chat-resource-cards.mdx +60 -0
  68. package/docs/docs.json +49 -0
  69. package/docs/drafts-acceptance.mdx +42 -0
  70. package/docs/drafts.mdx +35 -0
  71. package/docs/editing.mdx +63 -0
  72. package/docs/evolution-acceptance.mdx +98 -0
  73. package/docs/file-authoring-acceptance.mdx +62 -0
  74. package/docs/file-authoring.mdx +49 -0
  75. package/docs/file-datasets-acceptance.mdx +65 -0
  76. package/docs/fixed-build-multimodel-acceptance.mdx +129 -0
  77. package/docs/frontend-libraries-acceptance.mdx +86 -0
  78. package/docs/frontend-libraries.mdx +57 -0
  79. package/docs/html-acceptance.md +86 -0
  80. package/docs/html-mode.md +76 -0
  81. package/docs/index.mdx +47 -0
  82. package/docs/retry-regression-acceptance.mdx +112 -0
  83. package/docs/team-sharing-acceptance.mdx +66 -0
  84. package/docs/team-sharing.mdx +44 -0
  85. package/docs/verification.mdx +91 -0
  86. package/examples/assistant-middleware.yaml +28 -0
  87. package/examples/data-xpert-sales.json +118 -0
  88. package/examples/postgres-sales.json +93 -0
  89. package/index.cjs +1 -0
  90. package/package.json +73 -3
  91. package/skills/live-dashboard/SKILL.md +71 -0
  92. package/skills/live-dashboard/agents/xpertai.yaml +21 -0
  93. package/skills/live-dashboard/references/data-validation.md +15 -0
  94. package/skills/live-dashboard/references/html-lifecycle.md +129 -0
  95. package/skills/live-dashboard/references/html-runtime.md +53 -0
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dashboardNavigationKey = exports.dashboardNavigationSchema = exports.DASHBOARD_VIEW_KEY = void 0;
4
+ const v3_1 = require("zod/v3");
5
+ // The host namespaces provider + local view key; cards use the resolved public key.
6
+ exports.DASHBOARD_VIEW_KEY = 'live-dashboard__live-dashboard';
7
+ exports.dashboardNavigationSchema = v3_1.z.object({
8
+ selectionId: v3_1.z.string().uuid().optional(),
9
+ parameters: v3_1.z.object({ artifactId: v3_1.z.string().uuid().optional(), versionId: v3_1.z.string().uuid().optional() }).strict().optional()
10
+ }).transform((query, ctx) => {
11
+ const artifactId = query.selectionId ?? query.parameters?.artifactId;
12
+ const versionId = query.parameters?.versionId;
13
+ if (query.selectionId && query.parameters?.artifactId && query.selectionId !== query.parameters.artifactId || versionId && !artifactId)
14
+ ctx.addIssue({ code: v3_1.z.ZodIssueCode.custom, message: 'DASHBOARD_NAVIGATION_INVALID: provide one Artifact identity and an optional version' });
15
+ return { artifactId, versionId };
16
+ });
17
+ const dashboardNavigationKey = (target) => JSON.stringify([target.artifactId ?? null, target.versionId ?? null]);
18
+ exports.dashboardNavigationKey = dashboardNavigationKey;
@@ -0,0 +1,8 @@
1
+ import type { AnalyticalDataset, AnalyticsValue } from '@xpert-ai/contracts';
2
+ import { type DataSourceActor, type RuntimeCapabilityRegistry } from '@xpert-ai/plugin-sdk';
3
+ import type { DashboardManifest } from './dashboard.schema';
4
+ export declare function validateControls(manifest: DashboardManifest, input: Record<string, AnalyticsValue>): {
5
+ [x: string]: AnalyticsValue;
6
+ };
7
+ export declare function queryDashboardBinding(runtime: RuntimeCapabilityRegistry, actor: DataSourceActor, manifest: DashboardManifest, bindingId: string, input: Record<string, AnalyticsValue>): Promise<AnalyticalDataset>;
8
+ export declare function queryDashboard(runtime: RuntimeCapabilityRegistry, actor: DataSourceActor, manifest: DashboardManifest, input: Record<string, AnalyticsValue>): Promise<AnalyticalDataset[]>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateControls = validateControls;
4
+ exports.queryDashboardBinding = queryDashboardBinding;
5
+ exports.queryDashboard = queryDashboard;
6
+ const common_1 = require("@nestjs/common");
7
+ const plugin_sdk_1 = require("@xpert-ai/plugin-sdk");
8
+ function validateControls(manifest, input) {
9
+ if (Object.keys(input).some(id => !manifest.controls.some(control => control.controlId === id)))
10
+ throw new common_1.BadRequestException('DASHBOARD_UNKNOWN_CONTROL');
11
+ const values = { ...Object.fromEntries(manifest.controls.filter(control => control.defaultValue !== undefined).map(control => [control.controlId, control.defaultValue ?? null])), ...input };
12
+ for (const control of manifest.controls) {
13
+ const value = values[control.controlId];
14
+ if (value === undefined)
15
+ continue;
16
+ if (control.allowedValues && !control.allowedValues.includes(value))
17
+ throw new common_1.BadRequestException('DASHBOARD_CONTROL_VALUE_DENIED');
18
+ if (value !== null && (control.type === 'number' ? typeof value !== 'number' || !Number.isFinite(value) : control.type === 'boolean' ? typeof value !== 'boolean' : typeof value !== 'string'))
19
+ throw new common_1.BadRequestException('DASHBOARD_CONTROL_TYPE_INVALID');
20
+ }
21
+ return values;
22
+ }
23
+ async function queryDashboardBinding(runtime, actor, manifest, bindingId, input) {
24
+ const binding = manifest.bindings.find(item => item.id === bindingId);
25
+ if (!binding)
26
+ throw new common_1.ForbiddenException('DASHBOARD_BINDING_DENIED');
27
+ const controls = validateControls(manifest, input);
28
+ const selected = Object.fromEntries(Object.entries(controls).filter(([id]) => binding.parameters.some(parameter => parameter.controlId === id)));
29
+ return runtime.require(plugin_sdk_1.AnalyticsRuntimeCapability).query(actor, { binding, controls: selected });
30
+ }
31
+ async function queryDashboard(runtime, actor, manifest, input) {
32
+ validateControls(manifest, input);
33
+ const datasets = [];
34
+ for (const binding of manifest.bindings)
35
+ datasets.push(await queryDashboardBinding(runtime, actor, manifest, binding.id, input));
36
+ if (Buffer.byteLength(JSON.stringify(datasets)) > 3_000_000)
37
+ throw new common_1.BadRequestException('DASHBOARD_RESULT_TOO_LARGE');
38
+ return datasets;
39
+ }
@@ -0,0 +1,11 @@
1
+ export declare const DASHBOARD_MUTATION_TOOLS: string[];
2
+ /** Tool start/failed logs can share the host event channel; only a saved receipt opens a View. */
3
+ export declare function createdDashboard(output: unknown): {
4
+ status: "draft";
5
+ artifactId: string;
6
+ draftRevision: number;
7
+ } | null;
8
+ export declare function savedDashboardSource(output: unknown): {
9
+ path: string;
10
+ sha256: string;
11
+ } | null;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DASHBOARD_MUTATION_TOOLS = void 0;
4
+ exports.createdDashboard = createdDashboard;
5
+ exports.savedDashboardSource = savedDashboardSource;
6
+ const v3_1 = require("zod/v3");
7
+ exports.DASHBOARD_MUTATION_TOOLS = ['dashboard_create', 'dashboard_create_html', 'dashboard_update'];
8
+ const receiptSchema = v3_1.z.object({ dashboard: v3_1.z.object({ artifactId: v3_1.z.string().uuid(), draftRevision: v3_1.z.number().int().positive(), status: v3_1.z.literal('draft') }) });
9
+ /** Tool start/failed logs can share the host event channel; only a saved receipt opens a View. */
10
+ function createdDashboard(output) {
11
+ let value = output;
12
+ if (typeof value === 'string') {
13
+ try {
14
+ value = JSON.parse(value);
15
+ }
16
+ catch {
17
+ return null;
18
+ }
19
+ }
20
+ const parsed = receiptSchema.safeParse(value);
21
+ return parsed.success ? parsed.data.dashboard : null;
22
+ }
23
+ function savedDashboardSource(output) {
24
+ let value = output;
25
+ if (typeof value === 'string') {
26
+ try {
27
+ value = JSON.parse(value);
28
+ }
29
+ catch {
30
+ return null;
31
+ }
32
+ }
33
+ const parsed = v3_1.z.object({ sourceFile: v3_1.z.object({ path: v3_1.z.string(), sha256: v3_1.z.string().regex(/^[a-f0-9]{64}$/) }) }).safeParse(value);
34
+ return parsed.success ? parsed.data.sourceFile : null;
35
+ }