@xpert-ai/plugin-live-dashboard 0.7.0 → 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 (61) 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/bundled-example-source.d.ts +11 -0
  6. package/dist/lib/bundled-example-source.js +60 -0
  7. package/dist/lib/certification.schema.d.ts +4 -0
  8. package/dist/lib/certification.schema.js +14 -0
  9. package/dist/lib/content-capability.js +1 -0
  10. package/dist/lib/dashboard-delivery.d.ts +11 -0
  11. package/dist/lib/dashboard-delivery.js +55 -0
  12. package/dist/lib/dashboard-navigation.d.ts +5 -5
  13. package/dist/lib/dashboard-queries.d.ts +2 -2
  14. package/dist/lib/dashboard-queries.js +2 -2
  15. package/dist/lib/dashboard-view.schema.d.ts +10 -10
  16. package/dist/lib/dashboard.schema.d.ts +18 -0
  17. package/dist/lib/dashboard.schema.js +2 -1
  18. package/dist/lib/dashboard.service.d.ts +11 -2
  19. package/dist/lib/dashboard.service.js +17 -4
  20. package/dist/lib/definition-tools.d.ts +14 -54
  21. package/dist/lib/definition-tools.js +29 -9
  22. package/dist/lib/editing-session.d.ts +4 -4
  23. package/dist/lib/evidence/evidence-diff.d.ts +17 -0
  24. package/dist/lib/evidence/evidence-diff.js +30 -0
  25. package/dist/lib/evidence/evidence-transfers.d.ts +14 -0
  26. package/dist/lib/evidence/evidence-transfers.js +41 -0
  27. package/dist/lib/evidence/evidence-view.provider.d.ts +91 -0
  28. package/dist/lib/evidence/evidence-view.provider.js +92 -0
  29. package/dist/lib/evidence/evidence.entity.d.ts +14 -0
  30. package/dist/lib/evidence/evidence.entity.js +62 -0
  31. package/dist/lib/evidence/evidence.provider.d.ts +43 -0
  32. package/dist/lib/evidence/evidence.provider.js +91 -0
  33. package/dist/lib/evidence/evidence.service.d.ts +67 -0
  34. package/dist/lib/evidence/evidence.service.js +218 -0
  35. package/dist/lib/middleware.d.ts +6 -2
  36. package/dist/lib/middleware.js +95 -11
  37. package/dist/lib/monitor.js +2 -2
  38. package/dist/lib/plugin.js +6 -1
  39. package/dist/lib/query-session.d.ts +1 -1
  40. package/dist/lib/query-session.js +13 -8
  41. package/dist/lib/remote-entry.d.ts +1 -1
  42. package/dist/lib/runtime-context.d.ts +2 -0
  43. package/dist/lib/runtime-context.js +21 -0
  44. package/dist/lib/source-executions.d.ts +36 -18
  45. package/dist/lib/source-executions.js +2 -1
  46. package/dist/lib/templates.js +5 -5
  47. package/dist/lib/view.provider.js +7 -1
  48. package/dist/remote/app.css +1 -1
  49. package/dist/remote/app.js +23 -23
  50. package/dist/remote/build-manifest.json +45 -35
  51. package/dist/sandbox-actions/action.json +1 -1
  52. package/dist/sandbox-actions/bundle/host.js +2 -2
  53. package/docs/editing.mdx +6 -0
  54. package/docs/html-mode.md +1 -1
  55. package/package.json +5 -5
  56. package/skills/live-dashboard/SKILL.md +1 -1
  57. package/skills/live-dashboard/examples/README.md +2 -2
  58. package/skills/live-dashboard/examples/production-quality/README.md +2 -2
  59. package/skills/live-dashboard/examples/regional-sales/README.md +3 -3
  60. package/skills/live-dashboard/examples/regional-sales/query.json +49 -1
  61. package/skills/live-dashboard/examples/sales-overview/README.md +2 -2
@@ -1,56 +1,16 @@
1
+ import { exampleIdSchema } from './bundled-example-source';
2
+ import type { AnalyticsBinding } from '@xpert-ai/contracts';
3
+ import type { AnalyticsDefinitionReceipt } from '@xpert-ai/plugin-sdk';
4
+ import { type DynamicStructuredTool } from '@langchain/core/tools';
1
5
  import { z } from 'zod/v3';
2
6
  import { type IAgentMiddlewareContext } from '@xpert-ai/plugin-sdk';
