@linkdesk/contracts 0.1.53 → 0.1.55
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/linkdesk.d.ts +69 -15
- package/package.json +25 -25
package/linkdesk.d.ts
CHANGED
|
@@ -29,6 +29,11 @@ export interface AiPolicyOptionDto {
|
|
|
29
29
|
/** 一句人话(i18n key)——与设置声明 enumDescriptions 同文 */
|
|
30
30
|
description: string;
|
|
31
31
|
}
|
|
32
|
+
/** 档位块下方的能力摘要(名称 + 当前判定;名称是 i18n key;随档位变) */
|
|
33
|
+
export interface AiPolicyCapabilityDto {
|
|
34
|
+
label: string;
|
|
35
|
+
decision: AiPolicyDecisionDto;
|
|
36
|
+
}
|
|
32
37
|
/** 风险表一行(`decision` = **当前档位下**的判定,随档变化) */
|
|
33
38
|
export interface AiPolicyRiskRowDto {
|
|
34
39
|
id: string;
|
|
@@ -40,6 +45,15 @@ export interface AiPolicyRiskRowDto {
|
|
|
40
45
|
/** 为什么这样判(i18n key) */
|
|
41
46
|
why?: string;
|
|
42
47
|
}
|
|
48
|
+
/** 敏感能力一行(规则是固定语义;`decision` 仍按当前档位给) */
|
|
49
|
+
export interface AiPolicySensitiveRowDto {
|
|
50
|
+
id: string;
|
|
51
|
+
/** 能力名(i18n key) */
|
|
52
|
+
label: string;
|
|
53
|
+
/** 规则说明(i18n key) */
|
|
54
|
+
rule: string;
|
|
55
|
+
decision: AiPolicyDecisionDto;
|
|
56
|
+
}
|
|
43
57
|
export interface AiPolicyStateDto {
|
|
44
58
|
mode: AiPolicyModeDto;
|
|
45
59
|
/** true = 配置损坏/值非法,已按 fail-closed 档(ask)处理 */
|
|
@@ -51,7 +65,12 @@ export interface AiPolicyStateDto {
|
|
|
51
65
|
/** 四档 × 四级判定(唯一来源 = 主进程 `decide`,⛔ 不二次实现) */
|
|
52
66
|
matrix: AiPolicyMatrixDto;
|
|
53
67
|
options: AiPolicyOptionDto[];
|
|
68
|
+
/** 档位块下方的摘要(4 条;随档位变) */
|
|
69
|
+
capabilities: AiPolicyCapabilityDto[];
|
|
70
|
+
/** 操作清单(表格行) */
|
|
54
71
|
riskTable: AiPolicyRiskRowDto[];
|
|
72
|
+
/** 敏感能力(表格行) */
|
|
73
|
+
sensitive: AiPolicySensitiveRowDto[];
|
|
55
74
|
/** `userOnly` 命令 id(AI 永远不可调)——由壳命令补,主进程返回空数组 */
|
|
56
75
|
protectedCommands: string[];
|
|
57
76
|
}
|
|
@@ -1535,13 +1554,6 @@ export interface MenuItemDescriptor {
|
|
|
1535
1554
|
onSelect?: () => void;
|
|
1536
1555
|
children?: Array<string | MenuItemDescriptor>;
|
|
1537
1556
|
}
|
|
1538
|
-
/**
|
|
1539
|
-
* Dialog wire contract—
|
|
1540
|
-
*
|
|
1541
|
-
* Once defined twice: linkdesk-api.ts (plugin side, ) and an inline struct in dialog-handlers.ts
|
|
1542
|
-
* manually aligned—changing one side silently broke the other. This module defines it in one place:
|
|
1543
|
-
* plugin API re-export (keeping the existing import path) + preload + main process, three ends import type.
|
|
1544
|
-
*/
|
|
1545
1557
|
export interface DialogOpenOptions {
|
|
1546
1558
|
title?: string;
|
|
1547
1559
|
/** true = pick a directory; defaults to picking a file */
|
|
@@ -2529,15 +2541,21 @@ export interface PluginInstallRequest {
|
|
|
2529
2541
|
display: PluginInstallDisplay;
|
|
2530
2542
|
/** update 模式:显式放行降级(版本下拉选旧版)——仍会走确认(policy 出 `downgrade`) */
|
|
2531
2543
|
allowOlder?: boolean;
|
|
2532
|
-
/** 缺依赖解析目录(同 PluginInstallRequestOpts.catalogUrl 语义)——壳在同一 job
|
|
2544
|
+
/** 缺依赖解析目录(同 PluginInstallRequestOpts.catalogUrl 语义)——壳在同一 job 内自动装依赖用。
|
|
2545
|
+
* 🔴 市场**必须**带上(旧链靠它做依赖自动安装,漏了 = 依赖装不上、插件 parked)。 */
|
|
2533
2546
|
catalogUrl?: string;
|
|
2547
|
+
/** 目录条目声明的最低壳版本——壳**自己**再判一次(spec §四:不满足直接拦,不进入确认)。
|
|
2548
|
+
* 市场照抄目录条目即可;不带 = 不判(旧目录条目没有该字段)。 */
|
|
2549
|
+
minAppVersion?: string;
|
|
2534
2550
|
}
|
|
2535
2551
|
/** `requestInstall` 回执——`confirmed:false` + `cancelled:false` = 被拒(`reason` 说原因) */
|
|
2536
2552
|
export interface PluginInstallConfirmResult {
|
|
2537
2553
|
confirmed: boolean;
|
|
2554
|
+
/** 🔴 执行结果(confirmed 只表示「用户同意了」):false = 已确认但没装成。
|
|
2555
|
+
* 市场必须据此报错——实机(2026-11-24):明文 http 被拒后**一点提示都没有**,就是因为这里被吞了。 */
|
|
2556
|
+
ok?: boolean;
|
|
2557
|
+
error?: string;
|
|
2538
2558
|
cancelled?: boolean;
|
|
2539
|
-
/** 确认后壳已入队;进度/终态走 `plugin:installJobs` 全量快照 */
|
|
2540
|
-
jobId?: string;
|
|
2541
2559
|
/** `invalid` = 请求本身不成立(同版本重装 / 未放行降级 / 重复请求) */
|
|
2542
2560
|
reason?: "user-cancelled" | "source-changed" | "integrity-failed" | "min-app" | "no-token" | "up-to-date" | "invalid";
|
|
2543
2561
|
}
|
|
@@ -2547,14 +2565,12 @@ export interface PluginConfirmRejected {
|
|
|
2547
2565
|
reason: "min-app" | "integrity-failed" | "invalid";
|
|
2548
2566
|
message?: string;
|
|
2549
2567
|
}
|
|
2550
|
-
/** `requestUpdateBatch` 回执——`confirmed:false` = **整批取消**(0
|
|
2568
|
+
/** `requestUpdateBatch` 回执——`confirmed:false` = **整批取消**(0 个执行,spec §五.4)。
|
|
2569
|
+
* 🔴 壳不建 job 表:这里的 `confirmed` 只回答「用户同不同意」,逐项成败走完成通知(轻 toast + 铃铛面板)。 */
|
|
2551
2570
|
export interface PluginUpdateBatchResult {
|
|
2552
2571
|
confirmed: boolean;
|
|
2553
2572
|
cancelled?: boolean;
|
|
2554
|
-
/**
|
|
2555
|
-
jobIds: string[];
|
|
2556
|
-
batchId?: string;
|
|
2557
|
-
/** 被直接拒的项(不弹卡、不进 jobIds) */
|
|
2573
|
+
/** 被直接拒的项(不弹卡、不执行) */
|
|
2558
2574
|
rejected?: PluginConfirmRejected[];
|
|
2559
2575
|
}
|
|
2560
2576
|
/** 需要确认的原因——**封闭集合**;渲染体只按它选文案,⛔ 不自推(两条独立开关见 PluginUpdatePolicy) */
|
|
@@ -2602,6 +2618,30 @@ export interface PluginConfirmPlan {
|
|
|
2602
2618
|
silent: number;
|
|
2603
2619
|
};
|
|
2604
2620
|
}
|
|
2621
|
+
/**
|
|
2622
|
+
* `prepareInstall` / `prepareUpdateBatch` 的产物——**两步确认的第一跳**(2026-11-24 D1′)。
|
|
2623
|
+
* 壳只算计划、⛔ 不弹任何 UI、零副作用;`planId` 短 TTL(5 分钟)且绑定请求指纹。
|
|
2624
|
+
* 市场拿 `plan` 自己画卡(可用共享件、可完全自绘);用户点确认后再调 `commitInstall(planId)`。
|
|
2625
|
+
*/
|
|
2626
|
+
export interface PluginInstallPrepared {
|
|
2627
|
+
/** 一次性句柄——`commitInstall(planId)` 才签令牌并执行 */
|
|
2628
|
+
planId: string;
|
|
2629
|
+
/** 壳算出的确认计划(来源/发布者/版本/哈希/风险唯一来源,⛔ 市场不许自造) */
|
|
2630
|
+
plan: PluginConfirmPlan;
|
|
2631
|
+
/** 句柄到期时刻(ms)——到点后 commit 返回 `expired` */
|
|
2632
|
+
expiresAt: number;
|
|
2633
|
+
}
|
|
2634
|
+
/** `commitInstall` 回执——`confirmed:true` = 用户已确认且已交执行体(成败看 `ok`) */
|
|
2635
|
+
export interface PluginInstallCommitResult {
|
|
2636
|
+
confirmed: boolean;
|
|
2637
|
+
/** 🔴 **执行结果**(confirmed 只表示"用户同意了"):false = 已确认但没装成(下载/校验/落盘失败)。
|
|
2638
|
+
* 市场必须据此报错,⛔ 不许把 confirmed 当成"装好了"(实机:确认后失败的更新被报成成功)。 */
|
|
2639
|
+
ok?: boolean;
|
|
2640
|
+
error?: string;
|
|
2641
|
+
cancelled?: boolean;
|
|
2642
|
+
/** `unknown-plan` = planId 不存在/已用过/已过期(统一一个词,⛔ 不细分) */
|
|
2643
|
+
reason?: "unknown-plan" | "rejected" | "user-cancelled" | "no-token";
|
|
2644
|
+
}
|
|
2605
2645
|
/** 两条**独立**开关(D5 拍板:正交、可同时开;首装/来源变更/降级不可关,见 spec §3.5) */
|
|
2606
2646
|
export interface PluginUpdatePolicy {
|
|
2607
2647
|
/** 官方目录的**同源更新**不逐项询问(默认开) */
|
|
@@ -2812,6 +2852,9 @@ export interface PluginsAPI {
|
|
|
2812
2852
|
* a jobId → AbortController registry and does not interpret semantics. Returns false = that job currently has no in-flight download
|
|
2813
2853
|
* (already finished / not started / not in the download stage) — callers should read this as "cancel accepted, wait for the terminal state", not as a failure. */
|
|
2814
2854
|
packageCancel?(jobId: string): Promise<boolean>;
|
|
2855
|
+
/** P1(D9′ 零插件路径):只读拉取目录原文(HTTPS-only;主进程唯一网络出口)——命令面 `plugins.listCatalog` 用。
|
|
2856
|
+
* ⛔ 不解析、不缓存:解析归调用方(壳命令),主进程只当管道。 */
|
|
2857
|
+
packageReadCatalog?(catalogUrl: string): Promise<string>;
|
|
2815
2858
|
/** (stage B): the main-process real network stage — fetches marketplace.json → version comparison (does not touch the ledger — current is passed in by the shell). Prereleases are ignored by default. */
|
|
2816
2859
|
packageUpdateCheck?(pluginId: string, catalogUrl: string, currentVersion?: string): Promise<PluginUpdateCheckResult>;
|
|
2817
2860
|
/** b/c (stage B): the main-process real download+extract stage — downloads to tmp → extracts to {userData}/tmp/.stage-<id> (id consistency + version direction validation; the old directory is untouched).
|
|
@@ -2840,6 +2883,17 @@ export interface PluginsAPI {
|
|
|
2840
2883
|
requestInstall?(req: PluginInstallRequest): Promise<PluginInstallConfirmResult>;
|
|
2841
2884
|
/** 批量更新 —— 只提交结构化请求;谁要确认由壳算(`ask` 为空则**不弹卡**直接全入队) */
|
|
2842
2885
|
requestUpdateBatch?(reqs: PluginInstallRequest[]): Promise<PluginUpdateBatchResult>;
|
|
2886
|
+
/** 两步确认 · 第一跳:只算计划,⛔ 不弹 UI、零副作用(2026-11-24 D1′:UI 归市场) */
|
|
2887
|
+
prepareInstall?(req: PluginInstallRequest): Promise<PluginInstallPrepared>;
|
|
2888
|
+
/** 两步确认 · 批量第一跳(一张计划的 ask/silent/分组全在返回值里) */
|
|
2889
|
+
prepareUpdateBatch?(reqs: PluginInstallRequest[]): Promise<PluginInstallPrepared>;
|
|
2890
|
+
/** 两步确认 · 第二跳:用户已在自己画的卡上点确认 ⇒ 壳签一次性令牌并执行。
|
|
2891
|
+
* `confirmed:false` 等价于 discard(不执行)。不调这一步就装不上——这是"必须调 API"的硬形态。 */
|
|
2892
|
+
commitInstall?(planId: string, opts?: {
|
|
2893
|
+
confirmed?: boolean;
|
|
2894
|
+
}): Promise<PluginInstallCommitResult>;
|
|
2895
|
+
/** 释放句柄(用户取消 / 页面关闭)——不执行、不签票 */
|
|
2896
|
+
discardInstall?(planId: string): Promise<void>;
|
|
2843
2897
|
/** 只读预览:按**当前**设置算一遍计划(不改状态、不入队)。确认卡内改设置后就地重算;
|
|
2844
2898
|
* AI 也可先用它看「这次会问哪几个」。`forceAsk` = 把免问项也展开成需确认(本批临时,不改设置) */
|
|
2845
2899
|
previewUpdatePlan?(reqs: PluginInstallRequest[], opts?: {
|
package/package.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@linkdesk/contracts",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "LinkDesk 插件契约类型——window.linkdesk.* 全量类型定义(E5.8 契约生成产物)。第三方插件作者唯一合法类型消费路径。",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"types": "./linkdesk.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"linkdesk.d.ts"
|
|
9
|
-
],
|
|
10
|
-
"sideEffects": false,
|
|
11
|
-
"publishConfig": {
|
|
12
|
-
"access": "public"
|
|
13
|
-
},
|
|
14
|
-
"scripts": {
|
|
15
|
-
"prepublishOnly": "node ../scripts/prepublish-auth-preflight.mjs --npm",
|
|
16
|
-
"prepack": "node ../scripts/generate-contract.mjs"
|
|
17
|
-
},
|
|
18
|
-
"keywords": [
|
|
19
|
-
"linkdesk",
|
|
20
|
-
"plugin",
|
|
21
|
-
"types",
|
|
22
|
-
"contract"
|
|
23
|
-
],
|
|
24
|
-
"license": "MIT"
|
|
25
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@linkdesk/contracts",
|
|
3
|
+
"version": "0.1.55",
|
|
4
|
+
"description": "LinkDesk 插件契约类型——window.linkdesk.* 全量类型定义(E5.8 契约生成产物)。第三方插件作者唯一合法类型消费路径。",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"types": "./linkdesk.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"linkdesk.d.ts"
|
|
9
|
+
],
|
|
10
|
+
"sideEffects": false,
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"prepublishOnly": "node ../scripts/prepublish-auth-preflight.mjs --npm",
|
|
16
|
+
"prepack": "node ../scripts/generate-contract.mjs"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"linkdesk",
|
|
20
|
+
"plugin",
|
|
21
|
+
"types",
|
|
22
|
+
"contract"
|
|
23
|
+
],
|
|
24
|
+
"license": "MIT"
|
|
25
|
+
}
|