@nimbus-sh/worker 0.9.0 → 0.11.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/NOTICE.md +5 -0
- package/README.md +10 -0
- package/dist/_shared/session-router.d.ts +7 -0
- package/dist/_shared/session-router.d.ts.map +1 -1
- package/dist/_shared/session-router.js +7 -0
- package/dist/bindings/body.d.ts +6 -0
- package/dist/bindings/body.d.ts.map +1 -0
- package/dist/bindings/body.js +37 -0
- package/dist/bindings/kv.d.ts +0 -2
- package/dist/bindings/kv.d.ts.map +1 -1
- package/dist/bindings/kv.js +3 -42
- package/dist/bindings/r2.d.ts +0 -2
- package/dist/bindings/r2.d.ts.map +1 -1
- package/dist/bindings/r2.js +4 -44
- package/dist/esbuild-cli-artifact.generated.d.ts +18 -0
- package/dist/esbuild-cli-artifact.generated.d.ts.map +1 -0
- package/dist/esbuild-cli-artifact.generated.js +17 -0
- package/dist/esbuild-wasm-bundle.generated.d.ts +24 -24
- package/dist/esbuild-wasm-bundle.generated.d.ts.map +1 -1
- package/dist/esbuild-wasm-bundle.generated.js +24 -24
- package/dist/facets/cirrus-real.d.ts.map +1 -1
- package/dist/facets/cirrus-real.js +11 -6
- package/dist/facets/compose.d.ts +11 -7
- package/dist/facets/compose.d.ts.map +1 -1
- package/dist/facets/compose.js +8 -31
- package/dist/facets/data-plan.d.ts +79 -0
- package/dist/facets/data-plan.d.ts.map +1 -0
- package/dist/facets/data-plan.js +477 -0
- package/dist/facets/esbuild-bundle-pool.d.ts +1 -1
- package/dist/facets/esbuild-bundle-pool.js +3 -3
- package/dist/facets/esbuild-transform.d.ts +38 -8
- package/dist/facets/esbuild-transform.d.ts.map +1 -1
- package/dist/facets/esbuild-transform.js +219 -19
- package/dist/facets/exec-telemetry.d.ts +7 -3
- package/dist/facets/exec-telemetry.d.ts.map +1 -1
- package/dist/facets/manager.d.ts +198 -69
- package/dist/facets/manager.d.ts.map +1 -1
- package/dist/facets/manager.js +1276 -652
- package/dist/facets/opencode-staging.d.ts +0 -2
- package/dist/facets/opencode-staging.d.ts.map +1 -1
- package/dist/facets/opencode-staging.js +5 -11
- package/dist/facets/process.d.ts +4 -0
- package/dist/facets/process.d.ts.map +1 -1
- package/dist/facets/process.js +3 -0
- package/dist/facets/read-profile.d.ts +149 -0
- package/dist/facets/read-profile.d.ts.map +1 -0
- package/dist/facets/read-profile.js +483 -0
- package/dist/facets/real-vite-hmr.d.ts +2 -0
- package/dist/facets/real-vite-hmr.d.ts.map +1 -1
- package/dist/facets/real-vite-hmr.js +3 -2
- package/dist/facets/resident-identity.d.ts +0 -1
- package/dist/facets/resident-identity.d.ts.map +1 -1
- package/dist/facets/resident-identity.js +0 -3
- package/dist/facets/wasm-swap-registry.d.ts +34 -25
- package/dist/facets/wasm-swap-registry.d.ts.map +1 -1
- package/dist/facets/wasm-swap-registry.js +62 -56
- package/dist/facets/ws-terminal.d.ts +4 -4
- package/dist/facets/ws-terminal.d.ts.map +1 -1
- package/dist/facets/ws-terminal.js +4 -5
- package/dist/git/commands.d.ts +33 -10
- package/dist/git/commands.d.ts.map +1 -1
- package/dist/git/commands.js +1891 -197
- package/dist/git/network-facet.d.ts +12 -2
- package/dist/git/network-facet.d.ts.map +1 -1
- package/dist/git/network-facet.js +69 -18
- package/dist/git/unified-diff.d.ts +74 -0
- package/dist/git/unified-diff.d.ts.map +1 -0
- package/dist/git/unified-diff.js +676 -0
- package/dist/git-bundle.generated.d.ts +7 -11
- package/dist/git-bundle.generated.d.ts.map +1 -1
- package/dist/git-bundle.generated.js +7 -11
- package/dist/hosted/commands.d.ts.map +1 -1
- package/dist/hosted/commands.js +64 -245
- package/dist/hosted/runtime.d.ts +22 -15
- package/dist/hosted/runtime.d.ts.map +1 -1
- package/dist/hosted/runtime.js +72 -14
- package/dist/hosted/services.d.ts +8 -1
- package/dist/hosted/services.d.ts.map +1 -1
- package/dist/hosted/services.js +12 -13
- package/dist/hosted/session.d.ts +165 -0
- package/dist/hosted/session.d.ts.map +1 -0
- package/dist/hosted/session.js +132 -0
- package/dist/loaders/generated-workers.d.ts +6 -3
- package/dist/loaders/generated-workers.d.ts.map +1 -1
- package/dist/loaders/generated-workers.js +8 -5
- package/dist/loaders/npm-resolve-preamble.d.ts.map +1 -1
- package/dist/loaders/npm-resolve-preamble.js +0 -27
- package/dist/loaders/pre-bundle-preamble.d.ts +6 -3
- package/dist/loaders/pre-bundle-preamble.d.ts.map +1 -1
- package/dist/loaders/pre-bundle-preamble.js +13 -8
- package/dist/node-shims-artifact.generated.d.ts +13 -4
- package/dist/node-shims-artifact.generated.d.ts.map +1 -1
- package/dist/node-shims-artifact.generated.js +16 -7
- package/dist/npm/bin-links.d.ts +3 -1
- package/dist/npm/bin-links.d.ts.map +1 -1
- package/dist/npm/bin-links.js +32 -8
- package/dist/npm/cache.d.ts +11 -1
- package/dist/npm/cache.d.ts.map +1 -1
- package/dist/npm/cache.js +21 -7
- package/dist/npm/install-batch-facet.d.ts +4 -2
- package/dist/npm/install-batch-facet.d.ts.map +1 -1
- package/dist/npm/install-batch-facet.js +32 -18
- package/dist/npm/installer.d.ts +23 -3
- package/dist/npm/installer.d.ts.map +1 -1
- package/dist/npm/installer.js +330 -131
- package/dist/npm/npx-install.d.ts +3 -1
- package/dist/npm/npx-install.d.ts.map +1 -1
- package/dist/npm/npx-install.js +4 -1
- package/dist/npm/package-lock.d.ts +32 -0
- package/dist/npm/package-lock.d.ts.map +1 -0
- package/dist/npm/package-lock.js +65 -0
- package/dist/npm/placement.d.ts +16 -0
- package/dist/npm/placement.d.ts.map +1 -0
- package/dist/npm/placement.js +33 -0
- package/dist/npm/pre-bundle-facet.d.ts +1 -30
- package/dist/npm/pre-bundle-facet.d.ts.map +1 -1
- package/dist/npm/pre-bundle-facet.js +3 -5
- package/dist/npm/r2-cache.d.ts +12 -6
- package/dist/npm/r2-cache.d.ts.map +1 -1
- package/dist/npm/r2-cache.js +34 -16
- package/dist/npm/resolve-one-facet.d.ts +3 -0
- package/dist/npm/resolve-one-facet.d.ts.map +1 -1
- package/dist/npm/resolve-one-facet.js +15 -3
- package/dist/npm/resolver.d.ts +11 -13
- package/dist/npm/resolver.d.ts.map +1 -1
- package/dist/npm/resolver.js +12 -25
- package/dist/opencode-artifact.generated.js +2 -2
- package/dist/replica/routing.d.ts +2 -38
- package/dist/replica/routing.d.ts.map +1 -1
- package/dist/replica/routing.js +3 -55
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +15 -2
- package/dist/router/public-directory.d.ts +18 -0
- package/dist/router/public-directory.d.ts.map +1 -1
- package/dist/router/public-directory.js +1 -1
- package/dist/router/remote-api.d.ts +3 -1
- package/dist/router/remote-api.d.ts.map +1 -1
- package/dist/router/remote-api.js +42 -79
- package/dist/runtime/bash-repl.js +2 -2
- package/dist/runtime/bun-repl.d.ts.map +1 -1
- package/dist/runtime/bun-repl.js +2 -13
- package/dist/runtime/cpython-resident.d.ts.map +1 -1
- package/dist/runtime/cpython-resident.js +2 -10
- package/dist/runtime/esbuild-wasm-bytes.d.ts +37 -18
- package/dist/runtime/esbuild-wasm-bytes.d.ts.map +1 -1
- package/dist/runtime/esbuild-wasm-bytes.js +66 -92
- package/dist/runtime/facet-loader-host.d.ts.map +1 -1
- package/dist/runtime/facet-loader-host.js +0 -7
- package/dist/runtime/git-bundle-artifact.d.ts +17 -0
- package/dist/runtime/git-bundle-artifact.d.ts.map +1 -0
- package/dist/runtime/git-bundle-artifact.js +25 -0
- package/dist/runtime/node-repl.d.ts.map +1 -1
- package/dist/runtime/node-repl.js +2 -13
- package/dist/runtime/node-shims-artifact.d.ts +22 -23
- package/dist/runtime/node-shims-artifact.d.ts.map +1 -1
- package/dist/runtime/node-shims-artifact.js +48 -78
- package/dist/runtime/node-shims.d.ts.map +1 -1
- package/dist/runtime/node-shims.js +2358 -996
- package/dist/runtime/opencode-artifact.d.ts.map +1 -1
- package/dist/runtime/opencode-artifact.js +17 -53
- package/dist/runtime/opencode-facet-runner.d.ts +3 -6
- package/dist/runtime/opencode-facet-runner.d.ts.map +1 -1
- package/dist/runtime/opencode-facet-runner.js +45 -10
- package/dist/runtime/opentui-wasm-bytes.d.ts.map +1 -1
- package/dist/runtime/opentui-wasm-bytes.js +16 -49
- package/dist/runtime/package-manager.d.ts +0 -2
- package/dist/runtime/package-manager.d.ts.map +1 -1
- package/dist/runtime/package-manager.js +0 -3
- package/dist/runtime/python-repl.d.ts.map +1 -1
- package/dist/runtime/python-repl.js +4 -35
- package/dist/runtime/repl-session.d.ts +10 -0
- package/dist/runtime/repl-session.d.ts.map +1 -1
- package/dist/runtime/repl-session.js +7 -0
- package/dist/runtime/ruby-repl.d.ts.map +1 -1
- package/dist/runtime/ruby-repl.js +2 -2
- package/dist/runtime/ruby-resident.d.ts.map +1 -1
- package/dist/runtime/ruby-resident.js +41 -51
- package/dist/runtime/runtime-catalog.d.ts +10 -3
- package/dist/runtime/runtime-catalog.d.ts.map +1 -1
- package/dist/runtime/runtime-catalog.js +125 -15
- package/dist/runtime/sqlite-wasm-bytes.d.ts +4 -4
- package/dist/runtime/sqlite-wasm-bytes.d.ts.map +1 -1
- package/dist/runtime/sqlite-wasm-bytes.js +21 -57
- package/dist/runtime/staged-source.d.ts +67 -0
- package/dist/runtime/staged-source.d.ts.map +1 -0
- package/dist/runtime/staged-source.js +113 -0
- package/dist/runtime/wasi/preamble.d.ts +0 -22
- package/dist/runtime/wasi/preamble.d.ts.map +1 -1
- package/dist/runtime/wasi/preamble.js +98 -1425
- package/dist/runtime-catalog.generated.js +1 -1
- package/dist/session/agent.d.ts +14 -2
- package/dist/session/agent.d.ts.map +1 -1
- package/dist/session/agent.js +57 -19
- package/dist/session/ai.d.ts +0 -11
- package/dist/session/ai.d.ts.map +1 -1
- package/dist/session/ai.js +0 -4
- package/dist/session/fs-watch.d.ts +0 -11
- package/dist/session/fs-watch.d.ts.map +1 -1
- package/dist/session/fs-watch.js +0 -21
- package/dist/session/hibernation.d.ts +68 -2
- package/dist/session/hibernation.d.ts.map +1 -1
- package/dist/session/hibernation.js +95 -1
- package/dist/session/init-phases.d.ts +1 -2
- package/dist/session/init-phases.d.ts.map +1 -1
- package/dist/session/init-phases.js +1 -2
- package/dist/session/init.d.ts.map +1 -1
- package/dist/session/init.js +7 -20
- package/dist/session/keys.d.ts +0 -3
- package/dist/session/keys.d.ts.map +1 -1
- package/dist/session/keys.js +0 -3
- package/dist/session/legacy-reset.d.ts +11 -0
- package/dist/session/legacy-reset.d.ts.map +1 -0
- package/dist/session/legacy-reset.js +16 -0
- package/dist/session/nimbus-session.d.ts +50 -16
- package/dist/session/nimbus-session.d.ts.map +1 -1
- package/dist/session/nimbus-session.js +77 -71
- package/dist/session/npm-install-port.d.ts.map +1 -1
- package/dist/session/npm-install-port.js +2 -0
- package/dist/session/programmatic.d.ts +13 -18
- package/dist/session/programmatic.d.ts.map +1 -1
- package/dist/session/programmatic.js +53 -39
- package/dist/session/replica-routes.d.ts +2 -3
- package/dist/session/replica-routes.d.ts.map +1 -1
- package/dist/session/replica-routes.js +3 -10
- package/dist/session/routes.d.ts.map +1 -1
- package/dist/session/routes.js +11 -12
- package/dist/session/rpc.d.ts +108 -21
- package/dist/session/rpc.d.ts.map +1 -1
- package/dist/session/rpc.js +194 -39
- package/dist/session/start-real-vite.js +2 -2
- package/dist/session/state-store.d.ts +1 -17
- package/dist/session/state-store.d.ts.map +1 -1
- package/dist/session/state-store.js +3 -53
- package/dist/session/supervisor-op.d.ts +7 -0
- package/dist/session/supervisor-op.d.ts.map +1 -1
- package/dist/session/supervisor-op.js +6 -1
- package/dist/session/supervisor-rpc.d.ts +116 -19
- package/dist/session/supervisor-rpc.d.ts.map +1 -1
- package/dist/session/supervisor-rpc.js +194 -84
- package/dist/session/vite-command.d.ts.map +1 -1
- package/dist/session/vite-command.js +17 -14
- package/dist/session/ws.d.ts.map +1 -1
- package/dist/session/ws.js +20 -8
- package/dist/shell/npm-bin-entrypoints.d.ts.map +1 -1
- package/dist/shell/npm-bin-entrypoints.js +30 -5
- package/dist/vfs/facet-resident-limits.d.ts +33 -0
- package/dist/vfs/facet-resident-limits.d.ts.map +1 -0
- package/dist/vfs/facet-resident-limits.js +33 -0
- package/dist/vfs/facet-resident-store.d.ts +2 -10
- package/dist/vfs/facet-resident-store.d.ts.map +1 -1
- package/dist/vfs/facet-resident-store.js +1594 -219
- package/dist/workspace-host.d.ts +3 -1
- package/dist/workspace-host.d.ts.map +1 -1
- package/dist/workspace-host.js +2 -0
- package/dist/wrangler/nimbus-wrangler.d.ts +0 -2
- package/dist/wrangler/nimbus-wrangler.d.ts.map +1 -1
- package/dist/wrangler/nimbus-wrangler.js +8 -22
- package/package.json +34 -7
- package/public/_assets/esbuild-0.24.2.js +2380 -0
- package/public/_assets/opencode/1.16.2/index-attach.js +2 -2
- package/public/_assets/runtime/esbuild-cli-c4fda380d52befc1.js +6892 -0
- package/public/_assets/runtime/git-de3e60c9f3ff006a.js +103 -0
- package/public/_assets/runtime/{node-shims-acaa037e6d26ec0d.js → node-shims-06565b121555c194.js} +2879 -992
- package/public/_assets/runtime/resident-store-6ffb1939c53d982f.js +2264 -0
- package/public/_assets/runtime/vfs-write-ledger-e501e8fc793bc2c1.js +889 -0
- package/scripts/build-opencode-attach-entry.mjs +51 -1
- package/scripts/bundle-esbuild-wasm.mjs +55 -39
- package/scripts/bundle-facet-workers.mjs +159 -10
- package/scripts/bundle-git.mjs +88 -27
- package/scripts/bundle-node-shims.mjs +72 -46
- package/scripts/bundle-runtime.mjs +18 -421
- package/scripts/cf-git-patch.mjs +137 -0
- package/scripts/patch-install-deps.mjs +49 -96
- package/scripts/runtime-specs.mjs +435 -0
- package/vendor/git-http.generated.d.ts +82 -0
- package/vendor/git-upstream.generated.d.ts +4378 -0
- package/vendor/git.LICENSE +7 -0
- package/vendor/git.generated.d.mts +21 -0
- package/vendor/git.generated.mjs +103 -0
- package/dist/replica/suspension.d.ts +0 -36
- package/dist/replica/suspension.d.ts.map +0 -1
- package/dist/replica/suspension.js +0 -49
- package/dist/runtime/static-server.d.ts +0 -3
- package/dist/runtime/static-server.d.ts.map +0 -1
- package/dist/runtime/static-server.js +0 -133
- package/scripts/clean-dist.mjs +0 -7
package/dist/hosted/runtime.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { requireVfsCred } from '@nimbus-sh/core/runtime/os-contracts.js';
|
|
2
|
-
import {
|
|
3
|
-
import { ExecutionFs } from '@nimbus-sh/core/shell/execution-fs.js';
|
|
2
|
+
import { ProcessView } from '@nimbus-sh/core/runtime/process-files.js';
|
|
4
3
|
import { SUPERVISOR_OP_ROUTES, createSupervisorBridgeStore } from '@nimbus-sh/core/workspace/supervisor-op.js';
|
|
4
|
+
import { openSupervisorDeliveries } from '@nimbus-sh/core/workspace/supervisor-delivery.js';
|
|
5
5
|
import { WebSocketTerminal } from '../facets/ws-terminal.js';
|
|
6
6
|
import { buildSessionSupervisorOps } from '../session/supervisor-op.js';
|
|
7
|
-
import { installLogPersistence } from '../session/hibernation.js';
|
|
7
|
+
import { armResidentKeepalive, installLogPersistence, noteResidentClient, residentKeepaliveFired } from '../session/hibernation.js';
|
|
8
|
+
import { takeLegacyResetNotice } from '../session/legacy-reset.js';
|
|
8
9
|
import { appendScrollback, ensureSessionStateSchema, loadScrollback, loadShellState, persistShellState } from '../session/state-store.js';
|
|
9
10
|
import { wireProcessLogSocketBroadcast } from '../runtime/process-logs-api.js';
|
|
10
11
|
import { routeRuntimeLoopback } from '../session/loopback.js';
|
|
@@ -12,10 +13,11 @@ import * as rpc from '../session/rpc.js';
|
|
|
12
13
|
import * as operations from '../session/programmatic.js';
|
|
13
14
|
import * as services from './services.js';
|
|
14
15
|
import { registerHostedCommands } from './commands.js';
|
|
16
|
+
import { HostedSession } from './session.js';
|
|
15
17
|
import { z } from 'zod/v4';
|
|
16
18
|
import { adoptCtxExports, supervisorEntrypoint } from '@nimbus-sh/fabric/composition.js';
|
|
17
19
|
import { hostNamespaceBinding } from '@nimbus-sh/fabric/host-dispatch.js';
|
|
18
|
-
const HostedTask = z.enum(['resident-launch', 'log-flush', 'log-janitor']);
|
|
20
|
+
const HostedTask = z.enum(['resident-launch', 'resident-keepalive', 'log-flush', 'log-janitor']);
|
|
19
21
|
const InputFrame = z.discriminatedUnion('type', [
|
|
20
22
|
z.object({ type: z.literal('input'), data: z.string() }),
|
|
21
23
|
z.object({ type: z.literal('resize'), cols: z.number().int().positive(), rows: z.number().int().positive() }),
|
|
@@ -31,6 +33,8 @@ class RuntimeOwner {
|
|
|
31
33
|
closing = null;
|
|
32
34
|
_w9PersistWired = false;
|
|
33
35
|
_w9SchemaInit = false;
|
|
36
|
+
_w1KeepaliveArmed = false;
|
|
37
|
+
_w1LastClientActivityAt = 0;
|
|
34
38
|
_viteShimPid = null;
|
|
35
39
|
_viteShimPort = null;
|
|
36
40
|
wranglerAliasBannerShown = false;
|
|
@@ -49,12 +53,18 @@ class RuntimeOwner {
|
|
|
49
53
|
flushScheduled = false;
|
|
50
54
|
janitorScheduled = false;
|
|
51
55
|
recoveryNotice = false;
|
|
56
|
+
legacyNotice = null;
|
|
52
57
|
scheduling = new Set();
|
|
53
58
|
fileLeases = new Map();
|
|
54
59
|
services;
|
|
60
|
+
/** The workspace's namespace and process bindings. */
|
|
61
|
+
getFilesystemAuthority() { return this.options.workspace.filesystem; }
|
|
62
|
+
/** This instance's receipts for its processes' mutations delivered exactly once (see NimbusSession). */
|
|
63
|
+
supervisorDeliveries;
|
|
55
64
|
constructor(options) {
|
|
56
65
|
this.options = options;
|
|
57
66
|
hostNamespaceBinding(options.env, 'HostedRuntime');
|
|
67
|
+
this.supervisorDeliveries = openSupervisorDeliveries(options.ctx);
|
|
58
68
|
const exports = Reflect.get(options.ctx, 'exports');
|
|
59
69
|
if (!supervisorEntrypoint(exports)) {
|
|
60
70
|
throw new Error('Export the configured supervisor entrypoint and call composeFabric before composing a hosted runtime');
|
|
@@ -73,6 +83,7 @@ class RuntimeOwner {
|
|
|
73
83
|
requestLaunchTurn: (at) => this._scheduleLaunchTurn(at),
|
|
74
84
|
resolveWorkerLaunch: options.resolveWorkerLaunch,
|
|
75
85
|
filesystem: () => options.workspace.filesystem,
|
|
86
|
+
armResidentKeepalive: () => armResidentKeepalive(this, (at) => this.scheduleKeepalive(at)),
|
|
76
87
|
});
|
|
77
88
|
options.workspace.shell.bindTerminal(this.terminal);
|
|
78
89
|
installLogPersistence(this, options.ctx, () => this.scheduleLogs());
|
|
@@ -100,6 +111,8 @@ class RuntimeOwner {
|
|
|
100
111
|
ensureRuntimeReady() {
|
|
101
112
|
this.assertOpen();
|
|
102
113
|
this.readyPromise ??= (async () => {
|
|
114
|
+
// Files a pre-v2 Nimbus wrote are not read: say so, and start cold.
|
|
115
|
+
this.legacyNotice = takeLegacyResetNotice(this.sqliteFs, this.ctx);
|
|
103
116
|
const saved = loadShellState(this.ctx);
|
|
104
117
|
this.recoveryNotice = saved.hasPersistedState;
|
|
105
118
|
if (saved.cwd)
|
|
@@ -132,6 +145,14 @@ class RuntimeOwner {
|
|
|
132
145
|
this.options.lifecycle.waitUntil(pending);
|
|
133
146
|
return pending;
|
|
134
147
|
}
|
|
148
|
+
noteClientActivity() {
|
|
149
|
+
noteResidentClient(this, (at) => this.scheduleKeepalive(at));
|
|
150
|
+
}
|
|
151
|
+
scheduleKeepalive(at) {
|
|
152
|
+
const pending = this.schedule('resident-keepalive', at);
|
|
153
|
+
this.options.lifecycle.waitUntil(pending);
|
|
154
|
+
return pending.then(() => true, () => false);
|
|
155
|
+
}
|
|
135
156
|
schedule(reason, at) {
|
|
136
157
|
if (this._w1SessionDestroyed)
|
|
137
158
|
return Promise.reject(new Error('Nimbus runtime is closed'));
|
|
@@ -195,6 +216,11 @@ class RuntimeOwner {
|
|
|
195
216
|
if (task === 'resident-launch') {
|
|
196
217
|
await this.ensureFacetManager().pumpLaunches();
|
|
197
218
|
}
|
|
219
|
+
else if (task === 'resident-keepalive') {
|
|
220
|
+
const next = residentKeepaliveFired(this, this.ctx, Date.now());
|
|
221
|
+
if (next !== null && !(await this.scheduleKeepalive(next)))
|
|
222
|
+
this._w1KeepaliveArmed = false;
|
|
223
|
+
}
|
|
198
224
|
else if (task === 'log-flush') {
|
|
199
225
|
this.flushScheduled = false;
|
|
200
226
|
this.processes.flushLogs();
|
|
@@ -217,6 +243,10 @@ class RuntimeOwner {
|
|
|
217
243
|
this.terminal.write('\r\n[Runtime resumed; files and shell settings restored. Previous interpreter state was not retained.]\r\n');
|
|
218
244
|
this.recoveryNotice = false;
|
|
219
245
|
}
|
|
246
|
+
if (this.legacyNotice) {
|
|
247
|
+
this.terminal.write(`\r\n[${this.legacyNotice}]\r\n`);
|
|
248
|
+
this.legacyNotice = null;
|
|
249
|
+
}
|
|
220
250
|
if (!this.shell.running)
|
|
221
251
|
this.shell.printPrompt();
|
|
222
252
|
this.terminal.flushNow();
|
|
@@ -226,7 +256,16 @@ class RuntimeOwner {
|
|
|
226
256
|
await this.attachTerminal(ws, 'wake');
|
|
227
257
|
const text = typeof frame === 'string' ? frame : new TextDecoder().decode(frame);
|
|
228
258
|
const input = InputFrame.parse(JSON.parse(text));
|
|
229
|
-
this.terminal.handleMessage(input);
|
|
259
|
+
const completion = this.terminal.handleMessage(input);
|
|
260
|
+
if (completion) {
|
|
261
|
+
this.options.lifecycle.waitUntil(completion.catch((error) => {
|
|
262
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
263
|
+
console.error('[nimbus] terminal input failed:', message);
|
|
264
|
+
this.terminal.writeln(`terminal input failed: ${message}`);
|
|
265
|
+
}).finally(() => {
|
|
266
|
+
persistShellState(this.ctx, { cwd: this.shell.getCwd(), env: this.shell.getEnv() });
|
|
267
|
+
}));
|
|
268
|
+
}
|
|
230
269
|
persistShellState(this.ctx, { cwd: this.shell.getCwd(), env: this.shell.getEnv() });
|
|
231
270
|
}
|
|
232
271
|
terminalClose(ws) {
|
|
@@ -250,8 +289,7 @@ class RuntimeOwner {
|
|
|
250
289
|
lease = workspace.filesystem.openHost(identity);
|
|
251
290
|
this.fileLeases.set(key, lease);
|
|
252
291
|
}
|
|
253
|
-
|
|
254
|
-
return Object.assign(view, { as: (next) => this.files(next) });
|
|
292
|
+
return Object.assign(new ProcessView(lease.fs), { as: (next) => this.files(next) });
|
|
255
293
|
}
|
|
256
294
|
close() {
|
|
257
295
|
this.closing ??= Promise.resolve().then(async () => {
|
|
@@ -299,16 +337,24 @@ class RuntimeOwner {
|
|
|
299
337
|
return this.closing;
|
|
300
338
|
}
|
|
301
339
|
}
|
|
340
|
+
/** Every call an embedder makes is a client's: it notes activity for the resident keep-alive. */
|
|
341
|
+
function clientCalls(owner, calls) {
|
|
342
|
+
const wrapped = Object.fromEntries(Object.entries(calls).map(([name, call]) => [name, (...args) => {
|
|
343
|
+
owner.noteClientActivity();
|
|
344
|
+
return Reflect.apply(call, undefined, args);
|
|
345
|
+
}]));
|
|
346
|
+
// Same keys, same signatures: each entry forwards its arguments unchanged.
|
|
347
|
+
return wrapped;
|
|
348
|
+
}
|
|
302
349
|
export async function composeHostedRuntime(options) {
|
|
303
350
|
const owner = new RuntimeOwner(options);
|
|
304
351
|
await owner.ensureRuntimeReady();
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
files: owner.files(owner.processes.cred(owner.shellProcessPid)),
|
|
309
|
-
runtimes: owner.runtimeManager,
|
|
352
|
+
// Facet RPCs (supervisorOp), alarms and teardown are not clients.
|
|
353
|
+
const client = clientCalls(owner, {
|
|
354
|
+
facets: () => owner.ensureFacetManager(),
|
|
310
355
|
ready: operations.ensureProgrammaticReady.bind(null, owner),
|
|
311
356
|
exec: operations.rpcExec.bind(null, owner),
|
|
357
|
+
execStream: operations.rpcExecStream.bind(null, owner),
|
|
312
358
|
runCode: operations.rpcRunCode.bind(null, owner),
|
|
313
359
|
startProcess: operations.rpcStartProcess.bind(null, owner),
|
|
314
360
|
listProcesses: operations.rpcListProcesses.bind(null, owner),
|
|
@@ -334,10 +380,22 @@ export async function composeHostedRuntime(options) {
|
|
|
334
380
|
await operations.ensureProgrammaticReady(owner);
|
|
335
381
|
return owner.ensureFacetManager().apps.routeCapabilityPort(...args);
|
|
336
382
|
},
|
|
337
|
-
supervisorOp: (envelope) => owner.supervisorOp(envelope),
|
|
338
|
-
onScheduled: (task) => owner.onScheduled(task),
|
|
339
383
|
attachTerminal: (ws) => owner.attachTerminal(ws),
|
|
340
384
|
terminalFrame: (ws, message) => owner.terminalFrame(ws, message),
|
|
385
|
+
});
|
|
386
|
+
return {
|
|
387
|
+
workspace: options.workspace,
|
|
388
|
+
terminal: owner.terminal,
|
|
389
|
+
files: owner.files(owner.processes.cred(owner.shellProcessPid)),
|
|
390
|
+
runtimes: owner.runtimeManager,
|
|
391
|
+
...client,
|
|
392
|
+
supervisorOp: (envelope) => owner.supervisorOp(envelope),
|
|
393
|
+
/** The SDK's session surface for `Nimbus.fromSession`, optionally bound to one shell and identity. */
|
|
394
|
+
session: (scope = {}) => {
|
|
395
|
+
owner.assertOpen();
|
|
396
|
+
return new HostedSession(owner, scope);
|
|
397
|
+
},
|
|
398
|
+
onScheduled: (task) => owner.onScheduled(task),
|
|
341
399
|
terminalClose: (ws) => owner.terminalClose(ws),
|
|
342
400
|
close: () => owner.close(),
|
|
343
401
|
};
|
|
@@ -9,7 +9,7 @@ import type { IsolatePoolEnv } from '@nimbus-sh/fabric/isolate-pool.js';
|
|
|
9
9
|
export interface HostedRuntimeEnv extends RuntimeCatalogEnv, IsolatePoolEnv {
|
|
10
10
|
ASSETS?: Fetcher;
|
|
11
11
|
}
|
|
12
|
-
export type RuntimeServiceHost = Pick<SessionInternal, '_cpRegistry' | '_envFlagDefaultOn' | '_reportExternalExit' | 'buildFetchFn' | 'bundlePool' | 'ensureBundlePool' | 'ensureFacetManager' | 'ensureFetchProxy' | 'ensureSqliteFs' | 'esbuildService' | 'facetManagerComposed' | 'facetProcessManager' | 'fetchProxyEntrypoint' | 'npmInstaller' | 'portRegistry' | 'processes' | 'shell' | 'sqliteFs' | 'terminal'> & {
|
|
12
|
+
export type RuntimeServiceHost = Pick<SessionInternal, '_cpRegistry' | '_envFlagDefaultOn' | '_reportExternalExit' | 'buildFetchFn' | 'bundlePool' | 'ensureBundlePool' | 'ensureFacetManager' | 'ensureFetchProxy' | 'ensureSqliteFs' | 'esbuildService' | 'facetManagerComposed' | 'getFilesystemAuthority' | 'facetProcessManager' | 'fetchProxyEntrypoint' | 'npmInstaller' | 'portRegistry' | 'processes' | 'shell' | 'sqliteFs' | 'terminal'> & {
|
|
13
13
|
webSocketRelay: WebSocketRelay | null;
|
|
14
14
|
};
|
|
15
15
|
export interface RuntimeServiceContext {
|
|
@@ -18,6 +18,13 @@ export interface RuntimeServiceContext {
|
|
|
18
18
|
notify(line: string): void;
|
|
19
19
|
requestLaunchTurn(notBefore?: number): Promise<void>;
|
|
20
20
|
resolveWorkerLaunch?: FacetManagerHostHooks['resolveWorkerLaunch'];
|
|
21
|
+
/**
|
|
22
|
+
* Hold the host actor in memory while a resident process runs:
|
|
23
|
+
* `armResidentKeepalive` (session/hibernation.ts) bound to the host's own
|
|
24
|
+
* scheduler — the fabric timer mux for the session DO, the embedder's
|
|
25
|
+
* lifecycle for a hosted runtime.
|
|
26
|
+
*/
|
|
27
|
+
armResidentKeepalive: () => void;
|
|
21
28
|
/** The host's own authority: a session has exactly one, and this is it. */
|
|
22
29
|
filesystem: () => NimbusFilesystemAuthority;
|
|
23
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../src/hosted/services.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,KAAK,oBAAoB,EAAE,KAAK,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAGlH,OAAO,EAAkC,KAAK,yBAAyB,EAAgB,MAAM,yCAAyC,CAAC;AAEvI,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAErE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAKxD,OAAO,EAAE,cAA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B,gBAAgB,CAAC,IAAI,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,GAAG,GAAG,IAAI,CA8EvI;AAEH,wBAAgB,YAAY,CAAC,IAAI,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,CAkB7L;AAEH,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,YAAY,CAAC,CA0CjK;AAEH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAMtH;AAEH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,kBAAkB,EAAE,cAAc,EAAE,qBAAqB,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAW1H;AAEH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,kBAAkB,EAAE,OAAO,EAAE,qBAAqB;;;;;oCArKkB,MAAM,KAAK,IAAI;gCAgFnB,MAAM,KAAK,IAAI,yBAAU,MAAM,SAAS,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC;6CAoBtD,MAAM,KAAK,IAAI;;;EA6E3I"}
|
package/dist/hosted/services.js
CHANGED
|
@@ -3,15 +3,15 @@ import { composeFacetManager } from "../facets/compose.js";
|
|
|
3
3
|
import { FacetProcessManager, textBytes } from "../facets/process.js";
|
|
4
4
|
import { ChildProcessSpawnPool } from "../loaders/child-process/spawn-pool.js";
|
|
5
5
|
import { CRED_KERNEL, CRED_SESSION_USER } from "@nimbus-sh/core/runtime/os-contracts.js";
|
|
6
|
-
import {
|
|
6
|
+
import { ProcessFiles } from "@nimbus-sh/core/runtime/process-files.js";
|
|
7
7
|
import { EsbuildBundlePool } from "../facets/esbuild-bundle-pool.js";
|
|
8
|
-
import {
|
|
8
|
+
import { supervisorEsbuildService } from "../facets/esbuild-transform.js";
|
|
9
9
|
import { CF_COMPAT_DATE } from "@nimbus-sh/core/constants.js";
|
|
10
10
|
import { notifyTerminalEvent } from "../runtime/process-logs-api.js";
|
|
11
11
|
// The supervisor terminates a facet's outbound sockets so inbound frames
|
|
12
12
|
// arrive as supervisor replies (VFS coherence witness 3).
|
|
13
13
|
import { WebSocketRelay } from "../session/ws-relay.js";
|
|
14
|
-
// ── Pure helpers
|
|
14
|
+
// ── Pure helpers in ../session/helpers.ts ────────
|
|
15
15
|
//
|
|
16
16
|
// renderNoDevServerHtml, BUNDLER_BIN_PREFIXES, NIMBUS_UNSUPPORTED_BINS,
|
|
17
17
|
// WRANGLER_IGNORED_FLAGS{,_WITH_VALUE}, WRANGLER_UNSUPPORTED_CONFIG_FIELDS,
|
|
@@ -69,15 +69,15 @@ export function ensureFacetManager(self, runtimeContext) {
|
|
|
69
69
|
// The manager reaches the disk behind the authority (boot images, the
|
|
70
70
|
// launch journal), so a host that credentials something other than this
|
|
71
71
|
// session's SQLite filesystem cannot compose one.
|
|
72
|
-
if (!(filesystem instanceof
|
|
73
|
-
throw new Error('Nimbus: the facet manager needs the session
|
|
72
|
+
if (!(filesystem instanceof ProcessFiles)) {
|
|
73
|
+
throw new Error('Nimbus: the facet manager needs the session ProcessFiles, not a foreign filesystem authority');
|
|
74
74
|
}
|
|
75
75
|
self.facetManagerComposed = composeFacetManager({
|
|
76
76
|
ctx: runtimeContext.ctx,
|
|
77
77
|
env: runtimeContext.env,
|
|
78
78
|
processes: self.processes,
|
|
79
79
|
portRegistry: self.portRegistry,
|
|
80
|
-
vfs: filesystem.
|
|
80
|
+
vfs: filesystem.engine,
|
|
81
81
|
filesystem,
|
|
82
82
|
...(self.esbuildService ? { esbuild: self.esbuildService } : {}),
|
|
83
83
|
hooks: {
|
|
@@ -92,6 +92,9 @@ export function ensureFacetManager(self, runtimeContext) {
|
|
|
92
92
|
self.processes.openInput(pid);
|
|
93
93
|
}
|
|
94
94
|
catch { }
|
|
95
|
+
// The one arming site: the journal's re-drive path comes back
|
|
96
|
+
// through this same hook. See ensureResidentKeepalive.
|
|
97
|
+
runtimeContext.armResidentKeepalive();
|
|
95
98
|
}
|
|
96
99
|
// Only surface long-running / user-visible spawns to keep
|
|
97
100
|
// the terminal uncluttered. Short `node <file>` evals also
|
|
@@ -110,12 +113,8 @@ export function ensureFacetManager(self, runtimeContext) {
|
|
|
110
113
|
});
|
|
111
114
|
}
|
|
112
115
|
const composed = self.facetManagerComposed;
|
|
113
|
-
//
|
|
114
|
-
//
|
|
115
|
-
// wasm-init twice. The session may construct it after the manager
|
|
116
|
-
// exists, so the share is re-offered on every call; FacetManager
|
|
117
|
-
// otherwise lazy-creates its own on first exec — same wasm bytes,
|
|
118
|
-
// same ~10ms init cost, just paid once per surface.
|
|
116
|
+
// The session may create its esbuild after the manager exists, so it is
|
|
117
|
+
// offered on every call. Either one runs in the session's esbuild facet.
|
|
119
118
|
if (self.esbuildService) {
|
|
120
119
|
composed.manager.setEsbuildService(self.esbuildService);
|
|
121
120
|
}
|
|
@@ -450,7 +449,7 @@ export async function ensureNpmInstaller(self, runtimeContext, onProgress) {
|
|
|
450
449
|
if (!self.esbuildService) {
|
|
451
450
|
if (!self.sqliteFs)
|
|
452
451
|
throw new Error('Session VFS is not initialized');
|
|
453
|
-
self.esbuildService =
|
|
452
|
+
self.esbuildService = supervisorEsbuildService(runtimeContext.ctx, runtimeContext.env, self.getFilesystemAuthority().namespaceFs(CRED_KERNEL));
|
|
454
453
|
}
|
|
455
454
|
// Lazy-load the installer (+ its ~216 KB resolver/facet/loader-pool
|
|
456
455
|
// subgraph) on first npm use so it stays out of the cold script-eval
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SDK's session surface, served by a hosted runtime.
|
|
3
|
+
*
|
|
4
|
+
* `Nimbus.fromSession` drives a `NimbusSandbox` over any object with the
|
|
5
|
+
* `_rpc*` methods a `NimbusSession` Durable Object answers. A hosted runtime
|
|
6
|
+
* has no such object of its own: its embedder's Durable Object owns it. So the
|
|
7
|
+
* runtime hands out this `RpcTarget`, and the embedder passes it wherever a
|
|
8
|
+
* sandbox client runs — another isolate included, since an `RpcTarget`
|
|
9
|
+
* crosses RPC as a stub whose calls run here.
|
|
10
|
+
*
|
|
11
|
+
* A session may be scoped. A scope confines two things: the one named shell
|
|
12
|
+
* its commands run in, and the identity every command and file operation
|
|
13
|
+
* runs as. The stub is the capability, so a caller that names another shell
|
|
14
|
+
* or identity is refused rather than obeyed; a scope that names no shell
|
|
15
|
+
* runs no command, since the only shell left to it is the embedder's own.
|
|
16
|
+
* The workspace's destruction stays with the embedder. Processes, ports,
|
|
17
|
+
* logs and applications are not confined: they are workspace-wide, as they
|
|
18
|
+
* are to the shell's own `ps`, `kill`, `logs` and `nimbus expose`/`app`.
|
|
19
|
+
*/
|
|
20
|
+
import { RpcTarget } from 'cloudflare:workers';
|
|
21
|
+
import { type VfsCred } from '@nimbus-sh/core/runtime/os-contracts.js';
|
|
22
|
+
import * as operations from '../session/programmatic.js';
|
|
23
|
+
export interface HostedSessionScope {
|
|
24
|
+
/** The only named shell a command may run in; every command must name it (`sandbox(id, { shellId })`). */
|
|
25
|
+
readonly shellId?: string;
|
|
26
|
+
/** The identity every command and file operation runs as. */
|
|
27
|
+
readonly cred?: VfsCred;
|
|
28
|
+
}
|
|
29
|
+
type RunCodeOptions = operations.ProgrammaticExecOptions & {
|
|
30
|
+
language?: 'javascript' | 'typescript' | 'python' | 'ruby' | 'shell';
|
|
31
|
+
install?: 'never' | 'ifMissing';
|
|
32
|
+
};
|
|
33
|
+
type Visibility = {
|
|
34
|
+
visibility?: 'scoped' | 'public';
|
|
35
|
+
name?: string;
|
|
36
|
+
};
|
|
37
|
+
export interface HostedSessionOwner extends operations.ProgrammaticHost {
|
|
38
|
+
noteClientActivity(): void;
|
|
39
|
+
}
|
|
40
|
+
export declare class HostedSession extends RpcTarget {
|
|
41
|
+
private readonly owner;
|
|
42
|
+
private readonly scope;
|
|
43
|
+
constructor(owner: HostedSessionOwner, scope: HostedSessionScope);
|
|
44
|
+
/** Every call is a client's, as every `composeHostedRuntime` call is: it notes activity for the resident keep-alive. */
|
|
45
|
+
private client;
|
|
46
|
+
/**
|
|
47
|
+
* The identity a call acts as. A scoped session always names one: its own,
|
|
48
|
+
* or the session user every command runs as by default, so no verb's own
|
|
49
|
+
* default (the kernel, for `files.delete`) applies to it.
|
|
50
|
+
*/
|
|
51
|
+
private cred;
|
|
52
|
+
private exec;
|
|
53
|
+
_rpcReady(options?: operations.ProgrammaticReadyOptions): Promise<{
|
|
54
|
+
ok: true;
|
|
55
|
+
preinstalled: string[];
|
|
56
|
+
}>;
|
|
57
|
+
_rpcExecStream(command: string, options?: operations.ProgrammaticExecOptions): Promise<ReadableStream<Uint8Array>>;
|
|
58
|
+
_rpcStartProcess(command: string, options?: operations.ProgrammaticExecOptions): Promise<operations.ProgrammaticStartResult>;
|
|
59
|
+
_rpcRunCode(code: string, options?: RunCodeOptions): Promise<import("@nimbus-sh/core/runtime/exec-stream.js").ExecOutput>;
|
|
60
|
+
_rpcReadFile(path: string, _pid?: undefined, cred?: VfsCred): Promise<string | null>;
|
|
61
|
+
_rpcReadFileBytes(path: string, _pid?: undefined, cred?: VfsCred): Promise<Uint8Array | null>;
|
|
62
|
+
_rpcWriteFile(path: string, content: string | Uint8Array, _pid?: undefined, cred?: VfsCred): Promise<void>;
|
|
63
|
+
_rpcStat(path: string, _pid?: undefined, cred?: VfsCred): Promise<any>;
|
|
64
|
+
_rpcLstat(path: string, _pid?: undefined, cred?: VfsCred): Promise<any>;
|
|
65
|
+
_rpcReaddir(path: string, _pid?: undefined, cred?: VfsCred): Promise<{
|
|
66
|
+
name: string;
|
|
67
|
+
type: string;
|
|
68
|
+
}[]>;
|
|
69
|
+
_rpcRename(from: string, to: string, _pid?: undefined, cred?: VfsCred): Promise<void>;
|
|
70
|
+
_rpcChmod(path: string, mode: number, _pid?: undefined, cred?: VfsCred): Promise<void>;
|
|
71
|
+
_rpcFsReadRange(path: string, offset: number, length: number, _pid?: undefined, cred?: VfsCred): Promise<Uint8Array<ArrayBufferLike> | null>;
|
|
72
|
+
_rpcExists(path: string, _pid?: undefined, cred?: VfsCred): Promise<boolean>;
|
|
73
|
+
_rpcMkdir(path: string, _pid?: undefined, cred?: VfsCred): Promise<void>;
|
|
74
|
+
_rpcDeleteFile(path: string, options?: {
|
|
75
|
+
recursive?: boolean;
|
|
76
|
+
}, cred?: VfsCred): Promise<void>;
|
|
77
|
+
_rpcInstallRuntime(spec: string, options?: {
|
|
78
|
+
force?: boolean;
|
|
79
|
+
}): Promise<import("../runtime/package-manager.js").RuntimeInstallSummary>;
|
|
80
|
+
_rpcEnsureRuntimes(specs: string[], options?: {
|
|
81
|
+
force?: boolean;
|
|
82
|
+
}): Promise<import("../runtime/package-manager.js").RuntimeInstallSummary[]>;
|
|
83
|
+
_rpcListRuntimes(): Promise<{
|
|
84
|
+
installed: import("@nimbus-sh/core/runtime/installed-runtimes.js").RuntimeSummary[];
|
|
85
|
+
available: import("@nimbus-sh/core/runtime/runtime-package.js").RuntimeAvailability[];
|
|
86
|
+
}>;
|
|
87
|
+
_rpcListProcesses(): Promise<operations.SerializedProcess[]>;
|
|
88
|
+
_rpcKillProcess(pid: number): Promise<{
|
|
89
|
+
ok: boolean;
|
|
90
|
+
pid: number;
|
|
91
|
+
}>;
|
|
92
|
+
_rpcWriteProcessInput(pid: number, data: string): Promise<{
|
|
93
|
+
ok: boolean;
|
|
94
|
+
pid: number;
|
|
95
|
+
}>;
|
|
96
|
+
_rpcEndProcessInput(pid: number): Promise<{
|
|
97
|
+
ok: boolean;
|
|
98
|
+
pid: number;
|
|
99
|
+
}>;
|
|
100
|
+
_rpcResizeProcess(pid: number, size: {
|
|
101
|
+
columns: number;
|
|
102
|
+
rows: number;
|
|
103
|
+
}): Promise<{
|
|
104
|
+
ok: boolean;
|
|
105
|
+
pid: number;
|
|
106
|
+
}>;
|
|
107
|
+
_rpcSignalProcess(pid: number, signal: string): Promise<{
|
|
108
|
+
ok: boolean;
|
|
109
|
+
pid: number;
|
|
110
|
+
}>;
|
|
111
|
+
_rpcProcessLogs(pid: number, options?: {
|
|
112
|
+
cursor?: number;
|
|
113
|
+
lines?: number;
|
|
114
|
+
bytes?: number;
|
|
115
|
+
}): Promise<{
|
|
116
|
+
pid: number;
|
|
117
|
+
chunks: import("@nimbus-sh/core/runtime/process-logs.js").SequencedLogChunk[];
|
|
118
|
+
text: string;
|
|
119
|
+
cursor: number;
|
|
120
|
+
truncated: boolean;
|
|
121
|
+
exit: import("@nimbus-sh/core/runtime/process-logs.js").ProcessExitInfo | null;
|
|
122
|
+
}>;
|
|
123
|
+
_rpcListPorts(): Promise<operations.SerializedPort[]>;
|
|
124
|
+
_rpcExposePort(port: number, options?: Visibility): Promise<{
|
|
125
|
+
port: number;
|
|
126
|
+
listening: boolean;
|
|
127
|
+
pid: number | null;
|
|
128
|
+
registeredAt: number | null;
|
|
129
|
+
capability: string | null;
|
|
130
|
+
visibility: "scoped" | "public";
|
|
131
|
+
owner: string | null;
|
|
132
|
+
name: string | null;
|
|
133
|
+
}>;
|
|
134
|
+
_rpcUnexposePort(port: number): Promise<{
|
|
135
|
+
port: number;
|
|
136
|
+
ok: boolean;
|
|
137
|
+
}>;
|
|
138
|
+
_rpcListApps(): Promise<operations.ListedApp[]>;
|
|
139
|
+
_rpcExposeApp(target: operations.AppTarget, options?: Visibility): Promise<operations.ExposedAppResult>;
|
|
140
|
+
_rpcRotateLink(target: operations.AppTarget): Promise<operations.ExposedAppResult>;
|
|
141
|
+
_rpcRemoveApp(target: operations.AppTarget): Promise<{
|
|
142
|
+
owner: string;
|
|
143
|
+
removed: boolean;
|
|
144
|
+
port: number | null;
|
|
145
|
+
}>;
|
|
146
|
+
_rpcEnsureDurableApp(input: {
|
|
147
|
+
owner: string;
|
|
148
|
+
preferredPort?: number;
|
|
149
|
+
visibility?: 'scoped' | 'public';
|
|
150
|
+
name?: string;
|
|
151
|
+
}): Promise<{
|
|
152
|
+
port: number;
|
|
153
|
+
capability: string | null;
|
|
154
|
+
visibility: "scoped" | "public";
|
|
155
|
+
}>;
|
|
156
|
+
_rpcRemoveDurableApp(owner: string): Promise<{
|
|
157
|
+
owner: string;
|
|
158
|
+
removed: boolean;
|
|
159
|
+
port: number | null;
|
|
160
|
+
}>;
|
|
161
|
+
/** The embedder owns the workspace's life; a session it handed out cannot end it. */
|
|
162
|
+
_rpcDestroy(): Promise<never>;
|
|
163
|
+
}
|
|
164
|
+
export {};
|
|
165
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/hosted/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAG1F,OAAO,KAAK,UAAU,MAAM,4BAA4B,CAAC;AAEzD,MAAM,WAAW,kBAAkB;IACjC,0GAA0G;IAC1G,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,6DAA6D;IAC7D,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,KAAK,cAAc,GAAG,UAAU,CAAC,uBAAuB,GAAG;IACzD,QAAQ,CAAC,EAAE,YAAY,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;IACrE,OAAO,CAAC,EAAE,O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,IAAI,OAAO,CAAC,KAAK,CAAC;CAGpC"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SDK's session surface, served by a hosted runtime.
|
|
3
|
+
*
|
|
4
|
+
* `Nimbus.fromSession` drives a `NimbusSandbox` over any object with the
|
|
5
|
+
* `_rpc*` methods a `NimbusSession` Durable Object answers. A hosted runtime
|
|
6
|
+
* has no such object of its own: its embedder's Durable Object owns it. So the
|
|
7
|
+
* runtime hands out this `RpcTarget`, and the embedder passes it wherever a
|
|
8
|
+
* sandbox client runs — another isolate included, since an `RpcTarget`
|
|
9
|
+
* crosses RPC as a stub whose calls run here.
|
|
10
|
+
*
|
|
11
|
+
* A session may be scoped. A scope confines two things: the one named shell
|
|
12
|
+
* its commands run in, and the identity every command and file operation
|
|
13
|
+
* runs as. The stub is the capability, so a caller that names another shell
|
|
14
|
+
* or identity is refused rather than obeyed; a scope that names no shell
|
|
15
|
+
* runs no command, since the only shell left to it is the embedder's own.
|
|
16
|
+
* The workspace's destruction stays with the embedder. Processes, ports,
|
|
17
|
+
* logs and applications are not confined: they are workspace-wide, as they
|
|
18
|
+
* are to the shell's own `ps`, `kill`, `logs` and `nimbus expose`/`app`.
|
|
19
|
+
*/
|
|
20
|
+
import { RpcTarget } from 'cloudflare:workers';
|
|
21
|
+
import { CRED_SESSION_USER } from '@nimbus-sh/core/runtime/os-contracts.js';
|
|
22
|
+
import { encodeExecStream } from '@nimbus-sh/core/runtime/exec-stream.js';
|
|
23
|
+
import * as rpc from '../session/rpc.js';
|
|
24
|
+
import * as operations from '../session/programmatic.js';
|
|
25
|
+
function sameCred(a, b) {
|
|
26
|
+
return a.uid === b.uid && a.gid === b.gid && a.umask === b.umask
|
|
27
|
+
&& a.groups.length === b.groups.length && a.groups.every((group, index) => group === b.groups[index]);
|
|
28
|
+
}
|
|
29
|
+
export class HostedSession extends RpcTarget {
|
|
30
|
+
owner;
|
|
31
|
+
scope;
|
|
32
|
+
constructor(owner, scope) {
|
|
33
|
+
super();
|
|
34
|
+
this.owner = owner;
|
|
35
|
+
const { shellId, cred } = scope;
|
|
36
|
+
this.scope = shellId === undefined && cred === undefined ? null : Object.freeze({ shellId, cred });
|
|
37
|
+
}
|
|
38
|
+
/** Every call is a client's, as every `composeHostedRuntime` call is: it notes activity for the resident keep-alive. */
|
|
39
|
+
client() {
|
|
40
|
+
this.owner.noteClientActivity();
|
|
41
|
+
return this.owner;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The identity a call acts as. A scoped session always names one: its own,
|
|
45
|
+
* or the session user every command runs as by default, so no verb's own
|
|
46
|
+
* default (the kernel, for `files.delete`) applies to it.
|
|
47
|
+
*/
|
|
48
|
+
cred(asked) {
|
|
49
|
+
if (this.scope === null)
|
|
50
|
+
return asked;
|
|
51
|
+
const bound = this.scope.cred ?? CRED_SESSION_USER;
|
|
52
|
+
if (asked !== undefined && !sameCred(bound, asked))
|
|
53
|
+
throw new Error('EPERM: this session is bound to another identity');
|
|
54
|
+
return bound;
|
|
55
|
+
}
|
|
56
|
+
exec(options) {
|
|
57
|
+
if (this.scope !== null && (this.scope.shellId === undefined || options?.shellId !== this.scope.shellId)) {
|
|
58
|
+
// Named, never defaulted: a client that omits the shell also sends a cwd
|
|
59
|
+
// for the session's one shell, which would pin the named shell's cwd.
|
|
60
|
+
// A scope without a shell would run on the embedder's workspace shell,
|
|
61
|
+
// reading and planting its environment, so it runs nothing.
|
|
62
|
+
throw new Error(this.scope.shellId === undefined
|
|
63
|
+
? 'EPERM: this session names no shell, so it runs no command'
|
|
64
|
+
: `EPERM: this session runs commands only in shell '${this.scope.shellId}'; name it`);
|
|
65
|
+
}
|
|
66
|
+
const cred = this.cred(options?.cred);
|
|
67
|
+
return { ...options, ...(cred === undefined ? {} : { cred }) };
|
|
68
|
+
}
|
|
69
|
+
_rpcReady(options) { return operations.ensureProgrammaticReady(this.client(), options); }
|
|
70
|
+
async _rpcExecStream(command, options) {
|
|
71
|
+
return encodeExecStream(await operations.rpcExecStream(this.client(), command, this.exec(options)));
|
|
72
|
+
}
|
|
73
|
+
async _rpcStartProcess(command, options) {
|
|
74
|
+
return operations.rpcStartProcess(this.client(), command, this.exec(options));
|
|
75
|
+
}
|
|
76
|
+
async _rpcRunCode(code, options) { return operations.rpcRunCode(this.client(), code, this.exec(options)); }
|
|
77
|
+
// The file methods keep the session's wire shape: the third slot is a
|
|
78
|
+
// process claim no SDK caller makes, and is not accepted here either.
|
|
79
|
+
async _rpcReadFile(path, _pid, cred) {
|
|
80
|
+
return rpc._rpcReadFile(this.client(), path, undefined, this.cred(cred));
|
|
81
|
+
}
|
|
82
|
+
async _rpcReadFileBytes(path, _pid, cred) {
|
|
83
|
+
return rpc._rpcReadFileBytes(this.client(), path, undefined, this.cred(cred));
|
|
84
|
+
}
|
|
85
|
+
async _rpcWriteFile(path, content, _pid, cred) {
|
|
86
|
+
await rpc._rpcWriteFile(this.client(), path, content, undefined, this.cred(cred));
|
|
87
|
+
}
|
|
88
|
+
async _rpcStat(path, _pid, cred) { return rpc._rpcStat(this.client(), path, undefined, this.cred(cred)); }
|
|
89
|
+
async _rpcLstat(path, _pid, cred) { return rpc._rpcLstat(this.client(), path, undefined, this.cred(cred)); }
|
|
90
|
+
async _rpcReaddir(path, _pid, cred) { return rpc._rpcReaddir(this.client(), path, undefined, this.cred(cred)); }
|
|
91
|
+
async _rpcRename(from, to, _pid, cred) {
|
|
92
|
+
return rpc._rpcRename(this.client(), from, to, undefined, this.cred(cred));
|
|
93
|
+
}
|
|
94
|
+
async _rpcChmod(path, mode, _pid, cred) {
|
|
95
|
+
return rpc._rpcChmod(this.client(), path, mode, undefined, this.cred(cred));
|
|
96
|
+
}
|
|
97
|
+
async _rpcFsReadRange(path, offset, length, _pid, cred) {
|
|
98
|
+
return rpc._rpcFsReadRange(this.client(), path, offset, length, undefined, this.cred(cred));
|
|
99
|
+
}
|
|
100
|
+
async _rpcExists(path, _pid, cred) { return rpc._rpcExists(this.client(), path, undefined, this.cred(cred)); }
|
|
101
|
+
async _rpcMkdir(path, _pid, cred) { return rpc._rpcMkdir(this.client(), path, undefined, this.cred(cred)); }
|
|
102
|
+
async _rpcDeleteFile(path, options, cred) {
|
|
103
|
+
return operations.rpcDeleteFile(this.client(), path, options, this.cred(cred));
|
|
104
|
+
}
|
|
105
|
+
_rpcInstallRuntime(spec, options) { return operations.rpcInstallRuntime(this.client(), spec, options); }
|
|
106
|
+
_rpcEnsureRuntimes(specs, options) { return operations.rpcEnsureRuntimes(this.client(), specs, options); }
|
|
107
|
+
_rpcListRuntimes() { return operations.rpcListRuntimes(this.client()); }
|
|
108
|
+
_rpcListProcesses() { return operations.rpcListProcesses(this.client()); }
|
|
109
|
+
_rpcKillProcess(pid) { return operations.rpcKillProcess(this.client(), pid); }
|
|
110
|
+
_rpcWriteProcessInput(pid, data) { return operations.rpcWriteProcessInput(this.client(), pid, data); }
|
|
111
|
+
_rpcEndProcessInput(pid) { return operations.rpcEndProcessInput(this.client(), pid); }
|
|
112
|
+
_rpcResizeProcess(pid, size) { return operations.rpcResizeProcess(this.client(), pid, size); }
|
|
113
|
+
_rpcSignalProcess(pid, signal) { return operations.rpcSignalProcess(this.client(), pid, signal); }
|
|
114
|
+
_rpcProcessLogs(pid, options) {
|
|
115
|
+
return operations.rpcProcessLogs(this.client(), pid, options);
|
|
116
|
+
}
|
|
117
|
+
_rpcListPorts() { return operations.rpcListPorts(this.client()); }
|
|
118
|
+
_rpcExposePort(port, options) { return operations.rpcExposePort(this.client(), port, options); }
|
|
119
|
+
_rpcUnexposePort(port) { return operations.rpcUnexposePort(this.client(), port); }
|
|
120
|
+
_rpcListApps() { return operations.rpcListApps(this.client()); }
|
|
121
|
+
_rpcExposeApp(target, options) { return operations.rpcExposeApp(this.client(), target, options); }
|
|
122
|
+
_rpcRotateLink(target) { return operations.rpcRotateLink(this.client(), target); }
|
|
123
|
+
_rpcRemoveApp(target) { return operations.rpcRemoveApp(this.client(), target); }
|
|
124
|
+
_rpcEnsureDurableApp(input) {
|
|
125
|
+
return operations.rpcEnsureDurableApp(this.client(), input);
|
|
126
|
+
}
|
|
127
|
+
_rpcRemoveDurableApp(owner) { return operations.rpcRemoveDurableApp(this.client(), owner); }
|
|
128
|
+
/** The embedder owns the workspace's life; a session it handed out cannot end it. */
|
|
129
|
+
async _rpcDestroy() {
|
|
130
|
+
throw new Error('EPERM: a hosted session cannot destroy the workspace; its embedder closes the runtime');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
* Produced by scripts/bundle-facet-workers.mjs from:
|
|
5
5
|
* - @nimbus-sh/core src/_shared/tarball-stream.ts (streaming tar primitives)
|
|
6
6
|
* - @nimbus-sh/platform src/w7-frame.ts (W7 streaming bulk-write encoder)
|
|
7
|
+
* - @nimbus-sh/core src/_shared/esm-resolver.ts (Node's ESM resolver, for the node shims)
|
|
7
8
|
*
|
|
8
|
-
* Consumed by
|
|
9
|
+
* Consumed by fabric/isolate-pool.ts callers via the `preamble`
|
|
9
10
|
* option. The preamble is injected at the top of every generated
|
|
10
11
|
* worker module so user functions can reference the exported
|
|
11
12
|
* helpers by name.
|
|
@@ -15,9 +16,11 @@
|
|
|
15
16
|
* W7-frame symbols: encodeWriteBatchStream, decodeWriteBatchStream,
|
|
16
17
|
* W7_MAGIC, W7_MAX_RECORD_BYTES.
|
|
17
18
|
*
|
|
18
|
-
* Tar size: 4.
|
|
19
|
-
* W7 size:
|
|
19
|
+
* Tar size: 4.58 KiB
|
|
20
|
+
* W7 size: 30.14 KiB
|
|
20
21
|
*/
|
|
21
22
|
export declare const TAR_STREAM_PREAMBLE: string;
|
|
22
23
|
export declare const W7_FRAME_PREAMBLE: string;
|
|
24
|
+
/** Declares `function createEsmResolver(host)`; the node shims call it. */
|
|
25
|
+
export declare const ESM_RESOLVER_PREAMBLE: string;
|
|
23
26
|
//# sourceMappingURL=generated-workers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generated-workers.d.ts","sourceRoot":"","sources":["../../src/loaders/generated-workers.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"generated-workers.d.ts","sourceRoot":"","sources":["../../src/loaders/generated-workers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,eAAO,MAAM,mBAAmB,EAAE,MAAwyJ,CAAC;AAE30J,eAAO,MAAM,iBAAiB,EAAE,MAAyt+B,CAAC;AAE1v+B,2EAA2E;AAC3E,eAAO,MAAM,qBAAqB,EAAE,MAA6uuB,CAAC"}
|