tywrap 0.8.0 → 0.10.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 +42 -22
- package/SECURITY.md +38 -0
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +8 -0
- package/dist/config/index.js.map +1 -1
- package/dist/core/annotation-parser.d.ts +2 -1
- package/dist/core/annotation-parser.d.ts.map +1 -1
- package/dist/core/annotation-parser.js +6 -3
- package/dist/core/annotation-parser.js.map +1 -1
- package/dist/core/generator.d.ts +23 -4
- package/dist/core/generator.d.ts.map +1 -1
- package/dist/core/generator.js +254 -170
- package/dist/core/generator.js.map +1 -1
- package/dist/core/mapper.d.ts +3 -2
- package/dist/core/mapper.d.ts.map +1 -1
- package/dist/core/mapper.js +5 -5
- package/dist/core/mapper.js.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/runtime/base-bridge.d.ts +3 -7
- package/dist/runtime/base-bridge.d.ts.map +1 -1
- package/dist/runtime/base-bridge.js +4 -17
- package/dist/runtime/base-bridge.js.map +1 -1
- package/dist/runtime/bounded-context.d.ts +3 -22
- package/dist/runtime/bounded-context.d.ts.map +1 -1
- package/dist/runtime/bounded-context.js +13 -53
- package/dist/runtime/bounded-context.js.map +1 -1
- package/dist/runtime/bridge-codec.d.ts +3 -3
- package/dist/runtime/bridge-codec.d.ts.map +1 -1
- package/dist/runtime/bridge-codec.js +129 -62
- package/dist/runtime/bridge-codec.js.map +1 -1
- package/dist/runtime/errors.d.ts +16 -0
- package/dist/runtime/errors.d.ts.map +1 -1
- package/dist/runtime/errors.js +17 -0
- package/dist/runtime/errors.js.map +1 -1
- package/dist/runtime/http-transport.d.ts +1 -1
- package/dist/runtime/http-transport.d.ts.map +1 -1
- package/dist/runtime/http-transport.js +1 -1
- package/dist/runtime/http-transport.js.map +1 -1
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/node.d.ts +7 -36
- package/dist/runtime/node.d.ts.map +1 -1
- package/dist/runtime/node.js +2 -80
- package/dist/runtime/node.js.map +1 -1
- package/dist/runtime/pooled-transport.d.ts +120 -59
- package/dist/runtime/pooled-transport.d.ts.map +1 -1
- package/dist/runtime/pooled-transport.js +345 -78
- package/dist/runtime/pooled-transport.js.map +1 -1
- package/dist/runtime/pyodide-bootstrap-core.generated.d.ts.map +1 -1
- package/dist/runtime/pyodide-bootstrap-core.generated.js +1 -1
- package/dist/runtime/pyodide-bootstrap-core.generated.js.map +1 -1
- package/dist/runtime/pyodide-transport.d.ts +1 -1
- package/dist/runtime/pyodide-transport.d.ts.map +1 -1
- package/dist/runtime/pyodide-transport.js +2 -3
- package/dist/runtime/pyodide-transport.js.map +1 -1
- package/dist/runtime/rpc-client.d.ts +7 -36
- package/dist/runtime/rpc-client.d.ts.map +1 -1
- package/dist/runtime/rpc-client.js +20 -102
- package/dist/runtime/rpc-client.js.map +1 -1
- package/dist/runtime/subprocess-transport.d.ts +30 -69
- package/dist/runtime/subprocess-transport.d.ts.map +1 -1
- package/dist/runtime/subprocess-transport.js +179 -236
- package/dist/runtime/subprocess-transport.js.map +1 -1
- package/dist/runtime/timed-out-request-tracker.d.ts +2 -1
- package/dist/runtime/timed-out-request-tracker.d.ts.map +1 -1
- package/dist/runtime/transport.d.ts +9 -19
- package/dist/runtime/transport.d.ts.map +1 -1
- package/dist/runtime/transport.js +1 -1
- package/dist/runtime/transport.js.map +1 -1
- package/dist/runtime/validators.d.ts +50 -0
- package/dist/runtime/validators.d.ts.map +1 -1
- package/dist/runtime/validators.js +154 -0
- package/dist/runtime/validators.js.map +1 -1
- package/dist/types/index.d.ts +14 -39
- package/dist/types/index.d.ts.map +1 -1
- package/dist/tywrap.d.ts +3 -2
- package/dist/tywrap.d.ts.map +1 -1
- package/dist/tywrap.js +140 -13
- package/dist/tywrap.js.map +1 -1
- package/dist/utils/cache.d.ts +3 -16
- package/dist/utils/cache.d.ts.map +1 -1
- package/dist/utils/codec.d.ts +17 -0
- package/dist/utils/codec.d.ts.map +1 -1
- package/dist/utils/codec.js +500 -85
- package/dist/utils/codec.js.map +1 -1
- package/dist/utils/ir-cache.d.ts +2 -1
- package/dist/utils/ir-cache.d.ts.map +1 -1
- package/dist/utils/runtime.d.ts +0 -29
- package/dist/utils/runtime.d.ts.map +1 -1
- package/dist/utils/runtime.js +16 -107
- package/dist/utils/runtime.js.map +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +7 -6
- package/runtime/frame_codec.py +7 -1
- package/runtime/python_bridge.py +85 -125
- package/runtime/tywrap_bridge_core.py +515 -187
- package/src/config/index.ts +11 -0
- package/src/core/annotation-parser.ts +7 -4
- package/src/core/generator.ts +330 -205
- package/src/core/mapper.ts +8 -8
- package/src/index.ts +7 -4
- package/src/runtime/base-bridge.ts +5 -30
- package/src/runtime/bounded-context.ts +12 -67
- package/src/runtime/bridge-codec.ts +158 -74
- package/src/runtime/errors.ts +21 -0
- package/src/runtime/http-transport.ts +6 -1
- package/src/runtime/index.ts +6 -0
- package/src/runtime/node.ts +9 -120
- package/src/runtime/pooled-transport.ts +424 -90
- package/src/runtime/pyodide-bootstrap-core.generated.ts +1 -1
- package/src/runtime/pyodide-transport.ts +7 -3
- package/src/runtime/rpc-client.ts +37 -139
- package/src/runtime/subprocess-transport.ts +210 -285
- package/src/runtime/timed-out-request-tracker.ts +1 -1
- package/src/runtime/transport.ts +15 -23
- package/src/runtime/validators.ts +212 -0
- package/src/types/index.ts +21 -60
- package/src/tywrap.ts +157 -22
- package/src/utils/cache.ts +3 -3
- package/src/utils/codec.ts +749 -112
- package/src/utils/ir-cache.ts +1 -1
- package/src/utils/runtime.ts +17 -128
- package/src/version.ts +1 -1
- package/dist/core/discovery.d.ts +0 -103
- package/dist/core/discovery.d.ts.map +0 -1
- package/dist/core/discovery.js +0 -380
- package/dist/core/discovery.js.map +0 -1
- package/dist/core/validation.d.ts +0 -102
- package/dist/core/validation.d.ts.map +0 -1
- package/dist/core/validation.js +0 -490
- package/dist/core/validation.js.map +0 -1
- package/dist/runtime/base.d.ts +0 -22
- package/dist/runtime/base.d.ts.map +0 -1
- package/dist/runtime/base.js +0 -23
- package/dist/runtime/base.js.map +0 -1
- package/dist/runtime/transport-pool.d.ts +0 -196
- package/dist/runtime/transport-pool.d.ts.map +0 -1
- package/dist/runtime/transport-pool.js +0 -418
- package/dist/runtime/transport-pool.js.map +0 -1
- package/runtime/__pycache__/_tywrap_conformance_chunking_fixtures.cpython-311.pyc +0 -0
- package/runtime/__pycache__/_tywrap_member_fixtures.cpython-311.pyc +0 -0
- package/runtime/__pycache__/_tywrap_w4_chunking_fixture.cpython-311.pyc +0 -0
- package/runtime/__pycache__/_tywrap_w5_request_chunking_fixture.cpython-311.pyc +0 -0
- package/runtime/__pycache__/_tywrap_w6_pool_chunking_fixture.cpython-311.pyc +0 -0
- package/runtime/__pycache__/frame_codec.cpython-311.pyc +0 -0
- package/runtime/__pycache__/safe_codec.cpython-311.pyc +0 -0
- package/runtime/__pycache__/tywrap_bridge_core.cpython-311.pyc +0 -0
- package/runtime/safe_codec.py +0 -352
- package/src/core/discovery.ts +0 -477
- package/src/core/validation.ts +0 -729
- package/src/runtime/base.ts +0 -24
- package/src/runtime/transport-pool.ts +0 -538
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* NOT a base class bridges extend. It owns the one place where the wire frame
|
|
7
7
|
* is built and correlated: id generation, {id, protocol} stamping, codec
|
|
8
8
|
* encode/decode, and transport.send. It composes DisposableBase to obtain its
|
|
9
|
-
* lifecycle (init/dispose) and bounded execution (timeout/
|
|
9
|
+
* lifecycle (init/dispose) and single-attempt bounded execution (timeout/abort), but it
|
|
10
10
|
* carries no PythonRuntime contract obligation — the facade implements
|
|
11
11
|
* PythonRuntime and delegates the four RPC methods to this client.
|
|
12
12
|
*
|
|
@@ -90,39 +90,6 @@ function validateBridgeInfoPayload(value) {
|
|
|
90
90
|
if (typeof instances !== 'number' || !Number.isInteger(instances) || instances < 0) {
|
|
91
91
|
throw new BridgeProtocolError(`Invalid bridge info payload: instances expected non-negative integer, got ${formatValue(instances)}`);
|
|
92
92
|
}
|
|
93
|
-
// OPTIONAL chunked-transport negotiation block. Absent on old bridges and on
|
|
94
|
-
// HTTP/Pyodide (single-frame in 0.8.0) — absence is backward compatible. When
|
|
95
|
-
// present, validate every field and CARRY IT THROUGH so negotiation data
|
|
96
|
-
// survives the rebuild below (the old validator silently dropped unknown
|
|
97
|
-
// fields, which would have discarded this block).
|
|
98
|
-
let transport;
|
|
99
|
-
const rawTransport = obj.transport;
|
|
100
|
-
if (rawTransport !== undefined) {
|
|
101
|
-
if (!rawTransport || typeof rawTransport !== 'object' || Array.isArray(rawTransport)) {
|
|
102
|
-
const kind = rawTransport === null
|
|
103
|
-
? 'null'
|
|
104
|
-
: Array.isArray(rawTransport)
|
|
105
|
-
? 'array'
|
|
106
|
-
: typeof rawTransport;
|
|
107
|
-
throw new BridgeProtocolError(`Invalid bridge info payload: transport expected object, got ${kind}`);
|
|
108
|
-
}
|
|
109
|
-
const t = rawTransport;
|
|
110
|
-
const frameProtocol = t.frameProtocol;
|
|
111
|
-
if (typeof frameProtocol !== 'string' || frameProtocol.length === 0) {
|
|
112
|
-
throw new BridgeProtocolError(`Invalid bridge info payload: transport.frameProtocol expected non-empty string, got ${formatValue(frameProtocol)}`);
|
|
113
|
-
}
|
|
114
|
-
const supportsChunking = t.supportsChunking;
|
|
115
|
-
if (typeof supportsChunking !== 'boolean') {
|
|
116
|
-
throw new BridgeProtocolError(`Invalid bridge info payload: transport.supportsChunking expected boolean, got ${formatValue(supportsChunking)}`);
|
|
117
|
-
}
|
|
118
|
-
const maxFrameBytes = t.maxFrameBytes;
|
|
119
|
-
if (typeof maxFrameBytes !== 'number' ||
|
|
120
|
-
!Number.isInteger(maxFrameBytes) ||
|
|
121
|
-
maxFrameBytes <= 0) {
|
|
122
|
-
throw new BridgeProtocolError(`Invalid bridge info payload: transport.maxFrameBytes expected positive integer, got ${formatValue(maxFrameBytes)}`);
|
|
123
|
-
}
|
|
124
|
-
transport = { frameProtocol, supportsChunking, maxFrameBytes };
|
|
125
|
-
}
|
|
126
93
|
const info = {
|
|
127
94
|
protocol: PROTOCOL_ID,
|
|
128
95
|
protocolVersion: TYWRAP_PROTOCOL_VERSION,
|
|
@@ -136,9 +103,6 @@ function validateBridgeInfoPayload(value) {
|
|
|
136
103
|
sklearnAvailable,
|
|
137
104
|
instances,
|
|
138
105
|
};
|
|
139
|
-
if (transport !== undefined) {
|
|
140
|
-
info.transport = transport;
|
|
141
|
-
}
|
|
142
106
|
return info;
|
|
143
107
|
}
|
|
144
108
|
// =============================================================================
|
|
@@ -159,7 +123,7 @@ function validateBridgeInfoPayload(value) {
|
|
|
159
123
|
* this.rpc = new RpcClient({ transport, defaultTimeoutMs: options.timeout });
|
|
160
124
|
* this.trackResource(this.rpc);
|
|
161
125
|
* }
|
|
162
|
-
* // call
|
|
126
|
+
* // call and getBridgeInfo delegate to this.rpc.*
|
|
163
127
|
* }
|
|
164
128
|
* ```
|
|
165
129
|
*/
|
|
@@ -220,7 +184,7 @@ export class RpcClient extends DisposableBase {
|
|
|
220
184
|
* 4. Decodes and validates the response
|
|
221
185
|
*
|
|
222
186
|
* @param message - The protocol message (without id field)
|
|
223
|
-
* @param options - Execution options (timeout,
|
|
187
|
+
* @param options - Execution options (timeout, validation, and abort)
|
|
224
188
|
* @returns The typed response from Python
|
|
225
189
|
*
|
|
226
190
|
* @throws BridgeProtocolError if encoding/decoding fails
|
|
@@ -237,7 +201,7 @@ export class RpcClient extends DisposableBase {
|
|
|
237
201
|
* ndarrays, or other Arrow-encoded data structures.
|
|
238
202
|
*
|
|
239
203
|
* @param message - The protocol message (without id field)
|
|
240
|
-
* @param options - Execution options (timeout,
|
|
204
|
+
* @param options - Execution options (timeout, validation, and abort)
|
|
241
205
|
* @returns The typed response from Python with Arrow decoding applied
|
|
242
206
|
*
|
|
243
207
|
* @throws BridgeProtocolError if encoding/decoding fails
|
|
@@ -250,7 +214,7 @@ export class RpcClient extends DisposableBase {
|
|
|
250
214
|
/**
|
|
251
215
|
* Shared body for sendMessage/sendMessageAsync: stamp the frame, run the
|
|
252
216
|
* encode -> transport.send -> decode pipeline inside this.execute() (which
|
|
253
|
-
* supplies auto-init
|
|
217
|
+
* supplies auto-init and exactly-one-attempt timeout/abort handling), where the only difference between
|
|
254
218
|
* the sync and Arrow-aware paths is the supplied `decode` step.
|
|
255
219
|
*
|
|
256
220
|
* Behavior-preserving extraction of the two twins; ordering, the
|
|
@@ -263,7 +227,7 @@ export class RpcClient extends DisposableBase {
|
|
|
263
227
|
// 1. Encode request (validates args)
|
|
264
228
|
const encoded = this.codec.encodeRequest(fullMessage);
|
|
265
229
|
// 2. Send via transport
|
|
266
|
-
const responseStr = await this.transport.send(encoded, options?.timeoutMs ?? this.defaultTimeoutMs, options?.signal);
|
|
230
|
+
const responseStr = await this.transport.send(encoded, options?.timeoutMs ?? this.defaultTimeoutMs, options?.signal, fullMessage.id);
|
|
267
231
|
// 3. Decode response (sync or Arrow-aware, per caller)
|
|
268
232
|
return decode(responseStr);
|
|
269
233
|
}, options);
|
|
@@ -287,7 +251,7 @@ export class RpcClient extends DisposableBase {
|
|
|
287
251
|
async sendOn(transport, message, opts) {
|
|
288
252
|
const fullMessage = this.stampMessage(message);
|
|
289
253
|
const encoded = this.codec.encodeRequest(fullMessage);
|
|
290
|
-
const responseStr = await transport.send(encoded, opts?.timeoutMs ?? this.defaultTimeoutMs, opts?.signal);
|
|
254
|
+
const responseStr = await transport.send(encoded, opts?.timeoutMs ?? this.defaultTimeoutMs, opts?.signal, fullMessage.id);
|
|
291
255
|
return this.codec.decodeResponseAsync(responseStr);
|
|
292
256
|
}
|
|
293
257
|
/**
|
|
@@ -324,7 +288,7 @@ export class RpcClient extends DisposableBase {
|
|
|
324
288
|
* @param kwargs - Keyword arguments
|
|
325
289
|
* @returns The function result
|
|
326
290
|
*/
|
|
327
|
-
async call(module, functionName, args, kwargs) {
|
|
291
|
+
async call(module, functionName, args, kwargs, validate) {
|
|
328
292
|
return this.sendMessageAsync({
|
|
329
293
|
method: 'call',
|
|
330
294
|
params: {
|
|
@@ -333,69 +297,20 @@ export class RpcClient extends DisposableBase {
|
|
|
333
297
|
args,
|
|
334
298
|
kwargs,
|
|
335
299
|
},
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
* @param kwargs - Keyword constructor arguments
|
|
345
|
-
* @returns A handle to the created instance
|
|
346
|
-
*/
|
|
347
|
-
async instantiate(module, className, args, kwargs) {
|
|
348
|
-
return this.sendMessageAsync({
|
|
349
|
-
method: 'instantiate',
|
|
350
|
-
params: {
|
|
351
|
-
module,
|
|
352
|
-
className,
|
|
353
|
-
args,
|
|
354
|
-
kwargs,
|
|
355
|
-
},
|
|
356
|
-
});
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* Call a method on a Python instance.
|
|
360
|
-
*
|
|
361
|
-
* @param handle - Instance handle returned from instantiate()
|
|
362
|
-
* @param methodName - Method name to call
|
|
363
|
-
* @param args - Positional arguments
|
|
364
|
-
* @param kwargs - Keyword arguments
|
|
365
|
-
* @returns The method result
|
|
366
|
-
*/
|
|
367
|
-
async callMethod(handle, methodName, args, kwargs) {
|
|
368
|
-
return this.sendMessageAsync({
|
|
369
|
-
method: 'call_method',
|
|
370
|
-
params: {
|
|
371
|
-
handle,
|
|
372
|
-
methodName,
|
|
373
|
-
args,
|
|
374
|
-
kwargs,
|
|
375
|
-
},
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* Dispose a Python instance.
|
|
380
|
-
*
|
|
381
|
-
* Releases the instance handle on the Python side, allowing
|
|
382
|
-
* the object to be garbage collected.
|
|
383
|
-
*
|
|
384
|
-
* @param handle - Instance handle to dispose
|
|
385
|
-
*/
|
|
386
|
-
async disposeInstance(handle) {
|
|
387
|
-
await this.sendMessageAsync({
|
|
388
|
-
method: 'dispose_instance',
|
|
389
|
-
params: {
|
|
390
|
-
handle,
|
|
391
|
-
},
|
|
392
|
-
});
|
|
300
|
+
}, validate
|
|
301
|
+
? {
|
|
302
|
+
validate: result => {
|
|
303
|
+
validate(result);
|
|
304
|
+
return result;
|
|
305
|
+
},
|
|
306
|
+
}
|
|
307
|
+
: undefined);
|
|
393
308
|
}
|
|
394
309
|
/**
|
|
395
310
|
* Fetch bridge diagnostics and feature availability.
|
|
396
311
|
*
|
|
397
312
|
* The Python bridge supports a `meta` method that returns protocol and environment info
|
|
398
|
-
* (including optional codec availability and
|
|
313
|
+
* (including optional codec availability and a fixed zero instance count).
|
|
399
314
|
*/
|
|
400
315
|
async getBridgeInfo(options = {}) {
|
|
401
316
|
if (!options.refresh && this.bridgeInfoCache) {
|
|
@@ -407,6 +322,9 @@ export class RpcClient extends DisposableBase {
|
|
|
407
322
|
}, {
|
|
408
323
|
validate: validateBridgeInfoPayload,
|
|
409
324
|
});
|
|
325
|
+
if (info.instances !== 0) {
|
|
326
|
+
throw new BridgeProtocolError(`Invalid bridge info payload: instances expected 0, got ${String(info.instances)}`);
|
|
327
|
+
}
|
|
410
328
|
this.bridgeInfoCache = info;
|
|
411
329
|
return info;
|
|
412
330
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rpc-client.js","sourceRoot":"","sources":["../../src/runtime/rpc-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,cAAc,EAAuB,MAAM,sBAAsB,CAAC;AAC3E,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,WAAW,EAAqB,MAAM,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,WAAW,CACjC;YACE,MAAM,EAAE,MAAM;YACd,MAAM,EAAE,EAAE;SACX,EACD;YACE,QAAQ,EAAE,yBAAyB;SACpC,CACF,CAAC;QAEF,IAAI,IAAI,CAAC,SAAS,KAAK,CAAC,EAAE,CAAC;YACzB,MAAM,IAAI,mBAAmB,CAC3B,0DAA0D,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CACnF,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC;QAC5B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;;;;;;;OAWG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC;IACvC,CAAC;CACF"}
|
|
@@ -32,18 +32,6 @@ export interface SubprocessTransportOptions {
|
|
|
32
32
|
restartAfterRequests?: number;
|
|
33
33
|
/** Write queue timeout in milliseconds. Default: 30000ms */
|
|
34
34
|
writeQueueTimeoutMs?: number;
|
|
35
|
-
/**
|
|
36
|
-
* Enable `tywrap-frame/1` chunked transport negotiation. When `true`, the
|
|
37
|
-
* transport spawns the bridge with the three `TYWRAP_TRANSPORT_*` env vars and,
|
|
38
|
-
* during {@link SubprocessTransport.init}, probes the bridge's `meta` for a
|
|
39
|
-
* `transport.supportsChunking` block. If the bridge advertises chunking,
|
|
40
|
-
* oversize responses are transparently reassembled from frames; otherwise
|
|
41
|
-
* behavior is unchanged and an oversize response still fails loud (no silent
|
|
42
|
-
* single-frame fallback). Default: `false` (no negotiation, legacy behavior).
|
|
43
|
-
*
|
|
44
|
-
* Subprocess-only (0.8.0). See docs/transport-framing.md.
|
|
45
|
-
*/
|
|
46
|
-
enableChunking?: boolean;
|
|
47
35
|
/**
|
|
48
36
|
* Cap (UTF-8 bytes) on a single chunked RESPONSE reassembled in memory. A
|
|
49
37
|
* frame stream whose declared or accumulated payload exceeds this fails loud
|
|
@@ -87,25 +75,15 @@ export declare class SubprocessTransport extends DisposableBase implements Trans
|
|
|
87
75
|
private readonly maxReassemblyBytes;
|
|
88
76
|
private readonly restartAfterRequests;
|
|
89
77
|
private readonly writeQueueTimeoutMs;
|
|
90
|
-
/** Whether `tywrap-frame/1` negotiation was requested by the caller. */
|
|
91
|
-
private readonly enableChunking;
|
|
92
78
|
/**
|
|
93
|
-
*
|
|
94
|
-
* `
|
|
95
|
-
*
|
|
79
|
+
* Per-frame UTF-8 data ceiling. The packaged Python peer receives this
|
|
80
|
+
* transport's `maxLineLength` when it is spawned, so request and response
|
|
81
|
+
* framing use the same fixed ceiling without runtime negotiation.
|
|
96
82
|
*/
|
|
97
|
-
private
|
|
98
|
-
/**
|
|
99
|
-
* The per-frame UTF-8 byte ceiling actually agreed with the bridge:
|
|
100
|
-
* `min(maxLineLength, the bridge's advertised maxFrameBytes)`. Defaults to
|
|
101
|
-
* `maxLineLength` and is narrowed during negotiation, so REQUEST frames are
|
|
102
|
-
* never sized larger than the bridge said it will accept (the reference bridge
|
|
103
|
-
* echoes the requested value, but a custom bridge may advertise a smaller one).
|
|
104
|
-
*/
|
|
105
|
-
private negotiatedFrameBytes;
|
|
83
|
+
private readonly frameBytes;
|
|
106
84
|
/**
|
|
107
85
|
* Reassembles `tywrap-frame/1` response frames into single logical response
|
|
108
|
-
* lines.
|
|
86
|
+
* lines. Per-id discard tracks
|
|
109
87
|
* timed-out/aborted streams so late frames cannot desync stdout.
|
|
110
88
|
*/
|
|
111
89
|
private responseReassembler;
|
|
@@ -113,12 +91,18 @@ export declare class SubprocessTransport extends DisposableBase implements Trans
|
|
|
113
91
|
private processExited;
|
|
114
92
|
private processError;
|
|
115
93
|
private stdoutBuffer;
|
|
94
|
+
private stdoutScanOffset;
|
|
116
95
|
private stderrBuffer;
|
|
117
96
|
private readonly pending;
|
|
118
97
|
private readonly timedOutRequests;
|
|
119
98
|
private requestCount;
|
|
120
99
|
private needsRestart;
|
|
100
|
+
/** Serializes restart decisions with dispatch reservations. */
|
|
101
|
+
private dispatchMutex;
|
|
102
|
+
private activeDispatches;
|
|
103
|
+
private readonly dispatchDrainWaiters;
|
|
121
104
|
private readonly writeQueue;
|
|
105
|
+
private writeQueueHead;
|
|
122
106
|
private draining;
|
|
123
107
|
/**
|
|
124
108
|
* Per-logical-request write mutex (W5). When a request is chunked into
|
|
@@ -144,55 +128,33 @@ export declare class SubprocessTransport extends DisposableBase implements Trans
|
|
|
144
128
|
* @param signal - Optional AbortSignal for cancellation
|
|
145
129
|
* @returns The raw JSON response string
|
|
146
130
|
*/
|
|
147
|
-
send(message: string, timeoutMs: number, signal?: AbortSignal): Promise<string>;
|
|
131
|
+
send(message: string, timeoutMs: number, signal?: AbortSignal, requestId?: number): Promise<string>;
|
|
132
|
+
/**
|
|
133
|
+
* Atomically reserve the current process generation for one request. A
|
|
134
|
+
* threshold restart waits for every request reserved on the old generation
|
|
135
|
+
* to settle before killing it; later callers remain queued behind this lock.
|
|
136
|
+
*/
|
|
137
|
+
private withDispatchMutex;
|
|
138
|
+
private reserveDispatch;
|
|
139
|
+
private releaseDispatch;
|
|
140
|
+
private isLifecycleEnding;
|
|
148
141
|
/**
|
|
149
142
|
* Static capability descriptor for the subprocess backend.
|
|
150
143
|
*
|
|
151
144
|
* Per the {@link Transport.capabilities} contract this is lifecycle-independent
|
|
152
145
|
* (safe before `init()` / after `dispose()`) and never makes a Python round
|
|
153
146
|
* trip. Subprocess carries Arrow IPC and arbitrary binary (bytes envelopes)
|
|
154
|
-
* over the JSONL stream. `supportsChunking`
|
|
155
|
-
*
|
|
156
|
-
* `
|
|
157
|
-
*
|
|
158
|
-
* actually advertised framing is the negotiated fact, surfaced separately on
|
|
159
|
-
* `BridgeInfo.transport.supportsChunking`; "will chunking actually happen"
|
|
160
|
-
* needs both `true`. `supportsStreaming` stays `false` (0.8.0). `maxFrameBytes`
|
|
161
|
-
* is the configured JSONL line-length limit — the largest single (unchunked)
|
|
162
|
-
* response line this transport accepts.
|
|
147
|
+
* over the JSONL stream. `supportsChunking` is always `true` because the npm
|
|
148
|
+
* package ships both `tywrap-frame/1` peers. `supportsStreaming` stays `false`.
|
|
149
|
+
* `maxFrameBytes` is the fixed per-frame data ceiling supplied to the Python
|
|
150
|
+
* bridge at spawn time.
|
|
163
151
|
*/
|
|
164
152
|
capabilities(): TransportCapabilities;
|
|
165
153
|
/**
|
|
166
|
-
* Initialize the transport by spawning the Python process
|
|
167
|
-
*
|
|
154
|
+
* Initialize the transport by spawning the Python process. The packaged
|
|
155
|
+
* bridge always speaks `tywrap-frame/1`.
|
|
168
156
|
*/
|
|
169
157
|
protected doInit(): Promise<void>;
|
|
170
|
-
/**
|
|
171
|
-
* Probe the freshly-spawned bridge for `tywrap-frame/1` support.
|
|
172
|
-
*
|
|
173
|
-
* Sends a small unchunked `meta` request directly over stdin (NOT via the
|
|
174
|
-
* public {@link send}, which would re-enter init while we are mid-init) and
|
|
175
|
-
* reads the single-line response. If the bridge reports
|
|
176
|
-
* `transport.supportsChunking: true`, response reassembly is enabled. If the
|
|
177
|
-
* bridge does not advertise chunking (old bridge, or it disabled framing), the
|
|
178
|
-
* transport stays single-frame and an oversize response still fails loud — no
|
|
179
|
-
* silent fallback. A probe failure leaves chunking disabled but does not fail
|
|
180
|
-
* init (small calls must keep working); the loud failure is deferred to the
|
|
181
|
-
* first oversize response.
|
|
182
|
-
*/
|
|
183
|
-
private negotiateChunking;
|
|
184
|
-
/**
|
|
185
|
-
* Whether a parsed `meta` response advertises `tywrap-frame/1` chunking with a
|
|
186
|
-
* matching frame protocol. Defensive: any missing/mismatched field => `false`.
|
|
187
|
-
*/
|
|
188
|
-
private bridgeAdvertisesChunking;
|
|
189
|
-
/**
|
|
190
|
-
* Send a single in-init probe message over stdin and resolve with its raw
|
|
191
|
-
* response line. Registers a pending entry keyed by `probeId` exactly like the
|
|
192
|
-
* normal send path so {@link handleResponseLine} resolves it, but bypasses the
|
|
193
|
-
* `isReady`/auto-init guard (we are deliberately running during `doInit`).
|
|
194
|
-
*/
|
|
195
|
-
private sendProbe;
|
|
196
158
|
/**
|
|
197
159
|
* Dispose the transport by killing the Python process.
|
|
198
160
|
*/
|
|
@@ -218,8 +180,7 @@ export declare class SubprocessTransport extends DisposableBase implements Trans
|
|
|
218
180
|
/**
|
|
219
181
|
* Effective stdout line ceiling.
|
|
220
182
|
*
|
|
221
|
-
*
|
|
222
|
-
* chunking negotiated, a single wire line is a `tywrap-frame/1` envelope whose
|
|
183
|
+
* A single wire line may be a `tywrap-frame/1` envelope whose
|
|
223
184
|
* `data` slice is capped at `maxLineLength` UTF-8 bytes by the bridge, but the
|
|
224
185
|
* JSON envelope adds escaping (`"`/`\`) plus fixed keys; the ceiling is widened
|
|
225
186
|
* to bound that overhead so a legitimate frame line is never rejected while a
|
|
@@ -233,7 +194,7 @@ export declare class SubprocessTransport extends DisposableBase implements Trans
|
|
|
233
194
|
/**
|
|
234
195
|
* Handle a complete response line from stdout.
|
|
235
196
|
*
|
|
236
|
-
*
|
|
197
|
+
* A line may be a `tywrap-frame/1` envelope: it is
|
|
237
198
|
* routed into the per-id {@link Reassembler}, which returns the reassembled
|
|
238
199
|
* logical response only once the stream is complete and valid. Single-line
|
|
239
200
|
* (non-frame) responses keep the original fast path unchanged.
|
|
@@ -305,7 +266,7 @@ export declare class SubprocessTransport extends DisposableBase implements Trans
|
|
|
305
266
|
private writeToStdin;
|
|
306
267
|
/**
|
|
307
268
|
* Write one logical request to stdin, fragmenting it into `tywrap-frame/1`
|
|
308
|
-
* request frames when
|
|
269
|
+
* request frames when the encoded request exceeds
|
|
309
270
|
* the per-frame ceiling (W5 — the mirror of W4's response chunking).
|
|
310
271
|
*
|
|
311
272
|
* Both the chunked and single-line paths run under {@link writeMutex} so a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subprocess-transport.d.ts","sourceRoot":"","sources":["../../src/runtime/subprocess-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAIH,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAItD,OAAO,
|
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