@nimbus-sh/worker 0.4.0 → 0.6.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 +46 -43
- package/dist/_shared/preview-host.d.ts +33 -2
- package/dist/_shared/preview-host.d.ts.map +1 -1
- package/dist/_shared/preview-host.js +73 -8
- package/dist/_shared/session-router.d.ts +43 -0
- package/dist/_shared/session-router.d.ts.map +1 -1
- package/dist/_shared/session-router.js +59 -12
- package/dist/facets/durable-images.d.ts +59 -0
- package/dist/facets/durable-images.d.ts.map +1 -0
- package/dist/facets/durable-images.js +94 -0
- package/dist/facets/durable-slots.d.ts +45 -0
- package/dist/facets/durable-slots.d.ts.map +1 -0
- package/dist/facets/durable-slots.js +95 -0
- package/dist/facets/esbuild-transform.d.ts +10 -0
- package/dist/facets/esbuild-transform.d.ts.map +1 -0
- package/dist/facets/esbuild-transform.js +36 -0
- package/dist/facets/manager.d.ts +244 -6
- package/dist/facets/manager.d.ts.map +1 -1
- package/dist/facets/manager.js +901 -117
- package/dist/facets/resident-identity.d.ts +23 -0
- package/dist/facets/resident-identity.d.ts.map +1 -0
- package/dist/facets/resident-identity.js +31 -0
- package/dist/git/commands.d.ts +22 -1
- package/dist/git/commands.d.ts.map +1 -1
- package/dist/git/commands.js +429 -425
- package/dist/git-bundle.generated.d.ts +2 -2
- package/dist/git-bundle.generated.d.ts.map +1 -1
- package/dist/git-bundle.generated.js +3 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/node-shims-artifact.generated.js +3 -3
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +97 -3
- package/dist/router/public-directory-do.d.ts +17 -0
- package/dist/router/public-directory-do.d.ts.map +1 -0
- package/dist/router/public-directory-do.js +16 -0
- package/dist/router/public-directory.d.ts +79 -0
- package/dist/router/public-directory.d.ts.map +1 -0
- package/dist/router/public-directory.js +122 -0
- package/dist/router/remote-api.d.ts +27 -1
- package/dist/router/remote-api.d.ts.map +1 -1
- package/dist/router/remote-api.js +48 -2
- package/dist/runtime/cpython-resident.d.ts.map +1 -1
- package/dist/runtime/cpython-resident.js +3 -1
- package/dist/runtime/node-shims.d.ts +4 -1
- package/dist/runtime/node-shims.d.ts.map +1 -1
- package/dist/runtime/node-shims.js +324 -6
- package/dist/runtime/package-manager.d.ts +44 -1
- package/dist/runtime/package-manager.d.ts.map +1 -1
- package/dist/runtime/package-manager.js +168 -3
- package/dist/runtime/ruby-resident.d.ts.map +1 -1
- package/dist/runtime/ruby-resident.js +2 -0
- package/dist/session/agent.d.ts +11 -0
- package/dist/session/agent.d.ts.map +1 -1
- package/dist/session/agent.js +28 -1
- package/dist/session/helpers.js +1 -1
- package/dist/session/init-phases.d.ts +17 -23
- package/dist/session/init-phases.d.ts.map +1 -1
- package/dist/session/init-phases.js +17 -41
- package/dist/session/init.d.ts.map +1 -1
- package/dist/session/init.js +28 -15
- package/dist/session/keys.d.ts +12 -0
- package/dist/session/keys.d.ts.map +1 -1
- package/dist/session/keys.js +12 -0
- package/dist/session/nimbus-session.d.ts +63 -5
- package/dist/session/nimbus-session.d.ts.map +1 -1
- package/dist/session/nimbus-session.js +131 -17
- package/dist/session/port-capability.d.ts +141 -8
- package/dist/session/port-capability.d.ts.map +1 -1
- package/dist/session/port-capability.js +265 -8
- package/dist/session/programmatic.d.ts +145 -3
- package/dist/session/programmatic.d.ts.map +1 -1
- package/dist/session/programmatic.js +434 -12
- package/dist/session/routes.d.ts +26 -0
- package/dist/session/routes.d.ts.map +1 -1
- package/dist/session/routes.js +117 -25
- package/dist/session/rpc.d.ts +24 -1
- package/dist/session/rpc.d.ts.map +1 -1
- package/dist/session/rpc.js +65 -98
- package/dist/session/shell-socket.d.ts +76 -0
- package/dist/session/shell-socket.d.ts.map +1 -0
- package/dist/session/shell-socket.js +172 -0
- package/dist/session/start-real-vite.js +1 -1
- package/dist/session/supervisor-op.d.ts +42 -0
- package/dist/session/supervisor-op.d.ts.map +1 -0
- package/dist/session/supervisor-op.js +96 -0
- package/dist/session/supervisor-rpc.d.ts +6 -10
- package/dist/session/supervisor-rpc.d.ts.map +1 -1
- package/dist/session/supervisor-rpc.js +91 -71
- package/dist/session/ws.d.ts.map +1 -1
- package/dist/session/ws.js +19 -4
- package/package.json +4 -4
- package/public/_assets/runtime/{node-shims-fea906843f6d594e.js → node-shims-9e1380d9ee430fcc.js} +320 -5
- package/public/s/index.html +101 -5
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The session's supervisor-op handler — one `createSupervisorOpHandler`
|
|
3
|
+
* built over this session's own SQLite filesystem, process table and `_rpc*`
|
|
4
|
+
* surface, so the same code serves process facets, the facet loopback stubs
|
|
5
|
+
* and the SDK's direct `_rpc*` calls.
|
|
6
|
+
*
|
|
7
|
+
* - The native filesystem ops in core's `ops` table run in-process against
|
|
8
|
+
* the shared bridge store — the same cache `supervisorBridge` hands the
|
|
9
|
+
* handle-based and append RPC bodies.
|
|
10
|
+
* - `readFile`, `readFileBytes`, `fsReadRange`, `fsReadRangeUncached` and
|
|
11
|
+
* `writeBatchStream` are overridden here, not replaced: they are the ops
|
|
12
|
+
* that carry this DO's heap accounting (read-allocation leases, the
|
|
13
|
+
* write-stream's decode-drain timestamp).
|
|
14
|
+
* - Every other named op dispatches through `SUPERVISOR_OP_ROUTES` to the
|
|
15
|
+
* session's `_rpc*` methods — `host` IS the session — exactly as the
|
|
16
|
+
* canonical route table maps them.
|
|
17
|
+
*/
|
|
18
|
+
import { type SupervisorOpBridgeStore, type SupervisorOpEnvelope } from '@nimbus-sh/core/workspace/supervisor-op.js';
|
|
19
|
+
import type { SqliteRuntimeFsBridge } from '@nimbus-sh/core/runtime/sqlite-runtime-fs-bridge.js';
|
|
20
|
+
import type { SqliteVFS } from '@nimbus-sh/core/vfs/sqlite-vfs.js';
|
|
21
|
+
import type { SessionProcessSupervisor } from '@nimbus-sh/core/runtime/session-process-supervisor.js';
|
|
22
|
+
/**
|
|
23
|
+
* The supervisor surface a session exposes to the handler: the `_rpc*`
|
|
24
|
+
* methods SUPERVISOR_OP_ROUTES can name plus the filesystem and process
|
|
25
|
+
* accessors the overrides read. Deliberately not an index-signature record —
|
|
26
|
+
* a class can't carry one, and the handler only ever reads named routes.
|
|
27
|
+
*/
|
|
28
|
+
export interface SessionSupervisorHost {
|
|
29
|
+
ensureSqliteFs(): void;
|
|
30
|
+
readonly sqliteFs: SqliteVFS | null;
|
|
31
|
+
readonly processes: SessionProcessSupervisor;
|
|
32
|
+
_rpcStdout(pid: number, data: string): Promise<void>;
|
|
33
|
+
_rpcStderr(pid: number, data: string): Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
export interface SessionSupervisorOps {
|
|
36
|
+
readonly dispatch: (envelope: SupervisorOpEnvelope) => Promise<unknown>;
|
|
37
|
+
readonly bridge: (pid?: number) => SqliteRuntimeFsBridge;
|
|
38
|
+
/** Drop a pid's bridge — a process exit ends its credential's validity. */
|
|
39
|
+
readonly forget: (pid: number) => void;
|
|
40
|
+
}
|
|
41
|
+
export declare function buildSessionSupervisorOps(host: SessionSupervisorHost, store?: SupervisorOpBridgeStore): SessionSupervisorOps;
|
|
42
|
+
//# sourceMappingURL=supervisor-op.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supervisor-op.d.ts","sourceRoot":"","sources":["../../src/session/supervisor-op.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,EAGL,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EAI1B,MAAM,4CAA4C,CAAC;AACpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AACjG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uDAAuD,CAAC;AAQtG;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,cAAc,IAAI,IAAI,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,wBAAwB,CAAC;IAC7C,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACrD,UAAU,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtD;AACD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,EAAE,CAAC,QAAQ,EAAE,oBAAoB,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACxE,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,EAAE,MAAM,KAAK,qBAAqB,CAAC;IACzD,2EAA2E;IAC3E,QAAQ,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACxC;AAED,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,qBAAqB,EAC3B,KAAK,CAAC,EAAE,uBAAuB,GAC9B,oBAAoB,CA8EtB"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The session's supervisor-op handler — one `createSupervisorOpHandler`
|
|
3
|
+
* built over this session's own SQLite filesystem, process table and `_rpc*`
|
|
4
|
+
* surface, so the same code serves process facets, the facet loopback stubs
|
|
5
|
+
* and the SDK's direct `_rpc*` calls.
|
|
6
|
+
*
|
|
7
|
+
* - The native filesystem ops in core's `ops` table run in-process against
|
|
8
|
+
* the shared bridge store — the same cache `supervisorBridge` hands the
|
|
9
|
+
* handle-based and append RPC bodies.
|
|
10
|
+
* - `readFile`, `readFileBytes`, `fsReadRange`, `fsReadRangeUncached` and
|
|
11
|
+
* `writeBatchStream` are overridden here, not replaced: they are the ops
|
|
12
|
+
* that carry this DO's heap accounting (read-allocation leases, the
|
|
13
|
+
* write-stream's decode-drain timestamp).
|
|
14
|
+
* - Every other named op dispatches through `SUPERVISOR_OP_ROUTES` to the
|
|
15
|
+
* session's `_rpc*` methods — `host` IS the session — exactly as the
|
|
16
|
+
* canonical route table maps them.
|
|
17
|
+
*/
|
|
18
|
+
import { createSupervisorOpHandler, createSupervisorBridgeStore, } from '@nimbus-sh/core/workspace/supervisor-op.js';
|
|
19
|
+
import { FsReadRangeArgsSchema, rangeReadBytes, withReadAllocation, } from './rpc.js';
|
|
20
|
+
import { dec } from '@nimbus-sh/core/_shared/bytes.js';
|
|
21
|
+
export function buildSessionSupervisorOps(host, store) {
|
|
22
|
+
host.ensureSqliteFs();
|
|
23
|
+
store ??= createSupervisorBridgeStore({ vfs: host.sqliteFs, processes: host.processes });
|
|
24
|
+
const extend = {
|
|
25
|
+
// The native ops whose session bodies carry accounting the bridge
|
|
26
|
+
// alone doesn't know: a read lease sized to what the file can return.
|
|
27
|
+
readFile: async (envelope, tools) => {
|
|
28
|
+
const path = envelope.args?.[0];
|
|
29
|
+
const fs = tools.bridge(envelope.pid);
|
|
30
|
+
const stat = await fs.stat(path);
|
|
31
|
+
if (!stat)
|
|
32
|
+
return null;
|
|
33
|
+
return withReadAllocation(stat.size, async () => {
|
|
34
|
+
const bytes = await fs.readFile(path);
|
|
35
|
+
return bytes ? dec.decode(bytes) : null;
|
|
36
|
+
});
|
|
37
|
+
},
|
|
38
|
+
readFileBytes: async (envelope, tools) => {
|
|
39
|
+
const path = envelope.args?.[0];
|
|
40
|
+
const fs = tools.bridge(envelope.pid);
|
|
41
|
+
const stat = await fs.stat(path);
|
|
42
|
+
if (!stat)
|
|
43
|
+
return null;
|
|
44
|
+
return withReadAllocation(stat.size, () => fs.readFile(path));
|
|
45
|
+
},
|
|
46
|
+
fsReadRange: async (envelope, tools) => {
|
|
47
|
+
const args = FsReadRangeArgsSchema.parse({
|
|
48
|
+
path: envelope.args?.[0],
|
|
49
|
+
offset: envelope.args?.[1],
|
|
50
|
+
length: envelope.args?.[2],
|
|
51
|
+
});
|
|
52
|
+
const fs = tools.bridge(envelope.pid);
|
|
53
|
+
return withReadAllocation(await rangeReadBytes(fs, args.path, args.offset, args.length), () => fs.readRange(args.path, args.offset, args.length));
|
|
54
|
+
},
|
|
55
|
+
fsReadRangeUncached: async (envelope, tools) => {
|
|
56
|
+
const args = FsReadRangeArgsSchema.parse({
|
|
57
|
+
path: envelope.args?.[0],
|
|
58
|
+
offset: envelope.args?.[1],
|
|
59
|
+
length: envelope.args?.[2],
|
|
60
|
+
});
|
|
61
|
+
const fs = tools.bridge(envelope.pid);
|
|
62
|
+
return withReadAllocation(await rangeReadBytes(fs, args.path, args.offset, args.length), () => fs.readRange(args.path, args.offset, args.length, { cached: false }));
|
|
63
|
+
},
|
|
64
|
+
// The write stream's decode-drain timestamp starts when the envelope
|
|
65
|
+
// arrives, not when the DO first reads it — the same contract
|
|
66
|
+
// _rpcWriteBatchStream has always had.
|
|
67
|
+
writeBatchStream: (envelope, tools) => {
|
|
68
|
+
if (!envelope.stream)
|
|
69
|
+
throw new Error('supervisor op writeBatchStream: no stream');
|
|
70
|
+
// Same contract _rpcWriteBatchStream had: a supplied pid must be a
|
|
71
|
+
// real process pid; only an absent pid is a host call.
|
|
72
|
+
const pid = envelope.pid;
|
|
73
|
+
if (pid !== undefined && (!Number.isInteger(pid) || pid <= 0)) {
|
|
74
|
+
throw new Error('filesystem RPC requires a valid process pid');
|
|
75
|
+
}
|
|
76
|
+
return tools.vfs.as(tools.cred(pid)).writeStream(envelope.stream, {
|
|
77
|
+
decodeDrainStartedAt: performance.now(),
|
|
78
|
+
mutationOwner: envelope.mutationOwner,
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
// stdout/stderr are session methods, not bridge ops: mirroring,
|
|
82
|
+
// log-append and prior-generation filtering all live in _rpcStdout.
|
|
83
|
+
stdout: (envelope) => host._rpcStdout(envelope.pid ?? 0, envelope.args?.[0]),
|
|
84
|
+
stderr: (envelope) => host._rpcStderr(envelope.pid ?? 0, envelope.args?.[0]),
|
|
85
|
+
};
|
|
86
|
+
const dispatch = createSupervisorOpHandler({
|
|
87
|
+
vfs: host.sqliteFs,
|
|
88
|
+
processes: host.processes,
|
|
89
|
+
// The session IS the host — its _rpc* methods are the route table's
|
|
90
|
+
// targets. The index signature exists on the declared surface only.
|
|
91
|
+
host: host,
|
|
92
|
+
bridge: store,
|
|
93
|
+
extend,
|
|
94
|
+
});
|
|
95
|
+
return { dispatch, bridge: store.bridge, forget: store.forget };
|
|
96
|
+
}
|
|
@@ -53,16 +53,12 @@ export type SupervisorCacheStatEvent = {
|
|
|
53
53
|
cacheKind: CacheKind;
|
|
54
54
|
};
|
|
55
55
|
export declare class SupervisorRPC extends WorkerEntrypoint {
|
|
56
|
-
/**
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
* discarded by the same call and never read by another (measured: two calls
|
|
63
|
-
* on one stub produced instances #3 and #4, each having served one call).
|
|
64
|
-
*/
|
|
65
|
-
private _getStub;
|
|
56
|
+
/** Resolve the composed host anew for each WorkerEntrypoint invocation. */
|
|
57
|
+
private _dispatch;
|
|
58
|
+
private _op;
|
|
59
|
+
/** Stamp filesystem credentials from the binding, not the supplied arguments. */
|
|
60
|
+
private _fsOp;
|
|
61
|
+
private _reportingPid;
|
|
66
62
|
private _call;
|
|
67
63
|
private _pid;
|
|
68
64
|
private _writerId;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"supervisor-rpc.d.ts","sourceRoot":"","sources":["../../src/session/supervisor-rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"supervisor-rpc.d.ts","sourceRoot":"","sources":["../../src/session/supervisor-rpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;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EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAIlF,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,OAAO,CAAC;QAAC,YAAY,EAAE,OAAO,CAAA;KAAE,CAAC;IAI1H,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI1D,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,OAAO,CAAC;QAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC;IAI1H;;;;;;;OAOG;IACG,gBAAgB,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QACtD,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;KAClD,CAAC;CAGH"}
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
* prefetch(cwd, entryCode) → Record<string, string>
|
|
30
30
|
*/
|
|
31
31
|
import { WorkerEntrypoint } from 'cloudflare:workers';
|
|
32
|
+
import { hostNamespace, hostDispatchMethod } from '@nimbus-sh/platform/composition.js';
|
|
32
33
|
// W5: OOM discriminator — record last-known RPC frame on writeBatch entry
|
|
33
34
|
import { setLastRpcFrame } from '@nimbus-sh/platform/oom-discriminator.js';
|
|
34
35
|
// Phase 2 A'.2 — supervisor in-flight RPC payload byte tracking.
|
|
@@ -78,21 +79,41 @@ function _estimateWriteBatchBytes(payload) {
|
|
|
78
79
|
// worker's composition root (src/index.ts) names this class to the fabric
|
|
79
80
|
// with composeFabric.
|
|
80
81
|
export class SupervisorRPC extends WorkerEntrypoint {
|
|
81
|
-
/**
|
|
82
|
-
|
|
83
|
-
*
|
|
84
|
-
* Minted per call, because that is the only lifetime an instance of this
|
|
85
|
-
* class has: workerd constructs a NEW WorkerEntrypoint for every RPC call,
|
|
86
|
-
* not one per facet invocation, so a field cached here is written and
|
|
87
|
-
* discarded by the same call and never read by another (measured: two calls
|
|
88
|
-
* on one stub produced instances #3 and #4, each having served one call).
|
|
89
|
-
*/
|
|
90
|
-
_getStub() {
|
|
82
|
+
/** Resolve the composed host anew for each WorkerEntrypoint invocation. */
|
|
83
|
+
_dispatch() {
|
|
91
84
|
const doId = this.ctx.props?.doId;
|
|
92
|
-
if (
|
|
85
|
+
if (typeof doId !== 'string' || doId.length === 0) {
|
|
93
86
|
throw new Error('SupervisorRPC: missing doId in props');
|
|
94
|
-
|
|
95
|
-
|
|
87
|
+
}
|
|
88
|
+
const binding = hostNamespace();
|
|
89
|
+
const namespace = Reflect.get(this.env, binding);
|
|
90
|
+
if (!namespace || typeof namespace.idFromString !== 'function') {
|
|
91
|
+
throw new Error(`SupervisorRPC: env.${binding} is not a Durable Object namespace; `
|
|
92
|
+
+ "a workspace host names its own with composeFabric({ hostNamespace: '<binding>' })");
|
|
93
|
+
}
|
|
94
|
+
const stub = namespace.get(namespace.idFromString(doId));
|
|
95
|
+
const method = hostDispatchMethod();
|
|
96
|
+
const dispatch = Reflect.get(stub, method);
|
|
97
|
+
if (typeof dispatch !== 'function') {
|
|
98
|
+
throw new Error(`SupervisorRPC: the workspace host mounts no ${method}(); `
|
|
99
|
+
+ 'a host forwards one method to workspace.supervisorOp(op)');
|
|
100
|
+
}
|
|
101
|
+
// Never `.call(stub, …)` on an RpcStub: the proxy treats `call` as a
|
|
102
|
+
// property get, which becomes an RPC to a method literally named "call".
|
|
103
|
+
// `Reflect.apply` reaches the proxied member's apply trap instead, and on
|
|
104
|
+
// a plain-object host it still invokes the method with the stub as `this`.
|
|
105
|
+
return (envelope) => Reflect.apply(dispatch, stub, [envelope]);
|
|
106
|
+
}
|
|
107
|
+
_op(op, args = [], extra = {}) {
|
|
108
|
+
return this._dispatch()({ op, args, ...extra });
|
|
109
|
+
}
|
|
110
|
+
/** Stamp filesystem credentials from the binding, not the supplied arguments. */
|
|
111
|
+
_fsOp(op, args = []) {
|
|
112
|
+
return this._op(op, args, { pid: this._pid() });
|
|
113
|
+
}
|
|
114
|
+
_reportingPid() {
|
|
115
|
+
const pid = this.ctx.props?.pid;
|
|
116
|
+
return typeof pid === 'number' && Number.isInteger(pid) && pid > 0 ? pid : 0;
|
|
96
117
|
}
|
|
97
118
|
_call(promise) {
|
|
98
119
|
return useRpcResource(promise, (value) => value);
|
|
@@ -113,14 +134,14 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
113
134
|
}
|
|
114
135
|
// ── Filesystem RPC ────────────────────────────────────────────────────
|
|
115
136
|
async readFile(path) {
|
|
116
|
-
return this._call(this.
|
|
137
|
+
return this._call(this._fsOp('readFile', [path]));
|
|
117
138
|
}
|
|
118
139
|
/**
|
|
119
140
|
* Read a file as raw bytes. Used by the git network facet for binary
|
|
120
141
|
* object/pack files where the text readFile would corrupt content.
|
|
121
142
|
*/
|
|
122
143
|
async readFileBytes(path) {
|
|
123
|
-
return this._call(this.
|
|
144
|
+
return this._call(this._fsOp('readFileBytes', [path]));
|
|
124
145
|
}
|
|
125
146
|
async writeFile(path, content) {
|
|
126
147
|
// binary-fs wave: accept Uint8Array natively. Pre-fix this RPC was
|
|
@@ -128,55 +149,55 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
128
149
|
// decode every Uint8Array write — mangling bytes ≥ 0x80 to U+FFFD
|
|
129
150
|
// and corrupting binary content. RPC structured-clone handles
|
|
130
151
|
// Uint8Array transparently; downstream _rpcWriteFile also accepts
|
|
131
|
-
return this._call(this.
|
|
152
|
+
return this._call(this._fsOp('writeFile', [path, content]));
|
|
132
153
|
}
|
|
133
154
|
async stat(path) {
|
|
134
|
-
return this._call(this.
|
|
155
|
+
return this._call(this._fsOp('stat', [path]));
|
|
135
156
|
}
|
|
136
157
|
async lstat(path) {
|
|
137
|
-
return this._call(this.
|
|
158
|
+
return this._call(this._fsOp('lstat', [path]));
|
|
138
159
|
}
|
|
139
160
|
async hasLegacySymlinkUnder(path) {
|
|
140
|
-
return this._call(this.
|
|
161
|
+
return this._call(this._fsOp('hasLegacySymlinkUnder', [path]));
|
|
141
162
|
}
|
|
142
163
|
async utimes(path, atimeMs, mtimeMs) {
|
|
143
|
-
return this._call(this.
|
|
164
|
+
return this._call(this._fsOp('utimes', [path, atimeMs, mtimeMs]));
|
|
144
165
|
}
|
|
145
166
|
async chmod(path, mode) {
|
|
146
|
-
return this._call(this.
|
|
167
|
+
return this._call(this._fsOp('chmod', [path, mode]));
|
|
147
168
|
}
|
|
148
169
|
async access(path, mode) {
|
|
149
|
-
return this._call(this.
|
|
170
|
+
return this._call(this._fsOp('access', [path, mode]));
|
|
150
171
|
}
|
|
151
172
|
async chown(path, uid, gid, options) {
|
|
152
|
-
return this._call(this.
|
|
173
|
+
return this._call(this._fsOp('chown', [path, uid, gid, options]));
|
|
153
174
|
}
|
|
154
175
|
async setUmask(mask) {
|
|
155
|
-
return this._call(this.
|
|
176
|
+
return this._call(this._fsOp('setUmask', [mask]));
|
|
156
177
|
}
|
|
157
178
|
async readdir(path) {
|
|
158
|
-
return this._call(this.
|
|
179
|
+
return this._call(this._fsOp('readdir', [path]));
|
|
159
180
|
}
|
|
160
181
|
async exists(path) {
|
|
161
|
-
return this._call(this.
|
|
182
|
+
return this._call(this._fsOp('exists', [path]));
|
|
162
183
|
}
|
|
163
184
|
async mkdir(path) {
|
|
164
|
-
return this._call(this.
|
|
185
|
+
return this._call(this._fsOp('mkdir', [path]));
|
|
165
186
|
}
|
|
166
187
|
async rmdir(path) {
|
|
167
|
-
return this._call(this.
|
|
188
|
+
return this._call(this._fsOp('rmdir', [path]));
|
|
168
189
|
}
|
|
169
190
|
async rename(from, to) {
|
|
170
|
-
return this._call(this.
|
|
191
|
+
return this._call(this._fsOp('rename', [from, to]));
|
|
171
192
|
}
|
|
172
193
|
async unlink(path) {
|
|
173
|
-
return this._call(this.
|
|
194
|
+
return this._call(this._fsOp('unlink', [path]));
|
|
174
195
|
}
|
|
175
196
|
async readlink(path) {
|
|
176
|
-
return this._call(this.
|
|
197
|
+
return this._call(this._fsOp('readlink', [path]));
|
|
177
198
|
}
|
|
178
199
|
async symlink(target, path) {
|
|
179
|
-
return this._call(this.
|
|
200
|
+
return this._call(this._fsOp('symlink', [target, path]));
|
|
180
201
|
}
|
|
181
202
|
/**
|
|
182
203
|
* ACQUIRE: the paths mutated since the facet's cursor, plus a fresh
|
|
@@ -190,10 +211,10 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
190
211
|
* disposal, which targets the returned value.
|
|
191
212
|
*/
|
|
192
213
|
async fsAcquire(epoch, cursor) {
|
|
193
|
-
return this._call(this.
|
|
214
|
+
return this._call(this._fsOp('fsAcquire', [epoch, cursor]));
|
|
194
215
|
}
|
|
195
216
|
async fsRevision(path) {
|
|
196
|
-
return this._call(this.
|
|
217
|
+
return this._call(this._fsOp('fsRevision', [path]));
|
|
197
218
|
}
|
|
198
219
|
/**
|
|
199
220
|
* Enumerate the session filesystem, one bounded page at a time.
|
|
@@ -213,7 +234,7 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
213
234
|
* never mistaken for a complete listing.
|
|
214
235
|
*/
|
|
215
236
|
async fsList(after, limit) {
|
|
216
|
-
return this._call(this.
|
|
237
|
+
return this._call(this._fsOp('fsList', [after ?? null, limit ?? null]));
|
|
217
238
|
}
|
|
218
239
|
/**
|
|
219
240
|
* WebSocket relay. A facet does not open its own sockets: the supervisor
|
|
@@ -224,28 +245,28 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
224
245
|
* facet's next synchronous read serves bytes the authority has replaced.
|
|
225
246
|
*/
|
|
226
247
|
async wsOpen(url, protocols) {
|
|
227
|
-
return this._call(this.
|
|
248
|
+
return this._call(this._fsOp('wsOpen', [url, protocols]));
|
|
228
249
|
}
|
|
229
250
|
async wsPoll(id, waitMs) {
|
|
230
|
-
return this._call(this.
|
|
251
|
+
return this._call(this._fsOp('wsPoll', [id, waitMs]));
|
|
231
252
|
}
|
|
232
253
|
async wsSend(id, text, bytes) {
|
|
233
|
-
return this._call(this.
|
|
254
|
+
return this._call(this._fsOp('wsSend', [id, text, bytes]));
|
|
234
255
|
}
|
|
235
256
|
async wsClose(id, code, reason) {
|
|
236
|
-
return this._call(this.
|
|
257
|
+
return this._call(this._fsOp('wsClose', [id, code, reason]));
|
|
237
258
|
}
|
|
238
259
|
async fsOpen(path, flags) {
|
|
239
|
-
return this._call(this.
|
|
260
|
+
return this._call(this._fsOp('fsOpen', [path, flags]));
|
|
240
261
|
}
|
|
241
262
|
async fsRead(handleId, offset, length) {
|
|
242
|
-
return this._call(this.
|
|
263
|
+
return this._call(this._fsOp('fsRead', [handleId, offset, length]));
|
|
243
264
|
}
|
|
244
265
|
async fsWrite(handleId, offset, bytes) {
|
|
245
|
-
return this._call(this.
|
|
266
|
+
return this._call(this._fsOp('fsWrite', [handleId, offset, bytes]));
|
|
246
267
|
}
|
|
247
268
|
async fsClose(handleId) {
|
|
248
|
-
return this._call(this.
|
|
269
|
+
return this._call(this._fsOp('fsClose', [handleId]));
|
|
249
270
|
}
|
|
250
271
|
/**
|
|
251
272
|
* Stateless ranged ops. Unlike fsOpen/fsRead/fsWrite they carry no
|
|
@@ -253,7 +274,7 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
253
274
|
* hibernation and never rewrite whole files for partial updates.
|
|
254
275
|
*/
|
|
255
276
|
async fsReadRange(path, offset, length) {
|
|
256
|
-
return this._call(this.
|
|
277
|
+
return this._call(this._fsOp('fsReadRange', [path, offset, length]));
|
|
257
278
|
}
|
|
258
279
|
/**
|
|
259
280
|
* The same read with the session's content cache bypassed, for a boot spec's
|
|
@@ -262,7 +283,7 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
262
283
|
* session's heap for the rest of its life.
|
|
263
284
|
*/
|
|
264
285
|
async fsReadRangeUncached(path, offset, length) {
|
|
265
|
-
return this._call(this.
|
|
286
|
+
return this._call(this._fsOp('fsReadRangeUncached', [path, offset, length]));
|
|
266
287
|
}
|
|
267
288
|
/**
|
|
268
289
|
* Read many ranges in ONE round trip — the read-side counterpart to
|
|
@@ -286,23 +307,23 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
286
307
|
setLastRpcFrame('fsReadBatch', payloadBytes);
|
|
287
308
|
rpcPayloadStart(payloadBytes);
|
|
288
309
|
try {
|
|
289
|
-
return await this._call(this.
|
|
310
|
+
return await this._call(this._fsOp('fsReadBatch', [requests]));
|
|
290
311
|
}
|
|
291
312
|
finally {
|
|
292
313
|
rpcPayloadEnd(payloadBytes);
|
|
293
314
|
}
|
|
294
315
|
}
|
|
295
316
|
async fsWriteRange(path, offset, bytes) {
|
|
296
|
-
return this._call(this.
|
|
317
|
+
return this._call(this._fsOp('fsWriteRange', [path, offset, bytes]));
|
|
297
318
|
}
|
|
298
319
|
async fsAppend(path, moduleId, operationId, bytes) {
|
|
299
|
-
return this._call(this.
|
|
320
|
+
return this._call(this._op('fsAppend', [path, moduleId, operationId, bytes], { pid: this._pid(), writerId: this._writerId() }));
|
|
300
321
|
}
|
|
301
322
|
async fsAppendAck(moduleId, operationId) {
|
|
302
|
-
return this._call(this.
|
|
323
|
+
return this._call(this._op('fsAppendAck', [moduleId, operationId], { pid: this._pid(), writerId: this._writerId() }));
|
|
303
324
|
}
|
|
304
325
|
async fsTruncate(path, size) {
|
|
305
|
-
return this._call(this.
|
|
326
|
+
return this._call(this._fsOp('fsTruncate', [path, size]));
|
|
306
327
|
}
|
|
307
328
|
/**
|
|
308
329
|
* Bulk-write all inodes + chunks in ONE transactionSync on the supervisor.
|
|
@@ -325,7 +346,7 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
325
346
|
setLastRpcFrame('writeBatch', payloadBytes);
|
|
326
347
|
rpcPayloadStart(payloadBytes);
|
|
327
348
|
try {
|
|
328
|
-
return await this._call(this.
|
|
349
|
+
return await this._call(this._fsOp('writeBatch', [payload]));
|
|
329
350
|
}
|
|
330
351
|
finally {
|
|
331
352
|
rpcPayloadEnd(payloadBytes);
|
|
@@ -356,7 +377,7 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
356
377
|
rpcPayloadStart(STREAM_RESIDENT_BYTES);
|
|
357
378
|
try {
|
|
358
379
|
const mutationOwner = this.ctx.props?.mutationOwner;
|
|
359
|
-
return await this._call(this.
|
|
380
|
+
return await this._call(this._op('writeBatchStream', [], { pid: this._pid(), mutationOwner: typeof mutationOwner === 'string' ? mutationOwner : undefined, stream }));
|
|
360
381
|
}
|
|
361
382
|
finally {
|
|
362
383
|
rpcPayloadEnd(STREAM_RESIDENT_BYTES);
|
|
@@ -384,7 +405,7 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
384
405
|
const payloadBytes = (Array.isArray(entries) ? entries.length : 0) * REGISTRY_ENTRY_BYTES;
|
|
385
406
|
rpcPayloadStart(payloadBytes);
|
|
386
407
|
try {
|
|
387
|
-
return await this._call(this.
|
|
408
|
+
return await this._call(this._op('putRegistryEntries', [entries]));
|
|
388
409
|
}
|
|
389
410
|
finally {
|
|
390
411
|
rpcPayloadEnd(payloadBytes);
|
|
@@ -477,10 +498,10 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
477
498
|
}
|
|
478
499
|
// ── Process I/O ───────────────────────────────────────────────────────
|
|
479
500
|
async stdout(data) {
|
|
480
|
-
return this._call(this.
|
|
501
|
+
return this._call(this._op('stdout', [data], { pid: this._reportingPid() }));
|
|
481
502
|
}
|
|
482
503
|
async stderr(data) {
|
|
483
|
-
return this._call(this.
|
|
504
|
+
return this._call(this._op('stderr', [data], { pid: this._reportingPid() }));
|
|
484
505
|
}
|
|
485
506
|
/**
|
|
486
507
|
* Report process exit to the supervisor. Called from the facet's own
|
|
@@ -492,19 +513,18 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
492
513
|
* via __pendingIO first).
|
|
493
514
|
*/
|
|
494
515
|
async reportExit(code, tail) {
|
|
495
|
-
|
|
496
|
-
return this._call(this._getStub()._rpcReportExit(pid, code, tail || ''));
|
|
516
|
+
return this._call(this._op('reportExit', [code, tail || ''], { pid: this._reportingPid() }));
|
|
497
517
|
}
|
|
498
518
|
// ── Prefetch ──────────────────────────────────────────────────────────
|
|
499
519
|
async prefetch(cwd, entryCode) {
|
|
500
|
-
return this._call(this.
|
|
520
|
+
return this._call(this._op('prefetch', [cwd, entryCode]));
|
|
501
521
|
}
|
|
502
522
|
// ── Port registration ─────────────────────────────────────────────────
|
|
503
523
|
async registerPort(port) {
|
|
504
|
-
return this._call(this.
|
|
524
|
+
return this._call(this._op('registerPort', [port], { pid: this._reportingPid() }));
|
|
505
525
|
}
|
|
506
526
|
async unregisterPort(port) {
|
|
507
|
-
return this._call(this.
|
|
527
|
+
return this._call(this._op('unregisterPort', [port]));
|
|
508
528
|
}
|
|
509
529
|
/**
|
|
510
530
|
* Route an in-session loopback HTTP request (a facet's fetch to
|
|
@@ -519,11 +539,11 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
519
539
|
* exactly how PortRegistry.routeRequest returns the facet's Response as-is.
|
|
520
540
|
*/
|
|
521
541
|
async routeLoopback(port, request) {
|
|
522
|
-
return this.
|
|
542
|
+
return this._op('routeLoopback', [port, request]);
|
|
523
543
|
}
|
|
524
544
|
// ── Esbuild transform ─────────────────────────────────────────────────
|
|
525
545
|
async transform(code, loader) {
|
|
526
|
-
return this._call(this.
|
|
546
|
+
return this._call(this._op('transform', [code, loader]));
|
|
527
547
|
}
|
|
528
548
|
// ── child_process [W8 Phase 1] ────────────────────────────────────────
|
|
529
549
|
//
|
|
@@ -532,28 +552,28 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
532
552
|
// route through the shared FacetProcessManager.
|
|
533
553
|
//
|
|
534
554
|
async cpSpawn(req) {
|
|
535
|
-
return this._call(this.
|
|
555
|
+
return this._call(this._op('cpSpawn', [{ ...req, parentPid: this._pid() }]));
|
|
536
556
|
}
|
|
537
557
|
async cpStdinWrite(childPid, data) {
|
|
538
|
-
return this._call(this.
|
|
558
|
+
return this._call(this._op('cpStdinWrite', [childPid, data]));
|
|
539
559
|
}
|
|
540
560
|
async cpStdinEnd(childPid) {
|
|
541
|
-
return this._call(this.
|
|
561
|
+
return this._call(this._op('cpStdinEnd', [childPid]));
|
|
542
562
|
}
|
|
543
563
|
async cpReadStdin(childPid, waitMs) {
|
|
544
|
-
return this._call(this.
|
|
564
|
+
return this._call(this._op('cpReadStdin', [childPid, waitMs]));
|
|
545
565
|
}
|
|
546
566
|
async cpReadOutput(childPid, fd, sinceSeq, waitMs) {
|
|
547
|
-
return this._call(this.
|
|
567
|
+
return this._call(this._op('cpReadOutput', [childPid, fd, sinceSeq, waitMs]));
|
|
548
568
|
}
|
|
549
569
|
async cpDrainOutput(childPid) {
|
|
550
|
-
return this._call(this.
|
|
570
|
+
return this._call(this._op('cpDrainOutput', [childPid]));
|
|
551
571
|
}
|
|
552
572
|
async cpKill(childPid, signal) {
|
|
553
|
-
return this._call(this.
|
|
573
|
+
return this._call(this._op('cpKill', [childPid, signal]));
|
|
554
574
|
}
|
|
555
575
|
async cpWait(childPid, waitMs) {
|
|
556
|
-
return this._call(this.
|
|
576
|
+
return this._call(this._op('cpWait', [childPid, waitMs]));
|
|
557
577
|
}
|
|
558
578
|
/**
|
|
559
579
|
* child-process isolation gap #1: dispatch a single cp.spawn request inline using
|
|
@@ -564,6 +584,6 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
564
584
|
* supervisor while keeping the dispatch envelope in a fresh isolate.
|
|
565
585
|
*/
|
|
566
586
|
async cpDispatchInline(req, kind) {
|
|
567
|
-
return this._call(this.
|
|
587
|
+
return this._call(this._op('cpDispatchInline', [req, kind]));
|
|
568
588
|
}
|
|
569
589
|
}
|
package/dist/session/ws.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../src/session/ws.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAOH,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,eAAe,CAAC;AAIvB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uDAAuD,CAAC;AACtG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"ws.d.ts","sourceRoot":"","sources":["../../src/session/ws.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAOH,OAAO,EAIL,KAAK,UAAU,EAChB,MAAM,eAAe,CAAC;AAIvB,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,uDAAuD,CAAC;AACtG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,yCAAyC,CAAC;AAG7E;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,QAAQ,EAAE,SAAS,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACnC,MAAM,EAAE,MAAM,GAAG,IAAI,C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