@tracecode/harness 0.16.2 → 0.16.4

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 (41) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/dist/{browser-runtime-provider-45ND6W3K.js → browser-runtime-provider-OGJQLGXU.js} +4 -4
  3. package/dist/{chunk-5SU2JQGI.js → chunk-5RT5IT4I.js} +16 -14
  4. package/dist/{chunk-J54PE2JS.js → chunk-6LE4KEMZ.js} +2 -2
  5. package/dist/{chunk-K4424WAS.js → chunk-AAKNIYV6.js} +3 -3
  6. package/dist/{chunk-HK62URW2.js → chunk-M7SNEZDR.js} +2 -2
  7. package/dist/{chunk-MJOC6WVB.js → chunk-RCOPAMVR.js} +10 -2
  8. package/dist/{chunk-DGXNINFR.js → chunk-Y72C46GE.js} +9 -9
  9. package/dist/core.cjs +8 -8
  10. package/dist/core.d.cts +2 -2
  11. package/dist/core.d.ts +2 -2
  12. package/dist/core.js +1 -1
  13. package/dist/{cpp-worker-client-I6CPM7TA.js → cpp-worker-client-HV7RO2P5.js} +3 -3
  14. package/dist/{csharp-worker-client-X7R4VXF4.js → csharp-worker-client-ARGMOB3M.js} +3 -3
  15. package/dist/internal/tracekernel-workspace.cjs +171 -31
  16. package/dist/internal/tracekernel-workspace.d.cts +8 -2
  17. package/dist/internal/tracekernel-workspace.d.ts +8 -2
  18. package/dist/internal/tracekernel-workspace.js +164 -24
  19. package/dist/{java-project-MLWER3CQ.js → java-project-JB5TUIFU.js} +2 -2
  20. package/dist/{java-project-client-R7CKC72F.js → java-project-client-PEQKFTH6.js} +11 -2
  21. package/dist/judge.cjs +194 -35
  22. package/dist/judge.d.cts +1 -1
  23. package/dist/judge.d.ts +1 -1
  24. package/dist/judge.js +6 -6
  25. package/dist/{project-browser-UALCR5KR.js → project-browser-3S2FWEAP.js} +2 -2
  26. package/dist/{project-browser-EIQ2FOXP.js → project-browser-HCQCXAYC.js} +2 -2
  27. package/dist/{project-browser-V3W4CQAQ.js → project-browser-QN7YOJQQ.js} +2 -2
  28. package/dist/{project-browser-JR2WG7DG.js → project-browser-S4KLCZV7.js} +2 -2
  29. package/dist/{project-browser-T3EIQCMD.js → project-browser-WDUWUGLZ.js} +2 -2
  30. package/dist/{python-worker-client-MRWQTXOF.js → python-worker-client-EX6Q2W4L.js} +3 -3
  31. package/dist/{runtime-environment-D7mZm8SA.d.cts → runtime-environment-BO5I1fAC.d.cts} +5 -0
  32. package/dist/{runtime-environment-Q60S0pUa.d.ts → runtime-environment-Dfg6ZoCj.d.ts} +5 -0
  33. package/dist/{runtime-open-source-info-BQtIRJ9F.d.cts → runtime-open-source-info-CaBpNicy.d.cts} +4 -2
  34. package/dist/{runtime-open-source-info-FkIxlAcm.d.ts → runtime-open-source-info-D0OJc4zH.d.ts} +4 -2
  35. package/dist/tracekernel.cjs +359 -60
  36. package/dist/tracekernel.d.cts +4 -4
  37. package/dist/tracekernel.d.ts +4 -4
  38. package/dist/tracekernel.js +166 -26
  39. package/package.json +3 -3
  40. package/runtime-assets.lock.json +7 -7
  41. package/workers/javascript/javascript-project-worker.js +7 -7
