@tracecode/harness 0.16.1 → 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 (45) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/{browser-runtime-provider-NQNCL6HE.js → browser-runtime-provider-C53ZJH3D.js} +4 -4
  3. package/dist/{chunk-MMQLUTPP.js → chunk-53ROKKGU.js} +2 -2
  4. package/dist/{chunk-KYTMGAFA.js → chunk-6SWX35P2.js} +2 -2
  5. package/dist/{chunk-4W6MUXZE.js → chunk-BXUGUGWL.js} +9 -9
  6. package/dist/{chunk-AWHLLSEH.js → chunk-DI7WIHES.js} +3 -3
  7. package/dist/chunk-EJE2EJDI.js +193 -0
  8. package/dist/{chunk-DQMPICNS.js → chunk-TXDHVV6B.js} +193 -345
  9. package/dist/{chunk-57WKRSIB.js → chunk-YID2AAYD.js} +2 -2
  10. package/dist/cli.cjs +5 -0
  11. package/dist/cli.js +5 -0
  12. package/dist/core.cjs +8 -8
  13. package/dist/core.d.cts +2 -2
  14. package/dist/core.d.ts +2 -2
  15. package/dist/core.js +1 -1
  16. package/dist/{cpp-worker-client-A2ULEW5T.js → cpp-worker-client-FLJ2YLSW.js} +3 -3
  17. package/dist/{csharp-worker-client-RA47P77F.js → csharp-worker-client-S4U6MCVF.js} +3 -3
  18. package/dist/internal/tracekernel-workspace.cjs +171 -31
  19. package/dist/internal/tracekernel-workspace.d.cts +8 -2
  20. package/dist/internal/tracekernel-workspace.d.ts +8 -2
  21. package/dist/internal/tracekernel-workspace.js +164 -24
  22. package/dist/{java-project-BTAANBJH.js → java-project-GK6MHT3I.js} +2 -2
  23. package/dist/{java-project-client-R7CKC72F.js → java-project-client-PEQKFTH6.js} +11 -2
  24. package/dist/judge.cjs +420 -214
  25. package/dist/judge.d.cts +1 -1
  26. package/dist/judge.d.ts +1 -1
  27. package/dist/judge.js +9 -7
  28. package/dist/{project-browser-GBSPIYEW.js → project-browser-3I5FVB5N.js} +2 -2
  29. package/dist/{project-browser-U3YK43H4.js → project-browser-ADXGG5RZ.js} +2 -2
  30. package/dist/{project-browser-J6LVPVDC.js → project-browser-B5T7WJWP.js} +2 -2
  31. package/dist/{project-browser-QMZCUVJA.js → project-browser-JXJ74RDZ.js} +2 -2
  32. package/dist/{project-browser-PC7TRROQ.js → project-browser-TDL4LMJJ.js} +2 -2
  33. package/dist/{python-worker-client-NEBS6V63.js → python-worker-client-2RF6IYIN.js} +3 -3
  34. package/dist/{runtime-environment-D7mZm8SA.d.cts → runtime-environment-BO5I1fAC.d.cts} +5 -0
  35. package/dist/{runtime-environment-Q60S0pUa.d.ts → runtime-environment-Dfg6ZoCj.d.ts} +5 -0
  36. package/dist/{runtime-open-source-info-BQtIRJ9F.d.cts → runtime-open-source-info-CaBpNicy.d.cts} +4 -2
  37. package/dist/{runtime-open-source-info-FkIxlAcm.d.ts → runtime-open-source-info-D0OJc4zH.d.ts} +4 -2
  38. package/dist/tracecc-runtime-assets-G3BFH7LY.js +19 -0
  39. package/dist/tracekernel.cjs +585 -235
  40. package/dist/tracekernel.d.cts +14 -5
  41. package/dist/tracekernel.d.ts +14 -5
  42. package/dist/tracekernel.js +175 -31
  43. package/package.json +44 -32
  44. package/runtime-assets.lock.json +7 -7
  45. package/workers/javascript/javascript-project-worker.js +7 -7
@@ -17081,7 +17081,7 @@ module.exports = __toCommonJS(workspace_exports);
17081
17081
  // package.json
