tywrap 0.6.1 → 0.8.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 (110) hide show
  1. package/README.md +15 -5
  2. package/dist/core/annotation-parser.d.ts.map +1 -1
  3. package/dist/core/annotation-parser.js.map +1 -1
  4. package/dist/core/emit-call.d.ts.map +1 -1
  5. package/dist/core/emit-call.js +1 -1
  6. package/dist/core/emit-call.js.map +1 -1
  7. package/dist/core/generator.d.ts.map +1 -1
  8. package/dist/core/generator.js +40 -9
  9. package/dist/core/generator.js.map +1 -1
  10. package/dist/dev.d.ts.map +1 -1
  11. package/dist/dev.js +1 -3
  12. package/dist/dev.js.map +1 -1
  13. package/dist/index.d.ts +1 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/runtime/base-bridge.d.ts +57 -0
  17. package/dist/runtime/base-bridge.d.ts.map +1 -0
  18. package/dist/runtime/base-bridge.js +72 -0
  19. package/dist/runtime/base-bridge.js.map +1 -0
  20. package/dist/runtime/frame-codec.d.ts +111 -0
  21. package/dist/runtime/frame-codec.d.ts.map +1 -0
  22. package/dist/runtime/frame-codec.js +352 -0
  23. package/dist/runtime/frame-codec.js.map +1 -0
  24. package/dist/runtime/http-transport.d.ts +11 -1
  25. package/dist/runtime/http-transport.d.ts.map +1 -1
  26. package/dist/runtime/http-transport.js +19 -0
  27. package/dist/runtime/http-transport.js.map +1 -1
  28. package/dist/runtime/http.d.ts +5 -12
  29. package/dist/runtime/http.d.ts.map +1 -1
  30. package/dist/runtime/http.js +6 -29
  31. package/dist/runtime/http.js.map +1 -1
  32. package/dist/runtime/index.d.ts +2 -2
  33. package/dist/runtime/index.d.ts.map +1 -1
  34. package/dist/runtime/index.js +1 -1
  35. package/dist/runtime/index.js.map +1 -1
  36. package/dist/runtime/node.d.ts +25 -19
  37. package/dist/runtime/node.d.ts.map +1 -1
  38. package/dist/runtime/node.js +19 -34
  39. package/dist/runtime/node.js.map +1 -1
  40. package/dist/runtime/pooled-transport.d.ts +21 -2
  41. package/dist/runtime/pooled-transport.d.ts.map +1 -1
  42. package/dist/runtime/pooled-transport.js +16 -0
  43. package/dist/runtime/pooled-transport.js.map +1 -1
  44. package/dist/runtime/pyodide-bootstrap-core.generated.d.ts.map +1 -1
  45. package/dist/runtime/pyodide-bootstrap-core.generated.js +1 -1
  46. package/dist/runtime/pyodide-bootstrap-core.generated.js.map +1 -1
  47. package/dist/runtime/pyodide-transport.d.ts +12 -1
  48. package/dist/runtime/pyodide-transport.d.ts.map +1 -1
  49. package/dist/runtime/pyodide-transport.js +20 -0
  50. package/dist/runtime/pyodide-transport.js.map +1 -1
  51. package/dist/runtime/pyodide.d.ts +5 -12
  52. package/dist/runtime/pyodide.d.ts.map +1 -1
  53. package/dist/runtime/pyodide.js +6 -29
  54. package/dist/runtime/pyodide.js.map +1 -1
  55. package/dist/runtime/rpc-client.d.ts +14 -1
  56. package/dist/runtime/rpc-client.d.ts.map +1 -1
  57. package/dist/runtime/rpc-client.js +68 -6
  58. package/dist/runtime/rpc-client.js.map +1 -1
  59. package/dist/runtime/subprocess-transport.d.ts +177 -3
  60. package/dist/runtime/subprocess-transport.d.ts.map +1 -1
  61. package/dist/runtime/subprocess-transport.js +526 -26
  62. package/dist/runtime/subprocess-transport.js.map +1 -1
  63. package/dist/runtime/transport.d.ts +141 -0
  64. package/dist/runtime/transport.d.ts.map +1 -1
  65. package/dist/runtime/transport.js +21 -0
  66. package/dist/runtime/transport.js.map +1 -1
  67. package/dist/types/index.d.ts +59 -0
  68. package/dist/types/index.d.ts.map +1 -1
  69. package/dist/tywrap.d.ts.map +1 -1
  70. package/dist/tywrap.js +204 -149
  71. package/dist/tywrap.js.map +1 -1
  72. package/dist/utils/codec.d.ts +2 -0
  73. package/dist/utils/codec.d.ts.map +1 -1
  74. package/dist/utils/codec.js +205 -6
  75. package/dist/utils/codec.js.map +1 -1
  76. package/dist/version.js +1 -1
  77. package/package.json +7 -1
  78. package/runtime/__pycache__/_tywrap_conformance_chunking_fixtures.cpython-311.pyc +0 -0
  79. package/runtime/__pycache__/_tywrap_member_fixtures.cpython-311.pyc +0 -0
  80. package/runtime/__pycache__/_tywrap_w4_chunking_fixture.cpython-311.pyc +0 -0
  81. package/runtime/__pycache__/_tywrap_w5_request_chunking_fixture.cpython-311.pyc +0 -0
  82. package/runtime/__pycache__/_tywrap_w6_pool_chunking_fixture.cpython-311.pyc +0 -0
  83. package/runtime/__pycache__/frame_codec.cpython-311.pyc +0 -0
  84. package/runtime/__pycache__/safe_codec.cpython-311.pyc +0 -0
  85. package/runtime/__pycache__/tywrap_bridge_core.cpython-311.pyc +0 -0
  86. package/runtime/frame_codec.py +424 -0
  87. package/runtime/python_bridge.py +241 -42
  88. package/runtime/tywrap_bridge_core.py +152 -13
  89. package/src/core/annotation-parser.ts +2 -1
  90. package/src/core/emit-call.ts +1 -7
  91. package/src/core/generator.ts +50 -11
  92. package/src/dev.ts +1 -3
  93. package/src/index.ts +1 -0
  94. package/src/runtime/base-bridge.ts +106 -0
  95. package/src/runtime/frame-codec.ts +469 -0
  96. package/src/runtime/http-transport.ts +21 -1
  97. package/src/runtime/http.ts +7 -51
  98. package/src/runtime/index.ts +2 -6
  99. package/src/runtime/node.ts +42 -53
  100. package/src/runtime/pooled-transport.ts +25 -2
  101. package/src/runtime/pyodide-bootstrap-core.generated.ts +1 -1
  102. package/src/runtime/pyodide-transport.ts +22 -0
  103. package/src/runtime/pyodide.ts +7 -52
  104. package/src/runtime/rpc-client.ts +91 -7
  105. package/src/runtime/subprocess-transport.ts +629 -30
  106. package/src/runtime/transport.ts +169 -0
  107. package/src/types/index.ts +62 -0
  108. package/src/tywrap.ts +265 -162
  109. package/src/utils/codec.ts +245 -7
  110. package/src/version.ts +1 -1
