@nimbus-sh/worker 0.1.0
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/README.md +219 -0
- package/dist/_shared/bytes.d.ts +18 -0
- package/dist/_shared/bytes.d.ts.map +1 -0
- package/dist/_shared/bytes.js +17 -0
- package/dist/_shared/cache-stats.d.ts +146 -0
- package/dist/_shared/cache-stats.d.ts.map +1 -0
- package/dist/_shared/cache-stats.js +162 -0
- package/dist/_shared/exports-resolver.d.ts +76 -0
- package/dist/_shared/exports-resolver.d.ts.map +1 -0
- package/dist/_shared/exports-resolver.js +284 -0
- package/dist/_shared/install-phase.d.ts +47 -0
- package/dist/_shared/install-phase.d.ts.map +1 -0
- package/dist/_shared/install-phase.js +1 -0
- package/dist/_shared/real-node-imports.d.ts +38 -0
- package/dist/_shared/real-node-imports.d.ts.map +1 -0
- package/dist/_shared/real-node-imports.js +46 -0
- package/dist/_shared/retry.d.ts +93 -0
- package/dist/_shared/retry.d.ts.map +1 -0
- package/dist/_shared/retry.js +161 -0
- package/dist/_shared/session-id.d.ts +39 -0
- package/dist/_shared/session-id.d.ts.map +1 -0
- package/dist/_shared/session-id.js +127 -0
- package/dist/_shared/session-router.d.ts +104 -0
- package/dist/_shared/session-router.d.ts.map +1 -0
- package/dist/_shared/session-router.js +165 -0
- package/dist/_shared/w7-frame.d.ts +93 -0
- package/dist/_shared/w7-frame.d.ts.map +1 -0
- package/dist/_shared/w7-frame.js +402 -0
- package/dist/auth/index.d.ts +16 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +15 -0
- package/dist/auth/middleware.d.ts +85 -0
- package/dist/auth/middleware.d.ts.map +1 -0
- package/dist/auth/middleware.js +150 -0
- package/dist/auth/token.d.ts +96 -0
- package/dist/auth/token.d.ts.map +1 -0
- package/dist/auth/token.js +226 -0
- package/dist/auth/types.d.ts +141 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +114 -0
- package/dist/bindings/d1.d.ts +102 -0
- package/dist/bindings/d1.d.ts.map +1 -0
- package/dist/bindings/d1.js +549 -0
- package/dist/bindings/kv.d.ts +82 -0
- package/dist/bindings/kv.d.ts.map +1 -0
- package/dist/bindings/kv.js +290 -0
- package/dist/bindings/r2.d.ts +137 -0
- package/dist/bindings/r2.d.ts.map +1 -0
- package/dist/bindings/r2.js +379 -0
- package/dist/cirrus-npm-cjs.generated.d.ts +17 -0
- package/dist/cirrus-npm-cjs.generated.d.ts.map +1 -0
- package/dist/cirrus-npm-cjs.generated.js +41 -0
- package/dist/cirrus-plugin-react.generated.d.ts +34 -0
- package/dist/cirrus-plugin-react.generated.d.ts.map +1 -0
- package/dist/cirrus-plugin-react.generated.js +33 -0
- package/dist/constants.d.ts +34 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +116 -0
- package/dist/esbuild-wasm-bundle.generated.d.ts +41 -0
- package/dist/esbuild-wasm-bundle.generated.d.ts.map +1 -0
- package/dist/esbuild-wasm-bundle.generated.js +40 -0
- package/dist/facets/cirrus-real.d.ts +147 -0
- package/dist/facets/cirrus-real.d.ts.map +1 -0
- package/dist/facets/cirrus-real.js +981 -0
- package/dist/facets/inner-do-registry.d.ts +41 -0
- package/dist/facets/inner-do-registry.d.ts.map +1 -0
- package/dist/facets/inner-do-registry.js +51 -0
- package/dist/facets/manager.d.ts +314 -0
- package/dist/facets/manager.d.ts.map +1 -0
- package/dist/facets/manager.js +2681 -0
- package/dist/facets/process.d.ts +318 -0
- package/dist/facets/process.d.ts.map +1 -0
- package/dist/facets/process.js +567 -0
- package/dist/facets/real-vite-fs-shim.d.ts +151 -0
- package/dist/facets/real-vite-fs-shim.d.ts.map +1 -0
- package/dist/facets/real-vite-fs-shim.js +1279 -0
- package/dist/facets/real-vite-hmr.d.ts +142 -0
- package/dist/facets/real-vite-hmr.d.ts.map +1 -0
- package/dist/facets/real-vite-hmr.js +476 -0
- package/dist/facets/vite-dev-server.d.ts +293 -0
- package/dist/facets/vite-dev-server.d.ts.map +1 -0
- package/dist/facets/vite-dev-server.js +2580 -0
- package/dist/facets/wasm-swap-registry.d.ts +261 -0
- package/dist/facets/wasm-swap-registry.d.ts.map +1 -0
- package/dist/facets/wasm-swap-registry.js +551 -0
- package/dist/facets/ws-terminal.d.ts +107 -0
- package/dist/facets/ws-terminal.d.ts.map +1 -0
- package/dist/facets/ws-terminal.js +207 -0
- package/dist/git/commands.d.ts +13 -0
- package/dist/git/commands.d.ts.map +1 -0
- package/dist/git/commands.js +633 -0
- package/dist/git/network-facet.d.ts +61 -0
- package/dist/git/network-facet.d.ts.map +1 -0
- package/dist/git/network-facet.js +700 -0
- package/dist/git-bundle.generated.d.ts +16 -0
- package/dist/git-bundle.generated.d.ts.map +1 -0
- package/dist/git-bundle.generated.js +15 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +73 -0
- package/dist/loaders/child-process/spawn-facet.d.ts +90 -0
- package/dist/loaders/child-process/spawn-facet.d.ts.map +1 -0
- package/dist/loaders/child-process/spawn-facet.js +103 -0
- package/dist/loaders/child-process/spawn-pool.d.ts +110 -0
- package/dist/loaders/child-process/spawn-pool.d.ts.map +1 -0
- package/dist/loaders/child-process/spawn-pool.js +161 -0
- package/dist/loaders/fanout-pool.d.ts +195 -0
- package/dist/loaders/fanout-pool.d.ts.map +1 -0
- package/dist/loaders/fanout-pool.js +326 -0
- package/dist/loaders/generated-workers.d.ts +26 -0
- package/dist/loaders/generated-workers.d.ts.map +1 -0
- package/dist/loaders/generated-workers.js +25 -0
- package/dist/loaders/index.d.ts +15 -0
- package/dist/loaders/index.d.ts.map +1 -0
- package/dist/loaders/index.js +13 -0
- package/dist/loaders/loader-pool.d.ts +273 -0
- package/dist/loaders/loader-pool.d.ts.map +1 -0
- package/dist/loaders/loader-pool.js +624 -0
- package/dist/loaders/npm-resolve-preamble.d.ts +34 -0
- package/dist/loaders/npm-resolve-preamble.d.ts.map +1 -0
- package/dist/loaders/npm-resolve-preamble.js +237 -0
- package/dist/loaders/pre-bundle-preamble.d.ts +41 -0
- package/dist/loaders/pre-bundle-preamble.d.ts.map +1 -0
- package/dist/loaders/pre-bundle-preamble.js +114 -0
- package/dist/loaders/vendor/codegen.d.ts +24 -0
- package/dist/loaders/vendor/codegen.d.ts.map +1 -0
- package/dist/loaders/vendor/codegen.js +44 -0
- package/dist/loaders/vendor/errors.d.ts +24 -0
- package/dist/loaders/vendor/errors.d.ts.map +1 -0
- package/dist/loaders/vendor/errors.js +46 -0
- package/dist/loaders/vendor/index.d.ts +16 -0
- package/dist/loaders/vendor/index.d.ts.map +1 -0
- package/dist/loaders/vendor/index.js +11 -0
- package/dist/loaders/vendor/pool.d.ts +88 -0
- package/dist/loaders/vendor/pool.d.ts.map +1 -0
- package/dist/loaders/vendor/pool.js +353 -0
- package/dist/loaders/vendor/primitives.d.ts +11 -0
- package/dist/loaders/vendor/primitives.d.ts.map +1 -0
- package/dist/loaders/vendor/primitives.js +33 -0
- package/dist/loaders/vendor/serialize.d.ts +3 -0
- package/dist/loaders/vendor/serialize.d.ts.map +1 -0
- package/dist/loaders/vendor/serialize.js +25 -0
- package/dist/loaders/vendor/types.d.ts +60 -0
- package/dist/loaders/vendor/types.d.ts.map +1 -0
- package/dist/loaders/vendor/types.js +4 -0
- package/dist/npm/cache.d.ts +136 -0
- package/dist/npm/cache.d.ts.map +1 -0
- package/dist/npm/cache.js +429 -0
- package/dist/npm/install-batch-facet.d.ts +129 -0
- package/dist/npm/install-batch-facet.d.ts.map +1 -0
- package/dist/npm/install-batch-facet.js +598 -0
- package/dist/npm/install-facet.d.ts +29 -0
- package/dist/npm/install-facet.d.ts.map +1 -0
- package/dist/npm/install-facet.js +9 -0
- package/dist/npm/installer.d.ts +239 -0
- package/dist/npm/installer.d.ts.map +1 -0
- package/dist/npm/installer.js +2022 -0
- package/dist/npm/npx-install.d.ts +74 -0
- package/dist/npm/npx-install.d.ts.map +1 -0
- package/dist/npm/npx-install.js +302 -0
- package/dist/npm/pre-bundle-facet.d.ts +168 -0
- package/dist/npm/pre-bundle-facet.d.ts.map +1 -0
- package/dist/npm/pre-bundle-facet.js +653 -0
- package/dist/npm/r2-cache.d.ts +286 -0
- package/dist/npm/r2-cache.d.ts.map +1 -0
- package/dist/npm/r2-cache.js +506 -0
- package/dist/npm/resolve-facet.d.ts +202 -0
- package/dist/npm/resolve-facet.d.ts.map +1 -0
- package/dist/npm/resolve-facet.js +833 -0
- package/dist/npm/resolve-one-facet.d.ts +204 -0
- package/dist/npm/resolve-one-facet.d.ts.map +1 -0
- package/dist/npm/resolve-one-facet.js +437 -0
- package/dist/npm/resolver.d.ts +109 -0
- package/dist/npm/resolver.d.ts.map +1 -0
- package/dist/npm/resolver.js +899 -0
- package/dist/npm/tarball-stream.d.ts +85 -0
- package/dist/npm/tarball-stream.d.ts.map +1 -0
- package/dist/npm/tarball-stream.js +205 -0
- package/dist/npm/tarball.d.ts +51 -0
- package/dist/npm/tarball.d.ts.map +1 -0
- package/dist/npm/tarball.js +185 -0
- package/dist/observability/diag-counters.d.ts +292 -0
- package/dist/observability/diag-counters.d.ts.map +1 -0
- package/dist/observability/diag-counters.js +302 -0
- package/dist/observability/heap-estimate.d.ts +166 -0
- package/dist/observability/heap-estimate.d.ts.map +1 -0
- package/dist/observability/heap-estimate.js +192 -0
- package/dist/observability/heavy-alloc-coord.d.ts +95 -0
- package/dist/observability/heavy-alloc-coord.d.ts.map +1 -0
- package/dist/observability/heavy-alloc-coord.js +149 -0
- package/dist/observability/oom-classify.d.ts +56 -0
- package/dist/observability/oom-classify.d.ts.map +1 -0
- package/dist/observability/oom-classify.js +118 -0
- package/dist/observability/oom-discriminator.d.ts +192 -0
- package/dist/observability/oom-discriminator.d.ts.map +1 -0
- package/dist/observability/oom-discriminator.js +233 -0
- package/dist/real-vite-bundle.generated.d.ts +46 -0
- package/dist/real-vite-bundle.generated.d.ts.map +1 -0
- package/dist/real-vite-bundle.generated.js +53 -0
- package/dist/replica/routing.d.ts +171 -0
- package/dist/replica/routing.d.ts.map +1 -0
- package/dist/replica/routing.js +288 -0
- package/dist/replica/suspension.d.ts +36 -0
- package/dist/replica/suspension.d.ts.map +1 -0
- package/dist/replica/suspension.js +49 -0
- package/dist/router/index.d.ts +156 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +220 -0
- package/dist/runtime/assets-loader.d.ts +71 -0
- package/dist/runtime/assets-loader.d.ts.map +1 -0
- package/dist/runtime/assets-loader.js +128 -0
- package/dist/runtime/barrel-detect.d.ts +46 -0
- package/dist/runtime/barrel-detect.d.ts.map +1 -0
- package/dist/runtime/barrel-detect.js +73 -0
- package/dist/runtime/barrel-synthesizer.d.ts +181 -0
- package/dist/runtime/barrel-synthesizer.d.ts.map +1 -0
- package/dist/runtime/barrel-synthesizer.js +541 -0
- package/dist/runtime/bun-repl.d.ts +46 -0
- package/dist/runtime/bun-repl.d.ts.map +1 -0
- package/dist/runtime/bun-repl.js +326 -0
- package/dist/runtime/bun-runner.d.ts +66 -0
- package/dist/runtime/bun-runner.d.ts.map +1 -0
- package/dist/runtime/bun-runner.js +219 -0
- package/dist/runtime/clang-runner.d.ts +38 -0
- package/dist/runtime/clang-runner.d.ts.map +1 -0
- package/dist/runtime/clang-runner.js +1033 -0
- package/dist/runtime/comment-strip.d.ts +37 -0
- package/dist/runtime/comment-strip.d.ts.map +1 -0
- package/dist/runtime/comment-strip.js +74 -0
- package/dist/runtime/esbuild-service.d.ts +201 -0
- package/dist/runtime/esbuild-service.d.ts.map +1 -0
- package/dist/runtime/esbuild-service.js +1444 -0
- package/dist/runtime/esbuild-wasm-bytes.d.ts +87 -0
- package/dist/runtime/esbuild-wasm-bytes.d.ts.map +1 -0
- package/dist/runtime/esbuild-wasm-bytes.js +131 -0
- package/dist/runtime/framework-detect.d.ts +71 -0
- package/dist/runtime/framework-detect.d.ts.map +1 -0
- package/dist/runtime/framework-detect.js +178 -0
- package/dist/runtime/long-running-handle.d.ts +133 -0
- package/dist/runtime/long-running-handle.d.ts.map +1 -0
- package/dist/runtime/long-running-handle.js +192 -0
- package/dist/runtime/node-repl.d.ts +36 -0
- package/dist/runtime/node-repl.d.ts.map +1 -0
- package/dist/runtime/node-repl.js +293 -0
- package/dist/runtime/node-runner.d.ts +111 -0
- package/dist/runtime/node-runner.d.ts.map +1 -0
- package/dist/runtime/node-runner.js +194 -0
- package/dist/runtime/node-shims.d.ts +24 -0
- package/dist/runtime/node-shims.d.ts.map +1 -0
- package/dist/runtime/node-shims.js +3019 -0
- package/dist/runtime/package-manager.d.ts +118 -0
- package/dist/runtime/package-manager.d.ts.map +1 -0
- package/dist/runtime/package-manager.js +420 -0
- package/dist/runtime/port-registry.d.ts +80 -0
- package/dist/runtime/port-registry.d.ts.map +1 -0
- package/dist/runtime/port-registry.js +166 -0
- package/dist/runtime/process-logs-api.d.ts +102 -0
- package/dist/runtime/process-logs-api.d.ts.map +1 -0
- package/dist/runtime/process-logs-api.js +253 -0
- package/dist/runtime/process-logs.d.ts +311 -0
- package/dist/runtime/process-logs.d.ts.map +1 -0
- package/dist/runtime/process-logs.js +656 -0
- package/dist/runtime/process-table.d.ts +65 -0
- package/dist/runtime/process-table.d.ts.map +1 -0
- package/dist/runtime/process-table.js +107 -0
- package/dist/runtime/project-detect.d.ts +21 -0
- package/dist/runtime/project-detect.d.ts.map +1 -0
- package/dist/runtime/project-detect.js +46 -0
- package/dist/runtime/python-repl.d.ts +66 -0
- package/dist/runtime/python-repl.d.ts.map +1 -0
- package/dist/runtime/python-repl.js +563 -0
- package/dist/runtime/python-runner.d.ts +50 -0
- package/dist/runtime/python-runner.d.ts.map +1 -0
- package/dist/runtime/python-runner.js +870 -0
- package/dist/runtime/repl-session.d.ts +160 -0
- package/dist/runtime/repl-session.d.ts.map +1 -0
- package/dist/runtime/repl-session.js +393 -0
- package/dist/runtime/require-resolver.d.ts +52 -0
- package/dist/runtime/require-resolver.d.ts.map +1 -0
- package/dist/runtime/require-resolver.js +690 -0
- package/dist/runtime/router-basename.d.ts +36 -0
- package/dist/runtime/router-basename.d.ts.map +1 -0
- package/dist/runtime/router-basename.js +310 -0
- package/dist/runtime/ruby-repl.d.ts +43 -0
- package/dist/runtime/ruby-repl.d.ts.map +1 -0
- package/dist/runtime/ruby-repl.js +229 -0
- package/dist/runtime/ruby-runner.d.ts +62 -0
- package/dist/runtime/ruby-runner.d.ts.map +1 -0
- package/dist/runtime/ruby-runner.js +737 -0
- package/dist/runtime/runtime-catalog.d.ts +99 -0
- package/dist/runtime/runtime-catalog.d.ts.map +1 -0
- package/dist/runtime/runtime-catalog.js +183 -0
- package/dist/runtime/runtime-registry.d.ts +136 -0
- package/dist/runtime/runtime-registry.d.ts.map +1 -0
- package/dist/runtime/runtime-registry.js +318 -0
- package/dist/runtime/streams.d.ts +13 -0
- package/dist/runtime/streams.d.ts.map +1 -0
- package/dist/runtime/streams.js +402 -0
- package/dist/runtime/wasi-instance.d.ts +190 -0
- package/dist/runtime/wasi-instance.d.ts.map +1 -0
- package/dist/runtime/wasi-instance.js +2044 -0
- package/dist/runtime/wasm-runner.d.ts +117 -0
- package/dist/runtime/wasm-runner.d.ts.map +1 -0
- package/dist/runtime/wasm-runner.js +705 -0
- package/dist/session/bindings.d.ts +168 -0
- package/dist/session/bindings.d.ts.map +1 -0
- package/dist/session/bindings.js +524 -0
- package/dist/session/ctx-exports.d.ts +16 -0
- package/dist/session/ctx-exports.d.ts.map +1 -0
- package/dist/session/ctx-exports.js +22 -0
- package/dist/session/diag.d.ts +62 -0
- package/dist/session/diag.d.ts.map +1 -0
- package/dist/session/diag.js +118 -0
- package/dist/session/fs-watch.d.ts +132 -0
- package/dist/session/fs-watch.d.ts.map +1 -0
- package/dist/session/fs-watch.js +255 -0
- package/dist/session/helpers.d.ts +150 -0
- package/dist/session/helpers.d.ts.map +1 -0
- package/dist/session/helpers.js +472 -0
- package/dist/session/hibernation.d.ts +145 -0
- package/dist/session/hibernation.d.ts.map +1 -0
- package/dist/session/hibernation.js +385 -0
- package/dist/session/init-phases.d.ts +87 -0
- package/dist/session/init-phases.d.ts.map +1 -0
- package/dist/session/init-phases.js +137 -0
- package/dist/session/init.d.ts +46 -0
- package/dist/session/init.d.ts.map +1 -0
- package/dist/session/init.js +3579 -0
- package/dist/session/keys.d.ts +56 -0
- package/dist/session/keys.d.ts.map +1 -0
- package/dist/session/keys.js +55 -0
- package/dist/session/nimbus-session.d.ts +434 -0
- package/dist/session/nimbus-session.d.ts.map +1 -0
- package/dist/session/nimbus-session.js +1084 -0
- package/dist/session/programmatic.d.ts +105 -0
- package/dist/session/programmatic.d.ts.map +1 -0
- package/dist/session/programmatic.js +326 -0
- package/dist/session/replica-routes.d.ts +68 -0
- package/dist/session/replica-routes.d.ts.map +1 -0
- package/dist/session/replica-routes.js +77 -0
- package/dist/session/routes.d.ts +29 -0
- package/dist/session/routes.d.ts.map +1 -0
- package/dist/session/routes.js +1331 -0
- package/dist/session/rpc.d.ts +323 -0
- package/dist/session/rpc.d.ts.map +1 -0
- package/dist/session/rpc.js +808 -0
- package/dist/session/state-store.d.ts +210 -0
- package/dist/session/state-store.d.ts.map +1 -0
- package/dist/session/state-store.js +459 -0
- package/dist/session/supervisor-rpc.d.ts +269 -0
- package/dist/session/supervisor-rpc.d.ts.map +1 -0
- package/dist/session/supervisor-rpc.js +437 -0
- package/dist/session/ws-hibernation-config.d.ts +64 -0
- package/dist/session/ws-hibernation-config.d.ts.map +1 -0
- package/dist/session/ws-hibernation-config.js +89 -0
- package/dist/session/ws.d.ts +95 -0
- package/dist/session/ws.d.ts.map +1 -0
- package/dist/session/ws.js +395 -0
- package/dist/shell/features.d.ts +410 -0
- package/dist/shell/features.d.ts.map +1 -0
- package/dist/shell/features.js +1885 -0
- package/dist/shell/unix-commands.d.ts +15 -0
- package/dist/shell/unix-commands.d.ts.map +1 -0
- package/dist/shell/unix-commands.js +3703 -0
- package/dist/stubs/lifo-ui.d.ts +10 -0
- package/dist/stubs/lifo-ui.d.ts.map +1 -0
- package/dist/stubs/lifo-ui.js +1 -0
- package/dist/tailwind-play.generated.d.ts +19 -0
- package/dist/tailwind-play.generated.d.ts.map +1 -0
- package/dist/tailwind-play.generated.js +18 -0
- package/dist/vfs/dev-provider.d.ts +64 -0
- package/dist/vfs/dev-provider.d.ts.map +1 -0
- package/dist/vfs/dev-provider.js +191 -0
- package/dist/vfs/events.d.ts +51 -0
- package/dist/vfs/events.d.ts.map +1 -0
- package/dist/vfs/events.js +127 -0
- package/dist/vfs/path.d.ts +30 -0
- package/dist/vfs/path.d.ts.map +1 -0
- package/dist/vfs/path.js +41 -0
- package/dist/vfs/seed-project.d.ts +62 -0
- package/dist/vfs/seed-project.d.ts.map +1 -0
- package/dist/vfs/seed-project.js +1045 -0
- package/dist/vfs/sqlite-vfs.d.ts +435 -0
- package/dist/vfs/sqlite-vfs.d.ts.map +1 -0
- package/dist/vfs/sqlite-vfs.js +1670 -0
- package/dist/vfs/symlink-registry.d.ts +64 -0
- package/dist/vfs/symlink-registry.d.ts.map +1 -0
- package/dist/vfs/symlink-registry.js +137 -0
- package/dist/wrangler/nimbus-wrangler.d.ts +157 -0
- package/dist/wrangler/nimbus-wrangler.d.ts.map +1 -0
- package/dist/wrangler/nimbus-wrangler.js +931 -0
- package/package.json +77 -0
- package/public/_assets/cirrus-plugin-react.bundle.js +70740 -0
- package/public/_assets/esbuild-0.24.2.wasm +0 -0
- package/public/_assets/real-vite-bundle.js +101478 -0
- package/public/_assets/rollup.wasm +0 -0
- package/public/favicon.svg +8 -0
- package/public/index.html +565 -0
- package/public/s/index.html +2379 -0
- package/scripts/bundle-esbuild-wasm.mjs +244 -0
- package/scripts/bundle-facet-workers.mjs +137 -0
- package/scripts/bundle-git.mjs +118 -0
- package/scripts/bundle-npm-cjs.mjs +363 -0
- package/scripts/bundle-plugin-react.mjs +480 -0
- package/scripts/bundle-real-vite.mjs +959 -0
- package/scripts/bundle-runtime.mjs +600 -0
- package/scripts/bundle-tailwind-play.mjs +130 -0
- package/scripts/patch-lifo-ui.mjs +131 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* session/programmatic.ts - public sandbox RPC helpers.
|
|
3
|
+
*
|
|
4
|
+
* These helpers are called by NimbusSession one-line delegators so the
|
|
5
|
+
* Durable Object exposes a typed, programmatic sandbox surface without
|
|
6
|
+
* duplicating the interactive terminal boot path.
|
|
7
|
+
*/
|
|
8
|
+
type Host = any;
|
|
9
|
+
export interface ProgrammaticReadyOptions {
|
|
10
|
+
preinstall?: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface ProgrammaticExecOptions extends ProgrammaticReadyOptions {
|
|
13
|
+
cwd?: string;
|
|
14
|
+
env?: Record<string, string>;
|
|
15
|
+
timeoutMs?: number;
|
|
16
|
+
stdin?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface ProgrammaticExecResult {
|
|
19
|
+
command: string;
|
|
20
|
+
exitCode: number;
|
|
21
|
+
success: boolean;
|
|
22
|
+
stdout: string;
|
|
23
|
+
stderr: string;
|
|
24
|
+
duration: number;
|
|
25
|
+
timestamp: number;
|
|
26
|
+
}
|
|
27
|
+
export interface ProgrammaticStartResult extends ProgrammaticExecResult {
|
|
28
|
+
pid: number | null;
|
|
29
|
+
process: SerializedProcess | null;
|
|
30
|
+
ports: SerializedPort[];
|
|
31
|
+
}
|
|
32
|
+
export interface SerializedProcess {
|
|
33
|
+
pid: number;
|
|
34
|
+
command: string;
|
|
35
|
+
argv: string[];
|
|
36
|
+
cwd: string;
|
|
37
|
+
state: string;
|
|
38
|
+
exitCode: number | null;
|
|
39
|
+
startTime: number;
|
|
40
|
+
endTime: number | null;
|
|
41
|
+
longRunning: boolean;
|
|
42
|
+
}
|
|
43
|
+
export interface SerializedPort {
|
|
44
|
+
port: number;
|
|
45
|
+
pid: number;
|
|
46
|
+
registeredAt: number;
|
|
47
|
+
}
|
|
48
|
+
export declare function ensureProgrammaticReady(self: Host, options?: ProgrammaticReadyOptions): Promise<{
|
|
49
|
+
ok: true;
|
|
50
|
+
preinstalled: string[];
|
|
51
|
+
}>;
|
|
52
|
+
export declare function rpcExec(self: Host, command: string, options?: ProgrammaticExecOptions): Promise<ProgrammaticExecResult>;
|
|
53
|
+
export declare function rpcStartProcess(self: Host, command: string, options?: ProgrammaticExecOptions): Promise<ProgrammaticStartResult>;
|
|
54
|
+
export declare function rpcRunCode(self: Host, code: string, options?: ProgrammaticExecOptions & {
|
|
55
|
+
language?: 'javascript' | 'typescript' | 'python' | 'ruby' | 'shell';
|
|
56
|
+
install?: 'never' | 'ifMissing';
|
|
57
|
+
}): Promise<ProgrammaticExecResult>;
|
|
58
|
+
export declare function rpcInstallRuntime(self: Host, spec: string, options?: {
|
|
59
|
+
force?: boolean;
|
|
60
|
+
}): Promise<import("../runtime/package-manager.js").RuntimeInstallSummary>;
|
|
61
|
+
export declare function rpcEnsureRuntimes(self: Host, specs: string[], options?: {
|
|
62
|
+
force?: boolean;
|
|
63
|
+
}): Promise<import("../runtime/package-manager.js").RuntimeInstallSummary[]>;
|
|
64
|
+
export declare function rpcListRuntimes(self: Host): Promise<{
|
|
65
|
+
installed: import("../runtime/package-manager.js").RuntimeSummary[];
|
|
66
|
+
available: {
|
|
67
|
+
name: string;
|
|
68
|
+
defaultVersion: string;
|
|
69
|
+
versions: Array<{
|
|
70
|
+
version: string;
|
|
71
|
+
sizeBytes: number;
|
|
72
|
+
license: string;
|
|
73
|
+
}>;
|
|
74
|
+
}[];
|
|
75
|
+
}>;
|
|
76
|
+
export declare function rpcListProcesses(self: Host): Promise<SerializedProcess[]>;
|
|
77
|
+
export declare function rpcKillProcess(self: Host, pid: number): Promise<{
|
|
78
|
+
ok: boolean;
|
|
79
|
+
pid: number;
|
|
80
|
+
}>;
|
|
81
|
+
export declare function rpcProcessLogs(self: Host, pid: number, options?: {
|
|
82
|
+
lines?: number;
|
|
83
|
+
bytes?: number;
|
|
84
|
+
}): Promise<{
|
|
85
|
+
pid: number;
|
|
86
|
+
chunks: any;
|
|
87
|
+
text: any;
|
|
88
|
+
exit: any;
|
|
89
|
+
}>;
|
|
90
|
+
export declare function rpcListPorts(self: Host): Promise<SerializedPort[]>;
|
|
91
|
+
export declare function rpcExposePort(self: Host, port: number): Promise<{
|
|
92
|
+
port: number;
|
|
93
|
+
listening: boolean;
|
|
94
|
+
pid: any;
|
|
95
|
+
registeredAt: any;
|
|
96
|
+
}>;
|
|
97
|
+
export declare function rpcUnexposePort(self: Host, port: number): Promise<{
|
|
98
|
+
port: number;
|
|
99
|
+
ok: any;
|
|
100
|
+
}>;
|
|
101
|
+
export declare function rpcDeleteFile(self: Host, path: string, options?: {
|
|
102
|
+
recursive?: boolean;
|
|
103
|
+
}): Promise<void>;
|
|
104
|
+
export {};
|
|
105
|
+
//# sourceMappingURL=programmatic.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"programmatic.d.ts","sourceRoot":"","sources":["../../src/session/programmatic.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAUH,KAAK,IAAI,GAAG,GAAG,CAAC;AAEhB,MAAM,WAAW,wBAAwB;IACvC,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;CACvB;AAED,MAAM,WAAW,uBAAwB,SAAQ,wBAAwB;IACvE,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,uBAAwB,SAAQ,sBAAsB;IACrE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAAC;IAClC,KAAK,EAAE,cAAc,EAAE,CAAC;CACzB;AAED,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;CACtB;AAkDD,wBAAsB,uBAAuB,CAC3C,IAAI,EAAE,IAAI,EACV,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAwB/C;AAED,wBAAsB,OAAO,CAC3B,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,sBAAsB,CAAC,CAyDjC;AAqBD,wBAAsB,eAAe,CACnC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,EACf,OAAO,GAAE,uBAA4B,GACpC,OAAO,CAAC,uBAAuB,CAAC,CAgBlC;AAED,wBAAsB,UAAU,CAC9B,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,uBAAuB,GAAG;IACjC,QAAQ,CAAC,EAAE,YAAY,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IACrE,OAAO,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;CAC5B,GACL,OAAO,CAAC,sBAAsB,CAAC,CAcjC;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,0EAIlC;AAED,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,MAAM,EAAE,EACf,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,OAAO,CAAA;CAAO,4EAQlC;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,IAAI;;;;;;;;;;;GAM/C;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAG/E;AAED,wBAAsB,cAAc,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CA0BnG;AAED,wBAAsB,cAAc,CAClC,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO;;;;;GAUjD;AAED,wBAAsB,YAAY,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAGxE;AAED,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM;;;;;GAU3D;AAED,wBAAsB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM;;;GAI7D;AAED,wBAAsB,aAAa,CACjC,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,GACpC,OAAO,CAAC,IAAI,CAAC,CAaf"}
|
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* session/programmatic.ts - public sandbox RPC helpers.
|
|
3
|
+
*
|
|
4
|
+
* These helpers are called by NimbusSession one-line delegators so the
|
|
5
|
+
* Durable Object exposes a typed, programmatic sandbox surface without
|
|
6
|
+
* duplicating the interactive terminal boot path.
|
|
7
|
+
*/
|
|
8
|
+
import { ensureRuntimesProgrammatic, installRuntimeProgrammatic, listAvailableRuntimes, listInstalledRuntimes, } from '../runtime/package-manager.js';
|
|
9
|
+
function makeHeadlessWebSocket() {
|
|
10
|
+
const listeners = new Map();
|
|
11
|
+
const ws = {
|
|
12
|
+
readyState: 1,
|
|
13
|
+
send(_data) { },
|
|
14
|
+
close() {
|
|
15
|
+
ws.readyState = 3;
|
|
16
|
+
for (const cb of listeners.get('close') ?? []) {
|
|
17
|
+
try {
|
|
18
|
+
cb();
|
|
19
|
+
}
|
|
20
|
+
catch { }
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
accept() { },
|
|
24
|
+
addEventListener(type, cb) {
|
|
25
|
+
const set = listeners.get(type) ?? new Set();
|
|
26
|
+
set.add(cb);
|
|
27
|
+
listeners.set(type, set);
|
|
28
|
+
},
|
|
29
|
+
removeEventListener(type, cb) {
|
|
30
|
+
listeners.get(type)?.delete(cb);
|
|
31
|
+
},
|
|
32
|
+
serializeAttachment(_value) { },
|
|
33
|
+
deserializeAttachment() { return { kind: 'programmatic' }; },
|
|
34
|
+
};
|
|
35
|
+
return ws;
|
|
36
|
+
}
|
|
37
|
+
function getHome(self) {
|
|
38
|
+
try {
|
|
39
|
+
const envHome = self.shell?.env?.HOME;
|
|
40
|
+
if (envHome)
|
|
41
|
+
return String(envHome);
|
|
42
|
+
}
|
|
43
|
+
catch { }
|
|
44
|
+
try {
|
|
45
|
+
const shellEnv = self.shell?.getEnv?.();
|
|
46
|
+
if (shellEnv?.HOME)
|
|
47
|
+
return String(shellEnv.HOME);
|
|
48
|
+
}
|
|
49
|
+
catch { }
|
|
50
|
+
return '/home/user';
|
|
51
|
+
}
|
|
52
|
+
function runtimeDeps(self) {
|
|
53
|
+
self.ensureSqliteFs();
|
|
54
|
+
return {
|
|
55
|
+
env: self.env,
|
|
56
|
+
vfs: self.sqliteFs,
|
|
57
|
+
registry: self._cpRegistry,
|
|
58
|
+
getHome: () => getHome(self),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export async function ensureProgrammaticReady(self, options = {}) {
|
|
62
|
+
if (!self.shell) {
|
|
63
|
+
self.initSession(makeHeadlessWebSocket());
|
|
64
|
+
// Programmatic boot owns no real terminal socket. Mark the session
|
|
65
|
+
// drained so a later browser /ws can warm-join instead of 409ing.
|
|
66
|
+
self._b4Phase = 'drained';
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
self.ensureSqliteFs();
|
|
70
|
+
self.ensureFacetManager();
|
|
71
|
+
}
|
|
72
|
+
const preinstall = Array.from(new Set(options.preinstall ?? []))
|
|
73
|
+
.map((s) => String(s).trim())
|
|
74
|
+
.filter(Boolean);
|
|
75
|
+
if (preinstall.length > 0) {
|
|
76
|
+
const results = await ensureRuntimesProgrammatic(runtimeDeps(self), preinstall);
|
|
77
|
+
const failed = results.filter((r) => r.exitCode !== 0);
|
|
78
|
+
if (failed.length > 0) {
|
|
79
|
+
const details = failed.map((r) => `${r.spec}: ${r.stderr || r.stdout}`).join('\n');
|
|
80
|
+
throw new Error(`runtime preinstall failed:\n${details}`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return { ok: true, preinstalled: preinstall };
|
|
84
|
+
}
|
|
85
|
+
export async function rpcExec(self, command, options = {}) {
|
|
86
|
+
await ensureProgrammaticReady(self, options);
|
|
87
|
+
const shell = self.shell;
|
|
88
|
+
if (!shell)
|
|
89
|
+
throw new Error('Nimbus shell did not initialize');
|
|
90
|
+
const stdout = [];
|
|
91
|
+
const stderr = [];
|
|
92
|
+
const started = Date.now();
|
|
93
|
+
const beforePids = new Set(self.processTable.getAll().map((p) => p.pid));
|
|
94
|
+
const controller = new AbortController();
|
|
95
|
+
let timeout = null;
|
|
96
|
+
let timedOut = false;
|
|
97
|
+
const run = shell.execute(String(command), {
|
|
98
|
+
cwd: options.cwd ?? shell.getCwd?.() ?? '/home/user',
|
|
99
|
+
env: { ...(shell.getEnv?.() ?? {}), ...(options.env ?? {}) },
|
|
100
|
+
onStdout: (d) => stdout.push(String(d)),
|
|
101
|
+
onStderr: (d) => stderr.push(String(d)),
|
|
102
|
+
signal: controller.signal,
|
|
103
|
+
stdin: options.stdin,
|
|
104
|
+
});
|
|
105
|
+
const result = await (options.timeoutMs && options.timeoutMs > 0
|
|
106
|
+
? Promise.race([
|
|
107
|
+
run,
|
|
108
|
+
new Promise((resolve) => {
|
|
109
|
+
timeout = setTimeout(() => {
|
|
110
|
+
timedOut = true;
|
|
111
|
+
try {
|
|
112
|
+
controller.abort();
|
|
113
|
+
}
|
|
114
|
+
catch { }
|
|
115
|
+
resolve({ exitCode: 124 });
|
|
116
|
+
}, options.timeoutMs);
|
|
117
|
+
}),
|
|
118
|
+
])
|
|
119
|
+
: run);
|
|
120
|
+
if (timeout)
|
|
121
|
+
clearTimeout(timeout);
|
|
122
|
+
const exitCode = Number(result?.exitCode ?? (timedOut ? 124 : 0));
|
|
123
|
+
if (timedOut) {
|
|
124
|
+
stderr.push(`command timed out after ${options.timeoutMs}ms\n`);
|
|
125
|
+
}
|
|
126
|
+
const logged = collectNewProcessOutput(self, beforePids);
|
|
127
|
+
if (stdout.length === 0 && logged.stdout)
|
|
128
|
+
stdout.push(logged.stdout);
|
|
129
|
+
if (stderr.length === 0 && logged.stderr)
|
|
130
|
+
stderr.push(logged.stderr);
|
|
131
|
+
return {
|
|
132
|
+
command: String(command),
|
|
133
|
+
exitCode,
|
|
134
|
+
success: exitCode === 0,
|
|
135
|
+
stdout: stdout.join(''),
|
|
136
|
+
stderr: stderr.join(''),
|
|
137
|
+
duration: Date.now() - started,
|
|
138
|
+
timestamp: Date.now(),
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
function collectNewProcessOutput(self, beforePids) {
|
|
142
|
+
const created = self.processTable.getAll()
|
|
143
|
+
.filter((p) => !beforePids.has(p.pid))
|
|
144
|
+
.sort((a, b) => a.startTime - b.startTime);
|
|
145
|
+
const stdout = [];
|
|
146
|
+
const stderr = [];
|
|
147
|
+
for (const entry of created) {
|
|
148
|
+
const chunks = self.processLogs.all(Number(entry.pid));
|
|
149
|
+
for (const chunk of chunks) {
|
|
150
|
+
if (chunk.stream === 'stderr')
|
|
151
|
+
stderr.push(String(chunk.data));
|
|
152
|
+
else
|
|
153
|
+
stdout.push(String(chunk.data));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return { stdout: stdout.join(''), stderr: stderr.join('') };
|
|
157
|
+
}
|
|
158
|
+
export async function rpcStartProcess(self, command, options = {}) {
|
|
159
|
+
await ensureProgrammaticReady(self, options);
|
|
160
|
+
const before = new Set(self.processTable.getAll().map((p) => p.pid));
|
|
161
|
+
const result = await rpcExec(self, command, options);
|
|
162
|
+
const created = self.processTable.getAll()
|
|
163
|
+
.filter((p) => !before.has(p.pid))
|
|
164
|
+
.sort((a, b) => b.startTime - a.startTime);
|
|
165
|
+
const running = created.find((p) => p.state === 'running') ?? null;
|
|
166
|
+
const pid = running?.pid ?? created[0]?.pid ?? null;
|
|
167
|
+
const process = pid != null ? serializeProcess(self.processTable.get(pid)) : null;
|
|
168
|
+
const ports = pid != null
|
|
169
|
+
? self.portRegistry.getAll().filter((p) => p.pid === pid).map(serializePort)
|
|
170
|
+
: [];
|
|
171
|
+
return { ...result, pid, process, ports };
|
|
172
|
+
}
|
|
173
|
+
export async function rpcRunCode(self, code, options = {}) {
|
|
174
|
+
const language = options.language ?? 'javascript';
|
|
175
|
+
if (language === 'python' && options.install === 'ifMissing') {
|
|
176
|
+
await ensureProgrammaticReady(self, { ...options, preinstall: ['python'] });
|
|
177
|
+
}
|
|
178
|
+
else if (language === 'ruby' && options.install === 'ifMissing') {
|
|
179
|
+
await ensureProgrammaticReady(self, { ...options, preinstall: ['ruby'] });
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
await ensureProgrammaticReady(self, options);
|
|
183
|
+
}
|
|
184
|
+
if (language === 'shell')
|
|
185
|
+
return rpcExec(self, code, options);
|
|
186
|
+
if (language === 'python')
|
|
187
|
+
return rpcExec(self, `python -c ${shellQuote(code)}`, options);
|
|
188
|
+
if (language === 'ruby')
|
|
189
|
+
return rpcExec(self, `ruby -e ${shellQuote(code)}`, options);
|
|
190
|
+
return rpcExec(self, `node -e ${shellQuote(code)}`, options);
|
|
191
|
+
}
|
|
192
|
+
export async function rpcInstallRuntime(self, spec, options = {}) {
|
|
193
|
+
await ensureProgrammaticReady(self);
|
|
194
|
+
return installRuntimeProgrammatic(runtimeDeps(self), String(spec), options);
|
|
195
|
+
}
|
|
196
|
+
export async function rpcEnsureRuntimes(self, specs, options = {}) {
|
|
197
|
+
await ensureProgrammaticReady(self);
|
|
198
|
+
return ensureRuntimesProgrammatic(runtimeDeps(self), specs.map((s) => String(s)), options);
|
|
199
|
+
}
|
|
200
|
+
export async function rpcListRuntimes(self) {
|
|
201
|
+
await ensureProgrammaticReady(self);
|
|
202
|
+
return {
|
|
203
|
+
installed: listInstalledRuntimes(self.sqliteFs, getHome(self)),
|
|
204
|
+
available: await listAvailableRuntimes(self.env),
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
export async function rpcListProcesses(self) {
|
|
208
|
+
await ensureProgrammaticReady(self);
|
|
209
|
+
return self.processTable.getAll().map((p) => serializeProcess(p));
|
|
210
|
+
}
|
|
211
|
+
export async function rpcKillProcess(self, pid) {
|
|
212
|
+
await ensureProgrammaticReady(self);
|
|
213
|
+
const n = Number(pid);
|
|
214
|
+
let ok = false;
|
|
215
|
+
if (self._viteShimPid === n) {
|
|
216
|
+
try {
|
|
217
|
+
if (self.cirrusReal?.isRunning) {
|
|
218
|
+
self.cirrusReal.stop(self.ctx);
|
|
219
|
+
self.cirrusReal = null;
|
|
220
|
+
}
|
|
221
|
+
if (self.viteDevServer?.isRunning) {
|
|
222
|
+
self.viteDevServer.stop();
|
|
223
|
+
self.viteDevServer = null;
|
|
224
|
+
try {
|
|
225
|
+
await self.ctx.storage.delete('vite-config');
|
|
226
|
+
}
|
|
227
|
+
catch { }
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
catch { }
|
|
231
|
+
try {
|
|
232
|
+
self.portRegistry.unregisterByPid(n);
|
|
233
|
+
}
|
|
234
|
+
catch { }
|
|
235
|
+
ok = self.processTable.kill(n);
|
|
236
|
+
self._viteShimPid = null;
|
|
237
|
+
self._viteShimPort = null;
|
|
238
|
+
}
|
|
239
|
+
else if (self.facetManager) {
|
|
240
|
+
ok = self.facetManager.kill(n);
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
ok = self.processTable.kill(n);
|
|
244
|
+
}
|
|
245
|
+
return { ok, pid: n };
|
|
246
|
+
}
|
|
247
|
+
export async function rpcProcessLogs(self, pid, options = {}) {
|
|
248
|
+
await ensureProgrammaticReady(self);
|
|
249
|
+
const chunks = self.processLogs.tail(Number(pid), options.bytes ? { bytes: options.bytes } : { lines: options.lines ?? 200 });
|
|
250
|
+
return {
|
|
251
|
+
pid: Number(pid),
|
|
252
|
+
chunks,
|
|
253
|
+
text: chunks.map((c) => c.data).join(''),
|
|
254
|
+
exit: self.processLogs.getExit(Number(pid)),
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
export async function rpcListPorts(self) {
|
|
258
|
+
await ensureProgrammaticReady(self);
|
|
259
|
+
return self.portRegistry.getAll().map(serializePort);
|
|
260
|
+
}
|
|
261
|
+
export async function rpcExposePort(self, port) {
|
|
262
|
+
await ensureProgrammaticReady(self);
|
|
263
|
+
const n = Number(port);
|
|
264
|
+
const entry = self.portRegistry.get(n);
|
|
265
|
+
return {
|
|
266
|
+
port: n,
|
|
267
|
+
listening: !!entry,
|
|
268
|
+
pid: entry?.pid ?? null,
|
|
269
|
+
registeredAt: entry?.registeredAt ?? null,
|
|
270
|
+
};
|
|
271
|
+
}
|
|
272
|
+
export async function rpcUnexposePort(self, port) {
|
|
273
|
+
await ensureProgrammaticReady(self);
|
|
274
|
+
const n = Number(port);
|
|
275
|
+
return { port: n, ok: self.portRegistry.unregister(n) };
|
|
276
|
+
}
|
|
277
|
+
export async function rpcDeleteFile(self, path, options = {}) {
|
|
278
|
+
await ensureProgrammaticReady(self);
|
|
279
|
+
const p = String(path).replace(/^\/+/, '');
|
|
280
|
+
if (!self.sqliteFs.exists(p))
|
|
281
|
+
return;
|
|
282
|
+
if (self.sqliteFs.isDirectory(p)) {
|
|
283
|
+
if (!options.recursive) {
|
|
284
|
+
self.sqliteFs.rmdir(p);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
rmrf(self.sqliteFs, p);
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
self.sqliteFs.unlink(p);
|
|
291
|
+
}
|
|
292
|
+
function rmrf(vfs, path) {
|
|
293
|
+
for (const entry of vfs.readdir(path)) {
|
|
294
|
+
const child = `${path}/${entry.name}`;
|
|
295
|
+
if (entry.type === 'directory')
|
|
296
|
+
rmrf(vfs, child);
|
|
297
|
+
else
|
|
298
|
+
vfs.unlink(child);
|
|
299
|
+
}
|
|
300
|
+
vfs.rmdir(path);
|
|
301
|
+
}
|
|
302
|
+
function serializeProcess(p) {
|
|
303
|
+
if (!p)
|
|
304
|
+
return null;
|
|
305
|
+
return {
|
|
306
|
+
pid: p.pid,
|
|
307
|
+
command: p.command,
|
|
308
|
+
argv: p.argv,
|
|
309
|
+
cwd: p.cwd,
|
|
310
|
+
state: p.state,
|
|
311
|
+
exitCode: p.exitCode,
|
|
312
|
+
startTime: p.startTime,
|
|
313
|
+
endTime: p.endTime,
|
|
314
|
+
longRunning: p.longRunning === true,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
function serializePort(p) {
|
|
318
|
+
return {
|
|
319
|
+
port: Number(p.port),
|
|
320
|
+
pid: Number(p.pid),
|
|
321
|
+
registeredAt: Number(p.registeredAt),
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
function shellQuote(s) {
|
|
325
|
+
return `'${String(s).replace(/'/g, `'\\''`)}'`;
|
|
326
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* session/replica-routes.ts — W12 DO read-replica state helpers.
|
|
3
|
+
*
|
|
4
|
+
* Two free functions paired with class delegators on NimbusSession:
|
|
5
|
+
*
|
|
6
|
+
* wireReplicasOnConstruct(self) — runs `tryEnableReplicas(ctx)` from
|
|
7
|
+
* the DO ctor; graceful-degrades to `{ state: 'error', error }` on
|
|
8
|
+
* throw. Result is stored on `self._w12EnableResult`.
|
|
9
|
+
*
|
|
10
|
+
* getReplicaState(self) — composes `_w12EnableResult` (constructor-time
|
|
11
|
+
* enable result) + live `inspectReplicaState(ctx)` (per-fetch isReplica
|
|
12
|
+
* + bookmark) + `replicasSuspended()` (write-burst guard). Surfaced
|
|
13
|
+
* via `/api/_diag/memory.replica` so operators (and the CT1 drift
|
|
14
|
+
* detector) can confirm replicas landed and observe replication lag.
|
|
15
|
+
*
|
|
16
|
+
* No module-level state. The W12 enable-result lives on the class
|
|
17
|
+
* (`self._w12EnableResult`); this file is pure logic.
|
|
18
|
+
*/
|
|
19
|
+
import { type TryEnableReplicasResult as W12EnableResult } from '../replica/routing.js';
|
|
20
|
+
export type { W12EnableResult };
|
|
21
|
+
/**
|
|
22
|
+
* Minimal shape of `NimbusSession` that the replica helpers need to
|
|
23
|
+
* read/write. Per plan §IX.1 (refined option b'), the class fields used
|
|
24
|
+
* here drop `private`, so this interface declares them as public.
|
|
25
|
+
*
|
|
26
|
+
* NOTE on `ctx`: the parent `CloudflareDurableObject` class declares
|
|
27
|
+
* `ctx` as `protected`, which is nominal-typed in TS. The interface
|
|
28
|
+
* cannot declare `ctx` (TS-2412). Helpers that need ctx must extract
|
|
29
|
+
* it from the call site (passed as a separate arg). We use `any` here
|
|
30
|
+
* for the field set, but `ctx` is never accessed via this interface —
|
|
31
|
+
* the helpers below accept ctx as a parameter when needed.
|
|
32
|
+
*/
|
|
33
|
+
export interface ReplicaHost {
|
|
34
|
+
_w12EnableResult: W12EnableResult | null;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Run at DO ctor time. Calls `tryEnableReplicas(ctx)` and returns the
|
|
38
|
+
* result. Pre-GA runtimes lacking the SPEC API yield
|
|
39
|
+
* `{ state: 'unsupported' }` and the DO behaves exactly as pre-W12. A
|
|
40
|
+
* throw (which `tryEnableReplicas` itself catches but we belt-and-braces)
|
|
41
|
+
* yields `{ state: 'error', error }`.
|
|
42
|
+
*
|
|
43
|
+
* `ctx` is the DurableObjectState (typed `any` because the class member
|
|
44
|
+
* is `protected` and can't be put on a public interface).
|
|
45
|
+
*/
|
|
46
|
+
export declare function wireReplicasOnConstruct(ctx: any): W12EnableResult;
|
|
47
|
+
/**
|
|
48
|
+
* Compose the full operator-facing replica state for
|
|
49
|
+
* `/api/_diag/memory.replica`.
|
|
50
|
+
*
|
|
51
|
+
* - `state` / `error` come from the ctor-time enable result on `host`.
|
|
52
|
+
* - `isReplica` / `bookmark` come from per-fetch `inspectReplicaState(ctx)`.
|
|
53
|
+
* - `suspended` reflects the global write-burst guard
|
|
54
|
+
* (npm install / git clone in flight) per CF research §G.4.
|
|
55
|
+
*
|
|
56
|
+
* Never throws. Callers can rely on the shape always being filled.
|
|
57
|
+
*
|
|
58
|
+
* Two args (host + ctx) because `ctx` is `protected` on the parent class
|
|
59
|
+
* and can't be reached through a public interface; see ReplicaHost docs.
|
|
60
|
+
*/
|
|
61
|
+
export declare function getReplicaState(host: ReplicaHost, ctx: any): {
|
|
62
|
+
state: string;
|
|
63
|
+
error: string | null;
|
|
64
|
+
isReplica: boolean;
|
|
65
|
+
bookmark: string | null;
|
|
66
|
+
suspended: boolean;
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=replica-routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replica-routes.d.ts","sourceRoot":"","sources":["../../src/session/replica-routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAGL,KAAK,uBAAuB,IAAI,eAAe,EAChD,MAAM,uBAAuB,CAAC;AAG/B,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,WAAW;IAC1B,gBAAgB,EAAE,eAAe,GAAG,IAAI,CAAC;CAC1C;AAED;;;;;;;;;GASG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,GAAG,GAAG,eAAe,CAQjE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,GAAG;IAC5D,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,OAAO,CAAC;CACpB,CAkBA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* session/replica-routes.ts — W12 DO read-replica state helpers.
|
|
3
|
+
*
|
|
4
|
+
* Two free functions paired with class delegators on NimbusSession:
|
|
5
|
+
*
|
|
6
|
+
* wireReplicasOnConstruct(self) — runs `tryEnableReplicas(ctx)` from
|
|
7
|
+
* the DO ctor; graceful-degrades to `{ state: 'error', error }` on
|
|
8
|
+
* throw. Result is stored on `self._w12EnableResult`.
|
|
9
|
+
*
|
|
10
|
+
* getReplicaState(self) — composes `_w12EnableResult` (constructor-time
|
|
11
|
+
* enable result) + live `inspectReplicaState(ctx)` (per-fetch isReplica
|
|
12
|
+
* + bookmark) + `replicasSuspended()` (write-burst guard). Surfaced
|
|
13
|
+
* via `/api/_diag/memory.replica` so operators (and the CT1 drift
|
|
14
|
+
* detector) can confirm replicas landed and observe replication lag.
|
|
15
|
+
*
|
|
16
|
+
* No module-level state. The W12 enable-result lives on the class
|
|
17
|
+
* (`self._w12EnableResult`); this file is pure logic.
|
|
18
|
+
*/
|
|
19
|
+
import { tryEnableReplicas as _w12TryEnableReplicas, inspectReplicaState as _w12InspectReplicaState, } from '../replica/routing.js';
|
|
20
|
+
import { replicasSuspended as _w12ReplicasSuspended } from '../replica/suspension.js';
|
|
21
|
+
/**
|
|
22
|
+
* Run at DO ctor time. Calls `tryEnableReplicas(ctx)` and returns the
|
|
23
|
+
* result. Pre-GA runtimes lacking the SPEC API yield
|
|
24
|
+
* `{ state: 'unsupported' }` and the DO behaves exactly as pre-W12. A
|
|
25
|
+
* throw (which `tryEnableReplicas` itself catches but we belt-and-braces)
|
|
26
|
+
* yields `{ state: 'error', error }`.
|
|
27
|
+
*
|
|
28
|
+
* `ctx` is the DurableObjectState (typed `any` because the class member
|
|
29
|
+
* is `protected` and can't be put on a public interface).
|
|
30
|
+
*/
|
|
31
|
+
export function wireReplicasOnConstruct(ctx) {
|
|
32
|
+
try {
|
|
33
|
+
return _w12TryEnableReplicas(ctx);
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
// tryEnableReplicas itself never throws (it catches), but keep this
|
|
37
|
+
// belt-and-braces so a future change doesn't break the constructor.
|
|
38
|
+
return { state: 'error', error: e?.message ?? String(e) };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Compose the full operator-facing replica state for
|
|
43
|
+
* `/api/_diag/memory.replica`.
|
|
44
|
+
*
|
|
45
|
+
* - `state` / `error` come from the ctor-time enable result on `host`.
|
|
46
|
+
* - `isReplica` / `bookmark` come from per-fetch `inspectReplicaState(ctx)`.
|
|
47
|
+
* - `suspended` reflects the global write-burst guard
|
|
48
|
+
* (npm install / git clone in flight) per CF research §G.4.
|
|
49
|
+
*
|
|
50
|
+
* Never throws. Callers can rely on the shape always being filled.
|
|
51
|
+
*
|
|
52
|
+
* Two args (host + ctx) because `ctx` is `protected` on the parent class
|
|
53
|
+
* and can't be reached through a public interface; see ReplicaHost docs.
|
|
54
|
+
*/
|
|
55
|
+
export function getReplicaState(host, ctx) {
|
|
56
|
+
const enable = host._w12EnableResult ?? { state: 'unknown', error: null };
|
|
57
|
+
let isReplica = false;
|
|
58
|
+
let bookmark = null;
|
|
59
|
+
try {
|
|
60
|
+
const inspect = _w12InspectReplicaState(ctx);
|
|
61
|
+
isReplica = inspect.isReplica;
|
|
62
|
+
bookmark = inspect.bookmark;
|
|
63
|
+
}
|
|
64
|
+
catch { /* never throw from a diag helper */ }
|
|
65
|
+
let suspended = false;
|
|
66
|
+
try {
|
|
67
|
+
suspended = _w12ReplicasSuspended();
|
|
68
|
+
}
|
|
69
|
+
catch { }
|
|
70
|
+
return {
|
|
71
|
+
state: enable.state,
|
|
72
|
+
error: enable.error,
|
|
73
|
+
isReplica,
|
|
74
|
+
bookmark,
|
|
75
|
+
suspended,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* session/routes.ts — HTTP/WS fetch routing for the supervisor DO.
|
|
3
|
+
*
|
|
4
|
+
* One handleRequest function for everything the DO speaks:
|
|
5
|
+
* /ws upgrade → cold-init / warm-rejoin (B'.5) / 409
|
|
6
|
+
* /preview/* → cirrus-real or vite-dev-server forward
|
|
7
|
+
* /port/:n/* → user http-server proxy via port-registry
|
|
8
|
+
* /worker/* → nimbus-wrangler dev forward
|
|
9
|
+
* /api/_diag/* → forensic surfaces (memory, session, cirrus)
|
|
10
|
+
* /api/_test/* → NIMBUS_DEBUG-gated probe endpoints
|
|
11
|
+
* /api/* (other) → small JSON endpoints (write-file, mkdir, ...)
|
|
12
|
+
*
|
|
13
|
+
* The dispatcher is one big if/else by design — pattern-matching
|
|
14
|
+
* URL paths cleanly is easier to read than a Map-based router for
|
|
15
|
+
* this many one-off shapes, and grep-ability matters when debugging.
|
|
16
|
+
*
|
|
17
|
+
* Surfaces:
|
|
18
|
+
* - handleFetch(self, request) — top-level dispatcher; was _handleFetch.
|
|
19
|
+
*
|
|
20
|
+
* The class retains `fetch` (DO contract) + `_handleFetch` as delegators
|
|
21
|
+
* per plan §IX.4 R1.
|
|
22
|
+
*
|
|
23
|
+
* Per DEFECT-D1: route handlers read self.ctx + self.env extensively
|
|
24
|
+
* (~30 sites). RoutesHost = any pragmatic deviation, like InitHost in S6.
|
|
25
|
+
*/
|
|
26
|
+
type RoutesHost = any;
|
|
27
|
+
export declare function handleFetch(self: RoutesHost, request: Request): Promise<Response>;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=routes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"routes.d.ts","sourceRoot":"","sources":["../../src/session/routes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AA+BH,KAAK,UAAU,GAAG,GAAG,CAAC;AAEtB,wBAAsB,WAAW,CAAC,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAi/BvF"}
|