@linkdesk/contracts 0.1.53 → 0.1.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/linkdesk.d.ts +54 -0
  2. package/package.json +1 -1
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
  }
@@ -2602,6 +2621,27 @@ export interface PluginConfirmPlan {
2602
2621
  silent: number;
2603
2622
  };
2604
2623
  }
2624
+ /**
2625
+ * `prepareInstall` / `prepareUpdateBatch` 的产物——**两步确认的第一跳**(2026-11-24 D1′)。
2626
+ * 壳只算计划、⛔ 不弹任何 UI、零副作用;`planId` 短 TTL(5 分钟)且绑定请求指纹。
2627
+ * 市场拿 `plan` 自己画卡(可用共享件、可完全自绘);用户点确认后再调 `commitInstall(planId)`。
2628
+ */
2629
+ export interface PluginInstallPrepared {
2630
+ /** 一次性句柄——`commitInstall(planId)` 才签令牌并执行 */
2631
+ planId: string;
2632
+ /** 壳算出的确认计划(来源/发布者/版本/哈希/风险唯一来源,⛔ 市场不许自造) */
2633
+ plan: PluginConfirmPlan;
2634
+ /** 句柄到期时刻(ms)——到点后 commit 返回 `expired` */
2635
+ expiresAt: number;
2636
+ }
2637
+ /** `commitInstall` 回执——`confirmed:true` = 用户已确认且已交执行(成败看 job 表) */
2638
+ export interface PluginInstallCommitResult {
2639
+ confirmed: boolean;
2640
+ cancelled?: boolean;
2641
+ jobId?: string;
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@linkdesk/contracts",
3
- "version": "0.1.53",
3
+ "version": "0.1.54",
4
4
  "description": "LinkDesk 插件契约类型——window.linkdesk.* 全量类型定义(E5.8 契约生成产物)。第三方插件作者唯一合法类型消费路径。",
5
5
  "type": "module",
6
6
  "types": "./linkdesk.d.ts",