@vibesdotdev/host-bun 0.0.0-stage → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +18 -0
- package/README.md +222 -2
- package/dist/applet-serve-host/applet-serve-host.impl.bun.d.ts +6 -0
- package/dist/applet-serve-host/applet-serve-host.impl.bun.d.ts.map +1 -0
- package/dist/applet-serve-host/applet-serve-host.impl.bun.js +80 -0
- package/dist/applet-serve-host/applet-serve-host.impl.bun.js.map +1 -0
- package/dist/applet-serve-host/applet-serve-host.plugin.d.ts +22 -0
- package/dist/applet-serve-host/applet-serve-host.plugin.d.ts.map +1 -0
- package/dist/applet-serve-host/applet-serve-host.plugin.js +42 -0
- package/dist/applet-serve-host/applet-serve-host.plugin.js.map +1 -0
- package/dist/applet-serve-host/index.d.ts +7 -0
- package/dist/applet-serve-host/index.d.ts.map +1 -0
- package/dist/applet-serve-host/index.js +7 -0
- package/dist/applet-serve-host/index.js.map +1 -0
- package/dist/applet-serve-host/stylesheet.compiler.d.ts +7 -0
- package/dist/applet-serve-host/stylesheet.compiler.d.ts.map +1 -0
- package/dist/applet-serve-host/stylesheet.compiler.js +63 -0
- package/dist/applet-serve-host/stylesheet.compiler.js.map +1 -0
- package/dist/atlas-migrations/register-atlas-host-migrations.d.ts +21 -0
- package/dist/atlas-migrations/register-atlas-host-migrations.d.ts.map +1 -0
- package/dist/atlas-migrations/register-atlas-host-migrations.js +148 -0
- package/dist/atlas-migrations/register-atlas-host-migrations.js.map +1 -0
- package/dist/buffered-capture.d.ts +4 -0
- package/dist/buffered-capture.d.ts.map +1 -0
- package/dist/buffered-capture.impl.bun.d.ts +18 -0
- package/dist/buffered-capture.impl.bun.d.ts.map +1 -0
- package/dist/buffered-capture.impl.bun.js +148 -0
- package/dist/buffered-capture.impl.bun.js.map +1 -0
- package/dist/buffered-capture.js +5 -0
- package/dist/buffered-capture.js.map +1 -0
- package/dist/bun-environment.impl.bun.d.ts +231 -0
- package/dist/bun-environment.impl.bun.d.ts.map +1 -0
- package/dist/bun-environment.impl.bun.js +352 -0
- package/dist/bun-environment.impl.bun.js.map +1 -0
- package/dist/cache-redis/cache-redis-connector.impl.bun.d.ts +20 -0
- package/dist/cache-redis/cache-redis-connector.impl.bun.d.ts.map +1 -0
- package/dist/cache-redis/cache-redis-connector.impl.bun.js +30 -0
- package/dist/cache-redis/cache-redis-connector.impl.bun.js.map +1 -0
- package/dist/cache-redis/cache-redis-connector.plugin.d.ts +21 -0
- package/dist/cache-redis/cache-redis-connector.plugin.d.ts.map +1 -0
- package/dist/cache-redis/cache-redis-connector.plugin.js +32 -0
- package/dist/cache-redis/cache-redis-connector.plugin.js.map +1 -0
- package/dist/cli-checkout.impl.bun.d.ts +13 -0
- package/dist/cli-checkout.impl.bun.d.ts.map +1 -0
- package/dist/cli-checkout.impl.bun.js +26 -0
- package/dist/cli-checkout.impl.bun.js.map +1 -0
- package/dist/docs/runtime-environment-bun.docs.descriptor.d.ts +19 -0
- package/dist/docs/runtime-environment-bun.docs.descriptor.d.ts.map +1 -0
- package/dist/docs/runtime-environment-bun.docs.descriptor.js +116 -0
- package/dist/docs/runtime-environment-bun.docs.descriptor.js.map +1 -0
- package/dist/filesystem/adapter.impl.bun.d.ts +15 -0
- package/dist/filesystem/adapter.impl.bun.d.ts.map +1 -0
- package/dist/filesystem/adapter.impl.bun.js +11 -0
- package/dist/filesystem/adapter.impl.bun.js.map +1 -0
- package/dist/filesystem/host-primitives.impl.bun.d.ts +12 -0
- package/dist/filesystem/host-primitives.impl.bun.d.ts.map +1 -0
- package/dist/filesystem/host-primitives.impl.bun.js +96 -0
- package/dist/filesystem/host-primitives.impl.bun.js.map +1 -0
- package/dist/filesystem/register.d.ts +12 -0
- package/dist/filesystem/register.d.ts.map +1 -0
- package/dist/filesystem/register.js +6 -0
- package/dist/filesystem/register.js.map +1 -0
- package/dist/filesystem/rooted-exclusive.impl.bun.d.ts +4 -0
- package/dist/filesystem/rooted-exclusive.impl.bun.d.ts.map +1 -0
- package/dist/filesystem/rooted-exclusive.impl.bun.js +135 -0
- package/dist/filesystem/rooted-exclusive.impl.bun.js.map +1 -0
- package/dist/held-launch/abi.impl.bun.d.ts +175 -0
- package/dist/held-launch/abi.impl.bun.d.ts.map +1 -0
- package/dist/held-launch/abi.impl.bun.js +476 -0
- package/dist/held-launch/abi.impl.bun.js.map +1 -0
- package/dist/held-launch/execution.impl.bun.d.ts +48 -0
- package/dist/held-launch/execution.impl.bun.d.ts.map +1 -0
- package/dist/held-launch/execution.impl.bun.js +375 -0
- package/dist/held-launch/execution.impl.bun.js.map +1 -0
- package/dist/held-launch/library.impl.bun.d.ts +23 -0
- package/dist/held-launch/library.impl.bun.d.ts.map +1 -0
- package/dist/held-launch/library.impl.bun.js +178 -0
- package/dist/held-launch/library.impl.bun.js.map +1 -0
- package/dist/held-launch/schemas.d.ts +10 -0
- package/dist/held-launch/schemas.d.ts.map +1 -0
- package/dist/held-launch/schemas.js +3 -0
- package/dist/held-launch/schemas.js.map +1 -0
- package/dist/held-launch/streams.impl.bun.d.ts +38 -0
- package/dist/held-launch/streams.impl.bun.d.ts.map +1 -0
- package/dist/held-launch/streams.impl.bun.js +183 -0
- package/dist/held-launch/streams.impl.bun.js.map +1 -0
- package/dist/host-channel.impl.bun.d.ts +25 -0
- package/dist/host-channel.impl.bun.d.ts.map +1 -0
- package/dist/host-channel.impl.bun.js +40 -0
- package/dist/host-channel.impl.bun.js.map +1 -0
- package/dist/host-client.impl.bun.d.ts +31 -0
- package/dist/host-client.impl.bun.d.ts.map +1 -0
- package/dist/host-client.impl.bun.js +39 -0
- package/dist/host-client.impl.bun.js.map +1 -0
- package/dist/host-credentials.d.ts +38 -0
- package/dist/host-credentials.d.ts.map +1 -0
- package/dist/host-credentials.js +44 -0
- package/dist/host-credentials.js.map +1 -0
- package/dist/host-loader.impl.bun.d.ts +12 -0
- package/dist/host-loader.impl.bun.d.ts.map +1 -0
- package/dist/host-loader.impl.bun.js +83 -0
- package/dist/host-loader.impl.bun.js.map +1 -0
- package/dist/host-signal.impl.bun.d.ts +11 -0
- package/dist/host-signal.impl.bun.d.ts.map +1 -0
- package/dist/host-signal.impl.bun.js +28 -0
- package/dist/host-signal.impl.bun.js.map +1 -0
- package/dist/http-listener.impl.bun.d.ts +8 -0
- package/dist/http-listener.impl.bun.d.ts.map +1 -0
- package/dist/http-listener.impl.bun.js +44 -0
- package/dist/http-listener.impl.bun.js.map +1 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +314 -0
- package/dist/index.js.map +1 -0
- package/dist/local-execution.impl.bun.d.ts +47 -0
- package/dist/local-execution.impl.bun.d.ts.map +1 -0
- package/dist/local-execution.impl.bun.js +150 -0
- package/dist/local-execution.impl.bun.js.map +1 -0
- package/dist/logging/file-host.impl.bun.d.ts +4 -0
- package/dist/logging/file-host.impl.bun.d.ts.map +1 -0
- package/dist/logging/file-host.impl.bun.js +36 -0
- package/dist/logging/file-host.impl.bun.js.map +1 -0
- package/dist/logging/logging.plugin.d.ts +12 -0
- package/dist/logging/logging.plugin.d.ts.map +1 -0
- package/dist/logging/logging.plugin.js +20 -0
- package/dist/logging/logging.plugin.js.map +1 -0
- package/dist/native/held-launch/aarch64-apple-darwin/libvibes_held_launch.dylib +0 -0
- package/dist/native/held-launch/aarch64-apple-darwin/manifest.json +237 -0
- package/dist/native/held-launch/aarch64-apple-darwin/vibes-held-launch +0 -0
- package/dist/native/held-launch/aarch64-unknown-linux-gnu/libvibes_held_launch.so +0 -0
- package/dist/native/held-launch/aarch64-unknown-linux-gnu/manifest.json +237 -0
- package/dist/native/held-launch/aarch64-unknown-linux-gnu/vibes-held-launch +0 -0
- package/dist/native/held-launch/x86_64-apple-darwin/libvibes_held_launch.dylib +0 -0
- package/dist/native/held-launch/x86_64-apple-darwin/manifest.json +237 -0
- package/dist/native/held-launch/x86_64-apple-darwin/vibes-held-launch +0 -0
- package/dist/native/held-launch/x86_64-unknown-linux-gnu/libvibes_held_launch.so +0 -0
- package/dist/native/held-launch/x86_64-unknown-linux-gnu/manifest.json +237 -0
- package/dist/native/held-launch/x86_64-unknown-linux-gnu/vibes-held-launch +0 -0
- package/dist/native-image.consumer.plugin.d.ts +4 -0
- package/dist/native-image.consumer.plugin.d.ts.map +1 -0
- package/dist/native-image.consumer.plugin.js +14 -0
- package/dist/native-image.consumer.plugin.js.map +1 -0
- package/dist/native-image.d.ts +79 -0
- package/dist/native-image.d.ts.map +1 -0
- package/dist/native-image.impl.consumer.d.ts +15 -0
- package/dist/native-image.impl.consumer.d.ts.map +1 -0
- package/dist/native-image.impl.consumer.js +86 -0
- package/dist/native-image.impl.consumer.js.map +1 -0
- package/dist/native-image.js +19 -0
- package/dist/native-image.js.map +1 -0
- package/dist/native-library.consumer.plugin.d.ts +6 -0
- package/dist/native-library.consumer.plugin.d.ts.map +1 -0
- package/dist/native-library.consumer.plugin.js +33 -0
- package/dist/native-library.consumer.plugin.js.map +1 -0
- package/dist/native-library.impl.consumer.d.ts +14 -0
- package/dist/native-library.impl.consumer.d.ts.map +1 -0
- package/dist/native-library.impl.consumer.js +46 -0
- package/dist/native-library.impl.consumer.js.map +1 -0
- package/dist/native-network/index.d.ts +3 -0
- package/dist/native-network/index.d.ts.map +1 -0
- package/dist/native-network/index.js +3 -0
- package/dist/native-network/index.js.map +1 -0
- package/dist/native-network/native-host.d.ts +4 -0
- package/dist/native-network/native-host.d.ts.map +1 -0
- package/dist/native-network/native-host.js +14 -0
- package/dist/native-network/native-host.js.map +1 -0
- package/dist/native-network/native-network.descriptor.d.ts +4 -0
- package/dist/native-network/native-network.descriptor.d.ts.map +1 -0
- package/dist/native-network/native-network.descriptor.js +11 -0
- package/dist/native-network/native-network.descriptor.js.map +1 -0
- package/dist/native-network/native-network.impl.bun.d.ts +19 -0
- package/dist/native-network/native-network.impl.bun.d.ts.map +1 -0
- package/dist/native-network/native-network.impl.bun.js +190 -0
- package/dist/native-network/native-network.impl.bun.js.map +1 -0
- package/dist/native-network/native-network.plugin.d.ts +6 -0
- package/dist/native-network/native-network.plugin.d.ts.map +1 -0
- package/dist/native-network/native-network.plugin.js +27 -0
- package/dist/native-network/native-network.plugin.js.map +1 -0
- package/dist/package-plugins/index.d.ts +11 -0
- package/dist/package-plugins/index.d.ts.map +1 -0
- package/dist/package-plugins/index.js +11 -0
- package/dist/package-plugins/index.js.map +1 -0
- package/dist/package-plugins/package-plugins.capability.bun.d.ts +11 -0
- package/dist/package-plugins/package-plugins.capability.bun.d.ts.map +1 -0
- package/dist/package-plugins/package-plugins.capability.bun.js +14 -0
- package/dist/package-plugins/package-plugins.capability.bun.js.map +1 -0
- package/dist/package-plugins/primitives.impl.bun.d.ts +11 -0
- package/dist/package-plugins/primitives.impl.bun.d.ts.map +1 -0
- package/dist/package-plugins/primitives.impl.bun.js +32 -0
- package/dist/package-plugins/primitives.impl.bun.js.map +1 -0
- package/dist/package-plugins/read-admission.impl.bun.d.ts +11 -0
- package/dist/package-plugins/read-admission.impl.bun.d.ts.map +1 -0
- package/dist/package-plugins/read-admission.impl.bun.js +224 -0
- package/dist/package-plugins/read-admission.impl.bun.js.map +1 -0
- package/dist/package-plugins/schemas.d.ts +28 -0
- package/dist/package-plugins/schemas.d.ts.map +1 -0
- package/dist/package-plugins/schemas.js +3 -0
- package/dist/package-plugins/schemas.js.map +1 -0
- package/dist/process/launch-artifacts.impl.bun.d.ts +11 -0
- package/dist/process/launch-artifacts.impl.bun.d.ts.map +1 -0
- package/dist/process/launch-artifacts.impl.bun.js +25 -0
- package/dist/process/launch-artifacts.impl.bun.js.map +1 -0
- package/dist/process/process-probe.impl.bun.d.ts +15 -0
- package/dist/process/process-probe.impl.bun.d.ts.map +1 -0
- package/dist/process/process-probe.impl.bun.js +35 -0
- package/dist/process/process-probe.impl.bun.js.map +1 -0
- package/dist/process/runtime-process.impl.bun.d.ts +20 -0
- package/dist/process/runtime-process.impl.bun.d.ts.map +1 -0
- package/dist/process/runtime-process.impl.bun.js +42 -0
- package/dist/process/runtime-process.impl.bun.js.map +1 -0
- package/dist/process/schemas.d.ts +9 -0
- package/dist/process/schemas.d.ts.map +1 -0
- package/dist/process/schemas.js +3 -0
- package/dist/process/schemas.js.map +1 -0
- package/dist/process/spawn.impl.bun.d.ts +31 -0
- package/dist/process/spawn.impl.bun.d.ts.map +1 -0
- package/dist/process/spawn.impl.bun.js +66 -0
- package/dist/process/spawn.impl.bun.js.map +1 -0
- package/dist/process/which.impl.bun.d.ts +16 -0
- package/dist/process/which.impl.bun.d.ts.map +1 -0
- package/dist/process/which.impl.bun.js +25 -0
- package/dist/process/which.impl.bun.js.map +1 -0
- package/dist/pty.adapter.impl.bun.d.ts +17 -0
- package/dist/pty.adapter.impl.bun.d.ts.map +1 -0
- package/dist/pty.adapter.impl.bun.js +102 -0
- package/dist/pty.adapter.impl.bun.js.map +1 -0
- package/dist/pty.darwin.impl.bun.d.ts +11 -0
- package/dist/pty.darwin.impl.bun.d.ts.map +1 -0
- package/dist/pty.darwin.impl.bun.js +200 -0
- package/dist/pty.darwin.impl.bun.js.map +1 -0
- package/dist/pty.node-host.impl.bun.d.ts +10 -0
- package/dist/pty.node-host.impl.bun.d.ts.map +1 -0
- package/dist/pty.node-host.impl.bun.js +42 -0
- package/dist/pty.node-host.impl.bun.js.map +1 -0
- package/dist/resolution-root.impl.bun.d.ts +170 -0
- package/dist/resolution-root.impl.bun.d.ts.map +1 -0
- package/dist/resolution-root.impl.bun.js +373 -0
- package/dist/resolution-root.impl.bun.js.map +1 -0
- package/dist/restricted-execute.darwin.impl.bun.d.ts +19 -0
- package/dist/restricted-execute.darwin.impl.bun.d.ts.map +1 -0
- package/dist/restricted-execute.darwin.impl.bun.js +459 -0
- package/dist/restricted-execute.darwin.impl.bun.js.map +1 -0
- package/dist/runtime-plugin-host/daemon-execution.worker-shim.bun.d.ts +2 -0
- package/dist/runtime-plugin-host/daemon-execution.worker-shim.bun.d.ts.map +1 -0
- package/dist/runtime-plugin-host/daemon-execution.worker-shim.bun.js +31 -0
- package/dist/runtime-plugin-host/daemon-execution.worker-shim.bun.js.map +1 -0
- package/dist/runtime-plugin-host/host-hot-reload.consumer.d.ts +20 -0
- package/dist/runtime-plugin-host/host-hot-reload.consumer.d.ts.map +1 -0
- package/dist/runtime-plugin-host/host-hot-reload.consumer.js +236 -0
- package/dist/runtime-plugin-host/host-hot-reload.consumer.js.map +1 -0
- package/dist/runtime-plugin-host/hot-plugin-build.worker.consumer.d.ts +2 -0
- package/dist/runtime-plugin-host/hot-plugin-build.worker.consumer.d.ts.map +1 -0
- package/dist/runtime-plugin-host/hot-plugin-build.worker.consumer.js +66 -0
- package/dist/runtime-plugin-host/hot-plugin-build.worker.consumer.js.map +1 -0
- package/dist/runtime-plugin-host/hot-plugin-module.consumer.d.ts +45 -0
- package/dist/runtime-plugin-host/hot-plugin-module.consumer.d.ts.map +1 -0
- package/dist/runtime-plugin-host/hot-plugin-module.consumer.js +490 -0
- package/dist/runtime-plugin-host/hot-plugin-module.consumer.js.map +1 -0
- package/dist/runtime-plugin-host/hot-reload.consumer.d.ts +83 -0
- package/dist/runtime-plugin-host/hot-reload.consumer.d.ts.map +1 -0
- package/dist/runtime-plugin-host/hot-reload.consumer.js +168 -0
- package/dist/runtime-plugin-host/hot-reload.consumer.js.map +1 -0
- package/dist/runtime-plugin-host/reclaim.impl.bun.d.ts +37 -0
- package/dist/runtime-plugin-host/reclaim.impl.bun.d.ts.map +1 -0
- package/dist/runtime-plugin-host/reclaim.impl.bun.js +159 -0
- package/dist/runtime-plugin-host/reclaim.impl.bun.js.map +1 -0
- package/dist/runtime-plugin-host/runtime-plugin-host.impl.bun.d.ts +4 -0
- package/dist/runtime-plugin-host/runtime-plugin-host.impl.bun.d.ts.map +1 -0
- package/dist/runtime-plugin-host/runtime-plugin-host.impl.bun.js +181 -0
- package/dist/runtime-plugin-host/runtime-plugin-host.impl.bun.js.map +1 -0
- package/dist/runtime-plugin-host/runtime-plugin-host.plugin.d.ts +17 -0
- package/dist/runtime-plugin-host/runtime-plugin-host.plugin.d.ts.map +1 -0
- package/dist/runtime-plugin-host/runtime-plugin-host.plugin.js +36 -0
- package/dist/runtime-plugin-host/runtime-plugin-host.plugin.js.map +1 -0
- package/dist/runtime-plugin-host/runtime-thread.impl.bun.d.ts +53 -0
- package/dist/runtime-plugin-host/runtime-thread.impl.bun.d.ts.map +1 -0
- package/dist/runtime-plugin-host/runtime-thread.impl.bun.js +249 -0
- package/dist/runtime-plugin-host/runtime-thread.impl.bun.js.map +1 -0
- package/dist/runtime-plugin-host/runtime-thread.shim.bun.d.ts +2 -0
- package/dist/runtime-plugin-host/runtime-thread.shim.bun.d.ts.map +1 -0
- package/dist/runtime-plugin-host/runtime-thread.shim.bun.js +56 -0
- package/dist/runtime-plugin-host/runtime-thread.shim.bun.js.map +1 -0
- package/dist/runtime-plugin-host/schemas.d.ts +437 -0
- package/dist/runtime-plugin-host/schemas.d.ts.map +1 -0
- package/dist/runtime-plugin-host/schemas.js +54 -0
- package/dist/runtime-plugin-host/schemas.js.map +1 -0
- package/dist/runtime-plugin-host/source-watcher.consumer.d.ts +109 -0
- package/dist/runtime-plugin-host/source-watcher.consumer.d.ts.map +1 -0
- package/dist/runtime-plugin-host/source-watcher.consumer.js +383 -0
- package/dist/runtime-plugin-host/source-watcher.consumer.js.map +1 -0
- package/dist/schemas/environment.d.ts +197 -0
- package/dist/schemas/environment.d.ts.map +1 -0
- package/dist/schemas/environment.js +7 -0
- package/dist/schemas/environment.js.map +1 -0
- package/dist/schemas/host-resources.d.ts +85 -0
- package/dist/schemas/host-resources.d.ts.map +1 -0
- package/dist/schemas/host-resources.js +22 -0
- package/dist/schemas/host-resources.js.map +1 -0
- package/dist/schemas/native-image.d.ts +128 -0
- package/dist/schemas/native-image.d.ts.map +1 -0
- package/dist/schemas/native-image.js +45 -0
- package/dist/schemas/native-image.js.map +1 -0
- package/dist/schemas/native-network.d.ts +56 -0
- package/dist/schemas/native-network.d.ts.map +1 -0
- package/dist/schemas/native-network.js +55 -0
- package/dist/schemas/native-network.js.map +1 -0
- package/dist/schemas/restricted-execute.d.ts +40 -0
- package/dist/schemas/restricted-execute.d.ts.map +1 -0
- package/dist/schemas/restricted-execute.js +14 -0
- package/dist/schemas/restricted-execute.js.map +1 -0
- package/dist/schemas/runtime-socket.d.ts +8 -0
- package/dist/schemas/runtime-socket.d.ts.map +1 -0
- package/dist/schemas/runtime-socket.js +7 -0
- package/dist/schemas/runtime-socket.js.map +1 -0
- package/dist/schemas/self-spawn.d.ts +11 -0
- package/dist/schemas/self-spawn.d.ts.map +1 -0
- package/dist/schemas/self-spawn.js +3 -0
- package/dist/schemas/self-spawn.js.map +1 -0
- package/dist/schemas/standard-output.d.ts +6 -0
- package/dist/schemas/standard-output.d.ts.map +1 -0
- package/dist/schemas/standard-output.js +2 -0
- package/dist/schemas/standard-output.js.map +1 -0
- package/dist/schemas/telemetry.d.ts +25 -0
- package/dist/schemas/telemetry.d.ts.map +1 -0
- package/dist/schemas/telemetry.js +10 -0
- package/dist/schemas/telemetry.js.map +1 -0
- package/dist/schemas/test-environment.d.ts +27 -0
- package/dist/schemas/test-environment.d.ts.map +1 -0
- package/dist/schemas/test-environment.js +2 -0
- package/dist/schemas/test-environment.js.map +1 -0
- package/dist/serve-stall-start.d.ts +8 -0
- package/dist/serve-stall-start.d.ts.map +1 -0
- package/dist/serve-stall-start.js +88 -0
- package/dist/serve-stall-start.js.map +1 -0
- package/dist/serve-stall.d.ts +11 -0
- package/dist/serve-stall.d.ts.map +1 -0
- package/dist/serve-stall.js +19 -0
- package/dist/serve-stall.js.map +1 -0
- package/dist/serve-stall.plugin.d.ts +10 -0
- package/dist/serve-stall.plugin.d.ts.map +1 -0
- package/dist/serve-stall.plugin.js +34 -0
- package/dist/serve-stall.plugin.js.map +1 -0
- package/dist/services/account-home.d.ts +39 -0
- package/dist/services/account-home.d.ts.map +1 -0
- package/dist/services/account-home.js +152 -0
- package/dist/services/account-home.js.map +1 -0
- package/dist/services/cli-process-host.d.ts +50 -0
- package/dist/services/cli-process-host.d.ts.map +1 -0
- package/dist/services/cli-process-host.js +88 -0
- package/dist/services/cli-process-host.js.map +1 -0
- package/dist/services/compatibility-host.impl.bun.d.ts +4 -0
- package/dist/services/compatibility-host.impl.bun.d.ts.map +1 -0
- package/dist/services/compatibility-host.impl.bun.js +24 -0
- package/dist/services/compatibility-host.impl.bun.js.map +1 -0
- package/dist/services/executable-identity.impl.bun.d.ts +164 -0
- package/dist/services/executable-identity.impl.bun.d.ts.map +1 -0
- package/dist/services/executable-identity.impl.bun.js +73 -0
- package/dist/services/executable-identity.impl.bun.js.map +1 -0
- package/dist/services/fatal-signals.impl.bun.d.ts +15 -0
- package/dist/services/fatal-signals.impl.bun.d.ts.map +1 -0
- package/dist/services/fatal-signals.impl.bun.js +61 -0
- package/dist/services/fatal-signals.impl.bun.js.map +1 -0
- package/dist/services/graph-freshness.impl.bun.d.ts +108 -0
- package/dist/services/graph-freshness.impl.bun.d.ts.map +1 -0
- package/dist/services/graph-freshness.impl.bun.js +49 -0
- package/dist/services/graph-freshness.impl.bun.js.map +1 -0
- package/dist/services/host-identity.capability.bun.d.ts +10 -0
- package/dist/services/host-identity.capability.bun.d.ts.map +1 -0
- package/dist/services/host-identity.capability.bun.js +27 -0
- package/dist/services/host-identity.capability.bun.js.map +1 -0
- package/dist/services/host-identity.impl.bun.d.ts +53 -0
- package/dist/services/host-identity.impl.bun.d.ts.map +1 -0
- package/dist/services/host-identity.impl.bun.js +76 -0
- package/dist/services/host-identity.impl.bun.js.map +1 -0
- package/dist/services/host-resources.impl.bun.d.ts +49 -0
- package/dist/services/host-resources.impl.bun.d.ts.map +1 -0
- package/dist/services/host-resources.impl.bun.js +144 -0
- package/dist/services/host-resources.impl.bun.js.map +1 -0
- package/dist/services/http-fetch.impl.bun.d.ts +10 -0
- package/dist/services/http-fetch.impl.bun.d.ts.map +1 -0
- package/dist/services/http-fetch.impl.bun.js +38 -0
- package/dist/services/http-fetch.impl.bun.js.map +1 -0
- package/dist/services/output-plane.impl.bun.d.ts +6 -0
- package/dist/services/output-plane.impl.bun.d.ts.map +1 -0
- package/dist/services/output-plane.impl.bun.js +26 -0
- package/dist/services/output-plane.impl.bun.js.map +1 -0
- package/dist/services/process-action-lifetime.consumer.d.ts +47 -0
- package/dist/services/process-action-lifetime.consumer.d.ts.map +1 -0
- package/dist/services/process-action-lifetime.consumer.js +68 -0
- package/dist/services/process-action-lifetime.consumer.js.map +1 -0
- package/dist/services/process-view.impl.bun.d.ts +18 -0
- package/dist/services/process-view.impl.bun.d.ts.map +1 -0
- package/dist/services/process-view.impl.bun.js +17 -0
- package/dist/services/process-view.impl.bun.js.map +1 -0
- package/dist/services/runtime-host-signals.impl.bun.d.ts +8 -0
- package/dist/services/runtime-host-signals.impl.bun.d.ts.map +1 -0
- package/dist/services/runtime-host-signals.impl.bun.js +29 -0
- package/dist/services/runtime-host-signals.impl.bun.js.map +1 -0
- package/dist/services/runtime-http-listener.impl.bun.d.ts +14 -0
- package/dist/services/runtime-http-listener.impl.bun.d.ts.map +1 -0
- package/dist/services/runtime-http-listener.impl.bun.js +463 -0
- package/dist/services/runtime-http-listener.impl.bun.js.map +1 -0
- package/dist/services/runtime-path.impl.bun.d.ts +16 -0
- package/dist/services/runtime-path.impl.bun.d.ts.map +1 -0
- package/dist/services/runtime-path.impl.bun.js +34 -0
- package/dist/services/runtime-path.impl.bun.js.map +1 -0
- package/dist/services/runtime-scoped-values.impl.bun.d.ts +4 -0
- package/dist/services/runtime-scoped-values.impl.bun.d.ts.map +1 -0
- package/dist/services/runtime-scoped-values.impl.bun.js +7 -0
- package/dist/services/runtime-scoped-values.impl.bun.js.map +1 -0
- package/dist/services/runtime-socket-datagram.impl.bun.d.ts +15 -0
- package/dist/services/runtime-socket-datagram.impl.bun.d.ts.map +1 -0
- package/dist/services/runtime-socket-datagram.impl.bun.js +19 -0
- package/dist/services/runtime-socket-datagram.impl.bun.js.map +1 -0
- package/dist/services/runtime-socket.impl.bun.d.ts +20 -0
- package/dist/services/runtime-socket.impl.bun.d.ts.map +1 -0
- package/dist/services/runtime-socket.impl.bun.js +47 -0
- package/dist/services/runtime-socket.impl.bun.js.map +1 -0
- package/dist/services/runtime-stdio.impl.bun.d.ts +11 -0
- package/dist/services/runtime-stdio.impl.bun.d.ts.map +1 -0
- package/dist/services/runtime-stdio.impl.bun.js +37 -0
- package/dist/services/runtime-stdio.impl.bun.js.map +1 -0
- package/dist/services/self-spawn.impl.bun.d.ts +39 -0
- package/dist/services/self-spawn.impl.bun.d.ts.map +1 -0
- package/dist/services/self-spawn.impl.bun.js +58 -0
- package/dist/services/self-spawn.impl.bun.js.map +1 -0
- package/dist/services/standard-output.d.ts +100 -0
- package/dist/services/standard-output.d.ts.map +1 -0
- package/dist/services/standard-output.js +35 -0
- package/dist/services/standard-output.js.map +1 -0
- package/dist/services/user-environment.impl.bun.d.ts +19 -0
- package/dist/services/user-environment.impl.bun.d.ts.map +1 -0
- package/dist/services/user-environment.impl.bun.js +117 -0
- package/dist/services/user-environment.impl.bun.js.map +1 -0
- package/dist/services/workspace-env.d.ts +30 -0
- package/dist/services/workspace-env.d.ts.map +1 -0
- package/dist/services/workspace-env.js +45 -0
- package/dist/services/workspace-env.js.map +1 -0
- package/dist/services/workspace-root-probe.impl.bun.d.ts +14 -0
- package/dist/services/workspace-root-probe.impl.bun.d.ts.map +1 -0
- package/dist/services/workspace-root-probe.impl.bun.js +27 -0
- package/dist/services/workspace-root-probe.impl.bun.js.map +1 -0
- package/dist/session-members.impl.bun.d.ts +22 -0
- package/dist/session-members.impl.bun.d.ts.map +1 -0
- package/dist/session-members.impl.bun.js +74 -0
- package/dist/session-members.impl.bun.js.map +1 -0
- package/dist/sqlite-driver/index.d.ts +7 -0
- package/dist/sqlite-driver/index.d.ts.map +1 -0
- package/dist/sqlite-driver/index.js +7 -0
- package/dist/sqlite-driver/index.js.map +1 -0
- package/dist/sqlite-driver/sqlite-driver.impl.bun.d.ts +6 -0
- package/dist/sqlite-driver/sqlite-driver.impl.bun.d.ts.map +1 -0
- package/dist/sqlite-driver/sqlite-driver.impl.bun.js +269 -0
- package/dist/sqlite-driver/sqlite-driver.impl.bun.js.map +1 -0
- package/dist/sqlite-driver/sqlite-driver.plugin.d.ts +22 -0
- package/dist/sqlite-driver/sqlite-driver.plugin.d.ts.map +1 -0
- package/dist/sqlite-driver/sqlite-driver.plugin.js +44 -0
- package/dist/sqlite-driver/sqlite-driver.plugin.js.map +1 -0
- package/dist/telemetry/telemetry.d.ts +34 -0
- package/dist/telemetry/telemetry.d.ts.map +1 -0
- package/dist/telemetry/telemetry.js +2 -0
- package/dist/telemetry/telemetry.js.map +1 -0
- package/dist/telemetry/telemetry.plugin.d.ts +4 -0
- package/dist/telemetry/telemetry.plugin.d.ts.map +1 -0
- package/dist/telemetry/telemetry.plugin.js +78 -0
- package/dist/telemetry/telemetry.plugin.js.map +1 -0
- package/dist/terminal-pty-bridge.impl.bun.d.ts +31 -0
- package/dist/terminal-pty-bridge.impl.bun.d.ts.map +1 -0
- package/dist/terminal-pty-bridge.impl.bun.js +333 -0
- package/dist/terminal-pty-bridge.impl.bun.js.map +1 -0
- package/dist/test-tooling/lazy-environment.impl.bun.d.ts +16 -0
- package/dist/test-tooling/lazy-environment.impl.bun.d.ts.map +1 -0
- package/dist/test-tooling/lazy-environment.impl.bun.js +36 -0
- package/dist/test-tooling/lazy-environment.impl.bun.js.map +1 -0
- package/dist/test-tooling/starttls-refusal.d.ts +7 -0
- package/dist/test-tooling/starttls-refusal.d.ts.map +1 -0
- package/dist/test-tooling/starttls-refusal.js +50 -0
- package/dist/test-tooling/starttls-refusal.js.map +1 -0
- package/dist/test-tooling/svelte-client-preload.impl.bun.d.ts +2 -0
- package/dist/test-tooling/svelte-client-preload.impl.bun.d.ts.map +1 -0
- package/dist/test-tooling/svelte-client-preload.impl.bun.js +4 -0
- package/dist/test-tooling/svelte-client-preload.impl.bun.js.map +1 -0
- package/dist/test-tooling/svelte-compiler.impl.bun.d.ts +10 -0
- package/dist/test-tooling/svelte-compiler.impl.bun.d.ts.map +1 -0
- package/dist/test-tooling/svelte-compiler.impl.bun.js +33 -0
- package/dist/test-tooling/svelte-compiler.impl.bun.js.map +1 -0
- package/dist/test-tooling/svelte-server-preload.impl.bun.d.ts +2 -0
- package/dist/test-tooling/svelte-server-preload.impl.bun.d.ts.map +1 -0
- package/dist/test-tooling/svelte-server-preload.impl.bun.js +4 -0
- package/dist/test-tooling/svelte-server-preload.impl.bun.js.map +1 -0
- package/dist/test-tooling/test-environment.impl.bun.d.ts +45 -0
- package/dist/test-tooling/test-environment.impl.bun.d.ts.map +1 -0
- package/dist/test-tooling/test-environment.impl.bun.js +163 -0
- package/dist/test-tooling/test-environment.impl.bun.js.map +1 -0
- package/dist/test-tooling/test-process-root.impl.bun.d.ts +4 -0
- package/dist/test-tooling/test-process-root.impl.bun.d.ts.map +1 -0
- package/dist/test-tooling/test-process-root.impl.bun.js +65 -0
- package/dist/test-tooling/test-process-root.impl.bun.js.map +1 -0
- package/dist/test-tooling/unix-http.impl.bun.d.ts +28 -0
- package/dist/test-tooling/unix-http.impl.bun.d.ts.map +1 -0
- package/dist/test-tooling/unix-http.impl.bun.js +181 -0
- package/dist/test-tooling/unix-http.impl.bun.js.map +1 -0
- package/dist/transpiler/transpiler.plugin.d.ts +10 -0
- package/dist/transpiler/transpiler.plugin.d.ts.map +1 -0
- package/dist/transpiler/transpiler.plugin.js +18 -0
- package/dist/transpiler/transpiler.plugin.js.map +1 -0
- package/native/held-launch/Cargo.toml +23 -0
- package/native/held-launch/abi-manifest.json +234 -0
- package/native/held-launch/src/bin/vibes-held-launch.rs +35 -0
- package/native/held-launch/src/events.rs +99 -0
- package/native/held-launch/src/lib.rs +528 -0
- package/native/held-launch/symbols.golden +21 -0
- package/package.json +313 -4
- package/resources/restricted-supervisor.impl.bun.d.mts +3 -0
- package/resources/restricted-supervisor.impl.bun.mjs +49 -0
- package/resources/serve-stall-watch.impl.bun.d.mts +3 -0
- 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
|