@vibesdotdev/host-bun 0.0.0-stage → 1.0.0-rc.3

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 (517) hide show
  1. package/LICENSE +18 -0
  2. package/README.md +222 -2
  3. package/dist/applet-serve-host/applet-serve-host.impl.bun.d.ts +6 -0
  4. package/dist/applet-serve-host/applet-serve-host.impl.bun.d.ts.map +1 -0
  5. package/dist/applet-serve-host/applet-serve-host.impl.bun.js +80 -0
  6. package/dist/applet-serve-host/applet-serve-host.impl.bun.js.map +1 -0
  7. package/dist/applet-serve-host/applet-serve-host.plugin.d.ts +22 -0
  8. package/dist/applet-serve-host/applet-serve-host.plugin.d.ts.map +1 -0
  9. package/dist/applet-serve-host/applet-serve-host.plugin.js +42 -0
  10. package/dist/applet-serve-host/applet-serve-host.plugin.js.map +1 -0
  11. package/dist/applet-serve-host/index.d.ts +7 -0
  12. package/dist/applet-serve-host/index.d.ts.map +1 -0
  13. package/dist/applet-serve-host/index.js +7 -0
  14. package/dist/applet-serve-host/index.js.map +1 -0
  15. package/dist/applet-serve-host/stylesheet.compiler.d.ts +7 -0
  16. package/dist/applet-serve-host/stylesheet.compiler.d.ts.map +1 -0
  17. package/dist/applet-serve-host/stylesheet.compiler.js +63 -0
  18. package/dist/applet-serve-host/stylesheet.compiler.js.map +1 -0
  19. package/dist/atlas-migrations/register-atlas-host-migrations.d.ts +21 -0
  20. package/dist/atlas-migrations/register-atlas-host-migrations.d.ts.map +1 -0
  21. package/dist/atlas-migrations/register-atlas-host-migrations.js +148 -0
  22. package/dist/atlas-migrations/register-atlas-host-migrations.js.map +1 -0
  23. package/dist/buffered-capture.d.ts +4 -0
  24. package/dist/buffered-capture.d.ts.map +1 -0
  25. package/dist/buffered-capture.impl.bun.d.ts +18 -0
  26. package/dist/buffered-capture.impl.bun.d.ts.map +1 -0
  27. package/dist/buffered-capture.impl.bun.js +148 -0
  28. package/dist/buffered-capture.impl.bun.js.map +1 -0
  29. package/dist/buffered-capture.js +5 -0
  30. package/dist/buffered-capture.js.map +1 -0
  31. package/dist/bun-environment.impl.bun.d.ts +231 -0
  32. package/dist/bun-environment.impl.bun.d.ts.map +1 -0
  33. package/dist/bun-environment.impl.bun.js +352 -0
  34. package/dist/bun-environment.impl.bun.js.map +1 -0
  35. package/dist/cache-redis/cache-redis-connector.impl.bun.d.ts +20 -0
  36. package/dist/cache-redis/cache-redis-connector.impl.bun.d.ts.map +1 -0
  37. package/dist/cache-redis/cache-redis-connector.impl.bun.js +30 -0
  38. package/dist/cache-redis/cache-redis-connector.impl.bun.js.map +1 -0
  39. package/dist/cache-redis/cache-redis-connector.plugin.d.ts +21 -0
  40. package/dist/cache-redis/cache-redis-connector.plugin.d.ts.map +1 -0
  41. package/dist/cache-redis/cache-redis-connector.plugin.js +32 -0
  42. package/dist/cache-redis/cache-redis-connector.plugin.js.map +1 -0
  43. package/dist/cli-checkout.impl.bun.d.ts +13 -0
  44. package/dist/cli-checkout.impl.bun.d.ts.map +1 -0
  45. package/dist/cli-checkout.impl.bun.js +26 -0
  46. package/dist/cli-checkout.impl.bun.js.map +1 -0
  47. package/dist/docs/runtime-environment-bun.docs.descriptor.d.ts +19 -0
  48. package/dist/docs/runtime-environment-bun.docs.descriptor.d.ts.map +1 -0
  49. package/dist/docs/runtime-environment-bun.docs.descriptor.js +116 -0
  50. package/dist/docs/runtime-environment-bun.docs.descriptor.js.map +1 -0
  51. package/dist/filesystem/adapter.impl.bun.d.ts +15 -0
  52. package/dist/filesystem/adapter.impl.bun.d.ts.map +1 -0
  53. package/dist/filesystem/adapter.impl.bun.js +11 -0
  54. package/dist/filesystem/adapter.impl.bun.js.map +1 -0
  55. package/dist/filesystem/host-primitives.impl.bun.d.ts +12 -0
  56. package/dist/filesystem/host-primitives.impl.bun.d.ts.map +1 -0
  57. package/dist/filesystem/host-primitives.impl.bun.js +96 -0
  58. package/dist/filesystem/host-primitives.impl.bun.js.map +1 -0
  59. package/dist/filesystem/register.d.ts +12 -0
  60. package/dist/filesystem/register.d.ts.map +1 -0
  61. package/dist/filesystem/register.js +6 -0
  62. package/dist/filesystem/register.js.map +1 -0
  63. package/dist/filesystem/rooted-exclusive.impl.bun.d.ts +4 -0
  64. package/dist/filesystem/rooted-exclusive.impl.bun.d.ts.map +1 -0
  65. package/dist/filesystem/rooted-exclusive.impl.bun.js +135 -0
  66. package/dist/filesystem/rooted-exclusive.impl.bun.js.map +1 -0
  67. package/dist/held-launch/abi.impl.bun.d.ts +175 -0
  68. package/dist/held-launch/abi.impl.bun.d.ts.map +1 -0
  69. package/dist/held-launch/abi.impl.bun.js +476 -0
  70. package/dist/held-launch/abi.impl.bun.js.map +1 -0
  71. package/dist/held-launch/execution.impl.bun.d.ts +48 -0
  72. package/dist/held-launch/execution.impl.bun.d.ts.map +1 -0
  73. package/dist/held-launch/execution.impl.bun.js +375 -0
  74. package/dist/held-launch/execution.impl.bun.js.map +1 -0
  75. package/dist/held-launch/library.impl.bun.d.ts +23 -0
  76. package/dist/held-launch/library.impl.bun.d.ts.map +1 -0
  77. package/dist/held-launch/library.impl.bun.js +178 -0
  78. package/dist/held-launch/library.impl.bun.js.map +1 -0
  79. package/dist/held-launch/schemas.d.ts +10 -0
  80. package/dist/held-launch/schemas.d.ts.map +1 -0
  81. package/dist/held-launch/schemas.js +3 -0
  82. package/dist/held-launch/schemas.js.map +1 -0
  83. package/dist/held-launch/streams.impl.bun.d.ts +38 -0
  84. package/dist/held-launch/streams.impl.bun.d.ts.map +1 -0
  85. package/dist/held-launch/streams.impl.bun.js +183 -0
  86. package/dist/held-launch/streams.impl.bun.js.map +1 -0
  87. package/dist/host-channel.impl.bun.d.ts +25 -0
  88. package/dist/host-channel.impl.bun.d.ts.map +1 -0
  89. package/dist/host-channel.impl.bun.js +40 -0
  90. package/dist/host-channel.impl.bun.js.map +1 -0
  91. package/dist/host-client.impl.bun.d.ts +31 -0
  92. package/dist/host-client.impl.bun.d.ts.map +1 -0
  93. package/dist/host-client.impl.bun.js +39 -0
  94. package/dist/host-client.impl.bun.js.map +1 -0
  95. package/dist/host-credentials.d.ts +38 -0
  96. package/dist/host-credentials.d.ts.map +1 -0
  97. package/dist/host-credentials.js +44 -0
  98. package/dist/host-credentials.js.map +1 -0
  99. package/dist/host-loader.impl.bun.d.ts +12 -0
  100. package/dist/host-loader.impl.bun.d.ts.map +1 -0
  101. package/dist/host-loader.impl.bun.js +83 -0
  102. package/dist/host-loader.impl.bun.js.map +1 -0
  103. package/dist/host-signal.impl.bun.d.ts +11 -0
  104. package/dist/host-signal.impl.bun.d.ts.map +1 -0
  105. package/dist/host-signal.impl.bun.js +28 -0
  106. package/dist/host-signal.impl.bun.js.map +1 -0
  107. package/dist/http-listener.impl.bun.d.ts +8 -0
  108. package/dist/http-listener.impl.bun.d.ts.map +1 -0
  109. package/dist/http-listener.impl.bun.js +44 -0
  110. package/dist/http-listener.impl.bun.js.map +1 -0
  111. package/dist/index.d.ts +38 -0
  112. package/dist/index.d.ts.map +1 -0
  113. package/dist/index.js +314 -0
  114. package/dist/index.js.map +1 -0
  115. package/dist/local-execution.impl.bun.d.ts +47 -0
  116. package/dist/local-execution.impl.bun.d.ts.map +1 -0
  117. package/dist/local-execution.impl.bun.js +150 -0
  118. package/dist/local-execution.impl.bun.js.map +1 -0
  119. package/dist/logging/file-host.impl.bun.d.ts +4 -0
  120. package/dist/logging/file-host.impl.bun.d.ts.map +1 -0
  121. package/dist/logging/file-host.impl.bun.js +36 -0
  122. package/dist/logging/file-host.impl.bun.js.map +1 -0
  123. package/dist/logging/logging.plugin.d.ts +12 -0
  124. package/dist/logging/logging.plugin.d.ts.map +1 -0
  125. package/dist/logging/logging.plugin.js +20 -0
  126. package/dist/logging/logging.plugin.js.map +1 -0
  127. package/dist/native/held-launch/aarch64-apple-darwin/libvibes_held_launch.dylib +0 -0
  128. package/dist/native/held-launch/aarch64-apple-darwin/manifest.json +237 -0
  129. package/dist/native/held-launch/aarch64-apple-darwin/vibes-held-launch +0 -0
  130. package/dist/native/held-launch/aarch64-unknown-linux-gnu/libvibes_held_launch.so +0 -0
  131. package/dist/native/held-launch/aarch64-unknown-linux-gnu/manifest.json +237 -0
  132. package/dist/native/held-launch/aarch64-unknown-linux-gnu/vibes-held-launch +0 -0
  133. package/dist/native/held-launch/x86_64-apple-darwin/libvibes_held_launch.dylib +0 -0
  134. package/dist/native/held-launch/x86_64-apple-darwin/manifest.json +237 -0
  135. package/dist/native/held-launch/x86_64-apple-darwin/vibes-held-launch +0 -0
  136. package/dist/native/held-launch/x86_64-unknown-linux-gnu/libvibes_held_launch.so +0 -0
  137. package/dist/native/held-launch/x86_64-unknown-linux-gnu/manifest.json +237 -0
  138. package/dist/native/held-launch/x86_64-unknown-linux-gnu/vibes-held-launch +0 -0
  139. package/dist/native-image.consumer.plugin.d.ts +4 -0
  140. package/dist/native-image.consumer.plugin.d.ts.map +1 -0
  141. package/dist/native-image.consumer.plugin.js +14 -0
  142. package/dist/native-image.consumer.plugin.js.map +1 -0
  143. package/dist/native-image.d.ts +79 -0
  144. package/dist/native-image.d.ts.map +1 -0
  145. package/dist/native-image.impl.consumer.d.ts +15 -0
  146. package/dist/native-image.impl.consumer.d.ts.map +1 -0
  147. package/dist/native-image.impl.consumer.js +86 -0
  148. package/dist/native-image.impl.consumer.js.map +1 -0
  149. package/dist/native-image.js +19 -0
  150. package/dist/native-image.js.map +1 -0
  151. package/dist/native-library.consumer.plugin.d.ts +6 -0
  152. package/dist/native-library.consumer.plugin.d.ts.map +1 -0
  153. package/dist/native-library.consumer.plugin.js +33 -0
  154. package/dist/native-library.consumer.plugin.js.map +1 -0
  155. package/dist/native-library.impl.consumer.d.ts +14 -0
  156. package/dist/native-library.impl.consumer.d.ts.map +1 -0
  157. package/dist/native-library.impl.consumer.js +46 -0
  158. package/dist/native-library.impl.consumer.js.map +1 -0
  159. package/dist/native-network/index.d.ts +3 -0
  160. package/dist/native-network/index.d.ts.map +1 -0
  161. package/dist/native-network/index.js +3 -0
  162. package/dist/native-network/index.js.map +1 -0
  163. package/dist/native-network/native-host.d.ts +4 -0
  164. package/dist/native-network/native-host.d.ts.map +1 -0
  165. package/dist/native-network/native-host.js +14 -0
  166. package/dist/native-network/native-host.js.map +1 -0
  167. package/dist/native-network/native-network.descriptor.d.ts +4 -0
  168. package/dist/native-network/native-network.descriptor.d.ts.map +1 -0
  169. package/dist/native-network/native-network.descriptor.js +11 -0
  170. package/dist/native-network/native-network.descriptor.js.map +1 -0
  171. package/dist/native-network/native-network.impl.bun.d.ts +19 -0
  172. package/dist/native-network/native-network.impl.bun.d.ts.map +1 -0
  173. package/dist/native-network/native-network.impl.bun.js +190 -0
  174. package/dist/native-network/native-network.impl.bun.js.map +1 -0
  175. package/dist/native-network/native-network.plugin.d.ts +6 -0
  176. package/dist/native-network/native-network.plugin.d.ts.map +1 -0
  177. package/dist/native-network/native-network.plugin.js +27 -0
  178. package/dist/native-network/native-network.plugin.js.map +1 -0
  179. package/dist/package-plugins/index.d.ts +11 -0
  180. package/dist/package-plugins/index.d.ts.map +1 -0
  181. package/dist/package-plugins/index.js +11 -0
  182. package/dist/package-plugins/index.js.map +1 -0
  183. package/dist/package-plugins/package-plugins.capability.bun.d.ts +11 -0
  184. package/dist/package-plugins/package-plugins.capability.bun.d.ts.map +1 -0
  185. package/dist/package-plugins/package-plugins.capability.bun.js +14 -0
  186. package/dist/package-plugins/package-plugins.capability.bun.js.map +1 -0
  187. package/dist/package-plugins/primitives.impl.bun.d.ts +11 -0
  188. package/dist/package-plugins/primitives.impl.bun.d.ts.map +1 -0
  189. package/dist/package-plugins/primitives.impl.bun.js +32 -0
  190. package/dist/package-plugins/primitives.impl.bun.js.map +1 -0
  191. package/dist/package-plugins/read-admission.impl.bun.d.ts +11 -0
  192. package/dist/package-plugins/read-admission.impl.bun.d.ts.map +1 -0
  193. package/dist/package-plugins/read-admission.impl.bun.js +224 -0
  194. package/dist/package-plugins/read-admission.impl.bun.js.map +1 -0
  195. package/dist/package-plugins/schemas.d.ts +28 -0
  196. package/dist/package-plugins/schemas.d.ts.map +1 -0
  197. package/dist/package-plugins/schemas.js +3 -0
  198. package/dist/package-plugins/schemas.js.map +1 -0
  199. package/dist/process/launch-artifacts.impl.bun.d.ts +11 -0
  200. package/dist/process/launch-artifacts.impl.bun.d.ts.map +1 -0
  201. package/dist/process/launch-artifacts.impl.bun.js +25 -0
  202. package/dist/process/launch-artifacts.impl.bun.js.map +1 -0
  203. package/dist/process/process-probe.impl.bun.d.ts +15 -0
  204. package/dist/process/process-probe.impl.bun.d.ts.map +1 -0
  205. package/dist/process/process-probe.impl.bun.js +35 -0
  206. package/dist/process/process-probe.impl.bun.js.map +1 -0
  207. package/dist/process/runtime-process.impl.bun.d.ts +20 -0
  208. package/dist/process/runtime-process.impl.bun.d.ts.map +1 -0
  209. package/dist/process/runtime-process.impl.bun.js +42 -0
  210. package/dist/process/runtime-process.impl.bun.js.map +1 -0
  211. package/dist/process/schemas.d.ts +9 -0
  212. package/dist/process/schemas.d.ts.map +1 -0
  213. package/dist/process/schemas.js +3 -0
  214. package/dist/process/schemas.js.map +1 -0
  215. package/dist/process/spawn.impl.bun.d.ts +31 -0
  216. package/dist/process/spawn.impl.bun.d.ts.map +1 -0
  217. package/dist/process/spawn.impl.bun.js +66 -0
  218. package/dist/process/spawn.impl.bun.js.map +1 -0
  219. package/dist/process/which.impl.bun.d.ts +16 -0
  220. package/dist/process/which.impl.bun.d.ts.map +1 -0
  221. package/dist/process/which.impl.bun.js +25 -0
  222. package/dist/process/which.impl.bun.js.map +1 -0
  223. package/dist/pty.adapter.impl.bun.d.ts +17 -0
  224. package/dist/pty.adapter.impl.bun.d.ts.map +1 -0
  225. package/dist/pty.adapter.impl.bun.js +102 -0
  226. package/dist/pty.adapter.impl.bun.js.map +1 -0
  227. package/dist/pty.darwin.impl.bun.d.ts +11 -0
  228. package/dist/pty.darwin.impl.bun.d.ts.map +1 -0
  229. package/dist/pty.darwin.impl.bun.js +200 -0
  230. package/dist/pty.darwin.impl.bun.js.map +1 -0
  231. package/dist/pty.node-host.impl.bun.d.ts +10 -0
  232. package/dist/pty.node-host.impl.bun.d.ts.map +1 -0
  233. package/dist/pty.node-host.impl.bun.js +42 -0
  234. package/dist/pty.node-host.impl.bun.js.map +1 -0
  235. package/dist/resolution-root.impl.bun.d.ts +170 -0
  236. package/dist/resolution-root.impl.bun.d.ts.map +1 -0
  237. package/dist/resolution-root.impl.bun.js +373 -0
  238. package/dist/resolution-root.impl.bun.js.map +1 -0
  239. package/dist/restricted-execute.darwin.impl.bun.d.ts +19 -0
  240. package/dist/restricted-execute.darwin.impl.bun.d.ts.map +1 -0
  241. package/dist/restricted-execute.darwin.impl.bun.js +459 -0
  242. package/dist/restricted-execute.darwin.impl.bun.js.map +1 -0
  243. package/dist/runtime-plugin-host/daemon-execution.worker-shim.bun.d.ts +2 -0
  244. package/dist/runtime-plugin-host/daemon-execution.worker-shim.bun.d.ts.map +1 -0
  245. package/dist/runtime-plugin-host/daemon-execution.worker-shim.bun.js +31 -0
  246. package/dist/runtime-plugin-host/daemon-execution.worker-shim.bun.js.map +1 -0
  247. package/dist/runtime-plugin-host/host-hot-reload.consumer.d.ts +20 -0
  248. package/dist/runtime-plugin-host/host-hot-reload.consumer.d.ts.map +1 -0
  249. package/dist/runtime-plugin-host/host-hot-reload.consumer.js +236 -0
  250. package/dist/runtime-plugin-host/host-hot-reload.consumer.js.map +1 -0
  251. package/dist/runtime-plugin-host/hot-plugin-build.worker.consumer.d.ts +2 -0
  252. package/dist/runtime-plugin-host/hot-plugin-build.worker.consumer.d.ts.map +1 -0
  253. package/dist/runtime-plugin-host/hot-plugin-build.worker.consumer.js +66 -0
  254. package/dist/runtime-plugin-host/hot-plugin-build.worker.consumer.js.map +1 -0
  255. package/dist/runtime-plugin-host/hot-plugin-module.consumer.d.ts +45 -0
  256. package/dist/runtime-plugin-host/hot-plugin-module.consumer.d.ts.map +1 -0
  257. package/dist/runtime-plugin-host/hot-plugin-module.consumer.js +490 -0
  258. package/dist/runtime-plugin-host/hot-plugin-module.consumer.js.map +1 -0
  259. package/dist/runtime-plugin-host/hot-reload.consumer.d.ts +83 -0
  260. package/dist/runtime-plugin-host/hot-reload.consumer.d.ts.map +1 -0
  261. package/dist/runtime-plugin-host/hot-reload.consumer.js +168 -0
  262. package/dist/runtime-plugin-host/hot-reload.consumer.js.map +1 -0
  263. package/dist/runtime-plugin-host/reclaim.impl.bun.d.ts +37 -0
  264. package/dist/runtime-plugin-host/reclaim.impl.bun.d.ts.map +1 -0
  265. package/dist/runtime-plugin-host/reclaim.impl.bun.js +159 -0
  266. package/dist/runtime-plugin-host/reclaim.impl.bun.js.map +1 -0
  267. package/dist/runtime-plugin-host/runtime-plugin-host.impl.bun.d.ts +4 -0
  268. package/dist/runtime-plugin-host/runtime-plugin-host.impl.bun.d.ts.map +1 -0
  269. package/dist/runtime-plugin-host/runtime-plugin-host.impl.bun.js +181 -0
  270. package/dist/runtime-plugin-host/runtime-plugin-host.impl.bun.js.map +1 -0
  271. package/dist/runtime-plugin-host/runtime-plugin-host.plugin.d.ts +17 -0
  272. package/dist/runtime-plugin-host/runtime-plugin-host.plugin.d.ts.map +1 -0
  273. package/dist/runtime-plugin-host/runtime-plugin-host.plugin.js +36 -0
  274. package/dist/runtime-plugin-host/runtime-plugin-host.plugin.js.map +1 -0
  275. package/dist/runtime-plugin-host/runtime-thread.impl.bun.d.ts +53 -0
  276. package/dist/runtime-plugin-host/runtime-thread.impl.bun.d.ts.map +1 -0
  277. package/dist/runtime-plugin-host/runtime-thread.impl.bun.js +249 -0
  278. package/dist/runtime-plugin-host/runtime-thread.impl.bun.js.map +1 -0
  279. package/dist/runtime-plugin-host/runtime-thread.shim.bun.d.ts +2 -0
  280. package/dist/runtime-plugin-host/runtime-thread.shim.bun.d.ts.map +1 -0
  281. package/dist/runtime-plugin-host/runtime-thread.shim.bun.js +56 -0
  282. package/dist/runtime-plugin-host/runtime-thread.shim.bun.js.map +1 -0
  283. package/dist/runtime-plugin-host/schemas.d.ts +437 -0
  284. package/dist/runtime-plugin-host/schemas.d.ts.map +1 -0
  285. package/dist/runtime-plugin-host/schemas.js +54 -0
  286. package/dist/runtime-plugin-host/schemas.js.map +1 -0
  287. package/dist/runtime-plugin-host/source-watcher.consumer.d.ts +109 -0
  288. package/dist/runtime-plugin-host/source-watcher.consumer.d.ts.map +1 -0
  289. package/dist/runtime-plugin-host/source-watcher.consumer.js +383 -0
  290. package/dist/runtime-plugin-host/source-watcher.consumer.js.map +1 -0
  291. package/dist/schemas/environment.d.ts +197 -0
  292. package/dist/schemas/environment.d.ts.map +1 -0
  293. package/dist/schemas/environment.js +7 -0
  294. package/dist/schemas/environment.js.map +1 -0
  295. package/dist/schemas/host-resources.d.ts +85 -0
  296. package/dist/schemas/host-resources.d.ts.map +1 -0
  297. package/dist/schemas/host-resources.js +22 -0
  298. package/dist/schemas/host-resources.js.map +1 -0
  299. package/dist/schemas/native-image.d.ts +128 -0
  300. package/dist/schemas/native-image.d.ts.map +1 -0
  301. package/dist/schemas/native-image.js +45 -0
  302. package/dist/schemas/native-image.js.map +1 -0
  303. package/dist/schemas/native-network.d.ts +56 -0
  304. package/dist/schemas/native-network.d.ts.map +1 -0
  305. package/dist/schemas/native-network.js +55 -0
  306. package/dist/schemas/native-network.js.map +1 -0
  307. package/dist/schemas/restricted-execute.d.ts +40 -0
  308. package/dist/schemas/restricted-execute.d.ts.map +1 -0
  309. package/dist/schemas/restricted-execute.js +14 -0
  310. package/dist/schemas/restricted-execute.js.map +1 -0
  311. package/dist/schemas/runtime-socket.d.ts +8 -0
  312. package/dist/schemas/runtime-socket.d.ts.map +1 -0
  313. package/dist/schemas/runtime-socket.js +7 -0
  314. package/dist/schemas/runtime-socket.js.map +1 -0
  315. package/dist/schemas/self-spawn.d.ts +11 -0
  316. package/dist/schemas/self-spawn.d.ts.map +1 -0
  317. package/dist/schemas/self-spawn.js +3 -0
  318. package/dist/schemas/self-spawn.js.map +1 -0
  319. package/dist/schemas/standard-output.d.ts +6 -0
  320. package/dist/schemas/standard-output.d.ts.map +1 -0
  321. package/dist/schemas/standard-output.js +2 -0
  322. package/dist/schemas/standard-output.js.map +1 -0
  323. package/dist/schemas/telemetry.d.ts +25 -0
  324. package/dist/schemas/telemetry.d.ts.map +1 -0
  325. package/dist/schemas/telemetry.js +10 -0
  326. package/dist/schemas/telemetry.js.map +1 -0
  327. package/dist/schemas/test-environment.d.ts +27 -0
  328. package/dist/schemas/test-environment.d.ts.map +1 -0
  329. package/dist/schemas/test-environment.js +2 -0
  330. package/dist/schemas/test-environment.js.map +1 -0
  331. package/dist/serve-stall-start.d.ts +8 -0
  332. package/dist/serve-stall-start.d.ts.map +1 -0
  333. package/dist/serve-stall-start.js +88 -0
  334. package/dist/serve-stall-start.js.map +1 -0
  335. package/dist/serve-stall.d.ts +11 -0
  336. package/dist/serve-stall.d.ts.map +1 -0
  337. package/dist/serve-stall.js +19 -0
  338. package/dist/serve-stall.js.map +1 -0
  339. package/dist/serve-stall.plugin.d.ts +10 -0
  340. package/dist/serve-stall.plugin.d.ts.map +1 -0
  341. package/dist/serve-stall.plugin.js +34 -0
  342. package/dist/serve-stall.plugin.js.map +1 -0
  343. package/dist/services/account-home.d.ts +39 -0
  344. package/dist/services/account-home.d.ts.map +1 -0
  345. package/dist/services/account-home.js +152 -0
  346. package/dist/services/account-home.js.map +1 -0
  347. package/dist/services/cli-process-host.d.ts +50 -0
  348. package/dist/services/cli-process-host.d.ts.map +1 -0
  349. package/dist/services/cli-process-host.js +88 -0
  350. package/dist/services/cli-process-host.js.map +1 -0
  351. package/dist/services/compatibility-host.impl.bun.d.ts +4 -0
  352. package/dist/services/compatibility-host.impl.bun.d.ts.map +1 -0
  353. package/dist/services/compatibility-host.impl.bun.js +24 -0
  354. package/dist/services/compatibility-host.impl.bun.js.map +1 -0
  355. package/dist/services/executable-identity.impl.bun.d.ts +164 -0
  356. package/dist/services/executable-identity.impl.bun.d.ts.map +1 -0
  357. package/dist/services/executable-identity.impl.bun.js +73 -0
  358. package/dist/services/executable-identity.impl.bun.js.map +1 -0
  359. package/dist/services/fatal-signals.impl.bun.d.ts +15 -0
  360. package/dist/services/fatal-signals.impl.bun.d.ts.map +1 -0
  361. package/dist/services/fatal-signals.impl.bun.js +61 -0
  362. package/dist/services/fatal-signals.impl.bun.js.map +1 -0
  363. package/dist/services/graph-freshness.impl.bun.d.ts +108 -0
  364. package/dist/services/graph-freshness.impl.bun.d.ts.map +1 -0
  365. package/dist/services/graph-freshness.impl.bun.js +49 -0
  366. package/dist/services/graph-freshness.impl.bun.js.map +1 -0
  367. package/dist/services/host-identity.capability.bun.d.ts +10 -0
  368. package/dist/services/host-identity.capability.bun.d.ts.map +1 -0
  369. package/dist/services/host-identity.capability.bun.js +27 -0
  370. package/dist/services/host-identity.capability.bun.js.map +1 -0
  371. package/dist/services/host-identity.impl.bun.d.ts +53 -0
  372. package/dist/services/host-identity.impl.bun.d.ts.map +1 -0
  373. package/dist/services/host-identity.impl.bun.js +76 -0
  374. package/dist/services/host-identity.impl.bun.js.map +1 -0
  375. package/dist/services/host-resources.impl.bun.d.ts +49 -0
  376. package/dist/services/host-resources.impl.bun.d.ts.map +1 -0
  377. package/dist/services/host-resources.impl.bun.js +144 -0
  378. package/dist/services/host-resources.impl.bun.js.map +1 -0
  379. package/dist/services/http-fetch.impl.bun.d.ts +10 -0
  380. package/dist/services/http-fetch.impl.bun.d.ts.map +1 -0
  381. package/dist/services/http-fetch.impl.bun.js +38 -0
  382. package/dist/services/http-fetch.impl.bun.js.map +1 -0
  383. package/dist/services/output-plane.impl.bun.d.ts +6 -0
  384. package/dist/services/output-plane.impl.bun.d.ts.map +1 -0
  385. package/dist/services/output-plane.impl.bun.js +26 -0
  386. package/dist/services/output-plane.impl.bun.js.map +1 -0
  387. package/dist/services/process-action-lifetime.consumer.d.ts +47 -0
  388. package/dist/services/process-action-lifetime.consumer.d.ts.map +1 -0
  389. package/dist/services/process-action-lifetime.consumer.js +68 -0
  390. package/dist/services/process-action-lifetime.consumer.js.map +1 -0
  391. package/dist/services/process-view.impl.bun.d.ts +18 -0
  392. package/dist/services/process-view.impl.bun.d.ts.map +1 -0
  393. package/dist/services/process-view.impl.bun.js +17 -0
  394. package/dist/services/process-view.impl.bun.js.map +1 -0
  395. package/dist/services/runtime-host-signals.impl.bun.d.ts +8 -0
  396. package/dist/services/runtime-host-signals.impl.bun.d.ts.map +1 -0
  397. package/dist/services/runtime-host-signals.impl.bun.js +29 -0
  398. package/dist/services/runtime-host-signals.impl.bun.js.map +1 -0
  399. package/dist/services/runtime-http-listener.impl.bun.d.ts +14 -0
  400. package/dist/services/runtime-http-listener.impl.bun.d.ts.map +1 -0
  401. package/dist/services/runtime-http-listener.impl.bun.js +463 -0
  402. package/dist/services/runtime-http-listener.impl.bun.js.map +1 -0
  403. package/dist/services/runtime-path.impl.bun.d.ts +16 -0
  404. package/dist/services/runtime-path.impl.bun.d.ts.map +1 -0
  405. package/dist/services/runtime-path.impl.bun.js +34 -0
  406. package/dist/services/runtime-path.impl.bun.js.map +1 -0
  407. package/dist/services/runtime-scoped-values.impl.bun.d.ts +4 -0
  408. package/dist/services/runtime-scoped-values.impl.bun.d.ts.map +1 -0
  409. package/dist/services/runtime-scoped-values.impl.bun.js +7 -0
  410. package/dist/services/runtime-scoped-values.impl.bun.js.map +1 -0
  411. package/dist/services/runtime-socket-datagram.impl.bun.d.ts +15 -0
  412. package/dist/services/runtime-socket-datagram.impl.bun.d.ts.map +1 -0
  413. package/dist/services/runtime-socket-datagram.impl.bun.js +19 -0
  414. package/dist/services/runtime-socket-datagram.impl.bun.js.map +1 -0
  415. package/dist/services/runtime-socket.impl.bun.d.ts +20 -0
  416. package/dist/services/runtime-socket.impl.bun.d.ts.map +1 -0
  417. package/dist/services/runtime-socket.impl.bun.js +47 -0
  418. package/dist/services/runtime-socket.impl.bun.js.map +1 -0
  419. package/dist/services/runtime-stdio.impl.bun.d.ts +11 -0
  420. package/dist/services/runtime-stdio.impl.bun.d.ts.map +1 -0
  421. package/dist/services/runtime-stdio.impl.bun.js +37 -0
  422. package/dist/services/runtime-stdio.impl.bun.js.map +1 -0
  423. package/dist/services/self-spawn.impl.bun.d.ts +39 -0
  424. package/dist/services/self-spawn.impl.bun.d.ts.map +1 -0
  425. package/dist/services/self-spawn.impl.bun.js +58 -0
  426. package/dist/services/self-spawn.impl.bun.js.map +1 -0
  427. package/dist/services/standard-output.d.ts +100 -0
  428. package/dist/services/standard-output.d.ts.map +1 -0
  429. package/dist/services/standard-output.js +35 -0
  430. package/dist/services/standard-output.js.map +1 -0
  431. package/dist/services/user-environment.impl.bun.d.ts +19 -0
  432. package/dist/services/user-environment.impl.bun.d.ts.map +1 -0
  433. package/dist/services/user-environment.impl.bun.js +117 -0
  434. package/dist/services/user-environment.impl.bun.js.map +1 -0
  435. package/dist/services/workspace-env.d.ts +30 -0
  436. package/dist/services/workspace-env.d.ts.map +1 -0
  437. package/dist/services/workspace-env.js +45 -0
  438. package/dist/services/workspace-env.js.map +1 -0
  439. package/dist/services/workspace-root-probe.impl.bun.d.ts +14 -0
  440. package/dist/services/workspace-root-probe.impl.bun.d.ts.map +1 -0
  441. package/dist/services/workspace-root-probe.impl.bun.js +27 -0
  442. package/dist/services/workspace-root-probe.impl.bun.js.map +1 -0
  443. package/dist/session-members.impl.bun.d.ts +22 -0
  444. package/dist/session-members.impl.bun.d.ts.map +1 -0
  445. package/dist/session-members.impl.bun.js +74 -0
  446. package/dist/session-members.impl.bun.js.map +1 -0
  447. package/dist/sqlite-driver/index.d.ts +7 -0
  448. package/dist/sqlite-driver/index.d.ts.map +1 -0
  449. package/dist/sqlite-driver/index.js +7 -0
  450. package/dist/sqlite-driver/index.js.map +1 -0
  451. package/dist/sqlite-driver/sqlite-driver.impl.bun.d.ts +6 -0
  452. package/dist/sqlite-driver/sqlite-driver.impl.bun.d.ts.map +1 -0
  453. package/dist/sqlite-driver/sqlite-driver.impl.bun.js +269 -0
  454. package/dist/sqlite-driver/sqlite-driver.impl.bun.js.map +1 -0
  455. package/dist/sqlite-driver/sqlite-driver.plugin.d.ts +22 -0
  456. package/dist/sqlite-driver/sqlite-driver.plugin.d.ts.map +1 -0
  457. package/dist/sqlite-driver/sqlite-driver.plugin.js +44 -0
  458. package/dist/sqlite-driver/sqlite-driver.plugin.js.map +1 -0
  459. package/dist/telemetry/telemetry.d.ts +34 -0
  460. package/dist/telemetry/telemetry.d.ts.map +1 -0
  461. package/dist/telemetry/telemetry.js +2 -0
  462. package/dist/telemetry/telemetry.js.map +1 -0
  463. package/dist/telemetry/telemetry.plugin.d.ts +4 -0
  464. package/dist/telemetry/telemetry.plugin.d.ts.map +1 -0
  465. package/dist/telemetry/telemetry.plugin.js +78 -0
  466. package/dist/telemetry/telemetry.plugin.js.map +1 -0
  467. package/dist/terminal-pty-bridge.impl.bun.d.ts +31 -0
  468. package/dist/terminal-pty-bridge.impl.bun.d.ts.map +1 -0
  469. package/dist/terminal-pty-bridge.impl.bun.js +333 -0
  470. package/dist/terminal-pty-bridge.impl.bun.js.map +1 -0
  471. package/dist/test-tooling/lazy-environment.impl.bun.d.ts +16 -0
  472. package/dist/test-tooling/lazy-environment.impl.bun.d.ts.map +1 -0
  473. package/dist/test-tooling/lazy-environment.impl.bun.js +36 -0
  474. package/dist/test-tooling/lazy-environment.impl.bun.js.map +1 -0
  475. package/dist/test-tooling/starttls-refusal.d.ts +7 -0
  476. package/dist/test-tooling/starttls-refusal.d.ts.map +1 -0
  477. package/dist/test-tooling/starttls-refusal.js +50 -0
  478. package/dist/test-tooling/starttls-refusal.js.map +1 -0
  479. package/dist/test-tooling/svelte-client-preload.impl.bun.d.ts +2 -0
  480. package/dist/test-tooling/svelte-client-preload.impl.bun.d.ts.map +1 -0
  481. package/dist/test-tooling/svelte-client-preload.impl.bun.js +4 -0
  482. package/dist/test-tooling/svelte-client-preload.impl.bun.js.map +1 -0
  483. package/dist/test-tooling/svelte-compiler.impl.bun.d.ts +10 -0
  484. package/dist/test-tooling/svelte-compiler.impl.bun.d.ts.map +1 -0
  485. package/dist/test-tooling/svelte-compiler.impl.bun.js +33 -0
  486. package/dist/test-tooling/svelte-compiler.impl.bun.js.map +1 -0
  487. package/dist/test-tooling/svelte-server-preload.impl.bun.d.ts +2 -0
  488. package/dist/test-tooling/svelte-server-preload.impl.bun.d.ts.map +1 -0
  489. package/dist/test-tooling/svelte-server-preload.impl.bun.js +4 -0
  490. package/dist/test-tooling/svelte-server-preload.impl.bun.js.map +1 -0
  491. package/dist/test-tooling/test-environment.impl.bun.d.ts +45 -0
  492. package/dist/test-tooling/test-environment.impl.bun.d.ts.map +1 -0
  493. package/dist/test-tooling/test-environment.impl.bun.js +163 -0
  494. package/dist/test-tooling/test-environment.impl.bun.js.map +1 -0
  495. package/dist/test-tooling/test-process-root.impl.bun.d.ts +4 -0
  496. package/dist/test-tooling/test-process-root.impl.bun.d.ts.map +1 -0
  497. package/dist/test-tooling/test-process-root.impl.bun.js +65 -0
  498. package/dist/test-tooling/test-process-root.impl.bun.js.map +1 -0
  499. package/dist/test-tooling/unix-http.impl.bun.d.ts +28 -0
  500. package/dist/test-tooling/unix-http.impl.bun.d.ts.map +1 -0
  501. package/dist/test-tooling/unix-http.impl.bun.js +181 -0
  502. package/dist/test-tooling/unix-http.impl.bun.js.map +1 -0
  503. package/dist/transpiler/transpiler.plugin.d.ts +10 -0
  504. package/dist/transpiler/transpiler.plugin.d.ts.map +1 -0
  505. package/dist/transpiler/transpiler.plugin.js +18 -0
  506. package/dist/transpiler/transpiler.plugin.js.map +1 -0
  507. package/native/held-launch/Cargo.toml +23 -0
  508. package/native/held-launch/abi-manifest.json +234 -0
  509. package/native/held-launch/src/bin/vibes-held-launch.rs +35 -0
  510. package/native/held-launch/src/events.rs +99 -0
  511. package/native/held-launch/src/lib.rs +528 -0
  512. package/native/held-launch/symbols.golden +21 -0
  513. package/package.json +313 -4
  514. package/resources/restricted-supervisor.impl.bun.d.mts +3 -0
  515. package/resources/restricted-supervisor.impl.bun.mjs +49 -0
  516. package/resources/serve-stall-watch.impl.bun.d.mts +3 -0
  517. package/resources/serve-stall-watch.impl.bun.mjs +51 -0
