@xpert-ai/plugin-live-dashboard 0.7.0 → 0.7.2

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 (66) hide show
  1. package/.xpertai-plugin/plugin.json +1 -1
  2. package/README.md +2 -2
  3. package/dist/lib/analysis-scene-tool.d.ts +8 -8
  4. package/dist/lib/analysis-scene.schema.d.ts +6 -6
  5. package/dist/lib/artifact-type.provider.js +38 -1
  6. package/dist/lib/bundled-example-source.d.ts +11 -0
  7. package/dist/lib/bundled-example-source.js +60 -0
  8. package/dist/lib/certification.schema.d.ts +4 -0
  9. package/dist/lib/certification.schema.js +14 -0
  10. package/dist/lib/content-capability.js +1 -0
  11. package/dist/lib/dashboard-delivery.d.ts +11 -0
  12. package/dist/lib/dashboard-delivery.js +55 -0
  13. package/dist/lib/dashboard-download-policy.d.ts +4 -0
  14. package/dist/lib/dashboard-download-policy.js +7 -0
  15. package/dist/lib/dashboard-navigation.d.ts +5 -5
  16. package/dist/lib/dashboard-queries.d.ts +2 -2
  17. package/dist/lib/dashboard-queries.js +2 -2
  18. package/dist/lib/dashboard-view.schema.d.ts +10 -10
  19. package/dist/lib/dashboard.schema.d.ts +18 -0
  20. package/dist/lib/dashboard.schema.js +2 -1
  21. package/dist/lib/dashboard.service.d.ts +11 -2
  22. package/dist/lib/dashboard.service.js +17 -4
  23. package/dist/lib/definition-tools.d.ts +14 -54
  24. package/dist/lib/definition-tools.js +29 -9
  25. package/dist/lib/document-host.d.ts +1 -1
  26. package/dist/lib/document-host.js +2 -1
  27. package/dist/lib/editing-session.d.ts +4 -4
  28. package/dist/lib/evidence/evidence-diff.d.ts +17 -0
  29. package/dist/lib/evidence/evidence-diff.js +30 -0
  30. package/dist/lib/evidence/evidence-transfers.d.ts +14 -0
  31. package/dist/lib/evidence/evidence-transfers.js +41 -0
  32. package/dist/lib/evidence/evidence-view.provider.d.ts +91 -0
  33. package/dist/lib/evidence/evidence-view.provider.js +92 -0
  34. package/dist/lib/evidence/evidence.entity.d.ts +14 -0
  35. package/dist/lib/evidence/evidence.entity.js +62 -0
  36. package/dist/lib/evidence/evidence.provider.d.ts +43 -0
  37. package/dist/lib/evidence/evidence.provider.js +91 -0
  38. package/dist/lib/evidence/evidence.service.d.ts +67 -0
  39. package/dist/lib/evidence/evidence.service.js +218 -0
  40. package/dist/lib/middleware.d.ts +6 -2
  41. package/dist/lib/middleware.js +95 -11
  42. package/dist/lib/monitor.js +2 -2
  43. package/dist/lib/plugin.js +6 -1
  44. package/dist/lib/query-session.d.ts +1 -1
  45. package/dist/lib/query-session.js +13 -8
  46. package/dist/lib/remote-entry.d.ts +1 -1
  47. package/dist/lib/runtime-context.d.ts +2 -0
  48. package/dist/lib/runtime-context.js +21 -0
  49. package/dist/lib/source-executions.d.ts +36 -18
  50. package/dist/lib/source-executions.js +2 -1
  51. package/dist/lib/templates.js +5 -5
  52. package/dist/lib/view.provider.js +7 -1
  53. package/dist/remote/app.css +1 -1
  54. package/dist/remote/app.js +23 -23
  55. package/dist/remote/build-manifest.json +48 -37
  56. package/dist/sandbox-actions/action.json +1 -1
  57. package/dist/sandbox-actions/bundle/host.js +2 -2
  58. package/docs/editing.mdx +6 -0
  59. package/docs/html-mode.md +1 -1
  60. package/package.json +5 -5
  61. package/skills/live-dashboard/SKILL.md +1 -1
  62. package/skills/live-dashboard/examples/README.md +2 -2
  63. package/skills/live-dashboard/examples/production-quality/README.md +2 -2
  64. package/skills/live-dashboard/examples/regional-sales/README.md +3 -3
  65. package/skills/live-dashboard/examples/regional-sales/query.json +49 -1
  66. package/skills/live-dashboard/examples/sales-overview/README.md +2 -2
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpert-ai/plugin-live-dashboard",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "level": "system",
5
5
  "artifactNamespace": "live_dashboard",