17082
17082
  var package_default = {
17083
17083
  name: "@tracecode/harness",
17084
- version: "0.16.1",
17084
+ version: "0.16.3",
17085
17085
  license: "AGPL-3.0-only",
17086
17086
  homepage: "https://tracecode.app",
17087
17087
  repository: {
@@ -17338,7 +17338,7 @@ var LANGUAGE_RUNTIME_INFOS = Object.freeze(
17338
17338
  "versionLabel": "Python 3.13.2",
17339
17339
  "executionPlatform": {
17340
17340
  "name": "TraceKernel",
17341
- "version": "0.16.1"
17341
+ "version": "0.16.3"
17342
17342
  },
17343
17343
  "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.",
17344
17344
  "runtime": {
@@ -17365,7 +17365,7 @@ var LANGUAGE_RUNTIME_INFOS = Object.freeze(
17365
17365
  "versionLabel": "JavaScript (ECMAScript 2023)",
17366
17366
  "executionPlatform": {
17367
17367
  "name": "TraceKernel",
17368
- "version": "0.16.1"
17368
+ "version": "0.16.3"
17369
17369
  },
17370
17370
  "runtime": {
17371
17371
  "name": "TraceKernel JavaScript runtime",
@@ -17457,7 +17457,7 @@ Binary Search Tree, Trie, and Graph are bundled too, but are not exposed globall
17457
17457
  "versionLabel": "TypeScript 5.9.3",
17458
17458
  "executionPlatform": {
17459
17459
  "name": "TraceKernel",
17460
- "version": "0.16.1"
17460
+ "version": "0.16.3"
17461
17461
  },
17462
17462
  "description": `TypeScript 5.9.3 is compiled with the TypeScript compiler and executed by TraceKernel's JavaScript runtime.
17463
17463
 
@@ -17557,7 +17557,7 @@ The compiled output runs on the same TraceKernel execution lane as JavaScript su
17557
17557
  "versionLabel": "Java 23",
17558
17558
  "executionPlatform": {
17559
17559
  "name": "TraceKernel",
17560
- "version": "0.16.1"
17560
+ "version": "0.16.3"
17561
17561
  },
17562
17562
  "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.",
17563
17563
  "runtime": {
@@ -17594,7 +17594,7 @@ The compiled output runs on the same TraceKernel execution lane as JavaScript su
17594
17594
  "versionLabel": "C# 14",
17595
17595
  "executionPlatform": {
17596
17596
  "name": "TraceKernel",
17597
- "version": "0.16.1"
17597
+ "version": "0.16.3"
17598
17598
  },
17599
17599
  "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.",
17600
17600
  "runtime": {
@@ -17623,7 +17623,7 @@ The compiled output runs on the same TraceKernel execution lane as JavaScript su
17623
17623
  "versionLabel": "C++23",
17624
17624
  "executionPlatform": {
17625
17625
  "name": "TraceKernel",
17626
- "version": "0.16.1"
17626
+ "version": "0.16.3"
17627
17627
  },
17628
17628
  "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.",
17629
17629
  "runtime": {
@@ -17775,7 +17775,7 @@ var LANGUAGE_RUNTIME_OPEN_SOURCE_INFOS = Object.freeze(
17775
17775
  {
17776
17776
  "kind": "modifications",
17777
17777
  "label": "Runtime modifications",
17778
- "url": "https://github.com/tracecodeapp/harness/tree/v0.16.1/workers/python/pyodide-0.29.3"
17778
+ "url": "https://github.com/tracecodeapp/harness/tree/v0.16.3/workers/python/pyodide-0.29.3"
17779
17779
  }
17780
17780
  ]
17781
17781
  }
@@ -87951,20 +87951,27 @@ var RuntimeProjectWorkspaceTerminalSession = class {
87951
87951
  signalCharacter === "" ? "SIGINT" : "SIGQUIT"
87952
87952
  );
87953
87953
  }
87954
- const route = this.options.terminalInputRouter?.write(data) ?? (this.activeStdinPipe !== null ? "legacy" : "rejected");
87954
+ const routed = this.options.terminalInputRouter?.write(data);
87955
+ const route = routed === "rejected" && this.activeStdinPipe !== null ? "legacy" : routed ?? (this.activeStdinPipe !== null ? "legacy" : "rejected");
87955
87956
  if (route === "legacy") {
87956
- this.activeStdinPipe?.write(data);
87957
+ if (!this.activeStdinPipe) return false;
87958
+ try {
87959
+ this.activeStdinPipe.write(data);
87960
+ } catch {
87961
+ return false;
87962
+ }
87957
87963
  }
87958
87964
  const accepted = route !== "rejected";
87959
87965
  if (accepted && this.currentInputState.mode === "stdin") {
87960
87966
  this.activeStdinPrompt = "";
87961
- this.setInputState("busy", "stdin-submit");
87967
+ this.setInputState("stdin", "stdin-submit", "");
87962
87968
  }
87963
87969
  return accepted;
87964
87970
  }
87965
87971
  endStdin() {
87966
87972
  if (!this.activeRun || this.activeStdinEnded) return false;
87967
- const route = this.options.terminalInputRouter?.end() ?? (this.activeStdinPipe !== null ? "legacy" : "rejected");
87973
+ const routed = this.options.terminalInputRouter?.end();
87974
+ const route = routed === "rejected" && this.activeStdinPipe !== null ? "legacy" : routed ?? (this.activeStdinPipe !== null ? "legacy" : "rejected");
87968
87975
  if (route === "rejected") return false;
87969
87976
  this.activeStdinEnded = true;
87970
87977
  if (route === "legacy") {
@@ -88003,6 +88010,14 @@ var RuntimeProjectWorkspaceTerminalSession = class {
88003
88010
  this.emitTerminalEvent(reason);
88004
88011
  return this.currentInputState;
88005
88012
  }
88013
+ showForegroundInputLine() {
88014
+ const acceptsInput = this.activeStdinPipe !== null || this.options.terminalInputRouter !== void 0;
88015
+ return this.setInputState(
88016
+ acceptsInput ? "stdin" : "busy",
88017
+ "command-start",
88018
+ acceptsInput ? "" : this.prompt.text
88019
+ );
88020
+ }
88006
88021
  async run(command, options = {}) {
88007
88022
  const trimmed = command.trim();
88008
88023
  if (!trimmed) return { stdout: "", stderr: "", exitCode: 0 };
@@ -88057,7 +88072,7 @@ var RuntimeProjectWorkspaceTerminalSession = class {
88057
88072
  this.activeTerminalEventHandler = options.onTerminalEvent;
88058
88073
  this.activeStdinPrompt = "";
88059
88074
  this.activeCommand = submittedCommand;
88060
- this.setInputState("busy", "command-start");
88075
+ this.showForegroundInputLine();
88061
88076
  try {
88062
88077
  let stdout = "";
88063
88078
  let stderr = "";
@@ -88086,6 +88101,7 @@ var RuntimeProjectWorkspaceTerminalSession = class {
88086
88101
  ...error ? { error } : {}
88087
88102
  };
88088
88103
  } finally {
88104
+ this.options.terminalInputRouter?.reset();
88089
88105
  ownedStdinPipe?.close();
88090
88106
  this.activeStdinPipe = previousStdinPipe;
88091
88107
  this.activeStdinEnded = previousStdinEnded;
@@ -88124,7 +88140,7 @@ var RuntimeProjectWorkspaceTerminalSession = class {
88124
88140
  this.activeStdinPrompt = "";
88125
88141
  this.activeCommand = trimmed;
88126
88142
  this.activeCommandAbortController = commandAbortController;
88127
- this.setInputState("busy", "command-start");
88143
+ this.showForegroundInputLine();
88128
88144
  try {
88129
88145
  const result = await this.runForegroundTerminalCommand(
88130
88146
  trimmed,
@@ -88135,6 +88151,7 @@ var RuntimeProjectWorkspaceTerminalSession = class {
88135
88151
  return result;
88136
88152
  } finally {
88137
88153
  options.signal?.removeEventListener("abort", forwardExternalAbort);
88154
+ this.options.terminalInputRouter?.reset();
88138
88155
  ownedStdinPipe?.close();
88139
88156
  this.activeStdinPipe = previousStdinPipe;
88140
88157
  this.activeStdinEnded = previousStdinEnded;
@@ -93808,21 +93825,26 @@ function createWorkspaceRuntimeRunnerBridge(bridge) {
93808
93825
  ...requestWithoutLegacyStdin
93809
93826
  } = request;
93810
93827
  const activeStdinPipe = request.source !== "compile" && request.source !== "stdin" ? commandContext?.stdinPipe : void 0;
93828
+ const consumesLiveStdin = request.source !== "compile" && request.source !== "stdin";
93811
93829
  const stdinPipe = request.stdinPipe ?? activeStdinPipe;
93812
- const processBinding = commandContext ? bridge.bindProcess(commandContext, descriptorStdio) : {};
93830
+ const processBinding = commandContext ? bridge.bindProcess(
93831
+ commandContext,
93832
+ descriptorStdio,
93833
+ consumesLiveStdin
93834
+ ) : {};
93813
93835
  const signal = processBinding.signal ?? request.signal;
93814
93836
  const runtimeIo = commandContext?.runtimeIo;
93815
93837
  let acceptingRunnerEvents = true;
93816
93838
  let result;
93817
93839
  const kernelSyscalls = options.kernelSyscalls ? bridge.createKernelSyscallBridge(commandContext) : void 0;
93818
- if (descriptorStdio && commandContext) {
93840
+ if (descriptorStdio && commandContext && consumesLiveStdin) {
93819
93841
  bridge.startHostStandardInputPump(commandContext);
93820
93842
  }
93821
93843
  try {
93822
- result = await runner({
93823
- ...descriptorStdio ? requestWithoutLegacyStdin : request,
93844
+ const execution = runner({
93845
+ ...descriptorStdio || !consumesLiveStdin ? requestWithoutLegacyStdin : request,
93824
93846
  ...processBinding.process ? { process: processBinding.process } : {},
93825
- ...stdinPipe && !descriptorStdio ? { stdinPipe: { buffer: stdinPipe.buffer } } : {},
93847
+ ...stdinPipe && !descriptorStdio && consumesLiveStdin ? { stdinPipe: { buffer: stdinPipe.buffer } } : {},
93826
93848
  ...commandContext?.terminal ? { terminal: commandContext.terminal } : {},
93827
93849
  ...commandContext?.engineLease ? { engineLease: commandContext.engineLease } : {},
93828
93850
  ...signal ? { signal } : {},
@@ -93834,6 +93856,8 @@ function createWorkspaceRuntimeRunnerBridge(bridge) {
93834
93856
  bridge.handleRuntimeCommandEvent(event, commandContext);
93835
93857
  }
93836
93858
  });
93859
+ await processBinding.replayStartupInput?.();
93860
+ result = await execution;
93837
93861
  } finally {
93838
93862
  acceptingRunnerEvents = false;
93839
93863
  kernelSyscalls?.close();
@@ -94721,6 +94745,7 @@ function createRuntimeWorkspaceShellCommands(options) {
94721
94745
  var PRINCIPAL_ACTOR2 = runtimeWorkspaceActorPreset("principal");
94722
94746
  var RUNTIME_ACTOR = runtimeWorkspaceActorPreset("runtime");
94723
94747
  var SYSTEM_ACTOR2 = runtimeWorkspaceActorPreset("system");
94748
+ var TERMINAL_STARTUP_INPUT_MAX_BYTES = 64 * 1024 - 1;
94724
94749
  var TRACEKERNEL_SYSCALL_ERROR_CODES = /* @__PURE__ */ new Set([
94725
94750
  "E2BIG",
94726
94751
  "EAGAIN",
@@ -94854,6 +94879,7 @@ var RuntimeProjectWorkspace = class {
94854
94879
  processState = new WorkspaceProcessState();
94855
94880
  terminalShells = /* @__PURE__ */ new Map();
94856
94881
  terminalResourceIds = /* @__PURE__ */ new Map();
94882
+ pendingTerminalStartupInput = /* @__PURE__ */ new Map();
94857
94883
  processProjection;
94858
94884
  // Temporary 0.13 introspection aliases. The process state module remains
94859
94885
  // authoritative; these preserve existing hardening probes while 0.14 moves
@@ -95035,17 +95061,24 @@ var RuntimeProjectWorkspace = class {
95035
95061
  });
95036
95062
  const withEvents = createWorkspaceRuntimeRunnerBridge({
95037
95063
  resolveCommandContext: (context2) => this.resolveCommandContext(context2),
95038
- bindProcess: (context2, descriptorStdio) => {
95064
+ bindProcess: (context2, descriptorStdio, consumesLiveStdin) => {
95039
95065
  const executionHandle = this.processProjection.executionHandle(
95040
95066
  context2.process
95041
95067
  );
95042
95068
  if (executionHandle) {
95043
95069
  executionHandle.descriptorStdio = descriptorStdio;
95070
+ executionHandle.consumesLiveStdin = consumesLiveStdin;
95044
95071
  }
95045
95072
  const processSnapshot = this.processProjection.authoritativeSnapshot(
95046
95073
  context2.process
95047
95074
  );
95048
95075
  return {
95076
+ replayStartupInput: () => this.resolvePendingTerminalStartupInput(
95077
+ context2.process.pid,
95078
+ descriptorStdio,
95079
+ context2.stdinPipe,
95080
+ consumesLiveStdin
95081
+ ),
95049
95082
  ...executionHandle?.abortController?.signal ? { signal: executionHandle.abortController.signal } : {},
95050
95083
  ...executionHandle?.signalChannel ? { kernelSignals: executionHandle.signalChannel } : {},
95051
95084
  ...processSnapshot ? {
@@ -97593,24 +97626,106 @@ var RuntimeProjectWorkspace = class {
97593
97626
  )
97594
97627
  );
97595
97628
  }
97596
- kernelTerminalInputRoute(terminal) {
97629
+ kernelTerminalInputRoute(terminalSessionId, terminal) {
97597
97630
  const hasDescriptorConsumer = this.traceKernelAuthority?.session.processSnapshots().some(
97598
- (process3) => process3.sid === terminal.sessionId && process3.pgid === terminal.foregroundProcessGroupId && this.processState.executionHandles.get(process3.pid)?.descriptorStdio === true
97631
+ (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
97599
97632
  ) === true;
97600
- return hasDescriptorConsumer ? "kernel" : "legacy";
97633
+ if (hasDescriptorConsumer) return "kernel";
97634
+ const foregroundPid = this.processState.terminalForeground.get(
97635
+ terminalSessionId
97636
+ );
97637
+ if (foregroundPid === void 0) return "pending";
97638
+ const executionHandle = this.processState.executionHandles.get(foregroundPid);
97639
+ if (executionHandle?.consumesLiveStdin !== true) return "pending";
97640
+ const descriptorStdio = executionHandle.descriptorStdio;
97641
+ return descriptorStdio === void 0 ? "pending" : descriptorStdio ? "kernel" : "legacy";
97642
+ }
97643
+ queueTerminalStartupInput(terminalSessionId, input = {}) {
97644
+ const pending2 = this.pendingTerminalStartupInput.get(terminalSessionId) ?? {
97645
+ chunks: [],
97646
+ byteLength: 0,
97647
+ eof: false
97648
+ };
97649
+ if (input.data) {
97650
+ const byteLength = new TextEncoder().encode(input.data).byteLength;
97651
+ if (pending2.byteLength + byteLength > TERMINAL_STARTUP_INPUT_MAX_BYTES) {
97652
+ return false;
97653
+ }
97654
+ pending2.chunks.push(input.data);
97655
+ pending2.byteLength += byteLength;
97656
+ }
97657
+ if (input.eof) pending2.eof = true;
97658
+ this.pendingTerminalStartupInput.set(terminalSessionId, pending2);
97659
+ return true;
97601
97660
  }
97602
- writeKernelTerminalInput(terminalSessionId, data) {
97661
+ async resolvePendingTerminalStartupInput(foregroundPid, descriptorStdio, stdinPipe, consumesLiveStdin = true) {
97662
+ const boundProcess = this.processProjection.find(foregroundPid);
97663
+ const boundSnapshot = boundProcess ? this.processProjection.authoritativeSnapshot(boundProcess) : void 0;
97664
+ const terminalSessionId = [...this.processState.terminalForeground].find(([, pid]) => {
97665
+ if (pid === foregroundPid) return true;
97666
+ const terminalProcess = this.processProjection.find(pid);
97667
+ const terminalSnapshot = terminalProcess ? this.processProjection.authoritativeSnapshot(terminalProcess) : void 0;
97668
+ return Boolean(
97669
+ boundSnapshot && terminalSnapshot && boundSnapshot.pgid === terminalSnapshot.pgid
97670
+ );
97671
+ })?.[0];
97672
+ if (!terminalSessionId) return;
97673
+ const pending2 = this.pendingTerminalStartupInput.get(terminalSessionId);
97674
+ if (!pending2) return;
97675
+ if (!consumesLiveStdin) return;
97676
+ this.pendingTerminalStartupInput.delete(terminalSessionId);
97677
+ if (!descriptorStdio) {
97678
+ if (!stdinPipe) return;
97679
+ try {
97680
+ for (const chunk2 of pending2.chunks) stdinPipe.write(chunk2);
97681
+ if (pending2.eof) stdinPipe.close();
97682
+ } catch {
97683
+ stdinPipe.close();
97684
+ }
97685
+ return;
97686
+ }
97603
97687
  const authority = this.traceKernelAuthority;
97604
97688
  const terminalId = this.terminalResourceIds.get(terminalSessionId);
97605
97689
  const terminal = terminalId === void 0 ? void 0 : authority?.session.terminalSnapshots().find(
97606
97690
  (candidate) => candidate.id === terminalId
97607
97691
  );
97608
- if (!authority || !terminal || terminal.closed) return "rejected";
97692
+ if (!authority || !terminal || terminal.closed) return;
97693
+ const bytes = new TextEncoder().encode(pending2.chunks.join(""));
97694
+ await runPromise(
97695
+ gen2(function* () {
97696
+ if (bytes.byteLength > 0) {
97697
+ yield* authority.session.writeTerminalInput(terminal.id, bytes);
97698
+ }
97699
+ if (pending2.eof) {
97700
+ yield* authority.session.sendTerminalInputEof(terminal.id);
97701
+ }
97702
+ }).pipe(catchAll2(() => _void))
97703
+ );
97704
+ }
97705
+ discardPendingTerminalStartupInput(terminalSessionId, foregroundPid) {
97706
+ if (terminalSessionId && (foregroundPid === void 0 || this.processState.terminalForeground.get(terminalSessionId) === foregroundPid)) {
97707
+ this.pendingTerminalStartupInput.delete(terminalSessionId);
97708
+ }
97709
+ }
97710
+ writeKernelTerminalInput(terminalSessionId, data) {
97609
97711
  const signalByte = new TextEncoder().encode(data).find(
97610
97712
  (byte) => byte === 3 || byte === 28
97611
97713
  );
97612
- if (signalByte === void 0 && this.kernelTerminalInputRoute(terminal) === "legacy") {
97613
- return "legacy";
97714
+ const authority = this.traceKernelAuthority;
97715
+ const terminalId = this.terminalResourceIds.get(terminalSessionId);
97716
+ const terminal = terminalId === void 0 ? void 0 : authority?.session.terminalSnapshots().find(
97717
+ (candidate) => candidate.id === terminalId
97718
+ );
97719
+ if (!authority || !terminal || terminal.closed) {
97720
+ if (signalByte !== void 0) return "rejected";
97721
+ return this.queueTerminalStartupInput(terminalSessionId, { data }) ? "pending" : "rejected";
97722
+ }
97723
+ if (signalByte === void 0) {
97724
+ const route = this.kernelTerminalInputRoute(terminalSessionId, terminal);
97725
+ if (route === "pending") {
97726
+ return this.queueTerminalStartupInput(terminalSessionId, { data }) ? "pending" : "rejected";
97727
+ }
97728
+ if (route === "legacy") return "legacy";
97614
97729
  }
97615
97730
  if (signalByte !== void 0) {
97616
97731
  const signal = signalByte === 3 ? "SIGINT" : "SIGQUIT";
@@ -97640,8 +97755,16 @@ var RuntimeProjectWorkspace = class {
97640
97755
  const terminal = terminalId === void 0 ? void 0 : authority?.session.terminalSnapshots().find(
97641
97756
  (candidate) => candidate.id === terminalId
97642
97757
  );
97643
- if (!authority || !terminal || terminal.closed) return "rejected";
97644
- if (this.kernelTerminalInputRoute(terminal) === "legacy") return "legacy";
97758
+ if (!authority || !terminal || terminal.closed) {
97759
+ this.queueTerminalStartupInput(terminalSessionId, { eof: true });
97760
+ return "pending";
97761
+ }
97762
+ const route = this.kernelTerminalInputRoute(terminalSessionId, terminal);
97763
+ if (route === "pending") {
97764
+ this.queueTerminalStartupInput(terminalSessionId, { eof: true });
97765
+ return "pending";
97766
+ }
97767
+ if (route === "legacy") return "legacy";
97645
97768
  runFork2(
97646
97769
  authority.session.sendTerminalInputEof(terminal.id).pipe(
97647
97770
  catchAll2(() => _void)
@@ -98795,6 +98918,10 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
98795
98918
  executionHandle.signalChannel?.close();
98796
98919
  this.processState.executionHandles.delete(process3.pid);
98797
98920
  if (options.terminalSessionId && this.processState.terminalForeground.get(options.terminalSessionId) === process3.pid) {
98921
+ this.discardPendingTerminalStartupInput(
98922
+ options.terminalSessionId,
98923
+ process3.pid
98924
+ );
98798
98925
  this.processState.terminalForeground.delete(options.terminalSessionId);
98799
98926
  }
98800
98927
  clearKernelSignalHandler();
@@ -99049,6 +99176,10 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
99049
99176
  executionHandle.signalChannel?.close();
99050
99177
  this.processState.executionHandles.delete(process3.pid);
99051
99178
  if (options.terminalSessionId && this.processState.terminalForeground.get(options.terminalSessionId) === process3.pid) {
99179
+ this.discardPendingTerminalStartupInput(
99180
+ options.terminalSessionId,
99181
+ process3.pid
99182
+ );
99052
99183
  this.processState.terminalForeground.delete(options.terminalSessionId);
99053
99184
  }
99054
99185
  this.observeKernelReparentedChildren(process3.pid);
@@ -99355,6 +99486,7 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
99355
99486
  const shellPromise = this.terminalShells.get(terminalSessionId);
99356
99487
  this.terminalShells.delete(terminalSessionId);
99357
99488
  this.terminalResourceIds.delete(terminalSessionId);
99489
+ this.pendingTerminalStartupInput.delete(terminalSessionId);
99358
99490
  if (!shellPromise) return;
99359
99491
  const disposal = shellPromise.then(async (shell) => {
99360
99492
  const authority = this.traceKernelAuthority;
@@ -99409,7 +99541,8 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
99409
99541
  signalForeground: (signal) => this.signalTerminalForeground(terminalSessionId, signal),
99410
99542
  terminalInputRouter: {
99411
99543
  write: (data) => this.writeKernelTerminalInput(terminalSessionId, data),
99412
- end: () => this.endKernelTerminalInput(terminalSessionId)
99544
+ end: () => this.endKernelTerminalInput(terminalSessionId),
99545
+ reset: () => this.discardPendingTerminalStartupInput(terminalSessionId)
99413
99546
  },
99414
99547
  resizeTerminal: (columns, rows) => this.resizeKernelTerminal(terminalSessionId, columns, rows),
99415
99548
  closeTerminal: () => this.closeTerminalShell(terminalSessionId),
@@ -99523,13 +99656,14 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
99523
99656
  const descriptorStdio = this.cppRunner.capabilities?.descriptorStdio === true;
99524
99657
  if (executionHandle) {
99525
99658
  executionHandle.descriptorStdio = descriptorStdio;
99659
+ executionHandle.consumesLiveStdin = true;
99526
99660
  }
99527
99661
  if (descriptorStdio) {
99528
99662
  this.startHostStandardInputPump(request.commandContext);
99529
99663
  }
99530
99664
  let result;
99531
99665
  try {
99532
- result = await this.cppRunner({
99666
+ const execution = this.cppRunner({
99533
99667
  code: "",
99534
99668
  source: "run",
99535
99669
  scriptPath,
@@ -99554,6 +99688,12 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
99554
99688
  this.handleRuntimeCommandEvent(event, request.commandContext);
99555
99689
  }
99556
99690
  });
99691
+ await this.resolvePendingTerminalStartupInput(
99692
+ request.commandContext.process.pid,
99693
+ descriptorStdio,
99694
+ request.stdinPipe
99695
+ );
99696
+ result = await execution;
99557
99697
  } finally {
99558
99698
  kernelSyscalls?.close();
99559
99699
  }
@@ -165,6 +165,7 @@ declare class RuntimeProjectWorkspace implements RuntimeWorkspace {
165
165
  private readonly processState;
166
166
  private readonly terminalShells;
167
167
  private readonly terminalResourceIds;
168
+ private readonly pendingTerminalStartupInput;
168
169
  private readonly processProjection;
169
170
  private readonly processTable;
170
171
  private readonly processExecutionHandles;
@@ -285,6 +286,9 @@ declare class RuntimeProjectWorkspace implements RuntimeWorkspace {
285
286
  private signalTerminalForeground;
286
287
  private resizeKernelTerminal;
287
288
  private kernelTerminalInputRoute;
289
+ private queueTerminalStartupInput;
290
+ private resolvePendingTerminalStartupInput;
291
+ private discardPendingTerminalStartupInput;
288
292
  private writeKernelTerminalInput;
289
293
  private endKernelTerminalInput;
290
294
  private reapZombieProcess;
@@ -446,8 +450,9 @@ declare class RuntimeProjectWorkspaceTerminalSession implements RuntimeProjectTe
446
450
  runCommand: (command: string, options?: RuntimeCommandOptions) => Promise<RuntimeCommandResult>;
447
451
  signalForeground?: (signal: 'SIGINT' | 'SIGQUIT') => boolean;
448
452
  terminalInputRouter?: {
449
- write(data: string): 'kernel' | 'legacy' | 'rejected';
450
- end(): 'kernel' | 'legacy' | 'rejected';
453
+ write(data: string): 'kernel' | 'legacy' | 'pending' | 'rejected';
454
+ end(): 'kernel' | 'legacy' | 'pending' | 'rejected';
455
+ reset(): void;
451
456
  };
452
457
  resizeTerminal?: (columns: number, rows: number) => void;
453
458
  closeTerminal?: () => void;
@@ -472,6 +477,7 @@ declare class RuntimeProjectWorkspaceTerminalSession implements RuntimeProjectTe
472
477
  private emitTerminalEvent;
473
478
  private emitControlEvent;
474
479
  private setInputState;
480
+ private showForegroundInputLine;
475
481
  run(command: string, options?: RuntimeProjectTerminalRunOptions): Promise<RuntimeCommandResult>;
476
482
  private runTerminalCommandList;
477
483
  private runForegroundTerminalSubmission;
@@ -165,6 +165,7 @@ declare class RuntimeProjectWorkspace implements RuntimeWorkspace {
165
165
  private readonly processState;
166
166
  private readonly terminalShells;
167
167
  private readonly terminalResourceIds;
168
+ private readonly pendingTerminalStartupInput;
168
169
  private readonly processProjection;
169
170
  private readonly processTable;
170
171
  private readonly processExecutionHandles;
@@ -285,6 +286,9 @@ declare class RuntimeProjectWorkspace implements RuntimeWorkspace {
285
286
  private signalTerminalForeground;
286
287
  private resizeKernelTerminal;
287
288
  private kernelTerminalInputRoute;
289
+ private queueTerminalStartupInput;
290
+ private resolvePendingTerminalStartupInput;
291
+ private discardPendingTerminalStartupInput;
288
292
  private writeKernelTerminalInput;
289
293
  private endKernelTerminalInput;
290
294
  private reapZombieProcess;
@@ -446,8 +450,9 @@ declare class RuntimeProjectWorkspaceTerminalSession implements RuntimeProjectTe
446
450
  runCommand: (command: string, options?: RuntimeCommandOptions) => Promise<RuntimeCommandResult>;
447
451
  signalForeground?: (signal: 'SIGINT' | 'SIGQUIT') => boolean;
448
452
  terminalInputRouter?: {
449
- write(data: string): 'kernel' | 'legacy' | 'rejected';
450
- end(): 'kernel' | 'legacy' | 'rejected';
453
+ write(data: string): 'kernel' | 'legacy' | 'pending' | 'rejected';
454
+ end(): 'kernel' | 'legacy' | 'pending' | 'rejected';
455
+ reset(): void;
451
456
  };
452
457
  resizeTerminal?: (columns: number, rows: number) => void;
453
458
  closeTerminal?: () => void;
@@ -472,6 +477,7 @@ declare class RuntimeProjectWorkspaceTerminalSession implements RuntimeProjectTe
472
477
  private emitTerminalEvent;
473
478
  private emitControlEvent;
474
479
  private setInputState;
480
+ private showForegroundInputLine;
475
481
  run(command: string, options?: RuntimeProjectTerminalRunOptions): Promise<RuntimeCommandResult>;
476
482
  private runTerminalCommandList;
477
483
  private runForegroundTerminalSubmission;