@linkdesk/contracts 0.1.52 → 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.
- package/linkdesk.d.ts +322 -14
- 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 {
|
|
@@ -288,6 +369,22 @@ export interface LinkDeskLanguage {
|
|
|
288
369
|
label: string;
|
|
289
370
|
pluginId: string;
|
|
290
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
|
+
};
|
|
291
388
|
/** Theme + language + appearance asset namespace surfaces — modeled after the VS Code appearance surface */
|
|
292
389
|
export interface AppearanceAPI {
|
|
293
390
|
theme: {
|
|
@@ -344,6 +441,10 @@ export interface AppearanceAPI {
|
|
|
344
441
|
/** open the appearance storage directory (userData/appearance) — the main process resolves the path and uses shell.openPath to open the file explorer
|
|
345
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. */
|
|
346
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>;
|
|
347
448
|
};
|
|
348
449
|
}
|
|
349
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) */
|
|
@@ -356,6 +457,10 @@ export interface StorageAPI {
|
|
|
356
457
|
/** The absolute path of the currently effective cache directory — settings.json's `app.storage.cacheDir` (empty/missing = the userData default location);
|
|
357
458
|
* 🔴 the single resolution entry (placement contract iron rule 3: no second copy of the path is stored anywhere — take it, never copy it) */
|
|
358
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>;
|
|
359
464
|
};
|
|
360
465
|
}
|
|
361
466
|
/**
|
|
@@ -1452,6 +1557,17 @@ export interface DialogOpenOptions {
|
|
|
1452
1557
|
*/
|
|
1453
1558
|
defaultPathKind?: "appearance";
|
|
1454
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
|
+
}
|
|
1455
1571
|
/** rich-content confirm dialog open params—pool plugin → shell DialogService (addressed by content view declaration).
|
|
1456
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). */
|
|
1457
1573
|
export interface DialogContentOpenOptions {
|
|
@@ -1552,6 +1668,11 @@ export type PoolDialogData = {
|
|
|
1552
1668
|
renderPath: string;
|
|
1553
1669
|
/** Opaque serialized payload — travels with the open parameters through shell→back to pool (structured clone); used by the content view to fetch data */
|
|
1554
1670
|
payload?: unknown;
|
|
1671
|
+
} | {
|
|
1672
|
+
/** P1(D8 渲染槽):宿主内置内容视图 id(池内 `plugin-install-confirm` 注册表直挂,无需 renderPath)
|
|
1673
|
+
* ——壳默认渲染器用它;第三方整套替换时换 pluginId+renderPath 那一支。两支二选一。 */
|
|
1674
|
+
hostView: string;
|
|
1675
|
+
payload?: unknown;
|
|
1555
1676
|
};
|
|
1556
1677
|
};
|
|
1557
1678
|
/**
|
|
@@ -1578,8 +1699,9 @@ export interface PoolPendingDialog {
|
|
|
1578
1699
|
/** rich-content confirmation — content = a plugin's self-drawn view. Gives the **identity** (not renderPath: that is the pool-internal addressing key,
|
|
1579
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"). */
|
|
1580
1701
|
content?: {
|
|
1581
|
-
pluginId
|
|
1582
|
-
viewId
|
|
1702
|
+
pluginId?: string;
|
|
1703
|
+
viewId?: string; /** P1:宿主内置默认渲染器(无 pluginId/viewId——壳自带视图) */
|
|
1704
|
+
hostView?: string;
|
|
1583
1705
|
};
|
|
1584
1706
|
}
|
|
1585
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).
|
|
@@ -1734,6 +1856,10 @@ export interface UiAPI {
|
|
|
1734
1856
|
open(opts?: DialogOpenOptions): Promise<string | null>;
|
|
1735
1857
|
/** Opens the file picker — returns the user-selected path; cancel → null. Security is controlled by the main process */
|
|
1736
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>;
|
|
1737
1863
|
/** rich-content confirm — the dialog's content = a plugin self-drawn view (content view declarative addressing + opaque payload).
|
|
1738
1864
|
* Dialog mechanics match confirm (centered/mask/Esc/focus lock/click-mask-to-cancel); content layout and buttons are drawn by the plugin view
|
|
1739
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,
|
|
@@ -1915,6 +2041,20 @@ export interface WorkspaceFolder {
|
|
|
1915
2041
|
/** Index—the first opened folder is index=0 */
|
|
1916
2042
|
index: number;
|
|
1917
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
|
+
}
|
|
1918
2058
|
/** File/directory entry—shared by front and back ends */
|
|
1919
2059
|
export interface FileEntry {
|
|
1920
2060
|
name: string;
|
|
@@ -1983,6 +2123,12 @@ export interface WorkspaceAPI {
|
|
|
1983
2123
|
removeFolder(path: string): Promise<void>;
|
|
1984
2124
|
onDidChangeFolders(cb: () => void): () => void;
|
|
1985
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;
|
|
1986
2132
|
};
|
|
1987
2133
|
/** Filesystem — plugin read/write (path validation is performed by the main process) */
|
|
1988
2134
|
filesystem: {
|
|
@@ -2349,6 +2495,132 @@ export interface PluginUpdateCheckResult {
|
|
|
2349
2495
|
downloadUrl?: string;
|
|
2350
2496
|
update: boolean;
|
|
2351
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
|
+
}
|
|
2352
2624
|
/** Manifest serialization subset of list() — aligned with the projection fields of handlePluginsCall "list"
|
|
2353
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
|
|
2354
2626
|
* (the dependencies.ts engine runs only inside the shell; consumption goes through the list() projection). No requires = undefined.
|
|
@@ -2402,6 +2674,9 @@ export interface PluginInstallRequestOpts {
|
|
|
2402
2674
|
displayName?: string;
|
|
2403
2675
|
/** Job origin — row = one user action (user, default); dependencies dragged in by a plugin (dependency) hide inside that row */
|
|
2404
2676
|
origin?: "user" | "dependency";
|
|
2677
|
+
/** P1(spec §七):期望的包 sha256(小写 hex)——壳在**下载后、解压前**校验,不符即删包拒装。
|
|
2678
|
+
* 壳自己的确认链(`plugins.requestInstall`)必带;市场/手装可缺省(过渡期「未校验」不阻断)。 */
|
|
2679
|
+
sha256?: string;
|
|
2405
2680
|
/**
|
|
2406
2681
|
* R4-1.3(I21/壳侧·正典 09 §三·补3):目录条目的 pricing 声明随行——**声明进数据层、裁决进壳**。
|
|
2407
2682
|
* 调用方(市场插件)把它读到的条目 pricing 原样带上;壳安装门见 model 存在即查壳侧权益(licenses),
|
|
@@ -2519,7 +2794,9 @@ export interface PluginsAPI {
|
|
|
2519
2794
|
readAllManifests?(): Promise<Record<string, PluginManifest>>;
|
|
2520
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).
|
|
2521
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) */
|
|
2522
|
-
|
|
2797
|
+
/** P1 sha256(spec §七):传了就在**下载后、解压前**校验——不符即删包并拒装(`integrity-failed`)。
|
|
2798
|
+
* 缺省 = 过渡期「未校验」(旧目录条目没有 hash),不阻断。 */
|
|
2799
|
+
packageDownload?(url: string, job?: PluginInstallJobRef, sha256?: string): Promise<{
|
|
2523
2800
|
zipPath: string;
|
|
2524
2801
|
sizeBytes?: number;
|
|
2525
2802
|
}>;
|
|
@@ -2553,6 +2830,36 @@ export interface PluginsAPI {
|
|
|
2553
2830
|
version: string;
|
|
2554
2831
|
deferred?: boolean;
|
|
2555
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[]>;
|
|
2556
2863
|
};
|
|
2557
2864
|
/** Plugin management — bridges IpcBridgeHandler → loader functions. Pool-authoritative (consumed by marketplace plugins), required */
|
|
2558
2865
|
pluginManager: {
|
|
@@ -3276,16 +3583,17 @@ export interface UpdateAPI {
|
|
|
3276
3583
|
getState(): Promise<UpdateState>;
|
|
3277
3584
|
};
|
|
3278
3585
|
}
|
|
3279
|
-
/**
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
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;
|
|
3289
3597
|
/**
|
|
3290
3598
|
* 🔥 Canonical vocabulary for settings control hints (`uiHint`) — the single vocabulary between host declarations and the rendering layer (criterion B).
|
|
3291
3599
|
*
|
|
@@ -3301,7 +3609,7 @@ export type LinkDeskAPI = CommandsAPI & AppearanceAPI & StorageAPI & TabsAPI & K
|
|
|
3301
3609
|
* The runtime list and type guards live in `@linkdesk/ui` (`SETTINGS_UI_HINTS` / `isSettingsUiHint`) —
|
|
3302
3610
|
* this contract package is a **pure type-generation artifact with zero runtime** and can only carry types.
|
|
3303
3611
|
*/
|
|
3304
|
-
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";
|
|
3305
3613
|
/**
|
|
3306
3614
|
* Canonical render hint for settings rows (`renderHint`) — three values.
|
|
3307
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.
|
|
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
|
+
}
|