@tracecode/harness 0.16.2 → 0.16.3

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 (42) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/{browser-runtime-provider-45ND6W3K.js → browser-runtime-provider-C53ZJH3D.js} +4 -4
  3. package/dist/{chunk-HK62URW2.js → chunk-53ROKKGU.js} +2 -2
  4. package/dist/{chunk-J54PE2JS.js → chunk-6SWX35P2.js} +2 -2
  5. package/dist/{chunk-DGXNINFR.js → chunk-BXUGUGWL.js} +9 -9
  6. package/dist/{chunk-K4424WAS.js → chunk-DI7WIHES.js} +3 -3
  7. package/dist/{chunk-5SU2JQGI.js → chunk-TXDHVV6B.js} +16 -14
  8. package/dist/{chunk-MJOC6WVB.js → chunk-YID2AAYD.js} +2 -2
  9. package/dist/cli.js +0 -0
  10. package/dist/core.cjs +8 -8
  11. package/dist/core.d.cts +2 -2
  12. package/dist/core.d.ts +2 -2
  13. package/dist/core.js +1 -1
  14. package/dist/{cpp-worker-client-I6CPM7TA.js → cpp-worker-client-FLJ2YLSW.js} +3 -3
  15. package/dist/{csharp-worker-client-X7R4VXF4.js → csharp-worker-client-S4U6MCVF.js} +3 -3
  16. package/dist/internal/tracekernel-workspace.cjs +171 -31
  17. package/dist/internal/tracekernel-workspace.d.cts +8 -2
  18. package/dist/internal/tracekernel-workspace.d.ts +8 -2
  19. package/dist/internal/tracekernel-workspace.js +164 -24
  20. package/dist/{java-project-MLWER3CQ.js → java-project-GK6MHT3I.js} +2 -2
  21. package/dist/{java-project-client-R7CKC72F.js → java-project-client-PEQKFTH6.js} +11 -2
  22. package/dist/judge.cjs +186 -35
  23. package/dist/judge.d.cts +1 -1
  24. package/dist/judge.d.ts +1 -1
  25. package/dist/judge.js +6 -6
  26. package/dist/{project-browser-UALCR5KR.js → project-browser-3I5FVB5N.js} +2 -2
  27. package/dist/{project-browser-EIQ2FOXP.js → project-browser-ADXGG5RZ.js} +2 -2
  28. package/dist/{project-browser-JR2WG7DG.js → project-browser-B5T7WJWP.js} +2 -2
  29. package/dist/{project-browser-V3W4CQAQ.js → project-browser-JXJ74RDZ.js} +2 -2
  30. package/dist/{project-browser-T3EIQCMD.js → project-browser-TDL4LMJJ.js} +2 -2
  31. package/dist/{python-worker-client-MRWQTXOF.js → python-worker-client-2RF6IYIN.js} +3 -3
  32. package/dist/{runtime-environment-D7mZm8SA.d.cts → runtime-environment-BO5I1fAC.d.cts} +5 -0
  33. package/dist/{runtime-environment-Q60S0pUa.d.ts → runtime-environment-Dfg6ZoCj.d.ts} +5 -0
  34. package/dist/{runtime-open-source-info-BQtIRJ9F.d.cts → runtime-open-source-info-CaBpNicy.d.cts} +4 -2
  35. package/dist/{runtime-open-source-info-FkIxlAcm.d.ts → runtime-open-source-info-D0OJc4zH.d.ts} +4 -2
  36. package/dist/tracekernel.cjs +351 -60
  37. package/dist/tracekernel.d.cts +4 -4
  38. package/dist/tracekernel.d.ts +4 -4
  39. package/dist/tracekernel.js +166 -26
  40. package/package.json +44 -32
  41. package/runtime-assets.lock.json +7 -7
  42. 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.3"
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.3"
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.3"
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.3"
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.3"
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.3"
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.3/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.3",
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,
@@ -95271,20 +95271,27 @@ var init_terminal_session = __esm({
95271
95271
  signalCharacter === "" ? "SIGINT" : "SIGQUIT"
95272
95272
  );
95273
95273
  }
