@xpert-ai/plugin-live-dashboard 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.xpertai-plugin/plugin.json +8 -0
- package/README.md +108 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +11 -0
- package/dist/lib/agent.schema.d.ts +568 -0
- package/dist/lib/agent.schema.js +52 -0
- package/dist/lib/dashboard-icon.d.ts +5 -0
- package/dist/lib/dashboard-icon.js +8 -0
- package/dist/lib/dashboard-navigation.d.ts +38 -0
- package/dist/lib/dashboard-navigation.js +18 -0
- package/dist/lib/dashboard-queries.d.ts +8 -0
- package/dist/lib/dashboard-queries.js +39 -0
- package/dist/lib/dashboard-receipt.d.ts +11 -0
- package/dist/lib/dashboard-receipt.js +35 -0
- package/dist/lib/dashboard.schema.d.ts +816 -0
- package/dist/lib/dashboard.schema.js +74 -0
- package/dist/lib/dashboard.service.d.ts +243 -0
- package/dist/lib/dashboard.service.js +185 -0
- package/dist/lib/document-libraries.d.ts +8 -0
- package/dist/lib/document-libraries.js +41 -0
- package/dist/lib/document-package.d.ts +41 -0
- package/dist/lib/document-package.js +25 -0
- package/dist/lib/editing.d.ts +403 -0
- package/dist/lib/editing.js +114 -0
- package/dist/lib/filter-evidence.d.ts +71 -0
- package/dist/lib/filter-evidence.js +60 -0
- package/dist/lib/html-guidance.d.ts +1 -0
- package/dist/lib/html-guidance.js +4 -0
- package/dist/lib/html-validation.d.ts +19 -0
- package/dist/lib/html-validation.js +136 -0
- package/dist/lib/middleware.d.ts +10 -0
- package/dist/lib/middleware.js +225 -0
- package/dist/lib/plugin.d.ts +2 -0
- package/dist/lib/plugin.js +22 -0
- package/dist/lib/presentation.provider.d.ts +122 -0
- package/dist/lib/presentation.provider.js +72 -0
- package/dist/lib/remote-entry.d.ts +4 -0
- package/dist/lib/remote-entry.js +12 -0
- package/dist/lib/renderer.d.ts +58 -0
- package/dist/lib/renderer.js +32 -0
- package/dist/lib/resource-card.d.ts +21 -0
- package/dist/lib/resource-card.js +33 -0
- package/dist/lib/save-evidence.d.ts +24 -0
- package/dist/lib/save-evidence.js +99 -0
- package/dist/lib/sharing.service.d.ts +93 -0
- package/dist/lib/sharing.service.js +71 -0
- package/dist/lib/view.provider.d.ts +235 -0
- package/dist/lib/view.provider.js +103 -0
- package/dist/libraries/ECHARTS-LICENSE.txt +222 -0
- package/dist/libraries/ECHARTS-NOTICE.txt +5 -0
- package/dist/libraries/THREE-LICENSE.txt +21 -0
- package/dist/libraries/catalog.json +1 -0
- package/dist/remote/app.css +1 -0
- package/dist/remote/app.js +253 -0
- package/dist/remote/build-manifest.json +63 -0
- package/dist/remote/renderer-source.json +5 -0
- package/dist/remote/renderer.html +4653 -0
- package/dist/sandbox-actions/action.json +10 -0
- package/dist/sandbox-actions/bundle/host.js +149 -0
- package/dist/sandbox-actions/bundle/runner.mjs +15 -0
- package/dist/sandbox-actions/bundle/validate.mjs +140 -0
- package/dist/validation/host-entry.d.ts +1 -0
- package/dist/validation/host-entry.js +6 -0
- package/docs/AGENTS.md +9 -0
- package/docs/acceptance.md +89 -0
- package/docs/agent-acceptance.md +96 -0
- package/docs/chat-resource-cards.mdx +60 -0
- package/docs/docs.json +49 -0
- package/docs/drafts-acceptance.mdx +42 -0
- package/docs/drafts.mdx +35 -0
- package/docs/editing.mdx +63 -0
- package/docs/evolution-acceptance.mdx +98 -0
- package/docs/file-authoring-acceptance.mdx +62 -0
- package/docs/file-authoring.mdx +49 -0
- package/docs/file-datasets-acceptance.mdx +65 -0
- package/docs/fixed-build-multimodel-acceptance.mdx +129 -0
- package/docs/frontend-libraries-acceptance.mdx +86 -0
- package/docs/frontend-libraries.mdx +57 -0
- package/docs/html-acceptance.md +86 -0
- package/docs/html-mode.md +76 -0
- package/docs/index.mdx +47 -0
- package/docs/retry-regression-acceptance.mdx +112 -0
- package/docs/team-sharing-acceptance.mdx +66 -0
- package/docs/team-sharing.mdx +44 -0
- package/docs/verification.mdx +91 -0
- package/examples/assistant-middleware.yaml +28 -0
- package/examples/data-xpert-sales.json +118 -0
- package/examples/postgres-sales.json +93 -0
- package/index.cjs +1 -0
- package/package.json +73 -3
- package/skills/live-dashboard/SKILL.md +71 -0
- package/skills/live-dashboard/agents/xpertai.yaml +21 -0
- package/skills/live-dashboard/references/data-validation.md +15 -0
- package/skills/live-dashboard/references/html-lifecycle.md +129 -0
- package/skills/live-dashboard/references/html-runtime.md +53 -0
package/README.md
CHANGED
|
@@ -1,3 +1,109 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Live Dashboard
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
System plugin `@xpert-ai/plugin-live-dashboard`: versioned live dashboards using platform analytics, Workspace Files and Artifacts. Supports the existing Data Analytics renderer and Agent-authored HTML/CSS/JavaScript pages.
|
|
4
|
+
|
|
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
|
+
|
|
7
|
+
## Ownership and flow
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
Assistant tool / Workbench controls
|
|
11
|
+
→ DashboardService → platform.datasource.analytics
|
|
12
|
+
→ source plugin → native read-only query → canonical Dataset
|
|
13
|
+
→ Data Analytics adapter → existing renderer
|
|
14
|
+
|
|
15
|
+
Dashboard definition → Workspace Files → immutable Artifact version
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
The platform owns Dataset/Binding validation, source authorization and dispatch. This plugin owns dashboard schemas/UI and renderer translation; source plugins are independently replaceable. Its browser has no credentials, PostgreSQL driver or ontology client.
|
|
19
|
+
|
|
20
|
+
Supported source adapters include PostgreSQL (`postgres.sql`), MySQL (`mysql.sql`), Apache Doris (`doris.sql`),
|
|
21
|
+
data-xpert ontology (`data-xpert.ontology`) and Workspace scripts (`workspace_script.query`). MySQL/Doris
|
|
22
|
+
use the [analytics-mysql plugin](../../tools/analytics-mysql/README.md) with the existing MySQL database driver;
|
|
23
|
+
their query syntax and wire types stay outside the dashboard plugin. Install source providers separately.
|
|
24
|
+
|
|
25
|
+
`LiveDashboard` middleware exposes source discovery and dashboard creation tools, and activates `live_dashboard`. The view appears in the enabled Assistant Workbench/project detail host using existing View Host messages, not an alternate unscoped API.
|
|
26
|
+
|
|
27
|
+
## One-sentence Agent workflow
|
|
28
|
+
|
|
29
|
+
For existing dashboards, use `dashboard_list`, `dashboard_open`, `dashboard_read_html`, `dashboard_history` and `dashboard_update`.
|
|
30
|
+
The Workbench supplies its selected Artifact/version through the platform context command. Open returns the stable Artifact ID and current draft revision;
|
|
31
|
+
update preserves identity and omitted fields, requires fresh preview receipts for replacement bindings, and uses the existing validation/CAS path.
|
|
32
|
+
Successful update receipts open the saved working draft; only human publication creates a formal version. See [continuous editing](docs/editing.mdx).
|
|
33
|
+
|
|
34
|
+
Tools are `dashboard_list_sources`, `dashboard_discover`, `dashboard_preview`, `dashboard_preview_binding`, `dashboard_create`, `dashboard_open`, `dashboard_update` and `dashboard_create_html`. File authoring is supplied by the platform SandboxFile middleware. The canonical preview tool accepts complete `bindingJson` returned by an adapter registration tool. Both preview tools use the same discovery and receipt checks. The middleware adds business-semantic guidance while preserving the host system message. It requires discovery and a successful preview of the exact binding/defaults before creation via run-local `previewId` receipts; save revalidates current source access. Evidence is local to the run and actor, and repeated creation of the same manifest rechecks authorization before reusing its Artifact.
|
|
35
|
+
|
|
36
|
+
Specialized Assistants may configure `allowedFinalProviders` on the middleware, for example `["workspace_script.query"]`. Upstream discovery and preview still work with other providers, but Agent save rejects final bindings outside this list. Omit it for the existing unrestricted provider workflow. This is an Agent workflow policy, not a substitute for the server's source/Artifact authorization.
|
|
37
|
+
|
|
38
|
+
For a dedicated Dashboard Assistant, mark its connected `LiveDashboard` middleware node `required: true` (see the [graph fragment](examples/assistant-middleware.yaml)). ChatKit sends an explicit capability allowlist; an optional middleware is unavailable until the user selects it. Enabling the Workbench view alone does not enable Agent tools. Preserve that platform selection behavior for general-purpose Assistants.
|
|
39
|
+
|
|
40
|
+
Only the LLM boundary uses `requestJson` / `payloadJson` strings, because recursive JSON unions are unreliable in model function schemas. The plugin parses these into the unchanged canonical JSON protocol before calling the platform. Protocol version and operation come from the discovered provider contract; parameter name also supplies the Agent-created control ID. Saved manifests retain the full generic Binding protocol. Preview uses Binding parameter defaults, avoiding a second control mapping for the model to repeat. Provider syntax is learned from discovery, not embedded in platform prompts.
|
|
41
|
+
|
|
42
|
+
The model gets at most 20 preview rows/32 KB, with original completeness and explicit omitted-row counts. It has 24 model tool rounds; after that it must report saved receipts or a blocker. Authored definitions, units, date range and aggregation grain still require business verification: structural validation alone does not prove metric correctness.
|
|
43
|
+
|
|
44
|
+
Categorical charts must encode every Dataset grain dimension in `x`/`color`. The renderer does not aggregate: totals need a separate previewed binding. Unsupported business metrics require clarification, not a proxy dashboard without agreement.
|
|
45
|
+
|
|
46
|
+
The Workbench subscribes to the existing `assistant.tool.completed` event for `dashboard_create` / `dashboard_create_html` and opens the exact Artifact from a valid saved receipt. Start/failure logs are ignored and repeated versions are deduplicated; concurrent conversations cannot redirect it to a different “newest” dashboard. Refresh also retrieves new definitions when none is selected.
|
|
47
|
+
|
|
48
|
+
The creation tool returns `{ dashboard: { artifactId, versionId, versionNumber, title } }`. This domain receipt keeps the platform's generic file auto-opener from presenting the JSON definition as a finished report. Artifacts remain the durable version store; the plugin View owns live presentation.
|
|
49
|
+
|
|
50
|
+
## Save, filter, refresh
|
|
51
|
+
|
|
52
|
+
`xpert.live-dashboard/v1` contains id/title/bindings/controls/charts/tables and optional `presentation: { type: "html", html }`. Charts reference stable Dataset field IDs. Controls map to typed binding parameters. Filter and refresh execute the saved server-side definition for the current viewer.
|
|
53
|
+
|
|
54
|
+
Save validates and queries all bindings before writing immutable JSON. `expectedVersionId` (null for new) and platform Artifact row-lock compare-and-set prevent lost updates. Content hashes support retries. Saved files contain definitions, not result rows.
|
|
55
|
+
|
|
56
|
+
Preview/save also probe a declared non-default filter value and, when applicable, its null alternative. This catches predicates bypassed by an “all” default. Open-ended controls and all combinations of multiple filters still require scenario-specific acceptance.
|
|
57
|
+
|
|
58
|
+
Artifacts are owner-only within their agent/project host for this MVP. MIME: `application/json`; resource type: `live-dashboard`; namespace: `live_dashboard`. The Workbench supports selection, JSON import/edit, typed filters, refresh, version/freshness and partial-result notices.
|
|
59
|
+
|
|
60
|
+
## HTML mode
|
|
61
|
+
|
|
62
|
+
See [HTML mode and acceptance](docs/html-mode.md). Agent tools write a complete single-file document to the authorized file workspace, then read and copy its bytes into the immutable dashboard JSON version alongside Bindings and Controls. Before creating an Artifact, a plugin-owned Sandbox Action runs the page with real preview datasets in the platform Browser Runtime, through the sandbox-browser queue. Unavailable runtime or failed initial rendering blocks HTML save and returns diagnostics to the Agent. No live workspace path is dereferenced on reopening. A changed file requires a new saved version. Existing JSON-only dashboards remain compatible.
|
|
63
|
+
|
|
64
|
+
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.
|
|
65
|
+
|
|
66
|
+
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; network/CDN imports and eval are unavailable. Script processing remains in the separate Workspace Script provider.
|
|
67
|
+
|
|
68
|
+
HTML is capped at 300 KB; the whole saved definition remains capped at 600 KB. HTML pages own their chart layout, so their charts/tables arrays are empty. The standard renderer remains an independent option. Sharing, data permissions and source limits are unchanged.
|
|
69
|
+
|
|
70
|
+
## Renderer reuse
|
|
71
|
+
|
|
72
|
+
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.
|
|
73
|
+
|
|
74
|
+
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.
|
|
75
|
+
|
|
76
|
+
## Build and validation
|
|
77
|
+
|
|
78
|
+
Use the xpertai workspace's declared Corepack/pnpm. Development dependencies pin published SDK/contracts 3.25.0 and the Data Analytics renderer 0.1.35; no local platform or community links are required.
|
|
79
|
+
|
|
80
|
+
```sh
|
|
81
|
+
corepack pnpm install --frozen-lockfile
|
|
82
|
+
corepack pnpm exec nx build @xpert-ai/plugin-live-dashboard
|
|
83
|
+
corepack pnpm exec nx test @xpert-ai/plugin-live-dashboard
|
|
84
|
+
node apps/live-dashboard/tests/workbench-host.cjs
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
The representative host runs at http://127.0.0.1:4317. Import its `/manifest`; `/state` exposes non-secret acceptance counters. It uses the production bundle/service with in-memory capability fixtures. It proves UI protocol flow, not installed platform authentication or SSO.
|
|
88
|
+
|
|
89
|
+
Run the repository plugin harness before authenticated `plugin:deploy:local`. System plugins require API restart. For data-xpert, copy platform changes to xpert-pro and test through its SSO with published resources and viewer policies.
|
|
90
|
+
|
|
91
|
+
## MVP boundaries
|
|
92
|
+
|
|
93
|
+
Eight bindings, 24 controls, 20 charts/tables each, 100 listed dashboards per host. Queries execute sequentially with individual deadlines. No scheduler, cross-source joins, public sharing, shared result cache, visual query builder, chart-detail MCP resource or custom Artifact-gallery viewer. The Workbench provides authoring and preview. Authenticated team links open a standalone read-only page backed by the same renderers; drafts and management remain creator-only.
|
|
94
|
+
|
|
95
|
+
## Documentation
|
|
96
|
+
|
|
97
|
+
See [integration and architecture](docs/index.mdx), [build and verification](docs/verification.mdx), and the dated historical acceptance records linked there. The package includes the examples. Source-side `scripts/build-action.mjs --verify-package <extracted-package>` verifies the actual packed HTML validation Action.
|
|
98
|
+
|
|
99
|
+
Draft autosave and human publication: [workflow and architecture](docs/drafts.mdx), [SSO acceptance (2026-10-17)](docs/drafts-acceptance.mdx).
|
|
100
|
+
|
|
101
|
+
Agent 工作流程见随插件发布的 [live-dashboard 技能](skills/live-dashboard/SKILL.md) 和 [文件编辑说明](docs/file-authoring.mdx)。HTML 编辑需要平台 SandboxFile 与 skillsMiddleware。
|
|
102
|
+
|
|
103
|
+
## Team sharing
|
|
104
|
+
|
|
105
|
+
The Share action publishes a link to an already published dashboard: follow the latest formal version or pin one version. It never publishes a draft. Team members sign in and query as themselves; sharing the definition does not grant data-source, ontology or Workspace access. The creator can revoke the link. Workspace-script dashboards with private script/file dependencies are currently blocked with a diagnostic.
|
|
106
|
+
|
|
107
|
+
See [team sharing and standalone pages](docs/team-sharing.mdx) and [local acceptance](docs/team-sharing-acceptance.mdx). This feature needs a host exposing the Artifact Presentation registry, API and page; it cannot be installed on an older SDK alone.
|
|
108
|
+
|
|
109
|
+
Chat messages use the platform resource-card protocol after a successful create, update or open. The card opens the exact dashboard in Workbench; no dashboard renderer or queries are embedded in messages. See [chat resource cards](docs/chat-resource-cards.mdx).
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const node_fs_1 = require("node:fs");
|
|
4
|
+
const node_path_1 = require("node:path");
|
|
5
|
+
const plugin_1 = require("./lib/plugin");
|
|
6
|
+
const packageJson = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, '../package.json'), 'utf8'));
|
|
7
|
+
const plugin = {
|
|
8
|
+
meta: { name: packageJson.name, version: packageJson.version, category: 'middleware', displayName: 'Live dashboards', description: 'Live dashboards', author: 'XpertAI', level: packageJson.xpert.plugin.level, artifactNamespace: packageJson.xpert.plugin.artifactNamespace },
|
|
9
|
+
register: () => ({ module: plugin_1.LiveDashboardPlugin })
|
|
10
|
+
};
|
|
11
|
+
exports.default = plugin;
|