package/dist/judge.cjs CHANGED
@@ -13074,7 +13074,7 @@ var init_runtime_language_info_data = __esm({
13074
13074
  "versionLabel": "Python 3.13.2",
13075
13075
  "executionPlatform": {
13076
13076
  "name": "TraceKernel",
13077
- "version": "0.16.2"
13077
+ "version": "0.16.4"
13078
13078
  },
13079
13079
  "description": "Python 3.13.2 runs in TraceKernel's isolated Python runtime.\n\nCommon algorithm helpers are imported automatically, including array, bisect, collections, functools, heapq, itertools. Other standard-library modules can be imported normally.\n\nOptional third-party packages are consumer-owned runtime assets and are available only when declared by the TraceKernel runtime manifest.",
13080
13080
  "runtime": {
@@ -13101,7 +13101,7 @@ var init_runtime_language_info_data = __esm({
13101
13101
  "versionLabel": "JavaScript (ECMAScript 2023)",
13102
13102
  "executionPlatform": {
13103
13103
  "name": "TraceKernel",
13104
- "version": "0.16.2"
13104
+ "version": "0.16.4"
13105
13105
  },
13106
13106
  "runtime": {
13107
13107
  "name": "TraceKernel JavaScript runtime",
@@ -13193,7 +13193,7 @@ Binary Search Tree, Trie, and Graph are bundled too, but are not exposed globall
13193
13193
  "versionLabel": "TypeScript 5.9.3",
13194
13194
  "executionPlatform": {
13195
13195
  "name": "TraceKernel",
13196
- "version": "0.16.2"
13196
+ "version": "0.16.4"
13197
13197
  },
13198
13198
  "description": `TypeScript 5.9.3 is compiled with the TypeScript compiler and executed by TraceKernel's JavaScript runtime.
13199
13199
 
@@ -13293,7 +13293,7 @@ The compiled output runs on the same TraceKernel execution lane as JavaScript su
13293
13293
  "versionLabel": "Java 23",
13294
13294
  "executionPlatform": {
13295
13295
  "name": "TraceKernel",
13296
- "version": "0.16.2"
13296
+ "version": "0.16.4"
13297
13297
  },
13298
13298
  "description": "Java 23 is compiled with javac 23 and executed by the Java runtime on TraceKernel.\n\nCommon imports are added automatically: java.util.*, java.io.*, java.math.*, java.util.stream.*, javafx.util.Pair.",
13299
13299
  "runtime": {
@@ -13330,7 +13330,7 @@ The compiled output runs on the same TraceKernel execution lane as JavaScript su
13330
13330
  "versionLabel": "C# 14",
13331
13331
  "executionPlatform": {
13332
13332
  "name": "TraceKernel",
13333
- "version": "0.16.2"
13333
+ "version": "0.16.4"
13334
13334
  },
13335
13335
  "description": "C# 14 source is compiled and executed by TraceKernel's isolated C# runtime.\n\nCommon namespaces are imported automatically: System, System.Collections, System.Collections.Generic, System.IO, System.Linq, System.Numerics, System.Text, System.Text.RegularExpressions.",
13336
13336
  "runtime": {
@@ -13359,7 +13359,7 @@ The compiled output runs on the same TraceKernel execution lane as JavaScript su
13359
13359
  "versionLabel": "C++23",
13360
13360
  "executionPlatform": {
13361
13361
  "name": "TraceKernel",
13362
- "version": "0.16.2"
13362
+ "version": "0.16.4"
13363
13363
  },
13364
13364
  "description": "C++ source is compiled using the C++23 standard.\n\nSubmissions compile to WebAssembly and run in TraceKernel's WASI execution lane. The compiler currently uses -O0 and -fno-exceptions, with a fixed program stack size.\n\nCommon standard library headers are included automatically, including <algorithm>, <array>, <bitset>, <climits>, <cmath>, <cstdint>, <functional>, <limits>, <numeric>, <sstream>, <tuple>, <vector>, <unordered_map>, <unordered_set> and more.",
13365
13365
  "runtime": {
@@ -13524,7 +13524,7 @@ var init_runtime_open_source_info_data = __esm({
13524
13524
  {
13525
13525
  "kind": "modifications",
13526
13526
  "label": "Runtime modifications",
13527
- "url": "https://github.com/tracecodeapp/harness/tree/v0.16.2/workers/python/pyodide-0.29.3"
13527
+ "url": "https://github.com/tracecodeapp/harness/tree/v0.16.4/workers/python/pyodide-0.29.3"
13528
13528
  }
13529
13529
  ]
13530
13530
  }
@@ -15138,7 +15138,7 @@ var init_package = __esm({
15138
15138
  "package.json"() {
15139
15139
  package_default = {
15140
15140
  name: "@tracecode/harness",
15141
- version: "0.16.2",
15141
+ version: "0.16.4",
15142
15142
  license: "AGPL-3.0-only",
15143
15143
  homepage: "https://tracecode.app",
15144
15144
  repository: {
@@ -31356,7 +31356,6 @@ var init_cpp_worker_client = __esm({
31356
31356
  });
31357
31357
  }
31358
31358
  async executeProjectCpp(request, timeoutMs = this.executionTimeoutMs, onEvent, signal = request.signal, engineLease) {
31359
- engineLease?.attach({ release: () => void 0 });
31360
31359
  if (request.source === "compile" && this.options.trustedCompilerService) {
31361
31360
  const {
31362
31361
  signal: _signal,
@@ -31425,6 +31424,7 @@ var init_cpp_worker_client = __esm({
31425
31424
  }]
31426
31425
  };
31427
31426
  }
31427
+ engineLease?.attach({ release: () => void 0 });
31428
31428
  return this.runInDisposableExecutionWorker(async (lifecycleGeneration) => {
31429
31429
  const {
31430
31430
  signal: _signal,
@@ -31870,6 +31870,14 @@ var init_tracecc_compiler_service = __esm({
31870
31870
  }, this.requestTimeoutMs);
31871
31871
  worker.onmessage = (event) => {
31872
31872
  const message = event.data;
31873
+ if (message.type === "idle-timeout") {
31874
+ if (generation === this.generation) {
31875
+ this.reset(
31876
+ new Error("TraceCC compiler Worker closed after idle timeout.")
31877
+ );
31878
+ }
31879
+ return;
31880
+ }
31873
31881
  if (message.type === "worker-ready") {
31874
31882
  globalThis.clearTimeout(readyTimeout);
31875
31883
  resolve();
@@ -95271,20 +95279,27 @@ var init_terminal_session = __esm({
95271
95279
  signalCharacter === "" ? "SIGINT" : "SIGQUIT"
95272
95280
  );
95273
95281
  }
95274
- const route = this.options.terminalInputRouter?.write(data) ?? (this.activeStdinPipe !== null ? "legacy" : "rejected");
95282
+ const routed = this.options.terminalInputRouter?.write(data);
95283
+ const route = routed === "rejected" && this.activeStdinPipe !== null ? "legacy" : routed ?? (this.activeStdinPipe !== null ? "legacy" : "rejected");
95275
95284
  if (route === "legacy") {
95276
- this.activeStdinPipe?.write(data);
95285
+ if (!this.activeStdinPipe) return false;
95286
+ try {
95287
+ this.activeStdinPipe.write(data);
95288
+ } catch {
95289
+ return false;
95290
+ }
95277
95291
  }
95278
95292
  const accepted = route !== "rejected";
95279
95293
  if (accepted && this.currentInputState.mode === "stdin") {
95280
95294
  this.activeStdinPrompt = "";
95281
- this.setInputState("busy", "stdin-submit");
95295
+ this.setInputState("stdin", "stdin-submit", "");
95282
95296
  }
95283
95297
  return accepted;
95284
95298
  }
95285
95299
  endStdin() {
95286
95300
  if (!this.activeRun || this.activeStdinEnded) return false;
95287
- const route = this.options.terminalInputRouter?.end() ?? (this.activeStdinPipe !== null ? "legacy" : "rejected");
95301
+ const routed = this.options.terminalInputRouter?.end();
95302
+ const route = routed === "rejected" && this.activeStdinPipe !== null ? "legacy" : routed ?? (this.activeStdinPipe !== null ? "legacy" : "rejected");
95288
95303
  if (route === "rejected") return false;
95289
95304
  this.activeStdinEnded = true;
95290
95305
  if (route === "legacy") {
@@ -95323,6 +95338,14 @@ var init_terminal_session = __esm({
95323
95338
  this.emitTerminalEvent(reason);
95324
95339
  return this.currentInputState;
95325
95340
  }
95341
+ showForegroundInputLine() {
95342
+ const acceptsInput = this.activeStdinPipe !== null || this.options.terminalInputRouter !== void 0;
95343
+ return this.setInputState(
95344
+ acceptsInput ? "stdin" : "busy",
95345
+ "command-start",
95346
+ acceptsInput ? "" : this.prompt.text
95347
+ );
95348
+ }
95326
95349
  async run(command, options = {}) {
95327
95350
  const trimmed = command.trim();
95328
95351
  if (!trimmed) return { stdout: "", stderr: "", exitCode: 0 };
@@ -95377,7 +95400,7 @@ var init_terminal_session = __esm({
95377
95400
  this.activeTerminalEventHandler = options.onTerminalEvent;
95378
95401
  this.activeStdinPrompt = "";
95379
95402
  this.activeCommand = submittedCommand;
95380
- this.setInputState("busy", "command-start");
95403
+ this.showForegroundInputLine();
95381
95404
  try {
95382
95405
  let stdout = "";
95383
95406
  let stderr = "";
@@ -95406,6 +95429,7 @@ var init_terminal_session = __esm({
95406
95429
  ...error ? { error } : {}
95407
95430
  };
95408
95431
  } finally {
95432
+ this.options.terminalInputRouter?.reset();
95409
95433
  ownedStdinPipe?.close();
95410
95434
  this.activeStdinPipe = previousStdinPipe;
95411
95435
  this.activeStdinEnded = previousStdinEnded;
@@ -95444,7 +95468,7 @@ var init_terminal_session = __esm({
95444
95468
  this.activeStdinPrompt = "";
95445
95469
  this.activeCommand = trimmed;
95446
95470
  this.activeCommandAbortController = commandAbortController;
95447
- this.setInputState("busy", "command-start");
95471
+ this.showForegroundInputLine();
95448
95472
  try {
95449
95473
  const result = await this.runForegroundTerminalCommand(
95450
95474
  trimmed,
@@ -95455,6 +95479,7 @@ var init_terminal_session = __esm({
95455
95479
  return result;
95456
95480
  } finally {
95457
95481
  options.signal?.removeEventListener("abort", forwardExternalAbort);
95482
+ this.options.terminalInputRouter?.reset();
95458
95483
  ownedStdinPipe?.close();
95459
95484
  this.activeStdinPipe = previousStdinPipe;
95460
95485
  this.activeStdinEnded = previousStdinEnded;
@@ -101289,21 +101314,26 @@ function createWorkspaceRuntimeRunnerBridge(bridge) {
101289
101314
  ...requestWithoutLegacyStdin
101290
101315
  } = request;
101291
101316
  const activeStdinPipe = request.source !== "compile" && request.source !== "stdin" ? commandContext?.stdinPipe : void 0;
101317
+ const consumesLiveStdin = request.source !== "compile" && request.source !== "stdin";
101292
101318
  const stdinPipe = request.stdinPipe ?? activeStdinPipe;
101293
- const processBinding = commandContext ? bridge.bindProcess(commandContext, descriptorStdio) : {};
101319
+ const processBinding = commandContext ? bridge.bindProcess(
101320
+ commandContext,
101321
+ descriptorStdio,
101322
+ consumesLiveStdin
101323
+ ) : {};
101294
101324
  const signal = processBinding.signal ?? request.signal;
101295
101325
  const runtimeIo = commandContext?.runtimeIo;
101296
101326
  let acceptingRunnerEvents = true;
101297
101327
  let result;
101298
101328
  const kernelSyscalls = options.kernelSyscalls ? bridge.createKernelSyscallBridge(commandContext) : void 0;
101299
- if (descriptorStdio && commandContext) {
101329
+ if (descriptorStdio && commandContext && consumesLiveStdin) {
101300
101330
  bridge.startHostStandardInputPump(commandContext);
101301
101331
  }
101302
101332
  try {
101303
- result = await runner({
101304
- ...descriptorStdio ? requestWithoutLegacyStdin : request,
101333
+ const execution = runner({
101334
+ ...descriptorStdio || !consumesLiveStdin ? requestWithoutLegacyStdin : request,
101305
101335
  ...processBinding.process ? { process: processBinding.process } : {},
101306
- ...stdinPipe && !descriptorStdio ? { stdinPipe: { buffer: stdinPipe.buffer } } : {},
101336
+ ...stdinPipe && !descriptorStdio && consumesLiveStdin ? { stdinPipe: { buffer: stdinPipe.buffer } } : {},
101307
101337
  ...commandContext?.terminal ? { terminal: commandContext.terminal } : {},
101308
101338
  ...commandContext?.engineLease ? { engineLease: commandContext.engineLease } : {},
101309
101339
  ...signal ? { signal } : {},
@@ -101315,6 +101345,8 @@ function createWorkspaceRuntimeRunnerBridge(bridge) {
101315
101345
  bridge.handleRuntimeCommandEvent(event, commandContext);
101316
101346
  }
101317
101347
  });
101348
+ await processBinding.replayStartupInput?.();
101349
+ result = await execution;
101318
101350
  } finally {
101319
101351
  acceptingRunnerEvents = false;
101320
101352
  kernelSyscalls?.close();
@@ -102358,7 +102390,7 @@ async function createRuntimeWorkspace(options = {}) {
102358
102390
  }
102359
102391
  return workspace;
102360
102392
  }
102361
- var PRINCIPAL_ACTOR2, RUNTIME_ACTOR, SYSTEM_ACTOR2, TRACEKERNEL_SYSCALL_ERROR_CODES, TRACEKERNEL_ZOMBIE_RETENTION_MS, RuntimeProjectWorkspace;
102393
+ var PRINCIPAL_ACTOR2, RUNTIME_ACTOR, SYSTEM_ACTOR2, TERMINAL_STARTUP_INPUT_MAX_BYTES, TRACEKERNEL_SYSCALL_ERROR_CODES, TRACEKERNEL_ZOMBIE_RETENTION_MS, RuntimeProjectWorkspace;
102362
102394
  var init_runtime_project_workspace = __esm({
102363
102395
  "packages/tracekernel/src/workspace/runtime-project-workspace.ts"() {
102364
102396
  "use strict";
@@ -102408,6 +102440,7 @@ var init_runtime_project_workspace = __esm({
102408
102440
  PRINCIPAL_ACTOR2 = runtimeWorkspaceActorPreset("principal");
102409
102441
  RUNTIME_ACTOR = runtimeWorkspaceActorPreset("runtime");
102410
102442
  SYSTEM_ACTOR2 = runtimeWorkspaceActorPreset("system");
102443
+ TERMINAL_STARTUP_INPUT_MAX_BYTES = 64 * 1024 - 1;
102411
102444
  TRACEKERNEL_SYSCALL_ERROR_CODES = /* @__PURE__ */ new Set([
102412
102445
  "E2BIG",
102413
102446
  "EAGAIN",
@@ -102482,6 +102515,7 @@ var init_runtime_project_workspace = __esm({
102482
102515
  processState = new WorkspaceProcessState();
102483
102516
  terminalShells = /* @__PURE__ */ new Map();
102484
102517
  terminalResourceIds = /* @__PURE__ */ new Map();
102518
+ pendingTerminalStartupInput = /* @__PURE__ */ new Map();
102485
102519
  processProjection;
102486
102520
  // Temporary 0.13 introspection aliases. The process state module remains
102487
102521
  // authoritative; these preserve existing hardening probes while 0.14 moves
@@ -102663,17 +102697,24 @@ var init_runtime_project_workspace = __esm({
102663
102697
  });
102664
102698
  const withEvents = createWorkspaceRuntimeRunnerBridge({
102665
102699
  resolveCommandContext: (context2) => this.resolveCommandContext(context2),
102666
- bindProcess: (context2, descriptorStdio) => {
102700
+ bindProcess: (context2, descriptorStdio, consumesLiveStdin) => {
102667
102701
  const executionHandle = this.processProjection.executionHandle(
102668
102702
  context2.process
102669
102703
  );
102670
102704
  if (executionHandle) {
102671
102705
  executionHandle.descriptorStdio = descriptorStdio;
102706
+ executionHandle.consumesLiveStdin = consumesLiveStdin;
102672
102707
  }
102673
102708
  const processSnapshot = this.processProjection.authoritativeSnapshot(
102674
102709
  context2.process
102675
102710
  );
102676
102711
  return {
102712
+ replayStartupInput: () => this.resolvePendingTerminalStartupInput(
102713
+ context2.process.pid,
102714
+ descriptorStdio,
102715
+ context2.stdinPipe,
102716
+ consumesLiveStdin
102717
+ ),
102677
102718
  ...executionHandle?.abortController?.signal ? { signal: executionHandle.abortController.signal } : {},
102678
102719
  ...executionHandle?.signalChannel ? { kernelSignals: executionHandle.signalChannel } : {},
102679
102720
  ...processSnapshot ? {
@@ -105221,24 +105262,106 @@ var init_runtime_project_workspace = __esm({
105221
105262
  )
105222
105263
  );
105223
105264
  }
105224
- kernelTerminalInputRoute(terminal) {
105265
+ kernelTerminalInputRoute(terminalSessionId, terminal) {
105225
105266
  const hasDescriptorConsumer = this.traceKernelAuthority?.session.processSnapshots().some(
105226
- (process3) => process3.sid === terminal.sessionId && process3.pgid === terminal.foregroundProcessGroupId && this.processState.executionHandles.get(process3.pid)?.descriptorStdio === true
105267
+ (process3) => process3.sid === terminal.sessionId && process3.pgid === terminal.foregroundProcessGroupId && this.processState.executionHandles.get(process3.pid)?.descriptorStdio === true && this.processState.executionHandles.get(process3.pid)?.consumesLiveStdin === true
105227
105268
  ) === true;
105228
- return hasDescriptorConsumer ? "kernel" : "legacy";
105269
+ if (hasDescriptorConsumer) return "kernel";
105270
+ const foregroundPid = this.processState.terminalForeground.get(
105271
+ terminalSessionId
105272
+ );
105273
+ if (foregroundPid === void 0) return "pending";
105274
+ const executionHandle = this.processState.executionHandles.get(foregroundPid);
105275
+ if (executionHandle?.consumesLiveStdin !== true) return "pending";
105276
+ const descriptorStdio = executionHandle.descriptorStdio;
105277
+ return descriptorStdio === void 0 ? "pending" : descriptorStdio ? "kernel" : "legacy";
105278
+ }
105279
+ queueTerminalStartupInput(terminalSessionId, input = {}) {
105280
+ const pending2 = this.pendingTerminalStartupInput.get(terminalSessionId) ?? {
105281
+ chunks: [],
105282
+ byteLength: 0,
105283
+ eof: false
105284
+ };
105285
+ if (input.data) {
105286
+ const byteLength = new TextEncoder().encode(input.data).byteLength;
105287
+ if (pending2.byteLength + byteLength > TERMINAL_STARTUP_INPUT_MAX_BYTES) {
105288
+ return false;
105289
+ }
105290
+ pending2.chunks.push(input.data);
105291
+ pending2.byteLength += byteLength;
105292
+ }
105293
+ if (input.eof) pending2.eof = true;
105294
+ this.pendingTerminalStartupInput.set(terminalSessionId, pending2);
105295
+ return true;
105229
105296
  }
105230
- writeKernelTerminalInput(terminalSessionId, data) {
105297
+ async resolvePendingTerminalStartupInput(foregroundPid, descriptorStdio, stdinPipe, consumesLiveStdin = true) {
105298
+ const boundProcess = this.processProjection.find(foregroundPid);
105299
+ const boundSnapshot = boundProcess ? this.processProjection.authoritativeSnapshot(boundProcess) : void 0;
105300
+ const terminalSessionId = [...this.processState.terminalForeground].find(([, pid]) => {
105301
+ if (pid === foregroundPid) return true;
105302
+ const terminalProcess = this.processProjection.find(pid);
105303
+ const terminalSnapshot = terminalProcess ? this.processProjection.authoritativeSnapshot(terminalProcess) : void 0;
105304
+ return Boolean(
105305
+ boundSnapshot && terminalSnapshot && boundSnapshot.pgid === terminalSnapshot.pgid
105306
+ );
105307
+ })?.[0];
105308
+ if (!terminalSessionId) return;
105309
+ const pending2 = this.pendingTerminalStartupInput.get(terminalSessionId);
105310
+ if (!pending2) return;
105311
+ if (!consumesLiveStdin) return;
105312
+ this.pendingTerminalStartupInput.delete(terminalSessionId);
105313
+ if (!descriptorStdio) {
105314
+ if (!stdinPipe) return;
105315
+ try {
105316
+ for (const chunk2 of pending2.chunks) stdinPipe.write(chunk2);
105317
+ if (pending2.eof) stdinPipe.close();
105318
+ } catch {
105319
+ stdinPipe.close();
105320
+ }
105321
+ return;
105322
+ }
105231
105323
  const authority = this.traceKernelAuthority;
105232
105324
  const terminalId = this.terminalResourceIds.get(terminalSessionId);
105233
105325
  const terminal = terminalId === void 0 ? void 0 : authority?.session.terminalSnapshots().find(
105234
105326
  (candidate) => candidate.id === terminalId
105235
105327
  );
105236
- if (!authority || !terminal || terminal.closed) return "rejected";
105328
+ if (!authority || !terminal || terminal.closed) return;
105329
+ const bytes2 = new TextEncoder().encode(pending2.chunks.join(""));
105330
+ await runPromise(
105331
+ gen2(function* () {
105332
+ if (bytes2.byteLength > 0) {
105333
+ yield* authority.session.writeTerminalInput(terminal.id, bytes2);
105334
+ }
105335
+ if (pending2.eof) {
105336
+ yield* authority.session.sendTerminalInputEof(terminal.id);
105337
+ }
105338
+ }).pipe(catchAll2(() => _void))
105339
+ );
105340
+ }
105341
+ discardPendingTerminalStartupInput(terminalSessionId, foregroundPid) {
105342
+ if (terminalSessionId && (foregroundPid === void 0 || this.processState.terminalForeground.get(terminalSessionId) === foregroundPid)) {
105343
+ this.pendingTerminalStartupInput.delete(terminalSessionId);
105344
+ }
105345
+ }
105346
+ writeKernelTerminalInput(terminalSessionId, data) {
105237
105347
  const signalByte = new TextEncoder().encode(data).find(
105238
105348
  (byte) => byte === 3 || byte === 28
105239
105349
  );
105240
- if (signalByte === void 0 && this.kernelTerminalInputRoute(terminal) === "legacy") {
105241
- return "legacy";
105350
+ const authority = this.traceKernelAuthority;
105351
+ const terminalId = this.terminalResourceIds.get(terminalSessionId);
105352
+ const terminal = terminalId === void 0 ? void 0 : authority?.session.terminalSnapshots().find(
105353
+ (candidate) => candidate.id === terminalId
105354
+ );
105355
+ if (!authority || !terminal || terminal.closed) {
105356
+ if (signalByte !== void 0) return "rejected";
105357
+ return this.queueTerminalStartupInput(terminalSessionId, { data }) ? "pending" : "rejected";
105358
+ }
105359
+ if (signalByte === void 0) {
105360
+ const route = this.kernelTerminalInputRoute(terminalSessionId, terminal);
105361
+ if (route === "pending") {
105362
+ return this.queueTerminalStartupInput(terminalSessionId, { data }) ? "pending" : "rejected";
105363
+ }
105364
+ if (route === "legacy") return "legacy";
105242
105365
  }
105243
105366
  if (signalByte !== void 0) {
105244
105367
  const signal = signalByte === 3 ? "SIGINT" : "SIGQUIT";
@@ -105268,8 +105391,16 @@ var init_runtime_project_workspace = __esm({
105268
105391
  const terminal = terminalId === void 0 ? void 0 : authority?.session.terminalSnapshots().find(
105269
105392
  (candidate) => candidate.id === terminalId
105270
105393
  );
105271
- if (!authority || !terminal || terminal.closed) return "rejected";
105272
- if (this.kernelTerminalInputRoute(terminal) === "legacy") return "legacy";
105394
+ if (!authority || !terminal || terminal.closed) {
105395
+ this.queueTerminalStartupInput(terminalSessionId, { eof: true });
105396
+ return "pending";
105397
+ }
105398
+ const route = this.kernelTerminalInputRoute(terminalSessionId, terminal);
105399
+ if (route === "pending") {
105400
+ this.queueTerminalStartupInput(terminalSessionId, { eof: true });
105401
+ return "pending";
105402
+ }
105403
+ if (route === "legacy") return "legacy";
105273
105404
  runFork2(
105274
105405
  authority.session.sendTerminalInputEof(terminal.id).pipe(
105275
105406
  catchAll2(() => _void)
@@ -106423,6 +106554,10 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
106423
106554
  executionHandle.signalChannel?.close();
106424
106555
  this.processState.executionHandles.delete(process3.pid);
106425
106556
  if (options.terminalSessionId && this.processState.terminalForeground.get(options.terminalSessionId) === process3.pid) {
106557
+ this.discardPendingTerminalStartupInput(
106558
+ options.terminalSessionId,
106559
+ process3.pid
106560
+ );
106426
106561
  this.processState.terminalForeground.delete(options.terminalSessionId);
106427
106562
  }
106428
106563
  clearKernelSignalHandler();
@@ -106677,6 +106812,10 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
106677
106812
  executionHandle.signalChannel?.close();
106678
106813
  this.processState.executionHandles.delete(process3.pid);
106679
106814
  if (options.terminalSessionId && this.processState.terminalForeground.get(options.terminalSessionId) === process3.pid) {
106815
+ this.discardPendingTerminalStartupInput(
106816
+ options.terminalSessionId,
106817
+ process3.pid
106818
+ );
106680
106819
  this.processState.terminalForeground.delete(options.terminalSessionId);
106681
106820
  }
106682
106821
  this.observeKernelReparentedChildren(process3.pid);
@@ -106983,6 +107122,7 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
106983
107122
  const shellPromise = this.terminalShells.get(terminalSessionId);
106984
107123
  this.terminalShells.delete(terminalSessionId);
106985
107124
  this.terminalResourceIds.delete(terminalSessionId);
107125
+ this.pendingTerminalStartupInput.delete(terminalSessionId);
106986
107126
  if (!shellPromise) return;
106987
107127
  const disposal = shellPromise.then(async (shell) => {
106988
107128
  const authority = this.traceKernelAuthority;
@@ -107037,7 +107177,8 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
107037
107177
  signalForeground: (signal) => this.signalTerminalForeground(terminalSessionId, signal),
107038
107178
  terminalInputRouter: {
107039
107179
  write: (data) => this.writeKernelTerminalInput(terminalSessionId, data),
107040
- end: () => this.endKernelTerminalInput(terminalSessionId)
107180
+ end: () => this.endKernelTerminalInput(terminalSessionId),
107181
+ reset: () => this.discardPendingTerminalStartupInput(terminalSessionId)
107041
107182
  },
107042
107183
  resizeTerminal: (columns, rows) => this.resizeKernelTerminal(terminalSessionId, columns, rows),
107043
107184
  closeTerminal: () => this.closeTerminalShell(terminalSessionId),
@@ -107151,13 +107292,14 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
107151
107292
  const descriptorStdio = this.cppRunner.capabilities?.descriptorStdio === true;
107152
107293
  if (executionHandle) {
107153
107294
  executionHandle.descriptorStdio = descriptorStdio;
107295
+ executionHandle.consumesLiveStdin = true;
107154
107296
  }
107155
107297
  if (descriptorStdio) {
107156
107298
  this.startHostStandardInputPump(request.commandContext);
107157
107299
  }
107158
107300
  let result;
107159
107301
  try {
107160
- result = await this.cppRunner({
107302
+ const execution = this.cppRunner({
107161
107303
  code: "",
107162
107304
  source: "run",
107163
107305
  scriptPath,
@@ -107182,6 +107324,12 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
107182
107324
  this.handleRuntimeCommandEvent(event, request.commandContext);
107183
107325
  }
107184
107326
  });
107327
+ await this.resolvePendingTerminalStartupInput(
107328
+ request.commandContext.process.pid,
107329
+ descriptorStdio,
107330
+ request.stdinPipe
107331
+ );
107332
+ result = await execution;
107185
107333
  } finally {
107186
107334
  kernelSyscalls?.close();
107187
107335
  }
@@ -123543,6 +123691,13 @@ function normalizeBaseUrl(value) {
123543
123691
  const baseUrl = value ?? resolveBuiltInTraceJVMRuntimeAssetBaseUrl();
123544
123692
  return normalizeTraceJVMRuntimeAssetBaseUrl(baseUrl);
123545
123693
  }
123694
+ function normalizeWorkerUrl2(value) {
123695
+ const workerUrl = value.trim();
123696
+ if (!workerUrl) {
123697
+ throw new TypeError("TraceJVM project Worker URL cannot be empty");
123698
+ }
123699
+ return workerUrl;
123700
+ }
123546
123701
  function createWorker(workerUrl, role) {
123547
123702
  return new Worker(workerUrl, {
123548
123703
  type: "module",
@@ -123551,7 +123706,9 @@ function createWorker(workerUrl, role) {
123551
123706
  }
123552
123707
  function createJavaProjectClientFactory(options = {}) {
123553
123708
  const runtimeAssetBaseUrl = normalizeBaseUrl(options.runtimeAssetBaseUrl);
123554
- const workerUrl = `${runtimeAssetBaseUrl}/browser-worker.js`;
123709
+ const workerUrl = normalizeWorkerUrl2(
123710
+ options.workerUrl ?? `${runtimeAssetBaseUrl}/browser-worker.js`
123711
+ );
123555
123712
  const workerFor = (role) => options.createWorker?.(workerUrl, role) ?? createWorker(workerUrl, role);
123556
123713
  const runtimeProfile = options.runtimeProfile ?? "spring-server";
123557
123714
  const runtimeProfileBaseUrls = {
@@ -140748,6 +140905,7 @@ async function createBrowserProjectWorkspace(options = {}) {
140748
140905
  runtimeProviders: _runtimeProviders,
140749
140906
  java,
140750
140907
  javaRuntimeAssetBaseUrl,
140908
+ javaProjectWorkerUrl,
140751
140909
  executionHost: executionHostOptions,
140752
140910
  nodeProject,
140753
140911
  typescriptProject,
@@ -140915,7 +141073,8 @@ async function createBrowserProjectWorkspace(options = {}) {
140915
141073
  const builtInJavaFactory = hasProvider("java") && !java && !injectedJavaProvider && builtInJavaAvailable && javaProvider ? javaProvider[2].createJavaProjectClientFactory({
140916
141074
  runtimeAssetBaseUrl: javaRuntimeAssetBaseUrl ?? javaProvider[2].resolveBuiltInTraceJVMRuntimeAssetBaseUrl(
140917
141075
  options.assetBaseUrl ?? "/workers"
140918
- )
141076
+ ),
141077
+ workerUrl: javaProjectWorkerUrl ?? `${javaProvider[2].resolveBuiltInTraceJVMRuntimeAssetBaseUrl()}/browser-worker.js`
140919
141078
  }) : void 0;
140920
141079
  if (builtInJavaFactory) ownedWorkers.push(builtInJavaFactory);
140921
141080
  const builtInJava = builtInJavaFactory ? {
package/dist/judge.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as Effect from 'effect/Effect';
2
2
  import * as Scope from 'effect/Scope';
3
3
  import { L as Language, R as RuntimeExecutionStyle, h as RuntimeExecutionLimits, T as TraceExecutionOptions } from './runtime-capabilities-lLyT-B7D.cjs';
4
- import { N as CreateBrowserProjectWorkspaceOptions, l as BrowserRuntimeAssets, o as BrowserRuntimeEnvironment, v as BrowserRuntimeReadiness, q as BrowserRuntimeEnvironmentReport, k as BrowserRuntimeAssetOverrides, n as BrowserRuntimeEngine, r as BrowserRuntimeFeatureSupport } from './runtime-environment-D7mZm8SA.cjs';
4
+ import { N as CreateBrowserProjectWorkspaceOptions, l as BrowserRuntimeAssets, o as BrowserRuntimeEnvironment, v as BrowserRuntimeReadiness, q as BrowserRuntimeEnvironmentReport, k as BrowserRuntimeAssetOverrides, n as BrowserRuntimeEngine, r as BrowserRuntimeFeatureSupport } from './runtime-environment-BO5I1fAC.cjs';
5
5
  import { B as BrowserExecutionWorkerHostOptions } from './execution-host-BtriY0VV.cjs';
6
6
  import * as effect_Cause from 'effect/Cause';
7
7
  import * as effect_Types from 'effect/Types';
package/dist/judge.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as Effect from 'effect/Effect';
2
2
  import * as Scope from 'effect/Scope';
3
3
  import { L as Language, R as RuntimeExecutionStyle, h as RuntimeExecutionLimits, T as TraceExecutionOptions } from './runtime-capabilities-lLyT-B7D.js';
4
- import { N as CreateBrowserProjectWorkspaceOptions, l as BrowserRuntimeAssets, o as BrowserRuntimeEnvironment, v as BrowserRuntimeReadiness, q as BrowserRuntimeEnvironmentReport, k as BrowserRuntimeAssetOverrides, n as BrowserRuntimeEngine, r as BrowserRuntimeFeatureSupport } from './runtime-environment-Q60S0pUa.js';
4
+ import { N as CreateBrowserProjectWorkspaceOptions, l as BrowserRuntimeAssets, o as BrowserRuntimeEnvironment, v as BrowserRuntimeReadiness, q as BrowserRuntimeEnvironmentReport, k as BrowserRuntimeAssetOverrides, n as BrowserRuntimeEngine, r as BrowserRuntimeFeatureSupport } from './runtime-environment-Dfg6ZoCj.js';
5
5
  import { B as BrowserExecutionWorkerHostOptions } from './execution-host-BtriY0VV.js';
6
6
  import * as effect_Cause from 'effect/Cause';
7
7
  import * as effect_Types from 'effect/Types';
package/dist/judge.js CHANGED
@@ -1,8 +1,8 @@
1
1
  var define = undefined;
2
2
  import {
3
3
  createCppBrowserRuntimeProvider
4
- } from "./chunk-MJOC6WVB.js";
5
- import "./chunk-K4424WAS.js";
4
+ } from "./chunk-RCOPAMVR.js";
5
+ import "./chunk-AAKNIYV6.js";
6
6
  import {
7
7
  normalizeTraceJVMRuntimeAssetBaseUrl,
8
8
  preflightBuiltInTraceJVMRuntimeAssets,
@@ -10,20 +10,20 @@ import {
10
10
  } from "./chunk-FYDQ4ZKL.js";
11
11
  import {
12
12
  CSharpWorkerClient
13
- } from "./chunk-J54PE2JS.js";
13
+ } from "./chunk-6LE4KEMZ.js";
14
14
  import {
15
15
  PYTHON_RUNTIME_IMAGE_PROTOCOL_VERSION,
16
16
  createBrowserProjectWorkspace,
17
17
  createBrowserRuntimeAssetPreflight,
18
18
  createBrowserRuntimeEnvironment,
19
19
  makeTraceKernelHost
20
- } from "./chunk-5SU2JQGI.js";
20
+ } from "./chunk-5RT5IT4I.js";
21
21
  import {
22
22
  resolveBuiltInTraceCCRuntimeManifest
23
23
  } from "./chunk-EJE2EJDI.js";
24
24
  import {
25
25
  PythonWorkerClient
26
- } from "./chunk-HK62URW2.js";
26
+ } from "./chunk-M7SNEZDR.js";
27
27
  import {
28
28
  RUNTIME_TRACE_SCHEMA_VERSION,
29
29
  createEmptyRuntimeTrace,
@@ -32,7 +32,7 @@ import {
32
32
  liftCodeOutcome,
33
33
  liftTraceOutcome,
34
34
  runtimeWorkspaceActorPreset
35
- } from "./chunk-DGXNINFR.js";
35
+ } from "./chunk-Y72C46GE.js";
36
36
  import {
37
37
  TraceKernelControlledRuntime,
38
38
  TraceKernelSharedSyscallServer,
@@ -2,7 +2,7 @@ var define = undefined;
2
2
  import {
3
3
  runRuntimeProjectWorkerBridge,
4
4
  withRuntimeProjectCommandRunnerCapabilities
5
- } from "./chunk-DGXNINFR.js";
5
+ } from "./chunk-Y72C46GE.js";
6
6
  import "./chunk-756Z7C6D.js";
7
7
 
8
8
  // packages/runtime-cpp/src/project-browser.ts
@@ -32,4 +32,4 @@ function createBrowserCppProjectRunner(workerClient, options = {}) {
32
32
  export {
33
33
  createBrowserCppProjectRunner
34
34
  };
35
- //# sourceMappingURL=project-browser-UALCR5KR.js.map
35
+ //# sourceMappingURL=project-browser-3S2FWEAP.js.map
@@ -3,7 +3,7 @@ import {
3
3
  createRuntimeProjectIoBridge,
4
4
  runRuntimeProjectWorkerBridge,
5
5
  withRuntimeProjectCommandRunnerCapabilities
6
- } from "./chunk-DGXNINFR.js";
6
+ } from "./chunk-Y72C46GE.js";
7
7
  import "./chunk-756Z7C6D.js";
8
8
 
9
9
  // packages/runtime-csharp/src/project-browser.ts
@@ -79,4 +79,4 @@ function createBrowserCSharpProjectRunner(workerClient, options = {}) {
79
79
  export {
80
80
  createBrowserCSharpProjectRunner
81
81
  };
82
- //# sourceMappingURL=project-browser-EIQ2FOXP.js.map
82
+ //# sourceMappingURL=project-browser-HCQCXAYC.js.map
@@ -53,7 +53,7 @@ import {
53
53
  runtimeKernelWriteFsErrorMessage,
54
54
  runtimeKernelWriteTarget,
55
55
  runtimeProjectInfrastructureFailure
56
- } from "./chunk-DGXNINFR.js";
56
+ } from "./chunk-Y72C46GE.js";
57
57
  import {
58
58
  decodeTraceKernelWatchEvent
59
59
  } from "./chunk-LTRAP6OY.js";
@@ -10865,4 +10865,4 @@ export {
10865
10865
  createBrowserTypeScriptProjectRunner,
10866
10866
  runBrowserJavaScriptProjectRequest
10867
10867
  };
10868
- //# sourceMappingURL=project-browser-V3W4CQAQ.js.map
10868
+ //# sourceMappingURL=project-browser-QN7YOJQQ.js.map
@@ -2,7 +2,7 @@ var define = undefined;
2
2
  import {
3
3
  runRuntimeProjectWorkerBridge,
4
4
  withRuntimeProjectCommandRunnerCapabilities
5
- } from "./chunk-DGXNINFR.js";
5
+ } from "./chunk-Y72C46GE.js";
6
6
  import "./chunk-756Z7C6D.js";
7
7
 
8
8
  // packages/runtime-python/src/project-browser.ts
@@ -35,4 +35,4 @@ function createBrowserPythonProjectRunner(workerClient, options = {}) {
35
35
  export {
36
36
  createBrowserPythonProjectRunner
37
37
  };
38
- //# sourceMappingURL=project-browser-JR2WG7DG.js.map
38
+ //# sourceMappingURL=project-browser-S4KLCZV7.js.map
@@ -3,7 +3,7 @@ import {
3
3
  createRuntimeProjectIoBridge,
4
4
  runRuntimeProjectWorkerBridge,
5
5
  withRuntimeProjectCommandRunnerCapabilities
6
- } from "./chunk-DGXNINFR.js";
6
+ } from "./chunk-Y72C46GE.js";
7
7
  import "./chunk-756Z7C6D.js";
8
8
 
9
9
  // packages/runtime-java/src/project-browser.ts
@@ -77,4 +77,4 @@ function createBrowserJavaProjectRunner(workerClient, options = {}) {
77
77
  export {
78
78
  createBrowserJavaProjectRunner
79
79
  };
80
- //# sourceMappingURL=project-browser-T3EIQCMD.js.map
80
+ //# sourceMappingURL=project-browser-WDUWUGLZ.js.map