6
6
  "sandboxActions": "./dist/sandbox-actions/action.json",
package/README.md CHANGED
@@ -208,11 +208,11 @@ HTML is capped at 300 KB; the whole saved definition remains capped at 600 KB. H
208
208
 
209
209
  Build reads the compressed renderer assets from the published `@xpert-ai/community-data-analytics@0.1.35` package, copies original renderer bytes into `dist/remote/renderer.html`, and records SHA-256 in `renderer-source.json`. Never edit minified assets. One adapter translates Dataset fields into Data Analytics v1 encodings and snapshots.
210
210
 
211
- The renderer runs in a script-only sandbox with no-network CSP. A small in-memory fetch adapter provides manifest/snapshot/package endpoints because srcDoc has no HTTP origin. Exact table rows are preserved; chart copies convert supported numeric strings and reject precision loss. Render payloads are capped at 3 MB.
211
+ The standard viewer iframe allows scripts and browser file downloads. Its document keeps the renderer CSP, including the no-network fetch policy. A small in-memory fetch adapter provides manifest/snapshot/package endpoints because srcDoc has no HTTP origin. Exact table rows are preserved; chart copies convert supported numeric strings and reject precision loss. Render payloads are capped at 3 MB.
212
212
 
213
213
  ## Build and validation
214
214
 
215
- Use the xpertai workspace's declared Corepack/pnpm. Live Dashboard uses published SDK/contracts 3.35.0 for resource discovery, group sharing and inline widget presentation. Development dependencies pin the Data Analytics renderer to 0.1.35. SDK 3.33.0 supplies the host-owned online resource policy, bounded query scheduler and grouped query runtime without a local SDK patch. Rebuild both the viewer and HTML preflight assets after changing the SDK; `verify:dist` checks their source fingerprints.
215
+ Use the xpertai workspace's declared Corepack/pnpm. The viewer and HTML preflight bundles are built with published `@xpert-ai/plugin-sdk` 3.38.0 and `@xpert-ai/contracts` 3.38.0. SDK 3.38.0 is the first release that applies `allowDownloads` while mounting an artifact document; 3.37.2 and earlier always set `sandbox="allow-scripts"`. Its type surface depends on contracts 3.38.0, so the dashboard build pins that same contracts version and does not keep a second 3.36.0 copy. Host peer ranges stay `^3.36.0`: the Nest plugin does not apply the document sandbox, and the browser bundles do. The interactive HTML viewer passes `allowDownloads: true`. HTML preflight calls the same mount without that option, so its sandbox stays script-only. The standard viewer sets `allow-scripts allow-downloads` on its own iframe and does not call the artifact-document mount. Development dependencies pin the Data Analytics renderer to 0.1.35. SDK 3.33.0 supplies the host-owned online resource policy, bounded query scheduler and grouped query runtime without a local SDK patch. Rebuild both the viewer and HTML preflight assets after changing the SDK; `verify:dist` checks their source fingerprints.
216
216
 