@@ -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;A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C,EAAE,CAAC,CAAC;QACvB,0EAA0E;QAC1E,uEAAuE;QACvE,0DAA0D;QAC1D,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,GAAG,iBAAiB,EAAE,CAAC;YAC5C,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,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"}
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * @see https://github.com/bbopen/tywrap/issues/149
8
8
  */
9
- import type { Transport } from './transport.js';
9
+ import type { Transport, TransportCapabilities } from './transport.js';
10
10
  /**
11
11
  * Configuration options for the HttpTransport.
12
12
  */
@@ -69,6 +69,16 @@ export declare class HttpTransport implements Transport {
69
69
  * Returns true unless dispose() has been called.
70
70
  */
71
71
  get isReady(): boolean;
72
+ /**
73
+ * Static capability descriptor for the HTTP backend.
74
+ *
75
+ * The Python server can return Arrow IPC and arbitrary binary (bytes
76
+ * envelopes) in the HTTP response body. Chunking/streaming are not implemented
77
+ * (0.8.0). HTTP imposes no transport-level frame ceiling — the whole body is
78
+ * read in one shot — so `maxFrameBytes` is `Number.POSITIVE_INFINITY` (a higher
79
+ * layer, e.g. the codec payload limit, may still cap the size).
80
+ */
81
+ capabilities(): TransportCapabilities;
72
82
  /**
73
83
  * Send a message to the Python server and wait for the response.
74
84
  *
@@ -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,MAAM,gBAAgB,CAAC;AAMhD;;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,YAAW,SAAS;IAC7C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IACjD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,WAAW,CAAS;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;IAMD;;;;;;;;;;;;OAYG;IACG,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAwGrF;;OAEG;YACW,YAAY;CAO3B"}
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,YAAW,SAAS;IAC7C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAyB;IACjD,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAS;IAC1C,OAAO,CAAC,WAAW,CAAS;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,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC;IAwGrF;;OAEG;YACW,YAAY;CAO3B"}
@@ -78,6 +78,25 @@ export class HttpTransport {
78
78
  get isReady() {
79
79
  return !this._isDisposed;
80
80
  }
81
+ /**
82
+ * Static capability descriptor for the HTTP backend.
83
+ *
84
+ * The Python server can return Arrow IPC and arbitrary binary (bytes
85
+ * envelopes) in the HTTP response body. Chunking/streaming are not implemented
86
+ * (0.8.0). HTTP imposes no transport-level frame ceiling — the whole body is
87
+ * read in one shot — so `maxFrameBytes` is `Number.POSITIVE_INFINITY` (a higher
88
+ * layer, e.g. the codec payload limit, may still cap the size).
89
+ */
90
+ capabilities() {
91
+ return {
92
+ backend: 'http',
93
+ supportsArrow: true,
94
+ supportsBinary: true,
95
+ supportsChunking: false,
96
+ supportsStreaming: false,
97
+ maxFrameBytes: Number.POSITIVE_INFINITY,
98
+ };
99
+ }
81
100
  // ===========================================================================
82
101
  // SEND
83
102
  // ===========================================================================
@@ -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,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;IACH,IAAI,OAAO;QACT,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC;IAC3B,CAAC;IAED,8EAA8E;IAC9E,OAAO;IACP,8EAA8E;IAE9E;;;;;;;;;;;;OAYG;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EAAE,CAAC;gBAC5B,YAAY,CAAC,SAAS,CAAC,CAAC;YAC1B,CAAC;YAED,oCAAoC;YACpC,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,CAAC,mBAAmB,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"}
@@ -7,9 +7,8 @@
7
7
  *
8
8
  * @see https://github.com/bbopen/tywrap/issues/149
9
9
  */
10
- import type { PythonRuntime, BridgeInfo } from '../types/index.js';
11
- import { DisposableBase } from './bounded-context.js';
12
- import { type GetBridgeInfoOptions } from './rpc-client.js';
10
+ import { BasePythonBridge } from './base-bridge.js';
11
+ import { RpcClient } from './rpc-client.js';
13
12
  import type { CodecOptions } from './bridge-codec.js';
14
13
  /**
15
14
  * Configuration options for HttpBridge.
@@ -48,7 +47,7 @@ export interface HttpBridgeOptions {
48
47
  * await bridge.dispose();
49
48
  * ```
50
49
  */
51
- export declare class HttpBridge extends DisposableBase implements PythonRuntime {
50
+ export declare class HttpBridge extends BasePythonBridge {
52
51
  private readonly rpc;
53
52
  /**
54
53
  * Create a new HttpBridge instance.
@@ -62,15 +61,9 @@ export declare class HttpBridge extends DisposableBase implements PythonRuntime
62
61
  * as a resource and disposed automatically by DisposableBase.
63
62
  */
64
63
  protected doDispose(): Promise<void>;
65
- call<T = unknown>(module: string, functionName: string, args: unknown[], kwargs?: Record<string, unknown>): Promise<T>;
66
- instantiate<T = unknown>(module: string, className: string, args: unknown[], kwargs?: Record<string, unknown>): Promise<T>;
67
- callMethod<T = unknown>(handle: string, methodName: string, args: unknown[], kwargs?: Record<string, unknown>): Promise<T>;
68
- disposeInstance(handle: string): Promise<void>;
69
- getBridgeInfo(options?: GetBridgeInfoOptions): Promise<BridgeInfo>;
70
64
  /**
71
- * Ensure the facade is initialized before delegating an RPC, replicating the
72
- * auto-init that the bounded execute path provided pre-composition.
65
+ * Expose the held RpcClient to BasePythonBridge's shared delegating methods.
73
66
  */
74
- private ensureReady;
67
+ protected getRpcClient(): RpcClient;
75
68
  }
76
69
  //# sourceMappingURL=http.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/runtime/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAGnE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAa,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAEvE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMtD;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,qEAAqE;IACrE,OAAO,EAAE,MAAM,CAAC;IAEhB,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEjC,8DAA8D;IAC9D,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,iDAAiD;IACjD,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAMD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,UAAW,SAAQ,cAAe,YAAW,aAAa;IACrE,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAY;IAEhC;;;;OAIG;gBACS,OAAO,EAAE,iBAAiB;cAsBtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAMvC;;;OAGG;cACa,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAQpC,IAAI,CAAC,CAAC,GAAG,OAAO,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,iDAAiD;IACjD,KAAK,CAAC,EAAE,YAAY,CAAC;CACtB;AAMD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,qBAAa,UAAW,SAAQ,gBAAgB;IAC9C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAY;IAEhC;;;;OAIG;gBACS,OAAO,EAAE,iBAAiB;cAsBtB,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAMvC;;;OAGG;cACa,SAAS,IAAI,OAAO,CAAC,IAAI,CAAC;IAQ1C;;OAEG;IACH,SAAS,CAAC,YAAY,IAAI,SAAS;CAGpC"}
@@ -8,7 +8,7 @@
8
8
  * @see https://github.com/bbopen/tywrap/issues/149
9
9
  */
10
10
  import { autoRegisterArrowDecoder } from '../utils/codec.js';
11
- import { DisposableBase } from './bounded-context.js';
11
+ import { BasePythonBridge } from './base-bridge.js';
12
12
  import { RpcClient } from './rpc-client.js';
13
13
  import { HttpTransport } from './http-transport.js';
14
14
  // =============================================================================
@@ -38,7 +38,7 @@ import { HttpTransport } from './http-transport.js';
38
38
  * await bridge.dispose();
39
39
  * ```
40
40
  */
41
- export class HttpBridge extends DisposableBase {
41
+ export class HttpBridge extends BasePythonBridge {
42
42
  rpc;
43
43
  /**
44
44
  * Create a new HttpBridge instance.
@@ -76,36 +76,13 @@ export class HttpBridge extends DisposableBase {
76
76
  // Intentionally empty; tracked resources handle disposal.
77
77
  }
78
78
  // ===========================================================================
79
- // RPC METHODS (delegate to the held RpcClient)
79
+ // RPC DELEGATION (the held RpcClient)
80
80
  // ===========================================================================
81
- async call(module, functionName, args, kwargs) {
82
- await this.ensureReady();
83
- return this.rpc.call(module, functionName, args, kwargs);
84
- }
85
- async instantiate(module, className, args, kwargs) {
86
- await this.ensureReady();
87
- return this.rpc.instantiate(module, className, args, kwargs);
88
- }
89
- async callMethod(handle, methodName, args, kwargs) {
90
- await this.ensureReady();
91
- return this.rpc.callMethod(handle, methodName, args, kwargs);
92
- }
93
- async disposeInstance(handle) {
94
- await this.ensureReady();
95
- return this.rpc.disposeInstance(handle);
96
- }
97
- async getBridgeInfo(options) {
98
- await this.ensureReady();
99
- return this.rpc.getBridgeInfo(options);
100
- }
101
81
  /**
102
- * Ensure the facade is initialized before delegating an RPC, replicating the
103
- * auto-init that the bounded execute path provided pre-composition.
82
+ * Expose the held RpcClient to BasePythonBridge's shared delegating methods.
104
83
  */
105
- async ensureReady() {
106
- if (!this.isReady) {
107
- await this.init();
108
- }
84
+ getRpcClient() {
85
+ return this.rpc;
109
86
  }
110
87
  }
111
88
  //# sourceMappingURL=http.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/runtime/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,SAAS,EAA6B,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAwBpD,gFAAgF;AAChF,cAAc;AACd,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,OAAO,UAAW,SAAQ,cAAc;IAC3B,GAAG,CAAY;IAEhC;;;;OAIG;IACH,YAAY,OAA0B;QACpC,KAAK,EAAE,CAAC;QAER,MAAM,SAAS,GAAG,IAAI,aAAa,CAAC;YAClC,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,OAAO,EAAE,OAAO,CAAC,OAAO;YACxB,gBAAgB,EAAE,OAAO,CAAC,SAAS;SACpC,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,GAAG,IAAI,SAAS,CAAC;YACvB,SAAS;YACT,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,gBAAgB,EAAE,OAAO,CAAC,SAAS;SACpC,CAAC,CAAC;QACH,kDAAkD;QAClD,IAAI,CAAC,aAAa,CAAC,IAAI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F;QAChF,MAAM,wBAAwB,EAAE,CAAC;QACjC,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;IACxB,CAAC;IAED;;;OAGG;IACO,KAAK,CAAC,SAAS;QACvB,0DAA0D;IAC5D,CAAC;IAED,8EAA8E;IAC9E,sCAAsC;IACtC,8EAA8E;IAE9E;;OAEG;IACO,YAAY;QACpB,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;CACF"}
@@ -8,8 +8,8 @@
8
8
  */
9
9
  import type { RuntimeExecution } from '../types/index.js';
10
10
  export { BridgeCodec, type CodecOptions } from './bridge-codec.js';
11
- export type { Transport, TransportOptions, ProtocolMessage, ProtocolResponse, } from './transport.js';
12
- export { PROTOCOL_ID, isTransport, isProtocolMessage, isProtocolResponse, } from './transport.js';
11
+ export type { Transport, TransportCapabilities, TransportOptions, ProtocolMessage, ProtocolResponse, } from './transport.js';
12
+ export { PROTOCOL_ID, isTransport, isProtocolMessage, isProtocolResponse } from './transport.js';
13
13
  export declare function setRuntimeBridge(bridge: RuntimeExecution): void;
14
14
  export declare function getRuntimeBridge(): RuntimeExecution;
15
15
  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,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;AAGnE,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,7 @@
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 { PROTOCOL_ID, isTransport, isProtocolMessage, isProtocolResponse } from './transport.js';
12
12
  let runtimeBridge = null;
13
13
  export function setRuntimeBridge(bridge) {
14
14
  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;AASnE,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;AAUnE,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"}