@@ -0,0 +1,528 @@
1
+ //! Execution owner's native ABI. One opaque handle retains one actual Child.
2
+ //! Calls on a handle must be serialized; a pointer is valid until dispose=1.
3
+ //! No runtime, process registry, identity resolver, timer, or secret lookup.
4
+ #![cfg(any(target_os = "macos", target_os = "linux"))]
5
+
6
+ mod events;
7
+
8
+ use std::ffi::{CStr, c_char, c_int, c_ulong};
9
+ use std::fs::File;
10
+ use std::io::{self, Write};
11
+ use std::os::fd::{AsRawFd, FromRawFd, IntoRawFd};
12
+ use std::os::unix::net::UnixStream;
13
+ use std::os::unix::process::ExitStatusExt;
14
+ use std::os::unix::process::CommandExt;
15
+ use std::path::Path;
16
+ use std::process::{Command, Stdio};
17
+ use vibes_native_core::held_launch::{ControlInterest, ExecStatus, HeldChild, LaunchError, NativeIdentity,
18
+ exec_after_release_with_stdio, read_declared_launch_payload, report_exec_failure};
19
+ use vibes_native_core::process_identity::read_process_identity;
20
+
21
+ vibes_native_core::last_error_plane!(vhl);
22
+
23
+ #[cfg(target_os = "macos")]
24
+ const OPEN_PTY_FLAGS: c_int = 2 | 0x0002_0000 | 0x0100_0000;
25
+ #[cfg(target_os = "linux")]
26
+ const OPEN_PTY_FLAGS: c_int = 2 | 0x100 | 0x80000;
27
+ #[cfg(target_os = "macos")]
28
+ const TIOCSCTTY: c_ulong = 0x2000_7461;
29
+ #[cfg(target_os = "linux")]
30
+ const TIOCSCTTY: c_ulong = 0x540e;
31
+ #[cfg(target_os = "macos")]
32
+ const TIOCSWINSZ: c_ulong = 0x8008_7467;
33
+ #[cfg(target_os = "linux")]
34
+ const TIOCSWINSZ: c_ulong = 0x5414;
35
+ #[cfg(target_os = "macos")]
36
+ const O_NONBLOCK: c_int = 0x4;
37
+ #[cfg(target_os = "linux")]
38
+ const O_NONBLOCK: c_int = 0x800;
39
+
40
+ unsafe extern "C" {
41
+ fn posix_openpt(flags: c_int) -> c_int;
42
+ fn grantpt(fd: c_int) -> c_int;
43
+ fn unlockpt(fd: c_int) -> c_int;
44
+ fn ptsname_r(fd: c_int, buffer: *mut c_char, len: usize) -> c_int;
45
+ fn open(path: *const c_char, flags: c_int, ...) -> c_int;
46
+ fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int;
47
+ fn dup2(old: c_int, new: c_int) -> c_int;
48
+ fn fcntl(fd: c_int, command: c_int, ...) -> c_int;
49
+ fn getrlimit(resource: c_int, limit: *mut ResourceLimit) -> c_int;
50
+ fn setrlimit(resource: c_int, limit: *const ResourceLimit) -> c_int;
51
+ fn fork() -> c_int;
52
+ fn setsid() -> c_int;
53
+ }
54
+
55
+ #[repr(C)]
56
+ struct ResourceLimit { soft: u64, hard: u64 }
57
+ #[cfg(target_os = "macos")]
58
+ const NOFILE: c_int = 8;
59
+ #[cfg(target_os = "linux")]
60
+ const NOFILE: c_int = 7;
61
+
62
+ /// The helper is already exec'd: no allocation or host policy runs between fork and exec.
63
+ fn require_fd_floor(floor: u64) -> io::Result<()> {
64
+ if floor == 0 { return Ok(()); }
65
+ let mut limit = ResourceLimit { soft: 0, hard: 0 };
66
+ if unsafe { getrlimit(NOFILE, &mut limit) } < 0 { return Err(io::Error::last_os_error()); }
67
+ if limit.soft >= floor { return Ok(()); }
68
+ if limit.hard < floor { return Err(io::Error::from(io::ErrorKind::PermissionDenied)); }
69
+ let requested = ResourceLimit { soft: floor, hard: limit.hard };
70
+ if unsafe { setrlimit(NOFILE, &requested) } < 0 { return Err(io::Error::last_os_error()); }
71
+ if unsafe { getrlimit(NOFILE, &mut limit) } < 0 { return Err(io::Error::last_os_error()); }
72
+ if limit.soft < floor || limit.hard != requested.hard { return Err(io::Error::from(io::ErrorKind::PermissionDenied)); }
73
+ Ok(())
74
+ }
75
+
76
+ /// Preserve existing flags; failure leaves the descriptor with its native owner.
77
+ fn prepare_transferred_fd(fd: c_int) -> io::Result<()> {
78
+ unsafe {
79
+ let descriptor_flags = fcntl(fd, 1); // F_GETFD
80
+ if descriptor_flags < 0 { return Err(io::Error::last_os_error()); }
81
+ if fcntl(fd, 2, descriptor_flags | 1) < 0 { return Err(io::Error::last_os_error()); } // F_SETFD, FD_CLOEXEC
82
+ let status_flags = fcntl(fd, 3); // F_GETFL
83
+ if status_flags < 0 { return Err(io::Error::last_os_error()); }
84
+ if fcntl(fd, 4, status_flags | O_NONBLOCK) < 0 { return Err(io::Error::last_os_error()); } // F_SETFL
85
+ }
86
+ Ok(())
87
+ }
88
+
89
+ #[repr(C)]
90
+ struct WindowSize { rows: u16, cols: u16, xpixel: u16, ypixel: u16 }
91
+
92
+ /// ABI error text contains only stable phases and numeric errno.
93
+ fn record(phase: &str, errno: Option<i32>) -> i32 {
94
+ set_last_error(format!("{phase}:errno={}", errno.unwrap_or(0)));
95
+ -1
96
+ }
97
+ fn launch_error(error: LaunchError) -> i32 { record(error.phase, error.errno) }
98
+ fn invalid() -> io::Error { io::Error::from(io::ErrorKind::InvalidInput) }
99
+
100
+ struct Cursor<'a> { bytes: &'a [u8], offset: usize }
101
+ impl<'a> Cursor<'a> {
102
+ fn take(&mut self, len: usize) -> io::Result<&'a [u8]> {
103
+ let end = self.offset.checked_add(len).ok_or_else(invalid)?;
104
+ let value = self.bytes.get(self.offset..end).ok_or_else(invalid)?;
105
+ self.offset = end;
106
+ Ok(value)
107
+ }
108
+ fn count(&mut self) -> io::Result<usize> {
109
+ let bytes: [u8; 4] = self.take(4)?.try_into().map_err(|_| invalid())?;
110
+ Ok(u32::from_be_bytes(bytes) as usize)
111
+ }
112
+ fn string(&mut self) -> io::Result<&'a str> {
113
+ let len = self.count()?;
114
+ let value = std::str::from_utf8(self.take(len)?).map_err(|_| invalid())?;
115
+ if value.as_bytes().contains(&0) { return Err(invalid()); }
116
+ Ok(value)
117
+ }
118
+ }
119
+
120
+ /// VHLW2\0, u64 minimum NOFILE (zero absent), command/cwd, argc, envc.
121
+ /// Counts/string lengths are u32 big-endian. No trailing bytes, NULs or implicit env.
122
+ fn workload(bytes: &[u8]) -> io::Result<(Command, u64)> {
123
+ let mut cursor = Cursor { bytes, offset: 0 };
124
+ if cursor.take(6)? != b"VHLW2\0" { return Err(invalid()); }
125
+ let floor = u64::from_be_bytes(cursor.take(8)?.try_into().map_err(|_| invalid())?);
126
+ if floor > 9_007_199_254_740_991 { return Err(invalid()); }
127
+ let executable = cursor.string()?;
128
+ let cwd = cursor.string()?;
129
+ if !Path::new(executable).is_absolute() || !Path::new(cwd).is_absolute() { return Err(invalid()); }
130
+ let mut command = Command::new(executable);
131
+ command.current_dir(cwd).env_clear();
132
+ for _ in 0..cursor.count()? { command.arg(cursor.string()?); }
133
+ for _ in 0..cursor.count()? {
134
+ let name = cursor.string()?;
135
+ if name.is_empty() || name.contains('=') { return Err(invalid()); }
136
+ command.env(name, cursor.string()?);
137
+ }
138
+ if cursor.offset != bytes.len() { return Err(invalid()); }
139
+ Ok((command, floor))
140
+ }
141
+
142
+ fn stdio(mode: u8) -> io::Result<Stdio> {
143
+ match mode { 0 => Ok(Stdio::piped()), 1 => Ok(Stdio::inherit()), 2 => Ok(Stdio::null()), _ => Err(invalid()) }
144
+ }
145
+
146
+ fn resize(fd: c_int, cols: u16, rows: u16) -> io::Result<()> {
147
+ if cols == 0 || rows == 0 { return Err(invalid()); }
148
+ let size = WindowSize { rows, cols, xpixel: 0, ypixel: 0 };
149
+ if unsafe { ioctl(fd, TIOCSWINSZ, &size) } < 0 { return Err(io::Error::last_os_error()); }
150
+ Ok(())
151
+ }
152
+
153
+ fn pty(cols: u16, rows: u16) -> io::Result<(File, File)> {
154
+ // Atomic CLOEXEC at creation; never use openpty followed by a racy fcntl.
155
+ let master_fd = unsafe { posix_openpt(OPEN_PTY_FLAGS) };
156
+ if master_fd < 0 { return Err(io::Error::last_os_error()); }
157
+ let master = unsafe { File::from_raw_fd(master_fd) };
158
+ if unsafe { grantpt(master_fd) } < 0 || unsafe { unlockpt(master_fd) } < 0 {
159
+ return Err(io::Error::last_os_error());
160
+ }
161
+ // This is a native device-name buffer, not a workload/resource budget.
162
+ let mut path = [0 as c_char; 4096];
163
+ let result = unsafe { ptsname_r(master_fd, path.as_mut_ptr(), path.len()) };
164
+ if result != 0 { return Err(if result > 0 { io::Error::from_raw_os_error(result) } else { io::Error::last_os_error() }); }
165
+ let slave_fd = unsafe { open(path.as_ptr(), OPEN_PTY_FLAGS) };
166
+ if slave_fd < 0 { return Err(io::Error::last_os_error()); }
167
+ let slave = unsafe { File::from_raw_fd(slave_fd) };
168
+ resize(master_fd, cols, rows)?;
169
+ Ok((master, slave))
170
+ }
171
+
172
+ pub struct Launch {
173
+ child: Option<HeldChild>,
174
+ master: Option<File>,
175
+ master_transferred: bool,
176
+ }
177
+
178
+ /// All pointer/length pairs are caller-owned valid memory for the call. Handles
179
+ /// cannot be forged, aliased concurrently, or used after successful dispose.
180
+ unsafe fn launch<'a>(pointer: *mut Launch) -> Result<&'a mut Launch, i32> {
181
+ unsafe { pointer.as_mut() }.ok_or_else(|| record("handle-invalid", None))
182
+ }
183
+ unsafe fn bytes<'a>(pointer: *const u8, len: usize) -> io::Result<&'a [u8]> {
184
+ if len == 0 { return Ok(&[]); }
185
+ if pointer.is_null() || len > isize::MAX as usize { return Err(invalid()); }
186
+ Ok(unsafe { vibes_native_core::byte_slice(pointer, len) })
187
+ }
188
+ unsafe fn path<'a>(pointer: *const c_char) -> io::Result<&'a str> {
189
+ if pointer.is_null() { return Err(invalid()); }
190
+ let value = unsafe { CStr::from_ptr(pointer) }.to_str().map_err(|_| invalid())?;
191
+ if !Path::new(value).is_absolute() { return Err(invalid()); }
192
+ Ok(value)
193
+ }
194
+
195
+ /// stdin/out/err: 0 pipe, 1 inherit, 2 ignore. cols=rows=0 selects pipes;
196
+ /// nonzero cols AND rows select PTY. helper cwd is an explicit host declaration.
197
+ #[unsafe(no_mangle)]
198
+ pub unsafe extern "C" fn vhl_spawn(helper: *const c_char, helper_cwd: *const c_char,
199
+ payload: *const u8, len: usize, max_payload_bytes: usize, stdin: u8, stdout: u8, stderr: u8,
200
+ cols: u16, rows: u16) -> *mut Launch
201
+ {
202
+ let prepared = (|| -> io::Result<(Command, Vec<u8>, Option<File>)> {
203
+ if max_payload_bytes == 0 || max_payload_bytes >= isize::MAX as usize || len > max_payload_bytes {
204
+ return Err(invalid());
205
+ }
206
+ let bytes = unsafe { bytes(payload, len)? };
207
+ let _validated = workload(bytes)?;
208
+ let mut helper = Command::new(unsafe { path(helper)? });
209
+ helper.current_dir(unsafe { path(helper_cwd)? }).env_clear();
210
+ let terminal = cols != 0 || rows != 0;
211
+ let master = if terminal {
212
+ if cols == 0 || rows == 0 { return Err(invalid()); }
213
+ let (master, slave) = pty(cols, rows)?;
214
+ helper.stdin(Stdio::from(slave.try_clone()?))
215
+ .stdout(Stdio::from(slave.try_clone()?)).stderr(Stdio::from(slave));
216
+ Some(master)
217
+ } else {
218
+ helper.stdin(stdio(stdin)?).stdout(stdio(stdout)?).stderr(stdio(stderr)?);
219
+ None
220
+ };
221
+ let mut framed = Vec::new();
222
+ framed.try_reserve_exact(bytes.len().checked_add(1).ok_or_else(invalid)?)
223
+ .map_err(|_| io::Error::from(io::ErrorKind::OutOfMemory))?;
224
+ framed.push(u8::from(terminal));
225
+ framed.extend_from_slice(bytes);
226
+ Ok((helper, framed, master))
227
+ })();
228
+ let (helper, payload, master) = match prepared {
229
+ Ok(prepared) => prepared,
230
+ Err(error) => { record("launch-prepare", error.raw_os_error()); return std::ptr::null_mut(); }
231
+ };
232
+ // The protocol's terminal tag is fixed overhead, outside the workload budget.
233
+ match HeldChild::spawn_with_payload(helper, |fd| fd.to_string(), payload, max_payload_bytes + 1) {
234
+ Ok(child) => Box::into_raw(Box::new(Launch { child: Some(child), master, master_transferred: false })),
235
+ Err(error) => { launch_error(error); std::ptr::null_mut() }
236
+ }
237
+ }
238
+
239
+ #[unsafe(no_mangle)]
240
+ pub unsafe extern "C" fn vhl_pid(pointer: *mut Launch) -> i64 {
241
+ match unsafe { launch(pointer) } { Ok(handle) => handle.child.as_ref().map_or(-1, |child| i64::from(child.pid())), Err(_) => -1 }
242
+ }
243
+ #[unsafe(no_mangle)]
244
+ pub unsafe extern "C" fn vhl_control_fd(pointer: *mut Launch) -> i32 {
245
+ match unsafe { launch(pointer) } { Ok(handle) => handle.child.as_ref().map_or(-1, |child| child.control_event().0.as_raw_fd()), Err(error) => error }
246
+ }
247
+ /// 1 readable, 2 writable; borrowed descriptor, level-triggered registration.
248
+ #[unsafe(no_mangle)]
249
+ pub unsafe extern "C" fn vhl_control_interest(pointer: *mut Launch) -> i32 {
250
+ match unsafe { launch(pointer) } {
251
+ Ok(handle) => match handle.child.as_ref().map(|child| child.control_event().1) {
252
+ Some(ControlInterest::Readable) => 1, Some(ControlInterest::Writable) => 2, None => -1
253
+ }, Err(error) => error
254
+ }
255
+ }
256
+
257
+ unsafe fn identity(pid: u32, sid: u32, token: *const u8, len: usize) -> io::Result<NativeIdentity> {
258
+ let token = std::str::from_utf8(unsafe { bytes(token, len)? }).map_err(|_| invalid())?;
259
+ if token.is_empty() || token.as_bytes().contains(&0) { return Err(invalid()); }
260
+ Ok(NativeIdentity { pid, session_id: sid, start_token: token.to_owned() })
261
+ }
262
+
263
+ /// Read identity for this retained child, never an arbitrary caller-supplied pid.
264
+ /// Success returns the UTF-8 token length (not NUL terminated) and writes pid/sid
265
+ /// to out[0]/out[1]. Failure=-1; no output is written on insufficient capacity.
266
+ #[unsafe(no_mangle)]
267
+ pub unsafe extern "C" fn vhl_identity(pointer: *mut Launch, out: *mut u32,
268
+ token: *mut u8, capacity: usize) -> isize
269
+ {
270
+ if out.is_null() || token.is_null() || capacity > isize::MAX as usize {
271
+ return record("identity-output-invalid", None) as isize;
272
+ }
273
+ let handle = match unsafe { launch(pointer) } { Ok(handle) => handle, Err(error) => return error as isize };
274
+ let Some(child) = handle.child.as_mut() else { return record("handle-disposed", None) as isize; };
275
+ match child.try_reap() {
276
+ Ok(None) => {},
277
+ Ok(Some(_)) => return record("identity-child-exited", None) as isize,
278
+ Err(error) => return launch_error(error) as isize,
279
+ }
280
+ let observed = match read_process_identity(child.pid()) {
281
+ Ok(Some(identity)) => identity,
282
+ Ok(None) => return record("identity-child-absent", None) as isize,
283
+ Err(error) => return record("identity-read", error.raw_os_error()) as isize,
284
+ };
285
+ match child.try_reap() {
286
+ Ok(None) => {},
287
+ Ok(Some(_)) => return record("identity-child-exited", None) as isize,
288
+ Err(error) => return launch_error(error) as isize,
289
+ }
290
+ let bytes = observed.start_token.as_bytes();
291
+ if capacity < bytes.len() { return record("identity-output-capacity", None) as isize; }
292
+ unsafe {
293
+ out.write(observed.pid);
294
+ out.add(1).write(observed.session_id);
295
+ std::ptr::copy_nonoverlapping(bytes.as_ptr(), token, bytes.len());
296
+ }
297
+ bytes.len() as isize
298
+ }
299
+
300
+ /// 0 pending, 1 complete READY frame, -1 failure. Only after 1 should the
301
+ /// adapter obtain its canonical identity snapshot and call vhl_ready.
302
+ #[unsafe(no_mangle)]
303
+ pub unsafe extern "C" fn vhl_advance_ready(pointer: *mut Launch) -> i32 {
304
+ let handle = match unsafe { launch(pointer) } { Ok(handle) => handle, Err(error) => return error };
305
+ let Some(child) = handle.child.as_mut() else { return record("handle-disposed", None); };
306
+ match child.try_ready_message() { Ok(true) => 1, Ok(false) => 0, Err(error) => launch_error(error) }
307
+ }
308
+
309
+ /// 0 pending, 1 READY admitted, -1 fixed error. Identity comes from the canonical
310
+ /// process owner, never from this library. The actual retained Child is checked.
311
+ #[unsafe(no_mangle)]
312
+ pub unsafe extern "C" fn vhl_ready(pointer: *mut Launch, pid: u32, sid: u32, token: *const u8, len: usize) -> i32 {
313
+ let handle = match unsafe { launch(pointer) } { Ok(handle) => handle, Err(error) => return error };
314
+ let identity = match unsafe { identity(pid, sid, token, len) } { Ok(identity) => identity, Err(_) => return record("identity-invalid", None) };
315
+ let Some(child) = handle.child.as_mut() else { return record("handle-disposed", None); };
316
+ match child.try_ready(|_| Ok(identity)) { Ok(Some(_)) => 1, Ok(None) => 0, Err(error) => launch_error(error) }
317
+ }
318
+
319
+ #[unsafe(no_mangle)]
320
+ pub unsafe extern "C" fn vhl_release(pointer: *mut Launch, pid: u32, sid: u32, token: *const u8, len: usize) -> i32 {
321
+ let handle = match unsafe { launch(pointer) } { Ok(handle) => handle, Err(error) => return error };
322
+ let identity = match unsafe { identity(pid, sid, token, len) } { Ok(identity) => identity, Err(_) => return record("identity-invalid", None) };
323
+ let Some(child) = handle.child.as_mut() else { return record("handle-disposed", None); };
324
+ match child.release(|_| Ok(identity)) { Ok(()) => 1, Err(error) => launch_error(error) }
325
+ }
326
+
327
+ /// Transfer one FD exactly once: 0 stdin, 1 stdout, 2 stderr, 3 PTY master.
328
+ /// Admission sets O_NONBLOCK and FD_CLOEXEC before transfer, retaining custody
329
+ /// on failure. Child-side pipe ends and the PTY slave remain blocking.
330
+ /// -2 is an undeclared/already-transferred stream; -1 is an actual failure.
331
+ #[unsafe(no_mangle)]
332
+ pub unsafe extern "C" fn vhl_take_fd(pointer: *mut Launch, stream: u8) -> i32 {
333
+ let handle = match unsafe { launch(pointer) } { Ok(handle) => handle, Err(error) => return error };
334
+ let Some(child) = handle.child.as_mut() else { return record("handle-disposed", None); };
335
+ let pipe = match stream { 0 => child.stdin_fd(), 1 => child.stdout_fd(), 2 => child.stderr_fd(), _ => None };
336
+ if let Some(fd) = pipe {
337
+ if let Err(error) = prepare_transferred_fd(fd) { return record("stream-transfer-flags", error.raw_os_error()); }
338
+ }
339
+ match stream {
340
+ 0 => child.take_stdin().map_or(-2, IntoRawFd::into_raw_fd),
341
+ 1 => child.take_stdout().map_or(-2, IntoRawFd::into_raw_fd),
342
+ 2 => child.take_stderr().map_or(-2, IntoRawFd::into_raw_fd),
343
+ 3 => {
344
+ if handle.master_transferred { return -2; }
345
+ let Some(master) = &handle.master else { return -2; };
346
+ match master.try_clone() {
347
+ Ok(fd) => {
348
+ if let Err(error) = prepare_transferred_fd(fd.as_raw_fd()) { return record("pty-transfer-flags", error.raw_os_error()); }
349
+ handle.master_transferred = true;
350
+ fd.into_raw_fd()
351
+ },
352
+ Err(error) => record("pty-transfer", error.raw_os_error())
353
+ }
354
+ },
355
+ _ => record("stream-invalid", None)
356
+ }
357
+ }
358
+
359
+ #[unsafe(no_mangle)]
360
+ pub unsafe extern "C" fn vhl_resize(pointer: *mut Launch, cols: u16, rows: u16) -> i32 {
361
+ let handle = match unsafe { launch(pointer) } { Ok(handle) => handle, Err(error) => return error };
362
+ let Some(master) = &handle.master else { return record("pty-unavailable", None); };
363
+ match resize(master.as_raw_fd(), cols, rows) { Ok(()) => 1, Err(error) => record("pty-resize", error.raw_os_error()) }
364
+ }
365
+
366
+ #[unsafe(no_mangle)]
367
+ pub unsafe extern "C" fn vhl_terminate(pointer: *mut Launch) -> i32 {
368
+ let handle = match unsafe { launch(pointer) } { Ok(handle) => handle, Err(error) => return error };
369
+ let Some(child) = handle.child.as_mut() else { return record("handle-disposed", None); };
370
+ match child.terminate_child() { Ok(()) => 1, Err(error) => launch_error(error) }
371
+ }
372
+
373
+ /// 0 pending, 1 reaped, -1 error. out[0]=exit code (-1 absent), out[1]=signal
374
+ /// number (0 absent). Only actual parent wait evidence populates these values.
375
+ #[unsafe(no_mangle)]
376
+ pub unsafe extern "C" fn vhl_reap(pointer: *mut Launch, out: *mut i32) -> i32 {
377
+ if out.is_null() { return record("reap-output-invalid", None); }
378
+ let handle = match unsafe { launch(pointer) } { Ok(handle) => handle, Err(error) => return error };
379
+ let Some(child) = handle.child.as_mut() else { return record("handle-disposed", None); };
380
+ match child.try_reap() {
381
+ Ok(None) => 0,
382
+ Ok(Some(status)) => { unsafe { out.write(status.code().unwrap_or(-1)); out.add(1).write(status.signal().unwrap_or(0)); } 1 },
383
+ Err(error) => launch_error(error)
384
+ }
385
+ }
386
+
387
+ /// 0 pending, 1 control closed (NOT exit), 2 exec failure with out[0]=errno.
388
+ #[unsafe(no_mangle)]
389
+ pub unsafe extern "C" fn vhl_exec_status(pointer: *mut Launch, out: *mut i32) -> i32 {
390
+ if out.is_null() { return record("exec-status-output-invalid", None); }
391
+ let handle = match unsafe { launch(pointer) } { Ok(handle) => handle, Err(error) => return error };
392
+ let Some(child) = handle.child.as_mut() else { return record("handle-disposed", None); };
393
+ match child.try_exec_status() {
394
+ Ok(None) => 0,
395
+ Ok(Some(ExecStatus::ControlClosed)) => 1,
396
+ Ok(Some(ExecStatus::Failed(errno))) => { unsafe { out.write(errno); } 2 },
397
+ Err(error) => launch_error(error)
398
+ }
399
+ }
400
+
401
+ /// Success=1 invalidates the pointer. Failure=-1 RETAINS it and its child.
402
+ #[unsafe(no_mangle)]
403
+ pub unsafe extern "C" fn vhl_dispose(pointer: *mut Launch) -> i32 {
404
+ let handle = match unsafe { launch(pointer) } { Ok(handle) => handle, Err(error) => return error };
405
+ let Some(child) = handle.child.take() else { return record("handle-disposed", None); };
406
+ match child.try_dispose() {
407
+ Ok(()) => { drop(unsafe { Box::from_raw(pointer) }); 1 },
408
+ Err((child, error)) => { handle.child = Some(child); launch_error(error) }
409
+ }
410
+ }
411
+
412
+ /// Called only by this cohort's trusted helper executable. The received bytes
413
+ /// have no authority to choose another resolver or supervisor.
414
+ pub fn run_helper(mut control: UnixStream) -> (&'static str, Option<i32>) {
415
+ let payload = match read_declared_launch_payload(&mut control) {
416
+ Ok(payload) => payload,
417
+ Err(error) => return ("payload-read", error.raw_os_error())
418
+ };
419
+ let Some((&terminal, bytes)) = payload.split_first() else { return ("payload-invalid", None); };
420
+ if terminal > 1 { return ("payload-invalid", None); }
421
+ let (mut command, floor) = match workload(bytes) {
422
+ Ok(command) => command,
423
+ Err(error) => return ("payload-invalid", error.raw_os_error())
424
+ };
425
+ let mut status = match control.try_clone() {
426
+ Ok(status) => status,
427
+ Err(error) => return ("status-duplicate", error.raw_os_error())
428
+ };
429
+ let error = exec_after_release_with_stdio(control, &mut command, || {
430
+ require_fd_floor(floor)?;
431
+ if terminal == 1 {
432
+ if unsafe { ioctl(0, TIOCSCTTY, 0) } < 0 { return Err(io::Error::last_os_error()); }
433
+ if unsafe { dup2(0, 1) } < 0 || unsafe { dup2(0, 2) } < 0 { return Err(io::Error::last_os_error()); }
434
+ }
435
+ Ok(())
436
+ });
437
+ if let Err(report) = report_exec_failure(&mut status, error.raw_os_error()) {
438
+ return ("exec-status-write", report.raw_os_error());
439
+ }
440
+ ("helper-exec", error.raw_os_error())
441
+ }
442
+
443
+ /// Ordinary caller-owned ChildProcess handoff: no setsid, identity or membership owner.
444
+ /// The parent's native spawn has already chosen detached/stdio dispositions.
445
+ pub fn run_direct_helper(mut control: UnixStream) -> (&'static str, Option<i32>) {
446
+ let prepared = (|| -> io::Result<(Command, u64)> {
447
+ let payload = read_declared_launch_payload(&mut control)?;
448
+ workload(&payload)
449
+ })();
450
+ let (mut command, floor) = match prepared {
451
+ Ok(value) => value,
452
+ Err(error) => {
453
+ if let Err(report) = direct_failure(&mut control, b"FAIL", error.raw_os_error()) {
454
+ return ("exec-status-write", report.raw_os_error());
455
+ }
456
+ return ("payload-invalid", error.raw_os_error());
457
+ }
458
+ };
459
+ let fd = control.as_raw_fd();
460
+ let setup = (|| -> io::Result<()> {
461
+ let flags = unsafe { fcntl(fd, 1) };
462
+ if flags < 0 || unsafe { fcntl(fd, 2, flags | 1) } < 0 { return Err(io::Error::last_os_error()); }
463
+ require_fd_floor(floor)
464
+ })();
465
+ if let Err(error) = setup {
466
+ if let Err(report) = direct_failure(&mut control, b"FDNO", error.raw_os_error()) {
467
+ return ("exec-status-write", report.raw_os_error());
468
+ }
469
+ return ("fd-floor", error.raw_os_error());
470
+ }
471
+ if let Err(error) = control.write_all(b"VFD2RDY\n") { return ("ready-write", error.raw_os_error()); }
472
+ let error = command.exec();
473
+ if let Err(report) = direct_failure(&mut control, b"EXEC", error.raw_os_error()) { return ("exec-status-write", report.raw_os_error()); }
474
+ ("helper-exec", error.raw_os_error())
475
+ }
476
+
477
+ /// Daemon handoff: this helper is the launcher's child and exits as soon as it has forked the
478
+ /// workload, so the system reparents the workload and it is never a descendant of the launcher.
479
+ /// The workload starts its own session (pid = pgid = sid), applies the floor, reports its pid in
480
+ /// the fixed `VFD2DMN\n` + u32 big-endian frame and execs. The helper's exit and the workload's
481
+ /// CLOEXEC exec together end the stream: EOF after the pid frame with no failure frame is the exec
482
+ /// receipt. `None` is the helper's own success (exit 0); `Some` is a fixed phase/errno (exit 126).
483
+ pub fn run_daemon_helper(mut control: UnixStream) -> Option<(&'static str, Option<i32>)> {
484
+ let prepared = (|| -> io::Result<(Command, u64)> {
485
+ let payload = read_declared_launch_payload(&mut control)?;
486
+ workload(&payload)
487
+ })();
488
+ let (mut command, floor) = match prepared {
489
+ Ok(value) => value,
490
+ Err(error) => return Some(daemon_failure(&mut control, b"FAIL", "payload-invalid", error))
491
+ };
492
+ let fd = control.as_raw_fd();
493
+ let flags = unsafe { fcntl(fd, 1) };
494
+ if flags < 0 || unsafe { fcntl(fd, 2, flags | 1) } < 0 {
495
+ return Some(daemon_failure(&mut control, b"FAIL", "control-cloexec", io::Error::last_os_error()));
496
+ }
497
+ // The helper is single-threaded (already exec'd), so the forked workload may run ordinary code before its exec.
498
+ match unsafe { fork() } {
499
+ pid if pid < 0 => Some(daemon_failure(&mut control, b"FORK", "fork", io::Error::last_os_error())),
500
+ 0 => {
501
+ if unsafe { setsid() } < 0 {
502
+ return Some(daemon_failure(&mut control, b"SSID", "setsid", io::Error::last_os_error()));
503
+ }
504
+ if let Err(error) = require_fd_floor(floor) {
505
+ return Some(daemon_failure(&mut control, b"FDNO", "fd-floor", error));
506
+ }
507
+ let mut ready = *b"VFD2DMN\n\0\0\0\0";
508
+ ready[8..].copy_from_slice(&std::process::id().to_be_bytes());
509
+ if let Err(error) = control.write_all(&ready) { return Some(("ready-write", error.raw_os_error())); }
510
+ let error = command.exec();
511
+ Some(daemon_failure(&mut control, b"EXEC", "helper-exec", error))
512
+ }
513
+ _ => None
514
+ }
515
+ }
516
+
517
+ /// Report one fixed failure frame; a frame that cannot be written is reported as the write failure.
518
+ fn daemon_failure(control: &mut UnixStream, phase: &[u8; 4], name: &'static str, error: io::Error) -> (&'static str, Option<i32>) {
519
+ match direct_failure(control, phase, error.raw_os_error()) {
520
+ Ok(()) => (name, error.raw_os_error()),
521
+ Err(report) => ("exec-status-write", report.raw_os_error())
522
+ }
523
+ }
524
+
525
+ fn direct_failure(control: &mut UnixStream, phase: &[u8; 4], errno: Option<i32>) -> io::Result<()> {
526
+ control.write_all(phase)?;
527
+ control.write_all(&errno.unwrap_or(0).to_be_bytes())
528
+ }
@@ -0,0 +1,21 @@
1
+ _vhl_advance_ready
2
+ _vhl_control_fd
3
+ _vhl_control_interest
4
+ _vhl_dispose
5
+ _vhl_events_cancel
6
+ _vhl_events_create
7
+ _vhl_events_dispose
8
+ _vhl_events_finish
9
+ _vhl_events_watch_child
10
+ _vhl_events_watch_fd
11
+ _vhl_exec_status
12
+ _vhl_identity
13
+ _vhl_last_error
14
+ _vhl_pid
15
+ _vhl_ready
16
+ _vhl_reap
17
+ _vhl_release
18
+ _vhl_resize
19
+ _vhl_spawn
20
+ _vhl_take_fd
21
+ _vhl_terminate