@linkdesk/contracts 0.1.51 → 0.1.53

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 +326 -14
  2. package/package.json +25 -25
package/linkdesk.d.ts CHANGED
@@ -13,6 +13,57 @@
13
13
  */
14
14
 
15
15
  // ── Contract types ──
16
+ /** 四档 id(与主进程 `PolicyMode` 同值;跨进程边界用字符串) */
17
+ export type AiPolicyModeDto = "read" | "ask" | "auto" | "full";
18
+ /** 风险级(与主进程 `Risk` 同值) */
19
+ export type AiPolicyRiskDto = "R0" | "R1" | "R2" | "R3";
20
+ /** 判定(与主进程 `Decision` 同值) */
21
+ export type AiPolicyDecisionDto = "allow" | "ask" | "deny";
22
+ /** 四档 × 四级的全矩阵(四段控件给每段算摘要用——⛔ 渲染方不自己判,只格式化) */
23
+ export type AiPolicyMatrixDto = Record<AiPolicyModeDto, Record<AiPolicyRiskDto, AiPolicyDecisionDto>>;
24
+ /** 一段可选项(四段控件每段 = 一条) */
25
+ export interface AiPolicyOptionDto {
26
+ value: AiPolicyModeDto;
27
+ /** 段标题(i18n key) */
28
+ label: string;
29
+ /** 一句人话(i18n key)——与设置声明 enumDescriptions 同文 */
30
+ description: string;
31
+ }
32
+ /** 风险表一行(`decision` = **当前档位下**的判定,随档变化) */
33
+ export interface AiPolicyRiskRowDto {
34
+ id: string;
35
+ kind: "op" | "command";
36
+ risk: AiPolicyRiskDto;
37
+ decision: AiPolicyDecisionDto;
38
+ /** 是什么动作(i18n key;缺省 = 只有 id) */
39
+ what?: string;
40
+ /** 为什么这样判(i18n key) */
41
+ why?: string;
42
+ }
43
+ export interface AiPolicyStateDto {
44
+ mode: AiPolicyModeDto;
45
+ /** true = 配置损坏/值非法,已按 fail-closed 档(ask)处理 */
46
+ degraded: boolean;
47
+ /** 读数时刻(ms) */
48
+ effectiveAt: number;
49
+ /** AI 通道是否开着(`ai.mcp.enabled` / `ai.cli.enabled` 任一 true)——徽标据此显示/隐藏 */
50
+ channelsEnabled: boolean;
51
+ /** 四档 × 四级判定(唯一来源 = 主进程 `decide`,⛔ 不二次实现) */
52
+ matrix: AiPolicyMatrixDto;
53
+ options: AiPolicyOptionDto[];
54
+ riskTable: AiPolicyRiskRowDto[];
55
+ /** `userOnly` 命令 id(AI 永远不可调)——由壳命令补,主进程返回空数组 */
56
+ protectedCommands: string[];
57
+ }
58
+ export interface AiPolicyAPI {
59
+ /** AI 权限档位读面——只读:getState(快照)+ onChange(变更后重读并回调)。写档位不在此面 */
60
+ aiPolicy: {
61
+ /** 当前策略快照(档位 / 四档矩阵 / 风险表 / 受保护命令) */
62
+ getState(): Promise<AiPolicyStateDto>;
63
+ /** 档位变更订阅——回调参数是**重新读过**的快照(不是配置值);返回退订函数 */
64
+ onChange(cb: (state: AiPolicyStateDto) => void): () => void;
65
+ };
66
+ }
16
67
  /**
17
68
  * Command parameter descriptor — commands **carry their own parameter descriptions**, returned together with `commands.getCommands()`.
18
69
  * Positional semantics: `params[i]` maps **one-to-one by position** to handler arguments (`name` follows the handler's argument name, ⛔ do not invent another) —
@@ -39,6 +90,17 @@ export interface LinkDeskCommand {
39
90
  description?: string;
40
91
  /** parameter structure (positionally mapped to handler arguments). Optional, purely additive; omit for commands without parameters. */
41
92
  params?: LinkDeskCommandParam[];
93
+ /**
94
+ * AI permission tier (2026-11-24 · AI-safety policy, L2): `true` = user-only command —
95
+ * the AI gateway (`exec` / `notifyAction`) always answers `EPROTECTED`. Omitted = AI-callable
96
+ * (still subject to the policy tier). Purely additive: existing plugins keep current behaviour.
97
+ */
98
+ userOnly?: boolean;
99
+ /**
100
+ * Declared risk level (2026-11-24 · AI permission tiers) — mirrors `contributes.commands[].risk`.
101
+ * Merge order: host built-in table > this declaration > fallback R1. Purely additive.
102
+ */
103
+ risk?: "R0" | "R1" | "R2" | "R3";
42
104
  }
