@linkdesk/contracts 0.1.45 → 0.1.47

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 +189 -11
  2. package/package.json +1 -1
package/linkdesk.d.ts CHANGED
@@ -983,14 +983,6 @@ export interface PoolStatusBarItem {
983
983
  /** Leading divider — shell StatusBar render semantics (every item except the first in the left zone; except the first within a group in the right zone) */
984
984
  dividerBefore?: boolean;
985
985
  }
986
- /**
987
- * a row for an install job — the **only** row shape of the panel's "In progress / Waiting to install" two sections (dossier 18 §5 I.4).
988
- *
989
- * **Why the results area is not here**: install terminal states (success / failure / installed but missing dependencies) are announced by the existing toasts
990
- * (success = the sole outlet of the lifecycle consumer; failure = the settle failure toast with [Retry], see 73h/73e);
991
- * the results area is still grouped by source (`NotifGroup`). Job rows appear only in the two sections "not yet resulted" —
992
- * one install is always visible in exactly one place, never "installed twice".
993
- */
994
986
  export interface NotifJobRow {
995
987
  /** Row key — jobId (**not** the display name: same-named plugins must stay distinguishable, dossier 18 §7 73d row). */
996
988
  id: string;
@@ -1134,6 +1126,31 @@ export type PoolCommandHints = Record<string, {
1134
1126
  title: string;
1135
1127
  keybinding?: string;
1136
1128
  }>;
1129
+ /** 轻 Toast 栈条目——壳 store `presentation:"toast"` 条目的 DTO(TransientToast 池侧哑渲染)。
1130
+ * 与面板 DTO(NotifItem)同源异面:一条条目只进一个面(2026-11-19 改判)。 */
1131
+ export interface ToastStackItem {
1132
+ id: string;
1133
+ key?: string;
1134
+ message: string;
1135
+ severity: "info" | "success" | "warning";
1136
+ /** 动作(最多 1 个)——command/args 由**池**执行(插件命令注册在池;未注册 → 点击只关闭 B10) */
1137
+ action?: {
1138
+ title: string;
1139
+ command?: string;
1140
+ args?: unknown[];
1141
+ };
1142
+ /** false = 隐藏 severity 图标(01 契约 §2 icon 形参);缺省/true = 恒显 */
1143
+ icon?: boolean;
1144
+ /** 到期时间戳(epoch ms)——池侧计时真相(B21 hover 暂停 / B34 最小化继续都按 time-based 判定;
1145
+ * 池侧 interval 比对 now 与本值,过期即经 dismissToastItem 回壳删条目)。壳侧已按同 key 合并/上限 3 裁剪。 */
1146
+ expiresAt: number;
1147
+ }
1148
+ /** 轻 Toast 栈 DTO——挂在 PoolLayout 顶层与 statusBar.notif 同帧推送(壳想池画)。空数组 = 无在显条目 */
1149
+ export interface ToastStackLayout {
1150
+ items: ToastStackItem[];
1151
+ /** × 按钮文案(壳 t("关闭")——显示文本铁律) */
1152
+ dismissLabel?: string;
1153
+ }
1137
1154
  export interface PoolLayout {
1138
1155
  version: 2;
1139
1156
  titleBar: TitleBarLayout;
@@ -1161,6 +1178,8 @@ export interface PoolLayout {
1161
1178
  hintEnabled?: boolean;
1162
1179
  /** 04 "hover hint system" piece 1: command table — source of the automatic copy and shortcuts for `data-hint-command`. Window-agnostic ⇒ always pushed. */
1163
1180
  commands?: PoolCommandHints;
1181
+ /** 轻 Toast 栈(2026-11-19 改判恢复)——主窗随 statusBar 同策略推;缺省 = 池不渲染 */
1182
+ toastStack?: ToastStackLayout;
1164
1183
  }
1165
1184
  /**
1166
1185
  * per-window tab list — produced by **the same serializer** (`serializeGroups`) as the layout tree pushed to the pool,
@@ -1314,6 +1333,49 @@ export interface NotificationHandle {
1314
1333
  /** Cancel — closes directly, no completion toast */
1315
1334
  cancel(): Promise<void>;
1316
1335
  }
1336
+ /** Light-toast action (toasts.show options.action, 01 contract §2) — the **serializable subset**: pool→shell IPC cannot carry closures,
1337
+ * so the click path is `command`/`args` only (shell executeCommand). The `onClick` slot of the 01 §2 table is the **in-shell same-process** face
1338
+ * (direct pushToast callers); it has no physical carrier on this cross-process surface. Unknown command → click just closes (02 B10, no error). */
1339
+ export interface ToastShowAction {
1340
+ /** Button label — final display text, resolved by the producer (display-text iron rule) */
1341
+ title: string;
1342
+ /** Command id run on click — executeCommand(command, ...args); unregistered → click just closes (B10) */
1343
+ command?: string;
1344
+ /** ...args passed through to the command handler */
1345
+ args?: unknown[];
1346
+ }
1347
+ /** toasts.show options (01 contract §2 verbatim, minus the in-shell-only onClick slot — see ToastShowAction) */
1348
+ export interface ToastShowOptions {
1349
+ /** 必填 — one-liner; >2 visual lines ⇒ auto-degrades to the panel (caller does not decide) */
1350
+ message: string;
1351
+ /** 去重键 — same key updates the existing entry (B16) instead of adding one; omitted = a new entry each call */
1352
+ key?: string;
1353
+ /** 缺省 info; ⚠️ error not accepted — auto-degrades to the panel (caller passes it anyway, routing decides) */
1354
+ severity?: "info" | "success" | "warning";
1355
+ /** 最多 1 个;>1 ⇒ panel(B9)。轻提示的常见形态是无动作 */
1356
+ action?: ToastShowAction;
1357
+ /** ms,缺省 3000,夹取 [1500,10000](B15);≥8000 ⇒ 面板(B14) */
1358
+ ttl?: number;
1359
+ /** 缺省 true 恒显 severity 图标;显式 false 隐藏(语义由文案承载) */
1360
+ icon?: boolean;
1361
+ /**
1362
+ * 生产者身份(notifications.show 的 source 同款约定)——轻 Toast 不进面板分组,
1363
+ * 但 02 表 B20「插件卸载 → 其来源条目立即清除」的**来源键**由此而来;缺省归「其他」桶。
1364
+ * ⚠️ 01 契约 §2 表未列此字段(立档时序),此处为 B20 判据的机械前置——与 notifications.source 同形。
1365
+ */
1366
+ source?: string;
1367
+ }
1368
+ /** Light-toast presentation — which surface the entry actually landed on (2026-11-19 改判: one store, two presentations) */
1369
+ export type ToastPresentation = "toast" | "panel";
1370
+ /** Light-toast handle — update/dismiss route back to the same entry; presentation reports where it actually landed */
1371
+ export interface ToastHandle {
1372
+ /** 更新同一条目文案(toast 呈现时 TTL 重置;panel 呈现时原位改写) */
1373
+ update(message: string): Promise<void>;
1374
+ /** 立即关闭 */
1375
+ dismiss(): Promise<void>;
1376
+ /** 只读:实际落在了哪个面 — 排障与断言用(⛔ 调用方预判降级的那把尺不给他用) */
1377
+ readonly presentation: ToastPresentation;
1378
+ }
1317
1379
  /** A menu item declared by a plugin in plugin.json—either a command or a submenu, never both */
1318
1380
  export type ManifestMenuItem = string | {
1319
1381
  command: string;
@@ -1350,6 +1412,10 @@ export interface MenuItemDescriptor {
1350
1412
  * **the end** is the shared component's context"; ⛔ do not assume `args[0]` is necessarily your data (unless that slot has no shared context).
1351
1413
  */
1352
1414
  commandArgs?: unknown[];
1415
+ /** F14 配套(16 号档 · 2026-11-21):**进程内注入项**的池侧回调——有值则点击就地在池内执行,
1416
+ * 不走壳命令(ContextMenu 分发先查 onSelect 再 executeCommand)。仅 `items` prop 直注形态可用
1417
+ * (wire 菜单 getItems 不能携带函数——跨 IPC 只走 command/commandArgs)。 */
1418
+ onSelect?: () => void;
1353
1419
  children?: Array<string | MenuItemDescriptor>;
1354
1420
  }
1355
1421
  /**
@@ -1621,6 +1687,17 @@ export interface UiAPI {
1621
1687
  */
1622
1688
  subscribe(cb: () => void): () => void;
1623
1689
  };
1690
+ /**
1691
+ * 轻 Toast(TransientToast)——2026-11-19 用户授权改判恢复的第二呈现面(同一 store、不同名、不同角落)。
1692
+ * 分工判据(00 §二):**Toast 是「路过」,面板是「留存」**——短、轻、无动作/1 动作的一句话走这里;
1693
+ * 错误/需决策/进度/长文本仍走 `notifications`(自动降级路由,调用方不预判)。
1694
+ * 🔴 ⛔ 不用已删的顶层单数 `toast` 旧名(死面,名字带历史包袱);⛔ 第二个 store(与 notifications 同一后端队列)。
1695
+ */
1696
+ toasts: {
1697
+ /** Raises a light toast — returns a handle (update/dismiss/presentation). Degradation rules are pure-function
1698
+ * routed on the shell (01 §3): error / >1 action / >96 visual units / ttl ≥8000 / >2 explicit lines ⇒ panel. */
1699
+ show(options: ToastShowOptions): Promise<ToastHandle>;
1700
+ };
1624
1701
  /** Menus — declarative read/write for plugins */
1625
1702
  menu: {
1626
1703
  registerItems(menuId: string, pluginId: string, items: ManifestMenuItem[]): Promise<void>;
@@ -1845,6 +1922,12 @@ export interface EnvInfo {
1845
1922
  pluginDataDir?: string;
1846
1923
  pluginCacheDir?: string;
1847
1924
  pluginExportsDir?: string;
1925
+ /**
1926
+ * R4-1.3(I21·正典 09 §三·补3):机器指纹——MachineGuid+主板序列 sha256 前 16 位(主进程组装)。
1927
+ * 稳定性:两输入均为装机/出厂即定值(OS 安装时生成的 MachineGuid + 主板烧录序列),重启/换端口不变。
1928
+ * 消费方 = 许可验签的机器绑定比对(作者 kit `sign-license --machine` 决定绑不绑)。
1929
+ */
1930
+ machineFingerprint?: string;
1848
1931
  }
1849
1932
  /** IPC search:searchFiles payload—the wire subset of FileSearcher.SearchOptions (no signal) */
1850
1933
  export interface SearchWireOptions {
@@ -2301,6 +2384,16 @@ export interface PluginInstallRequestOpts {
2301
2384
  displayName?: string;
2302
2385
  /** Job origin — row = one user action (user, default); dependencies dragged in by a plugin (dependency) hide inside that row */
2303
2386
  origin?: "user" | "dependency";
2387
+ /**
2388
+ * R4-1.3(I21/壳侧·正典 09 §三·补3):目录条目的 pricing 声明随行——**声明进数据层、裁决进壳**。
2389
+ * 调用方(市场插件)把它读到的条目 pricing 原样带上;壳安装门见 model 存在即查壳侧权益(licenses),
2390
+ * 无有效许可 ⇒ licenseRequired 拦下。缺省/不带 = 免费(现状行为零变更)。
2391
+ * ⚠️ v1 边界(09「边界与代价」自认):无服务器 ⇒ 调用方可不带 ⇒ 深度对抗强制留 B3——本门保证的是
2392
+ * 官方面不漏门 + 权益与门都在壳(市场被整体替换也绕不过门的存在)。
2393
+ */
2394
+ pricing?: {
2395
+ model?: string;
2396
+ };
2304
2397
  /**
2305
2398
  * dependency resolution catalog — when passed, **missing** dependencies in this plugin's `requires` are
2306
2399
  * auto-installed first by the shell **within the same install job** (inline recursion, no second slot — dependency resolution reuses updateCheck against this catalog for the latest direct link).
@@ -2321,8 +2414,11 @@ export interface PluginInstallResult {
2321
2414
  version?: string;
2322
2415
  needRestart?: boolean;
2323
2416
  error?: string;
2417
+ /** R4-1.3(I21/壳侧·正典 09 §三·补3):安装门拦下——**不是失败是缺许可**。true = 该条目声明了
2418
+ * pricing.model 而壳侧权益存储无有效许可(消费方据此开许可弹窗,⛔ 不走失败红字分支)。 */
2419
+ licenseRequired?: boolean;
2324
2420
  /** (archive 18 §V I.6-7): the third terminal state — **installed but missing dependencies** (it is installed, shows in the list, but is unusable).
2325
- * When true, success is also true (the files really did land on disk), but consumers **must not render it as "✓ installed"** — that would be lying.
2421
+ * When true, success is also true (the files really did land on disk), but consumers **must not** render it as "✓ installed" — that would be lying.
2326
2422
  * The job row shows "installed but missing dependencies: {name}". */
2327
2423
  parked?: boolean;
2328
2424
  /** the user clicked "Cancel install" on the panel — **not a failure** (`success` being false just means "the install did not happen").
@@ -2330,6 +2426,26 @@ export interface PluginInstallResult {
2330
2426
  * reporting the error again would weaponize the user's own decision against them. The job row is **removed entirely** by the queue side (no ✗ rendered). */
2331
2427
  cancelled?: boolean;
2332
2428
  }
2429
+ /** R4-1.2(I16·正典 09 §三·补2):本地安装失败回执 reason——五类封闭集合 */
2430
+ export type PluginLocalInstallReason = "bad-manifest" | "unsafe-id" | "core-forbidden" | "exists" | "io";
2431
+ /**
2432
+ * R4-1.2(I16·正典 09 §三·补2):`pluginManager.installFromDirectory(path)` 回执。
2433
+ * 输入 = 含 plugin.json 的单插件文件夹,或 .linkdesk-plugin 离线包(解压走包安装流同一路);
2434
+ * 落盘 = {userData}/plugins/<pluginId>(用户安装家,与网络安装同路:账本 → 注册 → lifecycle,⛔ 不旁路)。
2435
+ * `reason` 封闭五类(09 正典):bad-manifest=plugin.json 缺失/不可解析/缺 version;unsafe-id=pluginId
2436
+ * 形状不合法(SAFE_PLUGIN_ID)或撞宿主伪身份;core-forbidden=本地不得自封内置;exists=同 id 已装
2437
+ * (调用方确认覆盖——先卸载再装);io=复制/解压/磁盘失败。成功面附带 version/parked/needRestart 透传。
2438
+ */
2439
+ export interface PluginLocalInstallResult {
2440
+ ok: boolean;
2441
+ pluginId?: string;
2442
+ version?: string;
2443
+ reason?: PluginLocalInstallReason;
2444
+ /** loadInstalledPlugin needRestart 透传(同会话曾加载过 ⇒ 池缓存旧 bundle) */
2445
+ needRestart?: boolean;
2446
+ /** 已落盘但缺依赖(loadPlugin park)透传——文件在、不可用 */
2447
+ parked?: boolean;
2448
+ }
2333
2449
  /** Disabled/uninstalled list entry — the serialized shape of loader getDisabledPluginInfo/getUninstalledPluginInfo (a further subset of PluginListSubset)
2334
2450
  * the core flag passes through — list() EXCLUDES disabled plugins; the disabled-state detail page's uninstall button honors "no uninstall button on the detail page for core:true"
2335
2451
  * and core can only be obtained here (read from the cached manifest; a purely additive optional field, zero regression).
@@ -2426,8 +2542,16 @@ export interface PluginsAPI {
2426
2542
  enable(id: string): Promise<unknown>;
2427
2543
  disable(id: string): Promise<unknown>;
2428
2544
  uninstall(id: string): Promise<unknown>;
2429
- /** opts carries the requester-side identity (pluginId/displayName/origin) — job table dedup + job row display name */
2545
+ /** opts carries the requester-side identity (pluginId/displayName/origin) — job table dedup + job row display name.
2546
+ * R4-1.3: opts.pricing 随行(目录条目声明)——壳安装门见 model 存在即查权益,无 ⇒ licenseRequired 拦下。 */
2430
2547
  install(path: string, opts?: PluginInstallRequestOpts): Promise<PluginInstallResult>;
2548
+ /**
2549
+ * R4-1.2(I16·正典 09 §三·补2):本地安装——含 plugin.json 的单插件文件夹或 .linkdesk-plugin 离线包,
2550
+ * 复制进 {userData}/plugins/<pluginId> → 账本 → 注册 → lifecycle(与网络安装同一路,⛔ 不旁路)。
2551
+ * 五类回执见 PluginLocalInstallReason;同 id 已装回 `reason:"exists"`(覆盖 = 调用方先卸载再装)。
2552
+ * 拒 core:true(本地不得自封内置)。⛔ 不做多插件目录(09 v2 再议)。
2553
+ */
2554
+ installFromDirectory?(path: string, opts?: PluginInstallRequestOpts): Promise<PluginLocalInstallResult>;
2431
2555
  /** (1.2-5): the explicit name for the url/.linkdesk-plugin package install flow (installPlugin routing alias; identical on both the shell and pool preloads — the pool proxies via plugins:call). Progress goes through the plugin:installProgress channel */
2432
2556
  installWithProgress?(path: string, opts?: PluginInstallRequestOpts): Promise<PluginInstallResult>;
2433
2557
  reinstall(id: string): Promise<unknown>;
@@ -2447,6 +2571,51 @@ export interface PluginsAPI {
2447
2571
  notifyManifestChanged?(): void;
2448
2572
  };
2449
2573
  }
2574
+ /** 验签失败原因——封闭集合(消费方照原因出文案;⛔ reason 存在时 valid 恒 false) */
2575
+ export type LicenseVerifyFailureReason = "bad-key-format" // 密钥串不是 v1.<payload>.<sig> 形状 / payload 非 JSON / 缺 pluginId
2576
+ | "bad-public-key" // publicKey 解不出 Ed25519 公钥(作者块字段缺失或损坏)
2577
+ | "bad-signature" // 签名对不上(密钥被改/公钥不是签发者)
2578
+ | "expired" // 载荷 exp 已过
2579
+ | "machine-mismatch"; // 载荷绑机器 ≠ 本机指纹
2580
+
2581
+ /**
2582
+ * licenses.verify 回执——valid=true 时壳已把权益写入壳侧存储(licenses.json);
2583
+ * valid=false 时 failureReason 必带、pluginId/exp 尽力回带(解出多少带多少)。
2584
+ */
2585
+ export interface LicenseVerifyResult {
2586
+ valid: boolean;
2587
+ pluginId?: string;
2588
+ exp?: number;
2589
+ /** 载荷带 machine = 签发者绑了机器(记录留痕用) */
2590
+ machineBound?: boolean;
2591
+ failureReason?: LicenseVerifyFailureReason;
2592
+ }
2593
+ /** 权益记录——壳侧 licenses.json 一条(09 §三·补3:权益记录住壳,市场被整体替换仍在) */
2594
+ export interface LicenseEntitlement {
2595
+ pluginId: string;
2596
+ /** 载荷 exp 透传(undefined = 永久)——临期/过期徽标与安装门失效判定都读它 */
2597
+ exp?: number;
2598
+ /** 验签时载荷是否绑机器(留痕;本机指纹不落盘明文存——记录只记「绑没绑」) */
2599
+ machineBound?: boolean;
2600
+ /** 验签通过时刻 ISO */
2601
+ verifiedAt: string;
2602
+ }
2603
+ /** Licenses namespace surfaces — 壳 preload 直答主进程;池插件经 plugins:call 代理同面 */
2604
+ export interface LicensesAPI {
2605
+ licenses: {
2606
+ /**
2607
+ * 验签并入库——key = 作者 kit 签发的许可密钥;publicKey = 目录作者块 `authors/<id>.json` 的
2608
+ * `publicKey` 字段(市场插件已拉取作者块——壳无目录上下文,公钥经调用随行;这是 09 `verify(key)`
2609
+ * 一参速记的实现展开,理由:壳不拉目录,公钥只能由唯一读者——市场——喂入)。
2610
+ * valid=true 时壳侧已写权益(幂等:重复验同密钥 = 刷新 verifiedAt)。
2611
+ */
2612
+ verify(key: string, publicKey: string): Promise<LicenseVerifyResult>;
2613
+ /** 全量权益——市场「已购未安装」分区与临期/过期徽标的数据源(⛔ v1 不做集中管理列表 UI——用户拍板) */
2614
+ list(): Promise<LicenseEntitlement[]>;
2615
+ /** 移除某插件的权益记录(用户主动清除;安装门随即重新拦) */
2616
+ remove(pluginId: string): Promise<void>;
2617
+ };
2618
+ }
2450
2619
  /**
2451
2620
  * Bridge request envelope contract—
2452
2621
  *
@@ -3098,7 +3267,7 @@ export interface UpdateAPI {
3098
3267
  * cross-composed from 15 namespace domain interfaces (interface→type intersection;
3099
3268
  * index access such as LinkDeskAPI["pool"]/["configuration"] keeps the consumer contract unchanged).
3100
3269
  */
3101
- export type LinkDeskAPI = CommandsAPI & AppearanceAPI & StorageAPI & TabsAPI & KeybindingsAPI & UiAPI & DataAPI & WorkspaceAPI & EditorAPI & PluginsAPI & ShellAPI & PanelAPI & SettingsAPI & FactorySlotsAPI & AppAPI & UpdateAPI;
3270
+ export type LinkDeskAPI = CommandsAPI & AppearanceAPI & StorageAPI & TabsAPI & KeybindingsAPI & UiAPI & DataAPI & WorkspaceAPI & EditorAPI & PluginsAPI & LicensesAPI & ShellAPI & PanelAPI & SettingsAPI & FactorySlotsAPI & AppAPI & UpdateAPI;
3102
3271
  /**
3103
3272
  * 🔥 Canonical vocabulary for settings control hints (`uiHint`) — the single vocabulary between host declarations and the rendering layer (criterion B).
3104
3273
  *
@@ -3124,6 +3293,15 @@ export type SettingsUiHint = "themePicker" | "select" | "accentSource" | "slider
3124
3293
  * `statusCommand`/`actionCommand` can coexist with **any** primary control (rendering `[primary control][companion button][companion read-only]`).
3125
3294
  */
3126
3295
  export type SettingsRenderHint = "readonly" | "action" | "color";
3296
+ /** 许可密钥签名载荷——kit `sign-license`(棒 11)签什么、壳就验什么(09 正典三字段,⛔ 不私加必填项) */
3297
+ export interface LicenseKeyPayload {
3298
+ /** 授权目标插件——payload 自描述(verify 只吃 key 也能知道为谁授权) */
3299
+ pluginId: string;
3300
+ /** 机器指纹(`env.machineFingerprint`,sha256 前 16 位)——可选:不带 = 不绑机器 */
3301
+ machine?: string;
3302
+ /** 过期时刻(unix 秒)——可选:不带 = 永久 */
3303
+ exp?: number;
3304
+ }
3127
3305
  /**
3128
3306
  * "Open with" request — the sole input shape of the shell command `SHELL_COMMANDS.openWith`.
3129
3307
  * Give at least one of `uri` and `ext`: the context-menu/editor entry provides `uri` (the shell computes `ext`); the settings page's "open by type" entry provides only `ext`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@linkdesk/contracts",
3
- "version": "0.1.45",
3
+ "version": "0.1.47",
4
4
  "description": "LinkDesk 插件契约类型——window.linkdesk.* 全量类型定义(E5.8 契约生成产物)。第三方插件作者唯一合法类型消费路径。",
5
5
  "type": "module",
6
6
  "types": "./linkdesk.d.ts",