@linkdesk/contracts 0.1.52 → 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.
- package/linkdesk.d.ts +376 -14
- package/package.json +25 -25
package/linkdesk.d.ts
CHANGED
|
@@ -13,6 +13,76 @@
|
|
|
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
|
+
/** 档位块下方的能力摘要(名称 + 当前判定;名称是 i18n key;随档位变) */
|
|
33
|
+
export interface AiPolicyCapabilityDto {
|
|
34
|
+
label: string;
|
|
35
|
+
decision: AiPolicyDecisionDto;
|
|
36
|
+
}
|
|
37
|
+
/** 风险表一行(`decision` = **当前档位下**的判定,随档变化) */
|
|
38
|
+
export interface AiPolicyRiskRowDto {
|
|
39
|
+
id: string;
|
|
40
|
+
kind: "op" | "command";
|
|
41
|
+
risk: AiPolicyRiskDto;
|
|
42
|
+
decision: AiPolicyDecisionDto;
|
|
43
|
+
/** 是什么动作(i18n key;缺省 = 只有 id) */
|
|
44
|
+
what?: string;
|
|
45
|
+
/** 为什么这样判(i18n key) */
|
|
46
|
+
why?: string;
|
|
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
|
+
}
|
|
57
|
+
export interface AiPolicyStateDto {
|
|
58
|
+
mode: AiPolicyModeDto;
|
|
59
|
+
/** true = 配置损坏/值非法,已按 fail-closed 档(ask)处理 */
|
|
60
|
+
degraded: boolean;
|
|
61
|
+
/** 读数时刻(ms) */
|
|
62
|
+
effectiveAt: number;
|
|
63
|
+
/** AI 通道是否开着(`ai.mcp.enabled` / `ai.cli.enabled` 任一 true)——徽标据此显示/隐藏 */
|
|
64
|
+
channelsEnabled: boolean;
|
|
65
|
+
/** 四档 × 四级判定(唯一来源 = 主进程 `decide`,⛔ 不二次实现) */
|
|
66
|
+
matrix: AiPolicyMatrixDto;
|
|
67
|
+
options: AiPolicyOptionDto[];
|
|
68
|
+
/** 档位块下方的摘要(4 条;随档位变) */
|
|
69
|
+
capabilities: AiPolicyCapabilityDto[];
|
|
70
|
+
/** 操作清单(表格行) */
|
|
71
|
+
riskTable: AiPolicyRiskRowDto[];
|
|
72
|
+
/** 敏感能力(表格行) */
|
|
73
|
+
sensitive: AiPolicySensitiveRowDto[];
|
|
74
|
+
/** `userOnly` 命令 id(AI 永远不可调)——由壳命令补,主进程返回空数组 */
|
|
75
|
+
protectedCommands: string[];
|
|
76
|
+
}
|
|
77
|
+
export interface AiPolicyAPI {
|
|
78
|
+
/** AI 权限档位读面——只读:getState(快照)+ onChange(变更后重读并回调)。写档位不在此面 */
|
|
79
|
+
aiPolicy: {
|
|
80
|
+
/** 当前策略快照(档位 / 四档矩阵 / 风险表 / 受保护命令) */
|
|
81
|
+
getState(): Promise<AiPolicyStateDto>;
|
|
82
|
+
/** 档位变更订阅——回调参数是**重新读过**的快照(不是配置值);返回退订函数 */
|
|
83
|
+
onChange(cb: (state: AiPolicyStateDto) => void): () => void;
|
|
84
|
+
};
|
|
85
|
+
}
|
|
16
86
|
/**
|
|
17
87
|
* Command parameter descriptor — commands **carry their own parameter descriptions**, returned together with `commands.getCommands()`.
|
|
18
88
|
* 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 +109,17 @@ export interface LinkDeskCommand {
|
|
|
39
109
|
description?: string;
|
|
40
110
|
/** parameter structure (positionally mapped to handler arguments). Optional, purely additive; omit for commands without parameters. */
|
|
41
111
|
params?: LinkDeskCommandParam[];
|
|
112
|
+
/**
|
|
113
|
+
* AI permission tier (2026-11-24 · AI-safety policy, L2): `true` = user-only command —
|
|
114
|
+
* the AI gateway (`exec` / `notifyAction`) always answers `EPROTECTED`. Omitted = AI-callable
|
|
115
|
+
* (still subject to the policy tier). Purely additive: existing plugins keep current behaviour.
|
|
116
|
+
*/
|
|
117
|
+
userOnly?: boolean;
|
|
118
|
+
/**
|
|
119
|
+
* Declared risk level (2026-11-24 · AI permission tiers) — mirrors `contributes.commands[].risk`.
|
|
120
|
+
* Merge order: host built-in table > this declaration > fallback R1. Purely additive.
|
|
121
|
+
*/
|
|
122
|
+
risk?: "R0" | "R1" | "R2" | "R3";
|
|
42
123
|
}
|
|
43
124
|
/** 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
125
|
* Five domains: colors (colorways always contribute) + the four appearance style domains (radius/glass/font/background).
|
|
@@ -98,6 +179,25 @@ export interface LinkDeskConfigProperty {
|
|
|
98
179
|
group?: string;
|
|
99
180
|
/** numeric unit — value-label unit for uiHint "slider" ("×" / "px"; empty = bare number) */
|
|
100
181
|
unit?: string;
|
|
182
|
+
/** 2026-11-24 semantic ownership: host asset domain registry key (e.g. "appearance") — the domain source of host asset actions.
|
|
183
|
+
* The UI forwards this value verbatim to `appearance.pickImage`; ⛔ it never holds a domain literal (replace the UI plugin and the start directory stays). */
|
|
184
|
+
assetDomain?: string;
|
|
185
|
+
/** 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. */
|
|
186
|
+
pickTarget?: string;
|
|
187
|
+
/** 2026-11-24: conditional description — when `{key,value}` holds, this text replaces `description`.
|
|
188
|
+
* Example: `app.themeColor` under `app.appearanceMode="custom"` shows the colors-domain source wording. The UI ⛔ no longer special-cases the key. */
|
|
189
|
+
descriptionWhen?: {
|
|
190
|
+
key: string;
|
|
191
|
+
value: unknown;
|
|
192
|
+
description: string;
|
|
193
|
+
};
|
|
194
|
+
/** 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. */
|
|
195
|
+
sourceActiveWhen?: {
|
|
196
|
+
key: string;
|
|
197
|
+
value: unknown;
|
|
198
|
+
};
|
|
199
|
+
/** 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. */
|
|
200
|
+
sourceFollowValue?: string;
|
|
101
201
|
}
|
|
102
202
|
/** Config schema — key → property definition (index signature kept for existing consumers) */
|
|
103
203
|
export interface LinkDeskConfigSchema {
|
|
@@ -288,6 +388,22 @@ export interface LinkDeskLanguage {
|
|
|
288
388
|
label: string;
|
|
289
389
|
pluginId: string;
|
|
290
390
|
}
|
|
391
|
+
/** Options for `appearance.pickImage` — the caller forwards the schema-declared `assetDomain` / `pickTarget` verbatim (2026-11-24 semantic ownership).
|
|
392
|
+
* ⛔ No path, no directory token, no domain literal: start directory / filters / copy-into-store are host-owned. */
|
|
393
|
+
export interface AppearancePickOptions {
|
|
394
|
+
/** Host asset domain registry key (e.g. "appearance") — declared by the config schema (`assetDomain`) */
|
|
395
|
+
domain: string;
|
|
396
|
+
/** Target slot inside the domain (e.g. "app" / "zone") — declared by the config schema (`pickTarget`); shares the domain's directory and filters */
|
|
397
|
+
target: string;
|
|
398
|
+
}
|
|
399
|
+
/** Result of `appearance.pickImage` — a canceled dialog is `{picked:false}`, not an error. */
|
|
400
|
+
export type AppearancePickResult = {
|
|
401
|
+
picked: true;
|
|
402
|
+
url: string;
|
|
403
|
+
name: string;
|
|
404
|
+
} | {
|
|
405
|
+
picked: false;
|
|
406
|
+
};
|
|
291
407
|
/** Theme + language + appearance asset namespace surfaces — modeled after the VS Code appearance surface */
|
|
292
408
|
export interface AppearanceAPI {
|
|
293
409
|
theme: {
|
|
@@ -344,6 +460,10 @@ export interface AppearanceAPI {
|
|
|
344
460
|
/** open the appearance storage directory (userData/appearance) — the main process resolves the path and uses shell.openPath to open the file explorer
|
|
345
461
|
* 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. */
|
|
346
462
|
revealStorage(): Promise<void>;
|
|
463
|
+
/** 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
|
|
464
|
+
* (`electron/services/hostAssets/appearance/defaults.ts` — the single semantic source); the caller only forwards the schema-declared `{domain,target}`.
|
|
465
|
+
* Returns the controlled URL (`linkdesk-userdata://…`) or `{picked:false}` on cancel. Replacing the UI plugin leaves this behavior intact. */
|
|
466
|
+
pickImage(options: AppearancePickOptions): Promise<AppearancePickResult>;
|
|
347
467
|
};
|
|
348
468
|
}
|
|
349
469
|
/** 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) */
|
|
@@ -356,6 +476,10 @@ export interface StorageAPI {
|
|
|
356
476
|
/** The absolute path of the currently effective cache directory — settings.json's `app.storage.cacheDir` (empty/missing = the userData default location);
|
|
357
477
|
* 🔴 the single resolution entry (placement contract iron rule 3: no second copy of the path is stored anywhere — take it, never copy it) */
|
|
358
478
|
cacheDir(): Promise<string>;
|
|
479
|
+
/** 🆕 2026-11-24: on-disk path of a host storage key (e.g. `"settings"` → `<userData>/settings.json`).
|
|
480
|
+
* 🔴 The filename map lives in the host only (`storageFilename` — shared by the renderer StorageService and the main process);
|
|
481
|
+
* a UI plugin must call this instead of joining `appDataDir` with a filename literal (V6 / K10). */
|
|
482
|
+
getFilePath(key: string): Promise<string>;
|
|
359
483
|
};
|
|
360
484
|
}
|
|
361
485
|
/**
|
|
@@ -1452,6 +1576,17 @@ export interface DialogOpenOptions {
|
|
|
1452
1576
|
*/
|
|
1453
1577
|
defaultPathKind?: "appearance";
|
|
1454
1578
|
}
|
|
1579
|
+
/** 2026-11-24(D12):保存对话框入参——只选**落盘路径**,壳不代写内容(写入由调用方走 filesystem)。
|
|
1580
|
+
* 起始目录 / 覆盖确认由 OS 原生对话框决定;插件⛔ 不再自造 `showSaveFilePicker` / `<a download>` 第二套。 */
|
|
1581
|
+
export interface DialogSaveOptions {
|
|
1582
|
+
title?: string;
|
|
1583
|
+
filters?: {
|
|
1584
|
+
name: string;
|
|
1585
|
+
extensions: string[];
|
|
1586
|
+
}[];
|
|
1587
|
+
/** 建议文件名(可含扩展名;OS 对话框据此给出落点) */
|
|
1588
|
+
defaultName?: string;
|
|
1589
|
+
}
|
|
1455
1590
|
/** rich-content confirm dialog open params—pool plugin → shell DialogService (addressed by content view declaration).
|
|
1456
1591
|
* 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). */
|
|
1457
1592
|
export interface DialogContentOpenOptions {
|
|
@@ -1552,6 +1687,11 @@ export type PoolDialogData = {
|
|
|
1552
1687
|
renderPath: string;
|
|
1553
1688
|
/** Opaque serialized payload — travels with the open parameters through shell→back to pool (structured clone); used by the content view to fetch data */
|
|
1554
1689
|
payload?: unknown;
|
|
1690
|
+
} | {
|
|
1691
|
+
/** P1(D8 渲染槽):宿主内置内容视图 id(池内 `plugin-install-confirm` 注册表直挂,无需 renderPath)
|
|
1692
|
+
* ——壳默认渲染器用它;第三方整套替换时换 pluginId+renderPath 那一支。两支二选一。 */
|
|
1693
|
+
hostView: string;
|
|
1694
|
+
payload?: unknown;
|
|
1555
1695
|
};
|
|
1556
1696
|
};
|
|
1557
1697
|
/**
|
|
@@ -1578,8 +1718,9 @@ export interface PoolPendingDialog {
|
|
|
1578
1718
|
/** rich-content confirmation — content = a plugin's self-drawn view. Gives the **identity** (not renderPath: that is the pool-internal addressing key,
|
|
1579
1719
|
* 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"). */
|
|
1580
1720
|
content?: {
|
|
1581
|
-
pluginId
|
|
1582
|
-
viewId
|
|
1721
|
+
pluginId?: string;
|
|
1722
|
+
viewId?: string; /** P1:宿主内置默认渲染器(无 pluginId/viewId——壳自带视图) */
|
|
1723
|
+
hostView?: string;
|
|
1583
1724
|
};
|
|
1584
1725
|
}
|
|
1585
1726
|
/** 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).
|
|
@@ -1734,6 +1875,10 @@ export interface UiAPI {
|
|
|
1734
1875
|
open(opts?: DialogOpenOptions): Promise<string | null>;
|
|
1735
1876
|
/** Opens the file picker — returns the user-selected path; cancel → null. Security is controlled by the main process */
|
|
1736
1877
|
openFile(opts?: DialogOpenOptions): Promise<string | null>;
|
|
1878
|
+
/** 2026-11-24 (D12): save dialog — returns the chosen absolute path, or null on cancel.
|
|
1879
|
+
* One host action for "where to save" (start directory / overwrite confirm are OS-native); the plugin then writes via `filesystem.writeTextFile`.
|
|
1880
|
+
* ⛔ A plugin must not build a second save path (`showSaveFilePicker` / `<a download>`) — the second consumer always copies it. */
|
|
1881
|
+
save(opts?: DialogSaveOptions): Promise<string | null>;
|
|
1737
1882
|
/** rich-content confirm — the dialog's content = a plugin self-drawn view (content view declarative addressing + opaque payload).
|
|
1738
1883
|
* Dialog mechanics match confirm (centered/mask/Esc/focus lock/click-mask-to-cancel); content layout and buttons are drawn by the plugin view
|
|
1739
1884
|
* (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,
|
|
@@ -1915,6 +2060,20 @@ export interface WorkspaceFolder {
|
|
|
1915
2060
|
/** Index—the first opened folder is index=0 */
|
|
1916
2061
|
index: number;
|
|
1917
2062
|
}
|
|
2063
|
+
/**
|
|
2064
|
+
* 「最近文件夹」的宿主语义 —— 纯函数(2026-11-24 A3 / F2)。
|
|
2065
|
+
*
|
|
2066
|
+
* 为什么住壳:最近文件夹的**属主是壳**(`app` 命名空间,唯一写点 = 欢迎页 `recentList.ts`)。
|
|
2067
|
+
* 文件树过去跨属主直读 `pluginState.get("app","recentFolders")`——宿主改键名/结构就静默断链。
|
|
2068
|
+
* 现在读取面 = `workspace.getRecentFolders()`(主进程按本文件的规则归一化后下发),
|
|
2069
|
+
* 插件⛔ 不再读别的属主的私有状态;写侧(合并/剔除)仍在欢迎页(本文件只给共享常量与读取归一)。
|
|
2070
|
+
*
|
|
2071
|
+
* 纯函数零副作用:不碰 window/fs/Electron——主进程与渲染侧可同图引用。
|
|
2072
|
+
*/
|
|
2073
|
+
export interface RecentFolder {
|
|
2074
|
+
path: string;
|
|
2075
|
+
name: string;
|
|
2076
|
+
}
|
|
1918
2077
|
/** File/directory entry—shared by front and back ends */
|
|
1919
2078
|
export interface FileEntry {
|
|
1920
2079
|
name: string;
|
|
@@ -1983,6 +2142,12 @@ export interface WorkspaceAPI {
|
|
|
1983
2142
|
removeFolder(path: string): Promise<void>;
|
|
1984
2143
|
onDidChangeFolders(cb: () => void): () => void;
|
|
1985
2144
|
onDidChangeActiveWorkspace(cb: (uri: string | null) => void): () => void;
|
|
2145
|
+
/** 2026-11-24 (A3/F2): the host-owned "recent folders" read surface — already normalized (legacy bare-string shape tolerated),
|
|
2146
|
+
* deduped and capped to the display limit by `src/core/services/recentFolders`. Pool plugins ⛔ must not read
|
|
2147
|
+
* `pluginState.get("app","recentFolders")` cross-owner: the host key/shape may change and the read breaks silently. */
|
|
2148
|
+
getRecentFolders(): Promise<RecentFolder[]>;
|
|
2149
|
+
/** 2026-11-24: subscribe to recent-folder changes — the host pushes the normalized display list (not a raw pluginState payload). */
|
|
2150
|
+
onDidChangeRecentFolders(cb: (folders: RecentFolder[]) => void): () => void;
|
|
1986
2151
|
};
|
|
1987
2152
|
/** Filesystem — plugin read/write (path validation is performed by the main process) */
|
|
1988
2153
|
filesystem: {
|
|
@@ -2349,6 +2514,153 @@ export interface PluginUpdateCheckResult {
|
|
|
2349
2514
|
downloadUrl?: string;
|
|
2350
2515
|
update: boolean;
|
|
2351
2516
|
}
|
|
2517
|
+
/** 来源身份——壳账本记录并比对(同源判据 = sourceUrl+repo+publisher+pluginId 全同,spec §3.4) */
|
|
2518
|
+
export interface PluginSourceIdentity {
|
|
2519
|
+
/** 市场源 id(`official` = 官方目录) */
|
|
2520
|
+
id: string;
|
|
2521
|
+
/** 目录源 URL */
|
|
2522
|
+
url: string;
|
|
2523
|
+
/** GitHub repo(可判定时,`owner/repo`) */
|
|
2524
|
+
repo?: string;
|
|
2525
|
+
/** 作者/发布者(目录条目声明值) */
|
|
2526
|
+
publisher?: string;
|
|
2527
|
+
}
|
|
2528
|
+
/** 确认卡可画的展示数据——⛔ 只许结构化纯数据(不接受 HTML/CSS;壳只额外接受一个经对比度校验的 accent,见 spec §3.3) */
|
|
2529
|
+
export interface PluginInstallDisplay {
|
|
2530
|
+
name: string;
|
|
2531
|
+
/** 图标声明(iconSource 语义同 plugin.json;壳解析,市场不传路径) */
|
|
2532
|
+
icon?: string;
|
|
2533
|
+
/** 纯文本简介——壳按卡片宽度截断 */
|
|
2534
|
+
description?: string;
|
|
2535
|
+
changelogUrl?: string;
|
|
2536
|
+
/** 包大小(字节) */
|
|
2537
|
+
size?: number;
|
|
2538
|
+
}
|
|
2539
|
+
/** 一次安装/更新请求——市场唯一可提交的形状(spec §3.2;`pluginManager.install/update` 不再是远程安装的可用面) */
|
|
2540
|
+
export interface PluginInstallRequest {
|
|
2541
|
+
mode: "install" | "update";
|
|
2542
|
+
pluginId: string;
|
|
2543
|
+
version: string;
|
|
2544
|
+
downloadUrl: string;
|
|
2545
|
+
/** P1 起必填(目录已收录的版本);缺省 = 过渡期「未校验」横幅,不阻断(spec §七 迁移) */
|
|
2546
|
+
sha256?: string;
|
|
2547
|
+
source: PluginSourceIdentity;
|
|
2548
|
+
display: PluginInstallDisplay;
|
|
2549
|
+
/** update 模式:显式放行降级(版本下拉选旧版)——仍会走确认(policy 出 `downgrade`) */
|
|
2550
|
+
allowOlder?: boolean;
|
|
2551
|
+
/** 缺依赖解析目录(同 PluginInstallRequestOpts.catalogUrl 语义)——壳在同一 job 内自动装依赖用 */
|
|
2552
|
+
catalogUrl?: string;
|
|
2553
|
+
}
|
|
2554
|
+
/** `requestInstall` 回执——`confirmed:false` + `cancelled:false` = 被拒(`reason` 说原因) */
|
|
2555
|
+
export interface PluginInstallConfirmResult {
|
|
2556
|
+
confirmed: boolean;
|
|
2557
|
+
cancelled?: boolean;
|
|
2558
|
+
/** 确认后壳已入队;进度/终态走 `plugin:installJobs` 全量快照 */
|
|
2559
|
+
jobId?: string;
|
|
2560
|
+
/** `invalid` = 请求本身不成立(同版本重装 / 未放行降级 / 重复请求) */
|
|
2561
|
+
reason?: "user-cancelled" | "source-changed" | "integrity-failed" | "min-app" | "no-token" | "up-to-date" | "invalid";
|
|
2562
|
+
}
|
|
2563
|
+
/** 直接拒的项——不弹卡、不入队(spec §四:minApp 不满足直接拦;哈希/id 不符直接拒) */
|
|
2564
|
+
export interface PluginConfirmRejected {
|
|
2565
|
+
pluginId: string;
|
|
2566
|
+
reason: "min-app" | "integrity-failed" | "invalid";
|
|
2567
|
+
message?: string;
|
|
2568
|
+
}
|
|
2569
|
+
/** `requestUpdateBatch` 回执——`confirmed:false` = **整批取消**(0 个入队,spec §五.4) */
|
|
2570
|
+
export interface PluginUpdateBatchResult {
|
|
2571
|
+
confirmed: boolean;
|
|
2572
|
+
cancelled?: boolean;
|
|
2573
|
+
/** 确认后 ask + silent 全部入队(按请求顺序);`batchId` 是壳侧汇总键,**不是 job 表字段** */
|
|
2574
|
+
jobIds: string[];
|
|
2575
|
+
batchId?: string;
|
|
2576
|
+
/** 被直接拒的项(不弹卡、不进 jobIds) */
|
|
2577
|
+
rejected?: PluginConfirmRejected[];
|
|
2578
|
+
}
|
|
2579
|
+
/** 需要确认的原因——**封闭集合**;渲染体只按它选文案,⛔ 不自推(两条独立开关见 PluginUpdatePolicy) */
|
|
2580
|
+
export type PluginConfirmReason = "first-install" | "source-changed" | "downgrade" | "untrusted-source"
|
|
2581
|
+
/** 官方同源更新、但用户把 `silentOfficial` 关掉了 ⇒ 仍需一问(不是「未信任」——官方恒信任) */
|
|
2582
|
+
| "official-source";
|
|
2583
|
+
/** 需要确认的一项(壳 policy 算好,渲染体只画) */
|
|
2584
|
+
export interface PluginConfirmItem {
|
|
2585
|
+
request: PluginInstallRequest;
|
|
2586
|
+
reason: PluginConfirmReason;
|
|
2587
|
+
/** `reason:"source-changed"` 时的旧身份——卡片画「旧 → 新」(spec §3.4) */
|
|
2588
|
+
previous?: PluginSourceIdentity;
|
|
2589
|
+
/** 旧身份的**显示名**(壳解析 = 与当前来源同一份推导 `sourceLabel`;⛔ 渲染体自己从 identity 推 = 第二推导点) */
|
|
2590
|
+
previousLabel?: string;
|
|
2591
|
+
}
|
|
2592
|
+
/** 免问项(silent)摘要行——⛔ 不逐项展开成表(spec §5.1:silent 项以「官方 3 个将直接更新」摘要出现) */
|
|
2593
|
+
export interface PluginConfirmSummaryRow {
|
|
2594
|
+
pluginId: string;
|
|
2595
|
+
displayName: string;
|
|
2596
|
+
version: string;
|
|
2597
|
+
sourceId: string;
|
|
2598
|
+
}
|
|
2599
|
+
/** 按来源分组——**需要确认的组在前、免问组在后**;组内保持目录顺序(spec §5.1) */
|
|
2600
|
+
export interface PluginConfirmGroup {
|
|
2601
|
+
sourceId: string;
|
|
2602
|
+
/** 来源显示名(壳解析 = 单一来源,⛔ 市场拼) */
|
|
2603
|
+
label: string;
|
|
2604
|
+
/** 该来源在信任清单里(官方 fixed 恒 true) */
|
|
2605
|
+
trusted: boolean;
|
|
2606
|
+
/** 当前策略下该来源的同源更新**免问**(trusted 且对应开关开 = 真;⛔ 渲染体自己按开关推) */
|
|
2607
|
+
silentAllowed: boolean;
|
|
2608
|
+
askCount: number;
|
|
2609
|
+
silentCount: number;
|
|
2610
|
+
}
|
|
2611
|
+
/** 确认计划——壳 `policy.ts` 唯一产出;确认卡 / 执行 / 完成通知全读它(⛔ 第二份计划) */
|
|
2612
|
+
export interface PluginConfirmPlan {
|
|
2613
|
+
ask: PluginConfirmItem[];
|
|
2614
|
+
silent: PluginConfirmSummaryRow[];
|
|
2615
|
+
groups: PluginConfirmGroup[];
|
|
2616
|
+
rejected: PluginConfirmRejected[];
|
|
2617
|
+
/** 顶栏总览:「共 N 个 · M 个需确认 · K 个免问」(spec §5.2) */
|
|
2618
|
+
totals: {
|
|
2619
|
+
total: number;
|
|
2620
|
+
ask: number;
|
|
2621
|
+
silent: number;
|
|
2622
|
+
};
|
|
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
|
+
}
|
|
2645
|
+
/** 两条**独立**开关(D5 拍板:正交、可同时开;首装/来源变更/降级不可关,见 spec §3.5) */
|
|
2646
|
+
export interface PluginUpdatePolicy {
|
|
2647
|
+
/** 官方目录的**同源更新**不逐项询问(默认开) */
|
|
2648
|
+
silentOfficial: boolean;
|
|
2649
|
+
/** 已信任第三方来源的**同源更新**不逐项询问(默认关) */
|
|
2650
|
+
silentTrustedSources: boolean;
|
|
2651
|
+
}
|
|
2652
|
+
/** 来源信任清单一行——每行**显式状态**(⛔ 让用户猜「点一下是信任还是不信任」,spec §3.5) */
|
|
2653
|
+
export interface PluginSourceTrustEntry {
|
|
2654
|
+
sourceId: string;
|
|
2655
|
+
url: string;
|
|
2656
|
+
repo?: string;
|
|
2657
|
+
publisher?: string;
|
|
2658
|
+
trusted: boolean;
|
|
2659
|
+
/** 官方固定信任(不可关) */
|
|
2660
|
+
fixed?: boolean;
|
|
2661
|
+
/** 最近一次见到该来源的时刻(ms) */
|
|
2662
|
+
seenAt?: number;
|
|
2663
|
+
}
|
|
2352
2664
|
/** Manifest serialization subset of list() — aligned with the projection fields of handlePluginsCall "list"
|
|
2353
2665
|
* 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
|
|
2354
2666
|
* (the dependencies.ts engine runs only inside the shell; consumption goes through the list() projection). No requires = undefined.
|
|
@@ -2402,6 +2714,9 @@ export interface PluginInstallRequestOpts {
|
|
|
2402
2714
|
displayName?: string;
|
|
2403
2715
|
/** Job origin — row = one user action (user, default); dependencies dragged in by a plugin (dependency) hide inside that row */
|
|
2404
2716
|
origin?: "user" | "dependency";
|
|
2717
|
+
/** P1(spec §七):期望的包 sha256(小写 hex)——壳在**下载后、解压前**校验,不符即删包拒装。
|
|
2718
|
+
* 壳自己的确认链(`plugins.requestInstall`)必带;市场/手装可缺省(过渡期「未校验」不阻断)。 */
|
|
2719
|
+
sha256?: string;
|
|
2405
2720
|
/**
|
|
2406
2721
|
* R4-1.3(I21/壳侧·正典 09 §三·补3):目录条目的 pricing 声明随行——**声明进数据层、裁决进壳**。
|
|
2407
2722
|
* 调用方(市场插件)把它读到的条目 pricing 原样带上;壳安装门见 model 存在即查壳侧权益(licenses),
|
|
@@ -2519,7 +2834,9 @@ export interface PluginsAPI {
|
|
|
2519
2834
|
readAllManifests?(): Promise<Record<string, PluginManifest>>;
|
|
2520
2835
|
/** (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).
|
|
2521
2836
|
* 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) */
|
|
2522
|
-
|
|
2837
|
+
/** P1 sha256(spec §七):传了就在**下载后、解压前**校验——不符即删包并拒装(`integrity-failed`)。
|
|
2838
|
+
* 缺省 = 过渡期「未校验」(旧目录条目没有 hash),不阻断。 */
|
|
2839
|
+
packageDownload?(url: string, job?: PluginInstallJobRef, sha256?: string): Promise<{
|
|
2523
2840
|
zipPath: string;
|
|
2524
2841
|
sizeBytes?: number;
|
|
2525
2842
|
}>;
|
|
@@ -2535,6 +2852,9 @@ export interface PluginsAPI {
|
|
|
2535
2852
|
* a jobId → AbortController registry and does not interpret semantics. Returns false = that job currently has no in-flight download
|
|
2536
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. */
|
|
2537
2854
|
packageCancel?(jobId: string): Promise<boolean>;
|
|
2855
|
+
/** P1(D9′ 零插件路径):只读拉取目录原文(HTTPS-only;主进程唯一网络出口)——命令面 `plugins.listCatalog` 用。
|
|
2856
|
+
* ⛔ 不解析、不缓存:解析归调用方(壳命令),主进程只当管道。 */
|
|
2857
|
+
packageReadCatalog?(catalogUrl: string): Promise<string>;
|
|
2538
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. */
|
|
2539
2859
|
packageUpdateCheck?(pluginId: string, catalogUrl: string, currentVersion?: string): Promise<PluginUpdateCheckResult>;
|
|
2540
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).
|
|
@@ -2553,6 +2873,47 @@ export interface PluginsAPI {
|
|
|
2553
2873
|
version: string;
|
|
2554
2874
|
deferred?: boolean;
|
|
2555
2875
|
}>;
|
|
2876
|
+
/* ── P1 壳托管安装/更新确认(2026-11-24 拍板 D1/D2/D3/D5/D8)──
|
|
2877
|
+
* 任何市场(官方/第三方)想装/更新插件都必须走这里:壳算 ConfirmPlan → 出确认卡(可替换渲染槽,
|
|
2878
|
+
* 默认壳渲染器)→ 用户确认 → 壳**内部**签一次性 token → 立刻执行。token ⛔ 不过 IPC、不进契约。
|
|
2879
|
+
* 原 pluginManager.install/update 对**远程来源**无 token 即拒(`no-token`);本地文件安装两条腿
|
|
2880
|
+
* (installFromDirectory / .linkdesk-plugin 包)不过此门(用户手势、无远程来源;2026-11-24 拍板)。
|
|
2881
|
+
* 全部可选 `?`:老 preload 无此面 ⇒ 调用方判存在后回落旧 API(市场兼容窗口,spec §9 P1)。 */
|
|
2882
|
+
/** 首装/单项更新 —— 一条请求一次确认事务;`confirmed:false` + `cancelled:false` = 被拒 */
|
|
2883
|
+
requestInstall?(req: PluginInstallRequest): Promise<PluginInstallConfirmResult>;
|
|
2884
|
+
/** 批量更新 —— 只提交结构化请求;谁要确认由壳算(`ask` 为空则**不弹卡**直接全入队) */
|
|
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>;
|
|
2897
|
+
/** 只读预览:按**当前**设置算一遍计划(不改状态、不入队)。确认卡内改设置后就地重算;
|
|
2898
|
+
* AI 也可先用它看「这次会问哪几个」。`forceAsk` = 把免问项也展开成需确认(本批临时,不改设置) */
|
|
2899
|
+
previewUpdatePlan?(reqs: PluginInstallRequest[], opts?: {
|
|
2900
|
+
forceAsk?: boolean;
|
|
2901
|
+
}): Promise<PluginConfirmPlan>;
|
|
2902
|
+
/** 读两条独立开关(设置页渲染源) */
|
|
2903
|
+
getUpdatePolicy?(): Promise<PluginUpdatePolicy>;
|
|
2904
|
+
/** 写两条开关(部分更新);返回写后全量 */
|
|
2905
|
+
setUpdatePolicy?(patch: Partial<PluginUpdatePolicy>): Promise<PluginUpdatePolicy>;
|
|
2906
|
+
/** 读来源信任清单(设置页/确认卡同一事实源;首装仍确认、来源变更自动失效) */
|
|
2907
|
+
listSourceTrust?(): Promise<PluginSourceTrustEntry[]>;
|
|
2908
|
+
/** 显式信任一个来源(返回写后清单) */
|
|
2909
|
+
trustSource?(entry: {
|
|
2910
|
+
sourceId: string;
|
|
2911
|
+
url: string;
|
|
2912
|
+
repo?: string;
|
|
2913
|
+
publisher?: string;
|
|
2914
|
+
}): Promise<PluginSourceTrustEntry[]>;
|
|
2915
|
+
/** 撤销信任(返回写后清单) */
|
|
2916
|
+
untrustSource?(sourceId: string): Promise<PluginSourceTrustEntry[]>;
|
|
2556
2917
|
};
|
|
2557
2918
|
/** Plugin management — bridges IpcBridgeHandler → loader functions. Pool-authoritative (consumed by marketplace plugins), required */
|
|
2558
2919
|
pluginManager: {
|
|
@@ -3276,16 +3637,17 @@ export interface UpdateAPI {
|
|
|
3276
3637
|
getState(): Promise<UpdateState>;
|
|
3277
3638
|
};
|
|
3278
3639
|
}
|
|
3279
|
-
/**
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3640
|
+
/** Plugin-packaged asset URL surface — pool-only (the shell renderer calls the util directly). */
|
|
3641
|
+
export interface PluginAssetsAPI {
|
|
3642
|
+
pluginAssets: {
|
|
3643
|
+
/** Build the controlled `linkdesk://` URL for a plugin-packaged asset (2026-11-24 A2/).
|
|
3644
|
+
* @param pluginId plugin identity (`plugin.json` `pluginId`)
|
|
3645
|
+
* @param relativePath plugin-root-relative path (`README.md`, `resources/icon.svg`, `docs/`); empty/omitted = plugin root.
|
|
3646
|
+
* Normalizes `\` → `/` and strips a leading `./`. ⛔ A plugin must not concatenate the protocol itself (K9). */
|
|
3647
|
+
getUrl(pluginId: string, relativePath?: string): string;
|
|
3648
|
+
};
|
|
3649
|
+
}
|
|
3650
|
+
export type LinkDeskAPI = CommandsAPI & AppearanceAPI & StorageAPI & TabsAPI & KeybindingsAPI & UiAPI & DataAPI & WorkspaceAPI & EditorAPI & PluginsAPI & LicensesAPI & ShellAPI & PanelAPI & SettingsAPI & FactorySlotsAPI & AppAPI & UpdateAPI & AiPolicyAPI & PluginAssetsAPI;
|
|
3289
3651
|
/**
|
|
3290
3652
|
* 🔥 Canonical vocabulary for settings control hints (`uiHint`) — the single vocabulary between host declarations and the rendering layer (criterion B).
|
|
3291
3653
|
*
|
|
@@ -3301,7 +3663,7 @@ export type LinkDeskAPI = CommandsAPI & AppearanceAPI & StorageAPI & TabsAPI & K
|
|
|
3301
3663
|
* The runtime list and type guards live in `@linkdesk/ui` (`SETTINGS_UI_HINTS` / `isSettingsUiHint`) —
|
|
3302
3664
|
* this contract package is a **pure type-generation artifact with zero runtime** and can only carry types.
|
|
3303
3665
|
*/
|
|
3304
|
-
export type SettingsUiHint = "themePicker" | "select" | "accentSource" | "slider" | "image" | "fontTone" | "fontFamily" | "color" | "file" | "directory" | "fontSize" | "segmented" | "stringList" | "fileAssociationsManager";
|
|
3666
|
+
export type SettingsUiHint = "themePicker" | "select" | "accentSource" | "slider" | "image" | "fontTone" | "fontFamily" | "color" | "file" | "directory" | "fontSize" | "segmented" | "stringList" | "fileAssociationsManager" | "aiPolicy";
|
|
3305
3667
|
/**
|
|
3306
3668
|
* Canonical render hint for settings rows (`renderHint`) — three values.
|
|
3307
3669
|
* `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.
|
|
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.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
|
+
}
|