43
105
  /** Recipe contribution domains—shared by theme metadata domains (mix-and-match source filtering) and the theme:changed payload (domain-level fine-grained refresh) (06 §2/§6.2).
44
106
  * Five domains: colors (colorways always contribute) + the four appearance style domains (radius/glass/font/background).
@@ -98,6 +160,25 @@ export interface LinkDeskConfigProperty {
98
160
  group?: string;
99
161
  /** numeric unit — value-label unit for uiHint "slider" ("×" / "px"; empty = bare number) */
100
162
  unit?: string;
163
+ /** 2026-11-24 semantic ownership: host asset domain registry key (e.g. "appearance") — the domain source of host asset actions.
164
+ * The UI forwards this value verbatim to `appearance.pickImage`; ⛔ it never holds a domain literal (replace the UI plugin and the start directory stays). */
165
+ assetDomain?: string;
166
+ /** 2026-11-24: asset target slot inside the domain (e.g. "app"/"zone") — same directory/filters, only decides which config key the UI writes back. */
167
+ pickTarget?: string;
168
+ /** 2026-11-24: conditional description — when `{key,value}` holds, this text replaces `description`.
169
+ * Example: `app.themeColor` under `app.appearanceMode="custom"` shows the colors-domain source wording. The UI ⛔ no longer special-cases the key. */
170
+ descriptionWhen?: {
171
+ key: string;
172
+ value: unknown;
173
+ description: string;
174
+ };
175
+ /** 2026-11-24: source-badge activation condition for `sourceKey` (e.g. appearanceMode="custom"). Without it the slot derives no "mix" source; the UI ⛔ no longer holds the `"custom"` literal. */
176
+ sourceActiveWhen?: {
177
+ key: string;
178
+ value: unknown;
179
+ };
180
+ /** 2026-11-24: the `sourceKey` sentinel meaning "follow theme" (e.g. "followTheme") — the second condition for a mix badge. The UI reads the declaration, ⛔ not a sentinel literal. */
181
+ sourceFollowValue?: string;
101
182
  }
102
183
  /** Config schema — key → property definition (index signature kept for existing consumers) */
103
184
  export interface LinkDeskConfigSchema {
@@ -269,6 +350,8 @@ export interface ColorwayMeta {
269
350
  accent: string;
270
351
  bgWindow: string;
271
352
  };
353
+ /** 派生极性(2026-11-24)——该配色生效 token 算出的 light/dark;跨明暗标签读它,不读配方声明 */
354
+ polarity: "light" | "dark";
272
355
  }
273
356
  /** recipe metadata — returned by theme.listRecipes() (all available recipes + colorways + preview colors, spec 06 §2).
274
357
  * domains = which domains the recipe contributes (basis for mash-up source filtering, spec 10 §2); type = light/dark category. */
@@ -276,6 +359,8 @@ export interface RecipeMeta {
276
359
  id: string;
277
360
  name: string;
278
361
  type: "light" | "dark";
362
+ /** 派生极性(首配色)——`type` 为作者 hint;UI 分组/标签一律读它 */
363
+ polarity: "light" | "dark";
279
364
  colorways: ColorwayMeta[];
280
365
  domains: ThemeDomain[];
281
366
  }
@@ -284,6 +369,22 @@ export interface LinkDeskLanguage {
284
369
  label: string;
285
370
  pluginId: string;
286
371
  }
372
+ /** Options for `appearance.pickImage` — the caller forwards the schema-declared `assetDomain` / `pickTarget` verbatim (2026-11-24 semantic ownership).
373
+ * ⛔ No path, no directory token, no domain literal: start directory / filters / copy-into-store are host-owned. */
374
+ export interface AppearancePickOptions {
375
+ /** Host asset domain registry key (e.g. "appearance") — declared by the config schema (`assetDomain`) */
376
+ domain: string;
377
+ /** Target slot inside the domain (e.g. "app" / "zone") — declared by the config schema (`pickTarget`); shares the domain's directory and filters */
378
+ target: string;
379
+ }
380
+ /** Result of `appearance.pickImage` — a canceled dialog is `{picked:false}`, not an error. */
381
+ export type AppearancePickResult = {
382
+ picked: true;
383
+ url: string;
384
+ name: string;
385
+ } | {
386
+ picked: false;
387
+ };
287
388
  /** Theme + language + appearance asset namespace surfaces — modeled after the VS Code appearance surface */