217
217
  ```sh
218
218
  corepack pnpm install --frozen-lockfile
@@ -11,10 +11,10 @@ export declare function createAnalysisSceneTool(query: (previewId: string) => Pr
11
11
  direction: import("zod").ZodEnum<["asc", "desc"]>;
12
12
  }, "strict", import("zod").ZodTypeAny, {
13
13
  field: string;
14
- direction: "desc" | "asc";
14
+ direction: "asc" | "desc";
15
15
  }, {
16
16
  field: string;
17
- direction: "desc" | "asc";
17
+ direction: "asc" | "desc";
18
18
  }>>;
19
19
  language: import("zod").ZodOptional<import("zod").ZodEnum<["zh-Hans", "en"]>>;
20
20
  maxRows: import("zod").ZodDefault<import("zod").ZodNumber>;
@@ -26,7 +26,7 @@ export declare function createAnalysisSceneTool(query: (previewId: string) => Pr
26
26
  maxRows: number;
27
27
  orderBy?: {
28
28
  field: string;
29
- direction: "desc" | "asc";
29
+ direction: "asc" | "desc";
30
30
  } | undefined;
31
31
  language?: "en" | "zh-Hans" | undefined;
32
32
  }, {
@@ -36,7 +36,7 @@ export declare function createAnalysisSceneTool(query: (previewId: string) => Pr
36
36
  previewId: string;
37
37
  orderBy?: {
38
38
  field: string;
39
- direction: "desc" | "asc";
39
+ direction: "asc" | "desc";
40
40
  } | undefined;
41
41
  language?: "en" | "zh-Hans" | undefined;
42
42
  maxRows?: number | undefined;
@@ -48,7 +48,7 @@ export declare function createAnalysisSceneTool(query: (previewId: string) => Pr
48
48
  maxRows: number;
49
49
  orderBy?: {
50
50
  field: string;
51
- direction: "desc" | "asc";
51
+ direction: "asc" | "desc";
52
52
  } | undefined;
53
53
  language?: "en" | "zh-Hans" | undefined;
54
54
  }, {
@@ -58,7 +58,7 @@ export declare function createAnalysisSceneTool(query: (previewId: string) => Pr
58
58
  previewId: string;
59
59
  orderBy?: {
60
60
  field: string;
61
- direction: "desc" | "asc";
61
+ direction: "asc" | "desc";
62
62
  } | undefined;
63
63
  language?: "en" | "zh-Hans" | undefined;
64
64
  maxRows?: number | undefined;
@@ -70,7 +70,7 @@ export declare function createAnalysisSceneTool(query: (previewId: string) => Pr
70
70
  maxRows: number;
71
71
  orderBy?: {
72
72
  field: string;
73
- direction: "desc" | "asc";
73
+ direction: "asc" | "desc";
74
74
  } | undefined;
75
75
  language?: "en" | "zh-Hans" | undefined;
76
76
  }, {
@@ -80,7 +80,7 @@ export declare function createAnalysisSceneTool(query: (previewId: string) => Pr
80
80
  previewId: string;
81
81
  orderBy?: {
82
82
  field: string;
83
- direction: "desc" | "asc";
83
+ direction: "asc" | "desc";
84
84
  } | undefined;
85
85
  language?: "en" | "zh-Hans" | undefined;
86
86
  maxRows?: number | undefined;
@@ -10,10 +10,10 @@ export declare const analysisSceneSchema: z.ZodEffects<z.ZodObject<{
10
10
  direction: z.ZodEnum<["asc", "desc"]>;
11
11
  }, "strict", z.ZodTypeAny, {
12
12
  field: string;
13
- direction: "desc" | "asc";
13
+ direction: "asc" | "desc";
14
14
  }, {
15
15
  field: string;
16
- direction: "desc" | "asc";
16
+ direction: "asc" | "desc";
17
17
  }>>;
18
18
  language: z.ZodOptional<z.ZodEnum<["zh-Hans", "en"]>>;
19
19
  maxRows: z.ZodDefault<z.ZodNumber>;
@@ -25,7 +25,7 @@ export declare const analysisSceneSchema: z.ZodEffects<z.ZodObject<{
25
25
  maxRows: number;
26
26
  orderBy?: {
27
27
  field: string;
28
- direction: "desc" | "asc";
28
+ direction: "asc" | "desc";
29
29
  } | undefined;
30
30
  language?: "en" | "zh-Hans" | undefined;
31
31
  }, {
@@ -35,7 +35,7 @@ export declare const analysisSceneSchema: z.ZodEffects<z.ZodObject<{
35
35
  previewId: string;
36
36
  orderBy?: {
37
37
  field: string;
38
- direction: "desc" | "asc";
38
+ direction: "asc" | "desc";
39
39
  } | undefined;
40
40
  language?: "en" | "zh-Hans" | undefined;
41
41
  maxRows?: number | undefined;
@@ -47,7 +47,7 @@ export declare const analysisSceneSchema: z.ZodEffects<z.ZodObject<{
47
47
  maxRows: number;
48
48
  orderBy?: {
49
49
  field: string;
50
- direction: "desc" | "asc";
50
+ direction: "asc" | "desc";
51
51
  } | undefined;
52
52
  language?: "en" | "zh-Hans" | undefined;
53
53
  }, {
@@ -57,7 +57,7 @@ export declare const analysisSceneSchema: z.ZodEffects<z.ZodObject<{
57
57
  previewId: string;
58
58
  orderBy?: {
59
59
  field: string;
60
- direction: "desc" | "asc";
60
+ direction: "asc" | "desc";
61
61
  } | undefined;
62
62
  language?: "en" | "zh-Hans" | undefined;
63
63
  maxRows?: number | undefined;
@@ -1,10 +1,43 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
2
18
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
19
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
20
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
21
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
22
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
23
  };
24
+ var __importStar = (this && this.__importStar) || (function () {
25
+ var ownKeys = function(o) {
26
+ ownKeys = Object.getOwnPropertyNames || function (o) {
27
+ var ar = [];
28
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
29
+ return ar;
30
+ };
31
+ return ownKeys(o);
32
+ };
33
+ return function (mod) {
34
+ if (mod && mod.__esModule) return mod;
35
+ var result = {};
36
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
37
+ __setModuleDefault(result, mod);
38
+ return result;
39
+ };
40
+ })();
8
41
  var __metadata = (this && this.__metadata) || function (k, v) {
9
42
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
43
  };
@@ -16,12 +49,16 @@ exports.DashboardArtifactType = void 0;
16
49
  const dashboard_artifact_1 = require("./dashboard-artifact");
17
50
  const dashboard_queries_1 = require("./dashboard-queries");
18
51
  const dashboard_service_1 = require("./dashboard.service");
52
+ const hostSdk = __importStar(require("@xpert-ai/plugin-sdk"));
19
53
  const common_1 = require("@nestjs/common");
20
54
  const plugin_sdk_1 = require("@xpert-ai/plugin-sdk");
21
55
  const document_package_1 = require("./document-package");
22
56
  const dashboard_sharing_1 = require("./dashboard-sharing");
23
57
  const content_type_1 = require("./content-type");
24
58
  const dashboard_icon_1 = require("./dashboard-icon");
59
+ const dashboard_download_policy_1 = require("./dashboard-download-policy");
60
+ // The host supplies the SDK. Older hosts reject unknown presentation fields at registration.
61
+ const sdk = hostSdk;
25
62
  /** Drafts require Project edit access; explicit authenticated shares may expand formal-version readership. */
26
63
  let DashboardArtifactType = class DashboardArtifactType {
27
64
  constructor(runtime, dashboards) {
@@ -37,7 +74,7 @@ let DashboardArtifactType = class DashboardArtifactType {
37
74
  useGrants: { audience: 'group', permission: 'read', queryOperations: ['query', 'query-binding'] },
38
75
  sharing: { projectAccess: 'link-audience', accessModes: ['organization_all'], versionModes: ['latest', 'version'],
39
76
  allowDownload: false, mutableLinks: true, descriptor: true, shareKey: dashboard_sharing_1.DASHBOARD_SHARE_KEY },
40
- presentation: { mode: 'authenticated' }
77
+ presentation: sdk.authenticatedArtifactPresentation?.(dashboard_download_policy_1.DASHBOARD_DOWNLOAD_POLICY) ?? { mode: 'authenticated' }
41
78
  };
42
79
  this.analytics = {
43
80
  resolveBindings: context => (0, dashboard_artifact_1.readDashboardArtifact)(context).manifest.bindings.map(binding => ({ binding })),
@@ -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,11 @@
1
+ import { type BaseMessage } from '@langchain/core/messages';
2
+ /** Use this turn's actual delivery receipt, including after a checkpoint resume. */
3
+ export declare function dashboardDelivery(messages?: BaseMessage[]): {
4
+ guidance: string;
5
+ verifiedDraft: {
6
+ status: "draft";
7
+ artifactId: string;
8
+ draftRevision: number;
9
+ title?: string | undefined;
10
+ } | undefined;
11
+ } | null;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dashboardDelivery = dashboardDelivery;
4
+ const messages_1 = require("@langchain/core/messages");
5
+ const v3_1 = require("zod/v3");
6
+ const dashboard_receipt_1 = require("./dashboard-receipt");
7
+ const savedCard = v3_1.z.object({
8
+ dashboard: v3_1.z.object({ artifactId: v3_1.z.string().uuid(), title: v3_1.z.string().optional(), draftRevision: v3_1.z.number().int().positive(), status: v3_1.z.literal('draft') }),
9
+ resourceCard: v3_1.z.object({ status: v3_1.z.enum(['emitted', 'unavailable']) })
10
+ });
11
+ const openedDraft = v3_1.z.object({ artifactId: v3_1.z.string().uuid(), state: v3_1.z.literal('draft'), expectedRevision: v3_1.z.number(), readVersionId: v3_1.z.undefined() });
12
+ function output(content) {
13
+ if (typeof content !== 'string')
14
+ return null;
15
+ try {
16
+ return JSON.parse(content);
17
+ }
18
+ catch {
19
+ return null;
20
+ }
21
+ }
22
+ /** Use this turn's actual delivery receipt, including after a checkpoint resume. */
23
+ function dashboardDelivery(messages = []) {
24
+ let lastRead;
25
+ let lastTool = true;
26
+ for (let i = messages.length - 1; i >= 0; i--) {
27
+ const message = messages[i];
28
+ if (message.getType() === 'human')
29
+ break;
30
+ if (!(0, messages_1.isToolMessage)(message))
31
+ continue;
32
+ if (lastTool && message.name === 'dashboard_open' && message.status !== 'error') {
33
+ const read = openedDraft.safeParse(output(message.content));
34
+ if (read.success)
35
+ lastRead = read.data;
36
+ }
37
+ lastTool = false;
38
+ if (message.status === 'error' || !message.name || !dashboard_receipt_1.DASHBOARD_MUTATION_TOOLS.includes(message.name))
39
+ continue;
40
+ const result = savedCard.safeParse(output(message.content));
41
+ if (!result.success)
42
+ continue;
43
+ const { dashboard, resourceCard } = result.data;
44
+ return {
45
+ guidance: `Draft ${dashboard.artifactId} revision ${dashboard.draftRevision} is saved. ` +
46
+ (resourceCard.status === 'emitted'
47
+ ? 'Its clickable Open card has already been delivered to this conversation. A request for an openable dashboard or a card is fulfilled by that delivery.'
48
+ : 'Card delivery was unavailable. The saved dashboard is available in the Workbench picker.') +
49
+ ' Reply with the result when this fulfills the request. Use editing tools only for outstanding changes.',
50
+ verifiedDraft: resourceCard.status === 'emitted' && lastRead?.artifactId === dashboard.artifactId &&
51
+ lastRead.expectedRevision === dashboard.draftRevision ? dashboard : undefined
52
+ };
53
+ }
54
+ return null;
55
+ }
@@ -0,0 +1,4 @@
1
+ export declare const DASHBOARD_DOWNLOAD_POLICY: Readonly<{
2
+ allowDownloads: true;
3
+ }>;
4
+ export declare const DASHBOARD_FRAME_SANDBOX: string;
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DASHBOARD_FRAME_SANDBOX = exports.DASHBOARD_DOWNLOAD_POLICY = void 0;
4
+ exports.DASHBOARD_DOWNLOAD_POLICY = Object.freeze({
5
+ allowDownloads: true
6
+ });
7
+ exports.DASHBOARD_FRAME_SANDBOX = exports.DASHBOARD_DOWNLOAD_POLICY.allowDownloads ? 'allow-scripts allow-downloads' : 'allow-scripts';
@@ -38,11 +38,11 @@ export declare const dashboardNavigationSchema: z.ZodEffects<z.ZodObject<{
38
38
  mode?: "draft" | "published" | undefined;
39
39
  versionId?: string | undefined;
40
40
  draftRevision?: number | undefined;
41
+ contentId?: string | undefined;
41
42
  pipelineInstanceId?: string | undefined;
42
43
  pipelineRoundId?: string | undefined;
43
44
  pipelineNodeId?: string | undefined;
44
45
  contentProvider?: string | undefined;
45
- contentId?: string | undefined;
46
46
  contentTitle?: string | undefined;
47
47
  contentEditor?: string | undefined;
48
48
  newDashboard?: boolean | undefined;
@@ -52,11 +52,11 @@ export declare const dashboardNavigationSchema: z.ZodEffects<z.ZodObject<{
52
52
  mode?: "draft" | "published" | undefined;
53
53
  versionId?: string | undefined;
54
54
  draftRevision?: number | undefined;
55
+ contentId?: string | undefined;
55
56
  pipelineInstanceId?: string | undefined;
56
57
  pipelineRoundId?: string | undefined;
57
58
  pipelineNodeId?: string | undefined;
58
59
  contentProvider?: string | undefined;
59
- contentId?: string | undefined;
60
60
  contentTitle?: string | undefined;
61
61
  contentEditor?: string | undefined;
62
62
  newDashboard?: boolean | undefined;
@@ -68,11 +68,11 @@ export declare const dashboardNavigationSchema: z.ZodEffects<z.ZodObject<{
68
68
  mode?: "draft" | "published" | undefined;
69
69
  versionId?: string | undefined;
70
70
  draftRevision?: number | undefined;
71
+ contentId?: string | undefined;
71
72
  pipelineInstanceId?: string | undefined;
72
73
  pipelineRoundId?: string | undefined;
73
74
  pipelineNodeId?: string | undefined;
74
75
  contentProvider?: string | undefined;
75
- contentId?: string | undefined;
76
76
  contentTitle?: string | undefined;
77
77
  contentEditor?: string | undefined;
78
78
  newDashboard?: boolean | undefined;
@@ -87,11 +87,11 @@ export declare const dashboardNavigationSchema: z.ZodEffects<z.ZodObject<{
87
87
  mode?: "draft" | "published" | undefined;
88
88
  versionId?: string | undefined;
89
89
  draftRevision?: number | undefined;
90
+ contentId?: string | undefined;
90
91
  pipelineInstanceId?: string | undefined;
91
92
  pipelineRoundId?: string | undefined;
92
93
  pipelineNodeId?: string | undefined;
93
94
  contentProvider?: string | undefined;
94
- contentId?: string | undefined;
95
95
  contentTitle?: string | undefined;
96
96
  contentEditor?: string | undefined;
97
97
  newDashboard?: boolean | undefined;
@@ -115,11 +115,11 @@ export declare const dashboardNavigationSchema: z.ZodEffects<z.ZodObject<{
115
115
  mode?: "draft" | "published" | undefined;
116
116
  versionId?: string | undefined;
117
117
  draftRevision?: number | undefined;
118
+ contentId?: string | undefined;
118
119
  pipelineInstanceId?: string | undefined;
119
120
  pipelineRoundId?: string | undefined;
120
121
  pipelineNodeId?: string | undefined;
121
122
  contentProvider?: string | undefined;
122
- contentId?: string | undefined;
123
123
  contentTitle?: string | undefined;
124
124
  contentEditor?: string | undefined;
125
125
  newDashboard?: boolean | undefined;
@@ -1,10 +1,10 @@
1
- import type { AnalyticalDataset, AnalyticsValue } from '@xpert-ai/contracts';
1
+ import type { AnalyticalDataset, AnalyticsValue, AnalyticsQueryRequest } from '@xpert-ai/contracts';
2
2
  import { type DataSourceActor, type RuntimeCapabilityRegistry } from '@xpert-ai/plugin-sdk';
3
3
  import type { DashboardManifest } from './dashboard.schema';
4
4
  export declare function validateControls(manifest: DashboardManifest, input: Record<string, AnalyticsValue>): {
5
5
  [x: string]: AnalyticsValue;
6
6
  };
7
- export declare function queryDashboardBinding(runtime: RuntimeCapabilityRegistry, actor: DataSourceActor, manifest: DashboardManifest, bindingId: string, input: Record<string, AnalyticsValue>): Promise<AnalyticalDataset>;
7
+ export declare function queryDashboardBinding(runtime: RuntimeCapabilityRegistry, actor: DataSourceActor, manifest: DashboardManifest, bindingId: string, input: Record<string, AnalyticsValue>, cache?: AnalyticsQueryRequest['cache']): Promise<AnalyticalDataset>;
8
8
  export declare function queryDashboard(runtime: RuntimeCapabilityRegistry, actor: DataSourceActor, manifest: DashboardManifest, input: Record<string, AnalyticsValue>, progress?: (completed: number) => Promise<void>): Promise<AnalyticalDataset[]>;
9
9
  /** Read-only rendering can show independent successful bindings. Saving/publishing still
10
10
  * uses queryDashboard and requires every binding to validate. Never return native error
@@ -22,13 +22,13 @@ function validateControls(manifest, input) {
22
22
  }
23
23
  return values;
24
24
  }
25
- async function queryDashboardBinding(runtime, actor, manifest, bindingId, input) {
25
+ async function queryDashboardBinding(runtime, actor, manifest, bindingId, input, cache) {
26
26
  const binding = manifest.bindings.find(item => item.id === bindingId);
27
27
  if (!binding)
28
28
  throw new common_1.ForbiddenException('DASHBOARD_BINDING_DENIED');
29
29
  const controls = validateControls(manifest, input);
30
30
  const selected = Object.fromEntries(Object.entries(controls).filter(([id]) => binding.parameters.some(parameter => parameter.controlId === id)));
31
- return runtime.require(plugin_sdk_1.AnalyticsRuntimeCapability).query(actor, { binding, controls: selected });
31
+ return runtime.require(plugin_sdk_1.AnalyticsRuntimeCapability).query(actor, { binding, controls: selected, ...(cache ? { cache } : {}) });
32
32
  }
33
33
  async function queryDashboard(runtime, actor, manifest, input, progress) {
34
34
  validateControls(manifest, input);
@@ -801,23 +801,23 @@ export declare const dashboardSavedSchema: z.ZodObject<{
801
801
  source: z.ZodString;
802
802
  }, "strict", z.ZodTypeAny, {
803
803
  id?: string;
804
+ source?: string;
804
805
  version?: string;
805
806
  sha256?: string;
806
- source?: string;
807
807
  format?: "classic-script";
808
808
  global?: string;
809
809
  }, {
810
810
  id?: string;
811
+ source?: string;
811
812
  version?: string;
812
813
  sha256?: string;
813
- source?: string;
814
814
  format?: "classic-script";
815
815
  global?: string;
816
816
  }>, import("@xpert-ai/plugin-sdk/artifact-document").ArtifactDocumentDependencyAsset, {
817
817
  id?: string;
818
+ source?: string;
818
819
  version?: string;
819
820
  sha256?: string;
820
- source?: string;
821
821
  format?: "classic-script";
822
822
  global?: string;
823
823
  }>, "many">>;
@@ -1010,9 +1010,9 @@ export declare const dashboardSavedSchema: z.ZodObject<{
1010
1010
  title?: string | null | undefined;
1011
1011
  dependencies?: {
1012
1012
  id?: string;
1013
+ source?: string;
1013
1014
  version?: string;
1014
1015
  sha256?: string;
1015
- source?: string;
1016
1016
  format?: "classic-script";
1017
1017
  global?: string;
1018
1018
  }[] | undefined;
@@ -1853,23 +1853,23 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
1853
1853
  source: z.ZodString;
1854
1854
  }, "strict", z.ZodTypeAny, {
1855
1855
  id?: string;
1856
+ source?: string;
1856
1857
  version?: string;
1857
1858
  sha256?: string;
1858
- source?: string;
1859
1859
  format?: "classic-script";
1860
1860
  global?: string;
1861
1861
  }, {
1862
1862
  id?: string;
1863
+ source?: string;
1863
1864
  version?: string;
1864
1865
  sha256?: string;
1865
- source?: string;
1866
1866
  format?: "classic-script";
1867
1867
  global?: string;
1868
1868
  }>, import("@xpert-ai/plugin-sdk/artifact-document").ArtifactDocumentDependencyAsset, {
1869
1869
  id?: string;
1870
+ source?: string;
1870
1871
  version?: string;
1871
1872
  sha256?: string;
1872
- source?: string;
1873
1873
  format?: "classic-script";
1874
1874
  global?: string;
1875
1875
  }>, "many">>;
@@ -2062,9 +2062,9 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
2062
2062
  title?: string | null | undefined;
2063
2063
  dependencies?: {
2064
2064
  id?: string;
2065
+ source?: string;
2065
2066
  version?: string;
2066
2067
  sha256?: string;
2067
- source?: string;
2068
2068
  format?: "classic-script";
2069
2069
  global?: string;
2070
2070
  }[] | undefined;
@@ -2382,9 +2382,9 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
2382
2382
  title?: string | null | undefined;
2383
2383
  dependencies?: {
2384
2384
  id?: string;
2385
+ source?: string;
2385
2386
  version?: string;
2386
2387
  sha256?: string;
2387
- source?: string;
2388
2388
  format?: "classic-script";
2389
2389
  global?: string;
2390
2390
  }[] | undefined;
@@ -2717,9 +2717,9 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
2717
2717
  title?: string | null | undefined;
2718
2718
  dependencies?: {
2719
2719
  id?: string;
2720
+ source?: string;
2720
2721
  version?: string;
2721
2722
  sha256?: string;
2722
- source?: string;
2723
2723
  format?: "classic-script";
2724
2724
  global?: string;
2725
2725
  }[] | undefined;
@@ -1819,16 +1819,34 @@ export declare const queryBindingSchema: z.ZodObject<{
1819
1819
  controls: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBoolean, z.ZodNull]>>>;
1820
1820
  } & {
1821
1821
  bindingId: z.ZodString;
1822
+ cache: z.ZodOptional<z.ZodObject<{
1823
+ maxAgeMs: z.ZodNumber;
1824
+ forceRefresh: z.ZodOptional<z.ZodBoolean>;
1825
+ }, "strict", z.ZodTypeAny, {
1826
+ maxAgeMs: number;
1827
+ forceRefresh?: boolean | undefined;
1828
+ }, {
1829
+ maxAgeMs: number;
1830
+ forceRefresh?: boolean | undefined;
1831
+ }>>;
1822
1832
  }, "strict", z.ZodTypeAny, {
1823
1833
  bindingId: string;
1824
1834
  artifactId: string;
1825
1835
  controls: Record<string, string | number | boolean | null>;
1826
1836
  versionId?: string | undefined;
1827
1837
  draftRevision?: number | undefined;
1838
+ cache?: {
1839
+ maxAgeMs: number;
1840
+ forceRefresh?: boolean | undefined;
1841
+ } | undefined;
1828
1842
  }, {
1829
1843
  bindingId: string;
1830
1844
  artifactId: string;
1831
1845
  controls?: Record<string, string | number | boolean | null> | undefined;
1832
1846
  versionId?: string | undefined;
1833
1847
  draftRevision?: number | undefined;
1848
+ cache?: {
1849
+ maxAgeMs: number;
1850
+ forceRefresh?: boolean | undefined;
1851
+ } | undefined;
1834
1852
  }>;
@@ -96,4 +96,5 @@ exports.controlsSchema = v3_1.z.record(v3_1.z.union([v3_1.z.string().max(4000),
96
96
  exports.saveSchema = v3_1.z.object({ manifest: exports.dashboardSchema, expectedVersionId: v3_1.z.string().uuid().nullable(), expectedRevision: v3_1.z.number().int().nonnegative().default(0) }).strict();
97
97
  exports.querySchema = v3_1.z.object({ artifactId: v3_1.z.string().uuid(), versionId: v3_1.z.string().uuid().optional(), draftRevision: v3_1.z.number().int().positive().optional(), controls: exports.controlsSchema.default({}) }).strict();
98
98
  /** Generated pages select a saved Binding by ID. Query text, provider and source overrides are rejected. */
99
- exports.queryBindingSchema = exports.querySchema.extend({ bindingId: id }).strict();
99
+ exports.queryBindingSchema = exports.querySchema.extend({ bindingId: id,
100
+ cache: v3_1.z.object({ maxAgeMs: v3_1.z.number().int().min(0).max(60000), forceRefresh: v3_1.z.boolean().optional() }).strict().optional() }).strict();