@linkdesk/contracts 0.1.54 → 0.1.56

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 +115 -17
  2. package/package.json +25 -25
package/linkdesk.d.ts CHANGED
@@ -1554,13 +1554,6 @@ export interface MenuItemDescriptor {
1554
1554
  onSelect?: () => void;
1555
1555
  children?: Array<string | MenuItemDescriptor>;
1556
1556
  }
1557
- /**
1558
- * Dialog wire contract—
1559
- *
1560
- * Once defined twice: linkdesk-api.ts (plugin side, ) and an inline struct in dialog-handlers.ts
1561
- * manually aligned—changing one side silently broke the other. This module defines it in one place:
1562
- * plugin API re-export (keeping the existing import path) + preload + main process, three ends import type.
1563
- */
1564
1557
  export interface DialogOpenOptions {
1565
1558
  title?: string;
1566
1559
  /** true = pick a directory; defaults to picking a file */
@@ -2548,15 +2541,29 @@ export interface PluginInstallRequest {
2548
2541
  display: PluginInstallDisplay;
2549
2542
  /** update 模式:显式放行降级(版本下拉选旧版)——仍会走确认(policy 出 `downgrade`) */
2550
2543
  allowOlder?: boolean;
2551
- /** 缺依赖解析目录(同 PluginInstallRequestOpts.catalogUrl 语义)——壳在同一 job 内自动装依赖用 */
2544
+ /** 缺依赖解析目录(同 PluginInstallRequestOpts.catalogUrl 语义)——壳在同一 job 内自动装依赖用。
2545
+ * 🔴 市场**必须**带上(旧链靠它做依赖自动安装,漏了 = 依赖装不上、插件 parked)。 */
2552
2546
  catalogUrl?: string;
2547
+ /**
2548
+ * 发起方(2026-11-25 线 1 拍板:AI 发起的安装必须可辨认)——缺省 `user`。
2549
+ * 进 `plan.items[].request` ⇒ 壳默认卡 / 市场自绘卡 / 命令面**三处同源**都能显示"发起方:AI"。
2550
+ * ⛔ 不由渲染体自己猜(它拿不到"谁发起的"这个事实)。
2551
+ */
2552
+ requestedBy?: "user" | "ai";
2553
+ /** AI 发起时的一句话理由(仅 `requestedBy === "ai"` 有意义;壳按 500 字硬截断,⛔ 不信任调用方长度)。 */
2554
+ aiReason?: string;
2555
+ /** 目录条目声明的最低壳版本——壳**自己**再判一次(spec §四:不满足直接拦,不进入确认)。
2556
+ * 市场照抄目录条目即可;不带 = 不判(旧目录条目没有该字段)。 */
2557
+ minAppVersion?: string;
2553
2558
  }
2554
2559
  /** `requestInstall` 回执——`confirmed:false` + `cancelled:false` = 被拒(`reason` 说原因) */
2555
2560
  export interface PluginInstallConfirmResult {
2556
2561
  confirmed: boolean;
2562
+ /** 🔴 执行结果(confirmed 只表示「用户同意了」):false = 已确认但没装成。
2563
+ * 市场必须据此报错——实机(2026-11-24):明文 http 被拒后**一点提示都没有**,就是因为这里被吞了。 */
2564
+ ok?: boolean;
2565
+ error?: string;
2557
2566
  cancelled?: boolean;
2558
- /** 确认后壳已入队;进度/终态走 `plugin:installJobs` 全量快照 */
2559
- jobId?: string;
2560
2567
  /** `invalid` = 请求本身不成立(同版本重装 / 未放行降级 / 重复请求) */
2561
2568
  reason?: "user-cancelled" | "source-changed" | "integrity-failed" | "min-app" | "no-token" | "up-to-date" | "invalid";
2562
2569
  }
@@ -2566,14 +2573,12 @@ export interface PluginConfirmRejected {
2566
2573
  reason: "min-app" | "integrity-failed" | "invalid";
2567
2574
  message?: string;
2568
2575
  }
2569
- /** `requestUpdateBatch` 回执——`confirmed:false` = **整批取消**(0 个入队,spec §五.4) */
2576
+ /** `requestUpdateBatch` 回执——`confirmed:false` = **整批取消**(0 个执行,spec §五.4)。
2577
+ * 🔴 壳不建 job 表:这里的 `confirmed` 只回答「用户同不同意」,逐项成败走完成通知(轻 toast + 铃铛面板)。 */
2570
2578
  export interface PluginUpdateBatchResult {
2571
2579
  confirmed: boolean;
2572
2580
  cancelled?: boolean;
2573
- /** 确认后 ask + silent 全部入队(按请求顺序);`batchId` 是壳侧汇总键,**不是 job 表字段** */
2574
- jobIds: string[];
2575
- batchId?: string;
2576
- /** 被直接拒的项(不弹卡、不进 jobIds) */
2581
+ /** 被直接拒的项(不弹卡、不执行) */
2577
2582
  rejected?: PluginConfirmRejected[];
2578
2583
  }
2579
2584
  /** 需要确认的原因——**封闭集合**;渲染体只按它选文案,⛔ 不自推(两条独立开关见 PluginUpdatePolicy) */
@@ -2621,6 +2626,90 @@ export interface PluginConfirmPlan {
2621
2626
  silent: number;
2622
2627
  };
2623
2628
  }
