@tracecode/harness 0.16.4 → 0.16.6

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 (50) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +6 -4
  3. package/dist/{browser-runtime-provider-OGJQLGXU.js → browser-runtime-provider-KPQBQ4EG.js} +5 -5
  4. package/dist/{chunk-AAKNIYV6.js → chunk-46XZQOHV.js} +3 -3
  5. package/dist/{chunk-6LE4KEMZ.js → chunk-4PN5YD6J.js} +489 -3
  6. package/dist/{chunk-DTLDQQHA.js → chunk-5KH5ABPQ.js} +72 -1
  7. package/dist/{chunk-5RT5IT4I.js → chunk-B2EM2SZ2.js} +15 -31
  8. package/dist/{chunk-M7SNEZDR.js → chunk-EPBHRROK.js} +3 -3
  9. package/dist/{chunk-Y72C46GE.js → chunk-GXTDL2ML.js} +20 -11
  10. package/dist/{chunk-RCOPAMVR.js → chunk-J2KGF5PU.js} +56 -36
  11. package/dist/core.cjs +19 -10
  12. package/dist/core.js +1 -1
  13. package/dist/cpp-worker-client-UWGDH6HR.js +12 -0
  14. package/dist/{csharp-worker-client-ARGMOB3M.js → csharp-worker-client-4QP2ZBSA.js} +4 -4
  15. package/dist/internal/browser.cjs +72 -0
  16. package/dist/internal/browser.d.cts +19 -1
  17. package/dist/internal/browser.d.ts +19 -1
  18. package/dist/internal/browser.js +3 -1
  19. package/dist/internal/tracekernel-workspace.cjs +19 -10
  20. package/dist/internal/tracekernel-workspace.js +1 -1
  21. package/dist/{java-project-JB5TUIFU.js → java-project-AEQEVBDA.js} +2 -2
  22. package/dist/judge.cjs +885 -89
  23. package/dist/judge.d.cts +6 -0
  24. package/dist/judge.d.ts +6 -0
  25. package/dist/judge.js +237 -23
  26. package/dist/{project-browser-3S2FWEAP.js → project-browser-HFNQEALT.js} +2 -2
  27. package/dist/{project-browser-QN7YOJQQ.js → project-browser-L3A2G2MA.js} +2 -2
  28. package/dist/{project-browser-S4KLCZV7.js → project-browser-OVE7V464.js} +2 -2
  29. package/dist/{project-browser-WDUWUGLZ.js → project-browser-P2H222D7.js} +2 -2
  30. package/dist/{project-browser-HCQCXAYC.js → project-browser-WCSIJY6I.js} +2 -2
  31. package/dist/{python-worker-client-EX6Q2W4L.js → python-worker-client-UCOMTSMU.js} +4 -4
  32. package/dist/tracekernel.cjs +650 -68
  33. package/dist/tracekernel.js +4 -4
  34. package/package.json +14 -5
  35. package/runtime-assets.lock.json +77 -70
  36. package/workers/cpp/cpp-worker.js +53 -43
  37. package/workers/csharp/csharp-worker.js +150 -1
  38. package/workers/javascript/javascript-project-worker.js +18 -9
  39. package/workers/python/python-worker.js +121 -1
  40. package/workers/vendor/csharp/_framework/TraceCode.CSharpHost.wasm +0 -0
  41. package/workers/vendor/csharp/_framework/TraceCode.CSharpJudgeRuntime.wasm +0 -0
  42. package/workers/vendor/csharp/_framework/TraceCode.TraceClrWire.wasm +0 -0
  43. package/workers/vendor/csharp/_framework/dotnet.boot.js +11 -6
  44. package/workers/vendor/csharp/_framework/dotnet.native.wasm +0 -0
  45. package/workers/vendor/csharp/_framework/supportFiles/TraceCode.CSharpHost.dll +0 -0
  46. package/workers/vendor/csharp/_framework/supportFiles/TraceCode.CSharpJudgeRuntime.dll +0 -0
  47. package/workers/vendor/csharp-runner/_framework/assemblies-02.pack +0 -0
  48. package/workers/vendor/csharp-runner/_framework/assemblies-03.pack +0 -0
  49. package/workers/vendor/csharp-runner/_framework/dotnet.boot.js +65 -65
  50. package/dist/cpp-worker-client-HV7RO2P5.js +0 -12
