@xpert-ai/plugin-live-dashboard 0.2.0 → 0.3.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xpert-ai/plugin-live-dashboard",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "level": "system",
5
5
  "artifactNamespace": "live_dashboard",
6
6
  "sandboxActions": "./dist/sandbox-actions/action.json",
package/README.md CHANGED
@@ -35,6 +35,17 @@ Tools are `dashboard_list_sources`, `dashboard_discover`, `dashboard_preview`, `
35
35
 
36
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
37
 
38
+ The settings form now selects each entry from a dropdown. Options come from
39
+ `GET /api/live-dashboard/provider-options`, using the host Analytics capability
40
+ with the authenticated tenant, organization and user. It lists distinct Provider
41
+ types of **currently accessible data sources**, not every installed adapter or
42
+ individual database connection. The list refreshes on loading the selector;
43
+ unavailable saved IDs remain visible and are not silently removed. A configured
44
+ policy still requires 1–20 values; the saved `string[]` contract is unchanged.
45
+ An empty catalog means no accessible sources; authorization/catalog errors remain
46
+ errors. This uses the existing platform `remoteSelect` control and requires no
47
+ platform changes.
48
+
38
49
  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
50
 
40
51
  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.
@@ -57,12 +68,130 @@ Preview/save also probe a declared non-default filter value and, when applicable
57
68
 
58
69
  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
70
 
71
+ ## Built-in prompt workflows / 内置提示词模板
72
+
73
+ ### Chat shortcut buttons / 聊天快捷按钮
74
+
75
+ Like Presentation Studio, this plugin contributes an Assistant template with
76
+ 12 workspace prompt workflows. In the plugin's contents, choose **实时看板助手 /
77
+ Live Dashboard Assistant**, install it into the target workspace, and select the
78
+ model and sandbox in the existing setup wizard. Its required LiveDashboard,
79
+ Skills and SandboxFile middleware nodes are already connected. Workspace prompts
80
+ use `insert_text`: clicking a shortcut opens editable text before sending.
81
+
82
+ Shortcut resources use names beginning with `live-dashboard-`. The legacy
83
+ middleware commands below keep their `/dashboard-` names: the host gives middleware
84
+ commands precedence, so reusing those names would hide the workspace shortcuts.
85
+ Both paths share the same prompt content. The workspace prompt library remains
86
+ the place to edit labels, content and Assistant associations.
87
+
88
+ **Existing Assistants:** a plugin update alone does not seed workspace resources.
89
+ Import the prompts once, or associate already imported prompts with the Assistant
90
+ in the workspace prompt library. The following shipped helper supports a one-time
91
+ import without changing the Assistant graph, model, publication or existing prompts:
92
+
93
+ 1. Configure and publish the Assistant with LiveDashboard connected to its main
94
+ Agent and **System middleware** enabled. Keep its normal Skills, SandboxFile,
95
+ model and sandbox configuration.
96
+ 2. From this plugin package directory (source checkout: build first), use Node 20+
97
+ and a platform login token with authoring access to the target workspace.
98
+ Provide `XPERT_TOKEN` through your normal secret environment; do not store it
99
+ in shell history or commit it. IDs come from the selected organization and
100
+ published Assistant.
101
+
102
+ ```sh
103
+ node scripts/import-prompts.mjs \
104
+ --api-url https://your-xpert-host/api \
105
+ --organization-id YOUR_ORGANIZATION_UUID \
106
+ --assistant-id YOUR_ASSISTANT_UUID
107
+ ```
108
+
109
+ 3. Review the read-only preview. Repeat with `--apply` to create only the missing
110
+ resources, associated with this Assistant. The script then checks the published
111
+ runtime exposes the new `insert_text` shortcuts. Reopen the chat/new conversation
112
+ to refresh its command list. No republishing is needed just for prompt import.
113
+
114
+ The helper never overwrites or archives prompts or changes associations. Matching,
115
+ active and applicable prompts are skipped. Edited/archived prompts, resources
116
+ associated with another Assistant, or disabled/overridden command-profile entries
117
+ stop the import before writes: resolve those deliberately in the prompt library
118
+ or Assistant command settings. For a second Assistant in the same workspace,
119
+ associate the existing resources instead of importing duplicates. Network failures
120
+ can leave some newly created prompts; rerunning safely skips them. Use HTTPS for
121
+ remote hosts and configure trust for private certificates; do not disable TLS
122
+ verification. The helper does not install or update the plugin.
123
+
124
+ ### Middleware slash commands / 中间件斜杠命令
125
+
126
+ When the Assistant has the `LiveDashboard` middleware, type `/dashboard-` in its
127
+ chat composer and select a workflow. Selection inserts an invocation so the user
128
+ can add requirements before sending; it does not submit or publish automatically.
129
+ Commands are contributed by the installed middleware, so existing Assistants can
130
+ use them after the updated plugin is loaded. No Assistant-template import or
131
+ database seeding is needed. The host must support middleware slash commands.
132
+
133
+ | Mode / 分类 | Command | 用途 |
134
+ | --- | --- | --- |
135
+ | Standard | `/dashboard-standard-auto` | 根据真实数据质量和业务价值自动选题,新建独立标准看板 |
136
+ | Standard | `/dashboard-standard-new` | 围绕指定主题新建标准看板 |
137
+ | Standard | `/dashboard-standard-improve` | 调整指定看板的图表、指标、筛选,保留 Artifact 身份 |
138
+ | Standard | `/dashboard-standard-recover` | 定位失败步骤,用本轮证据恢复标准草稿保存 |
139
+ | HTML | `/dashboard-html-auto` | 自动选题,新建布局精致、可实际使用的 HTML 看板 |
140
+ | HTML | `/dashboard-html-new` | 围绕指定业务问题、受众和视觉要求新建 HTML 看板 |
141
+ | HTML | `/dashboard-html-style` | 参考图片或风格描述美化已有 HTML 看板,保留查询与交互 |
142
+ | HTML | `/dashboard-html-recover` | 保留页面候选,按真实校验错误修复并恢复保存 |
143
+ | Inspect | `/dashboard-explore` | 只读探索数据源、字段、日期覆盖和候选业务主题 |
144
+ | Inspect | `/dashboard-test-source` | 最小真实查询、字段映射和筛选验证 |
145
+ | Inspect | `/dashboard-audit-metrics` | 只读核对计算、单位、期间和关联粒度 |
146
+ | Inspect | `/dashboard-verify` | 核对保存版本、筛选、刷新,并标明未执行的页面验收 |
147
+
148
+ Examples (replace the descriptive inputs with your own requirements):
149
+
150
+ ```text
151
+ /dashboard-standard-auto 使用当前组织的 BI 数据源,为采购主管挑选一个数据完整、能帮助识别交付问题的主题。新建独立看板。
152
+ /dashboard-standard-new 使用库存数据,面向仓库主管创建库存积压看板。核实库龄和库存金额口径,提供仓库与日期筛选。
153
+ /dashboard-html-auto 从已授权数据中选择一个能支持日常运营决策的主题。面向部门负责人,浅色企业风格,摘要指标、主趋势、关注清单和明细。
154
+ /dashboard-html-new 创建供应商交付分析看板。使用已授权采购数据,核实交付及时率口径;参考附图的留白、层次和配色,不复制示例数字。
155
+ /dashboard-html-style 美化当前选中的 HTML 看板,参考附图布局;保留现有指标、绑定、筛选和刷新,只调整视觉。
156
+ /dashboard-html-recover 继续保存刚才失败的 HTML 候选。读取实际文件与错误,重新获取本轮所需预览;如果运行时仍不可用,报告准确阻塞。
157
+ /dashboard-test-source 检查当前采购数据源的一个有实际数据的查询,验证一个供应商筛选及全部供应商。
158
+ /dashboard-verify 检查当前看板的默认日期、一个真实筛选值和全部值;区分查询验证与待人工页面验证。
159
+ ```
160
+
161
+ Provide a source name, business question, audience and date range where relevant;
162
+ HTML requests can include a reference image or style. IDs, provider contracts and
163
+ paths are discovered from tools, never hard-coded into the templates. Automatic
164
+ selection ranks business usefulness and data readiness; specified-topic workflows
165
+ do not silently substitute another topic. New HTML workflows choose an unused
166
+ file path and never overwrite the selected dashboard.
167
+
168
+ The templates guide real queries, metric checks, run-local previews/filter tests
169
+ and successful draft-save receipts. They do not grant source access or install a
170
+ missing Browser Runtime. HTML saves still require runtime validation. Native
171
+ dashboards keep their own renderer and supported chart/table schema. Formal
172
+ publication remains a human action. Inspection commands do not register
173
+ definitions, edit business data or save dashboards; a tool-level pass is not a
174
+ claim of visual acceptance.
175
+
176
+ ### Manual acceptance after loading the plugin
177
+
178
+ 1. In an Assistant with LiveDashboard, open the `/` picker and search `dashboard`.
179
+ Verify all twelve localized entries; selecting one should leave an editable
180
+ invocation in the composer.
181
+ 2. Run one standard-new and one HTML-new request against an authorized test source.
182
+ Verify independent Artifact IDs, fresh previews and successful draft receipts;
183
+ HTML also requires its normal Browser Runtime check.
184
+ 3. Reopen each saved draft, change a real filter and refresh. Confirm real data
185
+ updates. Run an inspection command and verify it does not save a new revision.
186
+
60
187
  ## HTML mode
61
188
 
62
189
  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
190
 
64
191
  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
192
 
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 without raising the SDK's query/concurrency limits. A request storm within a scenario still blocks saving; preflight is not a full combinatorial or sustained-load test.
194
+
66
195
  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.
67
196
 
68
197
  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.
@@ -107,3 +236,11 @@ The Share action publishes a link to an already published dashboard: follow the
107
236
  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
237
 
109
238
  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).
239
+
240
+ ### Delete a saved dashboard
241
+
242
+ Open the dashboard picker and use the trash icon beside an entry. The confirmation shows its title and Artifact ID, so same-name dashboards can be distinguished. Deletion recycles the whole dashboard (draft and published versions), removes it from the active list and revokes shared links; it does not delete source data or Assistant workspace files. Deleting the selected dashboard clears its preview and Assistant context; deleting another dashboard preserves the current view.
243
+
244
+ The owner can delete private Assistant dashboards; Project dashboards require the current user's management permission. Read-only shared pages expose no delete control. The platform checks the confirmed draft revision atomically, rejecting concurrent edits. Entries without a saved working draft (legacy version-only or incomplete first saves) have no recycle revision and do not expose this action. No Agent deletion tool is registered.
245
+
246
+ Manual acceptance after installing the updated plugin: cancel a deletion and confirm the entry remains; delete an unused saved dashboard and confirm it stays absent after reload; delete the selected dashboard and confirm the preview clears and its old shared link is unavailable.
package/dist/index.js CHANGED
@@ -3,9 +3,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const node_fs_1 = require("node:fs");
4
4
  const node_path_1 = require("node:path");
5
5
  const plugin_1 = require("./lib/plugin");
6
+ const assistant_template_1 = require("./lib/assistant-template");
7
+ const dashboard_icon_1 = require("./lib/dashboard-icon");
6
8
  const packageJson = JSON.parse((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, '../package.json'), 'utf8'));
7
9
  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 },
10
+ meta: {
11
+ name: packageJson.name, version: packageJson.version, category: 'middleware', displayName: 'Live dashboards', description: 'Live dashboards',
12
+ author: 'XpertAI', level: packageJson.xpert.plugin.level, artifactNamespace: packageJson.xpert.plugin.artifactNamespace, icon: dashboard_icon_1.dashboardIcon,
13
+ targetApps: ['xpert'],
14
+ targetAppMeta: { xpert: { types: ['assistant-template'], marketplace: { contents: [
15
+ { type: 'assistant-template', name: assistant_template_1.DASHBOARD_TEMPLATE_KEY, displayName: assistant_template_1.dashboardAssistantTemplate.title, description: assistant_template_1.dashboardAssistantTemplate.description }
16
+ ] } } }
17
+ },
18
+ templates: [assistant_template_1.dashboardAssistantTemplate],
9
19
  register: () => ({ module: plugin_1.LiveDashboardPlugin })
10
20
  };
11
21
  exports.default = plugin;
@@ -0,0 +1,3 @@
1
+ import type { XpertTemplateContribution } from '@xpert-ai/plugin-sdk';
2
+ export declare const DASHBOARD_TEMPLATE_KEY = "live-dashboard-assistant";
3
+ export declare const dashboardAssistantTemplate: XpertTemplateContribution;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.dashboardAssistantTemplate = exports.DASHBOARD_TEMPLATE_KEY = void 0;
4
+ const contracts_1 = require("@xpert-ai/contracts");
5
+ const dashboard_icon_1 = require("./dashboard-icon");
6
+ const prompt_workflows_1 = require("./prompt-workflows");
7
+ exports.DASHBOARD_TEMPLATE_KEY = 'live-dashboard-assistant';
8
+ const agentKey = 'Agent_LiveDashboard';
9
+ const middlewares = [
10
+ { key: 'Middleware_LiveDashboard', provider: 'LiveDashboard', title: '实时看板' },
11
+ { key: 'Middleware_Skills', provider: 'skillsMiddleware', title: 'Skills' },
12
+ { key: 'Middleware_SandboxFile', provider: 'SandboxFile', title: 'Sandbox files' }
13
+ ];
14
+ // The installation wizard resolves the model and sandbox provider for the target workspace.
15
+ exports.dashboardAssistantTemplate = {
16
+ key: exports.DASHBOARD_TEMPLATE_KEY,
17
+ name: 'Live Dashboard Assistant',
18
+ title: { en_US: 'Live Dashboard Assistant', zh_Hans: '实时看板助手' },
19
+ description: {
20
+ en_US: 'Create and improve standard or HTML dashboards from authorized data, with twelve editable prompt shortcuts.',
21
+ zh_Hans: '基于授权数据创建和优化标准或 HTML 看板,附带 12 个可编辑快捷提示词。'
22
+ },
23
+ icon: dashboard_icon_1.dashboardIcon,
24
+ type: contracts_1.XpertTypeEnum.Agent,
25
+ category: 'Analytics',
26
+ targetApps: ['xpert'],
27
+ dependencies: { plugins: ['@xpert-ai/plugin-live-dashboard'] },
28
+ promptWorkflows: prompt_workflows_1.dashboardWorkspacePrompts,
29
+ dslContent: JSON.stringify({
30
+ team: {
31
+ name: 'live-dashboard-assistant', type: 'agent', title: '实时看板助手',
32
+ description: 'Create verified live dashboards from authorized business data.',
33
+ agent: { key: agentKey },
34
+ features: { sandbox: { enabled: true } },
35
+ version: '1'
36
+ },
37
+ nodes: [
38
+ {
39
+ type: 'agent', key: agentKey, position: { x: 480, y: 40 },
40
+ entity: {
41
+ key: agentKey, name: 'live-dashboard-assistant', title: '实时看板助手',
42
+ prompt: 'Use the LiveDashboard tools and installed live-dashboard skill. Discover authorized data, verify business metrics and previews, then save a draft. Report success only after a successful save receipt. Match the user language.',
43
+ options: { middlewares: { order: middlewares.map(({ key }) => key) } },
44
+ collaboratorNames: [], toolsetIds: [], knowledgebaseIds: []
45
+ }
46
+ },
47
+ ...middlewares.map(({ key, provider, title }, index) => ({
48
+ type: 'workflow', key, position: { x: index * 320, y: 320 },
49
+ entity: { type: 'middleware', key, provider, title, required: true, options: {} }
50
+ }))
51
+ ],
52
+ connections: middlewares.map(({ key }) => ({ type: 'workflow', key: `${agentKey}/${key}`, from: agentKey, to: key }))
53
+ }),
54
+ default: false,
55
+ order: 75
56
+ };
@@ -6,6 +6,7 @@ export declare const dashboardSummarySchema: z.ZodObject<{
6
6
  title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
7
7
  updatedAt: z.ZodOptional<z.ZodString>;
8
8
  draftRevision: z.ZodOptional<z.ZodNumber>;
9
+ canDelete: z.ZodOptional<z.ZodBoolean>;
9
10
  isDraft: z.ZodOptional<z.ZodBoolean>;
10
11
  baseVersionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
11
12
  }, "strip", z.ZodTypeAny, {
@@ -17,6 +18,7 @@ export declare const dashboardSummarySchema: z.ZodObject<{
17
18
  baseVersionId?: string | null | undefined;
18
19
  isDraft?: boolean | undefined;
19
20
  updatedAt?: string | undefined;
21
+ canDelete?: boolean | undefined;
20
22
  }, {
21
23
  artifactId: string;
22
24
  title?: string | null | undefined;
@@ -26,6 +28,7 @@ export declare const dashboardSummarySchema: z.ZodObject<{
26
28
  baseVersionId?: string | null | undefined;
27
29
  isDraft?: boolean | undefined;
28
30
  updatedAt?: string | undefined;
31
+ canDelete?: boolean | undefined;
29
32
  }>;
30
33
  export declare const dashboardSavedSchema: z.ZodObject<{
31
34
  artifactId: z.ZodString;
@@ -34,6 +37,7 @@ export declare const dashboardSavedSchema: z.ZodObject<{
34
37
  title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
35
38
  updatedAt: z.ZodOptional<z.ZodString>;
36
39
  draftRevision: z.ZodOptional<z.ZodNumber>;
40
+ canDelete: z.ZodOptional<z.ZodBoolean>;
37
41
  isDraft: z.ZodOptional<z.ZodBoolean>;
38
42
  baseVersionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
39
43
  } & {
@@ -365,6 +369,7 @@ export declare const dashboardSavedSchema: z.ZodObject<{
365
369
  baseVersionId?: string | null | undefined;
366
370
  isDraft?: boolean | undefined;
367
371
  updatedAt?: string | undefined;
372
+ canDelete?: boolean | undefined;
368
373
  }, {
369
374
  manifest: {
370
375
  schema: "xpert.live-dashboard";
@@ -421,6 +426,7 @@ export declare const dashboardSavedSchema: z.ZodObject<{
421
426
  baseVersionId?: string | null | undefined;
422
427
  isDraft?: boolean | undefined;
423
428
  updatedAt?: string | undefined;
429
+ canDelete?: boolean | undefined;
424
430
  }>;
425
431
  export declare const dashboardViewDataSchema: z.ZodObject<{
426
432
  meta: z.ZodObject<{
@@ -453,6 +459,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
453
459
  title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
454
460
  updatedAt: z.ZodOptional<z.ZodString>;
455
461
  draftRevision: z.ZodOptional<z.ZodNumber>;
462
+ canDelete: z.ZodOptional<z.ZodBoolean>;
456
463
  isDraft: z.ZodOptional<z.ZodBoolean>;
457
464
  baseVersionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
458
465
  }, "strip", z.ZodTypeAny, {
@@ -464,6 +471,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
464
471
  baseVersionId?: string | null | undefined;
465
472
  isDraft?: boolean | undefined;
466
473
  updatedAt?: string | undefined;
474
+ canDelete?: boolean | undefined;
467
475
  }, {
468
476
  artifactId: string;
469
477
  title?: string | null | undefined;
@@ -473,6 +481,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
473
481
  baseVersionId?: string | null | undefined;
474
482
  isDraft?: boolean | undefined;
475
483
  updatedAt?: string | undefined;
484
+ canDelete?: boolean | undefined;
476
485
  }>, "many">;
477
486
  sources: z.ZodArray<z.ZodObject<{
478
487
  source: z.ZodType<import("@xpert-ai/contracts").AnalyticsSourceRef, z.ZodTypeDef, import("@xpert-ai/contracts").AnalyticsSourceRef>;
@@ -491,6 +500,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
491
500
  title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
492
501
  updatedAt: z.ZodOptional<z.ZodString>;
493
502
  draftRevision: z.ZodOptional<z.ZodNumber>;
503
+ canDelete: z.ZodOptional<z.ZodBoolean>;
494
504
  isDraft: z.ZodOptional<z.ZodBoolean>;
495
505
  baseVersionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
496
506
  } & {
@@ -822,6 +832,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
822
832
  baseVersionId?: string | null | undefined;
823
833
  isDraft?: boolean | undefined;
824
834
  updatedAt?: string | undefined;
835
+ canDelete?: boolean | undefined;
825
836
  }, {
826
837
  manifest: {
827
838
  schema: "xpert.live-dashboard";
@@ -878,6 +889,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
878
889
  baseVersionId?: string | null | undefined;
879
890
  isDraft?: boolean | undefined;
880
891
  updatedAt?: string | undefined;
892
+ canDelete?: boolean | undefined;
881
893
  }>>;
882
894
  versions: z.ZodOptional<z.ZodArray<z.ZodObject<{
883
895
  artifactId: z.ZodString;
@@ -886,6 +898,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
886
898
  title: z.ZodOptional<z.ZodNullable<z.ZodString>>;
887
899
  updatedAt: z.ZodOptional<z.ZodString>;
888
900
  draftRevision: z.ZodOptional<z.ZodNumber>;
901
+ canDelete: z.ZodOptional<z.ZodBoolean>;
889
902
  isDraft: z.ZodOptional<z.ZodBoolean>;
890
903
  baseVersionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
891
904
  }, "strip", z.ZodTypeAny, {
@@ -897,6 +910,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
897
910
  baseVersionId?: string | null | undefined;
898
911
  isDraft?: boolean | undefined;
899
912
  updatedAt?: string | undefined;
913
+ canDelete?: boolean | undefined;
900
914
  }, {
901
915
  artifactId: string;
902
916
  title?: string | null | undefined;
@@ -906,6 +920,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
906
920
  baseVersionId?: string | null | undefined;
907
921
  isDraft?: boolean | undefined;
908
922
  updatedAt?: string | undefined;
923
+ canDelete?: boolean | undefined;
909
924
  }>, "many">>;
910
925
  }, "strip", z.ZodTypeAny, {
911
926
  sources: {
@@ -921,6 +936,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
921
936
  baseVersionId?: string | null | undefined;
922
937
  isDraft?: boolean | undefined;
923
938
  updatedAt?: string | undefined;
939
+ canDelete?: boolean | undefined;
924
940
  }[];
925
941
  saved?: {
926
942
  manifest: {
@@ -965,6 +981,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
965
981
  baseVersionId?: string | null | undefined;
966
982
  isDraft?: boolean | undefined;
967
983
  updatedAt?: string | undefined;
984
+ canDelete?: boolean | undefined;
968
985
  } | undefined;
969
986
  navigationTarget?: {
970
987
  target: "workbench.view";
@@ -983,6 +1000,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
983
1000
  baseVersionId?: string | null | undefined;
984
1001
  isDraft?: boolean | undefined;
985
1002
  updatedAt?: string | undefined;
1003
+ canDelete?: boolean | undefined;
986
1004
  }[] | undefined;
987
1005
  }, {
988
1006
  sources: {
@@ -998,6 +1016,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
998
1016
  baseVersionId?: string | null | undefined;
999
1017
  isDraft?: boolean | undefined;
1000
1018
  updatedAt?: string | undefined;
1019
+ canDelete?: boolean | undefined;
1001
1020
  }[];
1002
1021
  saved?: {
1003
1022
  manifest: {
@@ -1055,6 +1074,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
1055
1074
  baseVersionId?: string | null | undefined;
1056
1075
  isDraft?: boolean | undefined;
1057
1076
  updatedAt?: string | undefined;
1077
+ canDelete?: boolean | undefined;
1058
1078
  } | undefined;
1059
1079
  navigationTarget?: {
1060
1080
  target: "workbench.view";
@@ -1073,6 +1093,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
1073
1093
  baseVersionId?: string | null | undefined;
1074
1094
  isDraft?: boolean | undefined;
1075
1095
  updatedAt?: string | undefined;
1096
+ canDelete?: boolean | undefined;
1076
1097
  }[] | undefined;
1077
1098
  }>;
1078
1099
  }, "strip", z.ZodTypeAny, {
@@ -1090,6 +1111,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
1090
1111
  baseVersionId?: string | null | undefined;
1091
1112
  isDraft?: boolean | undefined;
1092
1113
  updatedAt?: string | undefined;
1114
+ canDelete?: boolean | undefined;
1093
1115
  }[];
1094
1116
  saved?: {
1095
1117
  manifest: {
@@ -1134,6 +1156,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
1134
1156
  baseVersionId?: string | null | undefined;
1135
1157
  isDraft?: boolean | undefined;
1136
1158
  updatedAt?: string | undefined;
1159
+ canDelete?: boolean | undefined;
1137
1160
  } | undefined;
1138
1161
  navigationTarget?: {
1139
1162
  target: "workbench.view";
@@ -1152,6 +1175,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
1152
1175
  baseVersionId?: string | null | undefined;
1153
1176
  isDraft?: boolean | undefined;
1154
1177
  updatedAt?: string | undefined;
1178
+ canDelete?: boolean | undefined;
1155
1179
  }[] | undefined;
1156
1180
  };
1157
1181
  }, {
@@ -1169,6 +1193,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
1169
1193
  baseVersionId?: string | null | undefined;
1170
1194
  isDraft?: boolean | undefined;
1171
1195
  updatedAt?: string | undefined;
1196
+ canDelete?: boolean | undefined;
1172
1197
  }[];
1173
1198
  saved?: {
1174
1199
  manifest: {
@@ -1226,6 +1251,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
1226
1251
  baseVersionId?: string | null | undefined;
1227
1252
  isDraft?: boolean | undefined;
1228
1253
  updatedAt?: string | undefined;
1254
+ canDelete?: boolean | undefined;
1229
1255
  } | undefined;
1230
1256
  navigationTarget?: {
1231
1257
  target: "workbench.view";
@@ -1244,6 +1270,7 @@ export declare const dashboardViewDataSchema: z.ZodObject<{
1244
1270
  baseVersionId?: string | null | undefined;
1245
1271
  isDraft?: boolean | undefined;
1246
1272
  updatedAt?: string | undefined;
1273
+ canDelete?: boolean | undefined;
1247
1274
  }[] | undefined;
1248
1275
  };
1249
1276
  }>;
@@ -6,7 +6,7 @@ const analytics_1 = require("@xpert-ai/plugin-sdk/analytics");
6
6
  const artifact_document_1 = require("@xpert-ai/plugin-sdk/artifact-document");
7
7
  const dashboard_schema_1 = require("./dashboard.schema");
8
8
  const dashboard_navigation_1 = require("./dashboard-navigation");
9
- exports.dashboardSummarySchema = v3_1.z.object({ artifactId: v3_1.z.string(), versionId: v3_1.z.string().nullish(), versionNumber: v3_1.z.number().optional(), title: v3_1.z.string().nullish(), updatedAt: v3_1.z.string().optional(), draftRevision: v3_1.z.number().optional(), isDraft: v3_1.z.boolean().optional(), baseVersionId: v3_1.z.string().nullish() });
9
+ exports.dashboardSummarySchema = v3_1.z.object({ artifactId: v3_1.z.string(), versionId: v3_1.z.string().nullish(), versionNumber: v3_1.z.number().optional(), title: v3_1.z.string().nullish(), updatedAt: v3_1.z.string().optional(), draftRevision: v3_1.z.number().optional(), canDelete: v3_1.z.boolean().optional(), isDraft: v3_1.z.boolean().optional(), baseVersionId: v3_1.z.string().nullish() });
10
10
  exports.dashboardSavedSchema = exports.dashboardSummarySchema.extend({ manifest: dashboard_schema_1.dashboardSchema, dependencies: artifact_document_1.artifactDocumentDependencyAssets.optional() });
11
11
  // Source identities belong to Analytics, including immutable Definitions and Artifacts.
12
12
  // The viewer consumes only the reference and label; DataSource fields are not universal.
@@ -12,11 +12,16 @@ export declare class DashboardService {
12
12
  preview(context: XpertResolvedViewHostContext, input: AnalyticsQueryRequest): Promise<import("@xpert-ai/contracts").AnalyticalDataset>;
13
13
  list(context: XpertResolvedViewHostContext): Promise<{
14
14
  title: string | null | undefined;
15
+ draftRevision?: number | undefined;
16
+ canDelete: boolean;
15
17
  artifactId: string;
16
18
  versionId: string | null | undefined;
17
19
  versionNumber: number | undefined;
18
20
  updatedAt: string | Date | undefined;
19
21
  }[]>;
22
+ trash(context: XpertResolvedViewHostContext, artifactId: string, expectedRevision: number): Promise<{
23
+ artifactId: string;
24
+ }>;
20
25
  save(context: XpertResolvedViewHostContext, manifest: DashboardManifest, expectedVersionId: string | null, expectedRevision?: number): Promise<{
21
26
  artifactId: string;
22
27
  draftId: string;
@@ -244,7 +249,7 @@ export declare class DashboardService {
244
249
  }>;
245
250
  queryBinding(context: XpertResolvedViewHostContext, artifactId: string, versionId: string | undefined, bindingId: string, input: Record<string, AnalyticsValue>, draftRevision?: number): Promise<import("@xpert-ai/contracts").AnalyticalDataset>;
246
251
  /** Every operation uses the current human's Project role; data queries still use actor(context). */
247
- authorizeProject(context: XpertResolvedViewHostContext, operation?: 'read' | 'write' | 'manage'): Promise<void>;
252
+ authorizeProject(context: XpertResolvedViewHostContext, operation?: 'read' | 'write' | 'manage'): Promise<import("@xpert-ai/plugin-sdk").ProjectHumanAccess | undefined>;
248
253
  private execute;
249
254
  private probeControls;
250
255
  }
@@ -40,11 +40,25 @@ let DashboardService = class DashboardService {
40
40
  return dataset;
41
41
  }
42
42
  async list(context) {
43
- await this.authorizeProject(context);
43
+ const access = await this.authorizeProject(context);
44
44
  const result = await this.runtime.require(plugin_sdk_1.ArtifactsRuntimeCapability).listArtifacts({ pluginName: exports.PLUGIN_NAME, resourceType: RESOURCE_TYPE, resourceIdPrefix: hostPrefix(context), status: 'active', pageSize: 100, includeCurrentVersion: true });
45
45
  const items = result.items.filter((item) => item.resourceId.startsWith(hostPrefix(context)) && (item.userId === context.userId || !item.userId && item.projectId === projectId(context)));
46
46
  const drafts = new Map((await this.runtime.require(plugin_sdk_1.ArtifactDraftsRuntimeCapability).list(items.map(item => item.id))).map(draft => [draft.artifactId, draft]));
47
- return items.map(item => ({ ...summary(item), ...(drafts.has(item.id) ? { title: drafts.get(item.id).title ?? item.title } : {}) }));
47
+ return items.map(item => {
48
+ const draft = drafts.get(item.id);
49
+ return { ...summary(item), canDelete: !!draft && (!projectId(context) || access?.canManage === true),
50
+ ...(draft ? { title: draft.title ?? item.title, draftRevision: draft.revision } : {}) };
51
+ });
52
+ }
53
+ async trash(context, artifactId, expectedRevision) {
54
+ await this.authorizeProject(context, 'manage');
55
+ const artifact = await this.runtime.require(plugin_sdk_1.ArtifactsRuntimeCapability).getArtifact(artifactId);
56
+ assertOwned(context, artifact);
57
+ if (artifact.status !== 'active')
58
+ throw new common_1.ForbiddenException('DASHBOARD_ARCHIVED');
59
+ // Reuse the platform's atomic revision check, recycle state and share revocation.
60
+ await this.runtime.require(plugin_sdk_1.ArtifactDraftsRuntimeCapability).setRecycled({ artifactId, expectedRevision, recycled: true });
61
+ return { artifactId };
48
62
  }
49
63
  async save(context, manifest, expectedVersionId, expectedRevision = 0) {
50
64
  await this.authorizeProject(context, 'write');
@@ -175,11 +189,13 @@ let DashboardService = class DashboardService {
175
189
  if (context.hostType === 'agent')
176
190
  await access.assertAssistant({ ...input, assistantId: context.hostId });
177
191
  if (operation === 'write')
178
- await access.assertEdit(input);
179
- else if (operation === 'manage')
180
- await access.assertManage(input);
181
- else if (!(await access.listReadable({ actor: scopedActor, projectIds: [project] })).length)
192
+ return access.assertEdit(input);
193
+ if (operation === 'manage')
194
+ return access.assertManage(input);
195
+ const readable = (await access.listReadable({ actor: scopedActor, projectIds: [project] })).find(item => item.projectId === project);
196
+ if (!readable)
182
197
  throw new common_1.ForbiddenException('DASHBOARD_ACCESS_DENIED');
198
+ return readable;
183
199
  }
184
200
  execute(context, manifest, input) {
185
201
  return (0, dashboard_queries_1.queryDashboard)(this.runtime, actor(context), manifest, input);
@@ -33,7 +33,12 @@ const save_evidence_1 = require("./save-evidence");
33
33
  const resource_card_1 = require("./resource-card");
34
34
  const dashboard_icon_1 = require("./dashboard-icon");
35
35
  const preview_retry_1 = require("./preview-retry");
36
+ const prompt_workflows_1 = require("./prompt-workflows");
36
37
  const middlewareOptionsSchema = v3_1.z.object({ allowedFinalProviders: v3_1.z.array(v3_1.z.string().min(1)).min(1).max(20).optional() }).strict().default({});
38
+ const providerOptionSchema = {
39
+ type: 'string',
40
+ 'x-ui': { component: 'remoteSelect', selectUrl: '/api/live-dashboard/provider-options' }
41
+ };
37
42
  exports.DASHBOARD_GUIDANCE = `For a new independent dashboard, use a new unused HTML file path. An existing filename or matching title is not authorization to edit another Artifact; do not switch from creation to dashboard_open/update because a file already exists. For a new dashboard, call dashboard_list_sources before searching raw files, reading old scripts or creating transformations. Named governed sources may already provide the required query; inspect their provider contracts first. File-backed sources do not imply that a script must be written. For creating or editing live dashboards, first read the installed live-dashboard skill using read_skill_file and follow only the references relevant to the task. Use SandboxFile tools for all source-file authoring; HTML alone is not a saved dashboard. Follow preview.validation.checks immediately before authoring HTML; each suggestedCall must actually succeed. Business definitions, real data previews and nullable-filter tests are required before saving new or changed Bindings. Do not invent business data or substitute a different metric without agreement. Report completion only from a successful dashboard_create/dashboard_create_html/dashboard_update draft receipt. Human publication is separate. Successful create, update and open tools emit a chat resource card automatically; resourceCard.status reports emission. Its Open button selects the exact dashboard in Workbench. Never fabricate a link, call present_files for dashboard HTML, or output card JSON as text. If card delivery is unavailable, report the saved receipt and use the Workbench picker.`;
38
43
  let DashboardMiddleware = class DashboardMiddleware {
39
44
  constructor(service) {
@@ -41,10 +46,11 @@ let DashboardMiddleware = class DashboardMiddleware {
41
46
  this.meta = {
42
47
  name: 'LiveDashboard', label: { en_US: 'Live dashboards', zh_Hans: '实时看板' },
43
48
  description: { en_US: 'Discover, preview, create and update governed live dashboards.', zh_Hans: '发现业务数据、验证查询并持续修改实时看板。' },
49
+ slashCommands: prompt_workflows_1.dashboardPromptWorkflows,
44
50
  // Tools inherit this self-contained icon through the platform middleware metadata.
45
51
  icon: dashboard_icon_1.dashboardIcon, features: [view_provider_1.FEATURE], configSchema: { type: 'object', properties: {
46
- allowedFinalProviders: { type: 'array', items: { type: 'string' }, title: { en_US: 'Allowed final dashboard providers', zh_Hans: '最终看板允许的 Provider' },
47
- description: { en_US: 'Optional provider IDs required for saved Agent dashboards. Upstream previews remain available.', zh_Hans: '可选的最终看板 Provider ID 列表,不限制上游来源预览。' } }
52
+ allowedFinalProviders: { type: 'array', minItems: 1, maxItems: 20, items: providerOptionSchema, title: { en_US: 'Allowed final dashboard providers', zh_Hans: '最终看板允许的数据源类型' },
53
+ description: { en_US: 'Choose at least one provider from sources you can access when setting this policy. Existing unavailable IDs are retained. Upstream previews remain available.', zh_Hans: '配置此限制时至少选择一种当前可访问数据源的 Provider;暂不可用的已有值会保留,不影响上游来源预览。' } }
48
54
  }, additionalProperties: false }
49
55
  };
50
56
  }
@@ -16,9 +16,10 @@ const middleware_1 = require("./middleware");
16
16
  const html_validation_1 = require("./html-validation");
17
17
  const presentation_provider_1 = require("./presentation.provider");
18
18
  const sharing_service_1 = require("./sharing.service");
19
+ const provider_options_controller_1 = require("./provider-options.controller");
19
20
  let LiveDashboardPlugin = class LiveDashboardPlugin {
20
21
  };
21
22
  exports.LiveDashboardPlugin = LiveDashboardPlugin;
22
23
  exports.LiveDashboardPlugin = LiveDashboardPlugin = __decorate([
23
- (0, plugin_sdk_1.XpertServerPlugin)({ providers: [content_capability_1.DashboardCapability, content_provider_1.DashboardContentProvider, content_provider_1.DashboardContentEditor, dashboard_service_1.DashboardService, view_provider_1.DashboardViewProvider, middleware_1.DashboardMiddleware, html_validation_1.HtmlDashboardValidation, presentation_provider_1.DashboardPresentationProvider, sharing_service_1.DashboardSharingService] })
24
+ (0, plugin_sdk_1.XpertServerPlugin)({ controllers: [provider_options_controller_1.DashboardProviderOptionsController], providers: [content_capability_1.DashboardCapability, content_provider_1.DashboardContentProvider, content_provider_1.DashboardContentEditor, dashboard_service_1.DashboardService, view_provider_1.DashboardViewProvider, middleware_1.DashboardMiddleware, html_validation_1.HtmlDashboardValidation, presentation_provider_1.DashboardPresentationProvider, sharing_service_1.DashboardSharingService] })
24
25
  ], LiveDashboardPlugin);
@@ -0,0 +1,4 @@
1
+ import type { SkillSlashCommand, TPromptWorkflow } from '@xpert-ai/contracts';
2
+ export declare const dashboardPromptWorkflows: SkillSlashCommand[];
3
+ /** Separate names keep the host's middleware-first merge from hiding these editable shortcuts. */
4
+ export declare const dashboardWorkspacePrompts: TPromptWorkflow[];