2629
+ /**
2630
+ * 确认卡**文案包**——壳 t() 解析后随载荷整体下发(`{{x}}` 为占位符)。
2631
+ *
2632
+ * 🔴 为什么在契约里而不在 UI 包里:文案是**壳的单一来源**(硬约束 2),而消费者有两个——
2633
+ * 壳默认卡(D8)与**市场自绘卡**(D8′)。市场拿不到壳的 `t()`,只能吃壳下发好的字符串;
2634
+ * 载荷要过结构化克隆(IPC),所以是字符串而不是函数。
2635
+ */
2636
+ export interface PluginInstallConfirmLabels {
2637
+ /* ── 单项安装/更新卡 ── */
2638
+ installTitle: string; // 安装 {{name}}
2639
+ subFirst: string;
2640
+ subSourceChanged: string;
2641
+ subDowngrade: string;
2642
+ subOfficial: string;
2643
+ subUpdate: string;
2644
+ noteFirst: string;
2645
+ noteSourceChanged: string;
2646
+ noteDowngrade: string;
2647
+ kvPlugin: string;
2648
+ kvPublisher: string;
2649
+ kvSource: string;
2650
+ kvVersion: string;
2651
+ kvSize: string;
2652
+ kvIntegrity: string;
2653
+ kvOldSource: string;
2654
+ kvNewSource: string;
2655
+ integrityToVerify: string; // sha256 {{hash}} · 下载后校验
2656
+ integrityMissing: string;
2657
+ warnSourceChanged: string;
2658
+ rememberSource: string;
2659
+ actionInstall: string;
2660
+ actionUpdate: string;
2661
+ actionUpdateAnyway: string;
2662
+ actionCancel: string;
2663
+ unknownPublisher: string;
2664
+ unknownSize: string;
2665
+ /* ── 批量卡 ── */
2666
+ batchTitle: string;
2667
+ batchSub: string;
2668
+ statTotal: string;
2669
+ statAsk: string;
2670
+ statSilent: string;
2671
+ groupAsk: string; // {{n}} 个需要确认
2672
+ groupSilent: string; // {{n}} 个免问
2673
+ groupSilentSummary: string; // {{label}} {{n}} 个
2674
+ badgeOfficial: string;
2675
+ badgeThird: string;
2676
+ silentLine: string; // {{summary}}按设置免问,将随本批一起执行。
2677
+ silentAction: string; // 改为逐个确认
2678
+ rememberOfficial: string;
2679
+ batchEmpty: string;
2680
+ batchNote: string;
2681
+ actionConfirmBatch: string; // 确认更新 {{n}} 个
2682
+ actionRunBatch: string; // 直接更新 {{n}} 个
2683
+ actionCancelBatch: string;
2684
+ /* ── 发起方(2026-11-25):AI 发起的安装/更新要能一眼看出来 ── */
2685
+ originLabel: string; // 发起方
2686
+ originAI: string; // AI(专名不译)
2687
+ aiNoteTitle: string; // AI 说明
2688
+ aiNoteHint: string; // 由发起请求的 AI 提供
2689
+ aiNoteMore: string; // 展开
2690
+ aiNoteLess: string; // 收起
2691
+ }
2692
+ /**
2693
+ * 确认卡的**可渲染载荷**——壳默认卡(D8)与市场自绘卡(D8′)吃的是**同一份**。
2694
+ *
2695
+ * 分工:`plan` 是壳算的事实(来源/版本/哈希/风险),`labels` 是壳解析的文案,`policy` 决定勾选框初值。
2696
+ * ⛔ 渲染体不许自己拼来源/版本/哈希,也不许自己判"要不要问"——只画这份。
2697
+ * ⛔ 载荷**不含令牌**(token 永不过 IPC / 不进契约)。
2698
+ */
2699
+ export interface PluginConfirmViewPayload {
2700
+ kind: "install" | "batch";
2701
+ labels: PluginInstallConfirmLabels;
2702
+ plan: PluginConfirmPlan;
2703
+ /** 安装卡的当前版本(null/缺省 = 首装) */
2704
+ fromVersion?: string | null;
2705
+ /** 当前策略快照——批量卡「以后官方源不再询问」勾选的初值(⛔ 渲染体自己去读配置) */
2706
+ policy?: {
2707
+ silentOfficial: boolean;
2708
+ silentTrustedSources: boolean;
2709
+ };
2710
+ /** 本批原始请求——批内改设置后就地重算要全量(`plan.silent` 是摘要行,装不下下载地址) */
2711
+ reqs?: PluginInstallRequest[];
2712
+ }
2624
2713
  /**
2625
2714
  * `prepareInstall` / `prepareUpdateBatch` 的产物——**两步确认的第一跳**(2026-11-24 D1′)。
2626
2715
  * 壳只算计划、⛔ 不弹任何 UI、零副作用;`planId` 短 TTL(5 分钟)且绑定请求指纹。
@@ -2631,14 +2720,23 @@ export interface PluginInstallPrepared {
2631
2720
  planId: string;
2632
2721
  /** 壳算出的确认计划(来源/发布者/版本/哈希/风险唯一来源,⛔ 市场不许自造) */
