tywrap 0.5.1 → 0.6.1
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/dist/cli.js +8 -6
- package/dist/cli.js.map +1 -1
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +236 -147
- package/dist/config/index.js.map +1 -1
- package/dist/core/annotation-parser.d.ts.map +1 -1
- package/dist/core/annotation-parser.js +112 -97
- package/dist/core/annotation-parser.js.map +1 -1
- package/dist/core/discovery.d.ts +17 -0
- package/dist/core/discovery.d.ts.map +1 -1
- package/dist/core/discovery.js +85 -49
- package/dist/core/discovery.js.map +1 -1
- package/dist/core/emit-call.d.ts +58 -0
- package/dist/core/emit-call.d.ts.map +1 -0
- package/dist/core/emit-call.js +103 -0
- package/dist/core/emit-call.js.map +1 -0
- package/dist/core/generator.d.ts +2 -0
- package/dist/core/generator.d.ts.map +1 -1
- package/dist/core/generator.js +54 -211
- package/dist/core/generator.js.map +1 -1
- package/dist/core/mapper.d.ts.map +1 -1
- package/dist/core/mapper.js +118 -104
- package/dist/core/mapper.js.map +1 -1
- package/dist/core/validation.d.ts +23 -0
- package/dist/core/validation.d.ts.map +1 -1
- package/dist/core/validation.js +52 -48
- package/dist/core/validation.js.map +1 -1
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.js +175 -133
- package/dist/dev.js.map +1 -1
- package/dist/index.d.ts +6 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -31
- package/dist/index.js.map +1 -1
- package/dist/runtime/bounded-context.d.ts +2 -2
- package/dist/runtime/bounded-context.js +2 -2
- package/dist/runtime/{safe-codec.d.ts → bridge-codec.d.ts} +26 -11
- package/dist/runtime/bridge-codec.d.ts.map +1 -0
- package/dist/runtime/{safe-codec.js → bridge-codec.js} +69 -72
- package/dist/runtime/bridge-codec.js.map +1 -0
- package/dist/runtime/{http-io.d.ts → http-transport.d.ts} +6 -6
- package/dist/runtime/http-transport.d.ts.map +1 -0
- package/dist/runtime/{http-io.js → http-transport.js} +3 -3
- package/dist/runtime/http-transport.js.map +1 -0
- package/dist/runtime/http.d.ts +3 -3
- package/dist/runtime/http.d.ts.map +1 -1
- package/dist/runtime/http.js +4 -4
- package/dist/runtime/http.js.map +1 -1
- package/dist/runtime/index.d.ts +9 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +9 -1
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/node.d.ts +6 -6
- package/dist/runtime/node.d.ts.map +1 -1
- package/dist/runtime/node.js +7 -7
- package/dist/runtime/node.js.map +1 -1
- package/dist/runtime/pooled-transport.d.ts +11 -11
- package/dist/runtime/pooled-transport.d.ts.map +1 -1
- package/dist/runtime/pooled-transport.js +10 -10
- 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-io.d.ts → pyodide-transport.d.ts} +8 -8
- package/dist/runtime/pyodide-transport.d.ts.map +1 -0
- package/dist/runtime/{pyodide-io.js → pyodide-transport.js} +5 -5
- package/dist/runtime/pyodide-transport.js.map +1 -0
- package/dist/runtime/pyodide.d.ts +3 -3
- package/dist/runtime/pyodide.d.ts.map +1 -1
- package/dist/runtime/pyodide.js +5 -5
- package/dist/runtime/pyodide.js.map +1 -1
- package/dist/runtime/rpc-client.d.ts +23 -5
- package/dist/runtime/rpc-client.d.ts.map +1 -1
- package/dist/runtime/rpc-client.js +36 -31
- package/dist/runtime/rpc-client.js.map +1 -1
- package/dist/runtime/{process-io.d.ts → subprocess-transport.d.ts} +25 -9
- package/dist/runtime/subprocess-transport.d.ts.map +1 -0
- package/dist/runtime/{process-io.js → subprocess-transport.js} +60 -41
- package/dist/runtime/subprocess-transport.js.map +1 -0
- package/dist/runtime/{worker-pool.d.ts → transport-pool.d.ts} +15 -15
- package/dist/runtime/transport-pool.d.ts.map +1 -0
- package/dist/runtime/{worker-pool.js → transport-pool.js} +6 -6
- package/dist/runtime/transport-pool.js.map +1 -0
- package/dist/runtime/transport.d.ts +14 -8
- package/dist/runtime/transport.d.ts.map +1 -1
- package/dist/runtime/transport.js +10 -4
- package/dist/runtime/transport.js.map +1 -1
- package/dist/types/index.d.ts +10 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/tywrap.d.ts +0 -5
- package/dist/tywrap.d.ts.map +1 -1
- package/dist/tywrap.js +0 -20
- package/dist/tywrap.js.map +1 -1
- package/dist/utils/cache.d.ts +13 -2
- package/dist/utils/cache.d.ts.map +1 -1
- package/dist/utils/cache.js +52 -60
- package/dist/utils/cache.js.map +1 -1
- package/dist/utils/codec.d.ts +1 -1
- package/dist/utils/codec.d.ts.map +1 -1
- package/dist/utils/codec.js +181 -182
- package/dist/utils/codec.js.map +1 -1
- package/dist/utils/python.d.ts.map +1 -1
- package/dist/utils/python.js +28 -17
- package/dist/utils/python.js.map +1 -1
- package/dist/utils/runtime.d.ts.map +1 -1
- package/dist/utils/runtime.js +22 -16
- package/dist/utils/runtime.js.map +1 -1
- package/dist/version.d.ts +12 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +12 -0
- package/dist/version.js.map +1 -0
- package/package.json +3 -2
- package/runtime/__pycache__/safe_codec.cpython-311.pyc +0 -0
- package/runtime/__pycache__/tywrap_bridge_core.cpython-311.pyc +0 -0
- package/runtime/python_bridge.py +54 -6
- package/runtime/safe_codec.py +8 -8
- package/runtime/tywrap_bridge_core.py +159 -23
- package/src/cli.ts +8 -12
- package/src/config/index.ts +271 -165
- package/src/core/annotation-parser.ts +135 -123
- package/src/core/discovery.ts +102 -54
- package/src/core/emit-call.ts +171 -0
- package/src/core/generator.ts +67 -263
- package/src/core/mapper.ts +125 -110
- package/src/core/validation.ts +84 -48
- package/src/dev.ts +237 -153
- package/src/index.ts +11 -68
- package/src/runtime/bounded-context.ts +2 -2
- package/src/runtime/{safe-codec.ts → bridge-codec.ts} +83 -95
- package/src/runtime/{http-io.ts → http-transport.ts} +5 -5
- package/src/runtime/http.ts +5 -5
- package/src/runtime/index.ts +23 -1
- package/src/runtime/node.ts +15 -15
- package/src/runtime/pooled-transport.ts +15 -15
- package/src/runtime/pyodide-bootstrap-core.generated.ts +1 -1
- package/src/runtime/{pyodide-io.ts → pyodide-transport.ts} +7 -7
- package/src/runtime/pyodide.ts +6 -6
- package/src/runtime/rpc-client.ts +51 -40
- package/src/runtime/{process-io.ts → subprocess-transport.ts} +77 -47
- package/src/runtime/{worker-pool.ts → transport-pool.ts} +26 -26
- package/src/runtime/transport.ts +15 -8
- package/src/types/index.ts +10 -1
- package/src/tywrap.ts +0 -24
- package/src/utils/cache.ts +61 -63
- package/src/utils/codec.ts +217 -196
- package/src/utils/python.ts +33 -20
- package/src/utils/runtime.ts +24 -13
- package/src/version.ts +12 -0
- package/dist/runtime/http-io.d.ts.map +0 -1
- package/dist/runtime/http-io.js.map +0 -1
- package/dist/runtime/optimized-node.d.ts +0 -23
- package/dist/runtime/optimized-node.d.ts.map +0 -1
- package/dist/runtime/optimized-node.js +0 -23
- package/dist/runtime/optimized-node.js.map +0 -1
- package/dist/runtime/process-io.d.ts.map +0 -1
- package/dist/runtime/process-io.js.map +0 -1
- package/dist/runtime/protocol.d.ts +0 -3
- package/dist/runtime/protocol.d.ts.map +0 -1
- package/dist/runtime/protocol.js +0 -3
- package/dist/runtime/protocol.js.map +0 -1
- package/dist/runtime/pyodide-io.d.ts.map +0 -1
- package/dist/runtime/pyodide-io.js.map +0 -1
- package/dist/runtime/safe-codec.d.ts.map +0 -1
- package/dist/runtime/safe-codec.js.map +0 -1
- package/dist/runtime/worker-pool.d.ts.map +0 -1
- package/dist/runtime/worker-pool.js.map +0 -1
- package/dist/utils/bundle-optimizer.d.ts +0 -182
- package/dist/utils/bundle-optimizer.d.ts.map +0 -1
- package/dist/utils/bundle-optimizer.js +0 -680
- package/dist/utils/bundle-optimizer.js.map +0 -1
- package/dist/utils/memory-profiler.d.ts +0 -123
- package/dist/utils/memory-profiler.d.ts.map +0 -1
- package/dist/utils/memory-profiler.js +0 -426
- package/dist/utils/memory-profiler.js.map +0 -1
- package/src/runtime/optimized-node.ts +0 -25
- package/src/runtime/protocol.ts +0 -2
- package/src/utils/bundle-optimizer.ts +0 -876
- package/src/utils/memory-profiler.ts +0 -582
package/src/utils/codec.ts
CHANGED
|
@@ -40,7 +40,7 @@ export interface SklearnEstimator {
|
|
|
40
40
|
params: Record<string, unknown>;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
export type
|
|
43
|
+
export type ValueEnvelope =
|
|
44
44
|
| {
|
|
45
45
|
readonly __tywrap__: 'dataframe';
|
|
46
46
|
readonly codecVersion?: number;
|
|
@@ -337,7 +337,7 @@ function reshapeArray(flat: unknown[], shape: readonly number[]): unknown {
|
|
|
337
337
|
// Why: decoding needs to reject incompatible envelopes before we attempt to interpret payloads.
|
|
338
338
|
const CODEC_VERSION = 1;
|
|
339
339
|
|
|
340
|
-
function assertCodecVersion(envelope: { codecVersion?: unknown },
|
|
340
|
+
function assertCodecVersion(envelope: { codecVersion?: unknown }, typeTag: string): void {
|
|
341
341
|
if (!('codecVersion' in envelope)) {
|
|
342
342
|
return;
|
|
343
343
|
}
|
|
@@ -346,235 +346,256 @@ function assertCodecVersion(envelope: { codecVersion?: unknown }, marker: string
|
|
|
346
346
|
return;
|
|
347
347
|
}
|
|
348
348
|
if (typeof version !== 'number' || !Number.isFinite(version)) {
|
|
349
|
-
throw new Error(`Invalid ${
|
|
349
|
+
throw new Error(`Invalid ${typeTag} envelope: codecVersion must be a number`);
|
|
350
350
|
}
|
|
351
351
|
if (version !== CODEC_VERSION) {
|
|
352
|
-
throw new Error(`Unsupported ${
|
|
352
|
+
throw new Error(`Unsupported ${typeTag} envelope codecVersion: ${version}`);
|
|
353
353
|
}
|
|
354
354
|
}
|
|
355
355
|
|
|
356
|
-
|
|
357
|
-
|
|
356
|
+
/**
|
|
357
|
+
* Per-typeTag decode handler.
|
|
358
|
+
*
|
|
359
|
+
* Why: each scientific value envelope type (dataframe, series, ndarray, scipy.sparse,
|
|
360
|
+
* torch.tensor, sklearn.estimator) has its own validation and decode logic. Splitting
|
|
361
|
+
* the dispatch into one handler per type keeps each branch focused and testable while
|
|
362
|
+
* preserving byte-identical decoded output.
|
|
363
|
+
*/
|
|
364
|
+
type EnvelopeHandler = <T>(
|
|
365
|
+
value: { [k: string]: unknown },
|
|
358
366
|
decodeArrow: (bytes: Uint8Array) => MaybePromise<T>,
|
|
359
367
|
recurse: (value: unknown) => MaybePromise<T | unknown>
|
|
360
|
-
)
|
|
361
|
-
if (!isObject(value)) {
|
|
362
|
-
return value;
|
|
363
|
-
}
|
|
364
|
-
const marker = (value as { __tywrap__?: unknown }).__tywrap__;
|
|
365
|
-
if (typeof marker !== 'string') {
|
|
366
|
-
return value as unknown;
|
|
367
|
-
}
|
|
368
|
+
) => MaybePromise<T | unknown>;
|
|
368
369
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
throw new Error('Invalid dataframe envelope: missing b64');
|
|
386
|
-
}
|
|
387
|
-
const bytes = fromBase64(b64);
|
|
388
|
-
return decodeArrow(bytes);
|
|
389
|
-
}
|
|
390
|
-
if (encoding === 'json') {
|
|
391
|
-
if (!('data' in (value as object))) {
|
|
392
|
-
throw new Error('Invalid dataframe envelope: missing data');
|
|
393
|
-
}
|
|
394
|
-
return (value as { data: unknown }).data;
|
|
370
|
+
/**
|
|
371
|
+
* Decode an Arrow-or-JSON envelope (dataframe / series).
|
|
372
|
+
*
|
|
373
|
+
* Why: dataframe and series share identical arrow/json handling; the only difference
|
|
374
|
+
* is the typeTag name used in error messages.
|
|
375
|
+
*/
|
|
376
|
+
function decodeArrowOrJsonEnvelope<T>(
|
|
377
|
+
value: { [k: string]: unknown },
|
|
378
|
+
decodeArrow: (bytes: Uint8Array) => MaybePromise<T>,
|
|
379
|
+
typeTag: string
|
|
380
|
+
): MaybePromise<T | unknown> {
|
|
381
|
+
const encoding = value.encoding;
|
|
382
|
+
if (encoding === 'arrow') {
|
|
383
|
+
const b64 = value.b64;
|
|
384
|
+
if (typeof b64 !== 'string') {
|
|
385
|
+
throw new Error(`Invalid ${typeTag} envelope: missing b64`);
|
|
395
386
|
}
|
|
396
|
-
|
|
387
|
+
const bytes = fromBase64(b64);
|
|
388
|
+
return decodeArrow(bytes);
|
|
397
389
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
if (encoding === 'arrow') {
|
|
402
|
-
const b64 = (value as { b64?: unknown }).b64;
|
|
403
|
-
if (typeof b64 !== 'string') {
|
|
404
|
-
throw new Error('Invalid series envelope: missing b64');
|
|
405
|
-
}
|
|
406
|
-
const bytes = fromBase64(b64);
|
|
407
|
-
return decodeArrow(bytes);
|
|
390
|
+
if (encoding === 'json') {
|
|
391
|
+
if (!('data' in value)) {
|
|
392
|
+
throw new Error(`Invalid ${typeTag} envelope: missing data`);
|
|
408
393
|
}
|
|
409
|
-
|
|
410
|
-
if (!('data' in (value as object))) {
|
|
411
|
-
throw new Error('Invalid series envelope: missing data');
|
|
412
|
-
}
|
|
413
|
-
return (value as { data: unknown }).data;
|
|
414
|
-
}
|
|
415
|
-
throw new Error(`Invalid series envelope: unsupported encoding ${String(encoding)}`);
|
|
394
|
+
return value.data;
|
|
416
395
|
}
|
|
396
|
+
throw new Error(`Invalid ${typeTag} envelope: unsupported encoding ${String(encoding)}`);
|
|
397
|
+
}
|
|
417
398
|
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
const shapeValue = (value as { shape?: unknown }).shape;
|
|
421
|
-
const shape = isNumberArray(shapeValue) ? shapeValue : undefined;
|
|
399
|
+
const decodeDataframeEnvelope: EnvelopeHandler = (value, decodeArrow) =>
|
|
400
|
+
decodeArrowOrJsonEnvelope(value, decodeArrow, 'dataframe');
|
|
422
401
|
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
if (typeof b64 !== 'string') {
|
|
426
|
-
throw new Error('Invalid ndarray envelope: missing b64');
|
|
427
|
-
}
|
|
428
|
-
const bytes = fromBase64(b64);
|
|
429
|
-
const decoded = decodeArrow(bytes);
|
|
430
|
-
|
|
431
|
-
// Extract values from Arrow table and reshape if needed
|
|
432
|
-
// Arrow only handles 1D arrays, so we flatten on encode and reshape here
|
|
433
|
-
// Reshape for: scalars (shape.length === 0) and multi-dim (shape.length > 1)
|
|
434
|
-
// Skip reshape for: 1D arrays (shape.length === 1) - return as-is
|
|
435
|
-
if (isPromiseLike(decoded)) {
|
|
436
|
-
return decoded.then(data => {
|
|
437
|
-
const values = extractArrowValues(data);
|
|
438
|
-
if (!values) {
|
|
439
|
-
return data; // Fallback: return raw data if extraction fails
|
|
440
|
-
}
|
|
441
|
-
// Reshape scalars and multi-dimensional arrays, but not 1D
|
|
442
|
-
if (shape && shape.length !== 1) {
|
|
443
|
-
return reshapeArray(values, shape);
|
|
444
|
-
}
|
|
445
|
-
return values;
|
|
446
|
-
});
|
|
447
|
-
}
|
|
448
|
-
const values = extractArrowValues(decoded);
|
|
449
|
-
if (!values) {
|
|
450
|
-
return decoded; // Fallback: return raw data if extraction fails
|
|
451
|
-
}
|
|
452
|
-
// Reshape scalars and multi-dimensional arrays, but not 1D
|
|
453
|
-
if (shape && shape.length !== 1) {
|
|
454
|
-
return reshapeArray(values, shape);
|
|
455
|
-
}
|
|
456
|
-
return values;
|
|
457
|
-
}
|
|
458
|
-
if (encoding === 'json') {
|
|
459
|
-
if (!('data' in (value as object))) {
|
|
460
|
-
throw new Error('Invalid ndarray envelope: missing data');
|
|
461
|
-
}
|
|
462
|
-
return (value as { data: unknown }).data;
|
|
463
|
-
}
|
|
464
|
-
throw new Error(`Invalid ndarray envelope: unsupported encoding ${String(encoding)}`);
|
|
465
|
-
}
|
|
402
|
+
const decodeSeriesEnvelope: EnvelopeHandler = (value, decodeArrow) =>
|
|
403
|
+
decodeArrowOrJsonEnvelope(value, decodeArrow, 'series');
|
|
466
404
|
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
405
|
+
const decodeNdarrayEnvelope: EnvelopeHandler = (value, decodeArrow) => {
|
|
406
|
+
const encoding = value.encoding;
|
|
407
|
+
const shapeValue = value.shape;
|
|
408
|
+
const shape = isNumberArray(shapeValue) ? shapeValue : undefined;
|
|
409
|
+
|
|
410
|
+
if (encoding === 'arrow') {
|
|
411
|
+
const b64 = value.b64;
|
|
412
|
+
if (typeof b64 !== 'string') {
|
|
413
|
+
throw new Error('Invalid ndarray envelope: missing b64');
|
|
471
414
|
}
|
|
472
|
-
const
|
|
473
|
-
|
|
474
|
-
|
|
415
|
+
const bytes = fromBase64(b64);
|
|
416
|
+
const decoded = decodeArrow(bytes);
|
|
417
|
+
|
|
418
|
+
// Extract values from Arrow table and reshape if needed
|
|
419
|
+
// Arrow only handles 1D arrays, so we flatten on encode and reshape here
|
|
420
|
+
// Reshape for: scalars (shape.length === 0) and multi-dim (shape.length > 1)
|
|
421
|
+
// Skip reshape for: 1D arrays (shape.length === 1) - return as-is
|
|
422
|
+
if (isPromiseLike(decoded)) {
|
|
423
|
+
return decoded.then(data => {
|
|
424
|
+
const values = extractArrowValues(data);
|
|
425
|
+
if (!values) {
|
|
426
|
+
return data; // Fallback: return raw data if extraction fails
|
|
427
|
+
}
|
|
428
|
+
// Reshape scalars and multi-dimensional arrays, but not 1D
|
|
429
|
+
if (shape && shape.length !== 1) {
|
|
430
|
+
return reshapeArray(values, shape);
|
|
431
|
+
}
|
|
432
|
+
return values;
|
|
433
|
+
});
|
|
475
434
|
}
|
|
476
|
-
const
|
|
477
|
-
if (
|
|
478
|
-
|
|
479
|
-
shape.length !== 2 ||
|
|
480
|
-
typeof shape[0] !== 'number' ||
|
|
481
|
-
typeof shape[1] !== 'number'
|
|
482
|
-
) {
|
|
483
|
-
throw new Error('Invalid scipy.sparse envelope: shape must be a 2-item number[]');
|
|
435
|
+
const values = extractArrowValues(decoded);
|
|
436
|
+
if (!values) {
|
|
437
|
+
return decoded; // Fallback: return raw data if extraction fails
|
|
484
438
|
}
|
|
485
|
-
|
|
486
|
-
if (
|
|
487
|
-
|
|
439
|
+
// Reshape scalars and multi-dimensional arrays, but not 1D
|
|
440
|
+
if (shape && shape.length !== 1) {
|
|
441
|
+
return reshapeArray(values, shape);
|
|
488
442
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
if (
|
|
493
|
-
|
|
494
|
-
const col = (value as { col?: unknown }).col;
|
|
495
|
-
if (!Array.isArray(row) || !Array.isArray(col)) {
|
|
496
|
-
throw new Error('Invalid scipy.sparse envelope: coo requires row and col arrays');
|
|
497
|
-
}
|
|
498
|
-
return {
|
|
499
|
-
format,
|
|
500
|
-
shape,
|
|
501
|
-
data,
|
|
502
|
-
row,
|
|
503
|
-
col,
|
|
504
|
-
dtype,
|
|
505
|
-
} satisfies SparseMatrix;
|
|
443
|
+
return values;
|
|
444
|
+
}
|
|
445
|
+
if (encoding === 'json') {
|
|
446
|
+
if (!('data' in value)) {
|
|
447
|
+
throw new Error('Invalid ndarray envelope: missing data');
|
|
506
448
|
}
|
|
449
|
+
return value.data;
|
|
450
|
+
}
|
|
451
|
+
throw new Error(`Invalid ndarray envelope: unsupported encoding ${String(encoding)}`);
|
|
452
|
+
};
|
|
507
453
|
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
454
|
+
const decodeScipySparseEnvelope: EnvelopeHandler = value => {
|
|
455
|
+
const encoding = value.encoding;
|
|
456
|
+
if (encoding !== 'json') {
|
|
457
|
+
throw new Error(`Invalid scipy.sparse envelope: unsupported encoding ${String(encoding)}`);
|
|
458
|
+
}
|
|
459
|
+
const format = value.format;
|
|
460
|
+
if (format !== 'csr' && format !== 'csc' && format !== 'coo') {
|
|
461
|
+
throw new Error(`Invalid scipy.sparse envelope: unsupported format ${String(format)}`);
|
|
462
|
+
}
|
|
463
|
+
const shape = value.shape;
|
|
464
|
+
if (
|
|
465
|
+
!Array.isArray(shape) ||
|
|
466
|
+
shape.length !== 2 ||
|
|
467
|
+
typeof shape[0] !== 'number' ||
|
|
468
|
+
typeof shape[1] !== 'number'
|
|
469
|
+
) {
|
|
470
|
+
throw new Error('Invalid scipy.sparse envelope: shape must be a 2-item number[]');
|
|
471
|
+
}
|
|
472
|
+
const data = value.data;
|
|
473
|
+
if (!Array.isArray(data)) {
|
|
474
|
+
throw new Error('Invalid scipy.sparse envelope: data must be an array');
|
|
475
|
+
}
|
|
476
|
+
const dtypeValue = value.dtype;
|
|
477
|
+
const dtype = typeof dtypeValue === 'string' ? dtypeValue : undefined;
|
|
478
|
+
|
|
479
|
+
if (format === 'coo') {
|
|
480
|
+
const row = value.row;
|
|
481
|
+
const col = value.col;
|
|
482
|
+
if (!Array.isArray(row) || !Array.isArray(col)) {
|
|
483
|
+
throw new Error('Invalid scipy.sparse envelope: coo requires row and col arrays');
|
|
512
484
|
}
|
|
513
485
|
return {
|
|
514
486
|
format,
|
|
515
487
|
shape,
|
|
516
488
|
data,
|
|
517
|
-
|
|
518
|
-
|
|
489
|
+
row,
|
|
490
|
+
col,
|
|
519
491
|
dtype,
|
|
520
492
|
} satisfies SparseMatrix;
|
|
521
493
|
}
|
|
522
494
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
495
|
+
const indices = value.indices;
|
|
496
|
+
const indptr = value.indptr;
|
|
497
|
+
if (!Array.isArray(indices) || !Array.isArray(indptr)) {
|
|
498
|
+
throw new Error('Invalid scipy.sparse envelope: csr/csc requires indices and indptr arrays');
|
|
499
|
+
}
|
|
500
|
+
return {
|
|
501
|
+
format,
|
|
502
|
+
shape,
|
|
503
|
+
data,
|
|
504
|
+
indices,
|
|
505
|
+
indptr,
|
|
506
|
+
dtype,
|
|
507
|
+
} satisfies SparseMatrix;
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
const decodeTorchTensorEnvelope: EnvelopeHandler = <T>(
|
|
511
|
+
value: { [k: string]: unknown },
|
|
512
|
+
_decodeArrow: (bytes: Uint8Array) => MaybePromise<T>,
|
|
513
|
+
recurse: (value: unknown) => MaybePromise<T | unknown>
|
|
514
|
+
): MaybePromise<T | unknown> => {
|
|
515
|
+
const encoding = value.encoding;
|
|
516
|
+
if (encoding !== 'ndarray') {
|
|
517
|
+
throw new Error(`Invalid torch.tensor envelope: unsupported encoding ${String(encoding)}`);
|
|
518
|
+
}
|
|
519
|
+
if (!('value' in value)) {
|
|
520
|
+
throw new Error('Invalid torch.tensor envelope: missing value');
|
|
521
|
+
}
|
|
522
|
+
const nested = value.value;
|
|
523
|
+
if (!isObject(nested) || (nested as { __tywrap__?: unknown }).__tywrap__ !== 'ndarray') {
|
|
524
|
+
throw new Error('Invalid torch.tensor envelope: value must be an ndarray envelope');
|
|
525
|
+
}
|
|
526
|
+
const decoded = recurse(nested);
|
|
527
|
+
const shapeValue = value.shape;
|
|
528
|
+
const shape = isNumberArray(shapeValue) ? shapeValue : undefined;
|
|
529
|
+
const dtypeValue = value.dtype;
|
|
530
|
+
const dtype = typeof dtypeValue === 'string' ? dtypeValue : undefined;
|
|
531
|
+
const deviceValue = value.device;
|
|
532
|
+
const device = typeof deviceValue === 'string' ? deviceValue : undefined;
|
|
542
533
|
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
}
|
|
546
|
-
return { data: decoded, shape, dtype, device } satisfies TorchTensor;
|
|
534
|
+
if (isPromiseLike(decoded)) {
|
|
535
|
+
return decoded.then(data => ({ data, shape, dtype, device })) as Promise<T | unknown>;
|
|
547
536
|
}
|
|
537
|
+
return { data: decoded, shape, dtype, device } satisfies TorchTensor;
|
|
538
|
+
};
|
|
548
539
|
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
540
|
+
const decodeSklearnEstimatorEnvelope: EnvelopeHandler = value => {
|
|
541
|
+
const encoding = value.encoding;
|
|
542
|
+
if (encoding !== 'json') {
|
|
543
|
+
throw new Error(`Invalid sklearn.estimator envelope: unsupported encoding ${String(encoding)}`);
|
|
544
|
+
}
|
|
545
|
+
const className = value.className;
|
|
546
|
+
const module = value.module;
|
|
547
|
+
const params = value.params;
|
|
548
|
+
if (typeof className !== 'string' || typeof module !== 'string' || !isObject(params)) {
|
|
549
|
+
throw new Error(
|
|
550
|
+
'Invalid sklearn.estimator envelope: expected className/module strings + params object'
|
|
551
|
+
);
|
|
552
|
+
}
|
|
553
|
+
const versionValue = value.version;
|
|
554
|
+
if (versionValue !== undefined && typeof versionValue !== 'string') {
|
|
555
|
+
throw new Error('Invalid sklearn.estimator envelope: version must be a string when provided');
|
|
556
|
+
}
|
|
557
|
+
const version = typeof versionValue === 'string' ? versionValue : undefined;
|
|
558
|
+
return {
|
|
559
|
+
className,
|
|
560
|
+
module,
|
|
561
|
+
version,
|
|
562
|
+
params,
|
|
563
|
+
} satisfies SklearnEstimator;
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
// Why: dispatch over the __tywrap__ typeTag instead of a long if-chain so each type's
|
|
567
|
+
// decode logic lives in one focused handler. The typeTag strings are the on-the-wire keys
|
|
568
|
+
// emitted by the Python bridge and MUST stay byte-identical. A Map keyed by the typeTag
|
|
569
|
+
// avoids prototype-chain lookups when dispatching on attacker-controlled typeTag strings.
|
|
570
|
+
const ENVELOPE_HANDLERS: ReadonlyMap<string, EnvelopeHandler> = new Map([
|
|
571
|
+
['dataframe', decodeDataframeEnvelope],
|
|
572
|
+
['series', decodeSeriesEnvelope],
|
|
573
|
+
['ndarray', decodeNdarrayEnvelope],
|
|
574
|
+
['scipy.sparse', decodeScipySparseEnvelope],
|
|
575
|
+
['torch.tensor', decodeTorchTensorEnvelope],
|
|
576
|
+
['sklearn.estimator', decodeSklearnEstimatorEnvelope],
|
|
577
|
+
]);
|
|
578
|
+
|
|
579
|
+
function decodeEnvelopeCore<T>(
|
|
580
|
+
value: unknown,
|
|
581
|
+
decodeArrow: (bytes: Uint8Array) => MaybePromise<T>,
|
|
582
|
+
recurse: (value: unknown) => MaybePromise<T | unknown>
|
|
583
|
+
): MaybePromise<T | unknown> {
|
|
584
|
+
if (!isObject(value)) {
|
|
585
|
+
return value;
|
|
586
|
+
}
|
|
587
|
+
const typeTag = (value as { __tywrap__?: unknown }).__tywrap__;
|
|
588
|
+
if (typeof typeTag !== 'string') {
|
|
589
|
+
return value as unknown;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
const handler = ENVELOPE_HANDLERS.get(typeTag);
|
|
593
|
+
if (!handler) {
|
|
594
|
+
return value as unknown;
|
|
575
595
|
}
|
|
576
596
|
|
|
577
|
-
|
|
597
|
+
assertCodecVersion(value as { codecVersion?: unknown }, typeTag);
|
|
598
|
+
return handler(value, decodeArrow, recurse);
|
|
578
599
|
}
|
|
579
600
|
|
|
580
601
|
function decodeEnvelope<T>(value: unknown, decodeArrow: (bytes: Uint8Array) => T): T | unknown {
|
package/src/utils/python.ts
CHANGED
|
@@ -44,30 +44,43 @@ export function getDefaultPythonPath(): string {
|
|
|
44
44
|
return getPythonExecutableName();
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
/**
|
|
48
|
+
* Whether the configured pythonPath is the default interpreter (or unset),
|
|
49
|
+
* meaning a virtual environment lookup should take precedence.
|
|
50
|
+
*/
|
|
51
|
+
function usesDefaultPython(pythonPath: string | undefined): boolean {
|
|
52
|
+
return !pythonPath || pythonPath === 'python3' || pythonPath === 'python';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Resolve the Python executable inside a virtual environment, preferring the
|
|
57
|
+
* Node path module when available and falling back to cross-runtime pathUtils.
|
|
58
|
+
*/
|
|
59
|
+
async function resolveVenvPython(virtualEnv: string, cwd: string): Promise<string> {
|
|
60
|
+
const binDir = getVenvBinDir();
|
|
61
|
+
const exe = getVenvPythonExe();
|
|
62
|
+
const pathMod = await loadNodePathModule();
|
|
63
|
+
|
|
64
|
+
if (pathMod) {
|
|
65
|
+
const venvRoot = pathMod.resolve(cwd, virtualEnv);
|
|
66
|
+
return pathMod.join(venvRoot, binDir, exe);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const venvRoot = isAbsolutePath(virtualEnv)
|
|
70
|
+
? pathUtils.join(virtualEnv)
|
|
71
|
+
: pathUtils.join(cwd, virtualEnv);
|
|
72
|
+
return pathUtils.join(venvRoot, binDir, exe);
|
|
73
|
+
}
|
|
74
|
+
|
|
47
75
|
export async function resolvePythonExecutable(options: PythonResolveOptions = {}): Promise<string> {
|
|
48
76
|
const pythonPath = options.pythonPath?.trim();
|
|
49
77
|
const virtualEnv = options.virtualEnv?.trim();
|
|
50
78
|
|
|
51
|
-
if (virtualEnv) {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
(typeof process !== 'undefined' && typeof process.cwd === 'function' ? process.cwd() : '.');
|
|
57
|
-
const binDir = getVenvBinDir();
|
|
58
|
-
const exe = getVenvPythonExe();
|
|
59
|
-
const pathMod = await loadNodePathModule();
|
|
60
|
-
|
|
61
|
-
if (pathMod) {
|
|
62
|
-
const venvRoot = pathMod.resolve(cwd, virtualEnv);
|
|
63
|
-
return pathMod.join(venvRoot, binDir, exe);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const venvRoot = isAbsolutePath(virtualEnv)
|
|
67
|
-
? pathUtils.join(virtualEnv)
|
|
68
|
-
: pathUtils.join(cwd, virtualEnv);
|
|
69
|
-
return pathUtils.join(venvRoot, binDir, exe);
|
|
70
|
-
}
|
|
79
|
+
if (virtualEnv && usesDefaultPython(pythonPath)) {
|
|
80
|
+
const cwd =
|
|
81
|
+
options.cwd ??
|
|
82
|
+
(typeof process !== 'undefined' && typeof process.cwd === 'function' ? process.cwd() : '.');
|
|
83
|
+
return resolveVenvPython(virtualEnv, cwd);
|
|
71
84
|
}
|
|
72
85
|
|
|
73
86
|
if (pythonPath) {
|
package/src/utils/runtime.ts
CHANGED
|
@@ -229,26 +229,37 @@ async function loadPathModule(): Promise<PathModule | null> {
|
|
|
229
229
|
return null;
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Apply a single path segment to the accumulated normalized segments,
|
|
234
|
+
* resolving '..' and dropping '.'/empty segments in place.
|
|
235
|
+
*/
|
|
236
|
+
function applyPathSegment(normalized: string[], segment: string, isAbsolute: boolean): void {
|
|
237
|
+
if (segment === '.' || segment === '') {
|
|
238
|
+
return; // Skip current directory and empty segments
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
if (segment !== '..') {
|
|
242
|
+
normalized.push(segment);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
// '..' segment: go up one directory when possible.
|
|
247
|
+
if (normalized.length > 0 && normalized[normalized.length - 1] !== '..') {
|
|
248
|
+
normalized.pop();
|
|
249
|
+
} else if (!isAbsolute) {
|
|
250
|
+
normalized.push(segment); // Keep '..' if not absolute and at root
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
|
|
232
254
|
/**
|
|
233
255
|
* Normalize path by stripping '.' and resolving '..' components
|
|
234
256
|
*/
|
|
235
257
|
function normalizePath(path: string): string {
|
|
236
258
|
const isAbsolute = path.startsWith('/');
|
|
237
|
-
const segments = path.split('/');
|
|
238
259
|
const normalized: string[] = [];
|
|
239
260
|
|
|
240
|
-
for (const segment of
|
|
241
|
-
|
|
242
|
-
continue; // Skip current directory and empty segments
|
|
243
|
-
} else if (segment === '..') {
|
|
244
|
-
if (normalized.length > 0 && normalized[normalized.length - 1] !== '..') {
|
|
245
|
-
normalized.pop(); // Go up one directory
|
|
246
|
-
} else if (!isAbsolute) {
|
|
247
|
-
normalized.push(segment); // Keep '..' if not absolute and at root
|
|
248
|
-
}
|
|
249
|
-
} else {
|
|
250
|
-
normalized.push(segment);
|
|
251
|
-
}
|
|
261
|
+
for (const segment of path.split('/')) {
|
|
262
|
+
applyPathSegment(normalized, segment, isAbsolute);
|
|
252
263
|
}
|
|
253
264
|
|
|
254
265
|
const result = normalized.join('/');
|
package/src/version.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AUTO-GENERATED — DO NOT EDIT.
|
|
3
|
+
*
|
|
4
|
+
* Source: package.json (version field)
|
|
5
|
+
* Generator: scripts/generate-version.mjs (runs in `npm run build`)
|
|
6
|
+
*
|
|
7
|
+
* Single-sources the package version so the public API can re-export it without
|
|
8
|
+
* importing package.json from outside tsconfig `rootDir`.
|
|
9
|
+
* Regenerate with: node scripts/generate-version.mjs
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export const VERSION: string = "0.6.1";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"http-io.d.ts","sourceRoot":"","sources":["../../src/runtime/http-io.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAMhD;;GAEG;AACH,MAAM,WAAW,aAAa;I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E;IAC9E,UAAU;IACV,8EAA8E;IAE9E;;OAEG;IACK,KAAK,CAAC,YAAY,CAAC,QAAkB;QAC3C,IAAI,CAAC;YACH,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC/B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,CAAC;QACZ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @deprecated Import from './node.js' instead.
|
|
3
|
-
*
|
|
4
|
-
* Backward-compat shim for older deep imports. NodeBridge is the public API,
|
|
5
|
-
* and it now supports both single-process mode (default) and multi-process
|
|
6
|
-
* pooling via the minProcesses/maxProcesses options.
|
|
7
|
-
*
|
|
8
|
-
* Migration:
|
|
9
|
-
* ```typescript
|
|
10
|
-
* // Before
|
|
11
|
-
* import { OptimizedNodeBridge, ProcessPoolOptions } from './optimized-node.js';
|
|
12
|
-
* const bridge = new OptimizedNodeBridge({ minProcesses: 2, maxProcesses: 4 });
|
|
13
|
-
*
|
|
14
|
-
* // After
|
|
15
|
-
* import { NodeBridge, NodeBridgeOptions } from './node.js';
|
|
16
|
-
* const bridge = new NodeBridge({ minProcesses: 2, maxProcesses: 4 });
|
|
17
|
-
* ```
|
|
18
|
-
*
|
|
19
|
-
* This file is not exposed through the package exports map and is maintained
|
|
20
|
-
* for backward compatibility only.
|
|
21
|
-
*/
|
|
22
|
-
export { NodeBridge as OptimizedNodeBridge, type NodeBridgeOptions as ProcessPoolOptions, } from './node.js';
|
|
23
|
-
//# sourceMappingURL=optimized-node.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"optimized-node.d.ts","sourceRoot":"","sources":["../../src/runtime/optimized-node.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EACL,UAAU,IAAI,mBAAmB,EACjC,KAAK,iBAAiB,IAAI,kBAAkB,GAC7C,MAAM,WAAW,CAAC"}
|