3
- export declare const DEFINITION_GUIDANCE = "If dashboard_list_sources lacks the requested source, call analytics_definition_connections, then analytics_definition_inspect with an exact returned selection and inputJson=\"{}\". Follow its instructions, inspect real source data and generate the business definition yourself. Never ask users to fill internal IDs/configuration. Register using analytics_definition_register and a stable requestId, refresh dashboard_list_sources, discover the returned source and preview before saving. Settings \u2192 Analytics is for viewing, correction and version management. Do not create redundant definitions for already governed sources.";
4
- export declare function createDefinitionTools(context: IAgentMiddlewareContext, registered: () => void): (import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{}, "strict", z.ZodTypeAny, {}, {}>, {}, {}, string> | import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
5
- providerId: z.ZodString;
6
- connectionKey: z.ZodString;
7
- } & {
8
- inputJson: z.ZodString;
9
- }, "strict", z.ZodTypeAny, {
10
- providerId: string;
11
- connectionKey: string;
12
- inputJson: string;
13
- }, {
14
- providerId: string;
15
- connectionKey: string;
16
- inputJson: string;
17
- }>, {
18
- providerId: string;
19
- connectionKey: string;
20
- inputJson: string;
21
- }, {
22
- providerId: string;
23
- connectionKey: string;
24
- inputJson: string;
25
- }, string> | import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
26
- providerId: z.ZodString;
27
- connectionKey: z.ZodString;
28
- } & {
29
- requestId: z.ZodString;
30
- name: z.ZodString;
31
- definitionJson: z.ZodString;
32
- }, "strict", z.ZodTypeAny, {
33
- name: string;
34
- requestId: string;
35
- providerId: string;
36
- connectionKey: string;
37
- definitionJson: string;
38
- }, {
39
- name: string;
40
- requestId: string;
41
- providerId: string;
42
- connectionKey: string;
43
- definitionJson: string;
44
- }>, {
45
- name: string;
46
- requestId: string;
47
- providerId: string;
48
- connectionKey: string;
49
- definitionJson: string;
50
- }, {
51
- name: string;
52
- requestId: string;
53
- providerId: string;
54
- connectionKey: string;
55
- definitionJson: string;
56
- }, string>)[];
7
+ export declare const DEFINITION_GUIDANCE = "If dashboard_list_sources lacks the requested source, call analytics_definition_connections, then analytics_definition_inspect with an exact returned selection and inputJson=\"{}\". Follow its instructions, inspect real source data and generate the business definition yourself. Never ask users to fill internal IDs/configuration. For a custom definition, register the inspected providerId, connectionKey, name, definitionJson and a stable requestId. For a bundled sample, register with only its exampleId. Refresh sources and preview before saving. Settings \u2192 Analytics is for viewing, correction and version management. Do not create redundant definitions for already governed sources.";
8
+ export declare function createDefinitionTools(context: IAgentMiddlewareContext, registered: () => void, selectExample?: (id: z.infer<typeof exampleIdSchema>, receipt?: AnalyticsDefinitionReceipt) => Promise<{
9
+ binding: AnalyticsBinding;
10
+ preparedQuery?: {
11
+ description: string;
12
+ previewRequest: {
13
+ exampleQuery: string;
14
+ };
15
+ };
16
+ } | undefined> | void): DynamicStructuredTool[];
@@ -2,19 +2,29 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DEFINITION_GUIDANCE = void 0;
4
4
  exports.createDefinitionTools = createDefinitionTools;
5
+ const bundled_example_source_1 = require("./bundled-example-source");
5
6
  const tools_1 = require("@langchain/core/tools");
7
+ const json_schema_1 = require("@langchain/core/utils/json_schema");
6
8
  const v3_1 = require("zod/v3");
7
9
  const plugin_sdk_1 = require("@xpert-ai/plugin-sdk");
8
10
  const selection = v3_1.z.object({ providerId: v3_1.z.string().min(1).max(160), connectionKey: v3_1.z.string().min(1).max(400) }).strict();
