@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,175 @@
1
+ /**
2
+ * The execution base's adapter over the native held-launch ABI
3
+ * (`native/held-launch/src/lib.rs` + `abi-manifest.json`, Codex's contract).
4
+ *
5
+ * It turns one opaque native handle into a {@link HeldLaunchHandle}:
6
+ *
7
+ * - **Payload.** The workload travels only as the framed control-fd payload
8
+ * (`VHLW2\0`, u64BE minimum open-file budget, u32BE-length UTF-8 command and cwd, both absolute, a u32 argc
9
+ * plus strings, a u32 env count plus key/value strings; nothing trailing),
10
+ * bounded by the provider's declared `maxPayloadBytes` (never per request).
11
+ * - **Readiness is level-triggered.** Wait for the control fd's declared
12
+ * interest through the event reactor, then advance; never a timer. Only
13
+ * after a complete READY frame is the canonical identity read from the
14
+ * retained child (`vhl_identity`, never a caller-supplied pid) and admitted
15
+ * (`vhl_ready`); release takes a fresh identity snapshot.
16
+ * - **Exit.** The canonical process event precedes the parent's `try_reap`;
17
+ * control-fd EOF is not exit, and READY/release is not exec success
18
+ * (`vhl_exec_status` keeps exec failure apart from a workload's exit 126).
19
+ * - **Custody.** `take_fd` is one-shot; `resize` keeps the native PTY master;
20
+ * `dispose` alone invalidates the handle, and a refusal keeps it.
21
+ *
22
+ * The native library and the host's event owners are ports: this module holds
23
+ * no timer, no process registry and no identity resolver.
24
+ */
25
+ import { CapabilityError, type RuntimeLifecycle } from '@vibesdotdev/kernel';
26
+ import { type HeldLaunchFdStreams } from './streams.impl.bun.ts';
27
+ import type { HeldLaunchPort, NativeBirth } from '@vibesdotdev/execution-local/owned-session';
28
+ /** An opaque native handle; valid until a successful dispose. */
29
+ export type NativeLaunchHandle = number & {
30
+ readonly __nativeLaunchHandle: unique symbol;
31
+ };
32
+ /** An opaque native event-reactor handle; valid until `finish` returns 1. */
33
+ export type NativeEventsHandle = number & {
34
+ readonly __nativeEventsHandle: unique symbol;
35
+ };
36
+ /**
37
+ * Mint the opaque handle for a native launch address. The brand is nominal:
38
+ * only a binding that received `address` from the native library, or a scripted
39
+ * library standing in for it, may call this.
40
+ */
41
+ export declare function nativeLaunchHandle(address: number): NativeLaunchHandle;
42
+ /** Mint the opaque handle for a native event-reactor address (same contract as {@link nativeLaunchHandle}). */
43
+ export declare function nativeEventsHandle(address: number): NativeEventsHandle;
44
+ /** The reactor's callback events (`vibes_native_core::process_events`). */
45
+ export declare const REACTOR_EVENT: {
46
+ readonly fdReady: 1;
47
+ readonly childExited: 2;
48
+ readonly cancelAck: 3;
49
+ readonly disposeAck: 4;
50
+ readonly watchError: 5;
51
+ };
52
+ /** The ABI's stream numbers for `take_fd`. */
53
+ export type NativeStream = 0 | 1 | 2 | 3;
54
+ /**
55
+ * The raw ABI, one method per exported symbol. Integers are the ABI's own
56
+ * return codes; this module interprets them. A binding (bun:ffi) implements it.
57
+ */
58
+ export interface HeldLaunchLibrary {
59
+ spawn(helperPath: string, helperCwd: string, payload: Uint8Array, maxPayloadBytes: number, stdin: number, stdout: number, stderr: number, cols: number, rows: number): NativeLaunchHandle | null;
60
+ pid(handle: NativeLaunchHandle): number;
61
+ /** The retained child's canonical identity, or null on failure (see `lastError`). */
62
+ identity(handle: NativeLaunchHandle): NativeBirth | null;
63
+ controlFd(handle: NativeLaunchHandle): number;
64
+ /** 1 readable, 2 writable, negative on failure. */
65
+ controlInterest(handle: NativeLaunchHandle): number;
66
+ /** 0 pending, 1 complete READY frame, -1 failure. */
67
+ advanceReady(handle: NativeLaunchHandle): number;
68
+ /** 0 pending, 1 READY admitted, -1 failure. */
69
+ ready(handle: NativeLaunchHandle, pid: number, sessionId: number, startToken: Uint8Array): number;
70
+ /** 1 released, -1 failure. */
71
+ release(handle: NativeLaunchHandle, pid: number, sessionId: number, startToken: Uint8Array): number;
72
+ /** An owned fd, -2 undeclared or already transferred, -1 failure. */
73
+ takeFd(handle: NativeLaunchHandle, stream: NativeStream): number;
74
+ resize(handle: NativeLaunchHandle, cols: number, rows: number): number;
75
+ terminate(handle: NativeLaunchHandle): number;
76
+ /** status 0 pending, 1 reaped, -1 failure; code -1 absent; signal 0 absent. */
77
+ reap(handle: NativeLaunchHandle): {
78
+ status: number;
79
+ code: number;
80
+ signal: number;
81
+ };
82
+ /** status 0 pending, 1 control closed (not exit), 2 exec failure with errno, -1 failure. */
83
+ execStatus(handle: NativeLaunchHandle): {
84
+ status: number;
85
+ errno: number;
86
+ };
87
+ /** 1 disposed (handle invalid), -1 refused (handle and child retained). */
88
+ dispose(handle: NativeLaunchHandle): number;
89
+ /** The last failure on this thread: `<phase>:errno=<n>`, or null. */
90
+ lastError(): string | null;
91
+ /**
92
+ * Create the event reactor. `onEvent` is called on the JS thread for every
93
+ * native callback `(id, event, detail)`; the binding keeps it alive until
94
+ * `releaseCallback` runs, which the owner calls only after `eventsFinish`
95
+ * returned 1. The caps are the provider's declared resource inputs.
96
+ */
97
+ eventsCreate(onEvent: (id: number, event: number, detail: number) => void, maxWatches: number, maxPendingCommands: number): {
98
+ owner: NativeEventsHandle;
99
+ releaseCallback(): void;
100
+ } | null;
101
+ /** 1 accepted, -1 failure. `interest` 1 readable, 2 writable. */
102
+ eventsWatchFd(owner: NativeEventsHandle, fd: number, interest: 1 | 2, id: number): number;
103
+ /** 1 accepted, -1 failure; an already-exited child is delivered at once. */
104
+ eventsWatchChild(owner: NativeEventsHandle, handle: NativeLaunchHandle, id: number): number;
105
+ /** 1 pending (a cancel ACK follows), 2 already terminal (no new ACK), -1 failure. */
106
+ eventsCancel(owner: NativeEventsHandle, id: number): number;
107
+ /** 1 accepted (memoized; the pointer stays valid; event 4 follows), -1 failure. */
108
+ eventsDispose(owner: NativeEventsHandle): number;
109
+ /** 0 thread still running, 1 joined (pointer invalid), -1 failure (pointer retained). */
110
+ eventsFinish(owner: NativeEventsHandle): number;
111
+ }
112
+ /**
113
+ * The event owner around the ABI (the held-launch reactor, see
114
+ * {@link createHeldLaunchReactor}): one-shot,
115
+ * level-triggered watches that honour `signal` and settle only after the
116
+ * reactor acknowledged a cancel. None is a timer.
117
+ */
118
+ export interface HeldLaunchEvents {
119
+ /** Resolve once `fd` has the level-triggered `interest`; reject when `signal` aborts. */
120
+ controlReady(fd: number, interest: 'readable' | 'writable', signal: AbortSignal): Promise<void>;
121
+ /**
122
+ * Resolve when the retained child of `handle` has an exit to reap, including
123
+ * one that already happened; reject when `signal` aborts.
124
+ */
125
+ childExited(handle: NativeLaunchHandle, signal: AbortSignal): Promise<void>;
126
+ }
127
+ /**
128
+ * The {@link HeldLaunchPort} over a native held-launch library. `helperPath`
129
+ * is the installed trusted helper the host's manifest names; `maxPayloadBytes`
130
+ * is the provider's declared input budget (never a per-request override); the
131
+ * helper starts in the workload's cwd, which the payload also carries.
132
+ */
133
+ export declare function createHeldLaunchPort(options: {
134
+ readonly library: HeldLaunchLibrary;
135
+ readonly helperPath: string;
136
+ readonly maxPayloadBytes: number;
137
+ readonly events: HeldLaunchEvents;
138
+ readonly streams?: HeldLaunchFdStreams;
139
+ }): HeldLaunchPort;
140
+ /** The provider's declared reactor resource caps. */
141
+ export interface HeldLaunchReactorCaps {
142
+ readonly maxWatches: number;
143
+ readonly maxPendingCommands: number;
144
+ }
145
+ /** A runtime's one reactor: the {@link HeldLaunchEvents} plus its two-step shutdown. */
146
+ export interface HeldLaunchReactor extends HeldLaunchEvents {
147
+ /**
148
+ * Close every watch and join the reactor thread within `signal`/the
149
+ * finalization budget: dispose (memoized), await the dispose ACK, then
150
+ * `finish` until it joins; only then is the JS callback released. Resolves
151
+ * `joined: false` when the budget ran out before the join: the callback and
152
+ * library stay alive, and cleanup is unconfirmed, never claimed.
153
+ */
154
+ shutdown(lifecycle: Pick<RuntimeLifecycle, 'wait' | 'delay'>, budgetMs: number): Promise<HeldLaunchReactorShutdown>;
155
+ }
156
+ /**
157
+ * How a reactor shutdown ended. `joined: false` carries the typed failure
158
+ * (the finalization budget ran out, or the wait was cancelled) that left the
159
+ * join unconfirmed.
160
+ */
161
+ export type HeldLaunchReactorShutdown = {
162
+ readonly joined: true;
163
+ } | {
164
+ readonly joined: false;
165
+ readonly unconfirmed: CapabilityError;
166
+ };
167
+ /**
168
+ * The held-launch reactor over the native ABI. One per runtime, created on the
169
+ * first held launch. Watches are one-shot and level-triggered; a watch whose
170
+ * signal aborts is cancelled and settles only on its cancel ACK (or its
171
+ * already-in-flight terminal event), so an id is never retired early and never
172
+ * reused.
173
+ */
174
+ export declare function createHeldLaunchReactor(library: HeldLaunchLibrary, caps: HeldLaunchReactorCaps): HeldLaunchReactor;
175
+ //# sourceMappingURL=abi.impl.bun.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"abi.impl.bun.d.ts","sourceRoot":"","sources":["../../src/held-launch/abi.impl.bun.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,476 @@
1
+ /**
2
+ * The execution base's adapter over the native held-launch ABI
3
+ * (`native/held-launch/src/lib.rs` + `abi-manifest.json`, Codex's contract).
4
+ *
5
+ * It turns one opaque native handle into a {@link HeldLaunchHandle}:
6
+ *
7
+ * - **Payload.** The workload travels only as the framed control-fd payload
8
+ * (`VHLW2\0`, u64BE minimum open-file budget, u32BE-length UTF-8 command and cwd, both absolute, a u32 argc
9
+ * plus strings, a u32 env count plus key/value strings; nothing trailing),
10
+ * bounded by the provider's declared `maxPayloadBytes` (never per request).
11
+ * - **Readiness is level-triggered.** Wait for the control fd's declared
12
+ * interest through the event reactor, then advance; never a timer. Only
13
+ * after a complete READY frame is the canonical identity read from the
14
+ * retained child (`vhl_identity`, never a caller-supplied pid) and admitted
15
+ * (`vhl_ready`); release takes a fresh identity snapshot.
16
+ * - **Exit.** The canonical process event precedes the parent's `try_reap`;
17
+ * control-fd EOF is not exit, and READY/release is not exec success
18
+ * (`vhl_exec_status` keeps exec failure apart from a workload's exit 126).
19
+ * - **Custody.** `take_fd` is one-shot; `resize` keeps the native PTY master;
20
+ * `dispose` alone invalidates the handle, and a refusal keeps it.
21
+ *
22
+ * The native library and the host's event owners are ports: this module holds
23
+ * no timer, no process registry and no identity resolver.
24
+ */
25
+ import { closeSync } from 'node:fs';
26
+ import { constants as osConstants } from 'node:os';
27
+ import { CapabilityError } from '@vibesdotdev/kernel';
28
+ import { encodeHeldLaunchPayload, heldLaunchPayloadInvalid, isHeldLaunchAbsolutePath } from '@vibesdotdev/execution-local';
29
+ import { createReactorFdStreams } from "./streams.impl.bun.js";
30
+ /**
31
+ * Mint the opaque handle for a native launch address. The brand is nominal:
32
+ * only a binding that received `address` from the native library, or a scripted
33
+ * library standing in for it, may call this.
34
+ */
35
+ export function nativeLaunchHandle(address) {
36
+ // SAFETY: `NativeLaunchHandle` is a nominal brand over the native address; the number is unchanged and the brand has no runtime representation.
37
+ return address;
38
+ }
39
+ /** Mint the opaque handle for a native event-reactor address (same contract as {@link nativeLaunchHandle}). */
40
+ export function nativeEventsHandle(address) {
41
+ // SAFETY: `NativeEventsHandle` is a nominal brand over the native address; the number is unchanged and the brand has no runtime representation.
42
+ return address;
43
+ }
44
+ /** The reactor's callback events (`vibes_native_core::process_events`). */
45
+ export const REACTOR_EVENT = { fdReady: 1, childExited: 2, cancelAck: 3, disposeAck: 4, watchError: 5 };
46
+ const STDIO_CODE = { pipe: 0, inherit: 1, ignore: 2 };
47
+ function nativeFailureDetails(library, operation) {
48
+ const raw = library.lastError() ?? '';
49
+ const match = /^([a-z0-9-]+):errno=(-?\d+)$/.exec(raw);
50
+ return {
51
+ operation,
52
+ phase: match?.[1] ?? 'unknown',
53
+ errno: match ? Number(match[2]) : null
54
+ };
55
+ }
56
+ /** A native failure, with the ABI's fixed phase and errno only (never workload values). */
57
+ function nativeFailure(library, operation) {
58
+ return new CapabilityError(`The native held launch failed during ${operation}.`, 'UNAVAILABLE', {
59
+ reason: 'held-launch-failed',
60
+ retryable: false,
61
+ details: nativeFailureDetails(library, operation)
62
+ });
63
+ }
64
+ const SIGNAL_NAMES = new Map(Object.entries(osConstants.signals).map(([name, number]) => [number, name]));
65
+ /** Close `fd`; a failed close is returned for the caller to report, never dropped. */
66
+ function closeOnce(fd) {
67
+ try {
68
+ closeSync(fd);
69
+ return null;
70
+ }
71
+ catch (cause) {
72
+ return new CapabilityError('A transferred held-launch descriptor could not be closed.', 'UNAVAILABLE', {
73
+ reason: 'held-launch-fd-close-failed',
74
+ retryable: false,
75
+ details: { fd },
76
+ cause
77
+ });
78
+ }
79
+ }
80
+ /** Take the declared descriptors and give each to exactly one stream owner. */
81
+ function adoptIo(library, streams, handle, request, live) {
82
+ const taken = [];
83
+ const take = (stream) => {
84
+ const fd = library.takeFd(handle, stream);
85
+ if (fd === -2)
86
+ return null;
87
+ if (fd < 0)
88
+ throw nativeFailure(library, 'take-fd');
89
+ taken.push(fd);
90
+ return fd;
91
+ };
92
+ try {
93
+ if (request.pty !== undefined) {
94
+ const master = take(3);
95
+ if (master === null)
96
+ throw nativeFailure(library, 'take-pty-master');
97
+ return {
98
+ io: {
99
+ kind: 'pty',
100
+ // One owner for the one master fd: read and written, closed once.
101
+ master: streams.duplex(master),
102
+ resize(cols, rows) {
103
+ if (library.resize(live('resize'), cols, rows) !== 1)
104
+ throw nativeFailure(library, 'resize');
105
+ }
106
+ },
107
+ failure: undefined
108
+ };
109
+ }
110
+ const stdio = request.stdio;
111
+ const stdin = stdio.stdin === 'pipe' ? take(0) : null;
112
+ const stdout = stdio.stdout === 'pipe' ? take(1) : null;
113
+ const stderr = stdio.stderr === 'pipe' ? take(2) : null;
114
+ return {
115
+ io: {
116
+ kind: 'pipes',
117
+ stdin: stdin === null ? null : streams.writer(stdin),
118
+ stdout: stdout === null ? null : streams.reader(stdout),
119
+ stderr: stderr === null ? null : streams.reader(stderr)
120
+ },
121
+ failure: undefined
122
+ };
123
+ }
124
+ catch (error) {
125
+ // Every take precedes stream construction, so no stream owns these fds yet:
126
+ // this failed adoption closes each exactly once, and reports a close that fails.
127
+ const closeFailures = taken.map(closeOnce).filter((failure) => failure !== null);
128
+ const adoption = error instanceof CapabilityError
129
+ ? error
130
+ : new CapabilityError('The native held launch failed during adopt.', 'UNAVAILABLE', {
131
+ reason: 'held-launch-failed',
132
+ retryable: false,
133
+ details: nativeFailureDetails(library, 'adopt'),
134
+ cause: error
135
+ });
136
+ const failure = closeFailures.length === 0
137
+ ? adoption
138
+ : new CapabilityError('The held launch failed during adopt, and a transferred descriptor could not be closed.', 'UNAVAILABLE', {
139
+ reason: 'held-launch-adoption-cleanup-failed',
140
+ retryable: false,
141
+ cause: new AggregateError([adoption, ...closeFailures])
142
+ });
143
+ return { io: { kind: 'pipes', stdin: null, stdout: null, stderr: null }, failure };
144
+ }
145
+ }
146
+ function tokenBytes(birth) {
147
+ return new TextEncoder().encode(birth.startToken);
148
+ }
149
+ function adoptHandle(library, events, streams, handle, request) {
150
+ let disposed = false;
151
+ const live = (operation) => {
152
+ if (disposed) {
153
+ throw new CapabilityError(`The held launch was disposed; ${operation} has no handle.`, 'CONFLICT', {
154
+ reason: 'held-launch-disposed',
155
+ retryable: false
156
+ });
157
+ }
158
+ return handle;
159
+ };
160
+ // Custody first: nothing below may drop this handle. A failure while
161
+ // adopting it surfaces from `ready()`, so the owner's one cleanup still
162
+ // terminates, reaps and disposes the retained child.
163
+ let adoptionFailure;
164
+ if (library.pid(handle) <= 0)
165
+ adoptionFailure = nativeFailure(library, 'pid');
166
+ /** The canonical identity of the retained child, read natively. */
167
+ const identify = (operation) => {
168
+ const birth = library.identity(live(operation));
169
+ if (birth === null)
170
+ throw nativeFailure(library, `${operation}-identity`);
171
+ return birth;
172
+ };
173
+ // The streams exist from birth: the workload runs only after release.
174
+ const adopted = adoptIo(library, streams, handle, request, live);
175
+ adoptionFailure ??= adopted.failure;
176
+ const { io } = adopted;
177
+ const awaitControl = (signal) => {
178
+ const current = live('ready');
179
+ const interest = library.controlInterest(current);
180
+ if (interest !== 1 && interest !== 2)
181
+ throw nativeFailure(library, 'control-interest');
182
+ return events.controlReady(library.controlFd(current), interest === 1 ? 'readable' : 'writable', signal);
183
+ };
184
+ return {
185
+ io,
186
+ async ready(signal) {
187
+ if (adoptionFailure)
188
+ throw adoptionFailure;
189
+ // Level-triggered: advance; on "pending", wait for the declared interest and advance again.
190
+ for (;;) {
191
+ const advanced = library.advanceReady(live('ready'));
192
+ if (advanced === 1)
193
+ break;
194
+ if (advanced < 0)
195
+ throw nativeFailure(library, 'advance-ready');
196
+ await awaitControl(signal);
197
+ }
198
+ // Only after a complete READY frame: the canonical identity, then admission.
199
+ for (;;) {
200
+ const birth = identify('ready');
201
+ const admitted = library.ready(live('ready'), birth.pid, birth.sessionId, tokenBytes(birth));
202
+ if (admitted === 1)
203
+ return birth;
204
+ if (admitted < 0)
205
+ throw nativeFailure(library, 'ready');
206
+ await awaitControl(signal);
207
+ }
208
+ },
209
+ async release() {
210
+ // A fresh identity snapshot: release checks the held child is still that birth.
211
+ const birth = identify('release');
212
+ if (library.release(live('release'), birth.pid, birth.sessionId, tokenBytes(birth)) !== 1) {
213
+ throw nativeFailure(library, 'release');
214
+ }
215
+ },
216
+ async terminateChild() {
217
+ if (library.terminate(live('terminate')) !== 1)
218
+ throw nativeFailure(library, 'terminate');
219
+ },
220
+ async exited(signal) {
221
+ await events.childExited(live('exited'), signal);
222
+ },
223
+ async reaped(signal) {
224
+ // The canonical exit event precedes the parent's reap; a pending reap waits for it.
225
+ for (;;) {
226
+ const result = library.reap(live('reap'));
227
+ if (result.status === 1) {
228
+ return {
229
+ code: result.code === -1 ? null : result.code,
230
+ signal: result.signal === 0 ? null : (SIGNAL_NAMES.get(result.signal) ?? `SIG${result.signal}`)
231
+ };
232
+ }
233
+ if (result.status < 0)
234
+ throw nativeFailure(library, 'reap');
235
+ await events.childExited(live('reap'), signal);
236
+ }
237
+ },
238
+ execStatus() {
239
+ const result = library.execStatus(live('exec-status'));
240
+ if (result.status === 0)
241
+ return { status: 'pending' };
242
+ if (result.status === 1)
243
+ return { status: 'control-closed' };
244
+ if (result.status === 2)
245
+ return { status: 'exec-failed', errno: result.errno };
246
+ throw nativeFailure(library, 'exec-status');
247
+ },
248
+ async dispose() {
249
+ if (disposed)
250
+ return { disposed: true };
251
+ if (library.dispose(handle) === 1) {
252
+ disposed = true;
253
+ return { disposed: true };
254
+ }
255
+ // Refused: the native handle and its child stay in custody.
256
+ const failure = nativeFailure(library, 'dispose');
257
+ return { disposed: false, reason: `${failure.details?.phase ?? 'unknown'}` };
258
+ }
259
+ };
260
+ }
261
+ function budgetInvalid(value) {
262
+ return new CapabilityError('A held-launch provider declares a positive whole-byte payload budget.', 'INVALID_INPUT', {
263
+ reason: 'held-launch-payload-budget-invalid',
264
+ retryable: false,
265
+ details: { maxPayloadBytes: value }
266
+ });
267
+ }
268
+ /**
269
+ * The {@link HeldLaunchPort} over a native held-launch library. `helperPath`
270
+ * is the installed trusted helper the host's manifest names; `maxPayloadBytes`
271
+ * is the provider's declared input budget (never a per-request override); the
272
+ * helper starts in the workload's cwd, which the payload also carries.
273
+ */
274
+ export function createHeldLaunchPort(options) {
275
+ const { library, helperPath, maxPayloadBytes, events } = options;
276
+ // Default: the descriptors are read and written on the same reactor's readiness.
277
+ const streams = options.streams ?? createReactorFdStreams(events);
278
+ if (!isHeldLaunchAbsolutePath(helperPath))
279
+ throw heldLaunchPayloadInvalid('helperPath');
280
+ if (!Number.isSafeInteger(maxPayloadBytes) || maxPayloadBytes <= 0)
281
+ throw budgetInvalid(maxPayloadBytes);
282
+ return {
283
+ spawn(request) {
284
+ const payload = encodeHeldLaunchPayload(request);
285
+ if (payload.length > maxPayloadBytes) {
286
+ throw new CapabilityError('The held launch workload exceeds the provider\'s declared payload budget.', 'INVALID_INPUT', {
287
+ reason: 'held-launch-payload-too-large',
288
+ retryable: false,
289
+ details: { bytes: payload.length, maxPayloadBytes }
290
+ });
291
+ }
292
+ const stdio = request.stdio ?? { stdin: 'pipe', stdout: 'pipe', stderr: 'pipe' };
293
+ const handle = library.spawn(helperPath, request.cwd, payload, maxPayloadBytes, STDIO_CODE[stdio.stdin], STDIO_CODE[stdio.stdout], STDIO_CODE[stdio.stderr], request.pty?.cols ?? 0, request.pty?.rows ?? 0);
294
+ if (handle === null)
295
+ throw nativeFailure(library, 'spawn');
296
+ return adoptHandle(library, events, streams, handle, request);
297
+ }
298
+ };
299
+ }
300
+ function reactorFailure(library, operation) {
301
+ return nativeFailure(library, operation);
302
+ }
303
+ /**
304
+ * The held-launch reactor over the native ABI. One per runtime, created on the
305
+ * first held launch. Watches are one-shot and level-triggered; a watch whose
306
+ * signal aborts is cancelled and settles only on its cancel ACK (or its
307
+ * already-in-flight terminal event), so an id is never retired early and never
308
+ * reused.
309
+ */
310
+ export function createHeldLaunchReactor(library, caps) {
311
+ for (const [name, value] of Object.entries(caps)) {
312
+ if (!Number.isSafeInteger(value) || value <= 0) {
313
+ throw new CapabilityError(`The held-launch reactor's ${name} must be a positive whole number.`, 'INVALID_INPUT', {
314
+ reason: 'held-launch-reactor-caps-invalid',
315
+ retryable: false,
316
+ details: { [name]: value }
317
+ });
318
+ }
319
+ }
320
+ const pending = new Map();
321
+ let nextId = 1;
322
+ let fatalError;
323
+ let disposeAck;
324
+ const disposeAcked = new Promise((resolve) => {
325
+ disposeAck = resolve;
326
+ });
327
+ let shuttingDown = false;
328
+ const onEvent = (id, event, detail) => {
329
+ if (id === 0 && event === REACTOR_EVENT.watchError) {
330
+ fatalError = new CapabilityError('A held-launch global reactor error occurred.', 'UNAVAILABLE', {
331
+ reason: 'held-launch-reactor-failed',
332
+ retryable: false,
333
+ details: { errno: detail }
334
+ });
335
+ shuttingDown = true;
336
+ for (const [watchId, watch] of pending) {
337
+ pending.delete(watchId);
338
+ watch.reject(fatalError);
339
+ }
340
+ return;
341
+ }
342
+ if (event === REACTOR_EVENT.disposeAck) {
343
+ // Every watch is closed now; any still pending never receives its event.
344
+ for (const [watchId, watch] of pending) {
345
+ pending.delete(watchId);
346
+ watch.reject(watch.cancelError ??
347
+ watch.aborted ??
348
+ new CapabilityError('The held-launch reactor was disposed before this watch fired.', 'CANCELLED', {
349
+ reason: 'held-launch-reactor-disposed',
350
+ retryable: false
351
+ }));
352
+ }
353
+ disposeAck();
354
+ return;
355
+ }
356
+ const watch = pending.get(id);
357
+ if (!watch)
358
+ return;
359
+ pending.delete(id);
360
+ if (watch.cancelError !== undefined) {
361
+ watch.reject(watch.cancelError);
362
+ return;
363
+ }
364
+ if (watch.aborted !== undefined) {
365
+ watch.reject(watch.aborted);
366
+ return;
367
+ }
368
+ if (event === REACTOR_EVENT.fdReady || event === REACTOR_EVENT.childExited)
369
+ watch.resolve();
370
+ else if (event === REACTOR_EVENT.watchError) {
371
+ watch.reject(new CapabilityError('A held-launch watch failed natively.', 'UNAVAILABLE', {
372
+ reason: 'held-launch-watch-failed',
373
+ retryable: false,
374
+ details: { errno: detail }
375
+ }));
376
+ }
377
+ else {
378
+ watch.reject(new CapabilityError('The held-launch watch was cancelled.', 'CANCELLED', { reason: 'held-launch-watch-cancelled', retryable: false }));
379
+ }
380
+ };
381
+ const created = library.eventsCreate(onEvent, caps.maxWatches, caps.maxPendingCommands);
382
+ if (created === null)
383
+ throw reactorFailure(library, 'events-create');
384
+ const { owner, releaseCallback } = created;
385
+ const watch = (arm, operation, signal) => {
386
+ if (fatalError)
387
+ return Promise.reject(fatalError);
388
+ if (shuttingDown) {
389
+ return Promise.reject(new CapabilityError('The held-launch reactor is shutting down.', 'UNAVAILABLE', { reason: 'held-launch-reactor-disposed', retryable: false }));
390
+ }
391
+ if (signal.aborted)
392
+ return Promise.reject(signal.reason);
393
+ const id = nextId++;
394
+ return new Promise((resolve, reject) => {
395
+ const entry = { resolve, reject, cancelSent: false };
396
+ pending.set(id, entry);
397
+ if (arm(id) !== 1) {
398
+ pending.delete(id);
399
+ reject(reactorFailure(library, operation));
400
+ return;
401
+ }
402
+ const onAbort = () => {
403
+ if (!pending.has(id) || entry.cancelSent)
404
+ return;
405
+ entry.aborted = signal.reason;
406
+ entry.cancelSent = true;
407
+ // 1: an ACK follows; 2: the terminal event is in flight. Either way the entry settles on it.
408
+ // A cancel returning < 0 keeps pending custody until a terminal event, cancel ACK, or disposeAck.
409
+ if (library.eventsCancel(owner, id) < 0) {
410
+ entry.cancelError = reactorFailure(library, 'events-cancel');
411
+ }
412
+ };
413
+ signal.addEventListener('abort', onAbort, { once: true });
414
+ const settle = () => signal.removeEventListener('abort', onAbort);
415
+ entry.resolve = () => {
416
+ settle();
417
+ resolve();
418
+ };
419
+ entry.reject = (error) => {
420
+ settle();
421
+ reject(error);
422
+ };
423
+ });
424
+ };
425
+ let shutdownResult;
426
+ return {
427
+ controlReady(fd, interest, signal) {
428
+ return watch((id) => library.eventsWatchFd(owner, fd, interest === 'readable' ? 1 : 2, id), 'events-watch-fd', signal);
429
+ },
430
+ childExited(handle, signal) {
431
+ return watch((id) => library.eventsWatchChild(owner, handle, id), 'events-watch-child', signal);
432
+ },
433
+ shutdown(lifecycle, budgetMs) {
434
+ shutdownResult ??= (async () => {
435
+ shuttingDown = true;
436
+ let disposeError = null;
437
+ if (library.eventsDispose(owner) !== 1) {
438
+ disposeError = reactorFailure(library, 'events-dispose');
439
+ }
440
+ try {
441
+ await lifecycle.wait(async (signal) => {
442
+ if (!disposeError) {
443
+ // The dispose ACK arrives before the thread exits: it closes watches, not the join.
444
+ await Promise.race([
445
+ disposeAcked,
446
+ new Promise((_, reject) => signal.addEventListener('abort', () => reject(signal.reason), { once: true }))
447
+ ]);
448
+ }
449
+ // The native thread offers no join event: finish is polled, bounded by this wait.
450
+ for (;;) {
451
+ const finished = library.eventsFinish(owner);
452
+ if (finished === 1)
453
+ return;
454
+ if (finished < 0)
455
+ throw reactorFailure(library, 'events-finish');
456
+ await lifecycle.delay(5, signal);
457
+ }
458
+ }, { timeoutMs: Math.max(1, budgetMs), reason: 'held-launch-reactor-finish' });
459
+ }
460
+ catch (error) {
461
+ if (error instanceof CapabilityError && (error.code === 'TIMEOUT' || error.code === 'CANCELLED')) {
462
+ // Not joined: keep the callback and library alive; cleanup is unconfirmed.
463
+ return { joined: false, unconfirmed: error };
464
+ }
465
+ throw error;
466
+ }
467
+ releaseCallback();
468
+ if (disposeError)
469
+ throw disposeError;
470
+ return { joined: true };
471
+ })();
472
+ return shutdownResult;
473
+ }
474
+ };
475
+ }
476
+ //# sourceMappingURL=abi.impl.bun.js.map