@binblink/wasmnest-plugin-sdk-desktop 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 (271) hide show
  1. package/README.md +307 -2
  2. package/README_en.md +284 -0
  3. package/bin/cli.js +602 -0
  4. package/bin/manifest-gen.js +458 -0
  5. package/bin/manifest-validate.js +494 -0
  6. package/bin/permission-vocabulary.json +5 -0
  7. package/bin/plugin-watch.js +331 -0
  8. package/bin/wasm-hash.js +124 -0
  9. package/dev-shell/README.md +122 -0
  10. package/dev-shell/index.html +12 -0
  11. package/dev-shell/package.json +28 -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/components/LogPanel.vue +90 -0
  16. package/dev-shell/src/loader.ts +104 -0
  17. package/dev-shell/src/locale.ts +29 -0
  18. package/dev-shell/src/locales.ts +50 -0
  19. package/dev-shell/src/main.ts +46 -0
  20. package/dev-shell/src/mock/app-env.ts +102 -0
  21. package/dev-shell/src/mock/commands.ts +54 -0
  22. package/dev-shell/src/mock/domain-context.ts +46 -0
  23. package/dev-shell/src/mock/events.ts +16 -0
  24. package/dev-shell/src/mock/file-transfer.ts +512 -0
  25. package/dev-shell/src/mock/tauri-ipc.ts +109 -0
  26. package/dev-shell/src/registry.ts +90 -0
  27. package/dev-shell/src/shell/components/AppMountSlot.vue +241 -0
  28. package/dev-shell/src/shell/components/ShellIcon.vue +141 -0
  29. package/dev-shell/src/shell/components/ShellStatusBar.vue +87 -0
  30. package/dev-shell/src/shell/components/ShellToolbar.vue +287 -0
  31. package/dev-shell/src/shell/mount/appSession.ts +45 -0
  32. package/dev-shell/src/shell/mount/devAppMount.ts +80 -0
  33. package/dev-shell/src/shell/types.ts +121 -0
  34. package/dev-shell/src/styles/dev.css +27 -0
  35. package/dev-shell/src/styles/shell.css +752 -0
  36. package/dev-shell/src/styles/style.css +1178 -0
  37. package/dev-shell/src/theme.ts +140 -0
  38. package/dev-shell/src/vite-env.d.ts +24 -0
  39. package/dev-shell/tailwind.config.js +98 -0
  40. package/dev-shell/vite.config.ts +174 -0
  41. package/dist/index.d.ts +150 -0
  42. package/dist/index.js +238 -0
  43. package/dist/types.d.ts +632 -0
  44. package/dist/types.js +0 -0
  45. package/dist/vite-plugin.d.ts +25 -0
  46. package/dist/vite-plugin.js +80 -0
  47. package/go/.gitignore +5 -0
  48. package/go/README.md +80 -0
  49. package/go/gen/wasmnest/api-call/host-api-call/empty.s +3 -0
  50. package/go/gen/wasmnest/api-call/host-api-call/host-api-call.wasm.go +13 -0
  51. package/go/gen/wasmnest/api-call/host-api-call/host-api-call.wit.go +34 -0
  52. package/go/gen/wasmnest/app/host-app/empty.s +3 -0
  53. package/go/gen/wasmnest/app/host-app/host-app.wasm.go +29 -0
  54. package/go/gen/wasmnest/app/host-app/host-app.wit.go +108 -0
  55. package/go/gen/wasmnest/auth-center/host-auth-center/abi.go +14 -0
  56. package/go/gen/wasmnest/auth-center/host-auth-center/empty.s +3 -0
  57. package/go/gen/wasmnest/auth-center/host-auth-center/host-auth-center.wasm.go +49 -0
  58. package/go/gen/wasmnest/auth-center/host-auth-center/host-auth-center.wit.go +225 -0
  59. package/go/gen/wasmnest/clipboard/host-clipboard/abi.go +14 -0
  60. package/go/gen/wasmnest/clipboard/host-clipboard/empty.s +3 -0
  61. package/go/gen/wasmnest/clipboard/host-clipboard/host-clipboard.wasm.go +17 -0
  62. package/go/gen/wasmnest/clipboard/host-clipboard/host-clipboard.wit.go +68 -0
  63. package/go/gen/wasmnest/connection-registry/host-connection-registry/empty.s +3 -0
  64. package/go/gen/wasmnest/connection-registry/host-connection-registry/host-connection-registry.wasm.go +13 -0
  65. package/go/gen/wasmnest/connection-registry/host-connection-registry/host-connection-registry.wit.go +50 -0
  66. package/go/gen/wasmnest/crypto/host-crypto/abi.go +18 -0
  67. package/go/gen/wasmnest/crypto/host-crypto/empty.s +3 -0
  68. package/go/gen/wasmnest/crypto/host-crypto/host-crypto.wasm.go +37 -0
  69. package/go/gen/wasmnest/crypto/host-crypto/host-crypto.wit.go +139 -0
  70. package/go/gen/wasmnest/fs-desktop/host-fs-desktop/abi.go +14 -0
  71. package/go/gen/wasmnest/fs-desktop/host-fs-desktop/empty.s +3 -0
  72. package/go/gen/wasmnest/fs-desktop/host-fs-desktop/host-fs-desktop.wasm.go +21 -0
  73. package/go/gen/wasmnest/fs-desktop/host-fs-desktop/host-fs-desktop.wit.go +62 -0
  74. package/go/gen/wasmnest/http/host-http/abi.go +14 -0
  75. package/go/gen/wasmnest/http/host-http/empty.s +3 -0
  76. package/go/gen/wasmnest/http/host-http/host-http.wasm.go +13 -0
  77. package/go/gen/wasmnest/http/host-http/host-http.wit.go +40 -0
  78. package/go/gen/wasmnest/http-endpoint/host-http-endpoint/empty.s +3 -0
  79. package/go/gen/wasmnest/http-endpoint/host-http-endpoint/host-http-endpoint.wasm.go +17 -0
  80. package/go/gen/wasmnest/http-endpoint/host-http-endpoint/host-http-endpoint.wit.go +69 -0
  81. package/go/gen/wasmnest/mdns/host-mdns/empty.s +3 -0
  82. package/go/gen/wasmnest/mdns/host-mdns/host-mdns.wasm.go +29 -0
  83. package/go/gen/wasmnest/mdns/host-mdns/host-mdns.wit.go +101 -0
  84. package/go/gen/wasmnest/notify/host-notify/empty.s +3 -0
  85. package/go/gen/wasmnest/notify/host-notify/host-notify.wasm.go +13 -0
  86. package/go/gen/wasmnest/notify/host-notify/host-notify.wit.go +64 -0
  87. package/go/gen/wasmnest/peer/host-peer/abi.go +14 -0
  88. package/go/gen/wasmnest/peer/host-peer/empty.s +3 -0
  89. package/go/gen/wasmnest/peer/host-peer/host-peer.wasm.go +85 -0
  90. package/go/gen/wasmnest/peer/host-peer/host-peer.wit.go +357 -0
  91. package/go/gen/wasmnest/platform-desktop/host-platform-desktop/empty.s +3 -0
  92. package/go/gen/wasmnest/platform-desktop/host-platform-desktop/host-platform-desktop.wasm.go +21 -0
  93. package/go/gen/wasmnest/platform-desktop/host-platform-desktop/host-platform-desktop.wit.go +70 -0
  94. package/go/gen/wasmnest/plugin/abi-form/abi-form.exports.go +11 -0
  95. package/go/gen/wasmnest/plugin/abi-form/abi-form.wasm.go +13 -0
  96. package/go/gen/wasmnest/plugin/abi-form/abi-form.wit.go +7 -0
  97. package/go/gen/wasmnest/plugin/abi-form/empty.s +3 -0
  98. package/go/gen/wasmnest/plugin/command/command.exports.go +11 -0
  99. package/go/gen/wasmnest/plugin/command/command.wasm.go +19 -0
  100. package/go/gen/wasmnest/plugin/command/command.wit.go +6 -0
  101. package/go/gen/wasmnest/plugin/command/empty.s +3 -0
  102. package/go/gen/wasmnest/plugin/events/empty.s +3 -0
  103. package/go/gen/wasmnest/plugin/events/events.exports.go +52 -0
  104. package/go/gen/wasmnest/plugin/events/events.wasm.go +74 -0
  105. package/go/gen/wasmnest/plugin/events/events.wit.go +195 -0
  106. package/go/gen/wasmnest/plugin/host-bus/empty.s +3 -0
  107. package/go/gen/wasmnest/plugin/host-bus/host-bus.wasm.go +29 -0
  108. package/go/gen/wasmnest/plugin/host-bus/host-bus.wit.go +94 -0
  109. package/go/gen/wasmnest/plugin/host-config/abi.go +14 -0
  110. package/go/gen/wasmnest/plugin/host-config/empty.s +3 -0
  111. package/go/gen/wasmnest/plugin/host-config/host-config.wasm.go +13 -0
  112. package/go/gen/wasmnest/plugin/host-config/host-config.wit.go +21 -0
  113. package/go/gen/wasmnest/plugin/host-events/empty.s +3 -0
  114. package/go/gen/wasmnest/plugin/host-events/host-events.wasm.go +9 -0
  115. package/go/gen/wasmnest/plugin/host-events/host-events.wit.go +27 -0
  116. package/go/gen/wasmnest/plugin/host-fs/abi.go +14 -0
  117. package/go/gen/wasmnest/plugin/host-fs/empty.s +3 -0
  118. package/go/gen/wasmnest/plugin/host-fs/host-fs.wasm.go +33 -0
  119. package/go/gen/wasmnest/plugin/host-fs/host-fs.wit.go +86 -0
  120. package/go/gen/wasmnest/plugin/host-log/empty.s +3 -0
  121. package/go/gen/wasmnest/plugin/host-log/host-log.wasm.go +25 -0
  122. package/go/gen/wasmnest/plugin/host-log/host-log.wit.go +65 -0
  123. package/go/gen/wasmnest/plugin/host-metrics/empty.s +3 -0
  124. package/go/gen/wasmnest/plugin/host-metrics/host-metrics.wasm.go +13 -0
  125. package/go/gen/wasmnest/plugin/host-metrics/host-metrics.wit.go +34 -0
  126. package/go/gen/wasmnest/plugin/host-platform/empty.s +3 -0
  127. package/go/gen/wasmnest/plugin/host-platform/host-platform.wasm.go +21 -0
  128. package/go/gen/wasmnest/plugin/host-platform/host-platform.wit.go +85 -0
  129. package/go/gen/wasmnest/plugin/host-plugin-database/abi.go +14 -0
  130. package/go/gen/wasmnest/plugin/host-plugin-database/empty.s +3 -0
  131. package/go/gen/wasmnest/plugin/host-plugin-database/host-plugin-database.wasm.go +29 -0
  132. package/go/gen/wasmnest/plugin/host-plugin-database/host-plugin-database.wit.go +70 -0
  133. package/go/gen/wasmnest/plugin/host-storage/abi.go +14 -0
  134. package/go/gen/wasmnest/plugin/host-storage/empty.s +3 -0
  135. package/go/gen/wasmnest/plugin/host-storage/host-storage.wasm.go +21 -0
  136. package/go/gen/wasmnest/plugin/host-storage/host-storage.wit.go +44 -0
  137. package/go/gen/wasmnest/plugin/host-worker/empty.s +3 -0
  138. package/go/gen/wasmnest/plugin/host-worker/host-worker.wasm.go +17 -0
  139. package/go/gen/wasmnest/plugin/host-worker/host-worker.wit.go +50 -0
  140. package/go/gen/wasmnest/plugin/lifecycle/empty.s +3 -0
  141. package/go/gen/wasmnest/plugin/lifecycle/lifecycle.exports.go +32 -0
  142. package/go/gen/wasmnest/plugin/lifecycle/lifecycle.wasm.go +41 -0
  143. package/go/gen/wasmnest/plugin/lifecycle/lifecycle.wit.go +9 -0
  144. package/go/gen/wasmnest/plugin/manifest/empty.s +3 -0
  145. package/go/gen/wasmnest/plugin/manifest/manifest.exports.go +11 -0
  146. package/go/gen/wasmnest/plugin/manifest/manifest.wasm.go +13 -0
  147. package/go/gen/wasmnest/plugin/manifest/manifest.wit.go +6 -0
  148. package/go/gen/wasmnest/plugin/plugin/plugin.wit.go +4 -0
  149. package/go/gen/wasmnest/process/host-process/empty.s +3 -0
  150. package/go/gen/wasmnest/process/host-process/host-process.wasm.go +21 -0
  151. package/go/gen/wasmnest/process/host-process/host-process.wit.go +56 -0
  152. package/go/gen/wasmnest/pty/host-pty/abi.go +14 -0
  153. package/go/gen/wasmnest/pty/host-pty/empty.s +3 -0
  154. package/go/gen/wasmnest/pty/host-pty/host-pty.wasm.go +33 -0
  155. package/go/gen/wasmnest/pty/host-pty/host-pty.wit.go +164 -0
  156. package/go/gen/wasmnest/task/host-task/abi.go +14 -0
  157. package/go/gen/wasmnest/task/host-task/empty.s +3 -0
  158. package/go/gen/wasmnest/task/host-task/host-task.wasm.go +29 -0
  159. package/go/gen/wasmnest/task/host-task/host-task.wit.go +110 -0
  160. package/go/gen/wasmnest/timer/host-timer/empty.s +3 -0
  161. package/go/gen/wasmnest/timer/host-timer/host-timer.wasm.go +13 -0
  162. package/go/gen/wasmnest/timer/host-timer/host-timer.wit.go +25 -0
  163. package/go/gen/wasmnest/ws/host-websocket/empty.s +3 -0
  164. package/go/gen/wasmnest/ws/host-websocket/host-websocket.wasm.go +29 -0
  165. package/go/gen/wasmnest/ws/host-websocket/host-websocket.wit.go +109 -0
  166. package/go/gen/wasmnest/ws-server/host-websocket-server/empty.s +3 -0
  167. package/go/gen/wasmnest/ws-server/host-websocket-server/host-websocket-server.wasm.go +49 -0
  168. package/go/gen/wasmnest/ws-server/host-websocket-server/host-websocket-server.wit.go +220 -0
  169. package/go/go.mod +14 -0
  170. package/go/go.sum +2 -0
  171. package/go/sdk/dispatch.go +49 -0
  172. package/go/sdk/dispatch_test.go +81 -0
  173. package/go/sdk/entry_native.go +13 -0
  174. package/go/sdk/entry_wasip2.go +188 -0
  175. package/go/sdk/host_http_wasip2.go +42 -0
  176. package/go/sdk/host_wasip2.go +251 -0
  177. package/go/sdk/plugin.go +103 -0
  178. package/go/testplugin/index.js +1 -0
  179. package/go/testplugin/main.go +67 -0
  180. package/go/testplugin/plugin.json +24 -0
  181. package/go/tools/assemble-wit.mjs +152 -0
  182. package/go/tools/gen-bindings.mjs +51 -0
  183. package/go/wit/core.wit +273 -0
  184. package/go/wit/deps/api-call/cap-api-call.wit +20 -0
  185. package/go/wit/deps/app/cap-app.wit +54 -0
  186. package/go/wit/deps/auth-center/cap-auth-center.wit +124 -0
  187. package/go/wit/deps/clipboard/clipboard.wit +48 -0
  188. package/go/wit/deps/clocks/monotonic-clock.wit +45 -0
  189. package/go/wit/deps/clocks/wall-clock.wit +42 -0
  190. package/go/wit/deps/clocks/world.wit +6 -0
  191. package/go/wit/deps/connection-registry/cap-connection-registry.wit +40 -0
  192. package/go/wit/deps/crypto/cap-crypto.wit +68 -0
  193. package/go/wit/deps/filesystem/preopens.wit +8 -0
  194. package/go/wit/deps/filesystem/types.wit +634 -0
  195. package/go/wit/deps/filesystem/world.wit +6 -0
  196. package/go/wit/deps/fs-desktop/cap-fs-desktop.wit +29 -0
  197. package/go/wit/deps/http/http.wit +28 -0
  198. package/go/wit/deps/http-endpoint/cap-http.wit +44 -0
  199. package/go/wit/deps/io/error.wit +34 -0
  200. package/go/wit/deps/io/poll.wit +41 -0
  201. package/go/wit/deps/io/streams.wit +262 -0
  202. package/go/wit/deps/io/world.wit +6 -0
  203. package/go/wit/deps/mdns/mdns.wit +45 -0
  204. package/go/wit/deps/notify/notify.wit +51 -0
  205. package/go/wit/deps/peer/peer.wit +126 -0
  206. package/go/wit/deps/platform-desktop/cap-platform-desktop.wit +38 -0
  207. package/go/wit/deps/process/cap-process.wit +25 -0
  208. package/go/wit/deps/pty/pty.wit +80 -0
  209. package/go/wit/deps/random/insecure-seed.wit +25 -0
  210. package/go/wit/deps/random/insecure.wit +22 -0
  211. package/go/wit/deps/random/random.wit +26 -0
  212. package/go/wit/deps/random/world.wit +7 -0
  213. package/go/wit/deps/sockets/instance-network.wit +9 -0
  214. package/go/wit/deps/sockets/ip-name-lookup.wit +51 -0
  215. package/go/wit/deps/sockets/network.wit +145 -0
  216. package/go/wit/deps/sockets/tcp-create-socket.wit +27 -0
  217. package/go/wit/deps/sockets/tcp.wit +353 -0
  218. package/go/wit/deps/sockets/udp-create-socket.wit +27 -0
  219. package/go/wit/deps/sockets/udp.wit +266 -0
  220. package/go/wit/deps/sockets/world.wit +11 -0
  221. package/go/wit/deps/task/cap-task.wit +56 -0
  222. package/go/wit/deps/timer/cap-timer.wit +14 -0
  223. package/go/wit/deps/wasi-cli/command.wit +7 -0
  224. package/go/wit/deps/wasi-cli/environment.wit +18 -0
  225. package/go/wit/deps/wasi-cli/exit.wit +4 -0
  226. package/go/wit/deps/wasi-cli/imports.wit +20 -0
  227. package/go/wit/deps/wasi-cli/run.wit +4 -0
  228. package/go/wit/deps/wasi-cli/stdio.wit +17 -0
  229. package/go/wit/deps/wasi-cli/terminal.wit +49 -0
  230. package/go/wit/deps/ws/ws.wit +50 -0
  231. package/go/wit/deps/ws-server/cap-ws.wit +99 -0
  232. package/go/wit/go-plugin.wit +28 -0
  233. package/go/wit/plugin-face.wit +355 -0
  234. package/go/wit/wasmnest.wit +25 -0
  235. package/package.json +100 -3
  236. package/src/config.ts +49 -0
  237. package/src/global-dialog.ts +169 -0
  238. package/src/index.ts +88 -0
  239. package/src/runtime.ts +54 -0
  240. package/src/types.ts +681 -0
  241. package/src/ui/AppUpdateSection.d.ts +44 -0
  242. package/src/ui/AppUpdateSection.vue +253 -0
  243. package/src/ui/MarkdownEditor.vue +520 -0
  244. package/src/ui/NumberField.d.ts +49 -0
  245. package/src/ui/NumberField.vue +390 -0
  246. package/src/ui/PluginGlobalDialog.vue +401 -0
  247. package/src/ui/Select.d.ts +36 -0
  248. package/src/ui/Select.vue +220 -0
  249. package/src/ui/TerminalInputRail.vue +184 -0
  250. package/src/ui/apply-select-position.ts +65 -0
  251. package/src/ui/markdown-editor-syntax.ts +234 -0
  252. package/src/ui/markdown-editor.d.ts +36 -0
  253. package/src/ui/plugin-global-dialog.d.ts +12 -0
  254. package/src/ui/select-position.ts +79 -0
  255. package/src/ui/terminal-input-rail.d.ts +30 -0
  256. package/src/ui/zoom-compensation.d.ts +9 -0
  257. package/src/ui/zoom-compensation.ts +52 -0
  258. package/src/update.ts +123 -0
  259. package/src/vite-plugin.ts +124 -0
  260. package/template/README.md +39 -0
  261. package/template/package.json +23 -0
  262. package/template/plugin.json +14 -0
  263. package/template/rust/Cargo.toml +21 -0
  264. package/template/rust/src/lib.rs +39 -0
  265. package/template/src/env.d.ts +24 -0
  266. package/template/src/index.ts +37 -0
  267. package/template/tsconfig.json +17 -0
  268. package/template/vite.config.ts +21 -0
  269. package/tools/componentize/Cargo.lock +299 -0
  270. package/tools/componentize/Cargo.toml +18 -0
  271. package/tools/componentize/src/main.rs +197 -0