9
- exports.DEFINITION_GUIDANCE = 'If dashboard_list_sources lacks the requested source, call analytics_definition_connections, then analytics_definition_inspect with an exact returned selection and inputJson="{}". Follow its instructions, inspect real source data and generate the business definition yourself. Never ask users to fill internal IDs/configuration. Register using analytics_definition_register and a stable requestId, refresh dashboard_list_sources, discover the returned source and preview before saving. Settings → Analytics is for viewing, correction and version management. Do not create redundant definitions for already governed sources.';
10
- function createDefinitionTools(context, registered) {
11
+ exports.DEFINITION_GUIDANCE = 'If dashboard_list_sources lacks the requested source, call analytics_definition_connections, then analytics_definition_inspect with an exact returned selection and inputJson="{}". Follow its instructions, inspect real source data and generate the business definition yourself. Never ask users to fill internal IDs/configuration. For a custom definition, register the inspected providerId, connectionKey, name, definitionJson and a stable requestId. For a bundled sample, register with only its exampleId. Refresh sources and preview before saving. Settings → Analytics is for viewing, correction and version management. Do not create redundant definitions for already governed sources.';
12
+ const authoredSourceSchema = selection.extend({
13
+ requestId: v3_1.z.string().min(1).max(128).describe('Idempotency key for a custom definition.'), name: v3_1.z.string().min(1).max(200), definitionJson: v3_1.z.string().min(2).max(100000)
14
+ }).strict();
15
+ const sampleSchema = v3_1.z.object({ exampleId: bundled_example_source_1.exampleIdSchema }).strict().describe('Packaged sample. Supply only exampleId; the server derives its idempotency key.');
16
+ const registrationInput = v3_1.z.union([sampleSchema, authoredSourceSchema]);
17
+ // Keep an object root for model providers and expose the same exclusive input shapes the server validates.
18
+ const registrationSchema = { ...(0, json_schema_1.toJsonSchema)(registrationInput), type: 'object' };
19
+ function createDefinitionTools(context, registered, selectExample) {
11
20
  const api = () => {
12
21
  if (!context.workspaceId || !context.xpertId || !context.organizationId || !context.runtime?.capabilities)
13
22
  throw new Error('ANALYTICS_ASSISTANT_SCOPE_REQUIRED');
14
- return { runtime: context.runtime.capabilities.require(plugin_sdk_1.AnalyticsDefinitionAuthoringCapability), scope: {
23
+ const files = context.runtime.capabilities.require(plugin_sdk_1.WorkspaceFilesRuntimeCapability);
24
+ return { files, runtime: context.runtime.capabilities.require(plugin_sdk_1.AnalyticsDefinitionAuthoringCapability), scope: {
15
25
  actor: { tenantId: context.tenantId, organizationId: context.organizationId, userId: context.userId },
16
26
  workspaceId: context.workspaceId, xpertId: context.xpertId,
17
- files: context.runtime.capabilities.require(plugin_sdk_1.WorkspaceFilesRuntimeCapability)
27
+ files
18
28
  } };
19
29
  };
20
30
  return [
@@ -29,13 +39,23 @@ function createDefinitionTools(context, registered) {
29
39
  schema: selection.extend({ inputJson: v3_1.z.string().min(2).max(100000) }).strict(), verboseParsingErrors: true,
30
40
  metadata: { toolName: { en_US: 'Inspect analytics input', zh_Hans: '检查分析输入' } }
31
41
  }),
32
- (0, tools_1.tool)(async ({ definitionJson, ...input }) => {
33
- const { runtime, scope } = api();
34
- const receipt = await runtime.register(scope, { ...input, definition: plugin_sdk_1.analyticsOptionsSchema.parse(JSON.parse(definitionJson)) });
42
+ (0, tools_1.tool)(async (input) => {
43
+ const args = registrationInput.parse(input);
44
+ const { runtime, scope, files } = api();
45
+ if ('exampleId' in args) {
46
+ const { exampleId } = args;
47
+ await selectExample?.(exampleId);
48
+ const receipt = await (0, bundled_example_source_1.registerExampleSource)(exampleId, context.projectId, runtime, scope, files);
49
+ registered();
50
+ const discovery = await selectExample?.(exampleId, receipt);
51
+ return JSON.stringify({ ...receipt, exampleId, ...discovery });
52
+ }
53
+ const { definitionJson, ...selection } = args;
54
+ const receipt = await runtime.register(scope, { ...selection, definition: plugin_sdk_1.analyticsOptionsSchema.parse(JSON.parse(definitionJson)) });
35
55
  registered();
36
56
  return JSON.stringify(receipt);
37
- }, { name: 'analytics_definition_register', description: 'Register an Agent-generated definition matching definitionSchema. System supplies identities and validates real input. Keep requestId stable on retries; changed intent needs another key. Returns an immutable source and discoveryRequest. Refresh sources, discover and preview it before saving a dashboard.',
38
- schema: selection.extend({ requestId: v3_1.z.string().min(1).max(128), name: v3_1.z.string().min(1).max(200), definitionJson: v3_1.z.string().min(2).max(100000) }).strict(), verboseParsingErrors: true,
57
+ }, { name: 'analytics_definition_register', description: bundled_example_source_1.EXAMPLE_SOURCE_GUIDANCE + ' For a custom, Agent-authored definition use the separate providerId/connectionKey/requestId/name/definitionJson form. Only that form takes requestId. Returns an immutable source and discoveryRequest. Refresh sources, discover and preview it before saving a dashboard.',
58
+ schema: registrationSchema, verboseParsingErrors: true,
39
59
  metadata: { toolName: { en_US: 'Register analytics definition', zh_Hans: '生成分析定义' } }
40
60
  })
41
61
  ];
@@ -84,41 +84,41 @@ export declare const dashboardStateSchema: z.ZodObject<{
84
84
  draftRevision?: number | undefined;
85
85
  }>>;
86
86
  }, "strip", z.ZodTypeAny, {
87
+ scope: string;
87
88
  target: {
88
89
  artifactId: string;
89
90
  schemaVersion: 1;
90
91
  versionId?: string | undefined;
91
92
  draftRevision?: number | undefined;
92
93
  } | null;
93
- scope: string;
94
94
  }, {
95
+ scope: string;
95
96
  target: {
96
97
  artifactId: string;
97
98
  schemaVersion: 1;
98
99
  versionId?: string | undefined;
99
100
  draftRevision?: number | undefined;
100
101
  } | null;
101
- scope: string;
102
102
  }>>>;
103
103
  }, "strip", z.ZodTypeAny, {
104
104
  dashboardEditing?: {
105
+ scope: string;
105
106
  target: {
106
107
  artifactId: string;
107
108
  schemaVersion: 1;
108
109
  versionId?: string | undefined;
109
110
  draftRevision?: number | undefined;
110
111
  } | null;
111
- scope: string;
112
112
  } | null | undefined;
113
113
  }, {
114
114
  dashboardEditing?: {
115
+ scope: string;
115
116
  target: {
116
117
  artifactId: string;
117
118
  schemaVersion: 1;
118
119
  versionId?: string | undefined;
119
120
  draftRevision?: number | undefined;
120
121
  } | null;
121
- scope: string;
122
122
  } | null | undefined;
123
123
  }>;
124
124
  /** Checkpoints belong to an actor and conversation. Copied state must never choose another user's target. */
@@ -0,0 +1,17 @@
1
+ import type { AnalysisEvidenceSnapshot } from '@xpert-ai/contracts';
2
+ /** Positional comparison, not entity matching. Only compare snapshots already
3
+ * authorized and held by the caller; this does not authorize historical rows. */
4
+ export declare function compareEvidence(before: AnalysisEvidenceSnapshot, after: AnalysisEvidenceSnapshot): {
5
+ previousId: string;
6
+ currentId: string;
7
+ changedCells: number;
8
+ changedDatasets: number;
9
+ changes: {
10
+ datasetId: string;
11
+ row: number;
12
+ field: string;
13
+ before: string;
14
+ after: string;
15
+ }[];
16
+ truncated: boolean;
17
+ };
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.compareEvidence = compareEvidence;
4
+ const analytics_1 = require("@xpert-ai/plugin-sdk/analytics");
5
+ /** Positional comparison, not entity matching. Only compare snapshots already
6
+ * authorized and held by the caller; this does not authorize historical rows. */
7
+ function compareEvidence(before, after) {
8
+ const left = new Map(before.datasets.map(value => [value.datasetId, value]));
9
+ const right = new Map(after.datasets.map(value => [value.datasetId, value]));
10
+ const changes = [];
11
+ let changedCells = 0, changedDatasets = 0;
12
+ const display = (value) => value === undefined ? '—' : String(value).slice(0, 300);
13
+ for (const datasetId of new Set([...left.keys(), ...right.keys()])) {
14
+ const a = left.get(datasetId), b = right.get(datasetId);
15
+ if (!a || !b || (0, analytics_1.canonicalEvidenceJson)(a.fields) !== (0, analytics_1.canonicalEvidenceJson)(b.fields) ||
16
+ (0, analytics_1.canonicalEvidenceJson)(a.completeness) !== (0, analytics_1.canonicalEvidenceJson)(b.completeness))
17
+ changedDatasets++;
18
+ for (let row = 0; row < Math.max(a?.rows.length ?? 0, b?.rows.length ?? 0); row++) {
19
+ const av = a?.rows[row] ?? {}, bv = b?.rows[row] ?? {};
20
+ for (const field of new Set([...Object.keys(av), ...Object.keys(bv)])) {
21
+ if (Object.is(av[field], bv[field]))
22
+ continue;
23
+ changedCells++;
24
+ if (changes.length < 50)
25
+ changes.push({ datasetId, row, field, before: display(av[field]), after: display(bv[field]) });
26
+ }
27
+ }
28
+ }
29
+ return { previousId: before.id, currentId: after.id, changedCells, changedDatasets, changes, truncated: changedCells > changes.length };
30
+ }
@@ -0,0 +1,14 @@
1
+ import { type RuntimeCapabilityRegistry } from '@xpert-ai/plugin-sdk';
2
+ import type { XpertResolvedViewHostContext } from '@xpert-ai/contracts';
3
+ import { AnalysisEvidenceService } from './evidence.service';
4
+ export declare class AnalysisEvidenceTransfers {
5
+ private readonly evidence;
6
+ private readonly runtime;
7
+ constructor(evidence: AnalysisEvidenceService, runtime: RuntimeCapabilityRegistry);
8
+ convert(context: XpertResolvedViewHostContext, input: {
9
+ id: string;
10
+ requestId: string;
11
+ title: string;
12
+ target: 'document' | 'presentation' | 'motion';
13
+ }): Promise<import("@xpert-ai/contracts").ContentCatalogItem>;
14
+ }
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
12
+ return function (target, key) { decorator(target, key, paramIndex); }
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.AnalysisEvidenceTransfers = void 0;
16
+ const common_1 = require("@nestjs/common");
17
+ const plugin_sdk_1 = require("@xpert-ai/plugin-sdk");
18
+ const evidence_service_1 = require("./evidence.service");
19
+ const dashboard_service_1 = require("../dashboard.service");
20
+ let AnalysisEvidenceTransfers = class AnalysisEvidenceTransfers {
21
+ constructor(evidence, runtime) {
22
+ this.evidence = evidence;
23
+ this.runtime = runtime;
24
+ }
25
+ async convert(context, input) {
26
+ const snapshot = await this.evidence.read(context, input.id);
27
+ const scope = { actor: { tenantId: context.tenantId, organizationId: context.organizationId, userId: context.userId }, projectId: (0, dashboard_service_1.projectId)(context) };
28
+ const catalog = this.runtime.require(plugin_sdk_1.ContentResourcesRuntimeCapability).catalog;
29
+ const source = await catalog.register({ ...scope, source: { providerKey: evidence_service_1.EVIDENCE_PROVIDER, resourceId: snapshot.id } });
30
+ const target = input.target !== 'motion' ? { providerKey: 'office.documents', implementationKey: input.target === 'presentation' ? 'office-presentation' : 'office-document' }
31
+ : { providerKey: 'motion.evidence-video', implementationKey: 'motion-evidence-video' };
32
+ return catalog.create({ ...scope, ...target, requestId: input.requestId, title: input.title,
33
+ transferFrom: { contentId: source.contentId, expectedRevision: snapshot.sha256 } });
34
+ }
35
+ };
36
+ exports.AnalysisEvidenceTransfers = AnalysisEvidenceTransfers;
37
+ exports.AnalysisEvidenceTransfers = AnalysisEvidenceTransfers = __decorate([
38
+ (0, common_1.Injectable)(),
39
+ __param(1, (0, common_1.Inject)(plugin_sdk_1.XPERT_RUNTIME_CAPABILITIES_TOKEN)),
40
+ __metadata("design:paramtypes", [evidence_service_1.AnalysisEvidenceService, Object])
41
+ ], AnalysisEvidenceTransfers);
@@ -0,0 +1,91 @@
1
+ import { AnalysisEvidenceTransfers } from './evidence-transfers';
2
+ import { z } from 'zod/v3';
3
+ import { type IXpertViewExtensionProvider } from '@xpert-ai/plugin-sdk';
4
+ import type { ResourceContentEditorRegistration, XpertExtensionViewManifest, XpertResolvedViewHostContext, XpertViewActionRequest, XpertViewQuery } from '@xpert-ai/contracts';
5
+ import { AnalysisEvidenceService } from './evidence.service';
6
+ export declare const EVIDENCE_EDITOR = "live-dashboard.evidence-editor";
7
+ export declare const evidenceModel: {
8
+ typeId: string;
9
+ modelId: string;
10
+ schemaVersion: string;
11
+ editProtocol: {
12
+ id: string;
13
+ version: string;
14
+ };
15
+ };
16
+ export declare const evidenceConvertSchema: z.ZodObject<{
17
+ id: z.ZodString;
18
+ } & {
19
+ requestId: z.ZodString;
20
+ title: z.ZodString;
21
+ target: z.ZodEnum<["document", "presentation", "motion"]>;
22
+ }, "strict", z.ZodTypeAny, {
23
+ title: string;
24
+ id: string;
25
+ requestId: string;
26
+ target: "presentation" | "document" | "motion";
27
+ }, {
28
+ title: string;
29
+ id: string;
30
+ requestId: string;
31
+ target: "presentation" | "document" | "motion";
32
+ }>;
33
+ export declare class AnalysisEvidenceEditor {
34
+ readonly descriptor: ResourceContentEditorRegistration;
35
+ }
36
+ export declare class AnalysisEvidenceView implements IXpertViewExtensionProvider {
37
+ private readonly evidence;
38
+ private readonly transfers;
39
+ constructor(evidence: AnalysisEvidenceService, transfers: AnalysisEvidenceTransfers);
40
+ supports(context: XpertResolvedViewHostContext): boolean;
41
+ getViewManifests(context: XpertResolvedViewHostContext, slot: string): XpertExtensionViewManifest[];
42
+ getRemoteComponentEntry(_context: XpertResolvedViewHostContext, entry: string): Promise<{
43
+ html: string;
44
+ contentType: "text/html; charset=utf-8";
45
+ }>;
46
+ private assertView;
47
+ getViewData(context: XpertResolvedViewHostContext, key: string, query: XpertViewQuery): Promise<{
48
+ meta: {
49
+ canCapture: boolean;
50
+ snapshot: import("@xpert-ai/contracts").AnalysisEvidenceSnapshot;
51
+ refreshId?: undefined;
52
+ sourceChanged?: undefined;
53
+ };
54
+ } | {
55
+ meta: {
56
+ canCapture: boolean;
57
+ refreshId: string;
58
+ sourceChanged: boolean;
59
+ snapshot?: undefined;
60
+ };
61
+ } | {
62
+ meta: {
63
+ nextCursor?: number | undefined;
64
+ items: {
65
+ id: string;
66
+ title: string;
67
+ sha256: string;
68
+ capturedAt: string;
69
+ artifactId: string | null;
70
+ }[];
71
+ canCapture: boolean;
72
+ snapshot?: undefined;
73
+ refreshId?: undefined;
74
+ sourceChanged?: undefined;
75
+ };
76
+ }>;
77
+ executeViewAction(context: XpertResolvedViewHostContext, key: string, action: string, request: XpertViewActionRequest): Promise<{
78
+ success: boolean;
79
+ data: {
80
+ id: string;
81
+ artifactId: string;
82
+ sha256: string;
83
+ capturedAt: string;
84
+ };
85
+ refresh: boolean;
86
+ } | {
87
+ success: boolean;
88
+ data: import("@xpert-ai/contracts").ContentCatalogItem;
89
+ refresh: boolean;
90
+ }>;
91
+ }
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AnalysisEvidenceView = exports.AnalysisEvidenceEditor = exports.evidenceConvertSchema = exports.evidenceModel = exports.EVIDENCE_EDITOR = void 0;
13
+ const evidence_transfers_1 = require("./evidence-transfers");
14
+ const common_1 = require("@nestjs/common");
15
+ const v3_1 = require("zod/v3");
16
+ const plugin_sdk_1 = require("@xpert-ai/plugin-sdk");
17
+ const evidence_service_1 = require("./evidence.service");
18
+ const dashboard_service_1 = require("../dashboard.service");
19
+ const remote_entry_1 = require("../remote-entry");
20
+ const dashboard_icon_1 = require("../dashboard-icon");
21
+ const view_provider_1 = require("../view.provider");
22
+ exports.EVIDENCE_EDITOR = 'live-dashboard.evidence-editor';
23
+ exports.evidenceModel = { typeId: 'analysis-evidence', modelId: 'xpert.analysis-evidence', schemaVersion: '1', editProtocol: { id: 'immutable.snapshot', version: '1' } };
24
+ const provider = 'live-dashboard-evidence', view = 'analysis-evidence';
25
+ const idSchema = v3_1.z.object({ id: v3_1.z.string().uuid() }).strict();
26
+ const refreshSchema = idSchema.extend({ requestId: v3_1.z.string().uuid(), title: v3_1.z.string().min(1).max(200) });
27
+ exports.evidenceConvertSchema = idSchema.extend({ requestId: v3_1.z.string().uuid(), title: v3_1.z.string().min(1).max(200), target: v3_1.z.enum(['document', 'presentation', 'motion']) });
28
+ let AnalysisEvidenceEditor = class AnalysisEvidenceEditor {
29
+ constructor() {
30
+ this.descriptor = { kind: 'resource', key: exports.EVIDENCE_EDITOR, protocolVersion: 2,
31
+ title: 'Analysis evidence', view: { providerKey: provider, viewKey: view, entry: view }, supports: [{ ...exports.evidenceModel, access: ['view'] }] };
32
+ }
33
+ };
34
+ exports.AnalysisEvidenceEditor = AnalysisEvidenceEditor;
35
+ exports.AnalysisEvidenceEditor = AnalysisEvidenceEditor = __decorate([
36
+ (0, plugin_sdk_1.ContentEditorProvider)(exports.EVIDENCE_EDITOR)
37
+ ], AnalysisEvidenceEditor);
38
+ let AnalysisEvidenceView = class AnalysisEvidenceView {
39
+ constructor(evidence, transfers) {
40
+ this.evidence = evidence;
41
+ this.transfers = transfers;
42
+ }
43
+ supports(context) { return context.hostType === 'agent'; }
44
+ getViewManifests(context, slot) {
45
+ if (!this.supports(context) || !['agent.workbench', 'agent.workbench.fixed', 'agent.workbench.main'].includes(slot))
46
+ return [];
47
+ return [{ key: view, title: { en_US: 'Analysis evidence', zh_Hans: '分析证据', zh_Hant: '分析證據' }, hostType: 'agent', slot,
48
+ icon: dashboard_icon_1.dashboardIcon, activation: { projectResource: true, requiredFeatures: [view_provider_1.FEATURE] }, source: { provider, plugin: dashboard_service_1.PLUGIN_NAME }, refreshable: true,
49
+ workbench: { fixed: true, openMode: 'on-demand', menu: { enabled: true, order: 39 } },
50
+ view: { type: 'remote_component', runtime: 'react', protocolVersion: 1, component: { isolation: 'iframe', entry: view }, dataSource: { mode: 'platform' } },
51
+ dataSource: { mode: 'platform', querySchema: { supportsSelection: true, supportsParameters: true }, cache: { enabled: false } },
52
+ clientCommands: [{ key: 'workbench.content.resolve' }, { key: 'workbench.navigation.open' }],
53
+ actions: ['capture', 'refresh', 'convert'].map(key => ({ key, label: { en_US: key, zh_Hans: key }, actionType: 'invoke' })) }];
54
+ }
55
+ getRemoteComponentEntry(_context, entry) { this.assertView(entry); return (0, remote_entry_1.dashboardRemoteEntry)(false, 'evidence'); }
56
+ assertView(key) { if (key !== view)
57
+ throw new common_1.BadRequestException('EVIDENCE_VIEW_UNSUPPORTED'); }
58
+ async getViewData(context, key, query) {
59
+ this.assertView(key);
60
+ const canCapture = await this.evidence.canCapture(context);
61
+ if (query.selectionId) {
62
+ const id = v3_1.z.string().uuid().parse(query.selectionId);
63
+ try {
64
+ return { meta: { canCapture, snapshot: await this.evidence.read(context, id) } };
65
+ }
66
+ catch (error) {
67
+ if (!(error instanceof common_1.ConflictException) || error.message !== 'EVIDENCE_SOURCE_CHANGED_CAPTURE_NEW_SNAPSHOT')
68
+ throw error;
69
+ return { meta: { canCapture, refreshId: id, sourceChanged: true } };
70
+ }
71
+ }
72
+ return { meta: { canCapture, ...await this.evidence.list(context, Math.max(0, (query.page ?? 1) - 1) * 50) } };
73
+ }
74
+ async executeViewAction(context, key, action, request) {
75
+ this.assertView(key);
76
+ if (action === 'capture')
77
+ return { success: true, data: await this.evidence.capture(context, evidence_service_1.captureEvidenceSchema.parse(request.input)), refresh: true };
78
+ if (action === 'refresh') {
79
+ const input = refreshSchema.parse(request.input);
80
+ return { success: true, data: await this.evidence.refresh(context, input.id, input.requestId, input.title), refresh: false };
81
+ }
82
+ if (action === 'convert')
83
+ return { success: true, data: await this.transfers.convert(context, exports.evidenceConvertSchema.parse(request.input)), refresh: false };
84
+ throw new common_1.BadRequestException('EVIDENCE_ACTION_UNSUPPORTED');
85
+ }
86
+ };
87
+ exports.AnalysisEvidenceView = AnalysisEvidenceView;
88
+ exports.AnalysisEvidenceView = AnalysisEvidenceView = __decorate([
89
+ (0, plugin_sdk_1.ViewExtensionProvider)(provider),
90
+ __metadata("design:paramtypes", [evidence_service_1.AnalysisEvidenceService,
91
+ evidence_transfers_1.AnalysisEvidenceTransfers])
92
+ ], AnalysisEvidenceView);
@@ -0,0 +1,14 @@
1
+ import type { AnalysisEvidenceSnapshot } from '@xpert-ai/contracts';
2
+ /** Immutable snapshot; only the derived Artifact pointer may be completed after a retry. */
3
+ export declare class AnalysisEvidenceRecord {
4
+ id: string;
5
+ tenantId: string;
6
+ organizationId: string;
7
+ projectId: string;
8
+ createdById: string;
9
+ requestId: string;
10
+ requestHash: string;
11
+ snapshot: AnalysisEvidenceSnapshot;
12
+ artifactId: string | null;
13
+ createdAt: Date;
14
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ 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
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AnalysisEvidenceRecord = void 0;
13
+ const typeorm_1 = require("typeorm");
14
+ const resource_contract_1 = require("../library/resource-contract");
15
+ /** Immutable snapshot; only the derived Artifact pointer may be completed after a retry. */
16
+ let AnalysisEvidenceRecord = class AnalysisEvidenceRecord {
17
+ };
18
+ exports.AnalysisEvidenceRecord = AnalysisEvidenceRecord;
19
+ __decorate([
20
+ (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
21
+ __metadata("design:type", String)
22
+ ], AnalysisEvidenceRecord.prototype, "id", void 0);
23
+ __decorate([
24
+ (0, typeorm_1.Column)({ type: 'varchar' }),
25
+ __metadata("design:type", String)
26
+ ], AnalysisEvidenceRecord.prototype, "tenantId", void 0);
27
+ __decorate([
28
+ (0, typeorm_1.Column)({ type: 'varchar' }),
29
+ __metadata("design:type", String)
30
+ ], AnalysisEvidenceRecord.prototype, "organizationId", void 0);
31
+ __decorate([
32
+ (0, typeorm_1.Column)({ type: 'uuid' }),
33
+ __metadata("design:type", String)
34
+ ], AnalysisEvidenceRecord.prototype, "projectId", void 0);
35
+ __decorate([
36
+ (0, typeorm_1.Column)({ type: 'uuid' }),
37
+ __metadata("design:type", String)
38
+ ], AnalysisEvidenceRecord.prototype, "createdById", void 0);
39
+ __decorate([
40
+ (0, typeorm_1.Column)({ type: 'uuid' }),
41
+ __metadata("design:type", String)
42
+ ], AnalysisEvidenceRecord.prototype, "requestId", void 0);
43
+ __decorate([
44
+ (0, typeorm_1.Column)({ type: 'varchar', length: 64 }),
45
+ __metadata("design:type", String)
46
+ ], AnalysisEvidenceRecord.prototype, "requestHash", void 0);
47
+ __decorate([
48
+ (0, typeorm_1.Column)({ type: 'jsonb' }),
49
+ __metadata("design:type", Object)
50
+ ], AnalysisEvidenceRecord.prototype, "snapshot", void 0);
51
+ __decorate([
52
+ (0, typeorm_1.Column)({ type: 'uuid', nullable: true }),
53
+ __metadata("design:type", Object)
54
+ ], AnalysisEvidenceRecord.prototype, "artifactId", void 0);
55
+ __decorate([
56
+ (0, typeorm_1.CreateDateColumn)({ type: 'timestamptz' }),
57
+ __metadata("design:type", Date)
58
+ ], AnalysisEvidenceRecord.prototype, "createdAt", void 0);
59
+ exports.AnalysisEvidenceRecord = AnalysisEvidenceRecord = __decorate([
60
+ (0, typeorm_1.Entity)((0, resource_contract_1.libraryTable)('analysis_evidence_v1')),
61
+ (0, typeorm_1.Index)(['tenantId', 'organizationId', 'projectId', 'requestId'], { unique: true })
62
+ ], AnalysisEvidenceRecord);
@@ -0,0 +1,43 @@
1
+ import { type ArtifactTypeSource, type ArtifactTypeActor, type ContentOperation, type IArtifactTypeProvider, type ContentCatalogProvider, type IContentResourceProvider, type ContentResourceRequest } from '@xpert-ai/plugin-sdk';
2
+ import { AnalysisEvidenceService } from './evidence.service';
3
+ export declare class AnalysisEvidenceArtifactType implements IArtifactTypeProvider {
4
+ private readonly evidence;
5
+ constructor(evidence: AnalysisEvidenceService);
6
+ readonly definition: {
7
+ versioning: {
8
+ mode: "draft-only";
9
+ };
10
+ title: {
11
+ en_US: string;
12
+ zh_Hans: string;
13
+ };
14
+ kinds: "file"[];
15
+ content: {
16
+ mimeTypes: string[];
17
+ maxBytes: number;
18
+ };
19
+ collection: {
20
+ allowCopy: boolean;
21
+ };
22
+ presentation: {
23
+ mode: "file";
24
+ };
25
+ };
26
+ authorize(source: ArtifactTypeSource, actor: ArtifactTypeActor, operation: ContentOperation): Promise<void>;
27
+ authorizeDraft(source: ArtifactTypeSource, actor: ArtifactTypeActor, operation: ContentOperation): Promise<void>;
28
+ validateContent(buffer: Buffer, mimeType: string): Promise<void>;
29
+ }
30
+ export declare class AnalysisEvidenceContent implements IContentResourceProvider {
31
+ private readonly evidence;
32
+ readonly title = "Immutable analysis evidence";
33
+ constructor(evidence: AnalysisEvidenceService);
34
+ readonly catalog: ContentCatalogProvider;
35
+ authorize(input: ContentResourceRequest): Promise<{
36
+ providerKey: string;
37
+ resourceId: string;
38
+ title: string;
39
+ role: "editor" | "viewer";
40
+ canWrite: boolean;
41
+ canManage: boolean;
42
+ }>;
43
+ }