tywrap 0.7.0 → 0.9.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.
Files changed (165) hide show
  1. package/README.md +36 -11
  2. package/SECURITY.md +39 -0
  3. package/dist/config/index.d.ts.map +1 -1
  4. package/dist/config/index.js +8 -0
  5. package/dist/config/index.js.map +1 -1
  6. package/dist/core/annotation-parser.d.ts +2 -1
  7. package/dist/core/annotation-parser.d.ts.map +1 -1
  8. package/dist/core/annotation-parser.js +6 -3
  9. package/dist/core/annotation-parser.js.map +1 -1
  10. package/dist/core/emit-call.d.ts.map +1 -1
  11. package/dist/core/emit-call.js +1 -1
  12. package/dist/core/emit-call.js.map +1 -1
  13. package/dist/core/generator.d.ts +23 -4
  14. package/dist/core/generator.d.ts.map +1 -1
  15. package/dist/core/generator.js +243 -170
  16. package/dist/core/generator.js.map +1 -1
  17. package/dist/core/mapper.d.ts +3 -2
  18. package/dist/core/mapper.d.ts.map +1 -1
  19. package/dist/core/mapper.js +5 -5
  20. package/dist/core/mapper.js.map +1 -1
  21. package/dist/dev.d.ts.map +1 -1
  22. package/dist/dev.js +1 -3
  23. package/dist/dev.js.map +1 -1
  24. package/dist/index.d.ts +7 -5
  25. package/dist/index.d.ts.map +1 -1
  26. package/dist/index.js +6 -4
  27. package/dist/index.js.map +1 -1
  28. package/dist/runtime/base-bridge.d.ts +3 -7
  29. package/dist/runtime/base-bridge.d.ts.map +1 -1
  30. package/dist/runtime/base-bridge.js +4 -17
  31. package/dist/runtime/base-bridge.js.map +1 -1
  32. package/dist/runtime/bounded-context.d.ts +3 -22
  33. package/dist/runtime/bounded-context.d.ts.map +1 -1
  34. package/dist/runtime/bounded-context.js +13 -53
  35. package/dist/runtime/bounded-context.js.map +1 -1
  36. package/dist/runtime/bridge-codec.d.ts +1 -1
  37. package/dist/runtime/bridge-codec.d.ts.map +1 -1
  38. package/dist/runtime/bridge-codec.js +78 -55
  39. package/dist/runtime/bridge-codec.js.map +1 -1
  40. package/dist/runtime/errors.d.ts +16 -0
  41. package/dist/runtime/errors.d.ts.map +1 -1
  42. package/dist/runtime/errors.js +17 -0
  43. package/dist/runtime/errors.js.map +1 -1
  44. package/dist/runtime/frame-codec.d.ts +111 -0
  45. package/dist/runtime/frame-codec.d.ts.map +1 -0
  46. package/dist/runtime/frame-codec.js +352 -0
  47. package/dist/runtime/frame-codec.js.map +1 -0
  48. package/dist/runtime/http-transport.d.ts +1 -1
  49. package/dist/runtime/http-transport.d.ts.map +1 -1
  50. package/dist/runtime/http-transport.js +1 -1
  51. package/dist/runtime/http-transport.js.map +1 -1
  52. package/dist/runtime/index.d.ts +2 -1
  53. package/dist/runtime/index.d.ts.map +1 -1
  54. package/dist/runtime/index.js +2 -1
  55. package/dist/runtime/index.js.map +1 -1
  56. package/dist/runtime/node.d.ts +7 -23
  57. package/dist/runtime/node.d.ts.map +1 -1
  58. package/dist/runtime/node.js +5 -78
  59. package/dist/runtime/node.js.map +1 -1
  60. package/dist/runtime/pooled-transport.d.ts +120 -59
  61. package/dist/runtime/pooled-transport.d.ts.map +1 -1
  62. package/dist/runtime/pooled-transport.js +345 -78
  63. package/dist/runtime/pooled-transport.js.map +1 -1
  64. package/dist/runtime/pyodide-bootstrap-core.generated.d.ts.map +1 -1
  65. package/dist/runtime/pyodide-bootstrap-core.generated.js +1 -1
  66. package/dist/runtime/pyodide-bootstrap-core.generated.js.map +1 -1
  67. package/dist/runtime/pyodide-transport.d.ts +1 -1
  68. package/dist/runtime/pyodide-transport.d.ts.map +1 -1
  69. package/dist/runtime/pyodide-transport.js +2 -3
  70. package/dist/runtime/pyodide-transport.js.map +1 -1
  71. package/dist/runtime/rpc-client.d.ts +7 -36
  72. package/dist/runtime/rpc-client.d.ts.map +1 -1
  73. package/dist/runtime/rpc-client.js +37 -72
  74. package/dist/runtime/rpc-client.js.map +1 -1
  75. package/dist/runtime/subprocess-transport.d.ts +134 -8
  76. package/dist/runtime/subprocess-transport.d.ts.map +1 -1
  77. package/dist/runtime/subprocess-transport.js +490 -65
  78. package/dist/runtime/subprocess-transport.js.map +1 -1
  79. package/dist/runtime/timed-out-request-tracker.d.ts +2 -1
  80. package/dist/runtime/timed-out-request-tracker.d.ts.map +1 -1
  81. package/dist/runtime/transport.d.ts +90 -18
  82. package/dist/runtime/transport.d.ts.map +1 -1
  83. package/dist/runtime/transport.js +21 -1
  84. package/dist/runtime/transport.js.map +1 -1
  85. package/dist/runtime/validators.d.ts +49 -0
  86. package/dist/runtime/validators.d.ts.map +1 -1
  87. package/dist/runtime/validators.js +152 -0
  88. package/dist/runtime/validators.js.map +1 -1
  89. package/dist/types/index.d.ts +14 -15
  90. package/dist/types/index.d.ts.map +1 -1
  91. package/dist/tywrap.d.ts +3 -2
  92. package/dist/tywrap.d.ts.map +1 -1
  93. package/dist/tywrap.js +140 -21
  94. package/dist/tywrap.js.map +1 -1
  95. package/dist/utils/cache.d.ts +3 -16
  96. package/dist/utils/cache.d.ts.map +1 -1
  97. package/dist/utils/codec.d.ts +1 -0
  98. package/dist/utils/codec.d.ts.map +1 -1
  99. package/dist/utils/codec.js +165 -17
  100. package/dist/utils/codec.js.map +1 -1
  101. package/dist/utils/ir-cache.d.ts +2 -1
  102. package/dist/utils/ir-cache.d.ts.map +1 -1
  103. package/dist/utils/runtime.d.ts +0 -29
  104. package/dist/utils/runtime.d.ts.map +1 -1
  105. package/dist/utils/runtime.js +16 -107
  106. package/dist/utils/runtime.js.map +1 -1
  107. package/dist/version.js +1 -1
  108. package/package.json +7 -6
  109. package/runtime/frame_codec.py +430 -0
  110. package/runtime/python_bridge.py +213 -54
  111. package/runtime/tywrap_bridge_core.py +217 -147
  112. package/src/config/index.ts +11 -0
  113. package/src/core/annotation-parser.ts +9 -5
  114. package/src/core/emit-call.ts +1 -7
  115. package/src/core/generator.ts +315 -205
  116. package/src/core/mapper.ts +8 -8
  117. package/src/dev.ts +1 -3
  118. package/src/index.ts +7 -3
  119. package/src/runtime/base-bridge.ts +5 -30
  120. package/src/runtime/bounded-context.ts +12 -67
  121. package/src/runtime/bridge-codec.ts +94 -65
  122. package/src/runtime/errors.ts +21 -0
  123. package/src/runtime/frame-codec.ts +469 -0
  124. package/src/runtime/http-transport.ts +6 -1
  125. package/src/runtime/index.ts +7 -6
  126. package/src/runtime/node.ts +17 -104
  127. package/src/runtime/pooled-transport.ts +424 -90
  128. package/src/runtime/pyodide-bootstrap-core.generated.ts +1 -1
  129. package/src/runtime/pyodide-transport.ts +7 -3
  130. package/src/runtime/rpc-client.ts +58 -93
  131. package/src/runtime/subprocess-transport.ts +585 -80
  132. package/src/runtime/timed-out-request-tracker.ts +1 -1
  133. package/src/runtime/transport.ts +112 -22
  134. package/src/runtime/validators.ts +204 -0
  135. package/src/types/index.ts +21 -35
  136. package/src/tywrap.ts +157 -30
  137. package/src/utils/cache.ts +3 -3
  138. package/src/utils/codec.ts +205 -16
  139. package/src/utils/ir-cache.ts +1 -1
  140. package/src/utils/runtime.ts +17 -128
  141. package/src/version.ts +1 -1
  142. package/dist/core/discovery.d.ts +0 -103
  143. package/dist/core/discovery.d.ts.map +0 -1
  144. package/dist/core/discovery.js +0 -380
  145. package/dist/core/discovery.js.map +0 -1
  146. package/dist/core/validation.d.ts +0 -102
  147. package/dist/core/validation.d.ts.map +0 -1
  148. package/dist/core/validation.js +0 -490
  149. package/dist/core/validation.js.map +0 -1
  150. package/dist/runtime/base.d.ts +0 -22
  151. package/dist/runtime/base.d.ts.map +0 -1
  152. package/dist/runtime/base.js +0 -23
  153. package/dist/runtime/base.js.map +0 -1
  154. package/dist/runtime/transport-pool.d.ts +0 -196
  155. package/dist/runtime/transport-pool.d.ts.map +0 -1
  156. package/dist/runtime/transport-pool.js +0 -418
  157. package/dist/runtime/transport-pool.js.map +0 -1
  158. package/runtime/__pycache__/_tywrap_member_fixtures.cpython-311.pyc +0 -0
  159. package/runtime/__pycache__/safe_codec.cpython-311.pyc +0 -0
  160. package/runtime/__pycache__/tywrap_bridge_core.cpython-311.pyc +0 -0
  161. package/runtime/safe_codec.py +0 -352
  162. package/src/core/discovery.ts +0 -477
  163. package/src/core/validation.ts +0 -729
  164. package/src/runtime/base.ts +0 -24
  165. package/src/runtime/transport-pool.ts +0 -538
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Pure frame codec + reassembler for the `tywrap-frame/1` framing protocol.
3
+ *
4
+ * This module is the transport-agnostic core of large-payload chunking: it
5
+ * fragments one complete logical JSON message into {@link ChunkFrame}s and
6
+ * reassembles a stream of frames back into the original string. It performs NO
7
+ * I/O and knows nothing about subprocesses, stdin/stdout, or timeouts — the
8
+ * transport layer (W4/W5) wires these functions into the read/write loop.
9
+ *
10
+ * Encoding is `utf8-slice` (plan decision #6, docs/transport-framing.md): the
11
+ * logical payload is already valid-UTF-8 JSON, so each frame's `data` is a raw
12
+ * substring split on a UTF-8 codepoint boundary at or before `maxFrameBytes`
13
+ * UTF-8 bytes. Reassembly is plain concatenation — no base64, no ~33% inflation,
14
+ * no extra decode pass. A frame's `data` MUST NOT split a multi-byte UTF-8
15
+ * sequence; {@link encodeFrames} guarantees this by snapping every boundary back
16
+ * to the nearest codepoint boundary.
17
+ *
18
+ * The mirror implementation lives in `runtime/frame_codec.py`; the two MUST
19
+ * agree byte-for-byte on the wire (see test/frame-codec.test.ts and
20
+ * test/python/test_frame_codec.py for the cross-language parity vectors).
21
+ *
22
+ * @see docs/transport-framing.md
23
+ */
24
+ import { type ChunkFrame } from './transport.js';
25
+ /** Which logical stream a set of frames belongs to. */
26
+ export type FrameStream = ChunkFrame['stream'];
27
+ /** Options for {@link encodeFrames}. */
28
+ export interface EncodeFramesOptions {
29
+ /** RPC correlation id, shared with the logical {@link ProtocolMessage.id}. */
30
+ readonly id: number;
31
+ /** Which logical stream these frames belong to (`request` or `response`). */
32
+ readonly stream: FrameStream;
33
+ /**
34
+ * Maximum UTF-8 byte length of a single frame's `data` field. Each frame's
35
+ * `data` is guaranteed to be at most this many UTF-8 bytes, snapped back to a
36
+ * codepoint boundary so no multi-byte sequence is split. Must be a positive
37
+ * integer large enough to hold at least one codepoint (>= 4 bytes).
38
+ */
39
+ readonly maxFrameBytes: number;
40
+ }
41
+ /** Exact UTF-8 byte length of a JS string (no allocation of the encoded bytes). */
42
+ export declare function utf8ByteLength(value: string): number;
43
+ /**
44
+ * Fragment a complete logical JSON message into `tywrap-frame/1` frames.
45
+ *
46
+ * Splits `logicalJson` on UTF-8 codepoint boundaries so each frame's `data` is
47
+ * at most `maxFrameBytes` UTF-8 bytes and never splits a multi-byte sequence.
48
+ * `totalBytes` is the exact UTF-8 byte length of the full message; `total` is
49
+ * the resulting frame count; `seq` is zero-based and dense.
50
+ *
51
+ * An empty `logicalJson` still produces exactly one (empty) frame so the
52
+ * receiver always sees `total >= 1` and a well-formed stream.
53
+ *
54
+ * @throws BridgeProtocolError if `maxFrameBytes` is not a positive integer of at
55
+ * least 4 bytes (the worst-case single-codepoint size).
56
+ */
57
+ export declare function encodeFrames(logicalJson: string, opts: EncodeFramesOptions): ChunkFrame[];
58
+ /**
59
+ * Validates that a raw value is a structurally well-formed `tywrap-frame/1` data
60
+ * frame. Returns the frame typed, or throws a {@link BridgeProtocolError}.
61
+ *
62
+ * Only `__tywrap_frame__: 'chunk'` frames flow through reassembly; `'error'`
63
+ * frames are a transport-layer concern handled above this module.
64
+ */
65
+ export declare function parseChunkFrame(value: unknown): ChunkFrame;
66
+ export declare class Reassembler {
67
+ private readonly streams;
68
+ private readonly discarded;
69
+ private readonly maxReassemblyBytes;
70
+ private readonly expectedStream;
71
+ /**
72
+ * @param options.maxReassemblyBytes Reject (fail loud) any stream whose
73
+ * declared OR accumulated payload exceeds this many UTF-8 bytes, so a huge
74
+ * response cannot be buffered into memory before a higher layer's size cap
75
+ * would reject it anyway. Default: no limit (`Infinity`).
76
+ * @param options.expectedStream If set, every frame must carry this `stream`
77
+ * direction; a frame for the other direction is rejected. The response and
78
+ * request reassemblers are distinct instances, so this is defense-in-depth.
79
+ */
80
+ constructor(options?: {
81
+ maxReassemblyBytes?: number;
82
+ expectedStream?: FrameStream;
83
+ });
84
+ /**
85
+ * Feed one frame. Returns the fully reassembled logical string when this
86
+ * frame completes the stream for its id, `null` if more frames are still
87
+ * needed (or the frame was dropped because its id is timed out).
88
+ *
89
+ * @throws BridgeProtocolError on any framing violation (malformed frame,
90
+ * wrong stream direction, declared/accumulated payload over the cap,
91
+ * duplicate `seq`, inconsistent `total`/`totalBytes`, byte-count mismatch,
92
+ * invalid UTF-8, or unknown `frameProtocol`).
93
+ */
94
+ accept(rawFrame: unknown): string | null;
95
+ /**
96
+ * Mark an id as timed out / aborted. Any partial state is dropped immediately
97
+ * and every subsequent frame for this id is discarded until its declared
98
+ * final frame arrives. Idempotent.
99
+ */
100
+ discard(id: number): void;
101
+ /** Whether any frame for `id` is still being accumulated (not yet complete). */
102
+ isPending(id: number): boolean;
103
+ /** Number of ids currently mid-reassembly (for diagnostics/tests). */
104
+ get pendingCount(): number;
105
+ /**
106
+ * Number of timed-out ids whose late frames are still being dropped
107
+ * (FIFO-bounded by `MAX_DISCARDED_IDS`; for diagnostics/tests).
108
+ */
109
+ get discardedCount(): number;
110
+ }
111
+ //# sourceMappingURL=frame-codec.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frame-codec.d.ts","sourceRoot":"","sources":["../../src/runtime/frame-codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,EAAqB,KAAK,UAAU,EAA2B,MAAM,gBAAgB,CAAC;AAM7F,uDAAuD;AACvD,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;AAE/C,wCAAwC;AACxC,MAAM,WAAW,mBAAmB;IAClC,8EAA8E;IAC9E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB,6EAA6E;IAC7E,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAE7B;;;;;OAKG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;CAChC;AAuBD,mFAAmF;AACnF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMpD;AAMD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,mBAAmB,GAAG,UAAU,EAAE,CA0DzF;AAgBD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,UAAU,CAoE1D;AAkCD,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAC1D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAqB;IAC/C,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAS;IAC5C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAA0B;IAEzD;;;;;;;;OAQG;gBACS,OAAO,GAAE;QAAE,kBAAkB,CAAC,EAAE,MAAM,CAAC;QAAC,cAAc,CAAC,EAAE,WAAW,CAAA;KAAO;IAKvF;;;;;;;;;OASG;IACH,MAAM,CAAC,QAAQ,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI;IAwHxC;;;;OAIG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAczB,gFAAgF;IAChF,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAI9B,sEAAsE;IACtE,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED;;;OAGG;IACH,IAAI,cAAc,IAAI,MAAM,CAE3B;CACF"}
@@ -0,0 +1,352 @@
1
+ /**
2
+ * Pure frame codec + reassembler for the `tywrap-frame/1` framing protocol.
3
+ *
4
+ * This module is the transport-agnostic core of large-payload chunking: it
5
+ * fragments one complete logical JSON message into {@link ChunkFrame}s and
6
+ * reassembles a stream of frames back into the original string. It performs NO
7
+ * I/O and knows nothing about subprocesses, stdin/stdout, or timeouts — the
8
+ * transport layer (W4/W5) wires these functions into the read/write loop.
9
+ *
10
+ * Encoding is `utf8-slice` (plan decision #6, docs/transport-framing.md): the
11
+ * logical payload is already valid-UTF-8 JSON, so each frame's `data` is a raw
12
+ * substring split on a UTF-8 codepoint boundary at or before `maxFrameBytes`
13
+ * UTF-8 bytes. Reassembly is plain concatenation — no base64, no ~33% inflation,
14
+ * no extra decode pass. A frame's `data` MUST NOT split a multi-byte UTF-8
15
+ * sequence; {@link encodeFrames} guarantees this by snapping every boundary back
16
+ * to the nearest codepoint boundary.
17
+ *
18
+ * The mirror implementation lives in `runtime/frame_codec.py`; the two MUST
19
+ * agree byte-for-byte on the wire (see test/frame-codec.test.ts and
20
+ * test/python/test_frame_codec.py for the cross-language parity vectors).
21
+ *
22
+ * @see docs/transport-framing.md
23
+ */
24
+ import { BridgeProtocolError } from './errors.js';
25
+ import { FRAME_PROTOCOL_ID } from './transport.js';
26
+ // =============================================================================
27
+ // UTF-8 HELPERS (pure, codepoint-boundary aware)
28
+ // =============================================================================
29
+ const utf8Encoder = new TextEncoder();
30
+ const utf8Decoder = new TextDecoder('utf-8', { fatal: true });
31
+ /** UTF-8 byte length of a single Unicode codepoint. */
32
+ function utf8ByteLengthOfCodePoint(codePoint) {
33
+ if (codePoint <= 0x7f) {
34
+ return 1;
35
+ }
36
+ if (codePoint <= 0x7ff) {
37
+ return 2;
38
+ }
39
+ if (codePoint <= 0xffff) {
40
+ return 3;
41
+ }
42
+ return 4;
43
+ }
44
+ /** Exact UTF-8 byte length of a JS string (no allocation of the encoded bytes). */
45
+ export function utf8ByteLength(value) {
46
+ let bytes = 0;
47
+ for (const ch of value) {
48
+ bytes += utf8ByteLengthOfCodePoint(ch.codePointAt(0) ?? 0);
49
+ }
50
+ return bytes;
51
+ }
52
+ // =============================================================================
53
+ // ENCODE
54
+ // =============================================================================
55
+ /**
56
+ * Fragment a complete logical JSON message into `tywrap-frame/1` frames.
57
+ *
58
+ * Splits `logicalJson` on UTF-8 codepoint boundaries so each frame's `data` is
59
+ * at most `maxFrameBytes` UTF-8 bytes and never splits a multi-byte sequence.
60
+ * `totalBytes` is the exact UTF-8 byte length of the full message; `total` is
61
+ * the resulting frame count; `seq` is zero-based and dense.
62
+ *
63
+ * An empty `logicalJson` still produces exactly one (empty) frame so the
64
+ * receiver always sees `total >= 1` and a well-formed stream.
65
+ *
66
+ * @throws BridgeProtocolError if `maxFrameBytes` is not a positive integer of at
67
+ * least 4 bytes (the worst-case single-codepoint size).
68
+ */
69
+ export function encodeFrames(logicalJson, opts) {
70
+ const { id, stream, maxFrameBytes } = opts;
71
+ if (!Number.isInteger(maxFrameBytes) || maxFrameBytes < 4) {
72
+ throw new BridgeProtocolError(`encodeFrames: maxFrameBytes must be an integer >= 4 (got ${String(maxFrameBytes)})`, { code: 'FRAME_BAD_MAX_BYTES' });
73
+ }
74
+ // Validate the protocol fields locally too (parseChunkFrame enforces them on
75
+ // the decode side, but catching misuse at the encoder fails fast and keeps the
76
+ // two sides symmetric with the Python encoder).
77
+ if (stream !== 'request' && stream !== 'response') {
78
+ throw new BridgeProtocolError(`encodeFrames: stream must be 'request' or 'response' (got ${String(stream)})`, { code: 'FRAME_BAD_STREAM' });
79
+ }
80
+ if (!Number.isInteger(id)) {
81
+ throw new BridgeProtocolError(`encodeFrames: id must be an integer (got ${String(id)})`, {
82
+ code: 'FRAME_BAD_ID',
83
+ });
84
+ }
85
+ const totalBytes = utf8ByteLength(logicalJson);
86
+ const encoding = 'utf8-slice';
87
+ // Walk codepoints, accumulating UTF-8 bytes into the current slice until the
88
+ // next codepoint would exceed maxFrameBytes; that boundary is, by
89
+ // construction, a codepoint boundary so no multi-byte sequence is split.
90
+ const slices = [];
91
+ let current = '';
92
+ let currentBytes = 0;
93
+ for (const ch of logicalJson) {
94
+ const chBytes = utf8ByteLengthOfCodePoint(ch.codePointAt(0) ?? 0);
95
+ if (currentBytes + chBytes > maxFrameBytes && current.length > 0) {
96
+ slices.push(current);
97
+ current = '';
98
+ currentBytes = 0;
99
+ }
100
+ current += ch;
101
+ currentBytes += chBytes;
102
+ }
103
+ // Always emit a final slice (covers the empty-string case: one empty frame).
104
+ slices.push(current);
105
+ const total = slices.length;
106
+ return slices.map((data, seq) => ({
107
+ __tywrap_frame__: 'chunk',
108
+ frameProtocol: FRAME_PROTOCOL_ID,
109
+ stream,
110
+ id,
111
+ seq,
112
+ total,
113
+ totalBytes,
114
+ encoding,
115
+ data,
116
+ }));
117
+ }
118
+ /**
119
+ * Validates that a raw value is a structurally well-formed `tywrap-frame/1` data
120
+ * frame. Returns the frame typed, or throws a {@link BridgeProtocolError}.
121
+ *
122
+ * Only `__tywrap_frame__: 'chunk'` frames flow through reassembly; `'error'`
123
+ * frames are a transport-layer concern handled above this module.
124
+ */
125
+ export function parseChunkFrame(value) {
126
+ if (value === null || typeof value !== 'object') {
127
+ throw new BridgeProtocolError('frame: expected an object', {
128
+ code: 'FRAME_MALFORMED',
129
+ });
130
+ }
131
+ const f = value;
132
+ if (f.__tywrap_frame__ !== 'chunk') {
133
+ throw new BridgeProtocolError(`frame: __tywrap_frame__ must be "chunk" (got ${JSON.stringify(f.__tywrap_frame__)})`, { code: 'FRAME_MALFORMED' });
134
+ }
135
+ if (f.frameProtocol !== FRAME_PROTOCOL_ID) {
136
+ throw new BridgeProtocolError(`frame: unknown frameProtocol ${JSON.stringify(f.frameProtocol)} (expected ${FRAME_PROTOCOL_ID})`, { code: 'FRAME_UNKNOWN_PROTOCOL' });
137
+ }
138
+ if (f.stream !== 'request' && f.stream !== 'response') {
139
+ throw new BridgeProtocolError(`frame: stream must be "request" or "response" (got ${JSON.stringify(f.stream)})`, { code: 'FRAME_MALFORMED' });
140
+ }
141
+ if (f.encoding !== 'utf8-slice') {
142
+ // utf8-base64 is reserved in the schema but never emitted/accepted in 0.8.0.
143
+ throw new BridgeProtocolError(`frame: unsupported encoding ${JSON.stringify(f.encoding)} (only "utf8-slice" in 0.8.0)`, { code: 'FRAME_MALFORMED' });
144
+ }
145
+ if (!Number.isInteger(f.id)) {
146
+ throw new BridgeProtocolError(`frame: id must be an integer (got ${JSON.stringify(f.id)})`, {
147
+ code: 'FRAME_MALFORMED',
148
+ });
149
+ }
150
+ if (!Number.isInteger(f.seq) || f.seq < 0) {
151
+ throw new BridgeProtocolError(`frame: seq must be a non-negative integer (got ${JSON.stringify(f.seq)})`, { code: 'FRAME_MALFORMED' });
152
+ }
153
+ if (!Number.isInteger(f.total) || f.total < 1) {
154
+ throw new BridgeProtocolError(`frame: total must be an integer >= 1 (got ${JSON.stringify(f.total)})`, { code: 'FRAME_MALFORMED' });
155
+ }
156
+ if (!Number.isInteger(f.totalBytes) || f.totalBytes < 0) {
157
+ throw new BridgeProtocolError(`frame: totalBytes must be a non-negative integer (got ${JSON.stringify(f.totalBytes)})`, { code: 'FRAME_MALFORMED' });
158
+ }
159
+ if (typeof f.data !== 'string') {
160
+ throw new BridgeProtocolError(`frame: data must be a string (got ${typeof f.data})`, {
161
+ code: 'FRAME_MALFORMED',
162
+ });
163
+ }
164
+ if (f.seq >= f.total) {
165
+ throw new BridgeProtocolError(`frame: seq ${String(f.seq)} out of range for total ${String(f.total)}`, { code: 'FRAME_MALFORMED' });
166
+ }
167
+ return f;
168
+ }
169
+ /**
170
+ * Accumulates `tywrap-frame/1` frames by `id` and reconstructs the logical JSON
171
+ * string once a stream is complete.
172
+ *
173
+ * A single instance handles many concurrent ids (each correlated by
174
+ * {@link ChunkFrame.id}). Validation is enforced on every {@link accept} so a
175
+ * malformed/duplicate/inconsistent frame fails fast rather than corrupting an
176
+ * in-flight reassembly:
177
+ *
178
+ * - matching {@link FRAME_PROTOCOL_ID} on every frame;
179
+ * - consistent `total` / `totalBytes` across all frames of an id;
180
+ * - no duplicate `seq`;
181
+ * - on completion, exactly `total` frames covering `[0, total)`;
182
+ * - the concatenated payload's UTF-8 byte length equals `totalBytes` exactly;
183
+ * - the concatenated payload decodes as strict UTF-8.
184
+ *
185
+ * Timed-out ids: the transport marks an id timed out via {@link discard}. Every
186
+ * subsequent frame for that id is dropped (returning `null`) until its final
187
+ * frame arrives, at which point the id is forgotten so the slot can be reused.
188
+ * This prevents late multi-frame responses from desyncing the stream.
189
+ */
190
+ /**
191
+ * Defensive bounds on per-id reassembly state. The peer is the local Python
192
+ * bridge, but a buggy or corrupt bridge must not grow memory without limit:
193
+ * cap how many distinct ids may be mid-reassembly at once (fail loud past the
194
+ * cap), and FIFO-bound the timed-out-id discard set so a long-lived process
195
+ * that times out many chunked requests whose final frames never arrive (e.g.
196
+ * the bridge died mid-stream) does not leak markers forever.
197
+ */
198
+ const MAX_CONCURRENT_STREAMS = 1024;
199
+ const MAX_DISCARDED_IDS = 4096;
200
+ export class Reassembler {
201
+ streams = new Map();
202
+ discarded = new Set();
203
+ maxReassemblyBytes;
204
+ expectedStream;
205
+ /**
206
+ * @param options.maxReassemblyBytes Reject (fail loud) any stream whose
207
+ * declared OR accumulated payload exceeds this many UTF-8 bytes, so a huge
208
+ * response cannot be buffered into memory before a higher layer's size cap
209
+ * would reject it anyway. Default: no limit (`Infinity`).
210
+ * @param options.expectedStream If set, every frame must carry this `stream`
211
+ * direction; a frame for the other direction is rejected. The response and
212
+ * request reassemblers are distinct instances, so this is defense-in-depth.
213
+ */
214
+ constructor(options = {}) {
215
+ this.maxReassemblyBytes = options.maxReassemblyBytes ?? Number.POSITIVE_INFINITY;
216
+ this.expectedStream = options.expectedStream;
217
+ }
218
+ /**
219
+ * Feed one frame. Returns the fully reassembled logical string when this
220
+ * frame completes the stream for its id, `null` if more frames are still
221
+ * needed (or the frame was dropped because its id is timed out).
222
+ *
223
+ * @throws BridgeProtocolError on any framing violation (malformed frame,
224
+ * wrong stream direction, declared/accumulated payload over the cap,
225
+ * duplicate `seq`, inconsistent `total`/`totalBytes`, byte-count mismatch,
226
+ * invalid UTF-8, or unknown `frameProtocol`).
227
+ */
228
+ accept(rawFrame) {
229
+ const frame = parseChunkFrame(rawFrame);
230
+ const { id, seq, total, totalBytes, data, stream } = frame;
231
+ if (this.expectedStream !== undefined && stream !== this.expectedStream) {
232
+ throw new BridgeProtocolError(`frame: unexpected stream '${stream}' for id ${id} (this reassembler handles '${this.expectedStream}')`, { code: 'FRAME_WRONG_STREAM' });
233
+ }
234
+ // Late-frame discard: drop frames for a timed-out id; forget the id once its
235
+ // declared final frame has been seen so the stream stays aligned and the id
236
+ // can be reused.
237
+ if (this.discarded.has(id)) {
238
+ if (seq === total - 1) {
239
+ this.discarded.delete(id);
240
+ }
241
+ return null;
242
+ }
243
+ let state = this.streams.get(id);
244
+ if (state === undefined) {
245
+ if (this.streams.size >= MAX_CONCURRENT_STREAMS) {
246
+ throw new BridgeProtocolError(`frame: too many concurrent reassembly streams (>= ${MAX_CONCURRENT_STREAMS}); refusing to buffer id ${id}`, { code: 'FRAME_TOO_MANY_STREAMS' });
247
+ }
248
+ // Reject early: a declared payload past the cap can never be accepted by
249
+ // the higher-layer size guard, so refuse to buffer it instead of OOMing.
250
+ if (totalBytes > this.maxReassemblyBytes) {
251
+ throw new BridgeProtocolError(`frame: declared payload ${totalBytes} bytes exceeds max reassembly ${this.maxReassemblyBytes} bytes for id ${id}`, { code: 'FRAME_PAYLOAD_TOO_LARGE' });
252
+ }
253
+ state = { total, totalBytes, bytesSoFar: 0, slices: new Map() };
254
+ this.streams.set(id, state);
255
+ }
256
+ else {
257
+ if (state.total !== total) {
258
+ this.streams.delete(id);
259
+ throw new BridgeProtocolError(`frame: total mismatch for id ${id} (saw ${state.total}, frame says ${total})`, { code: 'FRAME_INCONSISTENT' });
260
+ }
261
+ if (state.totalBytes !== totalBytes) {
262
+ this.streams.delete(id);
263
+ throw new BridgeProtocolError(`frame: totalBytes mismatch for id ${id} (saw ${state.totalBytes}, frame says ${totalBytes})`, { code: 'FRAME_INCONSISTENT' });
264
+ }
265
+ }
266
+ if (state.slices.has(seq)) {
267
+ this.streams.delete(id);
268
+ throw new BridgeProtocolError(`frame: duplicate seq ${seq} for id ${id}`, {
269
+ code: 'FRAME_DUPLICATE_SEQ',
270
+ });
271
+ }
272
+ state.slices.set(seq, data);
273
+ // Running memory bound: a peer that under-declares totalBytes then overshoots
274
+ // is caught here (and the exact-count check at completion catches the rest)
275
+ // before the full payload is buffered.
276
+ state.bytesSoFar += utf8ByteLength(data);
277
+ if (state.bytesSoFar > this.maxReassemblyBytes) {
278
+ this.streams.delete(id);
279
+ throw new BridgeProtocolError(`frame: accumulated payload exceeds max reassembly ${this.maxReassemblyBytes} bytes for id ${id}`, { code: 'FRAME_PAYLOAD_TOO_LARGE' });
280
+ }
281
+ if (state.slices.size < total) {
282
+ return null;
283
+ }
284
+ // All `total` frames present; the dense [0, total) range is guaranteed
285
+ // because each seq is in range, unique, and there are exactly `total` of
286
+ // them. Concatenate in seq order.
287
+ this.streams.delete(id);
288
+ let payload = '';
289
+ for (let i = 0; i < total; i += 1) {
290
+ const slice = state.slices.get(i);
291
+ if (slice === undefined) {
292
+ // Unreachable given the count + uniqueness + range invariants above,
293
+ // but kept explicit rather than a silent gap.
294
+ throw new BridgeProtocolError(`frame: missing seq ${i} for id ${id}`, {
295
+ code: 'FRAME_SEQ_GAP',
296
+ });
297
+ }
298
+ payload += slice;
299
+ }
300
+ const actualBytes = utf8ByteLength(payload);
301
+ if (actualBytes !== totalBytes) {
302
+ throw new BridgeProtocolError(`frame: reassembled byte length ${actualBytes} != declared totalBytes ${totalBytes} for id ${id}`, { code: 'FRAME_BYTES_MISMATCH' });
303
+ }
304
+ // Strict UTF-8 validation: re-encode then decode in fatal mode. With
305
+ // utf8-slice the concatenation cannot introduce invalid sequences (each
306
+ // slice is whole codepoints), but the spec requires the check explicitly.
307
+ try {
308
+ utf8Decoder.decode(utf8Encoder.encode(payload));
309
+ }
310
+ catch (cause) {
311
+ throw new BridgeProtocolError(`frame: reassembled payload is not valid UTF-8 for id ${id}`, {
312
+ code: 'FRAME_INVALID_UTF8',
313
+ cause,
314
+ });
315
+ }
316
+ return payload;
317
+ }
318
+ /**
319
+ * Mark an id as timed out / aborted. Any partial state is dropped immediately
320
+ * and every subsequent frame for this id is discarded until its declared
321
+ * final frame arrives. Idempotent.
322
+ */
323
+ discard(id) {
324
+ this.streams.delete(id);
325
+ this.discarded.add(id);
326
+ // Bound the discard set (FIFO): a timed-out id whose declared final frame
327
+ // never arrives would otherwise linger forever. Set iteration order is
328
+ // insertion order, so the first key is the oldest marker.
329
+ if (this.discarded.size > MAX_DISCARDED_IDS) {
330
+ const oldest = this.discarded.values().next().value;
331
+ if (oldest !== undefined) {
332
+ this.discarded.delete(oldest);
333
+ }
334
+ }
335
+ }
336
+ /** Whether any frame for `id` is still being accumulated (not yet complete). */
337
+ isPending(id) {
338
+ return this.streams.has(id);
339
+ }
340
+ /** Number of ids currently mid-reassembly (for diagnostics/tests). */
341
+ get pendingCount() {
342
+ return this.streams.size;
343
+ }
344
+ /**
345
+ * Number of timed-out ids whose late frames are still being dropped
346
+ * (FIFO-bounded by `MAX_DISCARDED_IDS`; for diagnostics/tests).
347
+ */
348
+ get discardedCount() {
349
+ return this.discarded.size;
350
+ }
351
+ }
352
+ //# sourceMappingURL=frame-codec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"frame-codec.js","sourceRoot":"","sources":["../../src/runtime/frame-codec.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAA4C,MAAM,gBAAgB,CAAC;AA0B7F,gFAAgF;AAChF,iDAAiD;AACjD,gFAAgF;AAEhF,MAAM,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC;AACtC,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAE9D,uDAAuD;AACvD,SAAS,yBAAyB,CAAC,SAAiB;IAClD,IAAI,SAAS,IAAI,IAAI,EAAE,CAAC;QACtB,OAAO,CAAC,CAAC;IACX,CAAC;IACD,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;QACvB,OAAO,CAAC,CAAC;IACX,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AAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;YACpD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBACzB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;YAChC,CAAC;QACH,CAAC;IACH,CAAC;IAED,gFAAgF;IAChF,SAAS,CAAC,EAAU;QAClB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,sEAAsE;IACtE,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED;;;OAGG;IACH,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;IAC7B,CAAC;CACF"}
@@ -92,7 +92,7 @@ export declare class HttpTransport implements Transport {
92
92
  * @throws BridgeExecutionError if the server returns a non-2xx status
93
93
  * @throws BridgeProtocolError if the response cannot be read
94
94
  */
95
- send(message: string, timeoutMs: number, signal?: AbortSignal): Promise<string>;
95
+ send(message: string, timeoutMs: number, signal?: AbortSignal, _requestId?: number): Promise<string>;
96
96
  /**
97
97
  * Safely read response body as text, returning empty string on failure.
98
98
  */
@@ -1 +1 @@
1
- {"version":3,"file":"http-transport.d.ts","sourceRoot":"","sources":["../../src/runtime/http-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAQH,OAAO,KAAK,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAMvE;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,qEAAqE;IACrE,OAAO,EAAE,MAAM,CAAC;IAEhB,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,qBAAa,aAAc,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;gBAEhB,OAAO,EAAE,oBAAoB;IAczC;;;;;OAKG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B;;;;OAIG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B;;;;OAIG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;;;;;;;OAQG;IACH,YAAY,IAAI,qBAAqB;IAerC;;;;;;;;;;;;OAYG;IACG,IAAI,CACR,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,MAAM,CAAC,EAAE,WAAW,EACpB,UAAU,CAAC,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,CAAC;IAwGlB;;OAEG;YACW,YAAY;CAO3B"}
@@ -113,7 +113,7 @@ export class HttpTransport {
113
113
  * @throws BridgeExecutionError if the server returns a non-2xx status
114
114
  * @throws BridgeProtocolError if the response cannot be read
115
115
  */
116
- async send(message, timeoutMs, signal) {
116
+ async send(message, timeoutMs, signal, _requestId) {
117
117
  if (this._isDisposed) {
118
118
  throw new BridgeDisposedError('Transport has been disposed');
119
119
  }
@@ -1 +1 @@
1
- {"version":3,"file":"http-transport.js","sourceRoot":"","sources":["../../src/runtime/http-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAqBrB,gFAAgF;AAChF,iBAAiB;AACjB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,aAAa;IACP,OAAO,CAAS;IAChB,OAAO,CAAyB;IAChC,gBAAgB,CAAS;IAClC,WAAW,GAAG,KAAK,CAAC;IAE5B,YAAY,OAA6B;QACvC,wCAAwC;QACxC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAClD,IAAI,CAAC,OAAO,G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AmB,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;YAC5D,CAAC;QACH,CAAC;IACH,CAAC;IAED,8EAA8E;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
+ {"version":3,"file":"http-transport.js","sourceRoot":"","sources":["../../src/runtime/http-transport.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAqBrB,gFAAgF;AAChF,iBAAiB;AACjB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,OAAO,aAAa;IACP,OAAO,CAAS;IAChB,OAAO,CAAyB;IAChC,gBAAgB,CAAS;IAClC,WAAW,GAAG,KAAK,CAAC;IAE5B,YAAY,OAA6B;QACvC,wCAAwC;QACxC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAClD,IAAI,CAAC,OAAO,GAAG;YACb,cAAc,EAAE,kBAAkB;YAClC,GAAG,OAAO,CAAC,OAAO;SACnB,CAAC;QACF,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,IAAI,KAAK,CAAC;IAC5D,CAAC;IAED,8EAA8E;IAC9E,YAAY;IACZ,8EAA8E;IAE9E;;;;;OAKG;IACH,KAAK,CAAC,IAAI;QACR,4CAA4C;IAC9C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;IAC1B,CAAC;IAED;;;;OAIG;I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untimeExecution } from '../types/index.js';
10
10
  export { BridgeCodec, type CodecOptions } from './bridge-codec.js';
11
+ export { createReturnValidator, describeReceivedShape, type ReturnSchema, type ReturnValidator, } from './validators.js';
11
12
  export type { Transport, TransportCapabilities, TransportOptions, ProtocolMessage, ProtocolResponse, } from './transport.js';
12
- export { PROTOCOL_ID, isTransport, isProtocolMessage, isProtocolResponse, } from './transport.js';
13
+ export { PROTOCOL_ID, isTransport, isProtocolMessage, isProtocolResponse } from './transport.js';
13
14
  export declare function setRuntimeBridge(bridge: RuntimeExecution): void;
14
15
  export declare function getRuntimeBridge(): RuntimeExecution;
15
16
  export declare function clearRuntimeBridge(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGnE,YAAY,EACV,SAAS,EACT,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EACL,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAIxB,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAE/D;AAED,wBAAgB,gBAAgB,IAAI,gBAAgB,CAOnD;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,OAAO,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EACL,qBAAqB,EACrB,qBAAqB,EACrB,KAAK,YAAY,EACjB,KAAK,eAAe,GACrB,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EACV,SAAS,EACT,qBAAqB,EACrB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAIjG,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAE/D;AAED,wBAAgB,gBAAgB,IAAI,gBAAgB,CAOnD;AAED,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
@@ -8,7 +8,8 @@
8
8
  */
9
9
  // BridgeCodec — validation and serialization for the JS<->Python boundary
10
10
  export { BridgeCodec } from './bridge-codec.js';
11
- export { PROTOCOL_ID, isTransport, isProtocolMessage, isProtocolResponse, } from './transport.js';
11
+ export { createReturnValidator, describeReceivedShape, } from './validators.js';
12
+ export { PROTOCOL_ID, isTransport, isProtocolMessage, isProtocolResponse } from './transport.js';
12
13
  let runtimeBridge = null;
13
14
  export function setRuntimeBridge(bridge) {
14
15
  runtimeBridge = bridge;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,0EAA0E;AAC1E,OAAO,EAAE,WAAW,EAAqB,MAAM,mBAAmB,CAAC;AAUnE,OAAO,EACL,WAAW,EACX,WAAW,EACX,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAExB,IAAI,aAAa,GAA4B,IAAI,CAAC;AAElD,MAAM,UAAU,gBAAgB,CAAC,MAAwB;IACvD,aAAa,GAAG,MAAM,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CACb,sJAAsJ,CACvJ,CAAC;IACJ,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,aAAa,GAAG,IAAI,CAAC;AACvB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,0EAA0E;AAC1E,OAAO,EAAE,WAAW,EAAqB,MAAM,mBAAmB,CAAC;AACnE,OAAO,EACL,qBAAqB,EACrB,qBAAqB,GAGtB,MAAM,iBAAiB,CAAC;AAUzB,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEjG,IAAI,aAAa,GAA4B,IAAI,CAAC;AAElD,MAAM,UAAU,gBAAgB,CAAC,MAAwB;IACvD,aAAa,GAAG,MAAM,CAAC;AACzB,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CACb,sJAAsJ,CACvJ,CAAC;IACJ,CAAC;IACD,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,aAAa,GAAG,IAAI,CAAC;AACvB,CAAC"}
@@ -18,7 +18,12 @@ export interface NodeBridgeOptions {
18
18
  minProcesses?: number;
19
19
  /** Maximum number of Python processes to spawn. Default: 1 (single-process mode) */
20
20
  maxProcesses?: number;
21
- /** Maximum concurrent requests per process. Default: 10 */
21
+ /**
22
+ * Maximum concurrent requests per process. Default: 1.
23
+ *
24
+ * Python bridge workers process JSONL requests serially, so the default lets
25
+ * the pool use another process for concurrent calls when one is available.
26
+ */
22
27
  maxConcurrentPerProcess?: number;
23
28
  /** Path to Python executable. Auto-detected if not specified. */
24
29
  pythonPath?: string;
@@ -34,8 +39,6 @@ export interface NodeBridgeOptions {
34
39
  queueTimeoutMs?: number;
35
40
  /** Inherit all environment variables from parent process. Default: false */
36
41
  inheritProcessEnv?: boolean;
37
- /** Enable result caching for pure functions. Default: false */
38
- enableCache?: boolean;
39
42
  /** Optional extra environment variables to pass to the Python subprocess. */
40
43
  env?: Record<string, string | undefined>;
41
44
  /** Codec options for validation/serialization */
@@ -77,7 +80,6 @@ export interface NodeBridgeOptions {
77
80
  * - Virtual environment support
78
81
  * - Full BridgeCodec validation (NaN/Infinity rejection, key validation)
79
82
  * - Automatic Arrow decoding for DataFrames/ndarrays
80
- * - Optional result caching for pure functions
81
83
  * - Process warmup commands
82
84
  *
83
85
  * @example
@@ -98,7 +100,6 @@ export interface NodeBridgeOptions {
98
100
  * const pooledBridge = new NodeBridge({
99
101
  * maxProcesses: 4,
100
102
  * maxConcurrentPerProcess: 2,
101
- * enableCache: true,
102
103
  * });
103
104
  * await pooledBridge.init();
104
105
  * ```
@@ -128,18 +129,9 @@ export declare class NodeBridge extends BasePythonBridge {
128
129
  protected doDispose(): Promise<void>;
129
130
  /**
130
131
  * Expose the held RpcClient to BasePythonBridge's shared delegating methods
131
- * (instantiate/callMethod/disposeInstance/getBridgeInfo). call() is
132
- * overridden below to layer caching on top.
132
+ * (call/getBridgeInfo).
133
133
  */
134
134
  protected getRpcClient(): RpcClient;
135
- /**
136
- * Call a Python function, with optional result caching.
137
- *
138
- * Overrides BasePythonBridge.call() to layer the cache lookup/writeback on
139
- * top of the shared delegation. Cache lookup stays FIRST so cache hits return
140
- * without forcing init, preserving the pre-composition behavior.
141
- */
142
- call<T = unknown>(module: string, functionName: string, args: unknown[], kwargs?: Record<string, unknown>): Promise<T>;
143
135
  /**
144
136
  * Get current pool statistics.
145
137
  */
@@ -168,13 +160,5 @@ export declare class NodeBridge extends BasePythonBridge {
168
160
  poolSize: number;
169
161
  busyWorkers: number;
170
162
  };
171
- /**
172
- * Generate a cache key, returning null if generation fails.
173
- */
174
- private safeCacheKey;
175
- /**
176
- * Heuristic to determine if function result should be cached.
177
- */
178
- private isPureFunctionCandidate;
179
163
  }
180
164
  //# sourceMappingURL=node.d.ts.map