288
389
  export interface AppearanceAPI {
289
390
  theme: {
@@ -340,6 +441,10 @@ export interface AppearanceAPI {
340
441
  /** open the appearance storage directory (userData/appearance) — the main process resolves the path and uses shell.openPath to open the file explorer
341
442
  * at the directory contents (not highlighting a single file); a missing directory is created too (opening reveals the storage location); an openPath failure throws fail-loud. */
342
443
  revealStorage(): Promise<void>;
444
+ /** 2026-11-24 semantic ownership: pick + import in one host action. The start directory, extension whitelist and copy-into-store are decided by the main process
445
+ * (`electron/services/hostAssets/appearance/defaults.ts` — the single semantic source); the caller only forwards the schema-declared `{domain,target}`.
446
+ * Returns the controlled URL (`linkdesk-userdata://…`) or `{picked:false}` on cancel. Replacing the UI plugin leaves this behavior intact. */
447
+ pickImage(options: AppearancePickOptions): Promise<AppearancePickResult>;
343
448
  };
344
449
  }
345
450
  /** Storage namespace surface — the read port and open port for the currently effective cache directory (the single resolution point is in the main process storage-handlers) */
@@ -352,6 +457,10 @@ export interface StorageAPI {
352
457
  /** The absolute path of the currently effective cache directory — settings.json's `app.storage.cacheDir` (empty/missing = the userData default location);
353
458
  * 🔴 the single resolution entry (placement contract iron rule 3: no second copy of the path is stored anywhere — take it, never copy it) */
354
459
  cacheDir(): Promise<string>;
460
+ /** 🆕 2026-11-24: on-disk path of a host storage key (e.g. `"settings"` → `<userData>/settings.json`).
461
+ * 🔴 The filename map lives in the host only (`storageFilename` — shared by the renderer StorageService and the main process);
462
+ * a UI plugin must call this instead of joining `appDataDir` with a filename literal (V6 / K10). */
463
+ getFilePath(key: string): Promise<string>;
355
464
  };
356
465
  }
357
466
  /**
@@ -1448,6 +1557,17 @@ export interface DialogOpenOptions {
1448
1557
  */
1449
1558
  defaultPathKind?: "appearance";
1450
1559
  }
1560
+ /** 2026-11-24(D12):保存对话框入参——只选**落盘路径**,壳不代写内容(写入由调用方走 filesystem)。
1561
+ * 起始目录 / 覆盖确认由 OS 原生对话框决定;插件⛔ 不再自造 `showSaveFilePicker` / `<a download>` 第二套。 */
1562
+ export interface DialogSaveOptions {
1563
+ title?: string;
1564
+ filters?: {
1565
+ name: string;
1566
+ extensions: string[];
1567
+ }[];
1568
+ /** 建议文件名(可含扩展名;OS 对话框据此给出落点) */
1569
+ defaultName?: string;
1570
+ }
1451
1571
  /** rich-content confirm dialog open params—pool plugin → shell DialogService (addressed by content view declaration).
1452
1572
  * title/message are fallbacks—when the content view fails to resolve, the shell falls back to a plain-text confirm (the dialog still shows; it does not silently die). */
1453
1573
  export interface DialogContentOpenOptions {
@@ -1548,6 +1668,11 @@ export type PoolDialogData = {
1548
1668
  renderPath: string;
1549
1669
  /** Opaque serialized payload — travels with the open parameters through shell→back to pool (structured clone); used by the content view to fetch data */
1550
1670
  payload?: unknown;
1671
+ } | {
1672
+ /** P1(D8 渲染槽):宿主内置内容视图 id(池内 `plugin-install-confirm` 注册表直挂,无需 renderPath)
1673
+ * ——壳默认渲染器用它;第三方整套替换时换 pluginId+renderPath 那一支。两支二选一。 */
1674
+ hostView: string;
1675
+ payload?: unknown;
1551
1676
  };
1552
1677
  };
1553
1678
  /**
@@ -1574,8 +1699,9 @@ export interface PoolPendingDialog {
1574
1699
  /** rich-content confirmation — content = a plugin's self-drawn view. Gives the **identity** (not renderPath: that is the pool-internal addressing key,
1575
1700
  * whereas this surface asks "what is the shell waiting for" from inside the pool); ⛔ no payload (the opaque payload can be large and is useless for reading "what is being waited on"). */