@@ -0,0 +1,494 @@
1
+ /**
2
+ * manifest-validate — 桌面端 plugin.json 清单校验(可导入)
3
+ *
4
+ * 由两处共用,保证「CI/构建链里跑的就是 CLI 里那套规则」:
5
+ * - `wasmnest-plugin-desktop validate`(本包 CLI)
6
+ * - `wasmnest-desktop/scripts/plugin-build.js`(插件生产构建链,构建前拦截)
7
+ *
8
+ * 权限词汇不在此手抄:读 SDK 生成物 `bin/permission-vocabulary.json`
9
+ * (真源 `rust/src/permission.rs`,重跑 SDK 的 `pnpm run gen:permissions`)。
10
+ * `wasmHash` 的形态正则亦不手抄:取自 `bin/wasm-hash.js`(与产物注入、分发校验同一真源)。
11
+ */
12
+
13
+ import { existsSync, readFileSync } from 'node:fs'
14
+ import { dirname, join, resolve } from 'node:path'
15
+ import { fileURLToPath } from 'node:url'
16
+ import { WASM_HASH_PATTERN } from './wasm-hash.js'
17
+
18
+ const SDK_ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..')
19
+ const VOCABULARY_PATH = join(SDK_ROOT, 'bin', 'permission-vocabulary.json')
20
+
21
+ const VALID_PLUGIN_TYPES = new Set(['frontend', 'backend', 'full'])
22
+ /** 退役 pluginType → 迁移出路(fail-visible:点名旧值并给出新值,不静默拒绝) */
23
+ const RETIRED_PLUGIN_TYPES = new Map([
24
+ ['ts-only', 'frontend'],
25
+ ['rust', 'backend'],
26
+ ['rust-ts', 'full'],
27
+ ])
28
+
29
+ /**
30
+ * 适配平台取值域(manifest `platform`,必填,与 id/name/version 同档)
31
+ *
32
+ * 真源是 SDK `rust/src/types.rs::PluginPlatform`,此处只抄拼写(与 Rust 侧
33
+ * serde `rename_all = "lowercase"` 一致)。宿主在加载 / 安装期按本端校验:
34
+ * 桌面拒 `mobile`、移动拒 `desktop`,`both` 两端均可;构建期先拦拼写错误,
35
+ * 避免产出「装到目标端必被拒」的包。
36
+ */
37
+ const VALID_PLATFORMS = new Set(['desktop', 'mobile', 'both'])
38
+
39
+ /**
40
+ * 装配角色取值域(manifest `type`,ADR 0032)
41
+ *
42
+ * 真源是 SDK `rust/src/types.rs::PluginKind`,此处不手抄第二套语义,只抄拼写
43
+ * (与 Rust 侧 serde `rename_all = "kebab-case"` 一致;改枚举必须同改这里,
44
+ * 否则新角色在本机过不了、装了却不被宿主识别)。
45
+ */
46
+ const VALID_PLUGIN_KINDS = new Set(['basic-service', 'internal-business', 'business-app'])
47
+
48
+ /** 历史拼写(反序列化仍被宿主按别名接受,ADR 0032 之前)→ 现行角色 + 告警文案 */
49
+ const LEGACY_PLUGIN_KINDS = new Map([
50
+ ['system', 'basic-service'],
51
+ ['application', 'business-app'],
52
+ ])
53
+
54
+ /** 实例生命周期取值域(manifest `lifecycle`,ADR 0032;真源同 PluginKind 所在文件) */
55
+ const VALID_LIFECYCLES = new Set(['persistent', 'ephemeral'])
56
+
57
+ /** 权限词汇生成物(惰性读:缺文件时给出可操作的错误,而非 CLI 启动即崩) */
58
+ let vocabulary = null
59
+ export function permissionVocabulary() {
60
+ if (vocabulary) return vocabulary
61
+ let parsed
62
+ try {
63
+ parsed = JSON.parse(readFileSync(VOCABULARY_PATH, 'utf-8'))
64
+ } catch (e) {
65
+ throw new Error(
66
+ `权限词汇生成物不可读: ${VOCABULARY_PATH} — 在 SDK 包目录跑 pnpm run gen:permissions 重出(${e.message})`,
67
+ )
68
+ }
69
+ if (!Array.isArray(parsed?.permissions)) {
70
+ throw new Error(`权限词汇生成物形状不符(缺 permissions 数组): ${VOCABULARY_PATH}`)
71
+ }
72
+ vocabulary = { permissions: new Set(parsed.permissions), apiMap: parsed.apiMap || {} }
73
+ return vocabulary
74
+ }
75
+
76
+ /**
77
+ * 校验插件目录的 plugin.json
78
+ * @param {string} dir 插件工程目录
79
+ * @returns {{manifest: object, errors: string[], warnings: string[]}} errors 非空即不合法
80
+ */
81
+ export function validateManifest(dir) {
82
+ const manifestPath = join(dir, 'plugin.json')
83
+ const errors = []
84
+ const warnings = []
85
+
86
+ if (!existsSync(manifestPath)) {
87
+ return { manifest: null, errors: [`缺少 plugin.json: ${dir}`], warnings }
88
+ }
89
+
90
+ let manifest
91
+ try {
92
+ manifest = JSON.parse(readFileSync(manifestPath, 'utf-8'))
93
+ } catch (e) {
94
+ return { manifest: null, errors: [`plugin.json 不是合法 JSON: ${e.message}`], warnings }
95
+ }
96
+
97
+ // id:反域名风格
98
+ if (
99
+ typeof manifest.id !== 'string' ||
100
+ !/^[a-zA-Z0-9]+([._-][a-zA-Z0-9]+)*$/.test(manifest.id) ||
101
+ !manifest.id.includes('.')
102
+ ) {
103
+ errors.push(`id 非法: "${manifest.id}" — 使用反域名风格,如 com.example.my-plugin`)
104
+ }
105
+
106
+ // 必填字段(platform 与 id/name/version 同档:宿主反序列化无缺省,缺失即拒装)
107
+ for (const field of ['name', 'version', 'platform', 'main', 'pluginType', 'permissions', 'contributes']) {
108
+ if (manifest[field] === undefined || manifest[field] === null || manifest[field] === '') {
109
+ errors.push(`缺少必填字段: ${field}`)
110
+ }
111
+ }
112
+
113
+ // platform 取值域(拼写与宿主端门禁词汇同源;未知取值在宿主反序列化即拒)
114
+ if (manifest.platform && !VALID_PLATFORMS.has(manifest.platform)) {
115
+ errors.push(
116
+ `platform 非法: "${manifest.platform}"(允许: ${[...VALID_PLATFORMS].join(' / ')})`,
117
+ )
118
+ }
119
+
120
+ // pluginType / sandbox / rustLibrary
121
+ // pluginType 是语言无关的形态三档(frontend / backend / full,2026-10-26 语义
122
+ // 重定义,wasmnest-apps#21);旧值(rust / rust-ts / ts-only)退役——点名拒绝
123
+ // 并给出迁移出路(与宿主 serde 反序列化的错误口径一致,两侧都判死不留兼容期)
124
+ if (manifest.pluginType && !VALID_PLUGIN_TYPES.has(manifest.pluginType)) {
125
+ const retired = RETIRED_PLUGIN_TYPES.get(manifest.pluginType)
126
+ errors.push(
127
+ retired
128
+ ? `pluginType "${manifest.pluginType}" 已退役(形态三档重定义,2026-10-26,wasmnest-apps#21):改用 "${retired}"——词汇只表达形态,不表达后端语言`
129
+ : `pluginType 非法: "${manifest.pluginType}"(允许: ${[...VALID_PLUGIN_TYPES].join(' / ')})`,
130
+ )
131
+ }
132
+ if (manifest.sandbox && !['inline', 'isolated'].includes(manifest.sandbox)) {
133
+ errors.push(`sandbox 非法: "${manifest.sandbox}"(允许: inline / isolated)`)
134
+ }
135
+ // rustLibrary(wasm 模块名):前后端形态(full)必填——纯后端(backend)多为
136
+ // 构建链/内置注册形态,产物命名另有真源,不在此强制
137
+ if (manifest.pluginType === 'full' && !manifest.rustLibrary) {
138
+ errors.push('pluginType=full 时必须提供 rustLibrary(与 Cargo.toml 包名一致;键名暂保留历史拼写,见 wasmnest-apps#21 键位子决策)')
139
+ }
140
+
141
+ // type(装配角色,ADR 0032):L1 基础服务 / L2 内部统一业务 / L3 业务应用
142
+ // 非法取值**构建期拒**——宿主反序列化会拒(落 Error 态),但那时产物已发出去,
143
+ // 表现是「插件装了却不出现」;`system` / `application` 是历史拼写,宿主仍按别名
144
+ // 接受,故只告警不拦(拦会打断既有工程)。
145
+ if (manifest.type !== undefined && manifest.type !== null && manifest.type !== '') {
146
+ if (!VALID_PLUGIN_KINDS.has(manifest.type) && !LEGACY_PLUGIN_KINDS.has(manifest.type)) {
147
+ errors.push(
148
+ `type 非法: "${manifest.type}"(允许: ${[...VALID_PLUGIN_KINDS].join(' / ')})`,
149
+ )
150
+ } else if (LEGACY_PLUGIN_KINDS.has(manifest.type)) {
151
+ warnings.push(
152
+ `type="${manifest.type}" 是历史拼写,改写为 "${LEGACY_PLUGIN_KINDS.get(manifest.type)}"(ADR 0032 角色维度重构)`,
153
+ )
154
+ }
155
+ }
156
+
157
+ // lifecycle(实例生命周期,ADR 0032):缺省 persistent;`ephemeral`(业务 worker)
158
+ // **只预留类型**——宿主一次性实例机制与调度框架未落地(ADR 0032 §6 启用清单),
159
+ // 声明后在宿主加载期会被显性拒绝。构建期先拦,避免产出「装了必失败」的包。
160
+ if (manifest.lifecycle !== undefined && manifest.lifecycle !== null && manifest.lifecycle !== '') {
161
+ if (!VALID_LIFECYCLES.has(manifest.lifecycle)) {
162
+ errors.push(
163
+ `lifecycle 非法: "${manifest.lifecycle}"(允许: ${[...VALID_LIFECYCLES].join(' / ')},缺省即 persistent)`,
164
+ )
165
+ } else if (manifest.lifecycle === 'ephemeral') {
166
+ if (manifest.pluginType !== 'backend') {
167
+ errors.push(
168
+ `lifecycle="ephemeral" 只能配 pluginType="backend"(即用即弃 worker 无页面产物): ${JSON.stringify(manifest.pluginType)}`,
169
+ )
170
+ } else {
171
+ errors.push(
172
+ 'lifecycle="ephemeral" 暂不可用:宿主一次性实例机制与调度框架尚未落地(业务 worker 形态已登记,见 ADR 0032 §6;启用前需补齐调度方、store 传参协议、权限模型与 per-app 配额)',
173
+ )
174
+ }
175
+ }
176
+ }
177
+
178
+ // wasmHash(票 14):形态非法即拒;**值由构建注入产物**,源清单带它属于误用——
179
+ // manifest-gen 只回填 contributes/permissions,陈旧摘要会一路活到分发链(该链按字节复核后拒发)。
180
+ if (manifest.wasmHash !== undefined && manifest.wasmHash !== null && manifest.wasmHash !== '') {
181
+ if (typeof manifest.wasmHash !== 'string' || !WASM_HASH_PATTERN.test(manifest.wasmHash)) {
182
+ errors.push(
183
+ `wasmHash 形态非法(须为小写 64 位十六进制 SHA-256): ${JSON.stringify(manifest.wasmHash)}`,
184
+ )
185
+ }
186
+ warnings.push(
187
+ 'wasmHash 由构建链注入产物 plugin.json,源清单不必手写该键(写了也不会被刷新)',
188
+ )
189
+ }
190
+
191
+ // ptyQuota(会话引擎下沉 P1 / H1):可选,声明该插件可同时在册的 host-pty 句柄数。
192
+ // 本处只校**形态**(正整数)——区间上限是内核常量
193
+ // `PLUGIN_PTY_SESSIONS_CEILING_PER_PLUGIN`,在此复刻一份数字就是把配额判据拆成两处
194
+ // (改内核常量不会同步到这里);越界由宿主加载期拒绝(manager/validation.rs),
195
+ // 构建期误写 0 / 小数 / 字符串则在这里当场拒绝,不必等到装包才暴露。
196
+ if (manifest.ptyQuota !== undefined && manifest.ptyQuota !== null) {
197
+ if (!Number.isInteger(manifest.ptyQuota) || manifest.ptyQuota <= 0) {
198
+ errors.push(
199
+ `ptyQuota 形态非法(须为正整数;上限由宿主内核常量仲裁): ${JSON.stringify(manifest.ptyQuota)}`,
200
+ )
201
+ }
202
+ }
203
+
204
+ // 权限:SDK 词汇真源之外的声明会在授权时被静默过滤,等于装饰词汇 → 直接拒绝
205
+ if (Array.isArray(manifest.permissions)) {
206
+ const { permissions } = permissionVocabulary()
207
+ const unknown = manifest.permissions.filter((p) => !permissions.has(p))
208
+ if (unknown.length) {
209
+ errors.push(
210
+ `未知权限: ${unknown.join(', ')}(真源 SDK rust/src/permission.rs,声明未列入的权限会被宿主静默过滤)`,
211
+ )
212
+ }
213
+ }
214
+
215
+ // backgroundTransport(2026-10-23 用户裁决):运行期持有传输租约 = 应用整段
216
+ // 运行期对外可达(端口监听 + mDNS 广播)。必须与入站权限位同声明——没有
217
+ // ws:server / network:http 的应用既注册不出端点,也不该凭一个布尔位持续对外
218
+ // 广播。宿主加载期同规则(wasm-core `manager/validation.rs`),两侧都判死,
219
+ // 避免产出「装了必被拒」的包。
220
+ if (manifest.backgroundTransport !== undefined && manifest.backgroundTransport !== null) {
221
+ if (typeof manifest.backgroundTransport !== 'boolean') {
222
+ errors.push(
223
+ `backgroundTransport 形态非法(须为布尔值): ${JSON.stringify(manifest.backgroundTransport)}`,
224
+ )
225
+ } else if (manifest.backgroundTransport) {
226
+ const INBOUND_SERVER_PERMISSIONS = ['ws:server', 'network:http']
227
+ const declared = Array.isArray(manifest.permissions) ? manifest.permissions : []
228
+ if (!INBOUND_SERVER_PERMISSIONS.some((permission) => declared.includes(permission))) {
229
+ errors.push(
230
+ 'backgroundTransport=true 但 permissions 未声明入站权限位' +
231
+ `(${INBOUND_SERVER_PERMISSIONS.join(' / ')} 至少一个):` +
232
+ '运行期持有传输租约会让应用整段运行期对外可达,必须与对应的服务端权限一起声明',
233
+ )
234
+ }
235
+ }
236
+ }
237
+
238
+ // main 产物存在性(未构建仅警告)
239
+ const distMain = join(dir, 'dist', manifest.main || 'index.js')
240
+ if (!existsSync(distMain)) {
241
+ warnings.push(`dist/${manifest.main || 'index.js'} 不存在 — 尚未构建(pnpm run build)`)
242
+ }
243
+
244
+ // contributes 结构
245
+ if (manifest.contributes && typeof manifest.contributes !== 'object') {
246
+ errors.push('contributes 必须是对象')
247
+ }
248
+
249
+
250
+ // contributes.monitorPanels(monitor 统一壳的自定义面板注册元数据)
251
+ // 只登记 id / title / order;面板实现住提供方应用工程(mountMonitorPanel),
252
+ // 因此这里不校验组件路径。非法条目会让面板「列得出来、挂不上」,构建期判死。
253
+ const monitorPanels = manifest.contributes?.monitorPanels
254
+ if (monitorPanels !== undefined && monitorPanels !== null) {
255
+ if (!Array.isArray(monitorPanels)) {
256
+ errors.push('contributes.monitorPanels 必须是数组')
257
+ } else {
258
+ const panelIds = new Set()
259
+ for (const entry of monitorPanels) {
260
+ if (!entry || typeof entry !== 'object' || Array.isArray(entry)) {
261
+ errors.push(`contributes.monitorPanels 条目形态非法: ${JSON.stringify(entry)}`)
262
+ continue
263
+ }
264
+ if (typeof entry.id !== 'string' || entry.id.trim() === '') {
265
+ errors.push(`contributes.monitorPanels 条目缺非空 id: ${JSON.stringify(entry)}`)
266
+ } else if (panelIds.has(entry.id)) {
267
+ errors.push(`contributes.monitorPanels 重复 id: ${entry.id}`)
268
+ } else {
269
+ panelIds.add(entry.id)
270
+ }
271
+ if (typeof entry.title !== 'string' || entry.title.trim() === '') {
272
+ errors.push(`contributes.monitorPanels 条目缺非空 title: ${JSON.stringify(entry)}`)
273
+ }
274
+ if (entry.order !== undefined && !Number.isFinite(entry.order)) {
275
+ errors.push(`contributes.monitorPanels 条目 order 非法(须为数字): ${JSON.stringify(entry)}`)
276
+ }
277
+ }
278
+ }
279
+ }
280
+
281
+ // contributes.httpEndpoints(票 16 路径白名单、票 08 追加认证档位)
282
+ // 宿主**只认声明**:未声明路径 404,未声明清单等于没有 HTTP 面。条目两形态并存——
283
+ // 纯路径段(档位 = 宿主最严缺省 jwt)或 `{ path, auth }`。条目非法会让声明侧
284
+ // 「看起来有清单」而实际永远匹配不上,故构建期就判死;`auth` 取值真源是
285
+ // rust/src/types.rs 的 EndpointAuth(none|jwt),写错的条目在宿主侧不登记(端点不可达)。
286
+ const HTTP_ENDPOINT_AUTH_TIERS = ['none', 'jwt']
287
+ const httpEndpoints = manifest.contributes?.httpEndpoints
288
+ if (httpEndpoints !== undefined && httpEndpoints !== null) {
289
+ if (!Array.isArray(httpEndpoints)) {
290
+ errors.push('contributes.httpEndpoints 必须是「路径段字符串」或「{path, auth} 对象」的数组')
291
+ } else {
292
+ for (const entry of httpEndpoints) {
293
+ const isString = typeof entry === 'string'
294
+ const isObject = entry !== null && typeof entry === 'object' && !Array.isArray(entry)
295
+ if (!isString && !isObject) {
296
+ errors.push(
297
+ `contributes.httpEndpoints 条目形态非法(须为字符串或 {path, auth} 对象): ${JSON.stringify(entry)}`,
298
+ )
299
+ continue
300
+ }
301
+ const path = isString ? entry : entry.path
302
+ if (typeof path !== 'string' || path.trim() === '' || path.includes('..')) {
303
+ errors.push(
304
+ `contributes.httpEndpoints 条目 path 非法(须为非空相对路径段、不含 ..): ${JSON.stringify(entry)}`,
305
+ )
306
+ }
307
+ if (isString) continue
308
+ const extraKeys = Object.keys(entry).filter((k) => k !== 'path' && k !== 'auth')
309
+ if (extraKeys.length) {
310
+ errors.push(
311
+ `contributes.httpEndpoints 条目含未知字段(只允许 path / auth): ${extraKeys.join(', ')} → ${JSON.stringify(entry)}`,
312
+ )
313
+ }
314
+ if (entry.auth !== undefined && !HTTP_ENDPOINT_AUTH_TIERS.includes(entry.auth)) {
315
+ errors.push(
316
+ `contributes.httpEndpoints 条目 auth 取值非法(须为 ${HTTP_ENDPOINT_AUTH_TIERS.join(' | ')},缺省即最严档 jwt): ${JSON.stringify(entry)}`,
317
+ )
318
+ }
319
+ }
320
+ const normalized = httpEndpoints
321
+ .map((entry) => (typeof entry === 'string' ? entry : entry?.path))
322
+ .filter((p) => typeof p === 'string')
323
+ .map((p) => p.trim().replace(/^\/+/, ''))
324
+ const dup = normalized.filter((p, i) => normalized.indexOf(p) !== i)
325
+ if (dup.length) {
326
+ errors.push(`contributes.httpEndpoints 重复声明: ${[...new Set(dup)].join(', ')}`)
327
+ }
328
+ }
329
+ }
330
+
331
+ // contributes.wsEndpoints(票 09a WS 动作词表声明式化 · expand)
332
+ // 与 httpEndpoints 同构:纯路径段(档位 = 宿主 WS 默认档 none)或 `{ path, auth }`。
333
+ // 支持声明式 WS 端点:宿主按声明静态登记进 WS 注册表并精确匹配,未声明路径不可达。
334
+ // 条目非法会让声明侧「看起来有清单」而实际永远匹配不上,故构建期就判死;`auth` 取值真源
335
+ // 同样是 rust/src/types.rs 的 EndpointAuth(none|jwt)。
336
+ const WS_ENDPOINT_AUTH_TIERS = ['none', 'jwt']
337
+ const WS_ENDPOINT_PATH_MAX_LEN = 64
338
+ const wsEndpoints = manifest.contributes?.wsEndpoints
339
+ if (wsEndpoints !== undefined && wsEndpoints !== null) {
340
+ if (!Array.isArray(wsEndpoints)) {
341
+ errors.push('contributes.wsEndpoints 必须是「路径段字符串」或「{path, auth} 对象」的数组')
342
+ } else {
343
+ for (const entry of wsEndpoints) {
344
+ const isString = typeof entry === 'string'
345
+ const isObject = entry !== null && typeof entry === 'object' && !Array.isArray(entry)
346
+ if (!isString && !isObject) {
347
+ errors.push(
348
+ `contributes.wsEndpoints 条目形态非法(须为字符串或 {path, auth} 对象): ${JSON.stringify(entry)}`,
349
+ )
350
+ continue
351
+ }
352
+ const path = isString ? entry : entry.path
353
+ if (
354
+ typeof path !== 'string' ||
355
+ path.trim() === '' ||
356
+ path.includes('/') ||
357
+ path.includes('.') ||
358
+ [...path].length > WS_ENDPOINT_PATH_MAX_LEN
359
+ ) {
360
+ errors.push(
361
+ `contributes.wsEndpoints 条目 path 非法(须为非空单段相对路径、不含 / 或 .、长度不超过 ${WS_ENDPOINT_PATH_MAX_LEN}): ${JSON.stringify(entry)}`,
362
+ )
363
+ }
364
+ if (isString) continue
365
+ const extraKeys = Object.keys(entry).filter((k) => k !== 'path' && k !== 'auth')
366
+ if (extraKeys.length) {
367
+ errors.push(
368
+ `contributes.wsEndpoints 条目含未知字段(只允许 path / auth): ${extraKeys.join(', ')} → ${JSON.stringify(entry)}`,
369
+ )
370
+ }
371
+ const auth = typeof entry.auth === 'string' ? entry.auth.trim() : entry.auth
372
+ if (
373
+ entry.auth !== undefined &&
374
+ entry.auth !== null &&
375
+ entry.auth !== '' &&
376
+ (typeof auth !== 'string' || !WS_ENDPOINT_AUTH_TIERS.includes(auth))
377
+ ) {
378
+ errors.push(
379
+ `contributes.wsEndpoints 条目 auth 取值非法(须为 ${WS_ENDPOINT_AUTH_TIERS.join(' | ')},缺省即 WS 默认档 none): ${JSON.stringify(entry)}`,
380
+ )
381
+ }
382
+ }
383
+ const normalized = wsEndpoints
384
+ .map((entry) => (typeof entry === 'string' ? entry : entry?.path))
385
+ .filter((p) => typeof p === 'string')
386
+ .map((p) => p.trim())
387
+ const dup = normalized.filter((p, i) => normalized.indexOf(p) !== i)
388
+ if (dup.length) {
389
+ errors.push(`contributes.wsEndpoints 重复声明: ${[...new Set(dup)].join(', ')}`)
390
+ }
391
+ }
392
+ }
393
+
394
+ // wasiPreopenDirs(票 07 只读档;ADR 0034 归属类别闸门):条目两形态——裸路径字符串
395
+ // (可写,既有形态)或 `{ path, readonly }` 对象。这里管形态,宿主 Rust 端(SDK
396
+ // rust/src/types.rs::WasiPreopenDir::from_json)管仲裁:未知键 / 非布尔 readonly
397
+ // 若被静默忽略,只读声明会退化成可写挂载,所以两侧都不放过。
398
+ //
399
+ // **类别闸门(ADR 0034)**:`wasiPreopenDirs` 仅 worker 类别(lifecycle="ephemeral")
400
+ // 可用——主 wasm-app 文件访问一律走宿主 host-fs 授权机制。非 worker 声明即构建期
401
+ // 显性拒绝(不静默忽略:静默忽略会让「声明了却没人读它」的目录配置一路活到分发链)。
402
+ // worker 未实现期间(ADR 0032 §6 双侧拒绝)ephemeral 本身被下方 lifecycle 分支拦截,
403
+ // 故该字段当前对一切 manifest 不可达;此处闸门是取值域层面的落死。
404
+ const preopenDirs = manifest.wasiPreopenDirs
405
+ if (preopenDirs !== undefined && preopenDirs !== null) {
406
+ if (manifest.lifecycle !== 'ephemeral') {
407
+ errors.push(
408
+ 'wasiPreopenDirs 仅 worker 类别(lifecycle="ephemeral")可用:业务应用文件访问一律走宿主 host-fs 授权机制(permissions 声明 fs:read/fs:write,目录经 fs_request_auth 授权并持久化),见 ADR 0034',
409
+ )
410
+ }
411
+ if (!Array.isArray(preopenDirs)) {
412
+ errors.push('wasiPreopenDirs 必须是「路径字符串」或「{path, readonly} 对象」的数组')
413
+ } else {
414
+ for (const entry of preopenDirs) {
415
+ const isString = typeof entry === 'string'
416
+ const isObject = entry !== null && typeof entry === 'object' && !Array.isArray(entry)
417
+ if (!isString && !isObject) {
418
+ errors.push(
419
+ `wasiPreopenDirs 条目形态非法(须为路径字符串或 {path, readonly} 对象): ${JSON.stringify(entry)}`,
420
+ )
421
+ continue
422
+ }
423
+ const path = isString ? entry : entry.path
424
+ if (typeof path !== 'string' || path.trim() === '') {
425
+ errors.push(
426
+ `wasiPreopenDirs 条目 path 非法(须为非空字符串,支持 \${home} 前缀): ${JSON.stringify(entry)}`,
427
+ )
428
+ }
429
+ if (isString) continue
430
+ const extraKeys = Object.keys(entry).filter((k) => k !== 'path' && k !== 'readonly')
431
+ if (extraKeys.length) {
432
+ errors.push(
433
+ `wasiPreopenDirs 条目含未知字段(只允许 path / readonly): ${extraKeys.join(', ')} → ${JSON.stringify(entry)}`,
434
+ )
435
+ }
436
+ if (entry.readonly !== undefined && typeof entry.readonly !== 'boolean') {
437
+ errors.push(
438
+ `wasiPreopenDirs 条目 readonly 必须是布尔(缺省即可写;写错不会静默降级): ${JSON.stringify(entry)}`,
439
+ )
440
+ }
441
+ }
442
+ }
443
+ }
444
+
445
+ // update(应用更新源声明,2026-11-02 应用版本更新全链路):缺省 = 不参与
446
+ // 更新检查;声明后 repo / slug / tagPrefix 会成为宿主拼 URL 与资产名的输入,
447
+ // 形态非法在构建期拦下(与内核 `app_update::resolve_update_source` 同判据)。
448
+ if (manifest.update !== undefined && manifest.update !== null) {
449
+ const update = manifest.update
450
+ if (typeof update !== 'object' || Array.isArray(update)) {
451
+ errors.push(`update 必须是对象: ${JSON.stringify(update)}`)
452
+ } else {
453
+ if (update.provider !== undefined && update.provider !== 'github-release') {
454
+ errors.push(`update.provider 非法: "${update.provider}"(当前只支持 github-release)`)
455
+ }
456
+ if (update.repo !== undefined) {
457
+ const repo = update.repo
458
+ if (
459
+ typeof repo !== 'string' ||
460
+ !/^[A-Za-z0-9._-]+\/[A-Za-z0-9._-]+$/.test(repo) ||
461
+ repo.split('/').some((part) => part === '.' || part === '..')
462
+ ) {
463
+ errors.push(`update.repo 非法: ${JSON.stringify(repo)}(须为 GitHub 的 owner/name)`)
464
+ }
465
+ }
466
+ if (update.slug !== undefined) {
467
+ const slug = update.slug
468
+ if (typeof slug !== 'string' || !/^[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/.test(slug)) {
469
+ errors.push(`update.slug 非法: ${JSON.stringify(slug)}(小写字母数字与 '-',不能以 '-' 开头/结尾)`)
470
+ }
471
+ }
472
+ if (update.tagPrefix !== undefined) {
473
+ const prefix = update.tagPrefix
474
+ if (
475
+ typeof prefix !== 'string' ||
476
+ prefix.trim() === '' ||
477
+ prefix.includes('/') ||
478
+ prefix.includes('..') ||
479
+ /\s/.test(prefix)
480
+ ) {
481
+ errors.push(`update.tagPrefix 非法: ${JSON.stringify(prefix)}(非空,不含 '/'、'..' 或空白)`)
482
+ }
483
+ }
484
+ const extraKeys = Object.keys(update).filter(
485
+ (k) => !['provider', 'repo', 'tagPrefix', 'slug'].includes(k),
486
+ )
487
+ if (extraKeys.length) {
488
+ errors.push(`update 含未知字段: ${extraKeys.join(', ')}(只允许 provider / repo / tagPrefix / slug)`)
489
+ }
490
+ }
491
+ }
492
+
493
+ return { manifest, errors, warnings }
494
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "_generated": "生成物,勿手改。真源 packages/plugin-sdk-desktop/rust/src/permission.rs;重跑:SDK 包目录 pnpm run gen:permissions",
3
+ "permissions": ["terminal:input", "terminal:output", "session:read", "connection:read", "ui:sidebar", "ui:toolbox", "ui:statusbar", "ui:dialog", "ui:pageToolbar", "ui:settings", "ui:input", "ui:fileHandler", "network:http", "storage", "fs:read", "fs:write", "fs:pick", "broadcast", "timer:schedule", "process:run", "app:cli", "app:path", "peer", "mdns", "ws:client", "ws:server", "auth", "pty:spawn", "pty:io", "task:run", "worker:run", "crypto:aead", "crypto:asym", "crypto:kdf", "metrics:read", "notify", "clipboard:read", "clipboard:write", "tunnel:serve", "tunnel:connect", "tunnel:probe"],
4
+ "apiMap": { "terminal:input": ["terminal.onInput"], "terminal:output": ["terminal.onOutput"], "session:read": ["session.predictTerminalSize","session.openTerminal","session.closeTerminal","session.isTerminalOpen"], "connection:read": [], "ui:sidebar": ["ui.registerSidebarPanel","ui.registerPage"], "ui:toolbox": ["ui.registerToolboxPage"], "ui:statusbar": ["ui.registerStatusBarItem","ui.registerTitleBarItem"], "ui:dialog": ["ui.showDialog"], "ui:pageToolbar": ["ui.registerPageToolbarItem"], "ui:settings": ["ui.registerSettingsSection"], "ui:input": ["ui.registerInputExtension","ui.registerTerminalToolbarItem"], "ui:fileHandler": ["ui.registerFileHandler"], "network:http": ["http.registerEndpoint"], "storage": ["storage.get","storage.set","storage.delete","storage.flush"], "fs:read": ["fs.read","fs.copy"], "fs:write": ["fs.write","fs.copy"], "fs:pick": ["platform.pickFiles","platform.pickFolder","platform.pickFolders"], "broadcast": [], "timer:schedule": ["timer.register"], "process:run": ["process.run","process.kill"], "app:cli": ["app.cliInstall","app.cliUninstall"], "app:path": ["app.pathRegister","app.pathUnregister"], "peer": ["peer.listDevices","peer.dial","peer.disconnect","peer.respondConsent","peer.listTrusted","peer.revokeTrusted","peer.sendFiles","peer.listTransfers","peer.cancelTransfer","peer.retryTransfer","peer.clearTransferHistory","peer.listReceiving","peer.respondTransfer","peer.cancelReceiving","peer.clearReceivingHistory","peer.getReceiveSettings","peer.setReceivePolicy","peer.listSharedDirectories","peer.removeSharedDirectory","peer.addSharedDirectory","peer.listSharedRoots","peer.browseDirectory","peer.pullFiles","peer.pickFiles","peer.dialEndpoint","peer.close","peer.setSharedRoots"], "mdns": ["mdns.browse","mdns.stopBrowse","mdns.advertise","mdns.stopAdvertise","mdns.isAdvertising"], "ws:client": ["ws.connect","ws.sendText","ws.sendBinary","ws.close","ws.isConnected"], "ws:server": ["ws.registerEndpoint","ws.sendTextToClient","ws.sendBinaryToClient","ws.broadcastText","ws.broadcastBinary","ws.closeClient","ws.unregisterEndpoint","ws.listClients","ws.listEndpoints"], "auth": [], "pty:spawn": ["pty.spawn","pty.kill"], "pty:io": ["pty.write","pty.resize","pty.ringFetch","pty.isRunning"], "task:run": [], "worker:run": ["worker.submit","worker.cancel"], "crypto:aead": ["crypto.aeadEncrypt","crypto.aeadDecrypt","crypto.aeadGenerateKey","crypto.aeadGenerateNonce"], "crypto:asym": ["crypto.keyAgreementGenerate","crypto.keyAgreementShared"], "crypto:kdf": ["crypto.kdfDerive"], "metrics:read": ["metrics.snapshot"], "notify": [], "clipboard:read": ["clipboard.readText"], "clipboard:write": ["clipboard.writeText"], "tunnel:serve": ["tunnel.expose","tunnel.unexpose","tunnel.issuePairingTicket"], "tunnel:connect": ["tunnel.connect","tunnel.close"], "tunnel:probe": ["tunnel.probeRelay"] }
5
+ }