package/CHANGELOG.md CHANGED
@@ -6,6 +6,42 @@ This repo uses Git tags as release boundaries. Version notes below summarize wha
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.16.6] - 2026-08-14
10
+
11
+ ### Fixed
12
+
13
+ - Exposed the Java external-compiler endpoint through the public browser Judge
14
+ options, preserving a warm trusted compiler alongside disposable learner
15
+ runners in server-hosted browser authorities.
16
+
17
+ ## [0.16.5] - 2026-08-12
18
+
19
+ ### Added
20
+
21
+ - Added the in-repo TraceCLR algorithm profile, derived from the product C#
22
+ corpus, with deterministic compatibility checks, an explicit binary wire
23
+ boundary, and a trace-capable minimal runner used as evidence for the
24
+ optimized execution tier.
25
+
26
+ ### Changed
27
+
28
+ - C# prepared execution now selects either the optimized algorithm runner or
29
+ the broad compatibility runner before learner code starts. The selected
30
+ tier never falls through to the other runner after a learner failure, and
31
+ both tiers preserve the same output, tracing, limits, and isolation
32
+ contracts.
33
+ - Browser runtime prewarming now begins as promotable idle work. A foreground
34
+ compile promotes the same pending work instead of starting a second warmup.
35
+ - C++ toolchain asset loading, integrity validation, PCH registration, and
36
+ compiler initialization now stay inside the compiler Worker. Python runtime
37
+ image fetching and Wasm compilation likewise run in a short-lived bootstrap
38
+ Worker before the immutable image is retained at provider scope.
39
+
40
+ ### Fixed
41
+
42
+ - Prevented Python and C++ preflight from blocking the browser page thread
43
+ during Practice loading while preserving fast warmed first execution.
44
+
9
45
  ## [0.16.4] - 2026-08-11
10
46
 
11
47
  ### Fixed
package/README.md CHANGED
@@ -246,10 +246,12 @@ collapsed runtime-information section; full transitive notices remain in the
246
246
  versioned engine release.
247
247
 
248
248
  The default Python Judge deployment is self-contained under `/workers` after
249
- `sync-assets`. It retains immutable CPython startup state at provider scope,
250
- leases one clean Worker to a submission for preparation plus its case batch,
251
- and then terminates that Worker. A custom Python runtime manifest must include
252
- an engine-matched `runtimeImage`; missing or cross-engine images fail closed.
249
+ `sync-assets`. A short-lived bootstrap Worker fetches and compiles the immutable
250
+ CPython startup image, then transfers it to provider scope without performing
251
+ runtime-image work on the page thread. The provider leases one clean Worker to
252
+ a submission for preparation plus its case batch, and then terminates that
253
+ Worker. A custom Python runtime manifest must include an engine-matched
254
+ `runtimeImage`; missing or cross-engine images fail closed.
253
255
  Project Python processes continue to use the general TraceKernel process path
254
256
  because their modules, filesystem, stdin, servers, and lifetime are
255
257
  user-controlled.
@@ -2,14 +2,14 @@ var define = undefined;
2
2
  import {
3
3
  createCppBrowserRuntimeProvider,
4
4
  createTraceCCBrowserCompilerService
5
- } from "./chunk-RCOPAMVR.js";
6
- import "./chunk-AAKNIYV6.js";
7
- import "./chunk-Y72C46GE.js";
8
- import "./chunk-DTLDQQHA.js";
5
+ } from "./chunk-J2KGF5PU.js";
6
+ import "./chunk-46XZQOHV.js";
7
+ import "./chunk-GXTDL2ML.js";
8
+ import "./chunk-5KH5ABPQ.js";
9
9
  import "./chunk-C2RUZCIL.js";
10
10
  import "./chunk-756Z7C6D.js";
11
11
  export {
12
12
  createCppBrowserRuntimeProvider,
13
13
  createTraceCCBrowserCompilerService
14
14
  };
