@binblink/wasmnest-plugin-sdk-mobile 0.0.0-stage → 0.0.2

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 (122) hide show
  1. package/README.md +439 -2
  2. package/README_en.md +415 -0
  3. package/bin/build.js +271 -0
  4. package/bin/cli.js +96 -0
  5. package/bin/lib.js +349 -0
  6. package/bin/manifest-gen.js +327 -0
  7. package/bin/package.js +151 -0
  8. package/bin/scaffold.js +299 -0
  9. package/dev-shell/README.md +151 -0
  10. package/dev-shell/index.html +27 -0
  11. package/dev-shell/package.json +27 -0
  12. package/dev-shell/pnpm-workspace.yaml +9 -0
  13. package/dev-shell/postcss.config.js +6 -0
  14. package/dev-shell/src/App.vue +90 -0
  15. package/dev-shell/src/apps/mock-terminal/MockTerminalSlotCard.vue +43 -0
  16. package/dev-shell/src/apps/mock-terminal/MockTerminalView.vue +168 -0
  17. package/dev-shell/src/apps/mock-terminal/index.ts +50 -0
  18. package/dev-shell/src/components/DevToolbar.vue +100 -0
  19. package/dev-shell/src/components/DialogHost.vue +119 -0
  20. package/dev-shell/src/components/LogPanel.vue +80 -0
  21. package/dev-shell/src/i18n.ts +22 -0
  22. package/dev-shell/src/loader.ts +239 -0
  23. package/dev-shell/src/locale.ts +29 -0
  24. package/dev-shell/src/locales/en-shell.ts +332 -0
  25. package/dev-shell/src/locales/index.ts +70 -0
  26. package/dev-shell/src/locales/shell.ts +331 -0
  27. package/dev-shell/src/main.ts +58 -0
  28. package/dev-shell/src/mock/dialog-service.ts +58 -0
  29. package/dev-shell/src/mock/file-transfer.ts +390 -0
  30. package/dev-shell/src/mock/mobile-api.ts +369 -0
  31. package/dev-shell/src/mock/preset-tasks.ts +186 -0
  32. package/dev-shell/src/mock/session.ts +121 -0
  33. package/dev-shell/src/mock-context.ts +374 -0
  34. package/dev-shell/src/registry.ts +151 -0
  35. package/dev-shell/src/shared-runtime.ts +44 -0
  36. package/dev-shell/src/shell/ShellView.vue +52 -0
  37. package/dev-shell/src/shell/adapters/devAppSource.ts +144 -0
  38. package/dev-shell/src/shell/components/PluginContextHost.vue +40 -0
  39. package/dev-shell/src/shell/components/ShellAppCell.vue +75 -0
  40. package/dev-shell/src/shell/components/ShellAppIcon.vue +111 -0
  41. package/dev-shell/src/shell/components/ShellAppSurface.vue +46 -0
  42. package/dev-shell/src/shell/components/ShellBrandTile.vue +27 -0
  43. package/dev-shell/src/shell/components/ShellCapsuleMenu.vue +123 -0
  44. package/dev-shell/src/shell/components/ShellChip.vue +49 -0
  45. package/dev-shell/src/shell/components/ShellGroupCard.vue +17 -0
  46. package/dev-shell/src/shell/components/ShellHost.vue +75 -0
  47. package/dev-shell/src/shell/components/ShellNotificationShade.vue +501 -0
  48. package/dev-shell/src/shell/components/ShellPermissionPrompt.vue +127 -0
  49. package/dev-shell/src/shell/components/ShellPlaceholderSurface.vue +33 -0
  50. package/dev-shell/src/shell/components/ShellSection.vue +27 -0
  51. package/dev-shell/src/shell/components/ShellSheet.vue +74 -0
  52. package/dev-shell/src/shell/components/ShellStatusbar.vue +84 -0
  53. package/dev-shell/src/shell/components/screens/PluginRoutePage.vue +98 -0
  54. package/dev-shell/src/shell/components/screens/ShellAppDetailScreen.vue +359 -0
  55. package/dev-shell/src/shell/components/screens/ShellAppRunScreen.vue +90 -0
  56. package/dev-shell/src/shell/components/screens/ShellAppsScreen.vue +195 -0
  57. package/dev-shell/src/shell/components/screens/ShellHomeScreen.vue +357 -0
  58. package/dev-shell/src/shell/components/screens/ShellPermissionsScreen.vue +376 -0
  59. package/dev-shell/src/shell/components/screens/ShellSettingsScreen.vue +240 -0
  60. package/dev-shell/src/shell/components/screens/ShellSwitcherScreen.vue +559 -0
  61. package/dev-shell/src/shell/components/ui/ConfirmDialog.vue +137 -0
  62. package/dev-shell/src/shell/components/ui/Toggle.vue +53 -0
  63. package/dev-shell/src/shell/composables/useShellApps.ts +417 -0
  64. package/dev-shell/src/shell/composables/useShellNavigation.ts +197 -0
  65. package/dev-shell/src/shell/composables/useShellNotifications.ts +115 -0
  66. package/dev-shell/src/shell/composables/useShellOpen.ts +44 -0
  67. package/dev-shell/src/shell/composables/useShellOverlays.ts +101 -0
  68. package/dev-shell/src/shell/composables/useShellPreferences.ts +143 -0
  69. package/dev-shell/src/shell/composables/useShellRecent.ts +84 -0
  70. package/dev-shell/src/shell/composables/useSlotCarousel.ts +238 -0
  71. package/dev-shell/src/shell/composables/useToast.ts +33 -0
  72. package/dev-shell/src/shell/index.ts +88 -0
  73. package/dev-shell/src/shell/logger.ts +45 -0
  74. package/dev-shell/src/shell/permissions.ts +145 -0
  75. package/dev-shell/src/shell/registry.ts +220 -0
  76. package/dev-shell/src/shell/slotCards.ts +47 -0
  77. package/dev-shell/src/shell/styles/shell.css +1155 -0
  78. package/dev-shell/src/shell/surfaceIntent.ts +107 -0
  79. package/dev-shell/src/shell/types.ts +152 -0
  80. package/dev-shell/src/shell/utils.ts +54 -0
  81. package/dev-shell/src/styles/main.css +153 -0
  82. package/dev-shell/src/styles/mobile.css +981 -0
  83. package/dev-shell/src/styles/wallpaper.css +130 -0
  84. package/dev-shell/src/theme.ts +71 -0
  85. package/dev-shell/src/vite-env.d.ts +20 -0
  86. package/dev-shell/tailwind.config.js +101 -0
  87. package/dev-shell/tsconfig.json +16 -0
  88. package/dev-shell/vite.config.ts +130 -0
  89. package/dist/index.d.ts +124 -0
  90. package/dist/index.js +229 -0
  91. package/dist/types.d.ts +738 -0
  92. package/dist/types.js +0 -0
  93. package/dist/vite-plugin.d.ts +16 -0
  94. package/dist/vite-plugin.js +95 -0
  95. package/package.json +88 -3
  96. package/src/constants.ts +6 -0
  97. package/src/global-dialog.ts +168 -0
  98. package/src/index.ts +96 -0
  99. package/src/runtime.ts +44 -0
  100. package/src/types.ts +822 -0
  101. package/src/ui/AppUpdateSection.d.ts +44 -0
  102. package/src/ui/AppUpdateSection.vue +253 -0
  103. package/src/ui/PluginGlobalDialog.vue +388 -0
  104. package/src/ui/QuickCard.d.ts +33 -0
  105. package/src/ui/QuickCard.vue +167 -0
  106. package/src/ui/Select.d.ts +37 -0
  107. package/src/ui/Select.vue +307 -0
  108. package/src/ui/plugin-global-dialog.d.ts +11 -0
  109. package/src/ui/useSwipeTabs.d.ts +20 -0
  110. package/src/ui/useSwipeTabs.ts +53 -0
  111. package/src/update.ts +123 -0
  112. package/src/vite-plugin.ts +132 -0
  113. package/template/.gitignore +4 -0
  114. package/template/README.md +46 -0
  115. package/template/package.json +23 -0
  116. package/template/plugin.json +13 -0
  117. package/template/rust/Cargo.toml +19 -0
  118. package/template/rust/src/lib.rs +33 -0
  119. package/template/src/env.d.ts +24 -0
  120. package/template/src/index.ts +37 -0
  121. package/template/tsconfig.json +17 -0
  122. package/template/vite.config.ts +21 -0