95274
- const route = this.options.terminalInputRouter?.write(data) ?? (this.activeStdinPipe !== null ? "legacy" : "rejected");
95274
+ const routed = this.options.terminalInputRouter?.write(data);
95275
+ const route = routed === "rejected" && this.activeStdinPipe !== null ? "legacy" : routed ?? (this.activeStdinPipe !== null ? "legacy" : "rejected");
95275
95276
  if (route === "legacy") {
95276
- this.activeStdinPipe?.write(data);
95277
+ if (!this.activeStdinPipe) return false;
95278
+ try {
95279
+ this.activeStdinPipe.write(data);
95280
+ } catch {
95281
+ return false;
95282
+ }
95277
95283
  }
95278
95284
  const accepted = route !== "rejected";
95279
95285
  if (accepted && this.currentInputState.mode === "stdin") {
95280
95286
  this.activeStdinPrompt = "";
95281
- this.setInputState("busy", "stdin-submit");
95287
+ this.setInputState("stdin", "stdin-submit", "");
95282
95288
  }
95283
95289
  return accepted;
95284
95290
  }
95285
95291
  endStdin() {
95286
95292
  if (!this.activeRun || this.activeStdinEnded) return false;
95287
- const route = this.options.terminalInputRouter?.end() ?? (this.activeStdinPipe !== null ? "legacy" : "rejected");
95293
+ const routed = this.options.terminalInputRouter?.end();
95294
+ const route = routed === "rejected" && this.activeStdinPipe !== null ? "legacy" : routed ?? (this.activeStdinPipe !== null ? "legacy" : "rejected");
95288
95295
  if (route === "rejected") return false;
95289
95296
  this.activeStdinEnded = true;
95290
95297
  if (route === "legacy") {
@@ -95323,6 +95330,14 @@ var init_terminal_session = __esm({
95323
95330
  this.emitTerminalEvent(reason);
95324
95331
  return this.currentInputState;
95325
95332
  }
95333
+ showForegroundInputLine() {
95334
+ const acceptsInput = this.activeStdinPipe !== null || this.options.terminalInputRouter !== void 0;
95335
+ return this.setInputState(
95336
+ acceptsInput ? "stdin" : "busy",
95337
+ "command-start",
95338
+ acceptsInput ? "" : this.prompt.text
95339
+ );
95340
+ }
95326
95341
  async run(command, options = {}) {
95327
95342
  const trimmed = command.trim();
95328
95343
  if (!trimmed) return { stdout: "", stderr: "", exitCode: 0 };
@@ -95377,7 +95392,7 @@ var init_terminal_session = __esm({
95377
95392
  this.activeTerminalEventHandler = options.onTerminalEvent;
95378
95393
  this.activeStdinPrompt = "";
95379
95394
  this.activeCommand = submittedCommand;
95380
- this.setInputState("busy", "command-start");
95395
+ this.showForegroundInputLine();
95381
95396
  try {
95382
95397
  let stdout = "";
95383
95398
  let stderr = "";
@@ -95406,6 +95421,7 @@ var init_terminal_session = __esm({
95406
95421
  ...error ? { error } : {}
95407
95422
  };
95408
95423
  } finally {
95424
+ this.options.terminalInputRouter?.reset();
95409
95425
  ownedStdinPipe?.close();
95410
95426
  this.activeStdinPipe = previousStdinPipe;
95411
95427
  this.activeStdinEnded = previousStdinEnded;
@@ -95444,7 +95460,7 @@ var init_terminal_session = __esm({
95444
95460
  this.activeStdinPrompt = "";
95445
95461
  this.activeCommand = trimmed;
95446
95462
  this.activeCommandAbortController = commandAbortController;
95447
- this.setInputState("busy", "command-start");
95463
+ this.showForegroundInputLine();
95448
95464
  try {
95449
95465
  const result = await this.runForegroundTerminalCommand(
95450
95466
  trimmed,
@@ -95455,6 +95471,7 @@ var init_terminal_session = __esm({
95455
95471
  return result;
95456
95472
  } finally {
95457
95473
  options.signal?.removeEventListener("abort", forwardExternalAbort);
95474
+ this.options.terminalInputRouter?.reset();
95458
95475
  ownedStdinPipe?.close();
95459
95476
  this.activeStdinPipe = previousStdinPipe;
95460
95477
  this.activeStdinEnded = previousStdinEnded;
@@ -101289,21 +101306,26 @@ function createWorkspaceRuntimeRunnerBridge(bridge) {
101289
101306
  ...requestWithoutLegacyStdin
101290
101307
  } = request;
101291
101308
  const activeStdinPipe = request.source !== "compile" && request.source !== "stdin" ? commandContext?.stdinPipe : void 0;
101309
+ const consumesLiveStdin = request.source !== "compile" && request.source !== "stdin";
101292
101310
  const stdinPipe = request.stdinPipe ?? activeStdinPipe;
101293
- const processBinding = commandContext ? bridge.bindProcess(commandContext, descriptorStdio) : {};
101311
+ const processBinding = commandContext ? bridge.bindProcess(
101312
+ commandContext,
101313
+ descriptorStdio,
101314
+ consumesLiveStdin
101315
+ ) : {};
101294
101316
  const signal = processBinding.signal ?? request.signal;
101295
101317
  const runtimeIo = commandContext?.runtimeIo;
101296
101318
  let acceptingRunnerEvents = true;
101297
101319
  let result;
101298
101320
  const kernelSyscalls = options.kernelSyscalls ? bridge.createKernelSyscallBridge(commandContext) : void 0;
101299
- if (descriptorStdio && commandContext) {
101321
+ if (descriptorStdio && commandContext && consumesLiveStdin) {
101300
101322
  bridge.startHostStandardInputPump(commandContext);
101301
101323
  }
101302
101324
  try {
101303
- result = await runner({
101304
- ...descriptorStdio ? requestWithoutLegacyStdin : request,
101325
+ const execution = runner({
101326
+ ...descriptorStdio || !consumesLiveStdin ? requestWithoutLegacyStdin : request,
101305
101327
  ...processBinding.process ? { process: processBinding.process } : {},
101306
- ...stdinPipe && !descriptorStdio ? { stdinPipe: { buffer: stdinPipe.buffer } } : {},
101328
+ ...stdinPipe && !descriptorStdio && consumesLiveStdin ? { stdinPipe: { buffer: stdinPipe.buffer } } : {},
101307
101329
  ...commandContext?.terminal ? { terminal: commandContext.terminal } : {},
101308
101330
  ...commandContext?.engineLease ? { engineLease: commandContext.engineLease } : {},
101309
101331
  ...signal ? { signal } : {},
@@ -101315,6 +101337,8 @@ function createWorkspaceRuntimeRunnerBridge(bridge) {
101315
101337
  bridge.handleRuntimeCommandEvent(event, commandContext);
101316
101338
  }
101317
101339
  });
101340
+ await processBinding.replayStartupInput?.();
101341
+ result = await execution;
101318
101342
  } finally {
101319
101343
  acceptingRunnerEvents = false;
101320
101344
  kernelSyscalls?.close();
@@ -102358,7 +102382,7 @@ async function createRuntimeWorkspace(options = {}) {
102358
102382
  }
102359
102383
  return workspace;
102360
102384
  }
102361
- var PRINCIPAL_ACTOR2, RUNTIME_ACTOR, SYSTEM_ACTOR2, TRACEKERNEL_SYSCALL_ERROR_CODES, TRACEKERNEL_ZOMBIE_RETENTION_MS, RuntimeProjectWorkspace;
102385
+ var PRINCIPAL_ACTOR2, RUNTIME_ACTOR, SYSTEM_ACTOR2, TERMINAL_STARTUP_INPUT_MAX_BYTES, TRACEKERNEL_SYSCALL_ERROR_CODES, TRACEKERNEL_ZOMBIE_RETENTION_MS, RuntimeProjectWorkspace;
102362
102386
  var init_runtime_project_workspace = __esm({
102363
102387
  "packages/tracekernel/src/workspace/runtime-project-workspace.ts"() {
102364
102388
  "use strict";
@@ -102408,6 +102432,7 @@ var init_runtime_project_workspace = __esm({
102408
102432
  PRINCIPAL_ACTOR2 = runtimeWorkspaceActorPreset("principal");
102409
102433
  RUNTIME_ACTOR = runtimeWorkspaceActorPreset("runtime");
102410
102434
  SYSTEM_ACTOR2 = runtimeWorkspaceActorPreset("system");
102435
+ TERMINAL_STARTUP_INPUT_MAX_BYTES = 64 * 1024 - 1;
102411
102436
  TRACEKERNEL_SYSCALL_ERROR_CODES = /* @__PURE__ */ new Set([
102412
102437
  "E2BIG",
102413
102438
  "EAGAIN",
@@ -102482,6 +102507,7 @@ var init_runtime_project_workspace = __esm({
102482
102507
  processState = new WorkspaceProcessState();
102483
102508
  terminalShells = /* @__PURE__ */ new Map();
102484
102509
  terminalResourceIds = /* @__PURE__ */ new Map();
102510
+ pendingTerminalStartupInput = /* @__PURE__ */ new Map();
102485
102511
  processProjection;
102486
102512
  // Temporary 0.13 introspection aliases. The process state module remains
102487
102513
  // authoritative; these preserve existing hardening probes while 0.14 moves
@@ -102663,17 +102689,24 @@ var init_runtime_project_workspace = __esm({
102663
102689
  });
102664
102690
  const withEvents = createWorkspaceRuntimeRunnerBridge({
102665
102691
  resolveCommandContext: (context2) => this.resolveCommandContext(context2),
102666
- bindProcess: (context2, descriptorStdio) => {
102692
+ bindProcess: (context2, descriptorStdio, consumesLiveStdin) => {
102667
102693
  const executionHandle = this.processProjection.executionHandle(
102668
102694
  context2.process
102669
102695
  );
102670
102696
  if (executionHandle) {
102671
102697
  executionHandle.descriptorStdio = descriptorStdio;
102698
+ executionHandle.consumesLiveStdin = consumesLiveStdin;
102672
102699
  }
102673
102700
  const processSnapshot = this.processProjection.authoritativeSnapshot(
102674
102701
  context2.process
102675
102702
  );
102676
102703
  return {
102704
+ replayStartupInput: () => this.resolvePendingTerminalStartupInput(
102705
+ context2.process.pid,
102706
+ descriptorStdio,
102707
+ context2.stdinPipe,
102708
+ consumesLiveStdin
102709
+ ),
102677
102710
  ...executionHandle?.abortController?.signal ? { signal: executionHandle.abortController.signal } : {},
102678
102711
  ...executionHandle?.signalChannel ? { kernelSignals: executionHandle.signalChannel } : {},
102679
102712
  ...processSnapshot ? {
@@ -105221,24 +105254,106 @@ var init_runtime_project_workspace = __esm({
105221
105254
  )
105222
105255
  );
105223
105256
  }
105224
- kernelTerminalInputRoute(terminal) {
105257
+ kernelTerminalInputRoute(terminalSessionId, terminal) {
105225
105258
  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
105259
+ (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
105260
  ) === true;
105228
- return hasDescriptorConsumer ? "kernel" : "legacy";
105261
+ if (hasDescriptorConsumer) return "kernel";
105262
+ const foregroundPid = this.processState.terminalForeground.get(
105263
+ terminalSessionId
105264
+ );
105265
+ if (foregroundPid === void 0) return "pending";
105266
+ const executionHandle = this.processState.executionHandles.get(foregroundPid);
105267
+ if (executionHandle?.consumesLiveStdin !== true) return "pending";
105268
+ const descriptorStdio = executionHandle.descriptorStdio;
105269
+ return descriptorStdio === void 0 ? "pending" : descriptorStdio ? "kernel" : "legacy";
105270
+ }
105271
+ queueTerminalStartupInput(terminalSessionId, input = {}) {
105272
+ const pending2 = this.pendingTerminalStartupInput.get(terminalSessionId) ?? {
105273
+ chunks: [],
105274
+ byteLength: 0,
105275
+ eof: false
105276
+ };
105277
+ if (input.data) {
105278
+ const byteLength = new TextEncoder().encode(input.data).byteLength;
105279
+ if (pending2.byteLength + byteLength > TERMINAL_STARTUP_INPUT_MAX_BYTES) {
105280
+ return false;
105281
+ }
105282
+ pending2.chunks.push(input.data);
105283
+ pending2.byteLength += byteLength;
105284
+ }
105285
+ if (input.eof) pending2.eof = true;
105286
+ this.pendingTerminalStartupInput.set(terminalSessionId, pending2);
105287
+ return true;
105229
105288
  }
105230
- writeKernelTerminalInput(terminalSessionId, data) {
105289
+ async resolvePendingTerminalStartupInput(foregroundPid, descriptorStdio, stdinPipe, consumesLiveStdin = true) {
105290
+ const boundProcess = this.processProjection.find(foregroundPid);
105291
+ const boundSnapshot = boundProcess ? this.processProjection.authoritativeSnapshot(boundProcess) : void 0;
105292
+ const terminalSessionId = [...this.processState.terminalForeground].find(([, pid]) => {
105293
+ if (pid === foregroundPid) return true;
105294
+ const terminalProcess = this.processProjection.find(pid);
105295
+ const terminalSnapshot = terminalProcess ? this.processProjection.authoritativeSnapshot(terminalProcess) : void 0;
105296
+ return Boolean(
105297
+ boundSnapshot && terminalSnapshot && boundSnapshot.pgid === terminalSnapshot.pgid
105298
+ );
105299
+ })?.[0];
105300
+ if (!terminalSessionId) return;
105301
+ const pending2 = this.pendingTerminalStartupInput.get(terminalSessionId);
105302
+ if (!pending2) return;
105303
+ if (!consumesLiveStdin) return;
105304
+ this.pendingTerminalStartupInput.delete(terminalSessionId);
105305
+ if (!descriptorStdio) {
105306
+ if (!stdinPipe) return;
105307
+ try {
105308
+ for (const chunk2 of pending2.chunks) stdinPipe.write(chunk2);
105309
+ if (pending2.eof) stdinPipe.close();
105310
+ } catch {
105311
+ stdinPipe.close();
105312
+ }
105313
+ return;
105314
+ }
105231
105315
  const authority = this.traceKernelAuthority;
105232
105316
  const terminalId = this.terminalResourceIds.get(terminalSessionId);
105233
105317
  const terminal = terminalId === void 0 ? void 0 : authority?.session.terminalSnapshots().find(
105234
105318
  (candidate) => candidate.id === terminalId
105235
105319
  );
105236
- if (!authority || !terminal || terminal.closed) return "rejected";
105320
+ if (!authority || !terminal || terminal.closed) return;
105321
+ const bytes2 = new TextEncoder().encode(pending2.chunks.join(""));
105322
+ await runPromise(
105323
+ gen2(function* () {
105324
+ if (bytes2.byteLength > 0) {
105325
+ yield* authority.session.writeTerminalInput(terminal.id, bytes2);
105326
+ }
105327
+ if (pending2.eof) {
105328
+ yield* authority.session.sendTerminalInputEof(terminal.id);
105329
+ }
105330
+ }).pipe(catchAll2(() => _void))
105331
+ );
105332
+ }
105333
+ discardPendingTerminalStartupInput(terminalSessionId, foregroundPid) {
105334
+ if (terminalSessionId && (foregroundPid === void 0 || this.processState.terminalForeground.get(terminalSessionId) === foregroundPid)) {
105335
+ this.pendingTerminalStartupInput.delete(terminalSessionId);
105336
+ }
105337
+ }
105338
+ writeKernelTerminalInput(terminalSessionId, data) {
105237
105339
  const signalByte = new TextEncoder().encode(data).find(
105238
105340
  (byte) => byte === 3 || byte === 28
105239
105341
  );
105240
- if (signalByte === void 0 && this.kernelTerminalInputRoute(terminal) === "legacy") {
105241
- return "legacy";
105342
+ const authority = this.traceKernelAuthority;
105343
+ const terminalId = this.terminalResourceIds.get(terminalSessionId);
105344
+ const terminal = terminalId === void 0 ? void 0 : authority?.session.terminalSnapshots().find(
105345
+ (candidate) => candidate.id === terminalId
105346
+ );
105347
+ if (!authority || !terminal || terminal.closed) {
105348
+ if (signalByte !== void 0) return "rejected";
105349
+ return this.queueTerminalStartupInput(terminalSessionId, { data }) ? "pending" : "rejected";
105350
+ }
105351
+ if (signalByte === void 0) {
105352
+ const route = this.kernelTerminalInputRoute(terminalSessionId, terminal);
105353
+ if (route === "pending") {
105354
+ return this.queueTerminalStartupInput(terminalSessionId, { data }) ? "pending" : "rejected";
105355
+ }
105356
+ if (route === "legacy") return "legacy";
105242
105357
  }
105243
105358
  if (signalByte !== void 0) {
105244
105359
  const signal = signalByte === 3 ? "SIGINT" : "SIGQUIT";
@@ -105268,8 +105383,16 @@ var init_runtime_project_workspace = __esm({
105268
105383
  const terminal = terminalId === void 0 ? void 0 : authority?.session.terminalSnapshots().find(
105269
105384
  (candidate) => candidate.id === terminalId
105270
105385
  );
105271
- if (!authority || !terminal || terminal.closed) return "rejected";
105272
- if (this.kernelTerminalInputRoute(terminal) === "legacy") return "legacy";
105386
+ if (!authority || !terminal || terminal.closed) {
105387
+ this.queueTerminalStartupInput(terminalSessionId, { eof: true });
105388
+ return "pending";
105389
+ }
105390
+ const route = this.kernelTerminalInputRoute(terminalSessionId, terminal);
105391
+ if (route === "pending") {
105392
+ this.queueTerminalStartupInput(terminalSessionId, { eof: true });
105393
+ return "pending";
105394
+ }
105395
+ if (route === "legacy") return "legacy";
105273
105396
  runFork2(
105274
105397
  authority.session.sendTerminalInputEof(terminal.id).pipe(
105275
105398
  catchAll2(() => _void)
@@ -106423,6 +106546,10 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
106423
106546
  executionHandle.signalChannel?.close();
106424
106547
  this.processState.executionHandles.delete(process3.pid);
106425
106548
  if (options.terminalSessionId && this.processState.terminalForeground.get(options.terminalSessionId) === process3.pid) {
106549
+ this.discardPendingTerminalStartupInput(
106550
+ options.terminalSessionId,
106551
+ process3.pid
106552
+ );
106426
106553
  this.processState.terminalForeground.delete(options.terminalSessionId);
106427
106554
  }
106428
106555
  clearKernelSignalHandler();
@@ -106677,6 +106804,10 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
106677
106804
  executionHandle.signalChannel?.close();
106678
106805
  this.processState.executionHandles.delete(process3.pid);
106679
106806
  if (options.terminalSessionId && this.processState.terminalForeground.get(options.terminalSessionId) === process3.pid) {
106807
+ this.discardPendingTerminalStartupInput(
106808
+ options.terminalSessionId,
106809
+ process3.pid
106810
+ );
106680
106811
  this.processState.terminalForeground.delete(options.terminalSessionId);
106681
106812
  }
106682
106813
  this.observeKernelReparentedChildren(process3.pid);
@@ -106983,6 +107114,7 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
106983
107114
  const shellPromise = this.terminalShells.get(terminalSessionId);
106984
107115
  this.terminalShells.delete(terminalSessionId);
106985
107116
  this.terminalResourceIds.delete(terminalSessionId);
107117
+ this.pendingTerminalStartupInput.delete(terminalSessionId);
106986
107118
  if (!shellPromise) return;
106987
107119
  const disposal = shellPromise.then(async (shell) => {
106988
107120
  const authority = this.traceKernelAuthority;
@@ -107037,7 +107169,8 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
107037
107169
  signalForeground: (signal) => this.signalTerminalForeground(terminalSessionId, signal),
107038
107170
  terminalInputRouter: {
107039
107171
  write: (data) => this.writeKernelTerminalInput(terminalSessionId, data),
107040
- end: () => this.endKernelTerminalInput(terminalSessionId)
107172
+ end: () => this.endKernelTerminalInput(terminalSessionId),
107173
+ reset: () => this.discardPendingTerminalStartupInput(terminalSessionId)
107041
107174
  },
107042
107175
  resizeTerminal: (columns, rows) => this.resizeKernelTerminal(terminalSessionId, columns, rows),
107043
107176
  closeTerminal: () => this.closeTerminalShell(terminalSessionId),
@@ -107151,13 +107284,14 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
107151
107284
  const descriptorStdio = this.cppRunner.capabilities?.descriptorStdio === true;
107152
107285
  if (executionHandle) {
107153
107286
  executionHandle.descriptorStdio = descriptorStdio;
107287
+ executionHandle.consumesLiveStdin = true;
107154
107288
  }
107155
107289
  if (descriptorStdio) {
107156
107290
  this.startHostStandardInputPump(request.commandContext);
107157
107291
  }
107158
107292
  let result;
107159
107293
  try {
107160
- result = await this.cppRunner({
107294
+ const execution = this.cppRunner({
107161
107295
  code: "",
107162
107296
  source: "run",
107163
107297
  scriptPath,
@@ -107182,6 +107316,12 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
107182
107316
  this.handleRuntimeCommandEvent(event, request.commandContext);
107183
107317
  }
107184
107318
  });
107319
+ await this.resolvePendingTerminalStartupInput(
107320
+ request.commandContext.process.pid,
107321
+ descriptorStdio,
107322
+ request.stdinPipe
107323
+ );
107324
+ result = await execution;
107185
107325
  } finally {
107186
107326
  kernelSyscalls?.close();
107187
107327
  }
@@ -123543,6 +123683,13 @@ function normalizeBaseUrl(value) {
123543
123683
  const baseUrl = value ?? resolveBuiltInTraceJVMRuntimeAssetBaseUrl();
123544
123684
  return normalizeTraceJVMRuntimeAssetBaseUrl(baseUrl);
123545
123685
  }
123686
+ function normalizeWorkerUrl2(value) {
123687
+ const workerUrl = value.trim();
123688
+ if (!workerUrl) {
123689
+ throw new TypeError("TraceJVM project Worker URL cannot be empty");
123690
+ }
123691
+ return workerUrl;
123692
+ }
123546
123693
  function createWorker(workerUrl, role) {
123547
123694
  return new Worker(workerUrl, {
123548
123695
  type: "module",
@@ -123551,7 +123698,9 @@ function createWorker(workerUrl, role) {
123551
123698
  }
123552
123699
  function createJavaProjectClientFactory(options = {}) {
123553
123700
  const runtimeAssetBaseUrl = normalizeBaseUrl(options.runtimeAssetBaseUrl);
123554
- const workerUrl = `${runtimeAssetBaseUrl}/browser-worker.js`;
123701
+ const workerUrl = normalizeWorkerUrl2(
123702
+ options.workerUrl ?? `${runtimeAssetBaseUrl}/browser-worker.js`
123703
+ );
123555
123704
  const workerFor = (role) => options.createWorker?.(workerUrl, role) ?? createWorker(workerUrl, role);
123556
123705
  const runtimeProfile = options.runtimeProfile ?? "spring-server";
123557
123706
  const runtimeProfileBaseUrls = {
@@ -140748,6 +140897,7 @@ async function createBrowserProjectWorkspace(options = {}) {
140748
140897
  runtimeProviders: _runtimeProviders,
140749
140898
  java,
140750
140899
  javaRuntimeAssetBaseUrl,
140900
+ javaProjectWorkerUrl,
140751
140901
  executionHost: executionHostOptions,
140752
140902
  nodeProject,
140753
140903
  typescriptProject,
@@ -140915,7 +141065,8 @@ async function createBrowserProjectWorkspace(options = {}) {
140915
141065
  const builtInJavaFactory = hasProvider("java") && !java && !injectedJavaProvider && builtInJavaAvailable && javaProvider ? javaProvider[2].createJavaProjectClientFactory({
140916
141066
  runtimeAssetBaseUrl: javaRuntimeAssetBaseUrl ?? javaProvider[2].resolveBuiltInTraceJVMRuntimeAssetBaseUrl(
140917
141067
  options.assetBaseUrl ?? "/workers"
140918
- )
141068
+ ),
141069
+ workerUrl: javaProjectWorkerUrl ?? `${javaProvider[2].resolveBuiltInTraceJVMRuntimeAssetBaseUrl()}/browser-worker.js`
140919
141070
  }) : void 0;
140920
141071
  if (builtInJavaFactory) ownedWorkers.push(builtInJavaFactory);
140921
141072
  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-YID2AAYD.js";
5
+ import "./chunk-DI7WIHES.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-6SWX35P2.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-TXDHVV6B.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-53ROKKGU.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-BXUGUGWL.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-BXUGUGWL.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-3I5FVB5N.js.map
@@ -3,7 +3,7 @@ import {
3
3
  createRuntimeProjectIoBridge,
4
4
  runRuntimeProjectWorkerBridge,
5
5
  withRuntimeProjectCommandRunnerCapabilities
6
- } from "./chunk-DGXNINFR.js";
6
+ } from "./chunk-BXUGUGWL.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-ADXGG5RZ.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-BXUGUGWL.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-B5T7WJWP.js.map
@@ -53,7 +53,7 @@ import {
53
53
  runtimeKernelWriteFsErrorMessage,
54
54
  runtimeKernelWriteTarget,
55
55
  runtimeProjectInfrastructureFailure
56
- } from "./chunk-DGXNINFR.js";
56
+ } from "./chunk-BXUGUGWL.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-JXJ74RDZ.js.map
@@ -3,7 +3,7 @@ import {
3
3
  createRuntimeProjectIoBridge,
4
4
  runRuntimeProjectWorkerBridge,
5
5
  withRuntimeProjectCommandRunnerCapabilities
6
- } from "./chunk-DGXNINFR.js";
6
+ } from "./chunk-BXUGUGWL.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-TDL4LMJJ.js.map
@@ -2,8 +2,8 @@ var define = undefined;
2
2
  import {
3
3
  PythonWorkerClient,
4
4
  isWorkerSupported
5
- } from "./chunk-HK62URW2.js";
6
- import "./chunk-DGXNINFR.js";
5
+ } from "./chunk-53ROKKGU.js";
6
+ import "./chunk-BXUGUGWL.js";
7
7
  import "./chunk-DTLDQQHA.js";
8
8
  import "./chunk-C2RUZCIL.js";
9
9
  import "./chunk-756Z7C6D.js";
@@ -11,4 +11,4 @@ export {
11
11
  PythonWorkerClient,
12
12
  isWorkerSupported
13
13
  };
14
- //# sourceMappingURL=python-worker-client-MRWQTXOF.js.map
14
+ //# sourceMappingURL=python-worker-client-2RF6IYIN.js.map