15
- //# sourceMappingURL=browser-runtime-provider-OGJQLGXU.js.map
15
+ //# sourceMappingURL=browser-runtime-provider-KPQBQ4EG.js.map
@@ -4,7 +4,7 @@ import {
4
4
  liftCodeBatchOutcome,
5
5
  liftCodeOutcome,
6
6
  liftTraceOutcome
7
- } from "./chunk-Y72C46GE.js";
7
+ } from "./chunk-GXTDL2ML.js";
8
8
  import {
9
9
  WorkerCrashedError,
10
10
  WorkerReadyTimeoutError,
@@ -21,7 +21,7 @@ import {
21
21
  logRuntimeDiagnostic,
22
22
  restoreTransferredTraceEvents,
23
23
  traceEventTransferRequest
24
- } from "./chunk-DTLDQQHA.js";
24
+ } from "./chunk-5KH5ABPQ.js";
25
25
  import {
26
26
  andThen,
27
27
  catchIf,
@@ -1370,4 +1370,4 @@ var CppWorkerClient = class {
1370
1370
  export {
1371
1371
  CppWorkerClient
1372
1372
  };
1373
- //# sourceMappingURL=chunk-AAKNIYV6.js.map
1373
+ //# sourceMappingURL=chunk-46XZQOHV.js.map
@@ -4,7 +4,7 @@ import {
4
4
  liftCodeBatchOutcome,
5
5
  liftTraceOutcome,
6
6
  withRuntimeTraceOptions
7
- } from "./chunk-Y72C46GE.js";
7
+ } from "./chunk-GXTDL2ML.js";
8
8
  import {
9
9
  HostArtifactCache,
10
10
  WorkerCrashedError,
@@ -20,7 +20,7 @@ import {
20
20
  logRuntimeDiagnostic,
21
21
  restoreTransferredTraceEvents,
22
22
  traceEventTransferRequest
23
- } from "./chunk-DTLDQQHA.js";
23
+ } from "./chunk-5KH5ABPQ.js";
24
24
  import {
25
25
  _void,
26
26
  andThen,
@@ -31,6 +31,460 @@ import {
31
31
  tryPromise
32
32
  } from "./chunk-C2RUZCIL.js";
33
33
 
34
+ // packages/runtime-csharp/src/traceclr-wire.ts
35
+ var WIRE_MAGIC = 827802452;
36
+ var TRACECLR_WIRE_LIMITS = Object.freeze({
37
+ maxBytes: 16 * 1024 * 1024,
38
+ maxCollectionItems: 1e6,
39
+ maxDepth: 128
40
+ });
41
+ var WireWriter = class {
42
+ buffer = new ArrayBuffer(256);
43
+ view = new DataView(this.buffer);
44
+ length = 0;
45
+ reserve(bytes) {
46
+ const next = this.length + bytes;
47
+ if (!Number.isSafeInteger(bytes) || bytes < 0 || next > TRACECLR_WIRE_LIMITS.maxBytes) {
48
+ throw new RangeError(`TraceCLR wire payload exceeds ${TRACECLR_WIRE_LIMITS.maxBytes} bytes.`);
49
+ }
50
+ if (next > this.buffer.byteLength) {
51
+ let capacity = this.buffer.byteLength;
52
+ while (capacity < next) capacity = Math.min(TRACECLR_WIRE_LIMITS.maxBytes, capacity * 2);
53
+ const replacement = new ArrayBuffer(capacity);
54
+ new Uint8Array(replacement).set(new Uint8Array(this.buffer, 0, this.length));
55
+ this.buffer = replacement;
56
+ this.view = new DataView(replacement);
57
+ }
58
+ const offset = this.length;
59
+ this.length = next;
60
+ return offset;
61
+ }
62
+ uint8(value) {
63
+ const offset = this.reserve(1);
64
+ this.view.setUint8(offset, value);
65
+ }
66
+ int8(value) {
67
+ const offset = this.reserve(1);
68
+ this.view.setInt8(offset, value);
69
+ }
70
+ int16(value) {
71
+ const offset = this.reserve(2);
72
+ this.view.setInt16(offset, value, true);
73
+ }
74
+ uint16(value) {
75
+ const offset = this.reserve(2);
76
+ this.view.setUint16(offset, value, true);
77
+ }
78
+ int32(value) {
79
+ const offset = this.reserve(4);
80
+ this.view.setInt32(offset, value, true);
81
+ }
82
+ uint32(value) {
83
+ const offset = this.reserve(4);
84
+ this.view.setUint32(offset, value, true);
85
+ }
86
+ int64(value) {
87
+ const offset = this.reserve(8);
88
+ this.view.setBigInt64(offset, value, true);
89
+ }
90
+ uint64(value) {
91
+ const offset = this.reserve(8);
92
+ this.view.setBigUint64(offset, value, true);
93
+ }
94
+ float32(value) {
95
+ const offset = this.reserve(4);
96
+ this.view.setFloat32(offset, value, true);
97
+ }
98
+ float64(value) {
99
+ const offset = this.reserve(8);
100
+ this.view.setFloat64(offset, value, true);
101
+ }
102
+ bytes(value) {
103
+ const offset = this.reserve(value.byteLength);
104
+ new Uint8Array(this.buffer, offset, value.byteLength).set(value);
105
+ }
106
+ finish() {
107
+ return new Uint8Array(this.buffer.slice(0, this.length));
108
+ }
109
+ };
110
+ var WireReader = class {
111
+ view;
112
+ offset = 0;
113
+ constructor(bytes) {
114
+ if (bytes.byteLength > TRACECLR_WIRE_LIMITS.maxBytes) {
115
+ throw new RangeError(`TraceCLR wire payload exceeds ${TRACECLR_WIRE_LIMITS.maxBytes} bytes.`);
116
+ }
117
+ this.view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
118
+ }
119
+ take(bytes) {
120
+ if (this.offset + bytes > this.view.byteLength) {
121
+ throw new RangeError("TraceCLR wire payload ended unexpectedly.");
122
+ }
123
+ const offset = this.offset;
124
+ this.offset += bytes;
125
+ return offset;
126
+ }
127
+ uint8() {
128
+ return this.view.getUint8(this.take(1));
129
+ }
130
+ int8() {
131
+ return this.view.getInt8(this.take(1));
132
+ }
133
+ int16() {
134
+ return this.view.getInt16(this.take(2), true);
135
+ }
136
+ uint16() {
137
+ return this.view.getUint16(this.take(2), true);
138
+ }
139
+ int32() {
140
+ return this.view.getInt32(this.take(4), true);
141
+ }
142
+ uint32() {
143
+ return this.view.getUint32(this.take(4), true);
144
+ }
145
+ int64() {
146
+ return this.view.getBigInt64(this.take(8), true);
147
+ }
148
+ uint64() {
149
+ return this.view.getBigUint64(this.take(8), true);
150
+ }
151
+ float32() {
152
+ return this.view.getFloat32(this.take(4), true);
153
+ }
154
+ float64() {
155
+ return this.view.getFloat64(this.take(8), true);
156
+ }
157
+ bytes(length) {
158
+ return new Uint8Array(this.view.buffer, this.view.byteOffset + this.take(length), length);
159
+ }
160
+ done() {
161
+ if (this.offset !== this.view.byteLength) {
162
+ throw new RangeError(`TraceCLR wire payload has ${this.view.byteLength - this.offset} trailing bytes.`);
163
+ }
164
+ }
165
+ };
166
+ function parseWireType(text, depth = 0) {
167
+ if (depth > TRACECLR_WIRE_LIMITS.maxDepth) throw new RangeError("TraceCLR wire type is too deeply nested.");
168
+ if (text === "list-node<int32>") return { kind: "list-node" };
169
+ if (text === "tree-node<int32>") return { kind: "tree-node" };
170
+ for (const name of ["array", "list", "set"]) {
171
+ const prefix = `${name}<`;
172
+ if (text.startsWith(prefix) && text.endsWith(">")) {
173
+ return { kind: "container", name, element: parseWireType(text.slice(prefix.length, -1), depth + 1) };
174
+ }
175
+ }
176
+ const scalars = /* @__PURE__ */ new Set([
177
+ "void",
178
+ "null",
179
+ "bool",
180
+ "char",
181
+ "uint8",
182
+ "int8",
183
+ "int16",
184
+ "uint16",
185
+ "int32",
186
+ "uint32",
187
+ "int64",
188
+ "uint64",
189
+ "float32",
190
+ "float64",
191
+ "string"
192
+ ]);
193
+ if (!scalars.has(text)) throw new TypeError(`Unsupported TraceCLR wire type: ${text}`);
194
+ return { kind: "scalar", name: text };
195
+ }
196
+ function integer(value, minimum, maximum, label) {
197
+ if (typeof value !== "number" || !Number.isInteger(value) || value < minimum || value > maximum) {
198
+ throw new TypeError(`${label} must be an integer between ${minimum} and ${maximum}.`);
199
+ }
200
+ return value;
201
+ }
202
+ function integer64(value, signed) {
203
+ let converted = null;
204
+ if (typeof value === "bigint") {
205
+ converted = value;
206
+ } else if (typeof value === "number" && Number.isInteger(value)) {
207
+ const jsonDecimal = JSON.stringify(value);
208
+ if (jsonDecimal !== void 0) converted = BigInt(jsonDecimal);
209
+ }
210
+ const minimum = signed ? -(1n << 63n) : 0n;
211
+ const maximum = signed ? (1n << 63n) - 1n : (1n << 64n) - 1n;
212
+ if (converted === null || converted < minimum || converted > maximum) {
213
+ throw new TypeError(`${signed ? "int64" : "uint64"} must be a bigint or integer number in range.`);
214
+ }
215
+ return converted;
216
+ }
217
+ function floatingPoint(value, label) {
218
+ if (typeof value === "number") return Object.is(value, -0) ? 0 : value;
219
+ if (value === "NaN") return Number.NaN;
220
+ if (value === "Infinity") return Number.POSITIVE_INFINITY;
221
+ if (value === "-Infinity") return Number.NEGATIVE_INFINITY;
222
+ throw new TypeError(`${label} must be numeric or a named floating-point literal.`);
223
+ }
224
+ function collection(value, set) {
225
+ const items = set && value instanceof Set ? [...value] : value;
226
+ if (!Array.isArray(items)) throw new TypeError("TraceCLR collection values must be arrays or Sets.");
227
+ if (items.length > TRACECLR_WIRE_LIMITS.maxCollectionItems) {
228
+ throw new RangeError(`TraceCLR collection exceeds ${TRACECLR_WIRE_LIMITS.maxCollectionItems} items.`);
229
+ }
230
+ return items;
231
+ }
232
+ function writeValue(writer, type, value, depth) {
233
+ if (depth > TRACECLR_WIRE_LIMITS.maxDepth) throw new RangeError("TraceCLR value is too deeply nested.");
234
+ if (type.kind === "container") {
235
+ if (value === null) {
236
+ writer.int32(-1);
237
+ return;
238
+ }
239
+ const values = collection(value, type.name === "set");
240
+ writer.int32(values.length);
241
+ for (const item of values) writeValue(writer, type.element, item, depth + 1);
242
+ return;
243
+ }
244
+ if (type.kind === "list-node") {
245
+ if (value === null) {
246
+ writer.int32(-1);
247
+ return;
248
+ }
249
+ const values = Array.isArray(value) ? value : [];
250
+ if (!Array.isArray(value)) {
251
+ const seen = /* @__PURE__ */ new Set();
252
+ let node = value;
253
+ while (node !== null) {
254
+ if (typeof node !== "object" || seen.has(node)) throw new TypeError("TraceCLR ListNode must be acyclic.");
255
+ seen.add(node);
256
+ values.push(node.val ?? node.value);
257
+ node = node.next ?? null;
258
+ if (values.length > TRACECLR_WIRE_LIMITS.maxCollectionItems) throw new RangeError("TraceCLR ListNode is too long.");
259
+ }
260
+ }
261
+ writer.int32(values.length);
262
+ for (const item of values) writer.int32(integer(item, -2147483648, 2147483647, "ListNode value"));
263
+ return;
264
+ }
265
+ if (type.kind === "tree-node") {
266
+ if (value === null) {
267
+ writer.int32(-1);
268
+ return;
269
+ }
270
+ let rawValues;
271
+ if (Array.isArray(value)) {
272
+ rawValues = value;
273
+ } else if (typeof value === "object") {
274
+ const values2 = [];
275
+ const nodes = [value];
276
+ for (let index = 0; index < nodes.length; index++) {
277
+ const node = nodes[index];
278
+ if (node === null) {
279
+ values2.push(null);
280
+ continue;
281
+ }
282
+ if (typeof node !== "object") throw new TypeError("TraceCLR TreeNode nodes must be objects or null.");
283
+ const typed = node;
284
+ values2.push(typed.val ?? typed.value);
285
+ nodes.push(typed.left ?? null, typed.right ?? null);
286
+ if (nodes.length > TRACECLR_WIRE_LIMITS.maxCollectionItems) throw new RangeError("TraceCLR TreeNode is too large.");
287
+ }
288
+ while (values2.at(-1) === null) values2.pop();
289
+ rawValues = values2;
290
+ } else {
291
+ throw new TypeError("TraceCLR TreeNode inputs must be level-order arrays or node objects.");
292
+ }
293
+ const values = collection(rawValues, false);
294
+ writer.int32(values.length);
295
+ for (const item of values) {
296
+ writer.uint8(item === null ? 0 : 1);
297
+ if (item !== null) writer.int32(integer(item, -2147483648, 2147483647, "TreeNode value"));
298
+ }
299
+ return;
300
+ }
301
+ switch (type.name) {
302
+ case "void":
303
+ return;
304
+ case "null":
305
+ if (value !== null) throw new TypeError("TraceCLR null result must be null.");
306
+ writer.uint8(0);
307
+ return;
308
+ case "bool":
309
+ if (typeof value !== "boolean") throw new TypeError("bool must be boolean.");
310
+ writer.uint8(value ? 1 : 0);
311
+ return;
312
+ case "char": {
313
+ if (typeof value !== "string" || value.length !== 1) throw new TypeError("char must be one UTF-16 code unit.");
314
+ writer.uint16(value.charCodeAt(0));
315
+ return;
316
+ }
317
+ case "uint8":
318
+ writer.uint8(integer(value, 0, 255, "uint8"));
319
+ return;
320
+ case "int8":
321
+ writer.int8(integer(value, -128, 127, "int8"));
322
+ return;
323
+ case "int16":
324
+ writer.int16(integer(value, -32768, 32767, "int16"));
325
+ return;
326
+ case "uint16":
327
+ writer.uint16(integer(value, 0, 65535, "uint16"));
328
+ return;
329
+ case "int32":
330
+ writer.int32(integer(value, -2147483648, 2147483647, "int32"));
331
+ return;
332
+ case "uint32":
333
+ writer.uint32(integer(value, 0, 4294967295, "uint32"));
334
+ return;
335
+ case "int64":
336
+ writer.int64(integer64(value, true));
337
+ return;
338
+ case "uint64":
339
+ writer.uint64(integer64(value, false));
340
+ return;
341
+ case "float32":
342
+ writer.float32(floatingPoint(value, "float32"));
343
+ return;
344
+ case "float64":
345
+ writer.float64(floatingPoint(value, "float64"));
346
+ return;
347
+ case "string": {
348
+ if (value === null) {
349
+ writer.int32(-1);
350
+ return;
351
+ }
352
+ if (typeof value !== "string") throw new TypeError("string must be a string or null.");
353
+ const bytes = new TextEncoder().encode(value);
354
+ writer.int32(bytes.byteLength);
355
+ writer.bytes(bytes);
356
+ return;
357
+ }
358
+ }
359
+ }
360
+ function normalizePortableResult(type, value) {
361
+ if (value === null || value === void 0) return value;
362
+ if (type.kind === "container") {
363
+ const values = type.name === "set" && value instanceof Set ? [...value] : value;
364
+ if (!Array.isArray(values)) {
365
+ throw new TypeError(`TraceCLR ${type.name} result did not decode to a collection.`);
366
+ }
367
+ return values.map((item) => normalizePortableResult(type.element, item));
368
+ }
369
+ if (type.kind === "scalar" && (type.name === "int64" || type.name === "uint64")) {
370
+ if (typeof value !== "bigint") {
371
+ throw new TypeError(`TraceCLR ${type.name} result did not decode to a bigint.`);
372
+ }
373
+ return Number(value);
374
+ }
375
+ if (type.kind === "scalar" && (type.name === "float32" || type.name === "float64")) {
376
+ if (typeof value !== "number") {
377
+ throw new TypeError(`TraceCLR ${type.name} result did not decode to a number.`);
378
+ }
379
+ if (Number.isNaN(value)) return "NaN";
380
+ if (value === Number.POSITIVE_INFINITY) return "Infinity";
381
+ if (value === Number.NEGATIVE_INFINITY) return "-Infinity";
382
+ }
383
+ return value;
384
+ }
385
+ function readLength(reader) {
386
+ const length = reader.int32();
387
+ if (length === -1) return null;
388
+ if (length < 0 || length > TRACECLR_WIRE_LIMITS.maxCollectionItems) {
389
+ throw new RangeError(`Invalid TraceCLR collection length: ${length}.`);
390
+ }
391
+ return length;
392
+ }
393
+ function readByteLength(reader) {
394
+ const length = reader.int32();
395
+ if (length === -1) return null;
396
+ if (length < 0 || length > TRACECLR_WIRE_LIMITS.maxBytes) {
397
+ throw new RangeError(`Invalid TraceCLR byte length: ${length}.`);
398
+ }
399
+ return length;
400
+ }
401
+ function readValue(reader, type, depth) {
402
+ if (depth > TRACECLR_WIRE_LIMITS.maxDepth) throw new RangeError("TraceCLR value is too deeply nested.");
403
+ if (type.kind === "container") {
404
+ const length = readLength(reader);
405
+ if (length === null) return null;
406
+ const values = Array.from({ length }, () => readValue(reader, type.element, depth + 1));
407
+ return type.name === "set" ? new Set(values) : values;
408
+ }
409
+ if (type.kind === "list-node") {
410
+ const length = readLength(reader);
411
+ return length === null ? null : Array.from({ length }, () => reader.int32());
412
+ }
413
+ if (type.kind === "tree-node") {
414
+ const length = readLength(reader);
415
+ if (length === null) return null;
416
+ const values = Array.from({ length }, () => reader.uint8() === 0 ? null : reader.int32());
417
+ while (values.at(-1) === null) values.pop();
418
+ return values;
419
+ }
420
+ switch (type.name) {
421
+ case "void":
422
+ return void 0;
423
+ case "null":
424
+ if (reader.uint8() !== 0) throw new RangeError("Invalid TraceCLR null marker.");
425
+ return null;
426
+ case "bool": {
427
+ const value = reader.uint8();
428
+ if (value > 1) throw new RangeError("Invalid TraceCLR bool.");
429
+ return value === 1;
430
+ }
431
+ case "char":
432
+ return String.fromCharCode(reader.uint16());
433
+ case "uint8":
434
+ return reader.uint8();
435
+ case "int8":
436
+ return reader.int8();
437
+ case "int16":
438
+ return reader.int16();
439
+ case "uint16":
440
+ return reader.uint16();
441
+ case "int32":
442
+ return reader.int32();
443
+ case "uint32":
444
+ return reader.uint32();
445
+ case "int64":
446
+ return reader.int64();
447
+ case "uint64":
448
+ return reader.uint64();
449
+ case "float32":
450
+ return reader.float32();
451
+ case "float64":
452
+ return reader.float64();
453
+ case "string": {
454
+ const length = readByteLength(reader);
455
+ return length === null ? null : new TextDecoder("utf-8", { fatal: true }).decode(reader.bytes(length));
456
+ }
457
+ }
458
+ }
459
+ function begin(writer) {
460
+ writer.uint32(WIRE_MAGIC);
461
+ }
462
+ function verify(reader) {
463
+ if (reader.uint32() !== WIRE_MAGIC) throw new RangeError("TraceCLR wire magic/version mismatch.");
464
+ }
465
+ function encodeTraceClrWireInputs(contract, inputs) {
466
+ const writer = new WireWriter();
467
+ begin(writer);
468
+ writer.uint16(contract.parameters.length);
469
+ const positionalInputs = Object.values(inputs);
470
+ for (const [index, parameter] of contract.parameters.entries()) {
471
+ const value = Object.prototype.hasOwnProperty.call(inputs, parameter.name) ? inputs[parameter.name] : positionalInputs[index];
472
+ if (value === void 0 && !Object.prototype.hasOwnProperty.call(inputs, parameter.name) && index >= positionalInputs.length) {
473
+ throw new TypeError(`Missing TraceCLR input: ${parameter.name}`);
474
+ }
475
+ writeValue(writer, parseWireType(parameter.type.wireType), value, 0);
476
+ }
477
+ return writer.finish();
478
+ }
479
+ function decodeTraceClrWireResult(contract, bytes) {
480
+ const reader = new WireReader(bytes);
481
+ verify(reader);
482
+ const type = parseWireType(contract.returnType.wireType);
483
+ const value = readValue(reader, type, 0);
484
+ reader.done();
485
+ return normalizePortableResult(type, value);
486
+ }
487
+
34
488
  // packages/runtime-csharp/src/csharp-worker-client.ts
35
489
  var EXECUTION_TIMEOUT_MS = 2e4;
36
490
  var TRACING_TIMEOUT_MS = 2e4;
@@ -407,12 +861,17 @@ var CSharpWorkerClient = class {
407
861
  async executePreparedCode(prepared, call) {
408
862
  return this.runPreparedExecutionGeneration(call.signal, async () => {
409
863
  const wallClockMs = call.limits?.wallClockMs ?? this.executionTimeoutMs;
864
+ const inputBytes = prepared.preparedRunnerTier === "algorithm-fast" ? encodeTraceClrWireInputs(
865
+ prepared.traceClrWireContract,
866
+ call.inputs
867
+ ) : void 0;
410
868
  const program = this.preparedReadyEffect().pipe(
411
869
  andThen(
412
870
  this.core.withExecutionDeadline(
413
871
  this.sendCommandEffect("execute-prepared-code", {
414
872
  prepared,
415
873
  inputs: call.inputs,
874
+ ...inputBytes ? { inputBytes } : {},
416
875
  assetBaseUrl: this.options.assetBaseUrl,
417
876
  timeoutMs: Math.max(100, wallClockMs - 1e3),
418
877
  ...this.workerOptionsPayload()
@@ -422,6 +881,17 @@ var CSharpWorkerClient = class {
422
881
  )
423
882
  );
424
883
  const result = await this.core.runClientEffect(program, call.signal);
884
+ if (prepared.preparedRunnerTier === "algorithm-fast" && result.success) {
885
+ if (!(result.outputBytes instanceof Uint8Array)) {
886
+ throw new TypeError(
887
+ "The algorithm-fast C# runner returned no binary output payload."
888
+ );
889
+ }
890
+ result.output = decodeTraceClrWireResult(
891
+ prepared.traceClrWireContract,
892
+ result.outputBytes
893
+ );
894
+ }
425
895
  return this.toCodeExecutionResult(result);
426
896
  });
427
897
  }
@@ -433,6 +903,10 @@ var CSharpWorkerClient = class {
433
903
  }
434
904
  return this.runPreparedExecutionGeneration(call.signal, async () => {
435
905
  const wallClockMs = call.limits?.wallClockMs ?? this.resolveTracingTimeoutMs(prepared.functionName, prepared.executionStyle);
906
+ const inputBytes = prepared.preparedRunnerTier === "algorithm-fast" ? encodeTraceClrWireInputs(
907
+ prepared.traceClrWireContract,
908
+ call.inputs
909
+ ) : void 0;
436
910
  let result;
437
911
  const program = this.preparedReadyEffect().pipe(
438
912
  andThen(
@@ -440,6 +914,7 @@ var CSharpWorkerClient = class {
440
914
  this.sendCommandEffect("execute-prepared-trace", {
441
915
  prepared,
442
916
  inputs: call.inputs,
917
+ ...inputBytes ? { inputBytes } : {},
443
918
  ...call.recordTrace === void 0 ? {} : { tracingEnabled: call.recordTrace },
444
919
  assetBaseUrl: this.options.assetBaseUrl,
445
920
  timeoutMs: Math.max(100, wallClockMs - 1e3),
@@ -455,6 +930,17 @@ var CSharpWorkerClient = class {
455
930
  } catch (error) {
456
931
  return this.traceClientFailure(error, wallClockMs);
457
932
  }
933
+ if (prepared.preparedRunnerTier === "algorithm-fast" && result.success) {
934
+ if (!(result.outputBytes instanceof Uint8Array)) {
935
+ throw new TypeError(
936
+ "The algorithm-fast C# trace runner returned no binary output payload."
937
+ );
938
+ }
939
+ result.output = decodeTraceClrWireResult(
940
+ prepared.traceClrWireContract,
941
+ result.outputBytes
942
+ );
943
+ }
458
944
  return this.toTraceExecutionResult(
459
945
  result,
460
946
  prepared.traceOptions,
@@ -638,4 +1124,4 @@ var CSharpWorkerClient = class {
638
1124
  export {
639
1125
  CSharpWorkerClient
640
1126
  };
641
- //# sourceMappingURL=chunk-6LE4KEMZ.js.map
1127
+ //# sourceMappingURL=chunk-4PN5YD6J.js.map