package/src/types.ts ADDED
@@ -0,0 +1,822 @@
1
+ /**
2
+ * @binblink/wasmnest-plugin-sdk-mobile 类型定义
3
+ *
4
+ * 移动端插件开发者可用的所有公开类型
5
+ */
6
+
7
+ // ==================== 基础类型 ====================
8
+
9
+ /** Disposable 接口 */
10
+ export interface Disposable {
11
+ dispose(): void
12
+ }
13
+
14
+ /** 插件类型 */
15
+ /**
16
+ * 插件产物形态(语言无关三形态,2026-10-26 语义重定义,wasmnest-apps#21)
17
+ *
18
+ * 词汇只表达形态(是否携带 wasm 后端 / 前端产物),不表达后端语言。
19
+ * 旧值 rust / rust-ts / ts-only / wasm 已退役:scaffold 校验点名拒绝并给出迁移出路。
20
+ */
21
+ export type PluginType = 'frontend' | 'backend' | 'full'
22
+
23
+ /** 插件运行时状态
24
+ *
25
+ * 取值口径(2026-10-14 对齐):真源 = 共享 crate `wasmnest-wasm-core/src/manifest.rs` 的
26
+ * `PluginState`,其 serde 属性为 `#[serde(tag = "state", rename_all = "camelCase")]`——
27
+ * 线上 JSON 是 **camelCase**(`{state:'activated'}` / `{state:'needsApproval'}` …)。
28
+ * 旧声明写成 PascalCase(`'Activated'`),与后端序列化不一致:宿主前端按 PascalCase 分支
29
+ * 判断时永远命中不了,表现为「应用明明在跑,壳里显示 0 个运行中 / 未启动」。
30
+ * 改动词表时先改共享 crate,再同步本类型与两端消费者。 */
31
+ export type PluginState =
32
+ | { state: 'loaded' }
33
+ | { state: 'activating' }
34
+ | { state: 'activated' }
35
+ | { state: 'degraded'; error: string }
36
+ | { state: 'needsApproval' }
37
+ | { state: 'deactivated' }
38
+ | { state: 'error'; error: string }
39
+
40
+ /**
41
+ * 适配平台(manifest `platform` 字段,必填)
42
+ *
43
+ * 三值:`desktop`(仅桌面)/ `mobile`(仅移动)/ `both`(双端适配)。
44
+ * 宿主在加载 / zip 安装期按本端校验:桌面拒 `mobile`、移动拒 `desktop`,
45
+ * `both` 两端均可装载(真源 SDK `rust/src/types.rs::PluginPlatform`)。
46
+ */
47
+ export type PluginPlatform = 'desktop' | 'mobile' | 'both'
48
+
49
+ /** manifest `update` 段:应用更新源声明(缺省 = 不参与更新检查) */
50
+ export interface PluginUpdateDecl {
51
+ /** 更新来源类型;当前只支持 `github-release` */
52
+ provider?: 'github-release'
53
+ /** GitHub 仓库 `owner/name`;缺省 = 官方应用仓 `7ZAI/wasmnest-apps` */
54
+ repo?: string
55
+ /** Release tag 前缀(完整形态 `<tagPrefix>v<X.Y.Z>`);缺省 `<slug>-` */
56
+ tagPrefix?: string
57
+ /** Release 资产前缀(`<slug>-<end>-v<version>.zip`);缺省 = 插件 id 末段 */
58
+ slug?: string
59
+ }
60
+
61
+ /** 插件描述文件结构 */
62
+ export interface PluginManifest {
63
+ id: string
64
+ name: string
65
+ version: string
66
+ /**
67
+ * 适配平台:`desktop`(仅桌面)/ `mobile`(仅移动)/ `both`(双端适配)。
68
+ *
69
+ * **必填**(与 id/name/version 同档):宿主加载 / 安装时校验声明必须覆盖
70
+ * 当前端,不匹配即 fail-visible 拒绝装载。
71
+ */
72
+ platform: PluginPlatform
73
+ description: string
74
+ author: string
75
+ main: string
76
+ pluginType: PluginType
77
+ permissions: string[]
78
+ contributes: MobilePluginContributes
79
+ /** 插件图标:emoji、内联 <svg> 标记或相对插件目录的图片路径,缺省时前端生成字母头像回退 */
80
+ icon?: string
81
+ wasmHash?: string
82
+ rustLibrary?: string
83
+ /** 启用前预授权目录(宿主 preauthorize 统一弹窗,支持 ${downloads} 模板) */
84
+ preauthDirs?: string[]
85
+ /** 外网访问预授权 URL 声明(Egress L2 glob:`[scheme://][*.]host[:port][/path-prefix]`) */
86
+ preauthUrls?: string[]
87
+ /**
88
+ * 应用更新源声明(manifest `update`;缺省 = 不参与更新检查)
89
+ *
90
+ * 宿主按本段解析 GitHub 发布仓 / tag 前缀 / 资产 slug;缺省字段收敛到官方
91
+ * 应用仓命名约定。第三方应用可声明自己的 repo / tagPrefix / slug。
92
+ */
93
+ update?: PluginUpdateDecl
94
+ }
95
+
96
+ /** 移动端扩展点声明 */
97
+ export interface MobilePluginContributes {
98
+ commands: CommandContribution[]
99
+ views: ViewContribution[]
100
+ terminal?: TerminalContribution
101
+ navTab?: NavTabContribution
102
+ settings?: SettingsContribution
103
+ /** 动态路由扩展点(activate 时经 ui.registerRoute 注册,宿主 addRoute) */
104
+ routes?: RouteContribution[]
105
+ configuration?: PluginConfiguration
106
+ lifecycle?: LifecycleContribution
107
+ /** 自定义监控面板声明(monitor 统一壳消费;实现住提供方应用工程) */
108
+ monitorPanels?: MonitorPanelContribution[]
109
+ }
110
+
111
+ /** 自定义监控面板声明(只登记元数据) */
112
+ export interface MonitorPanelContribution {
113
+ id: string
114
+ title: string
115
+ /** 排序权重(小者靠前;缺省 100) */
116
+ order?: number
117
+ }
118
+
119
+ /** 命令扩展点 */
120
+ export interface CommandContribution {
121
+ id: string
122
+ title: string
123
+ icon?: string
124
+ }
125
+
126
+ /** 视图扩展点 */
127
+ export interface ViewContribution {
128
+ id: string
129
+ type: 'toolbox'
130
+ title: string
131
+ component: string
132
+ }
133
+
134
+ /** 底部导航 Tab 扩展点 */
135
+ export interface NavTabContribution {
136
+ id: string
137
+ title: string
138
+ icon: string
139
+ component: string
140
+ order?: number
141
+ }
142
+
143
+ /** 设置页扩展点 */
144
+ export interface SettingsContribution {
145
+ section: string
146
+ component: string
147
+ }
148
+
149
+ /** 路由扩展点声明(manifest 声明,宿主按 id 命名空间挂载动态路由) */
150
+ export interface RouteContribution {
151
+ id: string
152
+ title?: string
153
+ component: string
154
+ }
155
+
156
+ /** 终端扩展点(inputHandlers/outputParsers 已随票 15 阶段 B 退役——terminal-hooks 删面) */
157
+ export interface TerminalContribution {
158
+ toolbarItems: TerminalToolbarItemContribution[]
159
+ }
160
+
161
+ /** 终端工具栏按钮 */
162
+ export interface TerminalToolbarItemContribution {
163
+ id: string
164
+ title: string
165
+ icon: string
166
+ }
167
+
168
+ /** 插件配置声明 */
169
+ export interface PluginConfiguration {
170
+ title: string
171
+ properties: Record<string, ConfigProperty>
172
+ }
173
+
174
+ /** 配置属性 */
175
+ export interface ConfigProperty {
176
+ type: 'string' | 'number' | 'boolean'
177
+ title: string
178
+ description?: string
179
+ default?: any
180
+ }
181
+
182
+ /** 生命周期声明(onTerminalInput/onTerminalOutput 已随票 15 阶段 B 退役) */
183
+ export interface LifecycleContribution {
184
+ onStartup?: boolean
185
+ onShutdown?: boolean
186
+ onAuthSuccess?: boolean
187
+ onDisconnect?: boolean
188
+ onSessionCreated?: boolean
189
+ onSessionStopped?: boolean
190
+ }
191
+
192
+ // ==================== UI 描述符 ====================
193
+ //
194
+ // 票 2026-10-10 批次 C2:`ToolboxPageDescriptor` / `TerminalViewContribution` /
195
+ // `NavTabDescriptor` / `TerminalToolbarItemDescriptor` 及其对应注册方法已整面退役
196
+ // (宿主壳只认 `registerSurface` 一种运行面形态)。保留位仅供旧版本插件对照报错。
197
+
198
+ /** 插件路由描述符:整体路由由插件决定(openPage 跳转);id 即路径段,可含 '/' 支持深路径 */
199
+ export interface PluginRouteDescriptor {
200
+ /** 路由 id(路径段),宿主挂到 /mobile/plugins/{pluginId}/{id} */
201
+ id: string
202
+ /** 宿主页头标题(header 为真时展示) */
203
+ title?: string
204
+ component: any
205
+ /** 是否渲染宿主页头(back + title),默认 true;false 时插件自带布局 */
206
+ header?: boolean
207
+ }
208
+
209
+ // ==================== 宿主壳(Host Shell)贡献描述符 ====================
210
+ // 契约形状与宿主 `src/shell/types.ts` 逐字段一致(插件侧不 import 宿主代码,
211
+ // 数据经宿主壳 registry 双写投影)。appId 一律 = 插件 id,由宿主 context 代填。
212
+
213
+ /** 宿主壳运行面:应用在壳(/mobile/shell)内被打开时挂载的整页界面 */
214
+ export interface ShellSurfaceContribution {
215
+ /** 运行面组件;壳透传 { app } prop(应用元数据,可忽略) */
216
+ component: any
217
+ /** 应用自带主题色(仅作用于应用内部,绝不写回平台 token) */
218
+ accent?: string
219
+ }
220
+
221
+ /**
222
+ * 应用内入口意图(宿主 → 本应用运行面)
223
+ *
224
+ * 宿主**不解释** `key` / `payload`:只负责把应用给的意图原样投递给同一应用的
225
+ * 运行面(`context.ui.onSurfaceIntent`)。载荷留在同进程,不做序列化,可传任意
226
+ * 对象;形状与含义全归应用自持(宿主判据 B1–B6 均不命中)。
227
+ */
228
+ export interface ShellSurfaceIntent {
229
+ /** 应用自定义入口键(如 'session' / 'settings') */
230
+ key: string
231
+ /** 应用自定义载荷(宿主不读取、不复制) */
232
+ payload?: unknown
233
+ }
234
+
235
+ /** 宿主壳首页快捷卡片(应用自持内容,如「N 个活跃会话」) */
236
+ export interface ShellSlotContribution {
237
+ id: string
238
+ /**
239
+ * 卡片组件;壳透传 { app } prop。
240
+ *
241
+ * 卡片外观建议用 `@binblink/wasmnest-plugin-sdk-mobile/ui/quick-card` 的
242
+ * QuickCard(与宿主 token / 字号 / 明暗一致)。壳把整张卡渲染成按钮并负责
243
+ * 点击打开本应用——卡片内不得再放按钮 / 链接(嵌套交互会抢点击)。
244
+ * 宿主按自身展示上限截断(当前取注册顺序前若干张并自动轮播)。
245
+ */
246
+ component: any
247
+ /** 排序权重,小者靠前;缺省 100 */
248
+ order?: number
249
+ /**
250
+ * 点击卡片时应用要进入的内部位置(按**点击时刻**现算,可随数据变化)。
251
+ *
252
+ * 宿主照常「启动并打开本应用」,再把返回值经 `context.ui.onSurfaceIntent`
253
+ * 投递给运行面;返回 null / undefined = 只打开应用(旧行为)。卡片内仍不得
254
+ * 自带交互——本回调就是卡片点击的唯一出口,宿主按钮才是点击落点。
255
+ */
256
+ onPress?: () => ShellSurfaceIntent | null | undefined
257
+ }
258
+
259
+ /** 宿主壳胶囊菜单附加项(平台项 order:权限 10 / 停用 30,应用用中间值插入) */
260
+ export interface ShellCapsuleItem {
261
+ id: string
262
+ label: string
263
+ /** SVG path d(24×24 视框,stroke 风格);缺省用平台通用图标 */
264
+ icon?: string
265
+ order?: number
266
+ onSelect?: (appId: string) => void | Promise<void>
267
+ }
268
+
269
+ /** 日志 API */
270
+ export interface LoggerAPI {
271
+ info(message: string): void
272
+ debug(message: string): void
273
+ warn(message: string): void
274
+ error(message: string): void
275
+ }
276
+
277
+ // ==================== 移动端宿主能力 ====================
278
+
279
+ /** 连接引擎状态(与宿主 useMobileConnection ConnectionStatus 一一对应) */
280
+ export type MobileConnectionStatus =
281
+ | 'disconnected'
282
+ | 'connecting'
283
+ | 'connected'
284
+ | 'pairing'
285
+ | 'paired'
286
+ | 'error'
287
+
288
+ /** 连接目标设备(最小形状;mobileApi.connectDevice 入参) */
289
+ export interface MobileDeviceTarget {
290
+ address: string
291
+ port: number
292
+ name?: string
293
+ }
294
+
295
+ /**
296
+ * `connectDevice` 行为选项。
297
+ *
298
+ * `pairingOnly`:只把目标写入连接引擎 / 设好 HTTP base(供后续 `/api/auth/*`
299
+ * 配对请求使用),**不**先探测 `/api/health`。首次经隧道配对时探测会消费掉
300
+ * 一次性配对票据(隧道准入先放行再判 403),随后真正的认证请求反而无票可用;
301
+ * 因此配对流程必须用本模式,认证成功后再走普通 `connectDevice`。
302
+ */
303
+ export interface MobileConnectOptions {
304
+ pairingOnly?: boolean
305
+ }
306
+
307
+ /** 连接历史条目(宿主连接域引擎事实) */
308
+ export interface MobileConnectionHistoryItem {
309
+ address: string
310
+ name: string
311
+ /** ISO 时间字符串 */
312
+ lastConnected?: string
313
+ }
314
+
315
+ /** 连接生命周期事件(引擎事实面,与宿主 ws_reconnecting 等逐一对应) */
316
+ export type MobileHostConnectionEvent =
317
+ | { type: 'reconnecting'; retry: number; maxRetry: number }
318
+ | { type: 'reconnected' }
319
+ | { type: 'unexpected_disconnect' }
320
+ | { type: 'reauth_rejected'; reason: string }
321
+ | { type: 'reconnect_failed'; reason: string }
322
+ | { type: 'event_channel_ready' }
323
+
324
+ /** mDNS 发现到的服务(与宿主 useMdnsDiscovery DiscoveredService 同形状) */
325
+ export interface MobileMdnsService {
326
+ instance_name: string
327
+ host_name: string
328
+ address: string
329
+ port: number
330
+ txt_records: Record<string, string>
331
+ platform: string
332
+ device_name: string
333
+ }
334
+
335
+ /** 生物凭证状态(与宿主 useMobileCommands BiometricKeyStatus 同形状) */
336
+ export interface MobileBiometricKeyStatus {
337
+ deviceSupported: boolean
338
+ deviceReason: number
339
+ hasKey: boolean
340
+ }
341
+
342
+ /** HTTP API 结果(与宿主 useHttpApi 同构) */
343
+ export interface MobileHttpResult<T = any> {
344
+ code: number
345
+ message: string
346
+ data?: T
347
+ }
348
+
349
+ /** 通用对端 REST 请求选项(宿主注入 JWT / 链路加密 / 错误归一化) */
350
+ export interface MobileHttpRequestOptions {
351
+ method?: string
352
+ body?: any
353
+ headers?: Record<string, string>
354
+ }
355
+
356
+ /** 终端输出流句柄(openTerminalStream 返回;dispose = 注销本代页面通道)
357
+ *
358
+ * 注销携带登记时拿到的页面令牌:同一会话重复 open 时,旧句柄的 dispose 不会
359
+ * 摘掉新通道(宿主按令牌只摘当前代)。 */
360
+ export interface TerminalStreamHandle {
361
+ dispose(): void
362
+ }
363
+
364
+ /** 宿主会话/连接生命周期事件(onSessionEvent 投递;宿主白名单封装,插件不裸听 Tauri 事件名) */
365
+ export interface MobileHostSessionEvent {
366
+ /** disconnected:连接断开(含意外断开);session_status:会话状态变化;session_stopped:会话停止;session_removed:会话移除 */
367
+ type: 'disconnected' | 'session_status' | 'session_stopped' | 'session_removed'
368
+ /** 会话相关事件携带的会话 id(disconnected 无) */
369
+ sessionId?: string
370
+ /** session_status 的新状态(如 'running') */
371
+ newStatus?: string
372
+ }
373
+
374
+ /** 移动端宿主连接/HTTP 能力(共享运行时 mobileApi 模块)
375
+ *
376
+ * 通用能力层:连接状态 + 对端桌面端 REST 请求通道 + 终端流/主题/本地设置只读投影
377
+ * (票 15 扩展:openTerminalStream / isDark / mobileSettings / onSessionEvent / mockSessionId)。
378
+ * 具体插件业务端点(任务队列 / 会话模式 / 任务历史 / 定时任务等)
379
+ * 由各插件基于 httpRequest 自行封装,SDK 不感知插件领域细节。
380
+ */
381
+ export interface MobileHostApi {
382
+ /** 当前活动会话 id(响应式 ref,可 watch / computed) */
383
+ activeSessionId: import('vue').Ref<string | null>
384
+ /** 活跃会话列表(响应式 ref) */
385
+ activeSessions: import('vue').Ref<any[]>
386
+ /** 会话配置列表(响应式 ref) */
387
+ sessionConfigs: import('vue').Ref<any[]>
388
+ /** 是否已连接对端桌面端(响应式 ref,可 watch / computed)
389
+ *
390
+ * 注意语义边界:**只表示传输层已连**(connected/pairing/paired)。未认证的连接不能
391
+ * 访问需要 JWT 的端点(会话 / 任务等),凡是要发受保护请求前先判 {@link isPaired}。 */
392
+ isConnected: import('vue').Ref<boolean>
393
+ /** 是否已完成对端认证(paired,即持有可用的 JWT;响应式 ref)
394
+ *
395
+ * 与 `isConnected` 的区别:连上传输层 ≠ 已认证。用宿主持有的凭据静默换新 JWT 后、
396
+ * 或配对 / QR / 生物认证成功后置 true。 */
397
+ isPaired: import('vue').Ref<boolean>
398
+ /** 通用对端 REST 请求;返回 { code, message, data } 形状 */
399
+ httpRequest<T = any>(path: string, options?: MobileHttpRequestOptions): Promise<MobileHttpResult<T>>
400
+ /** 拉取/刷新活跃会话列表(宿主连接域机制;结果写入 activeSessions ref) */
401
+ loadActiveSessions(): Promise<void>
402
+ /** 拉取/刷新会话配置列表(结果写入 sessionConfigs ref) */
403
+ loadSessionConfigs(): Promise<void>
404
+ /** 会话配置是否已加载过(宿主连接域状态投影) */
405
+ hasLoadedConfigs: import('vue').Ref<boolean>
406
+ /** 会话配置是否加载中(宿主连接域状态投影) */
407
+ isLoadingConfigs: import('vue').Ref<boolean>
408
+ /** 打开终端输出字节流:宿主创建页面 Channel 并登记(terminal_page_subscribe),输出按序裸字节回调;
409
+ * 返回句柄,dispose 注销(terminal_page_unsubscribe)。链路订阅由插件命令面负责,本通道只承载页面接收 */
410
+ openTerminalStream(sessionId: string, onBytes: (bytes: Uint8Array) => void): Promise<TerminalStreamHandle>
411
+ /** 当前 App 是否深色(响应式 ref;终端主题解析依据) */
412
+ isDark: import('vue').Ref<boolean>
413
+ /** 移动端本地设置只读投影(vibrate / maxOpenTerminals 等;平台项由宿主设置页写入,
414
+ * 业务项由插件设置面经下方 KV 桥写入后反映到此) */
415
+ mobileSettings: import('vue').Ref<Record<string, unknown>>
416
+ /** 读全部设置键值(扁平表 `{ key: value }`;通用机制,插件自持哪些键是自己的设置项) */
417
+ readAllSettings(): Promise<Record<string, string>>
418
+ /** 写单个设置键(通用机制面:命中宿主已知键写穿其响应式单例,未命中直落 KV) */
419
+ writeSetting(key: string, value: string): Promise<void>
420
+ /** 会话/连接生命周期事件(断线 / 会话状态 / 停止 / 移除);Disposable.dispose = 取消订阅 */
421
+ onSessionEvent(handler: (event: MobileHostSessionEvent) => void): Disposable
422
+ // ── 连接引擎面(票 2026-10-09:宿主页下沉 bedcode 应用,引擎事实与动作)──
423
+
424
+ /** 连接引擎状态(disconnected/connecting/connected/pairing/paired/error) */
425
+ connectionStatus: import('vue').Ref<MobileConnectionStatus>
426
+ /** 是否正在连接(连接中禁止重复点击) */
427
+ isConnecting: import('vue').Ref<boolean>
428
+ /** 当前连接目标设备 */
429
+ currentDevice: import('vue').Ref<MobileDeviceTarget | null>
430
+ /** 连接历史(此前尝试连接过的桌面端端点;宿主连接域引擎事实) */
431
+ connectionHistory: import('vue').Ref<MobileConnectionHistoryItem[]>
432
+ /** 建立到目标桌面的连接(HTTP base url 探测 + WS 事件通道建链;宿主引擎动作)
433
+ *
434
+ * `pairingOnly=true`:仅设置目标(不探测),供首次配对/扫码先走 `/api/auth/*`;
435
+ * 认证成功后再调用默认模式建立事件通道。 */
436
+ connectDevice(device: MobileDeviceTarget, options?: MobileConnectOptions): Promise<void>
437
+ /** 取消进行中的连接 */
438
+ cancelConnection(): Promise<void>
439
+ /** 用宿主持有的凭据静默换新 JWT(返回用户免配对;凭据零过境,插件拿不到 token)
440
+ *
441
+ * - 宿主无凭据 / 桌面端拒绝 → false(由配对流程接管)
442
+ * - 成功 → `isPaired` 翻转 true,宿主广播 ws_paired */
443
+ authenticateWithStoredToken(): Promise<boolean>
444
+ /** 断开当前连接 */
445
+ disconnect(): Promise<void>
446
+ /** 刷新连接历史(force=true 忽略已加载标记) */
447
+ loadConnectionHistory(force?: boolean): Promise<void>
448
+ /** 清空连接历史 */
449
+ clearConnectionHistory(): Promise<void>
450
+ /** 从连接历史移除单条 */
451
+ removeFromConnectionHistory(address: string): Promise<void>
452
+ /** 写入/更新一条连接历史(去重后置顶,宿主域上限 10 条;认证成功时由连接页调用) */
453
+ addToConnectionHistory(address: string, name?: string): Promise<void>
454
+ /** 连接生命周期事件白名单(reconnecting/reconnected/unexpected_disconnect/reauth_rejected/reconnect_failed/event_channel_ready) */
455
+ onConnectionEvent(handler: (event: MobileHostConnectionEvent) => void): Disposable
456
+
457
+ // ── mDNS 主机发现引擎事实(原始发现事实投影;派生列表归插件自持)──
458
+
459
+ /** 已发现服务列表(响应式 ref) */
460
+ mdnsServices: import('vue').Ref<MobileMdnsService[]>
461
+ /** 是否扫描中(响应式 ref) */
462
+ mdnsScanning: import('vue').Ref<boolean>
463
+ /** 启动扫描(keepResults=true 保留既有列表续扫) */
464
+ mdnsStart(options?: { keepResults?: boolean }): Promise<void>
465
+ /** 停止扫描 */
466
+ mdnsStop(): Promise<void>
467
+ /** 重新拉取已发现服务 */
468
+ mdnsRefresh(): Promise<void>
469
+
470
+ // ── 生物凭证引擎面(C4 凭据零过境:只投状态与绑定动作,材料留宿主)──
471
+
472
+ getBiometricKeyStatus(): Promise<MobileBiometricKeyStatus>
473
+ bindBiometricCredential(): Promise<boolean>
474
+ unbindBiometricCredential(): Promise<boolean>
475
+
476
+ /** DEV mock 会话 id(生产为 null;终端 UI 据此进入本地 mock 渲染) */
477
+ mockSessionId: string | null
478
+ }
479
+
480
+ // ==================== 对话框 ====================
481
+
482
+ /** 对话框选项 */
483
+ export interface DialogOptions {
484
+ title?: string
485
+ message?: string
486
+ /** 视觉风格(默认 info) */
487
+ variant?: 'info' | 'warning' | 'danger'
488
+ confirmText?: string
489
+ cancelText?: string
490
+ /** showPrompt 时:输入框 placeholder */
491
+ inputPlaceholder?: string
492
+ /** showPrompt 时:输入框默认值 */
493
+ inputValue?: string
494
+ /** 是否可点击背景关闭(默认 false) */
495
+ dismissible?: boolean
496
+ }
497
+
498
+ /** 对话框结果 */
499
+ export interface DialogResult {
500
+ action: 'confirm' | 'cancel'
501
+ value?: string
502
+ }
503
+
504
+ /** 对话框 API — 宿主渲染移动端样式弹窗 */
505
+ export interface DialogAPI {
506
+ /** 通用对话框:返回用户操作结果 */
507
+ showDialog(options: DialogOptions): Promise<DialogResult>
508
+ /** 确认框:返回是否确认 */
509
+ showConfirm(options: DialogOptions): Promise<boolean>
510
+ /** 输入框:返回输入值;取消返回 null */
511
+ showPrompt(options: DialogOptions): Promise<string | null>
512
+ /** 轻提示(宿主 toast) */
513
+ showToast(message: string, type?: 'info' | 'success' | 'warning' | 'error'): void
514
+ }
515
+
516
+ // ==================== 通知 ====================
517
+
518
+ /** 系统通知 API — 走宿主 tauri-plugin-notification */
519
+ export interface NotificationAPI {
520
+ notify(title: string, body?: string): Promise<void>
521
+ }
522
+
523
+ // ==================== 状态上报 ====================
524
+
525
+ /** 插件状态上报 API — 启用时通过生命周期函数上报启动成功/失败 */
526
+ export interface StatusAPI {
527
+ /** 显式上报启动成功(activate 隐式成功之外的自愈通道:Error → Activated) */
528
+ reportReady(): Promise<void>
529
+ /** 上报启动/运行失败,宿主置 Error 状态并持久化未启用 */
530
+ reportError(error: string): Promise<void>
531
+ }
532
+
533
+ // ==================== PluginContext API ====================
534
+
535
+ /** 命令注册表 */
536
+ export interface CommandRegistry {
537
+ register(id: string, handler: (...args: any[]) => any): Disposable
538
+ execute(id: string, ...args: any[]): Promise<any>
539
+ }
540
+
541
+ /** 会话 API */
542
+ export interface SessionAPI {
543
+ list(): Promise<any[]>
544
+ get(sessionId: string): Promise<any>
545
+ onStatusChange(handler: (event: any) => void): Disposable
546
+ }
547
+
548
+ // ==================== 全局弹窗(宿主通用能力,与桌面端 SDK 同构) ====================
549
+
550
+ /** 弹窗动作按钮(预设模式,Label 文案由插件经自身 i18n 生成后传入) */
551
+ export interface PluginDialogAction {
552
+ label: string
553
+ /** 视觉变体:默认 / 主按钮 / 危险 / 幽灵 */
554
+ kind?: 'default' | 'primary' | 'danger' | 'ghost'
555
+ /** 点击回调(可异步);成功返回后自动关闭弹窗(抛错则保持打开以便重试) */
556
+ onClick?: () => void | Promise<void>
557
+ /** 点击后经宿主 router 跳转的目标路由(先关弹窗再跳转) */
558
+ navigateTo?: string
559
+ /** 动作进行中禁用(如提交中防重复点击);经 handle.update() 联动 */
560
+ disabled?: boolean
561
+ }
562
+
563
+ /**
564
+ * 全局弹窗选项(宿主统一渲染:遮罩/卡片/z-index/定时关闭/按钮/路由跳转)
565
+ *
566
+ * 两种模式:
567
+ * - 预设模式:title + message + icon + actions,常见「确认/拒绝」类请求开箱即用;
568
+ * - 组件模式:content 传入任意 Vue 组件(经 provide('pluginContext') 渲染),
569
+ * props 可经 handle.update() 热更新。
570
+ * 定时关闭为可选能力:仅当 timeoutSec / deadlineAt 之一提供时生效。
571
+ */
572
+ export interface PluginDialogOptions {
573
+ /** 自定义内容组件(组件模式);缺省用 title/message/icon/actions 预设渲染 */
574
+ content?: any
575
+ /** 内容组件 props(组件模式;handle.update() 可热更新) */
576
+ props?: Record<string, unknown>
577
+ /** 预设模式:标题 */
578
+ title?: string
579
+ /** 预设模式:正文 */
580
+ message?: string
581
+ /** 预设模式:图标(SVG path d,随文字颜色渲染) */
582
+ icon?: string
583
+ /** 预设模式:动作按钮组(缺省无按钮;顺序即展示顺序) */
584
+ actions?: PluginDialogAction[]
585
+ /** 定时自动关闭(可选):相对秒数,从弹窗弹出起算 */
586
+ timeoutSec?: number
587
+ /** 定时自动关闭(可选):绝对截止时间戳 ms(迟到打开 / 排队续算更准确,优先于 timeoutSec) */
588
+ deadlineAt?: number
589
+ /** 倒计时文案模板,{seconds} 占位(如 '{seconds} 秒后自动拒绝');缺省不显示倒计时 */
590
+ countdownLabel?: string
591
+ /** 超时回调(自动关闭前触发);缺省仅关闭 */
592
+ onTimeout?: () => void
593
+ /** 是否可手动关闭(右上角关闭按钮 / Escape / 遮罩点击),默认 true */
594
+ closable?: boolean
595
+ /** 点击遮罩是否关闭,默认 true(closable=false 时无效) */
596
+ closeOnBackdrop?: boolean
597
+ /** 卡片宽度(Tailwind max-w-* 类),默认 max-w-md */
598
+ widthClass?: string
599
+ /** 内容区 padding(Tailwind 类),默认 p-0(组件模式自带内距,预设模式内部处理) */
600
+ bodyClass?: string
601
+ /** 关闭后回调(按钮 / 遮罩 / Escape / 超时 / close() / 排队项被取消 均触发) */
602
+ onClose?: () => void
603
+ }
604
+
605
+ /** 全局弹窗句柄:调用方据此关闭或热更新当前弹窗 */
606
+ export interface PluginDialogHandle {
607
+ /** 关闭当前弹窗(幂等);队列中下一个弹窗自动接替 */
608
+ close(): void
609
+ /** 热更新选项(props / 文案 / 按钮 / 倒计时等) */
610
+ update(options: Partial<PluginDialogOptions>): void
611
+ }
612
+
613
+ /** 监控面板环境(收窄只读面;面板实现住提供方应用工程) */
614
+ export interface MonitorPanelEnv {
615
+ appId: string
616
+ panelId: string
617
+ /** 本应用插件面命令(与主界面同一权限;只在面板内只读取数) */
618
+ appInvoke: <T = any>(command: string, ...args: any[]) => Promise<T>
619
+ /** 本应用插件 KV 只读访问 */
620
+ appStorageGet: <T = any>(key: string) => Promise<T | undefined>
621
+ locale: string
622
+ theme: string
623
+ platform?: string
624
+ }
625
+
626
+ /** 监控面板句柄(monitor 切换页签 / 卸载时销毁) */
627
+ export interface MonitorPanelHandle {
628
+ unmount(): Promise<void>
629
+ }
630
+
631
+ /** 提供方模块可选导出;未导出 = 没有该面板实现(不是错误) */
632
+ export type MountMonitorPanel = (
633
+ root: HTMLElement,
634
+ env: MonitorPanelEnv,
635
+ ) => Promise<MonitorPanelHandle>
636
+
637
+ /**
638
+ * UI 注册表
639
+ *
640
+ * 票 2026-10-10 批次 C2 整面退役:`registerToolboxPage` / `registerNavTab` /
641
+ * `registerTerminalToolbarItem` / `registerTerminalView` 及其描述符类型已删除。
642
+ * 应用在宿主壳内**只有一种运行面形态**——`registerSurface`;应用内页签与子页走本表
643
+ * 保留的 `registerRoute` + `openPage`,不占宿主导航形态。旧插件若仍调用已退役方法,
644
+ * 宿主在调用点显式抛错(fail-visible),不做「查不到就静默忽略」。
645
+ */
646
+ export interface UIRegistry {
647
+ /**
648
+ * 装载其他应用注册的自定义监控面板(monitor 统一壳用;宿主中介)。
649
+ * 只 import 提供方前端模块并调用其 `mountMonitorPanel`,不激活其后端。
650
+ */
651
+ mountMonitorPanel(
652
+ container: HTMLElement,
653
+ appId: string,
654
+ panelId: string,
655
+ ): Promise<MonitorPanelHandle>
656
+ /** 宿主壳运行面(/mobile/shell 的应用运行屏;appId = 插件 id 由宿主代填)。
657
+ * 应用自持整个运行面——含底部导航与页签,壳不向其内加壳 chrome。 */
658
+ registerSurface(surface: ShellSurfaceContribution): Disposable
659
+ /** 宿主壳首页快捷卡片(应用自持内容;壳 Home 屏渲染,appId 由宿主代填) */
660
+ registerSlot(slot: ShellSlotContribution): Disposable
661
+ /**
662
+ * 订阅宿主投递的应用内入口意图(快捷卡片点击等;载荷由应用自持)。
663
+ *
664
+ * 订阅**之前**到达的意图由宿主按 appId 排队,订阅时按序补投(运行面晚于
665
+ * 点击创建时不会丢);应用停用 / 卸载 / 运行面销毁时队列清空,旧意图不会在
666
+ * 下一次打开时突然生效。Disposable.dispose = 取消订阅。
667
+ */
668
+ onSurfaceIntent(handler: (intent: ShellSurfaceIntent) => void): Disposable
669
+ /** 宿主壳胶囊菜单附加项(appId 由宿主代填) */
670
+ registerCapsuleItem(item: ShellCapsuleItem): Disposable
671
+ /** 动态注册插件路由(宿主 addRoute 至 /mobile/plugins/{pluginId}/{id};Disposable.dispose = removeRoute 撤销) */
672
+ registerRoute(route: PluginRouteDescriptor): Disposable
673
+ /** 整体跳转到本插件已注册路由;返回入口页用 goBack 或宿主页头返回按钮 */
674
+ openPage(routeId: string): void
675
+ /** 返回上一页(router.back) */
676
+ goBack(): void
677
+ /** 监听 Android 系统返回键(仅 Android 真机触发;有订阅者时系统返回不再执行默认的
678
+ * webview 后退/退出,改由回调接管)。
679
+ * 回调自行决定行为:应用自持的二级页 / 浮层在这里逐级收掉(回到应用主页面后不再
680
+ * 消费,交平台兜底);**返回 true 表示本次已消费**——不消费
681
+ * (返回 undefined / false)时返回会交给平台兜底(宿主壳回退到上一屏,主屏无兜底
682
+ * 则退出应用),因此应用在「自己已到头」的分支上不要返回 true,否则用户按返回无反应。
683
+ * 载荷 canGoBack = webview 自身是否有历史(需要时可用它恢复默认后退)。
684
+ * 非 Android(dev-shell / iOS)静默降级为永不触发;Disposable.dispose = 取消监听,
685
+ * 最后一个订阅者取消后恢复系统默认返回行为。 */
686
+ onBackPressed(handler: (payload: { canGoBack: boolean }) => boolean | void): Disposable
687
+ /** 全局弹窗(宿主统一渲染遮罩/卡片/倒计时/按钮/路由跳转;见 PluginDialogOptions) */
688
+ showDialog(options: PluginDialogOptions): PluginDialogHandle
689
+ }
690
+
691
+ /** 事件 API */
692
+ export interface EventAPI {
693
+ on(event: string, handler: (...args: any[]) => void): Disposable
694
+ emit(event: string, ...args: any[]): void
695
+ }
696
+
697
+ /** 存储 API */
698
+ export interface StorageAPI {
699
+ get<T = any>(key: string): Promise<T | undefined>
700
+ set(key: string, value: any): Promise<void>
701
+ delete(key: string): Promise<void>
702
+ }
703
+
704
+ // ==================== System API ====================
705
+
706
+ /** 系统 API — 宿主 OS 级文件操作(需 system:open 权限) */
707
+ export interface SystemAPI {
708
+ /** 用系统查看器打开本地文件(传输完成「打开本地文件」;Android ACTION_VIEW) */
709
+ openFile(path: string, displayName?: string): Promise<void>
710
+ /** 用系统文件管理器打开文件所在目录(历史记录「打开所在文件夹」;
711
+ * Android FileProvider 暴露父目录 + ACTION_VIEW,需 system:open 权限) */
712
+ revealInDir(path: string): Promise<void>
713
+ /** 按文件名打开接收文件的所在目录(历史「打开所在文件夹」真机路径;
714
+ * 接收落点不在 wire 上,宿主 MediaStore 公共下载按 displayName 命中 →
715
+ * primary:Download 目录,未命中回退 app 私有下载目录;需 system:open 权限) */
716
+ revealReceivedFileLocation(fileName: string): Promise<void>
717
+ /** 引导开启「所有文件访问」权限(打开系统公共 Download 目录需要
718
+ * MANAGE_EXTERNAL_STORAGE,无运行时弹窗只能跳系统设置页手动开启;
719
+ * 未授权时跳转系统授权页并在无该页面的 ROM 兑底应用详情页),返回
720
+ * 跳转前的授权状态;授权后用户重试 revealReceivedFileLocation 即达;
721
+ * 需 system:open 权限) */
722
+ requestAllFilesAccess(): Promise<boolean>
723
+ /** 打开系统公共下载目录(设置页下载目录区「打开」,核对文件是否落盘;
724
+ * 目标为系统 Download 目录(ExternalStorageProvider 树 URI),未授予
725
+ * 「所有文件访问」时报 needs_all_files_access,前端据此引导授权;
726
+ * 需 system:open 权限) */
727
+ openDownloadDir(): Promise<void>
728
+ }
729
+
730
+ // ==================== 插件开发期领域数据(dev-shell mock 协议) ====================
731
+
732
+ /**
733
+ * 插件开发期领域数据(dev-shell mock 协议,仅浏览器 dev 环境消费)。
734
+ *
735
+ * 与"宿主能力 mock"(会话/对话框/事件/HTTP 接口等,固定在 dev-shell 内实现)区分:
736
+ * 本协议只承载各插件自己的业务演示数据,由插件入口导出 devMock,dev-shell
737
+ * 加载插件时按 pluginId 注册、按需取用。
738
+ *
739
+ * SDK 只约定「入口导出 devMock」的通用容器协议,不感知任何插件领域细节:
740
+ * 各插件自有类型(任务队列种子 / 文件传输对等与传输域种子等)
741
+ * 由插件工程自行定义;dev-shell 消费时 cast 到插件自有形状。
742
+ * 真实宿主忽略该字段(多余导出对 activate 无影响),插件无需条件编译。
743
+ */
744
+ export type PluginDevMock = Record<string, unknown>
745
+
746
+ /** 国际化 API */
747
+ export interface I18nAPI {
748
+ registerMessages(locale: string, messages: Record<string, unknown>): void
749
+ t(key: string, params?: Record<string, unknown>): string
750
+ }
751
+
752
+ /** 生命周期 API(onTerminalInput/onTerminalOutput 已随票 15 阶段 B 退役) */
753
+ export interface LifecycleAPI {
754
+ onAppStartup(handler: () => void): Disposable
755
+ onAppShutdown(handler: () => void): Disposable
756
+ onAuthSuccess(handler: () => void): Disposable
757
+ onDisconnect(handler: (reason: string) => void): Disposable
758
+ onSessionCreated(handler: (sessionId: string) => void): Disposable
759
+ onSessionStopped(handler: (sessionId: string) => void): Disposable
760
+ }
761
+
762
+ /** 应用更新检查的拒绝 / 失败原因(展示层按 key 翻译;params 只承载版本号等非技术值) */
763
+ export interface AppUpdateReason {
764
+ key: string
765
+ params?: Record<string, string>
766
+ }
767
+
768
+ /**
769
+ * 应用更新检查结果(宿主默认实现返回;SDK 默认设置卡直接展示)
770
+ *
771
+ * 宿主侧已经完成「取 Release → 校验身份/完整性 → 兼容性判定」,插件只消费状态。
772
+ * `available` 表示有新版本且兼容;`incompatible` 只给原因,绝不提供更新动作。
773
+ */
774
+ export interface AppUpdateCheckResult {
775
+ status: 'idle' | 'checking' | 'up-to-date' | 'available' | 'incompatible' | 'error'
776
+ latestVersion?: string
777
+ currentVersion?: string
778
+ reason?: AppUpdateReason
779
+ }
780
+
781
+ /** 应用更新能力(宿主默认实现;appId 与凭据已由宿主绑定) */
782
+ export interface AppUpdateAPI {
783
+ /** 检查本应用更新;失败已由宿主归一化为 `status: 'error'`,不抛技术错误 */
784
+ check(): Promise<AppUpdateCheckResult>
785
+ }
786
+
787
+ /** 插件上下文 */
788
+ export interface PluginContext {
789
+ readonly id: string
790
+ readonly commands: CommandRegistry
791
+ readonly session: SessionAPI
792
+ readonly ui: UIRegistry
793
+ readonly events: EventAPI
794
+ readonly storage: StorageAPI
795
+ readonly i18n: I18nAPI
796
+ readonly lifecycle: LifecycleAPI
797
+ readonly logger: LoggerAPI
798
+ /** 对话框(弹窗扩展性) */
799
+ readonly dialogs: DialogAPI
800
+ /** 系统通知 */
801
+ readonly notifications: NotificationAPI
802
+ /** 系统 API(需 system:open 权限) */
803
+ readonly system: SystemAPI
804
+ /** 生命周期状态上报(启用成功/失败) */
805
+ readonly status: StatusAPI
806
+ /** 应用更新检查(宿主统一默认实现;可选——旧宿主 / dev-shell 可不提供) */
807
+ readonly appUpdate?: AppUpdateAPI
808
+ readonly _disposables: Disposable[]
809
+ }
810
+
811
+ /** 插件入口模块约定 */
812
+ export interface PluginModule {
813
+ activate(context: PluginContext): Promise<void>
814
+ deactivate?: () => Promise<void>
815
+ /**
816
+ * 可选:自定义监控面板实现(由 monitor 统一壳经宿主中介装载)。
817
+ * 只在面板装载时调用,不要求 activate 先执行;面板自行处理后端未运行的情况。
818
+ */
819
+ mountMonitorPanel?: MountMonitorPanel
820
+ /** dev-shell 领域数据(见 PluginDevMock);真实宿主忽略 */
821
+ devMock?: PluginDevMock
822
+ }