@nimbus-sh/worker 0.4.0 → 0.5.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 +14 -1
- package/dist/_shared/preview-host.d.ts.map +1 -1
- package/dist/_shared/preview-host.js +28 -3
- 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 +50 -0
- package/dist/facets/durable-images.d.ts.map +1 -0
- package/dist/facets/durable-images.js +75 -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 +94 -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 +160 -5
- package/dist/facets/manager.d.ts.map +1 -1
- package/dist/facets/manager.js +554 -97
- package/dist/git/commands.d.ts +22 -0
- package/dist/git/commands.d.ts.map +1 -1
- package/dist/git/commands.js +431 -424
- 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 +59 -2
- 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 +75 -0
- package/dist/router/public-directory.d.ts.map +1 -0
- package/dist/router/public-directory.js +115 -0
- package/dist/router/remote-api.d.ts +9 -1
- package/dist/router/remote-api.d.ts.map +1 -1
- package/dist/router/remote-api.js +19 -2
- 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/session/agent.d.ts +11 -0
- package/dist/session/agent.d.ts.map +1 -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 +19 -15
- package/dist/session/keys.d.ts +8 -0
- package/dist/session/keys.d.ts.map +1 -1
- package/dist/session/keys.js +8 -0
- package/dist/session/nimbus-session.d.ts +29 -4
- package/dist/session/nimbus-session.d.ts.map +1 -1
- package/dist/session/nimbus-session.js +62 -9
- package/dist/session/port-capability.d.ts +95 -8
- package/dist/session/port-capability.d.ts.map +1 -1
- package/dist/session/port-capability.js +165 -8
- package/dist/session/programmatic.d.ts +50 -2
- package/dist/session/programmatic.d.ts.map +1 -1
- package/dist/session/programmatic.js +104 -6
- package/dist/session/routes.d.ts +17 -0
- package/dist/session/routes.d.ts.map +1 -1
- package/dist/session/routes.js +92 -25
- package/dist/session/rpc.d.ts.map +1 -1
- package/dist/session/rpc.js +14 -4
- 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 +5 -0
- package/dist/session/supervisor-op.d.ts.map +1 -0
- package/dist/session/supervisor-op.js +74 -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 -70
- 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
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAStD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAC7F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAChF,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAUrE,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,wCAAwC,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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._fsOp('fsAppendAck', [this._writerId(), moduleId, operationId]));
|
|
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
|
|
@@ -493,18 +514,18 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
493
514
|
*/
|
|
494
515
|
async reportExit(code, tail) {
|
|
495
516
|
const pid = this.ctx.props?.pid || 0;
|
|
496
|
-
return this._call(this.
|
|
517
|
+
return this._call(this._op('reportExit', [code, tail || ''], { pid }));
|
|
497
518
|
}
|
|
498
519
|
// ── Prefetch ──────────────────────────────────────────────────────────
|
|
499
520
|
async prefetch(cwd, entryCode) {
|
|
500
|
-
return this._call(this.
|
|
521
|
+
return this._call(this._op('prefetch', [cwd, entryCode]));
|
|
501
522
|
}
|
|
502
523
|
// ── Port registration ─────────────────────────────────────────────────
|
|
503
524
|
async registerPort(port) {
|
|
504
|
-
return this._call(this.
|
|
525
|
+
return this._call(this._op('registerPort', [port], { pid: this._reportingPid() }));
|
|
505
526
|
}
|
|
506
527
|
async unregisterPort(port) {
|
|
507
|
-
return this._call(this.
|
|
528
|
+
return this._call(this._op('unregisterPort', [port]));
|
|
508
529
|
}
|
|
509
530
|
/**
|
|
510
531
|
* Route an in-session loopback HTTP request (a facet's fetch to
|
|
@@ -519,11 +540,11 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
519
540
|
* exactly how PortRegistry.routeRequest returns the facet's Response as-is.
|
|
520
541
|
*/
|
|
521
542
|
async routeLoopback(port, request) {
|
|
522
|
-
return this.
|
|
543
|
+
return this._op('routeLoopback', [port, request]);
|
|
523
544
|
}
|
|
524
545
|
// ── Esbuild transform ─────────────────────────────────────────────────
|
|
525
546
|
async transform(code, loader) {
|
|
526
|
-
return this._call(this.
|
|
547
|
+
return this._call(this._op('transform', [code, loader]));
|
|
527
548
|
}
|
|
528
549
|
// ── child_process [W8 Phase 1] ────────────────────────────────────────
|
|
529
550
|
//
|
|
@@ -532,28 +553,28 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
532
553
|
// route through the shared FacetProcessManager.
|
|
533
554
|
//
|
|
534
555
|
async cpSpawn(req) {
|
|
535
|
-
return this._call(this.
|
|
556
|
+
return this._call(this._op('cpSpawn', [{ ...req, parentPid: this._pid() }]));
|
|
536
557
|
}
|
|
537
558
|
async cpStdinWrite(childPid, data) {
|
|
538
|
-
return this._call(this.
|
|
559
|
+
return this._call(this._op('cpStdinWrite', [childPid, data]));
|
|
539
560
|
}
|
|
540
561
|
async cpStdinEnd(childPid) {
|
|
541
|
-
return this._call(this.
|
|
562
|
+
return this._call(this._op('cpStdinEnd', [childPid]));
|
|
542
563
|
}
|
|
543
564
|
async cpReadStdin(childPid, waitMs) {
|
|
544
|
-
return this._call(this.
|
|
565
|
+
return this._call(this._op('cpReadStdin', [childPid, waitMs]));
|
|
545
566
|
}
|
|
546
567
|
async cpReadOutput(childPid, fd, sinceSeq, waitMs) {
|
|
547
|
-
return this._call(this.
|
|
568
|
+
return this._call(this._op('cpReadOutput', [childPid, fd, sinceSeq, waitMs]));
|
|
548
569
|
}
|
|
549
570
|
async cpDrainOutput(childPid) {
|
|
550
|
-
return this._call(this.
|
|
571
|
+
return this._call(this._op('cpDrainOutput', [childPid]));
|
|
551
572
|
}
|
|
552
573
|
async cpKill(childPid, signal) {
|
|
553
|
-
return this._call(this.
|
|
574
|
+
return this._call(this._op('cpKill', [childPid, signal]));
|
|
554
575
|
}
|
|
555
576
|
async cpWait(childPid, waitMs) {
|
|
556
|
-
return this._call(this.
|
|
577
|
+
return this._call(this._op('cpWait', [childPid, waitMs]));
|
|
557
578
|
}
|
|
558
579
|
/**
|
|
559
580
|
* child-process isolation gap #1: dispatch a single cp.spawn request inline using
|
|
@@ -564,6 +585,6 @@ export class SupervisorRPC extends WorkerEntrypoint {
|
|
|
564
585
|
* supervisor while keeping the dispatch envelope in a fresh isolate.
|
|
565
586
|
*/
|
|
566
587
|
async cpDispatchInline(req, kind) {
|
|
567
|
-
return this._call(this.
|
|
588
|
+
return this._call(this._op('cpDispatchInline', [req, kind]));
|
|
568
589
|
}
|
|
569
590
|
}
|
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,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,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,sBAAsB,EAAE,MAAM,CAAC;IAC/B,qEAAqE;IACrE,QAAQ,EAAE,OAAO,0CAA0C,EAAE,YAAY,GAAG,IAAI,CAAC;IACjF,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IACvC,eAAe,IAAI,IAAI,CAAC;CACzB;AAgDD;;;;;;;GAOG;AACH,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AA0CD,wBAAgB,MAAM,CAAC,EAAE,EAAE,SAAS,GAAG,YAAY,CAElD;AAED,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CA4EzG;AA+CD,wBAAsB,OAAO,CAC3B,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,SAAS,EACb,KAAK,CAAC,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC,IAAI,CAAC,CAiGf;AAED,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CA4EtF;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAUlD"}
|
package/dist/session/ws.js
CHANGED
|
@@ -40,6 +40,7 @@ import { handleFsWatchSubscribe, handleFsWatchUnsubscribe, cleanupFsWatchOnClose
|
|
|
40
40
|
import { parseProcessLogClientFrame } from '@nimbus-sh/core/runtime/process-io-protocol.js';
|
|
41
41
|
import { applyProcessClientFrame } from '@nimbus-sh/core/runtime/process-input-routing.js';
|
|
42
42
|
import { z } from 'zod/v4';
|
|
43
|
+
import { clearShellSocketStamp, noteShellSocketActivity } from './shell-socket.js';
|
|
43
44
|
import { PRIOR_GENERATION_EXIT_REASON } from './rpc.js';
|
|
44
45
|
/**
|
|
45
46
|
* Snapshot the live Shell state and write it through to DO SQLite
|
|
@@ -151,6 +152,12 @@ export async function wsMessage(self, ws, message) {
|
|
|
151
152
|
await routeProcessLogClientMessage(self, ws, attach, message);
|
|
152
153
|
return;
|
|
153
154
|
}
|
|
155
|
+
// A frame arriving is the peer proving it is still on this socket.
|
|
156
|
+
// The stamp goes in the attachment because isolate memory does not
|
|
157
|
+
// survive hibernation and the /ws upgrade has to read it afterwards.
|
|
158
|
+
// Rate-limited inside; see src/session/shell-socket.ts.
|
|
159
|
+
if (attach?.kind === 'shell')
|
|
160
|
+
noteShellSocketActivity(ws);
|
|
154
161
|
const data = typeof message === 'string' ? message : dec.decode(message);
|
|
155
162
|
const value = JSON.parse(data);
|
|
156
163
|
// file-tree-watch (2026-05-15): handle fs-watch-* on this WS BEFORE
|
|
@@ -304,6 +311,11 @@ export async function wsClose(self, ws, _code, _reason, _wasClean) {
|
|
|
304
311
|
// wrangler dev) + long-running facets must still survive the
|
|
305
312
|
// terminal reconnect (see 607e472 — do NOT kill running processes
|
|
306
313
|
// here). Only reap per-tab state.
|
|
314
|
+
// The runtime says this socket is finished, so it no longer holds the
|
|
315
|
+
// terminal. Drop its liveness stamp before anything else: the frame
|
|
316
|
+
// that triggered this close stamped it moments ago, and leaving that
|
|
317
|
+
// behind would make the reconnect look like a second tab.
|
|
318
|
+
clearShellSocketStamp(ws);
|
|
307
319
|
// ── Phase 3 B'.1: transitionTo('drained') ──────────────────────────
|
|
308
320
|
// The Track B' state-machine transition. Persist final shell
|
|
309
321
|
// state + record a recovery_event BEFORE we null the in-memory
|
|
@@ -352,10 +364,9 @@ export async function wsClose(self, ws, _code, _reason, _wasClean) {
|
|
|
352
364
|
// upgrade calls terminal.attach(newWs) to swap in the new socket.
|
|
353
365
|
//
|
|
354
366
|
// Pre-B'.5 we nulled these three fields to avoid two-tab cross-
|
|
355
|
-
// wiring
|
|
356
|
-
//
|
|
357
|
-
//
|
|
358
|
-
// rejoin" (warmJoin path) from "active session busy" (still 409).
|
|
367
|
+
// wiring, which cost every reconnect a full rebuild. The upgrade now
|
|
368
|
+
// reads the sockets instead: a shell socket a peer still holds is the
|
|
369
|
+
// busy session it refuses, and this one is closing.
|
|
359
370
|
// Reset the one-shot "wrangler alias" banner so a reconnecting user
|
|
360
371
|
// sees it again — terminal-lifetime state, not session-lifetime.
|
|
361
372
|
self.wranglerAliasBannerShown = false;
|
|
@@ -387,6 +398,10 @@ export async function wsError(self, ws, _error) {
|
|
|
387
398
|
catch { /* best-effort */ }
|
|
388
399
|
return;
|
|
389
400
|
}
|
|
401
|
+
// Same reasoning as wsClose: this socket stops holding the terminal
|
|
402
|
+
// here. It matters more on this path, because the handler that just
|
|
403
|
+
// blew the 5-s cap is the one that stamped the socket.
|
|
404
|
+
clearShellSocketStamp(ws);
|
|
390
405
|
// ── Phase 3 B'.1: transitionTo('drained') ──────────────────────────
|
|
391
406
|
// Same architectural step as wsClose: persist shell state + record
|
|
392
407
|
// a drained event before nulling. wsError is a different physical
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nimbus-sh/worker",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Nimbus runtime package for Cloudflare Workers, re-exported publicly through @nimbus-sh/sdk/worker.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cloudflare",
|
|
@@ -84,9 +84,9 @@
|
|
|
84
84
|
},
|
|
85
85
|
"dependencies": {
|
|
86
86
|
"@ai-sdk/openai-compatible": "^2.0.41",
|
|
87
|
-
"@nimbus-sh/core": "^0.
|
|
88
|
-
"@nimbus-sh/fabric": "^0.
|
|
89
|
-
"@nimbus-sh/platform": "^0.
|
|
87
|
+
"@nimbus-sh/core": "^0.7.0",
|
|
88
|
+
"@nimbus-sh/fabric": "^0.3.0",
|
|
89
|
+
"@nimbus-sh/platform": "^0.2.0",
|
|
90
90
|
"@renovatebot/pep440": "^5.0.0",
|
|
91
91
|
"ai": "^6.0.182",
|
|
92
92
|
"clean-git-ref": "^2.0.1",
|