@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,38 @@
1
+ package wasmnest:platform-desktop@0.0.1;
2
+
3
+ // 桌面端能力域分片(WIT 按包拆分,ADR 0061):一个能力域 = 一个独立包,
4
+ // 版本独立演进——本包 WIT 变更只 bump 本包,不波及未 import 它的应用。
5
+ // 端 `plugin` world 经 `include wasmnest:platform-desktop/cap-platform-desktop@0.0.1;` 并入本接口。
6
+
7
+ /// 平台能力桌面扩展(v36 自 `host-platform` 拆出,双端交集切片——桌面独有 3 函数;
8
+ /// `pick-folders` 已按 2026-10-13 功能级统一迁 core `host-platform`)
9
+ interface host-platform-desktop {
10
+ /// WSL 发行版名枚举(v19 函数级追加):`string[]` JSON,顺序即
11
+ /// `wsl --list --verbose` 输出顺序。宿主无 WSL(非 Windows / 未安装 /
12
+ /// 命令不可用)时**显性报错**而非空数组——空数组会被消费方读成「装了 0 个
13
+ /// 发行版」,与「本机没有 WSL」不可区分(会话配置表单据此决定渲染下拉还是
14
+ /// 「未检测到 WSL」提示)。平台事实、无业务语义(ADR 0022 裁剪线)。
15
+ wsl-distros: func() -> result<string, string>;
16
+ /// 本机可访问的 IPv4 地址枚举(v19 函数级追加):`string[]` JSON,
17
+ /// 已排除回环与链路本地(与会话中心设备页原宿主命令 `get_local_ip_addresses`
18
+ /// 同口径),顺序即网卡枚举顺序。设备页据此渲染「移动端可访问的 IP」下拉。
19
+ /// 平台事实、无业务语义(ADR 0022 裁剪线);地址为空(无可用网卡)时返回
20
+ /// **空数组**(与 `wsl-distros` 的显性报错口径不同:此处「没有可用地址」是
21
+ /// 合法状态,前端渲染「未找到可用的 IPv4 地址」提示)。
22
+ local-ipv4-addresses: func() -> result<string, string>;
23
+ /// 在系统文件管理器中定位并选中文件/目录(v22 函数级追加):参数为绝对路径,
24
+ /// 路径不存在时**显性报错**(`reveal: path not found: …`)。平台实现:Windows
25
+ /// Shell COM(`SHOpenFolderAndSelectItems`,含 `\\?\` verbatim 前缀剥离与
26
+ /// `ERROR_FILE_NOT_FOUND` 兜底)/ macOS `open -R` / Linux `xdg-open`(打开所在
27
+ /// 目录,无选中语义)。
28
+ ///
29
+ /// 与 `pick-*` 同口径:定位是**平台交互动作、不读取任何数据**(路径本就由调用方
30
+ /// 提供),故**不叠加权限门**(ADR 0022 裁剪线);原先挂在宿主命令
31
+ /// `plugin_reveal_in_dir` + `system:open` 权限上的形态是「能力已存在但没有原语」
32
+ /// 的遗留形态(宿主命令面有授能力、但插件侧无原语可调)。
33
+ reveal-in-dir: func(path: string) -> result<_, string>;
34
+ }
35
+
36
+ world cap-platform-desktop {
37
+ import host-platform-desktop;
38
+ }
@@ -0,0 +1,25 @@
1
+ package wasmnest:process@0.0.1;
2
+
3
+ // 桌面端能力域分片(WIT 按包拆分,ADR 0061):一个能力域 = 一个独立包,
4
+ // 版本独立演进——本包 WIT 变更只 bump 本包,不波及未 import 它的应用。
5
+ // 端 `plugin` world 经 `include wasmnest:process/cap-process@0.0.1;` 并入本接口。
6
+
7
+ /// 进程执行(v8:host-process)——调度框架等插件需要执行外部命令/脚本
8
+ ///
9
+ /// 异步执行:`run` 立即返回 run-id,进程结束后宿主经 `events.on-process-done`
10
+ /// 回调插件(携带 exit_code / 超时标记);`kill` 用于超时/取消。
11
+ interface host-process {
12
+ run: func(request-json: string) -> result<string, string>;
13
+ kill: func(run-id: string) -> result<_, string>;
14
+ /// v19 函数级追加(工作区 git 域):**同步**执行并捕获输出。
15
+ /// request-json 同 `run`(command / args / cwd / env / timeout_ms,无
16
+ /// output_path——输出由宿主捕获);返回
17
+ /// `{exitCode, stdout, stderr, timedOut}`。同步阻塞等待进程结束,供插件
18
+ /// 同步路径(HTTP 端点命令面)使用;`run` 是异步事件模型(run-id +
19
+ /// on_process_done 回调),不适配「命令面里同步拿结果」。权限 `process:run`。
20
+ run-sync: func(request-json: string) -> result<string, string>;
21
+ }
22
+
23
+ world cap-process {
24
+ import host-process;
25
+ }
@@ -0,0 +1,80 @@
1
+ package wasmnest:pty@0.0.1;
2
+ // ======================================================================
3
+ /// 插件私有伪终端(host-pty,v16):裸 PTY 引擎原语,零业务语义(ADR 0022)
4
+ ///
5
+ /// **与宿主业务会话线的边界(终态,v27 + v28 后)**:本接口是**宿主侧唯一的 PTY 出口**,
6
+ /// 而业务会话本身就是一个本接口的句柄(会话 id 由插件自产,登记 / 状态机 / 输入输出编排
7
+ /// 全在 `com.wasmnest.bedcode` 私有域)。宿主**不再持有任何会话对象**:内核会话目录
8
+ /// `src-tauri/src/session/` 整目录删除,`host-session` 与 `host-terminal` 两个 interface
9
+ /// 随 v27 退役,PTY 引擎只有本接口这一张注册表(无 SessionManager、无业务输出总线、
10
+ /// 引擎不注入 `WASMNEST_SESSION_ID`)。**v28 起宿主也不再直读任何插件 PTY 的输出环**
11
+ /// (`hostBroadcastSessionId` 只读订阅声明已删除,详见下方版本说明)——输出只经属主
12
+ /// 插件的 `ring-fetch` 游标拉取。
13
+ ///
14
+ /// 约定与红线:
15
+ /// - **属主隔离**:句柄 `pty-<uuid>` 仅创建者插件可调,他人 → `not owner of pty handle`;
16
+ /// 插件停用时宿主回收其全部 PTY(kill + 摘注册表 + 补发 `pty:exit`)
17
+ /// - **输出纯拉取**(无 push 回调):宿主为每个 PTY 维护有界环形缓冲,插件按
18
+ /// 自己的节奏以游标拉取;慢插件只损失自己的历史(淘汰最旧 + `truncated`),
19
+ /// 背压绝不回传到 PTY 读取端
20
+ /// - **环的消费者只有属主插件一个**:曾允许 `spawn` 声明 `hostBroadcastSessionId`
21
+ /// 把本句柄挂进宿主侧的「会话 id → pty 句柄」只读映射、供宿主 server 直读同进程
22
+ /// `PtyRing`。该字段与宿主直读路径均已删除(PTY 引擎不再知道 session id),
23
+ /// 输出只能经本接口 `ring-fetch` 拉取
24
+ /// - **并发拉取**:游标由调用方自持、拉取本身是纯读(不消费、不推进全局状态);
25
+ /// 淘汰由**产出量**驱动(环满即淘汰最旧),读取不释放空间,慢消费者落后于
26
+ /// 驻留起点即 `truncated`(环容量需覆盖最慢消费者的滞后)
27
+ /// - **生命周期事件**:仅 `<owner>::pty:exit` 一条(host-bus 订阅,属主私有命名空间,
28
+ /// 跨属主订阅被宿主拒绝)。payload `{ ptyId, reason, exitCode? }`(camelCase),
29
+ /// `reason = "stopped" | "killed" | "error"`。**须在 activate 期订阅**:宿主不缓冲、
30
+ /// 不重放,晚订阅期间的丢失靠 `is-running` 快照自愈。事件发出即摘除注册表与环,
31
+ /// 插件应先消费完输出(`ring-fetch` 的 `next-offset` 不再前进)再等退出事件
32
+ /// - **明确不做**(业务语义归插件层):shell 包装(bash -lic / PowerShell -Command /
33
+ /// CMD /K)、WSL 路径转换、危险字符校验、默认 shell 探测、特殊键 API、close/reopen
34
+ ///
35
+ /// 权限两域(可独立授予/审计):`pty:spawn`(spawn / kill——任意命令执行的高风险面)、
36
+ /// `pty:io`(write / resize / ring-fetch / is-running——数据面)。
37
+ interface host-pty {
38
+ /// 一次拉取的返回(游标语义见 `ring-fetch`)
39
+ record ring-fetch-result {
40
+ /// `[实际起点, next-offset)` 区间的原始字节(未解码,可能是非 UTF-8)
41
+ data: list<u8>,
42
+ /// 下一次拉取应传的游标
43
+ next-offset: u64,
44
+ /// `from-offset` 落后于环驻留起点(中间字节已被淘汰)→ 调用方按 resync 重建上下文
45
+ truncated: bool,
46
+ }
47
+
48
+ /// 创建裸 PTY:成功返回句柄 `pty-<uuid>` 并登记属主;失败只回错误且
49
+ /// **不发布任何事件**(无句柄可寻址)。
50
+ /// config-json(camelCase,纯引擎参数,宿主不做 shell 解析):
51
+ /// `{ command, args?, env?, workingDir?, cols?, rows?, ringBytes? }`
52
+ /// (参数数组 exec 天然免注入;`env` 为追加进继承环境的键值;尺寸缺省取宿主终端配置
53
+ /// `terminal.default_cols` / `default_rows`,与业务线同源;`ringBytes` 是本条 PTY
54
+ /// 的输出环容量,缺省取宿主默认,超宿主上限或超出每插件在册条数上限一律 `Err`
55
+ /// ——配额类失败可见,不静默降级也不静默淘汰既有句柄)。
56
+ spawn: func(config-json: string) -> result<string, string>;
57
+ /// 写入输入字节(分块语义宿主内建;超单次上限 → Err)
58
+ write: func(pty-id: string, data: list<u8>) -> result<_, string>;
59
+ /// 调整终端尺寸(TUI 程序全屏刷新依赖)
60
+ resize: func(pty-id: string, cols: u16, rows: u16) -> result<_, string>;
61
+ /// 终止并销毁(优雅 Ctrl-C → 兜底强杀);随后发布 `<owner>::pty:exit`(reason=killed)
62
+ kill: func(pty-id: string) -> result<_, string>;
63
+ /// 按游标拉取输出历史
64
+ /// - `Ok(None)`:游标已追平产出端,无新字节
65
+ /// - `Ok(Some)`:自游标起的字节(单次不超 `max-bytes`),`next-offset` 续拉不重复
66
+ /// - `truncated = true`:`from-offset` 落后于环驻留起点,返回的是现存最早段
67
+ /// - `Err`:句柄不存在 / 非属主 / 权限缺失
68
+ ///
69
+ /// **并发拉取**:游标由调用方自持、互不干扰(`from-offset` 只描述本次拉取的窗口,
70
+ /// 拉取不消费不改变全局偏移);淘汰按产出量全局计,任一读取都不为他人保留历史,
71
+ /// 落后于驻留起点即 `truncated`。(消费者只有属主插件自己。)
72
+ ring-fetch: func(pty-id: string, from-offset: u64, max-bytes: u32) -> result<option<ring-fetch-result>, string>;
73
+ /// 进程是否仍在运行(丢失 `pty:exit` 事件后的自愈快照查询)
74
+ is-running: func(pty-id: string) -> result<bool, string>;
75
+ }
76
+ // 本分片供能力域 crate(pty-engine)自持 bindgen;端生成物由 compose-wit.mjs
77
+ // 收集到 `plugin-sdk-desktop/rust/wit/` 与共享核心同 package 拼装。
78
+ world cap-pty {
79
+ import host-pty;
80
+ }
@@ -0,0 +1,25 @@
1
+ package wasi:random@0.2.0;
2
+ /// The insecure-seed interface for seeding hash-map DoS resistance.
3
+ ///
4
+ /// It is intended to be portable at least between Unix-family platforms and
5
+ /// Windows.
6
+ interface insecure-seed {
7
+ /// Return a 128-bit value that may contain a pseudo-random value.
8
+ ///
9
+ /// The returned value is not required to be computed from a CSPRNG, and may
10
+ /// even be entirely deterministic. Host implementations are encouraged to
11
+ /// provide pseudo-random values to any program exposed to
12
+ /// attacker-controlled content, to enable DoS protection built into many
13
+ /// languages' hash-map implementations.
14
+ ///
15
+ /// This function is intended to only be called once, by a source language
16
+ /// to initialize Denial Of Service (DoS) protection in its hash-map
17
+ /// implementation.
18
+ ///
19
+ /// # Expected future evolution
20
+ ///
21
+ /// This will likely be changed to a value import, to prevent it from being
22
+ /// called multiple times and potentially used for purposes other than DoS
23
+ /// protection.
24
+ insecure-seed: func() -> tuple<u64, u64>;
25
+ }
@@ -0,0 +1,22 @@
1
+ package wasi:random@0.2.0;
2
+ /// The insecure interface for insecure pseudo-random numbers.
3
+ ///
4
+ /// It is intended to be portable at least between Unix-family platforms and
5
+ /// Windows.
6
+ interface insecure {
7
+ /// Return `len` insecure pseudo-random bytes.
8
+ ///
9
+ /// This function is not cryptographically secure. Do not use it for
10
+ /// anything related to security.
11
+ ///
12
+ /// There are no requirements on the values of the returned bytes, however
13
+ /// implementations are encouraged to return evenly distributed values with
14
+ /// a long period.
15
+ get-insecure-random-bytes: func(len: u64) -> list<u8>;
16
+
17
+ /// Return an insecure pseudo-random `u64` value.
18
+ ///
19
+ /// This function returns the same type of pseudo-random data as
20
+ /// `get-insecure-random-bytes`, represented as a `u64`.
21
+ get-insecure-random-u64: func() -> u64;
22
+ }
@@ -0,0 +1,26 @@
1
+ package wasi:random@0.2.0;
2
+ /// WASI Random is a random data API.
3
+ ///
4
+ /// It is intended to be portable at least between Unix-family platforms and
5
+ /// Windows.
6
+ interface random {
7
+ /// Return `len` cryptographically-secure random or pseudo-random bytes.
8
+ ///
9
+ /// This function must produce data at least as cryptographically secure and
10
+ /// fast as an adequately seeded cryptographically-secure pseudo-random
11
+ /// number generator (CSPRNG). It must not block, from the perspective of
12
+ /// the calling program, under any circumstances, including on the first
13
+ /// request and on requests for numbers of bytes. The returned data must
14
+ /// always be unpredictable.
15
+ ///
16
+ /// This function must always return fresh data. Deterministic environments
17
+ /// must omit this function, rather than implementing it with deterministic
18
+ /// data.
19
+ get-random-bytes: func(len: u64) -> list<u8>;
20
+
21
+ /// Return a cryptographically-secure random or pseudo-random `u64` value.
22
+ ///
23
+ /// This function returns the same type of data as `get-random-bytes`,
24
+ /// represented as a `u64`.
25
+ get-random-u64: func() -> u64;
26
+ }
@@ -0,0 +1,7 @@
1
+ package wasi:random@0.2.0;
2
+
3
+ world imports {
4
+ import random;
5
+ import insecure;
6
+ import insecure-seed;
7
+ }
@@ -0,0 +1,9 @@
1
+
2
+ /// This interface provides a value-export of the default network handle..
3
+ interface instance-network {
4
+ use network.{network};
5
+
6
+ /// Get a handle to the default network.
7
+ instance-network: func() -> network;
8
+
9
+ }
@@ -0,0 +1,51 @@
1
+
2
+ interface ip-name-lookup {
3
+ use wasi:io/poll@0.2.0.{pollable};
4
+ use network.{network, error-code, ip-address};
5
+
6
+
7
+ /// Resolve an internet host name to a list of IP addresses.
8
+ ///
9
+ /// Unicode domain names are automatically converted to ASCII using IDNA encoding.
10
+ /// If the input is an IP address string, the address is parsed and returned
11
+ /// as-is without making any external requests.
12
+ ///
13
+ /// See the wasi-socket proposal README.md for a comparison with getaddrinfo.
14
+ ///
15
+ /// This function never blocks. It either immediately fails or immediately
16
+ /// returns successfully with a `resolve-address-stream` that can be used
17
+ /// to (asynchronously) fetch the results.
18
+ ///
19
+ /// # Typical errors
20
+ /// - `invalid-argument`: `name` is a syntactically invalid domain name or IP address.
21
+ ///
22
+ /// # References:
23
+ /// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/getaddrinfo.html>
24
+ /// - <https://man7.org/linux/man-pages/man3/getaddrinfo.3.html>
25
+ /// - <https://learn.microsoft.com/en-us/windows/win32/api/ws2tcpip/nf-ws2tcpip-getaddrinfo>
26
+ /// - <https://man.freebsd.org/cgi/man.cgi?query=getaddrinfo&sektion=3>
27
+ resolve-addresses: func(network: borrow<network>, name: string) -> result<resolve-address-stream, error-code>;
28
+
29
+ resource resolve-address-stream {
30
+ /// Returns the next address from the resolver.
31
+ ///
32
+ /// This function should be called multiple times. On each call, it will
33
+ /// return the next address in connection order preference. If all
34
+ /// addresses have been exhausted, this function returns `none`.
35
+ ///
36
+ /// This function never returns IPv4-mapped IPv6 addresses.
37
+ ///
38
+ /// # Typical errors
39
+ /// - `name-unresolvable`: Name does not exist or has no suitable associated IP addresses. (EAI_NONAME, EAI_NODATA, EAI_ADDRFAMILY)
40
+ /// - `temporary-resolver-failure`: A temporary failure in name resolution occurred. (EAI_AGAIN)
41
+ /// - `permanent-resolver-failure`: A permanent failure in name resolution occurred. (EAI_FAIL)
42
+ /// - `would-block`: A result is not available yet. (EWOULDBLOCK, EAGAIN)
43
+ resolve-next-address: func() -> result<option<ip-address>, error-code>;
44
+
45
+ /// Create a `pollable` which will resolve once the stream is ready for I/O.
46
+ ///
47
+ /// Note: this function is here for WASI Preview2 only.
48
+ /// It's planned to be removed when `future` is natively supported in Preview3.
49
+ subscribe: func() -> pollable;
50
+ }
51
+ }
@@ -0,0 +1,145 @@
1
+
2
+ interface network {
3
+ /// An opaque resource that represents access to (a subset of) the network.
4
+ /// This enables context-based security for networking.
5
+ /// There is no need for this to map 1:1 to a physical network interface.
6
+ resource network;
7
+
8
+ /// Error codes.
9
+ ///
10
+ /// In theory, every API can return any error code.
11
+ /// In practice, API's typically only return the errors documented per API
12
+ /// combined with a couple of errors that are always possible:
13
+ /// - `unknown`
14
+ /// - `access-denied`
15
+ /// - `not-supported`
16
+ /// - `out-of-memory`
17
+ /// - `concurrency-conflict`
18
+ ///
19
+ /// See each individual API for what the POSIX equivalents are. They sometimes differ per API.
20
+ enum error-code {
21
+ /// Unknown error
22
+ unknown,
23
+
24
+ /// Access denied.
25
+ ///
26
+ /// POSIX equivalent: EACCES, EPERM
27
+ access-denied,
28
+
29
+ /// The operation is not supported.
30
+ ///
31
+ /// POSIX equivalent: EOPNOTSUPP
32
+ not-supported,
33
+
34
+ /// One of the arguments is invalid.
35
+ ///
36
+ /// POSIX equivalent: EINVAL
37
+ invalid-argument,
38
+
39
+ /// Not enough memory to complete the operation.
40
+ ///
41
+ /// POSIX equivalent: ENOMEM, ENOBUFS, EAI_MEMORY
42
+ out-of-memory,
43
+
44
+ /// The operation timed out before it could finish completely.
45
+ timeout,
46
+
47
+ /// This operation is incompatible with another asynchronous operation that is already in progress.
48
+ ///
49
+ /// POSIX equivalent: EALREADY
50
+ concurrency-conflict,
51
+
52
+ /// Trying to finish an asynchronous operation that:
53
+ /// - has not been started yet, or:
54
+ /// - was already finished by a previous `finish-*` call.
55
+ ///
56
+ /// Note: this is scheduled to be removed when `future`s are natively supported.
57
+ not-in-progress,
58
+
59
+ /// The operation has been aborted because it could not be completed immediately.
60
+ ///
61
+ /// Note: this is scheduled to be removed when `future`s are natively supported.
62
+ would-block,
63
+
64
+
65
+ /// The operation is not valid in the socket's current state.
66
+ invalid-state,
67
+
68
+ /// A new socket resource could not be created because of a system limit.
69
+ new-socket-limit,
70
+
71
+ /// A bind operation failed because the provided address is not an address that the `network` can bind to.
72
+ address-not-bindable,
73
+
74
+ /// A bind operation failed because the provided address is already in use or because there are no ephemeral ports available.
75
+ address-in-use,
76
+
77
+ /// The remote address is not reachable
78
+ remote-unreachable,
79
+
80
+
81
+ /// The TCP connection was forcefully rejected
82
+ connection-refused,
83
+
84
+ /// The TCP connection was reset.
85
+ connection-reset,
86
+
87
+ /// A TCP connection was aborted.
88
+ connection-aborted,
89
+
90
+
91
+ /// The size of a datagram sent to a UDP socket exceeded the maximum
92
+ /// supported size.
93
+ datagram-too-large,
94
+
95
+
96
+ /// Name does not exist or has no suitable associated IP addresses.
97
+ name-unresolvable,
98
+
99
+ /// A temporary failure in name resolution occurred.
100
+ temporary-resolver-failure,
101
+
102
+ /// A permanent failure in name resolution occurred.
103
+ permanent-resolver-failure,
104
+ }
105
+
106
+ enum ip-address-family {
107
+ /// Similar to `AF_INET` in POSIX.
108
+ ipv4,
109
+
110
+ /// Similar to `AF_INET6` in POSIX.
111
+ ipv6,
112
+ }
113
+
114
+ type ipv4-address = tuple<u8, u8, u8, u8>;
115
+ type ipv6-address = tuple<u16, u16, u16, u16, u16, u16, u16, u16>;
116
+
117
+ variant ip-address {
118
+ ipv4(ipv4-address),
119
+ ipv6(ipv6-address),
120
+ }
121
+
122
+ record ipv4-socket-address {
123
+ /// sin_port
124
+ port: u16,
125
+ /// sin_addr
126
+ address: ipv4-address,
127
+ }
128
+
129
+ record ipv6-socket-address {
130
+ /// sin6_port
131
+ port: u16,
132
+ /// sin6_flowinfo
133
+ flow-info: u32,
134
+ /// sin6_addr
135
+ address: ipv6-address,
136
+ /// sin6_scope_id
137
+ scope-id: u32,
138
+ }
139
+
140
+ variant ip-socket-address {
141
+ ipv4(ipv4-socket-address),
142
+ ipv6(ipv6-socket-address),
143
+ }
144
+
145
+ }
@@ -0,0 +1,27 @@
1
+
2
+ interface tcp-create-socket {
3
+ use network.{network, error-code, ip-address-family};
4
+ use tcp.{tcp-socket};
5
+
6
+ /// Create a new TCP socket.
7
+ ///
8
+ /// Similar to `socket(AF_INET or AF_INET6, SOCK_STREAM, IPPROTO_TCP)` in POSIX.
9
+ /// On IPv6 sockets, IPV6_V6ONLY is enabled by default and can't be configured otherwise.
10
+ ///
11
+ /// This function does not require a network capability handle. This is considered to be safe because
12
+ /// at time of creation, the socket is not bound to any `network` yet. Up to the moment `bind`/`connect`
13
+ /// is called, the socket is effectively an in-memory configuration object, unable to communicate with the outside world.
14
+ ///
15
+ /// All sockets are non-blocking. Use the wasi-poll interface to block on asynchronous operations.
16
+ ///
17
+ /// # Typical errors
18
+ /// - `not-supported`: The specified `address-family` is not supported. (EAFNOSUPPORT)
19
+ /// - `new-socket-limit`: The new socket resource could not be created because of a system limit. (EMFILE, ENFILE)
20
+ ///
21
+ /// # References
22
+ /// - <https://pubs.opengroup.org/onlinepubs/9699919799/functions/socket.html>
23
+ /// - <https://man7.org/linux/man-pages/man2/socket.2.html>
24
+ /// - <https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-wsasocketw>
25
+ /// - <https://man.freebsd.org/cgi/man.cgi?query=socket&sektion=2>
26
+ create-tcp-socket: func(address-family: ip-address-family) -> result<tcp-socket, error-code>;
27
+ }