1576
1701
  content?: {
1577
- pluginId: string;
1578
- viewId: string;
1702
+ pluginId?: string;
1703
+ viewId?: string; /** P1:宿主内置默认渲染器(无 pluginId/viewId——壳自带视图) */
1704
+ hostView?: string;
1579
1705
  };
1580
1706
  }
1581
1707
  /** Title bar action buttons — rendered by the pool + sent back for the shell to re-resolve business semantics (zero pool semantics, except UI mechanical knowledge).
@@ -1730,6 +1856,10 @@ export interface UiAPI {
1730
1856
  open(opts?: DialogOpenOptions): Promise<string | null>;
1731
1857
  /** Opens the file picker — returns the user-selected path; cancel → null. Security is controlled by the main process */
1732
1858
  openFile(opts?: DialogOpenOptions): Promise<string | null>;
1859
+ /** 2026-11-24 (D12): save dialog — returns the chosen absolute path, or null on cancel.
1860
+ * One host action for "where to save" (start directory / overwrite confirm are OS-native); the plugin then writes via `filesystem.writeTextFile`.
1861
+ * ⛔ A plugin must not build a second save path (`showSaveFilePicker` / `<a download>`) — the second consumer always copies it. */
1862
+ save(opts?: DialogSaveOptions): Promise<string | null>;
1733
1863
  /** rich-content confirm — the dialog's content = a plugin self-drawn view (content view declarative addressing + opaque payload).
1734
1864
  * Dialog mechanics match confirm (centered/mask/Esc/focus lock/click-mask-to-cancel); content layout and buttons are drawn by the plugin view
1735
1865
  * (Modeled after VS Code's "the dialog is the shell's, the content is the plugin's"). title/message as fallback — if the content view fails to resolve,
@@ -1911,6 +2041,20 @@ export interface WorkspaceFolder {
1911
2041
  /** Index—the first opened folder is index=0 */
1912
2042
  index: number;
1913
2043
  }
2044
+ /**
2045
+ * 「最近文件夹」的宿主语义 —— 纯函数(2026-11-24 A3 / F2)。
2046
+ *
2047
+ * 为什么住壳:最近文件夹的**属主是壳**(`app` 命名空间,唯一写点 = 欢迎页 `recentList.ts`)。
2048
+ * 文件树过去跨属主直读 `pluginState.get("app","recentFolders")`——宿主改键名/结构就静默断链。
2049
+ * 现在读取面 = `workspace.getRecentFolders()`(主进程按本文件的规则归一化后下发),
2050
+ * 插件⛔ 不再读别的属主的私有状态;写侧(合并/剔除)仍在欢迎页(本文件只给共享常量与读取归一)。
2051
+ *
2052
+ * 纯函数零副作用:不碰 window/fs/Electron——主进程与渲染侧可同图引用。
2053
+ */
2054
+ export interface RecentFolder {
2055
+ path: string;
2056
+ name: string;
2057
+ }
1914
2058
  /** File/directory entry—shared by front and back ends */