2633
2722
  plan: PluginConfirmPlan;
2723
+ /**
2724
+ * 直接可渲染的载荷(labels + plan + policy + reqs)——市场自绘卡**原样喂**给
2725
+ * `@linkdesk/ui` 的 `buildInstallVM` / `buildBatchVM` 即可,⛔ 不用自己拼文案或事实。
2726
+ * 与壳默认卡推给渲染槽的 payload 是**同一份**(`renderer.ts` 构造),此处提前给,市场不必等弹窗。
2727
+ */
2728
+ view: PluginConfirmViewPayload;
2634
2729
  /** 句柄到期时刻(ms)——到点后 commit 返回 `expired` */
2635
2730
  expiresAt: number;
2636
2731
  }
2637
- /** `commitInstall` 回执——`confirmed:true` = 用户已确认且已交执行(成败看 job 表) */
2732
+ /** `commitInstall` 回执——`confirmed:true` = 用户已确认且已交执行体(成败看 `ok`) */
2638
2733
  export interface PluginInstallCommitResult {
2639
2734
  confirmed: boolean;
2735
+ /** 🔴 **执行结果**(confirmed 只表示"用户同意了"):false = 已确认但没装成(下载/校验/落盘失败)。
2736
+ * 市场必须据此报错,⛔ 不许把 confirmed 当成"装好了"(实机:确认后失败的更新被报成成功)。 */
2737
+ ok?: boolean;
2738
+ error?: string;
2640
2739
  cancelled?: boolean;
2641
- jobId?: string;
2642
2740
  /** `unknown-plan` = planId 不存在/已用过/已过期(统一一个词,⛔ 不细分) */
2643
2741
  reason?: "unknown-plan" | "rejected" | "user-cancelled" | "no-token";
2644
2742
  }
package/package.json CHANGED
@@ -1,25 +1,25 @@
1
- {
2
- "name": "@linkdesk/contracts",
3
- "version": "0.1.54",
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.56",
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
+ }