@xpert-ai/plugin-live-dashboard 0.4.1 → 0.6.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.
- package/.xpertai-plugin/plugin.json +1 -1
- package/README.md +8 -2
- package/dist/index.js +3 -1
- package/dist/lib/agent.schema.d.ts +177 -23
- package/dist/lib/agent.schema.js +11 -9
- package/dist/lib/archive.service.d.ts +169 -0
- package/dist/lib/archive.service.js +147 -0
- package/dist/lib/bounded-map.d.ts +2 -0
- package/dist/lib/bounded-map.js +25 -0
- package/dist/lib/capacity.d.ts +14 -0
- package/dist/lib/capacity.js +16 -0
- package/dist/lib/content.provider.d.ts +1 -1
- package/dist/lib/dashboard-archive.d.ts +70 -0
- package/dist/lib/dashboard-archive.js +118 -0
- package/dist/lib/dashboard-queries.d.ts +1 -1
- package/dist/lib/dashboard-queries.js +11 -6
- package/dist/lib/dashboard-receipt.js +1 -1
- package/dist/lib/dashboard-sources.d.ts +69 -0
- package/dist/lib/dashboard-sources.js +38 -0
- package/dist/lib/dashboard-view.schema.d.ts +422 -88
- package/dist/lib/dashboard.schema.d.ts +379 -58
- package/dist/lib/dashboard.schema.js +20 -2
- package/dist/lib/dashboard.service.d.ts +80 -15
- package/dist/lib/dashboard.service.js +65 -9
- package/dist/lib/definition-tools.d.ts +4 -4
- package/dist/lib/document-host.js +1 -1
- package/dist/lib/document-package.d.ts +19 -4
- package/dist/lib/editing-patch.d.ts +3 -0
- package/dist/lib/editing-patch.js +4 -2
- package/dist/lib/editing-session.d.ts +4 -4
- package/dist/lib/editing.d.ts +204 -20
- package/dist/lib/editing.js +10 -3
- package/dist/lib/filter-evidence.d.ts +28 -0
- package/dist/lib/filter-evidence.js +3 -2
- package/dist/lib/html-guidance.d.ts +1 -0
- package/dist/lib/html-guidance.js +2 -1
- package/dist/lib/html-validation-feedback.d.ts +7 -0
- package/dist/lib/html-validation-feedback.js +19 -0
- package/dist/lib/html-validation.js +3 -2
- package/dist/lib/inspection-host.d.ts +7 -0
- package/dist/lib/inspection-host.js +48 -0
- package/dist/lib/inspection-runtime.d.ts +2 -0
- package/dist/lib/inspection-runtime.js +77 -0
- package/dist/lib/json-input.d.ts +4 -0
- package/dist/lib/json-input.js +21 -0
- package/dist/lib/middleware.d.ts +3 -1
- package/dist/lib/middleware.js +92 -13
- package/dist/lib/plugin.js +3 -1
- package/dist/lib/presentation.provider.d.ts +24 -9
- package/dist/lib/presentation.provider.js +2 -1
- package/dist/lib/preview-retry.d.ts +4 -3
- package/dist/lib/preview-retry.js +13 -7
- package/dist/lib/prompt-workflows.js +1 -1
- package/dist/lib/query-session.d.ts +9 -0
- package/dist/lib/query-session.js +64 -0
- package/dist/lib/save-requests.d.ts +118 -0
- package/dist/lib/save-requests.js +199 -0
- package/dist/lib/source-executions.d.ts +437 -0
- package/dist/lib/source-executions.js +49 -0
- package/dist/lib/source-validation.d.ts +2 -0
- package/dist/lib/source-validation.js +21 -0
- package/dist/lib/view.provider.d.ts +213 -8
- package/dist/lib/view.provider.js +47 -5
- package/dist/remote/app.css +1 -1
- package/dist/remote/app.js +185 -63
- package/dist/remote/build-manifest.json +52 -33
- package/dist/sandbox-actions/action.json +1 -1
- package/dist/sandbox-actions/bundle/host.js +63 -14
- package/dist/sandbox-actions/bundle/validate.mjs +2 -2
- package/dist/validation/host-entry.d.ts +5 -1
- package/dist/validation/host-entry.js +21 -4
- package/docs/docs.json +5 -1
- package/docs/large-dashboards-acceptance.mdx +74 -0
- package/docs/large-dashboards.mdx +80 -0
- package/docs/sources-inspect-portability-acceptance.mdx +67 -0
- package/docs/sources-inspect-portability.mdx +115 -0
- package/package.json +8 -7
- package/skills/live-dashboard/SKILL.md +5 -4
- package/skills/live-dashboard/references/source-inspection.md +17 -0
package/README.md
CHANGED
|
@@ -4,6 +4,12 @@ System plugin `@xpert-ai/plugin-live-dashboard`: versioned live dashboards using
|
|
|
4
4
|
|
|
5
5
|
See [implementation and installed-runtime acceptance](docs/acceptance.md) and [one-sentence Agent acceptance](docs/agent-acceptance.md). `examples/` contains equivalent PostgreSQL and data-xpert bindings for the same chart.
|
|
6
6
|
|
|
7
|
+
Sources, component Inspect and portable dashboard archives are tracked in the
|
|
8
|
+
[feature guide](docs/sources-inspect-portability.mdx) and
|
|
9
|
+
[current acceptance record](docs/sources-inspect-portability-acceptance.mdx).
|
|
10
|
+
|
|
11
|
+
Large dashboards now support 32 Bindings by default (64 protocol ceiling), bounded query scheduling, batch preview/filter validation and durable save progress. See the [feature guide](docs/large-dashboards.mdx) and [acceptance record](docs/large-dashboards-acceptance.mdx). These features require published SDK/contracts 3.33.0 or later; no SDK patch is required.
|
|
12
|
+
|
|
7
13
|
## Ownership and flow
|
|
8
14
|
|
|
9
15
|
```text
|
|
@@ -190,7 +196,7 @@ See [HTML mode and acceptance](docs/html-mode.md). Agent tools write a complete
|
|
|
190
196
|
|
|
191
197
|
The platform browser entry `@xpert-ai/plugin-sdk/artifact-document` owns the sandbox, CSP, MessageChannel, request validation and latest-response policy. The plugin owns lifecycle and supplies a narrow callback to `query-binding`. Its server loads the exact saved Artifact version, finds the declared Binding, validates controls and rechecks source access. The endpoint rejects full Binding, Provider, SQL/payload and alternate source fields.
|
|
192
198
|
|
|
193
|
-
HTML preflight checks each native select's alternative/restored values and each button path in a fresh document mount, with at most two pages active. A button path also clicks controls it inserts, reveals or enables, retaining their prerequisite state and the same query quota; traversal is bounded to the first 12 buttons and 12 clicks per path. Every scenario checks initial bindings and host refresh using the same preview datasets. Successful static resources can be reused within this validation (bounded to 32 MB, up to 8 MB per resource); every replay still passes the resource policy, and failed, redirected or non-cacheable responses are not replayed. A 55-second validation deadline fails closed and cancels remaining pages before the host's 60-second Action limit. This prevents repeated resource downloads and the synthetic interaction sweep from exhausting the Action budget or one document's rate window
|
|
199
|
+
HTML preflight checks each native select's alternative/restored values and each button path in a fresh document mount, with at most two pages active. A button path also clicks controls it inserts, reveals or enables, retaining their prerequisite state and the same query quota; traversal is bounded to the first 12 buttons and 12 clicks per path. Every scenario checks initial bindings and host refresh using the same preview datasets. Successful static resources can be reused within this validation (bounded to 32 MB, up to 8 MB per resource); every replay still passes the resource policy, and failed, redirected or non-cacheable responses are not replayed. A 55-second validation deadline fails closed and cancels remaining pages before the host's 60-second Action limit. This prevents repeated resource downloads and the synthetic interaction sweep from exhausting the Action budget or one document's rate window with a separate immutable-snapshot budget of at most 16 replays per Binding; live queries remain limited to 60 dispatches per minute and concurrency 4. A request storm within a scenario still blocks saving; preflight is not a full combinatorial or sustained-load test.
|
|
194
200
|
|
|
195
201
|
Pages call `window.xpertLiveArtifact.ready()`, `subscribe(bindingId, render)`, `query(bindingId, controls)` and `refresh(bindingId)`. Register subscriptions before the first query so the toolbar can refresh without resetting the document. Use inline DOM/SVG/Canvas or online scripts/styles/fonts from the HTTPS origins returned by `dashboard_libraries.online`. Tailwind CDN, jsDelivr, cdnjs, unpkg and Google Fonts are supported according to their resource-type allowlist. Preflight and the displayed page use the same policy; failed loads prevent saving. Pin online versions where possible. Unlike packaged libraries, online bytes are not part of the immutable Artifact snapshot. Direct data requests, external images, eval, workers and frames remain unavailable. Script processing remains in the separate Workspace Script provider.
|
|
196
202
|
|
|
@@ -204,7 +210,7 @@ The renderer runs in a script-only sandbox with no-network CSP. A small in-memor
|
|
|
204
210
|
|
|
205
211
|
## Build and validation
|
|
206
212
|
|
|
207
|
-
Use the xpertai workspace's declared Corepack/pnpm. Development dependencies pin published SDK/contracts 3.
|
|
213
|
+
Use the xpertai workspace's declared Corepack/pnpm. Development dependencies pin published SDK/contracts 3.33.0 and the Data Analytics renderer 0.1.35; no local platform or community links are required. 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.
|
|
208
214
|
|
|
209
215
|
```sh
|
|
210
216
|
corepack pnpm install --frozen-lockfile
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const capacity_1 = require("./lib/capacity");
|
|
3
4
|
const node_fs_1 = require("node:fs");
|
|
4
5
|
const node_path_1 = require("node:path");
|
|
5
6
|
const plugin_1 = require("./lib/plugin");
|
|
@@ -18,7 +19,8 @@ const plugin = {
|
|
|
18
19
|
{ type: 'assistant-template', name: assistant_template_1.DASHBOARD_TEMPLATE_KEY, displayName: assistant_template_1.dashboardAssistantTemplate.title, description: assistant_template_1.dashboardAssistantTemplate.description }
|
|
19
20
|
] } } }
|
|
20
21
|
},
|
|
22
|
+
config: { schema: capacity_1.dashboardConfigSchema },
|
|
21
23
|
templates: templates_1.dashboardTemplates,
|
|
22
|
-
register:
|
|
24
|
+
register: context => ({ module: plugin_1.LiveDashboardPlugin, providers: [{ provide: capacity_1.DASHBOARD_CONFIG, useValue: capacity_1.dashboardConfigSchema.parse(context.config ?? {}) }] })
|
|
23
25
|
};
|
|
24
26
|
exports.default = plugin;
|
|
@@ -15,6 +15,7 @@ export declare const discoverToolSchema: z.ZodObject<{
|
|
|
15
15
|
}>;
|
|
16
16
|
export declare const agentBindingSchema: z.ZodObject<{
|
|
17
17
|
source: z.ZodType<import("@xpert-ai/contracts").AnalyticsSourceRef, z.ZodTypeDef, import("@xpert-ai/contracts").AnalyticsSourceRef>;
|
|
18
|
+
providerId: z.ZodString;
|
|
18
19
|
output: z.ZodObject<{
|
|
19
20
|
datasetId: z.ZodString;
|
|
20
21
|
fields: z.ZodArray<z.ZodObject<{
|
|
@@ -73,7 +74,6 @@ export declare const agentBindingSchema: z.ZodObject<{
|
|
|
73
74
|
}[];
|
|
74
75
|
grain?: string[];
|
|
75
76
|
}>;
|
|
76
|
-
providerId: z.ZodString;
|
|
77
77
|
} & {
|
|
78
78
|
parameters: z.ZodArray<z.ZodObject<Omit<{
|
|
79
79
|
name: z.ZodString;
|
|
@@ -98,6 +98,7 @@ export declare const agentBindingSchema: z.ZodObject<{
|
|
|
98
98
|
payloadJson: z.ZodString;
|
|
99
99
|
}, "strict", z.ZodTypeAny, {
|
|
100
100
|
source: import("@xpert-ai/contracts").AnalyticsSourceRef;
|
|
101
|
+
providerId: string;
|
|
101
102
|
output: {
|
|
102
103
|
datasetId?: string;
|
|
103
104
|
fields?: {
|
|
@@ -119,10 +120,10 @@ export declare const agentBindingSchema: z.ZodObject<{
|
|
|
119
120
|
defaultValue?: string | number | boolean | null | undefined;
|
|
120
121
|
allowedValues?: (string | number | boolean | null)[] | undefined;
|
|
121
122
|
}[];
|
|
122
|
-
providerId: string;
|
|
123
123
|
payloadJson: string;
|
|
124
124
|
}, {
|
|
125
125
|
source: import("@xpert-ai/contracts").AnalyticsSourceRef;
|
|
126
|
+
providerId: string;
|
|
126
127
|
output: {
|
|
127
128
|
datasetId?: string;
|
|
128
129
|
fields?: {
|
|
@@ -144,12 +145,12 @@ export declare const agentBindingSchema: z.ZodObject<{
|
|
|
144
145
|
defaultValue?: string | number | boolean | null | undefined;
|
|
145
146
|
allowedValues?: (string | number | boolean | null)[] | undefined;
|
|
146
147
|
}[];
|
|
147
|
-
providerId: string;
|
|
148
148
|
payloadJson: string;
|
|
149
149
|
}>;
|
|
150
150
|
export declare const previewToolSchema: z.ZodObject<{
|
|
151
151
|
binding: z.ZodObject<{
|
|
152
152
|
source: z.ZodType<import("@xpert-ai/contracts").AnalyticsSourceRef, z.ZodTypeDef, import("@xpert-ai/contracts").AnalyticsSourceRef>;
|
|
153
|
+
providerId: z.ZodString;
|
|
153
154
|
output: z.ZodObject<{
|
|
154
155
|
datasetId: z.ZodString;
|
|
155
156
|
fields: z.ZodArray<z.ZodObject<{
|
|
@@ -208,7 +209,6 @@ export declare const previewToolSchema: z.ZodObject<{
|
|
|
208
209
|
}[];
|
|
209
210
|
grain?: string[];
|
|
210
211
|
}>;
|
|
211
|
-
providerId: z.ZodString;
|
|
212
212
|
} & {
|
|
213
213
|
parameters: z.ZodArray<z.ZodObject<Omit<{
|
|
214
214
|
name: z.ZodString;
|
|
@@ -233,6 +233,7 @@ export declare const previewToolSchema: z.ZodObject<{
|
|
|
233
233
|
payloadJson: z.ZodString;
|
|
234
234
|
}, "strict", z.ZodTypeAny, {
|
|
235
235
|
source: import("@xpert-ai/contracts").AnalyticsSourceRef;
|
|
236
|
+
providerId: string;
|
|
236
237
|
output: {
|
|
237
238
|
datasetId?: string;
|
|
238
239
|
fields?: {
|
|
@@ -254,10 +255,10 @@ export declare const previewToolSchema: z.ZodObject<{
|
|
|
254
255
|
defaultValue?: string | number | boolean | null | undefined;
|
|
255
256
|
allowedValues?: (string | number | boolean | null)[] | undefined;
|
|
256
257
|
}[];
|
|
257
|
-
providerId: string;
|
|
258
258
|
payloadJson: string;
|
|
259
259
|
}, {
|
|
260
260
|
source: import("@xpert-ai/contracts").AnalyticsSourceRef;
|
|
261
|
+
providerId: string;
|
|
261
262
|
output: {
|
|
262
263
|
datasetId?: string;
|
|
263
264
|
fields?: {
|
|
@@ -279,12 +280,12 @@ export declare const previewToolSchema: z.ZodObject<{
|
|
|
279
280
|
defaultValue?: string | number | boolean | null | undefined;
|
|
280
281
|
allowedValues?: (string | number | boolean | null)[] | undefined;
|
|
281
282
|
}[];
|
|
282
|
-
providerId: string;
|
|
283
283
|
payloadJson: string;
|
|
284
284
|
}>;
|
|
285
285
|
}, "strict", z.ZodTypeAny, {
|
|
286
286
|
binding: {
|
|
287
287
|
source: import("@xpert-ai/contracts").AnalyticsSourceRef;
|
|
288
|
+
providerId: string;
|
|
288
289
|
output: {
|
|
289
290
|
datasetId?: string;
|
|
290
291
|
fields?: {
|
|
@@ -306,12 +307,12 @@ export declare const previewToolSchema: z.ZodObject<{
|
|
|
306
307
|
defaultValue?: string | number | boolean | null | undefined;
|
|
307
308
|
allowedValues?: (string | number | boolean | null)[] | undefined;
|
|
308
309
|
}[];
|
|
309
|
-
providerId: string;
|
|
310
310
|
payloadJson: string;
|
|
311
311
|
};
|
|
312
312
|
}, {
|
|
313
313
|
binding: {
|
|
314
314
|
source: import("@xpert-ai/contracts").AnalyticsSourceRef;
|
|
315
|
+
providerId: string;
|
|
315
316
|
output: {
|
|
316
317
|
datasetId?: string;
|
|
317
318
|
fields?: {
|
|
@@ -333,7 +334,6 @@ export declare const previewToolSchema: z.ZodObject<{
|
|
|
333
334
|
defaultValue?: string | number | boolean | null | undefined;
|
|
334
335
|
allowedValues?: (string | number | boolean | null)[] | undefined;
|
|
335
336
|
}[];
|
|
336
|
-
providerId: string;
|
|
337
337
|
payloadJson: string;
|
|
338
338
|
};
|
|
339
339
|
}>;
|
|
@@ -377,24 +377,24 @@ export declare const createToolSchema: z.ZodObject<{} & {
|
|
|
377
377
|
color: z.ZodOptional<z.ZodString>;
|
|
378
378
|
}, "strict", z.ZodTypeAny, {
|
|
379
379
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
380
|
-
id: string;
|
|
381
380
|
title: string;
|
|
381
|
+
id: string;
|
|
382
382
|
datasetId: string;
|
|
383
383
|
x: string;
|
|
384
384
|
y: string;
|
|
385
385
|
color?: string | undefined;
|
|
386
386
|
}, {
|
|
387
387
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
388
|
-
id: string;
|
|
389
388
|
title: string;
|
|
389
|
+
id: string;
|
|
390
390
|
datasetId: string;
|
|
391
391
|
x: string;
|
|
392
392
|
y: string;
|
|
393
393
|
color?: string | undefined;
|
|
394
394
|
}>, "many">, {
|
|
395
395
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
396
|
-
id: string;
|
|
397
396
|
title: string;
|
|
397
|
+
id: string;
|
|
398
398
|
datasetId: string;
|
|
399
399
|
x: string;
|
|
400
400
|
y: string;
|
|
@@ -406,21 +406,81 @@ export declare const createToolSchema: z.ZodObject<{} & {
|
|
|
406
406
|
datasetId: z.ZodString;
|
|
407
407
|
fields: z.ZodArray<z.ZodString, "many">;
|
|
408
408
|
}, "strict", z.ZodTypeAny, {
|
|
409
|
-
id: string;
|
|
410
409
|
title: string;
|
|
410
|
+
id: string;
|
|
411
411
|
datasetId: string;
|
|
412
412
|
fields: string[];
|
|
413
413
|
}, {
|
|
414
|
-
id: string;
|
|
415
414
|
title: string;
|
|
415
|
+
id: string;
|
|
416
416
|
datasetId: string;
|
|
417
417
|
fields: string[];
|
|
418
418
|
}>, "many">, {
|
|
419
|
-
id: string;
|
|
420
419
|
title: string;
|
|
420
|
+
id: string;
|
|
421
421
|
datasetId: string;
|
|
422
422
|
fields: string[];
|
|
423
423
|
}[], unknown>;
|
|
424
|
+
sourceMetadata: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
425
|
+
bindingId: z.ZodString;
|
|
426
|
+
title: z.ZodString;
|
|
427
|
+
description: z.ZodOptional<z.ZodString>;
|
|
428
|
+
}, "strict", z.ZodTypeAny, {
|
|
429
|
+
bindingId: string;
|
|
430
|
+
title: string;
|
|
431
|
+
description?: string | undefined;
|
|
432
|
+
}, {
|
|
433
|
+
bindingId: string;
|
|
434
|
+
title: string;
|
|
435
|
+
description?: string | undefined;
|
|
436
|
+
}>, "many">, {
|
|
437
|
+
bindingId: string;
|
|
438
|
+
title: string;
|
|
439
|
+
description?: string | undefined;
|
|
440
|
+
}[], unknown>>;
|
|
441
|
+
components: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
442
|
+
id: z.ZodString;
|
|
443
|
+
elementId: z.ZodString;
|
|
444
|
+
title: z.ZodString;
|
|
445
|
+
kind: z.ZodEnum<["metric", "chart", "table", "filter", "text"]>;
|
|
446
|
+
sources: z.ZodArray<z.ZodObject<{
|
|
447
|
+
bindingId: z.ZodString;
|
|
448
|
+
fieldIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
449
|
+
}, "strict", z.ZodTypeAny, {
|
|
450
|
+
bindingId: string;
|
|
451
|
+
fieldIds?: string[] | undefined;
|
|
452
|
+
}, {
|
|
453
|
+
bindingId: string;
|
|
454
|
+
fieldIds?: string[] | undefined;
|
|
455
|
+
}>, "many">;
|
|
456
|
+
}, "strict", z.ZodTypeAny, {
|
|
457
|
+
title: string;
|
|
458
|
+
id: string;
|
|
459
|
+
elementId: string;
|
|
460
|
+
kind: "filter" | "metric" | "chart" | "table" | "text";
|
|
461
|
+
sources: {
|
|
462
|
+
bindingId: string;
|
|
463
|
+
fieldIds?: string[] | undefined;
|
|
464
|
+
}[];
|
|
465
|
+
}, {
|
|
466
|
+
title: string;
|
|
467
|
+
id: string;
|
|
468
|
+
elementId: string;
|
|
469
|
+
kind: "filter" | "metric" | "chart" | "table" | "text";
|
|
470
|
+
sources: {
|
|
471
|
+
bindingId: string;
|
|
472
|
+
fieldIds?: string[] | undefined;
|
|
473
|
+
}[];
|
|
474
|
+
}>, "many">, {
|
|
475
|
+
title: string;
|
|
476
|
+
id: string;
|
|
477
|
+
elementId: string;
|
|
478
|
+
kind: "filter" | "metric" | "chart" | "table" | "text";
|
|
479
|
+
sources: {
|
|
480
|
+
bindingId: string;
|
|
481
|
+
fieldIds?: string[] | undefined;
|
|
482
|
+
}[];
|
|
483
|
+
}[], unknown>>;
|
|
424
484
|
previewIds: z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], unknown>;
|
|
425
485
|
}, "strict", z.ZodTypeAny, {
|
|
426
486
|
title: string;
|
|
@@ -433,24 +493,41 @@ export declare const createToolSchema: z.ZodObject<{} & {
|
|
|
433
493
|
}[];
|
|
434
494
|
charts: {
|
|
435
495
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
436
|
-
id: string;
|
|
437
496
|
title: string;
|
|
497
|
+
id: string;
|
|
438
498
|
datasetId: string;
|
|
439
499
|
x: string;
|
|
440
500
|
y: string;
|
|
441
501
|
color?: string | undefined;
|
|
442
502
|
}[];
|
|
443
503
|
tables: {
|
|
444
|
-
id: string;
|
|
445
504
|
title: string;
|
|
505
|
+
id: string;
|
|
446
506
|
datasetId: string;
|
|
447
507
|
fields: string[];
|
|
448
508
|
}[];
|
|
449
509
|
previewIds: string[];
|
|
510
|
+
sourceMetadata?: {
|
|
511
|
+
bindingId: string;
|
|
512
|
+
title: string;
|
|
513
|
+
description?: string | undefined;
|
|
514
|
+
}[] | undefined;
|
|
515
|
+
components?: {
|
|
516
|
+
title: string;
|
|
517
|
+
id: string;
|
|
518
|
+
elementId: string;
|
|
519
|
+
kind: "filter" | "metric" | "chart" | "table" | "text";
|
|
520
|
+
sources: {
|
|
521
|
+
bindingId: string;
|
|
522
|
+
fieldIds?: string[] | undefined;
|
|
523
|
+
}[];
|
|
524
|
+
}[] | undefined;
|
|
450
525
|
creationIntent?: "new" | "copy" | undefined;
|
|
451
526
|
supersedesPaths?: string[] | undefined;
|
|
452
527
|
}, {
|
|
453
528
|
title: string;
|
|
529
|
+
sourceMetadata?: unknown;
|
|
530
|
+
components?: unknown;
|
|
454
531
|
controls?: unknown;
|
|
455
532
|
charts?: unknown;
|
|
456
533
|
tables?: unknown;
|
|
@@ -499,24 +576,24 @@ export declare const createHtmlToolSchema: z.ZodObject<Omit<{} & {
|
|
|
499
576
|
color: z.ZodOptional<z.ZodString>;
|
|
500
577
|
}, "strict", z.ZodTypeAny, {
|
|
501
578
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
502
|
-
id: string;
|
|
503
579
|
title: string;
|
|
580
|
+
id: string;
|
|
504
581
|
datasetId: string;
|
|
505
582
|
x: string;
|
|
506
583
|
y: string;
|
|
507
584
|
color?: string | undefined;
|
|
508
585
|
}, {
|
|
509
586
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
510
|
-
id: string;
|
|
511
587
|
title: string;
|
|
588
|
+
id: string;
|
|
512
589
|
datasetId: string;
|
|
513
590
|
x: string;
|
|
514
591
|
y: string;
|
|
515
592
|
color?: string | undefined;
|
|
516
593
|
}>, "many">, {
|
|
517
594
|
type: "bar" | "line" | "area" | "pie" | "scatter";
|
|
518
|
-
id: string;
|
|
519
595
|
title: string;
|
|
596
|
+
id: string;
|
|
520
597
|
datasetId: string;
|
|
521
598
|
x: string;
|
|
522
599
|
y: string;
|
|
@@ -528,21 +605,81 @@ export declare const createHtmlToolSchema: z.ZodObject<Omit<{} & {
|
|
|
528
605
|
datasetId: z.ZodString;
|
|
529
606
|
fields: z.ZodArray<z.ZodString, "many">;
|
|
530
607
|
}, "strict", z.ZodTypeAny, {
|
|
531
|
-
id: string;
|
|
532
608
|
title: string;
|
|
609
|
+
id: string;
|
|
533
610
|
datasetId: string;
|
|
534
611
|
fields: string[];
|
|
535
612
|
}, {
|
|
536
|
-
id: string;
|
|
537
613
|
title: string;
|
|
614
|
+
id: string;
|
|
538
615
|
datasetId: string;
|
|
539
616
|
fields: string[];
|
|
540
617
|
}>, "many">, {
|
|
541
|
-
id: string;
|
|
542
618
|
title: string;
|
|
619
|
+
id: string;
|
|
543
620
|
datasetId: string;
|
|
544
621
|
fields: string[];
|
|
545
622
|
}[], unknown>;
|
|
623
|
+
sourceMetadata: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
624
|
+
bindingId: z.ZodString;
|
|
625
|
+
title: z.ZodString;
|
|
626
|
+
description: z.ZodOptional<z.ZodString>;
|
|
627
|
+
}, "strict", z.ZodTypeAny, {
|
|
628
|
+
bindingId: string;
|
|
629
|
+
title: string;
|
|
630
|
+
description?: string | undefined;
|
|
631
|
+
}, {
|
|
632
|
+
bindingId: string;
|
|
633
|
+
title: string;
|
|
634
|
+
description?: string | undefined;
|
|
635
|
+
}>, "many">, {
|
|
636
|
+
bindingId: string;
|
|
637
|
+
title: string;
|
|
638
|
+
description?: string | undefined;
|
|
639
|
+
}[], unknown>>;
|
|
640
|
+
components: z.ZodOptional<z.ZodEffects<z.ZodArray<z.ZodObject<{
|
|
641
|
+
id: z.ZodString;
|
|
642
|
+
elementId: z.ZodString;
|
|
643
|
+
title: z.ZodString;
|
|
644
|
+
kind: z.ZodEnum<["metric", "chart", "table", "filter", "text"]>;
|
|
645
|
+
sources: z.ZodArray<z.ZodObject<{
|
|
646
|
+
bindingId: z.ZodString;
|
|
647
|
+
fieldIds: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
648
|
+
}, "strict", z.ZodTypeAny, {
|
|
649
|
+
bindingId: string;
|
|
650
|
+
fieldIds?: string[] | undefined;
|
|
651
|
+
}, {
|
|
652
|
+
bindingId: string;
|
|
653
|
+
fieldIds?: string[] | undefined;
|
|
654
|
+
}>, "many">;
|
|
655
|
+
}, "strict", z.ZodTypeAny, {
|
|
656
|
+
title: string;
|
|
657
|
+
id: string;
|
|
658
|
+
elementId: string;
|
|
659
|
+
kind: "filter" | "metric" | "chart" | "table" | "text";
|
|
660
|
+
sources: {
|
|
661
|
+
bindingId: string;
|
|
662
|
+
fieldIds?: string[] | undefined;
|
|
663
|
+
}[];
|
|
664
|
+
}, {
|
|
665
|
+
title: string;
|
|
666
|
+
id: string;
|
|
667
|
+
elementId: string;
|
|
668
|
+
kind: "filter" | "metric" | "chart" | "table" | "text";
|
|
669
|
+
sources: {
|
|
670
|
+
bindingId: string;
|
|
671
|
+
fieldIds?: string[] | undefined;
|
|
672
|
+
}[];
|
|
673
|
+
}>, "many">, {
|
|
674
|
+
title: string;
|
|
675
|
+
id: string;
|
|
676
|
+
elementId: string;
|
|
677
|
+
kind: "filter" | "metric" | "chart" | "table" | "text";
|
|
678
|
+
sources: {
|
|
679
|
+
bindingId: string;
|
|
680
|
+
fieldIds?: string[] | undefined;
|
|
681
|
+
}[];
|
|
682
|
+
}[], unknown>>;
|
|
546
683
|
previewIds: z.ZodEffects<z.ZodArray<z.ZodString, "many">, string[], unknown>;
|
|
547
684
|
}, "charts" | "tables"> & {
|
|
548
685
|
path: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
|
|
@@ -558,17 +695,34 @@ export declare const createHtmlToolSchema: z.ZodObject<Omit<{} & {
|
|
|
558
695
|
allowedValues?: (string | number | boolean | null)[] | undefined;
|
|
559
696
|
}[];
|
|
560
697
|
previewIds: string[];
|
|
698
|
+
sourceMetadata?: {
|
|
699
|
+
bindingId: string;
|
|
700
|
+
title: string;
|
|
701
|
+
description?: string | undefined;
|
|
702
|
+
}[] | undefined;
|
|
703
|
+
components?: {
|
|
704
|
+
title: string;
|
|
705
|
+
id: string;
|
|
706
|
+
elementId: string;
|
|
707
|
+
kind: "filter" | "metric" | "chart" | "table" | "text";
|
|
708
|
+
sources: {
|
|
709
|
+
bindingId: string;
|
|
710
|
+
fieldIds?: string[] | undefined;
|
|
711
|
+
}[];
|
|
712
|
+
}[] | undefined;
|
|
561
713
|
creationIntent?: "new" | "copy" | undefined;
|
|
562
714
|
supersedesPaths?: string[] | undefined;
|
|
563
715
|
libraries?: ("echarts" | "three" | "trend-workspace" | "profit-atlas" | "customer-brief")[] | undefined;
|
|
564
716
|
}, {
|
|
565
717
|
path: string;
|
|
566
718
|
title: string;
|
|
719
|
+
sourceMetadata?: unknown;
|
|
720
|
+
components?: unknown;
|
|
567
721
|
controls?: unknown;
|
|
568
722
|
creationIntent?: "new" | "copy" | undefined;
|
|
569
723
|
supersedesPaths?: string[] | undefined;
|
|
570
724
|
previewIds?: unknown;
|
|
571
725
|
libraries?: ("echarts" | "three" | "trend-workspace" | "profit-atlas" | "customer-brief")[] | undefined;
|
|
572
726
|
}>;
|
|
573
|
-
export declare function parseObjectJson(text: string): Record<string, import("@xpert-ai/contracts").JSONValue>;
|
|
727
|
+
export declare function parseObjectJson(text: string, field?: 'requestJson' | 'binding.payloadJson'): Record<string, import("@xpert-ai/contracts").JSONValue>;
|
|
574
728
|
export declare function fromAgentBinding(input: z.infer<typeof agentBindingSchema>, contract: AnalyticsDiscoveryResult['queryContract']): import("@xpert-ai/contracts").AnalyticsBinding;
|
package/dist/lib/agent.schema.js
CHANGED
|
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.createHtmlToolSchema = exports.htmlPathSchema = exports.createToolSchema = exports.previewToolSchema = exports.agentBindingSchema = exports.discoverToolSchema = void 0;
|
|
4
4
|
exports.parseObjectJson = parseObjectJson;
|
|
5
5
|
exports.fromAgentBinding = fromAgentBinding;
|
|
6
|
+
const capacity_1 = require("./capacity");
|
|
6
7
|
const v3_1 = require("zod/v3");
|
|
7
8
|
const analytics_1 = require("@xpert-ai/plugin-sdk/analytics");
|
|
8
9
|
const dashboard_schema_1 = require("./dashboard.schema");
|
|
9
10
|
const plugin_sdk_1 = require("@xpert-ai/plugin-sdk");
|
|
10
11
|
const document_libraries_1 = require("./document-libraries");
|
|
12
|
+
const json_input_1 = require("./json-input");
|
|
11
13
|
// LLM tool schemas cannot reliably express recursive JSON unions. Only this model boundary uses JSON text.
|
|
12
14
|
const objectJson = v3_1.z.string().min(2).max(64000).describe('A JSON object encoded as text. Use the exact provider-owned contract from discovery. No Markdown fences.');
|
|
13
15
|
const agentControlsSchema = v3_1.z.array(dashboard_schema_1.dashboardSchema.innerType().shape.controls.element.extend({
|
|
@@ -28,7 +30,9 @@ exports.createToolSchema = dashboard_schema_1.dashboardSchema.innerType().omit({
|
|
|
28
30
|
controls: (0, plugin_sdk_1.jsonEncodedSchema)(agentControlsSchema),
|
|
29
31
|
charts: (0, plugin_sdk_1.jsonEncodedSchema)(dashboard_schema_1.dashboardSchema.innerType().shape.charts),
|
|
30
32
|
tables: (0, plugin_sdk_1.jsonEncodedSchema)(dashboard_schema_1.dashboardSchema.innerType().shape.tables),
|
|
31
|
-
|
|
33
|
+
sourceMetadata: (0, plugin_sdk_1.jsonEncodedSchema)(dashboard_schema_1.dashboardSchema.innerType().shape.sourceMetadata.unwrap()).optional(),
|
|
34
|
+
components: (0, plugin_sdk_1.jsonEncodedSchema)(dashboard_schema_1.dashboardSchema.innerType().shape.components.unwrap()).optional(),
|
|
35
|
+
previewIds: (0, plugin_sdk_1.jsonEncodedSchema)(v3_1.z.array(v3_1.z.string().min(1)).min(1).max(capacity_1.MAX_DASHBOARD_BINDINGS).describe('Exact current-run previewId receipts from successful dashboard_preview or dashboard_preview_binding calls. For updates, changed bindings upsert by stable binding.id; omitted bindings remain. Keep every intended changed/new binding receipt when retrying a failed save. Do not repeat bindings.'))
|
|
32
36
|
}).strict();
|
|
33
37
|
exports.htmlPathSchema = plugin_sdk_1.workspaceRelativeFilePathSchema.refine(path => {
|
|
34
38
|
const name = path.split('/').at(-1) ?? '';
|
|
@@ -37,17 +41,15 @@ exports.htmlPathSchema = plugin_sdk_1.workspaceRelativeFilePathSchema.refine(pat
|
|
|
37
41
|
.describe('Workspace-relative HTML file created or edited with SandboxFile, for example dashboards/sales.html. Copy the complete htmlPath from dashboard_open when editing.');
|
|
38
42
|
exports.createHtmlToolSchema = exports.createToolSchema.omit({ charts: true, tables: true }).extend({ path: exports.htmlPathSchema,
|
|
39
43
|
libraries: document_libraries_1.libraryRequestsSchema.optional().describe('Bundled IDs from dashboard_libraries. Omit for native SVG/Canvas/DOM; use echarts or three for charts. Optional: add exactly one visual theme (trend-workspace, profit-atlas, customer-brief) with echarts. Preserve the saved theme unless a change is requested.') }).strict();
|
|
40
|
-
function parseObjectJson(text) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
throw new Error('DASHBOARD_INVALID_JSON: supply a JSON object encoded as text, matching the returned provider contract');
|
|
46
|
-
}
|
|
44
|
+
function parseObjectJson(text, field = 'requestJson') {
|
|
45
|
+
const parsed = analytics_1.analyticsOptionsSchema.safeParse((0, json_input_1.parseJsonInput)(text, field));
|
|
46
|
+
if (!parsed.success)
|
|
47
|
+
throw new Error(`DASHBOARD_INVALID_JSON: ${field} is valid JSON but must be an object matching the returned provider contract; arrays, null and scalar values are not accepted.`);
|
|
48
|
+
return parsed.data;
|
|
47
49
|
}
|
|
48
50
|
function fromAgentBinding(input, contract) {
|
|
49
51
|
const { payloadJson, ...binding } = input;
|
|
50
52
|
return analytics_1.analyticsBindingSchema.parse({ ...binding, id: input.output.datasetId,
|
|
51
53
|
operation: contract.operation, contractVersion: contract.contractVersion,
|
|
52
|
-
parameters: input.parameters.map(parameter => ({ ...parameter, controlId: parameter.name })), payload: parseObjectJson(payloadJson) });
|
|
54
|
+
parameters: input.parameters.map(parameter => ({ ...parameter, controlId: parameter.name })), payload: parseObjectJson(payloadJson, 'binding.payloadJson') });
|
|
53
55
|
}
|