1915
2059
  export interface FileEntry {
1916
2060
  name: string;
@@ -1979,6 +2123,12 @@ export interface WorkspaceAPI {
1979
2123
  removeFolder(path: string): Promise<void>;
1980
2124
  onDidChangeFolders(cb: () => void): () => void;
1981
2125
  onDidChangeActiveWorkspace(cb: (uri: string | null) => void): () => void;
2126
+ /** 2026-11-24 (A3/F2): the host-owned "recent folders" read surface — already normalized (legacy bare-string shape tolerated),
2127
+ * deduped and capped to the display limit by `src/core/services/recentFolders`. Pool plugins ⛔ must not read
2128
+ * `pluginState.get("app","recentFolders")` cross-owner: the host key/shape may change and the read breaks silently. */
2129
+ getRecentFolders(): Promise<RecentFolder[]>;
2130
+ /** 2026-11-24: subscribe to recent-folder changes — the host pushes the normalized display list (not a raw pluginState payload). */
2131
+ onDidChangeRecentFolders(cb: (folders: RecentFolder[]) => void): () => void;
1982
2132
  };
1983
2133
  /** Filesystem — plugin read/write (path validation is performed by the main process) */
1984
2134
  filesystem: {
@@ -2345,6 +2495,132 @@ export interface PluginUpdateCheckResult {
2345
2495
  downloadUrl?: string;
2346
2496
  update: boolean;
2347
2497
  }
2498
+ /** 来源身份——壳账本记录并比对(同源判据 = sourceUrl+repo+publisher+pluginId 全同,spec §3.4) */
2499
+ export interface PluginSourceIdentity {
2500
+ /** 市场源 id(`official` = 官方目录) */
2501
+ id: string;
2502
+ /** 目录源 URL */
2503
+ url: string;
2504
+ /** GitHub repo(可判定时,`owner/repo`) */
2505
+ repo?: string;
2506
+ /** 作者/发布者(目录条目声明值) */
2507
+ publisher?: string;
2508
+ }
2509
+ /** 确认卡可画的展示数据——⛔ 只许结构化纯数据(不接受 HTML/CSS;壳只额外接受一个经对比度校验的 accent,见 spec §3.3) */
2510
+ export interface PluginInstallDisplay {
2511
+ name: string;
2512
+ /** 图标声明(iconSource 语义同 plugin.json;壳解析,市场不传路径) */
2513
+ icon?: string;
2514
+ /** 纯文本简介——壳按卡片宽度截断 */
2515
+ description?: string;
2516
+ changelogUrl?: string;
2517
+ /** 包大小(字节) */
2518
+ size?: number;
2519
+ }
2520
+ /** 一次安装/更新请求——市场唯一可提交的形状(spec §3.2;`pluginManager.install/update` 不再是远程安装的可用面) */
2521
+ export interface PluginInstallRequest {
2522
+ mode: "install" | "update";
2523
+ pluginId: string;
2524
+ version: string;
2525
+ downloadUrl: string;
2526
+ /** P1 起必填(目录已收录的版本);缺省 = 过渡期「未校验」横幅,不阻断(spec §七 迁移) */
2527
+ sha256?: string;
2528
+ source: PluginSourceIdentity;
2529
+ display: PluginInstallDisplay;
2530
+ /** update 模式:显式放行降级(版本下拉选旧版)——仍会走确认(policy 出 `downgrade`) */
2531
+ allowOlder?: boolean;
2532
+ /** 缺依赖解析目录(同 PluginInstallRequestOpts.catalogUrl 语义)——壳在同一 job 内自动装依赖用 */
2533
+ catalogUrl?: string;
2534
+ }
2535
+ /** `requestInstall` 回执——`confirmed:false` + `cancelled:false` = 被拒(`reason` 说原因) */
2536
+ export interface PluginInstallConfirmResult {
2537
+ confirmed: boolean;
2538
+ cancelled?: boolean;
2539
+ /** 确认后壳已入队;进度/终态走 `plugin:installJobs` 全量快照 */
2540
+ jobId?: string;
2541
+ /** `invalid` = 请求本身不成立(同版本重装 / 未放行降级 / 重复请求) */
2542
+ reason?: "user-cancelled" | "source-changed" | "integrity-failed" | "min-app" | "no-token" | "up-to-date" | "invalid";
2543
+ }
2544
+ /** 直接拒的项——不弹卡、不入队(spec §四:minApp 不满足直接拦;哈希/id 不符直接拒) */
2545
+ export interface PluginConfirmRejected {
2546
+ pluginId: string;
2547
+ reason: "min-app" | "integrity-failed" | "invalid";
2548
+ message?: string;
2549
+ }
2550
+ /** `requestUpdateBatch` 回执——`confirmed:false` = **整批取消**(0 个入队,spec §五.4) */
2551
+ export interface PluginUpdateBatchResult {
2552
+ confirmed: boolean;
2553
+ cancelled?: boolean;
2554
+ /** 确认后 ask + silent 全部入队(按请求顺序);`batchId` 是壳侧汇总键,**不是 job 表字段** */
2555
+ jobIds: string[];
2556
+ batchId?: string;
2557
+ /** 被直接拒的项(不弹卡、不进 jobIds) */
2558
+ rejected?: PluginConfirmRejected[];
2559
+ }
2560
+ /** 需要确认的原因——**封闭集合**;渲染体只按它选文案,⛔ 不自推(两条独立开关见 PluginUpdatePolicy) */
2561
+ export type PluginConfirmReason = "first-install" | "source-changed" | "downgrade" | "untrusted-source"
2562
+ /** 官方同源更新、但用户把 `silentOfficial` 关掉了 ⇒ 仍需一问(不是「未信任」——官方恒信任) */
2563
+ | "official-source";
2564
+ /** 需要确认的一项(壳 policy 算好,渲染体只画) */
2565
+ export interface PluginConfirmItem {
2566
+ request: PluginInstallRequest;
2567
+ reason: PluginConfirmReason;
2568
+ /** `reason:"source-changed"` 时的旧身份——卡片画「旧 → 新」(spec §3.4) */
2569
+ previous?: PluginSourceIdentity;
2570
+ /** 旧身份的**显示名**(壳解析 = 与当前来源同一份推导 `sourceLabel`;⛔ 渲染体自己从 identity 推 = 第二推导点) */
2571
+ previousLabel?: string;
2572
+ }
2573
+ /** 免问项(silent)摘要行——⛔ 不逐项展开成表(spec §5.1:silent 项以「官方 3 个将直接更新」摘要出现) */
2574
+ export interface PluginConfirmSummaryRow {
2575
+ pluginId: string;
2576
+ displayName: string;
2577
+ version: string;
2578
+ sourceId: string;
2579
+ }
2580
+ /** 按来源分组——**需要确认的组在前、免问组在后**;组内保持目录顺序(spec §5.1) */
2581
+ export interface PluginConfirmGroup {
2582
+ sourceId: string;
2583
+ /** 来源显示名(壳解析 = 单一来源,⛔ 市场拼) */
2584
+ label: string;
2585
+ /** 该来源在信任清单里(官方 fixed 恒 true) */
2586
+ trusted: boolean;
2587
+ /** 当前策略下该来源的同源更新**免问**(trusted 且对应开关开 = 真;⛔ 渲染体自己按开关推) */
2588
+ silentAllowed: boolean;
2589
+ askCount: number;
2590
+ silentCount: number;
2591
+ }
2592
+ /** 确认计划——壳 `policy.ts` 唯一产出;确认卡 / 执行 / 完成通知全读它(⛔ 第二份计划) */
2593
+ export interface PluginConfirmPlan {
2594
+ ask: PluginConfirmItem[];
2595
+ silent: PluginConfirmSummaryRow[];
2596
+ groups: PluginConfirmGroup[];
2597
+ rejected: PluginConfirmRejected[];
2598
+ /** 顶栏总览:「共 N 个 · M 个需确认 · K 个免问」(spec §5.2) */
2599
+ totals: {
2600
+ total: number;
2601
+ ask: number;
2602
+ silent: number;
2603
+ };
2604
+ }
2605
+ /** 两条**独立**开关(D5 拍板:正交、可同时开;首装/来源变更/降级不可关,见 spec §3.5) */
2606
+ export interface PluginUpdatePolicy {
2607
+ /** 官方目录的**同源更新**不逐项询问(默认开) */
2608
+ silentOfficial: boolean;
2609
+ /** 已信任第三方来源的**同源更新**不逐项询问(默认关) */
2610
+ silentTrustedSources: boolean;
2611
+ }
2612
+ /** 来源信任清单一行——每行**显式状态**(⛔ 让用户猜「点一下是信任还是不信任」,spec §3.5) */
2613
+ export interface PluginSourceTrustEntry {
2614
+ sourceId: string;
2615
+ url: string;
2616
+ repo?: string;
2617
+ publisher?: string;
2618
+ trusted: boolean;
2619
+ /** 官方固定信任(不可关) */
2620
+ fixed?: boolean;
2621
+ /** 最近一次见到该来源的时刻(ms) */
2622
+ seenAt?: number;
2623
+ }
2348
2624
  /** Manifest serialization subset of list() — aligned with the projection fields of handlePluginsCall "list"
2349
2625
  * the declared dependency id list (manifest.requires passed through) — the data source for the marketplace's missing-dependency check and the depends-on/depended-on rows
2350
2626
  * (the dependencies.ts engine runs only inside the shell; consumption goes through the list() projection). No requires = undefined.
@@ -2398,6 +2674,9 @@ export interface PluginInstallRequestOpts {
2398
2674
  displayName?: string;
2399
2675
  /** Job origin — row = one user action (user, default); dependencies dragged in by a plugin (dependency) hide inside that row */
2400
2676
  origin?: "user" | "dependency";
2677
+ /** P1(spec §七):期望的包 sha256(小写 hex)——壳在**下载后、解压前**校验,不符即删包拒装。
2678
+ * 壳自己的确认链(`plugins.requestInstall`)必带;市场/手装可缺省(过渡期「未校验」不阻断)。 */
2679
+ sha256?: string;
2401
2680
  /**
2402
2681
  * R4-1.3(I21/壳侧·正典 09 §三·补3):目录条目的 pricing 声明随行——**声明进数据层、裁决进壳**。
2403
2682
  * 调用方(市场插件)把它读到的条目 pricing 原样带上;壳安装门见 model 存在即查壳侧权益(licenses),
@@ -2515,7 +2794,9 @@ export interface PluginsAPI {
2515
2794
  readAllManifests?(): Promise<Record<string, PluginManifest>>;
2516
2795
  /** (1.2-5): the main-process real download stage — fetches the .linkdesk-plugin package → {userData}/tmp/<original package name> (shell preload only; called by the loader's install flow packageOps).
2517
2796
  * may carry a job identity — progress events from the main-process stage backfill jobId/pluginId accordingly (absent = events carry no identity; with N=1 attributed to the active session) */
2518
- packageDownload?(url: string, job?: PluginInstallJobRef): Promise<{
2797
+ /** P1 sha256(spec §七):传了就在**下载后、解压前**校验——不符即删包并拒装(`integrity-failed`)。
2798
+ * 缺省 = 过渡期「未校验」(旧目录条目没有 hash),不阻断。 */
2799
+ packageDownload?(url: string, job?: PluginInstallJobRef, sha256?: string): Promise<{
2519
2800
  zipPath: string;
2520
2801
  sizeBytes?: number;
2521
2802
  }>;
@@ -2549,6 +2830,36 @@ export interface PluginsAPI {
2549
2830
  version: string;
2550
2831
  deferred?: boolean;
2551
2832
  }>;
2833
+ /* ── P1 壳托管安装/更新确认(2026-11-24 拍板 D1/D2/D3/D5/D8)──
2834
+ * 任何市场(官方/第三方)想装/更新插件都必须走这里:壳算 ConfirmPlan → 出确认卡(可替换渲染槽,
2835
+ * 默认壳渲染器)→ 用户确认 → 壳**内部**签一次性 token → 立刻执行。token ⛔ 不过 IPC、不进契约。
2836
+ * 原 pluginManager.install/update 对**远程来源**无 token 即拒(`no-token`);本地文件安装两条腿
2837
+ * (installFromDirectory / .linkdesk-plugin 包)不过此门(用户手势、无远程来源;2026-11-24 拍板)。
2838
+ * 全部可选 `?`:老 preload 无此面 ⇒ 调用方判存在后回落旧 API(市场兼容窗口,spec §9 P1)。 */
2839
+ /** 首装/单项更新 —— 一条请求一次确认事务;`confirmed:false` + `cancelled:false` = 被拒 */
2840
+ requestInstall?(req: PluginInstallRequest): Promise<PluginInstallConfirmResult>;
2841
+ /** 批量更新 —— 只提交结构化请求;谁要确认由壳算(`ask` 为空则**不弹卡**直接全入队) */
2842
+ requestUpdateBatch?(reqs: PluginInstallRequest[]): Promise<PluginUpdateBatchResult>;
2843
+ /** 只读预览:按**当前**设置算一遍计划(不改状态、不入队)。确认卡内改设置后就地重算;
2844
+ * AI 也可先用它看「这次会问哪几个」。`forceAsk` = 把免问项也展开成需确认(本批临时,不改设置) */
2845
+ previewUpdatePlan?(reqs: PluginInstallRequest[], opts?: {
2846
+ forceAsk?: boolean;
2847
+ }): Promise<PluginConfirmPlan>;
2848
+ /** 读两条独立开关(设置页渲染源) */
2849
+ getUpdatePolicy?(): Promise<PluginUpdatePolicy>;
2850
+ /** 写两条开关(部分更新);返回写后全量 */
2851
+ setUpdatePolicy?(patch: Partial<PluginUpdatePolicy>): Promise<PluginUpdatePolicy>;
2852
+ /** 读来源信任清单(设置页/确认卡同一事实源;首装仍确认、来源变更自动失效) */
2853
+ listSourceTrust?(): Promise<PluginSourceTrustEntry[]>;
2854
+ /** 显式信任一个来源(返回写后清单) */
2855
+ trustSource?(entry: {
2856
+ sourceId: string;
2857
+ url: string;
2858
+ repo?: string;
2859
+ publisher?: string;
2860
+ }): Promise<PluginSourceTrustEntry[]>;
2861
+ /** 撤销信任(返回写后清单) */
2862
+ untrustSource?(sourceId: string): Promise<PluginSourceTrustEntry[]>;
2552
2863
  };
2553
2864
  /** Plugin management — bridges IpcBridgeHandler → loader functions. Pool-authoritative (consumed by marketplace plugins), required */
2554
2865
  pluginManager: {
@@ -3272,16 +3583,17 @@ export interface UpdateAPI {
3272
3583
  getState(): Promise<UpdateState>;
3273
3584
  };
3274
3585
  }
3275
- /**
3276
- * linkdesk API — the type-safe entry point for plugin code.
3277
- * Global namespace structure modeled after the VS Code `vscode` object.
3278
- * The namespaces injected by the pool preload are the plugin runtime source of truth (required);
3279
- * only bridge (true-shell-only) / hotExit (pool-side-only) are optional with `?` — the other side does not inject them (review N1 fix:
3280
- * the remaining bridge surfaces window/pool/shell/getFilePath are injected on both ends and marked required in the contract).
3281
- * cross-composed from 15 namespace domain interfaces (interface→type intersection;
3282
- * index access such as LinkDeskAPI["pool"]/["configuration"] keeps the consumer contract unchanged).
3283
- */
3284
- export type LinkDeskAPI = CommandsAPI & AppearanceAPI & StorageAPI & TabsAPI & KeybindingsAPI & UiAPI & DataAPI & WorkspaceAPI & EditorAPI & PluginsAPI & LicensesAPI & ShellAPI & PanelAPI & SettingsAPI & FactorySlotsAPI & AppAPI & UpdateAPI;
3586
+ /** Plugin-packaged asset URL surface — pool-only (the shell renderer calls the util directly). */
3587
+ export interface PluginAssetsAPI {
3588
+ pluginAssets: {
3589
+ /** Build the controlled `linkdesk://` URL for a plugin-packaged asset (2026-11-24 A2/).
3590
+ * @param pluginId plugin identity (`plugin.json` `pluginId`)
3591
+ * @param relativePath plugin-root-relative path (`README.md`, `resources/icon.svg`, `docs/`); empty/omitted = plugin root.
3592
+ * Normalizes `\` → `/` and strips a leading `./`. ⛔ A plugin must not concatenate the protocol itself (K9). */
3593
+ getUrl(pluginId: string, relativePath?: string): string;
3594
+ };
3595
+ }
3596
+ export type LinkDeskAPI = CommandsAPI & AppearanceAPI & StorageAPI & TabsAPI & KeybindingsAPI & UiAPI & DataAPI & WorkspaceAPI & EditorAPI & PluginsAPI & LicensesAPI & ShellAPI & PanelAPI & SettingsAPI & FactorySlotsAPI & AppAPI & UpdateAPI & AiPolicyAPI & PluginAssetsAPI;
3285
3597
  /**
3286
3598
  * 🔥 Canonical vocabulary for settings control hints (`uiHint`) — the single vocabulary between host declarations and the rendering layer (criterion B).
3287
3599
  *
@@ -3297,7 +3609,7 @@ export type LinkDeskAPI = CommandsAPI & AppearanceAPI & StorageAPI & TabsAPI & K
3297
3609
  * The runtime list and type guards live in `@linkdesk/ui` (`SETTINGS_UI_HINTS` / `isSettingsUiHint`) —
3298
3610
  * this contract package is a **pure type-generation artifact with zero runtime** and can only carry types.
3299
3611
  */
3300
- export type SettingsUiHint = "themePicker" | "select" | "accentSource" | "slider" | "image" | "fontTone" | "fontFamily" | "color" | "file" | "directory" | "fontSize" | "segmented" | "stringList" | "fileAssociationsManager";
3612
+ export type SettingsUiHint = "themePicker" | "select" | "accentSource" | "slider" | "image" | "fontTone" | "fontFamily" | "color" | "file" | "directory" | "fontSize" | "segmented" | "stringList" | "fileAssociationsManager" | "aiPolicy";
3301
3613
  /**
3302
3614
  * Canonical render hint for settings rows (`renderHint`) — three values.
3303
3615
  * `readonly` read-only status row (value comes from the `statusCommand` runtime data source, not from config storage);
package/package.json CHANGED
@@ -1,25 +1,25 @@
1
- {
2
- "name": "@linkdesk/contracts",
3
- "version": "0.1.51",
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.53",
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
+ }