@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.
- package/CHANGELOG.md +21 -0
- package/dist/{browser-runtime-provider-45ND6W3K.js → browser-runtime-provider-OGJQLGXU.js} +4 -4
- package/dist/{chunk-5SU2JQGI.js → chunk-5RT5IT4I.js} +16 -14
- package/dist/{chunk-J54PE2JS.js → chunk-6LE4KEMZ.js} +2 -2
- package/dist/{chunk-K4424WAS.js → chunk-AAKNIYV6.js} +3 -3
- package/dist/{chunk-HK62URW2.js → chunk-M7SNEZDR.js} +2 -2
- package/dist/{chunk-MJOC6WVB.js → chunk-RCOPAMVR.js} +10 -2
- package/dist/{chunk-DGXNINFR.js → chunk-Y72C46GE.js} +9 -9
- package/dist/core.cjs +8 -8
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +1 -1
- package/dist/{cpp-worker-client-I6CPM7TA.js → cpp-worker-client-HV7RO2P5.js} +3 -3
- package/dist/{csharp-worker-client-X7R4VXF4.js → csharp-worker-client-ARGMOB3M.js} +3 -3
- package/dist/internal/tracekernel-workspace.cjs +171 -31
- package/dist/internal/tracekernel-workspace.d.cts +8 -2
- package/dist/internal/tracekernel-workspace.d.ts +8 -2
- package/dist/internal/tracekernel-workspace.js +164 -24
- package/dist/{java-project-MLWER3CQ.js → java-project-JB5TUIFU.js} +2 -2
- package/dist/{java-project-client-R7CKC72F.js → java-project-client-PEQKFTH6.js} +11 -2
- package/dist/judge.cjs +194 -35
- package/dist/judge.d.cts +1 -1
- package/dist/judge.d.ts +1 -1
- package/dist/judge.js +6 -6
- package/dist/{project-browser-UALCR5KR.js → project-browser-3S2FWEAP.js} +2 -2
- package/dist/{project-browser-EIQ2FOXP.js → project-browser-HCQCXAYC.js} +2 -2
- package/dist/{project-browser-V3W4CQAQ.js → project-browser-QN7YOJQQ.js} +2 -2
- package/dist/{project-browser-JR2WG7DG.js → project-browser-S4KLCZV7.js} +2 -2
- package/dist/{project-browser-T3EIQCMD.js → project-browser-WDUWUGLZ.js} +2 -2
- package/dist/{python-worker-client-MRWQTXOF.js → python-worker-client-EX6Q2W4L.js} +3 -3
- package/dist/{runtime-environment-D7mZm8SA.d.cts → runtime-environment-BO5I1fAC.d.cts} +5 -0
- package/dist/{runtime-environment-Q60S0pUa.d.ts → runtime-environment-Dfg6ZoCj.d.ts} +5 -0
- package/dist/{runtime-open-source-info-BQtIRJ9F.d.cts → runtime-open-source-info-CaBpNicy.d.cts} +4 -2
- package/dist/{runtime-open-source-info-FkIxlAcm.d.ts → runtime-open-source-info-D0OJc4zH.d.ts} +4 -2
- package/dist/tracekernel.cjs +359 -60
- package/dist/tracekernel.d.cts +4 -4
- package/dist/tracekernel.d.ts +4 -4
- package/dist/tracekernel.js +166 -26
- package/package.json +3 -3
- package/runtime-assets.lock.json +7 -7
- package/workers/javascript/javascript-project-worker.js +7 -7
package/dist/tracekernel.cjs
CHANGED
|
@@ -13521,7 +13521,7 @@ var init_package = __esm({
|
|
|
13521
13521
|
"package.json"() {
|
|
13522
13522
|
package_default = {
|
|
13523
13523
|
name: "@tracecode/harness",
|
|
13524
|
-
version: "0.16.
|
|
13524
|
+
version: "0.16.4",
|
|
13525
13525
|
license: "AGPL-3.0-only",
|
|
13526
13526
|
homepage: "https://tracecode.app",
|
|
13527
13527
|
repository: {
|
|
@@ -13791,7 +13791,7 @@ var init_runtime_language_info_data = __esm({
|
|
|
13791
13791
|
"versionLabel": "Python 3.13.2",
|
|
13792
13792
|
"executionPlatform": {
|
|
13793
13793
|
"name": "TraceKernel",
|
|
13794
|
-
"version": "0.16.
|
|
13794
|
+
"version": "0.16.4"
|
|
13795
13795
|
},
|
|
13796
13796
|
"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.",
|
|
13797
13797
|
"runtime": {
|
|
@@ -13818,7 +13818,7 @@ var init_runtime_language_info_data = __esm({
|
|
|
13818
13818
|
"versionLabel": "JavaScript (ECMAScript 2023)",
|
|
13819
13819
|
"executionPlatform": {
|
|
13820
13820
|
"name": "TraceKernel",
|
|
13821
|
-
"version": "0.16.
|
|
13821
|
+
"version": "0.16.4"
|
|
13822
13822
|
},
|
|
13823
13823
|
"runtime": {
|
|
13824
13824
|
"name": "TraceKernel JavaScript runtime",
|
|
@@ -13910,7 +13910,7 @@ Binary Search Tree, Trie, and Graph are bundled too, but are not exposed globall
|
|
|
13910
13910
|
"versionLabel": "TypeScript 5.9.3",
|
|
13911
13911
|
"executionPlatform": {
|
|
13912
13912
|
"name": "TraceKernel",
|
|
13913
|
-
"version": "0.16.
|
|
13913
|
+
"version": "0.16.4"
|
|
13914
13914
|
},
|
|
13915
13915
|
"description": `TypeScript 5.9.3 is compiled with the TypeScript compiler and executed by TraceKernel's JavaScript runtime.
|
|
13916
13916
|
|
|
@@ -14010,7 +14010,7 @@ The compiled output runs on the same TraceKernel execution lane as JavaScript su
|
|
|
14010
14010
|
"versionLabel": "Java 23",
|
|
14011
14011
|
"executionPlatform": {
|
|
14012
14012
|
"name": "TraceKernel",
|
|
14013
|
-
"version": "0.16.
|
|
14013
|
+
"version": "0.16.4"
|
|
14014
14014
|
},
|
|
14015
14015
|
"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.",
|
|
14016
14016
|
"runtime": {
|
|
@@ -14047,7 +14047,7 @@ The compiled output runs on the same TraceKernel execution lane as JavaScript su
|
|
|
14047
14047
|
"versionLabel": "C# 14",
|
|
14048
14048
|
"executionPlatform": {
|
|
14049
14049
|
"name": "TraceKernel",
|
|
14050
|
-
"version": "0.16.
|
|
14050
|
+
"version": "0.16.4"
|
|
14051
14051
|
},
|
|
14052
14052
|
"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.",
|
|
14053
14053
|
"runtime": {
|
|
@@ -14076,7 +14076,7 @@ The compiled output runs on the same TraceKernel execution lane as JavaScript su
|
|
|
14076
14076
|
"versionLabel": "C++23",
|
|
14077
14077
|
"executionPlatform": {
|
|
14078
14078
|
"name": "TraceKernel",
|
|
14079
|
-
"version": "0.16.
|
|
14079
|
+
"version": "0.16.4"
|
|
14080
14080
|
},
|
|
14081
14081
|
"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.",
|
|
14082
14082
|
"runtime": {
|
|
@@ -14241,7 +14241,7 @@ var init_runtime_open_source_info_data = __esm({
|
|
|
14241
14241
|
{
|
|
14242
14242
|
"kind": "modifications",
|
|
14243
14243
|
"label": "Runtime modifications",
|
|
14244
|
-
"url": "https://github.com/tracecodeapp/harness/tree/v0.16.
|
|
14244
|
+
"url": "https://github.com/tracecodeapp/harness/tree/v0.16.4/workers/python/pyodide-0.29.3"
|
|
14245
14245
|
}
|
|
14246
14246
|
]
|
|
14247
14247
|
}
|
|
@@ -89584,20 +89584,27 @@ var init_terminal_session = __esm({
|
|
|
89584
89584
|
signalCharacter === "" ? "SIGINT" : "SIGQUIT"
|
|
89585
89585
|
);
|
|
89586
89586
|
}
|
|
89587
|
-
const
|
|
89587
|
+
const routed = this.options.terminalInputRouter?.write(data);
|
|
89588
|
+
const route = routed === "rejected" && this.activeStdinPipe !== null ? "legacy" : routed ?? (this.activeStdinPipe !== null ? "legacy" : "rejected");
|
|
89588
89589
|
if (route === "legacy") {
|
|
89589
|
-
this.activeStdinPipe
|
|
89590
|
+
if (!this.activeStdinPipe) return false;
|
|
89591
|
+
try {
|
|
89592
|
+
this.activeStdinPipe.write(data);
|
|
89593
|
+
} catch {
|
|
89594
|
+
return false;
|
|
89595
|
+
}
|
|
89590
89596
|
}
|
|
89591
89597
|
const accepted = route !== "rejected";
|
|
89592
89598
|
if (accepted && this.currentInputState.mode === "stdin") {
|
|
89593
89599
|
this.activeStdinPrompt = "";
|
|
89594
|
-
this.setInputState("
|
|
89600
|
+
this.setInputState("stdin", "stdin-submit", "");
|
|
89595
89601
|
}
|
|
89596
89602
|
return accepted;
|
|
89597
89603
|
}
|
|
89598
89604
|
endStdin() {
|
|
89599
89605
|
if (!this.activeRun || this.activeStdinEnded) return false;
|
|
89600
|
-
const
|
|
89606
|
+
const routed = this.options.terminalInputRouter?.end();
|
|
89607
|
+
const route = routed === "rejected" && this.activeStdinPipe !== null ? "legacy" : routed ?? (this.activeStdinPipe !== null ? "legacy" : "rejected");
|
|
89601
89608
|
if (route === "rejected") return false;
|
|
89602
89609
|
this.activeStdinEnded = true;
|
|
89603
89610
|
if (route === "legacy") {
|
|
@@ -89636,6 +89643,14 @@ var init_terminal_session = __esm({
|
|
|
89636
89643
|
this.emitTerminalEvent(reason);
|
|
89637
89644
|
return this.currentInputState;
|
|
89638
89645
|
}
|
|
89646
|
+
showForegroundInputLine() {
|
|
89647
|
+
const acceptsInput = this.activeStdinPipe !== null || this.options.terminalInputRouter !== void 0;
|
|
89648
|
+
return this.setInputState(
|
|
89649
|
+
acceptsInput ? "stdin" : "busy",
|
|
89650
|
+
"command-start",
|
|
89651
|
+
acceptsInput ? "" : this.prompt.text
|
|
89652
|
+
);
|
|
89653
|
+
}
|
|
89639
89654
|
async run(command, options = {}) {
|
|
89640
89655
|
const trimmed = command.trim();
|
|
89641
89656
|
if (!trimmed) return { stdout: "", stderr: "", exitCode: 0 };
|
|
@@ -89690,7 +89705,7 @@ var init_terminal_session = __esm({
|
|
|
89690
89705
|
this.activeTerminalEventHandler = options.onTerminalEvent;
|
|
89691
89706
|
this.activeStdinPrompt = "";
|
|
89692
89707
|
this.activeCommand = submittedCommand;
|
|
89693
|
-
this.
|
|
89708
|
+
this.showForegroundInputLine();
|
|
89694
89709
|
try {
|
|
89695
89710
|
let stdout = "";
|
|
89696
89711
|
let stderr = "";
|
|
@@ -89719,6 +89734,7 @@ var init_terminal_session = __esm({
|
|
|
89719
89734
|
...error ? { error } : {}
|
|
89720
89735
|
};
|
|
89721
89736
|
} finally {
|
|
89737
|
+
this.options.terminalInputRouter?.reset();
|
|
89722
89738
|
ownedStdinPipe?.close();
|
|
89723
89739
|
this.activeStdinPipe = previousStdinPipe;
|
|
89724
89740
|
this.activeStdinEnded = previousStdinEnded;
|
|
@@ -89757,7 +89773,7 @@ var init_terminal_session = __esm({
|
|
|
89757
89773
|
this.activeStdinPrompt = "";
|
|
89758
89774
|
this.activeCommand = trimmed;
|
|
89759
89775
|
this.activeCommandAbortController = commandAbortController;
|
|
89760
|
-
this.
|
|
89776
|
+
this.showForegroundInputLine();
|
|
89761
89777
|
try {
|
|
89762
89778
|
const result = await this.runForegroundTerminalCommand(
|
|
89763
89779
|
trimmed,
|
|
@@ -89768,6 +89784,7 @@ var init_terminal_session = __esm({
|
|
|
89768
89784
|
return result;
|
|
89769
89785
|
} finally {
|
|
89770
89786
|
options.signal?.removeEventListener("abort", forwardExternalAbort);
|
|
89787
|
+
this.options.terminalInputRouter?.reset();
|
|
89771
89788
|
ownedStdinPipe?.close();
|
|
89772
89789
|
this.activeStdinPipe = previousStdinPipe;
|
|
89773
89790
|
this.activeStdinEnded = previousStdinEnded;
|
|
@@ -95602,21 +95619,26 @@ function createWorkspaceRuntimeRunnerBridge2(bridge) {
|
|
|
95602
95619
|
...requestWithoutLegacyStdin
|
|
95603
95620
|
} = request;
|
|
95604
95621
|
const activeStdinPipe = request.source !== "compile" && request.source !== "stdin" ? commandContext?.stdinPipe : void 0;
|
|
95622
|
+
const consumesLiveStdin = request.source !== "compile" && request.source !== "stdin";
|
|
95605
95623
|
const stdinPipe = request.stdinPipe ?? activeStdinPipe;
|
|
95606
|
-
const processBinding = commandContext ? bridge.bindProcess(
|
|
95624
|
+
const processBinding = commandContext ? bridge.bindProcess(
|
|
95625
|
+
commandContext,
|
|
95626
|
+
descriptorStdio,
|
|
95627
|
+
consumesLiveStdin
|
|
95628
|
+
) : {};
|
|
95607
95629
|
const signal = processBinding.signal ?? request.signal;
|
|
95608
95630
|
const runtimeIo = commandContext?.runtimeIo;
|
|
95609
95631
|
let acceptingRunnerEvents = true;
|
|
95610
95632
|
let result;
|
|
95611
95633
|
const kernelSyscalls = options.kernelSyscalls ? bridge.createKernelSyscallBridge(commandContext) : void 0;
|
|
95612
|
-
if (descriptorStdio && commandContext) {
|
|
95634
|
+
if (descriptorStdio && commandContext && consumesLiveStdin) {
|
|
95613
95635
|
bridge.startHostStandardInputPump(commandContext);
|
|
95614
95636
|
}
|
|
95615
95637
|
try {
|
|
95616
|
-
|
|
95617
|
-
...descriptorStdio ? requestWithoutLegacyStdin : request,
|
|
95638
|
+
const execution = runner({
|
|
95639
|
+
...descriptorStdio || !consumesLiveStdin ? requestWithoutLegacyStdin : request,
|
|
95618
95640
|
...processBinding.process ? { process: processBinding.process } : {},
|
|
95619
|
-
...stdinPipe && !descriptorStdio ? { stdinPipe: { buffer: stdinPipe.buffer } } : {},
|
|
95641
|
+
...stdinPipe && !descriptorStdio && consumesLiveStdin ? { stdinPipe: { buffer: stdinPipe.buffer } } : {},
|
|
95620
95642
|
...commandContext?.terminal ? { terminal: commandContext.terminal } : {},
|
|
95621
95643
|
...commandContext?.engineLease ? { engineLease: commandContext.engineLease } : {},
|
|
95622
95644
|
...signal ? { signal } : {},
|
|
@@ -95628,6 +95650,8 @@ function createWorkspaceRuntimeRunnerBridge2(bridge) {
|
|
|
95628
95650
|
bridge.handleRuntimeCommandEvent(event, commandContext);
|
|
95629
95651
|
}
|
|
95630
95652
|
});
|
|
95653
|
+
await processBinding.replayStartupInput?.();
|
|
95654
|
+
result = await execution;
|
|
95631
95655
|
} finally {
|
|
95632
95656
|
acceptingRunnerEvents = false;
|
|
95633
95657
|
kernelSyscalls?.close();
|
|
@@ -96671,7 +96695,7 @@ async function createRuntimeWorkspace2(options = {}) {
|
|
|
96671
96695
|
}
|
|
96672
96696
|
return workspace;
|
|
96673
96697
|
}
|
|
96674
|
-
var PRINCIPAL_ACTOR4, RUNTIME_ACTOR2, SYSTEM_ACTOR4, TRACEKERNEL_SYSCALL_ERROR_CODES2, TRACEKERNEL_ZOMBIE_RETENTION_MS2, RuntimeProjectWorkspace2;
|
|
96698
|
+
var PRINCIPAL_ACTOR4, RUNTIME_ACTOR2, SYSTEM_ACTOR4, TERMINAL_STARTUP_INPUT_MAX_BYTES2, TRACEKERNEL_SYSCALL_ERROR_CODES2, TRACEKERNEL_ZOMBIE_RETENTION_MS2, RuntimeProjectWorkspace2;
|
|
96675
96699
|
var init_runtime_project_workspace = __esm({
|
|
96676
96700
|
"packages/tracekernel/src/workspace/runtime-project-workspace.ts"() {
|
|
96677
96701
|
"use strict";
|
|
@@ -96721,6 +96745,7 @@ var init_runtime_project_workspace = __esm({
|
|
|
96721
96745
|
PRINCIPAL_ACTOR4 = runtimeWorkspaceActorPreset("principal");
|
|
96722
96746
|
RUNTIME_ACTOR2 = runtimeWorkspaceActorPreset("runtime");
|
|
96723
96747
|
SYSTEM_ACTOR4 = runtimeWorkspaceActorPreset("system");
|
|
96748
|
+
TERMINAL_STARTUP_INPUT_MAX_BYTES2 = 64 * 1024 - 1;
|
|
96724
96749
|
TRACEKERNEL_SYSCALL_ERROR_CODES2 = /* @__PURE__ */ new Set([
|
|
96725
96750
|
"E2BIG",
|
|
96726
96751
|
"EAGAIN",
|
|
@@ -96795,6 +96820,7 @@ var init_runtime_project_workspace = __esm({
|
|
|
96795
96820
|
processState = new WorkspaceProcessState2();
|
|
96796
96821
|
terminalShells = /* @__PURE__ */ new Map();
|
|
96797
96822
|
terminalResourceIds = /* @__PURE__ */ new Map();
|
|
96823
|
+
pendingTerminalStartupInput = /* @__PURE__ */ new Map();
|
|
96798
96824
|
processProjection;
|
|
96799
96825
|
// Temporary 0.13 introspection aliases. The process state module remains
|
|
96800
96826
|
// authoritative; these preserve existing hardening probes while 0.14 moves
|
|
@@ -96976,17 +97002,24 @@ var init_runtime_project_workspace = __esm({
|
|
|
96976
97002
|
});
|
|
96977
97003
|
const withEvents = createWorkspaceRuntimeRunnerBridge2({
|
|
96978
97004
|
resolveCommandContext: (context2) => this.resolveCommandContext(context2),
|
|
96979
|
-
bindProcess: (context2, descriptorStdio) => {
|
|
97005
|
+
bindProcess: (context2, descriptorStdio, consumesLiveStdin) => {
|
|
96980
97006
|
const executionHandle = this.processProjection.executionHandle(
|
|
96981
97007
|
context2.process
|
|
96982
97008
|
);
|
|
96983
97009
|
if (executionHandle) {
|
|
96984
97010
|
executionHandle.descriptorStdio = descriptorStdio;
|
|
97011
|
+
executionHandle.consumesLiveStdin = consumesLiveStdin;
|
|
96985
97012
|
}
|
|
96986
97013
|
const processSnapshot = this.processProjection.authoritativeSnapshot(
|
|
96987
97014
|
context2.process
|
|
96988
97015
|
);
|
|
96989
97016
|
return {
|
|
97017
|
+
replayStartupInput: () => this.resolvePendingTerminalStartupInput(
|
|
97018
|
+
context2.process.pid,
|
|
97019
|
+
descriptorStdio,
|
|
97020
|
+
context2.stdinPipe,
|
|
97021
|
+
consumesLiveStdin
|
|
97022
|
+
),
|
|
96990
97023
|
...executionHandle?.abortController?.signal ? { signal: executionHandle.abortController.signal } : {},
|
|
96991
97024
|
...executionHandle?.signalChannel ? { kernelSignals: executionHandle.signalChannel } : {},
|
|
96992
97025
|
...processSnapshot ? {
|
|
@@ -99534,24 +99567,106 @@ var init_runtime_project_workspace = __esm({
|
|
|
99534
99567
|
)
|
|
99535
99568
|
);
|
|
99536
99569
|
}
|
|
99537
|
-
kernelTerminalInputRoute(terminal) {
|
|
99570
|
+
kernelTerminalInputRoute(terminalSessionId, terminal) {
|
|
99538
99571
|
const hasDescriptorConsumer = this.traceKernelAuthority?.session.processSnapshots().some(
|
|
99539
|
-
(process4) => process4.sid === terminal.sessionId && process4.pgid === terminal.foregroundProcessGroupId && this.processState.executionHandles.get(process4.pid)?.descriptorStdio === true
|
|
99572
|
+
(process4) => process4.sid === terminal.sessionId && process4.pgid === terminal.foregroundProcessGroupId && this.processState.executionHandles.get(process4.pid)?.descriptorStdio === true && this.processState.executionHandles.get(process4.pid)?.consumesLiveStdin === true
|
|
99540
99573
|
) === true;
|
|
99541
|
-
|
|
99574
|
+
if (hasDescriptorConsumer) return "kernel";
|
|
99575
|
+
const foregroundPid = this.processState.terminalForeground.get(
|
|
99576
|
+
terminalSessionId
|
|
99577
|
+
);
|
|
99578
|
+
if (foregroundPid === void 0) return "pending";
|
|
99579
|
+
const executionHandle = this.processState.executionHandles.get(foregroundPid);
|
|
99580
|
+
if (executionHandle?.consumesLiveStdin !== true) return "pending";
|
|
99581
|
+
const descriptorStdio = executionHandle.descriptorStdio;
|
|
99582
|
+
return descriptorStdio === void 0 ? "pending" : descriptorStdio ? "kernel" : "legacy";
|
|
99583
|
+
}
|
|
99584
|
+
queueTerminalStartupInput(terminalSessionId, input = {}) {
|
|
99585
|
+
const pending2 = this.pendingTerminalStartupInput.get(terminalSessionId) ?? {
|
|
99586
|
+
chunks: [],
|
|
99587
|
+
byteLength: 0,
|
|
99588
|
+
eof: false
|
|
99589
|
+
};
|
|
99590
|
+
if (input.data) {
|
|
99591
|
+
const byteLength = new TextEncoder().encode(input.data).byteLength;
|
|
99592
|
+
if (pending2.byteLength + byteLength > TERMINAL_STARTUP_INPUT_MAX_BYTES2) {
|
|
99593
|
+
return false;
|
|
99594
|
+
}
|
|
99595
|
+
pending2.chunks.push(input.data);
|
|
99596
|
+
pending2.byteLength += byteLength;
|
|
99597
|
+
}
|
|
99598
|
+
if (input.eof) pending2.eof = true;
|
|
99599
|
+
this.pendingTerminalStartupInput.set(terminalSessionId, pending2);
|
|
99600
|
+
return true;
|
|
99542
99601
|
}
|
|
99543
|
-
|
|
99602
|
+
async resolvePendingTerminalStartupInput(foregroundPid, descriptorStdio, stdinPipe, consumesLiveStdin = true) {
|
|
99603
|
+
const boundProcess = this.processProjection.find(foregroundPid);
|
|
99604
|
+
const boundSnapshot = boundProcess ? this.processProjection.authoritativeSnapshot(boundProcess) : void 0;
|
|
99605
|
+
const terminalSessionId = [...this.processState.terminalForeground].find(([, pid]) => {
|
|
99606
|
+
if (pid === foregroundPid) return true;
|
|
99607
|
+
const terminalProcess = this.processProjection.find(pid);
|
|
99608
|
+
const terminalSnapshot = terminalProcess ? this.processProjection.authoritativeSnapshot(terminalProcess) : void 0;
|
|
99609
|
+
return Boolean(
|
|
99610
|
+
boundSnapshot && terminalSnapshot && boundSnapshot.pgid === terminalSnapshot.pgid
|
|
99611
|
+
);
|
|
99612
|
+
})?.[0];
|
|
99613
|
+
if (!terminalSessionId) return;
|
|
99614
|
+
const pending2 = this.pendingTerminalStartupInput.get(terminalSessionId);
|
|
99615
|
+
if (!pending2) return;
|
|
99616
|
+
if (!consumesLiveStdin) return;
|
|
99617
|
+
this.pendingTerminalStartupInput.delete(terminalSessionId);
|
|
99618
|
+
if (!descriptorStdio) {
|
|
99619
|
+
if (!stdinPipe) return;
|
|
99620
|
+
try {
|
|
99621
|
+
for (const chunk2 of pending2.chunks) stdinPipe.write(chunk2);
|
|
99622
|
+
if (pending2.eof) stdinPipe.close();
|
|
99623
|
+
} catch {
|
|
99624
|
+
stdinPipe.close();
|
|
99625
|
+
}
|
|
99626
|
+
return;
|
|
99627
|
+
}
|
|
99544
99628
|
const authority = this.traceKernelAuthority;
|
|
99545
99629
|
const terminalId = this.terminalResourceIds.get(terminalSessionId);
|
|
99546
99630
|
const terminal = terminalId === void 0 ? void 0 : authority?.session.terminalSnapshots().find(
|
|
99547
99631
|
(candidate) => candidate.id === terminalId
|
|
99548
99632
|
);
|
|
99549
|
-
if (!authority || !terminal || terminal.closed) return
|
|
99633
|
+
if (!authority || !terminal || terminal.closed) return;
|
|
99634
|
+
const bytes = new TextEncoder().encode(pending2.chunks.join(""));
|
|
99635
|
+
await runPromise(
|
|
99636
|
+
gen2(function* () {
|
|
99637
|
+
if (bytes.byteLength > 0) {
|
|
99638
|
+
yield* authority.session.writeTerminalInput(terminal.id, bytes);
|
|
99639
|
+
}
|
|
99640
|
+
if (pending2.eof) {
|
|
99641
|
+
yield* authority.session.sendTerminalInputEof(terminal.id);
|
|
99642
|
+
}
|
|
99643
|
+
}).pipe(catchAll2(() => _void))
|
|
99644
|
+
);
|
|
99645
|
+
}
|
|
99646
|
+
discardPendingTerminalStartupInput(terminalSessionId, foregroundPid) {
|
|
99647
|
+
if (terminalSessionId && (foregroundPid === void 0 || this.processState.terminalForeground.get(terminalSessionId) === foregroundPid)) {
|
|
99648
|
+
this.pendingTerminalStartupInput.delete(terminalSessionId);
|
|
99649
|
+
}
|
|
99650
|
+
}
|
|
99651
|
+
writeKernelTerminalInput(terminalSessionId, data) {
|
|
99550
99652
|
const signalByte = new TextEncoder().encode(data).find(
|
|
99551
99653
|
(byte) => byte === 3 || byte === 28
|
|
99552
99654
|
);
|
|
99553
|
-
|
|
99554
|
-
|
|
99655
|
+
const authority = this.traceKernelAuthority;
|
|
99656
|
+
const terminalId = this.terminalResourceIds.get(terminalSessionId);
|
|
99657
|
+
const terminal = terminalId === void 0 ? void 0 : authority?.session.terminalSnapshots().find(
|
|
99658
|
+
(candidate) => candidate.id === terminalId
|
|
99659
|
+
);
|
|
99660
|
+
if (!authority || !terminal || terminal.closed) {
|
|
99661
|
+
if (signalByte !== void 0) return "rejected";
|
|
99662
|
+
return this.queueTerminalStartupInput(terminalSessionId, { data }) ? "pending" : "rejected";
|
|
99663
|
+
}
|
|
99664
|
+
if (signalByte === void 0) {
|
|
99665
|
+
const route = this.kernelTerminalInputRoute(terminalSessionId, terminal);
|
|
99666
|
+
if (route === "pending") {
|
|
99667
|
+
return this.queueTerminalStartupInput(terminalSessionId, { data }) ? "pending" : "rejected";
|
|
99668
|
+
}
|
|
99669
|
+
if (route === "legacy") return "legacy";
|
|
99555
99670
|
}
|
|
99556
99671
|
if (signalByte !== void 0) {
|
|
99557
99672
|
const signal = signalByte === 3 ? "SIGINT" : "SIGQUIT";
|
|
@@ -99581,8 +99696,16 @@ var init_runtime_project_workspace = __esm({
|
|
|
99581
99696
|
const terminal = terminalId === void 0 ? void 0 : authority?.session.terminalSnapshots().find(
|
|
99582
99697
|
(candidate) => candidate.id === terminalId
|
|
99583
99698
|
);
|
|
99584
|
-
if (!authority || !terminal || terminal.closed)
|
|
99585
|
-
|
|
99699
|
+
if (!authority || !terminal || terminal.closed) {
|
|
99700
|
+
this.queueTerminalStartupInput(terminalSessionId, { eof: true });
|
|
99701
|
+
return "pending";
|
|
99702
|
+
}
|
|
99703
|
+
const route = this.kernelTerminalInputRoute(terminalSessionId, terminal);
|
|
99704
|
+
if (route === "pending") {
|
|
99705
|
+
this.queueTerminalStartupInput(terminalSessionId, { eof: true });
|
|
99706
|
+
return "pending";
|
|
99707
|
+
}
|
|
99708
|
+
if (route === "legacy") return "legacy";
|
|
99586
99709
|
runFork2(
|
|
99587
99710
|
authority.session.sendTerminalInputEof(terminal.id).pipe(
|
|
99588
99711
|
catchAll2(() => _void)
|
|
@@ -100736,6 +100859,10 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
|
|
|
100736
100859
|
executionHandle.signalChannel?.close();
|
|
100737
100860
|
this.processState.executionHandles.delete(process4.pid);
|
|
100738
100861
|
if (options.terminalSessionId && this.processState.terminalForeground.get(options.terminalSessionId) === process4.pid) {
|
|
100862
|
+
this.discardPendingTerminalStartupInput(
|
|
100863
|
+
options.terminalSessionId,
|
|
100864
|
+
process4.pid
|
|
100865
|
+
);
|
|
100739
100866
|
this.processState.terminalForeground.delete(options.terminalSessionId);
|
|
100740
100867
|
}
|
|
100741
100868
|
clearKernelSignalHandler();
|
|
@@ -100990,6 +101117,10 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
|
|
|
100990
101117
|
executionHandle.signalChannel?.close();
|
|
100991
101118
|
this.processState.executionHandles.delete(process4.pid);
|
|
100992
101119
|
if (options.terminalSessionId && this.processState.terminalForeground.get(options.terminalSessionId) === process4.pid) {
|
|
101120
|
+
this.discardPendingTerminalStartupInput(
|
|
101121
|
+
options.terminalSessionId,
|
|
101122
|
+
process4.pid
|
|
101123
|
+
);
|
|
100993
101124
|
this.processState.terminalForeground.delete(options.terminalSessionId);
|
|
100994
101125
|
}
|
|
100995
101126
|
this.observeKernelReparentedChildren(process4.pid);
|
|
@@ -101296,6 +101427,7 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
|
|
|
101296
101427
|
const shellPromise = this.terminalShells.get(terminalSessionId);
|
|
101297
101428
|
this.terminalShells.delete(terminalSessionId);
|
|
101298
101429
|
this.terminalResourceIds.delete(terminalSessionId);
|
|
101430
|
+
this.pendingTerminalStartupInput.delete(terminalSessionId);
|
|
101299
101431
|
if (!shellPromise) return;
|
|
101300
101432
|
const disposal = shellPromise.then(async (shell) => {
|
|
101301
101433
|
const authority = this.traceKernelAuthority;
|
|
@@ -101350,7 +101482,8 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
|
|
|
101350
101482
|
signalForeground: (signal) => this.signalTerminalForeground(terminalSessionId, signal),
|
|
101351
101483
|
terminalInputRouter: {
|
|
101352
101484
|
write: (data) => this.writeKernelTerminalInput(terminalSessionId, data),
|
|
101353
|
-
end: () => this.endKernelTerminalInput(terminalSessionId)
|
|
101485
|
+
end: () => this.endKernelTerminalInput(terminalSessionId),
|
|
101486
|
+
reset: () => this.discardPendingTerminalStartupInput(terminalSessionId)
|
|
101354
101487
|
},
|
|
101355
101488
|
resizeTerminal: (columns, rows) => this.resizeKernelTerminal(terminalSessionId, columns, rows),
|
|
101356
101489
|
closeTerminal: () => this.closeTerminalShell(terminalSessionId),
|
|
@@ -101464,13 +101597,14 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
|
|
|
101464
101597
|
const descriptorStdio = this.cppRunner.capabilities?.descriptorStdio === true;
|
|
101465
101598
|
if (executionHandle) {
|
|
101466
101599
|
executionHandle.descriptorStdio = descriptorStdio;
|
|
101600
|
+
executionHandle.consumesLiveStdin = true;
|
|
101467
101601
|
}
|
|
101468
101602
|
if (descriptorStdio) {
|
|
101469
101603
|
this.startHostStandardInputPump(request.commandContext);
|
|
101470
101604
|
}
|
|
101471
101605
|
let result;
|
|
101472
101606
|
try {
|
|
101473
|
-
|
|
101607
|
+
const execution = this.cppRunner({
|
|
101474
101608
|
code: "",
|
|
101475
101609
|
source: "run",
|
|
101476
101610
|
scriptPath,
|
|
@@ -101495,6 +101629,12 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
|
|
|
101495
101629
|
this.handleRuntimeCommandEvent(event, request.commandContext);
|
|
101496
101630
|
}
|
|
101497
101631
|
});
|
|
101632
|
+
await this.resolvePendingTerminalStartupInput(
|
|
101633
|
+
request.commandContext.process.pid,
|
|
101634
|
+
descriptorStdio,
|
|
101635
|
+
request.stdinPipe
|
|
101636
|
+
);
|
|
101637
|
+
result = await execution;
|
|
101498
101638
|
} finally {
|
|
101499
101639
|
kernelSyscalls?.close();
|
|
101500
101640
|
}
|
|
@@ -120539,6 +120679,13 @@ function normalizeBaseUrl(value) {
|
|
|
120539
120679
|
const baseUrl = value ?? resolveBuiltInTraceJVMRuntimeAssetBaseUrl();
|
|
120540
120680
|
return normalizeTraceJVMRuntimeAssetBaseUrl(baseUrl);
|
|
120541
120681
|
}
|
|
120682
|
+
function normalizeWorkerUrl(value) {
|
|
120683
|
+
const workerUrl = value.trim();
|
|
120684
|
+
if (!workerUrl) {
|
|
120685
|
+
throw new TypeError("TraceJVM project Worker URL cannot be empty");
|
|
120686
|
+
}
|
|
120687
|
+
return workerUrl;
|
|
120688
|
+
}
|
|
120542
120689
|
function createWorker(workerUrl, role) {
|
|
120543
120690
|
return new Worker(workerUrl, {
|
|
120544
120691
|
type: "module",
|
|
@@ -120547,7 +120694,9 @@ function createWorker(workerUrl, role) {
|
|
|
120547
120694
|
}
|
|
120548
120695
|
function createJavaProjectClientFactory(options = {}) {
|
|
120549
120696
|
const runtimeAssetBaseUrl = normalizeBaseUrl(options.runtimeAssetBaseUrl);
|
|
120550
|
-
const workerUrl =
|
|
120697
|
+
const workerUrl = normalizeWorkerUrl(
|
|
120698
|
+
options.workerUrl ?? `${runtimeAssetBaseUrl}/browser-worker.js`
|
|
120699
|
+
);
|
|
120551
120700
|
const workerFor = (role) => options.createWorker?.(workerUrl, role) ?? createWorker(workerUrl, role);
|
|
120552
120701
|
const runtimeProfile = options.runtimeProfile ?? "spring-server";
|
|
120553
120702
|
const runtimeProfileBaseUrls = {
|
|
@@ -122642,7 +122791,6 @@ var init_cpp_worker_client = __esm({
|
|
|
122642
122791
|
});
|
|
122643
122792
|
}
|
|
122644
122793
|
async executeProjectCpp(request, timeoutMs = this.executionTimeoutMs, onEvent, signal = request.signal, engineLease) {
|
|
122645
|
-
engineLease?.attach({ release: () => void 0 });
|
|
122646
122794
|
if (request.source === "compile" && this.options.trustedCompilerService) {
|
|
122647
122795
|
const {
|
|
122648
122796
|
signal: _signal,
|
|
@@ -122711,6 +122859,7 @@ var init_cpp_worker_client = __esm({
|
|
|
122711
122859
|
}]
|
|
122712
122860
|
};
|
|
122713
122861
|
}
|
|
122862
|
+
engineLease?.attach({ release: () => void 0 });
|
|
122714
122863
|
return this.runInDisposableExecutionWorker(async (lifecycleGeneration) => {
|
|
122715
122864
|
const {
|
|
122716
122865
|
signal: _signal,
|
|
@@ -123370,6 +123519,14 @@ var init_tracecc_compiler_service = __esm({
|
|
|
123370
123519
|
}, this.requestTimeoutMs);
|
|
123371
123520
|
worker.onmessage = (event) => {
|
|
123372
123521
|
const message = event.data;
|
|
123522
|
+
if (message.type === "idle-timeout") {
|
|
123523
|
+
if (generation === this.generation) {
|
|
123524
|
+
this.reset(
|
|
123525
|
+
new Error("TraceCC compiler Worker closed after idle timeout.")
|
|
123526
|
+
);
|
|
123527
|
+
}
|
|
123528
|
+
return;
|
|
123529
|
+
}
|
|
123373
123530
|
if (message.type === "worker-ready") {
|
|
123374
123531
|
globalThis.clearTimeout(readyTimeout);
|
|
123375
123532
|
resolve();
|
|
@@ -123740,7 +123897,7 @@ function normalizeAssetBaseUrl(value) {
|
|
|
123740
123897
|
}
|
|
123741
123898
|
return normalized;
|
|
123742
123899
|
}
|
|
123743
|
-
function
|
|
123900
|
+
function normalizeWorkerUrl2(value) {
|
|
123744
123901
|
const normalized = value.trim();
|
|
123745
123902
|
if (!normalized) {
|
|
123746
123903
|
throw new TypeError("TraceCC worker URL must not be empty.");
|
|
@@ -123761,7 +123918,7 @@ function descriptor2(asset) {
|
|
|
123761
123918
|
}
|
|
123762
123919
|
function createTraceCCRuntimeManifest(assetBaseUrl, options = {}) {
|
|
123763
123920
|
const normalizedAssetBaseUrl = normalizeAssetBaseUrl(assetBaseUrl);
|
|
123764
|
-
const workerUrl =
|
|
123921
|
+
const workerUrl = normalizeWorkerUrl2(
|
|
123765
123922
|
options.workerUrl ?? "/workers/cpp-worker.js"
|
|
123766
123923
|
);
|
|
123767
123924
|
const compilerWasm = descriptor2(
|
|
@@ -204596,20 +204753,27 @@ var RuntimeProjectWorkspaceTerminalSession = class {
|
|
|
204596
204753
|
signalCharacter === "" ? "SIGINT" : "SIGQUIT"
|
|
204597
204754
|
);
|
|
204598
204755
|
}
|
|
204599
|
-
const
|
|
204756
|
+
const routed = this.options.terminalInputRouter?.write(data);
|
|
204757
|
+
const route = routed === "rejected" && this.activeStdinPipe !== null ? "legacy" : routed ?? (this.activeStdinPipe !== null ? "legacy" : "rejected");
|
|
204600
204758
|
if (route === "legacy") {
|
|
204601
|
-
this.activeStdinPipe
|
|
204759
|
+
if (!this.activeStdinPipe) return false;
|
|
204760
|
+
try {
|
|
204761
|
+
this.activeStdinPipe.write(data);
|
|
204762
|
+
} catch {
|
|
204763
|
+
return false;
|
|
204764
|
+
}
|
|
204602
204765
|
}
|
|
204603
204766
|
const accepted = route !== "rejected";
|
|
204604
204767
|
if (accepted && this.currentInputState.mode === "stdin") {
|
|
204605
204768
|
this.activeStdinPrompt = "";
|
|
204606
|
-
this.setInputState("
|
|
204769
|
+
this.setInputState("stdin", "stdin-submit", "");
|
|
204607
204770
|
}
|
|
204608
204771
|
return accepted;
|
|
204609
204772
|
}
|
|
204610
204773
|
endStdin() {
|
|
204611
204774
|
if (!this.activeRun || this.activeStdinEnded) return false;
|
|
204612
|
-
const
|
|
204775
|
+
const routed = this.options.terminalInputRouter?.end();
|
|
204776
|
+
const route = routed === "rejected" && this.activeStdinPipe !== null ? "legacy" : routed ?? (this.activeStdinPipe !== null ? "legacy" : "rejected");
|
|
204613
204777
|
if (route === "rejected") return false;
|
|
204614
204778
|
this.activeStdinEnded = true;
|
|
204615
204779
|
if (route === "legacy") {
|
|
@@ -204648,6 +204812,14 @@ var RuntimeProjectWorkspaceTerminalSession = class {
|
|
|
204648
204812
|
this.emitTerminalEvent(reason);
|
|
204649
204813
|
return this.currentInputState;
|
|
204650
204814
|
}
|
|
204815
|
+
showForegroundInputLine() {
|
|
204816
|
+
const acceptsInput = this.activeStdinPipe !== null || this.options.terminalInputRouter !== void 0;
|
|
204817
|
+
return this.setInputState(
|
|
204818
|
+
acceptsInput ? "stdin" : "busy",
|
|
204819
|
+
"command-start",
|
|
204820
|
+
acceptsInput ? "" : this.prompt.text
|
|
204821
|
+
);
|
|
204822
|
+
}
|
|
204651
204823
|
async run(command, options = {}) {
|
|
204652
204824
|
const trimmed = command.trim();
|
|
204653
204825
|
if (!trimmed) return { stdout: "", stderr: "", exitCode: 0 };
|
|
@@ -204702,7 +204874,7 @@ var RuntimeProjectWorkspaceTerminalSession = class {
|
|
|
204702
204874
|
this.activeTerminalEventHandler = options.onTerminalEvent;
|
|
204703
204875
|
this.activeStdinPrompt = "";
|
|
204704
204876
|
this.activeCommand = submittedCommand;
|
|
204705
|
-
this.
|
|
204877
|
+
this.showForegroundInputLine();
|
|
204706
204878
|
try {
|
|
204707
204879
|
let stdout = "";
|
|
204708
204880
|
let stderr = "";
|
|
@@ -204731,6 +204903,7 @@ var RuntimeProjectWorkspaceTerminalSession = class {
|
|
|
204731
204903
|
...error ? { error } : {}
|
|
204732
204904
|
};
|
|
204733
204905
|
} finally {
|
|
204906
|
+
this.options.terminalInputRouter?.reset();
|
|
204734
204907
|
ownedStdinPipe?.close();
|
|
204735
204908
|
this.activeStdinPipe = previousStdinPipe;
|
|
204736
204909
|
this.activeStdinEnded = previousStdinEnded;
|
|
@@ -204769,7 +204942,7 @@ var RuntimeProjectWorkspaceTerminalSession = class {
|
|
|
204769
204942
|
this.activeStdinPrompt = "";
|
|
204770
204943
|
this.activeCommand = trimmed;
|
|
204771
204944
|
this.activeCommandAbortController = commandAbortController;
|
|
204772
|
-
this.
|
|
204945
|
+
this.showForegroundInputLine();
|
|
204773
204946
|
try {
|
|
204774
204947
|
const result = await this.runForegroundTerminalCommand(
|
|
204775
204948
|
trimmed,
|
|
@@ -204780,6 +204953,7 @@ var RuntimeProjectWorkspaceTerminalSession = class {
|
|
|
204780
204953
|
return result;
|
|
204781
204954
|
} finally {
|
|
204782
204955
|
options.signal?.removeEventListener("abort", forwardExternalAbort);
|
|
204956
|
+
this.options.terminalInputRouter?.reset();
|
|
204783
204957
|
ownedStdinPipe?.close();
|
|
204784
204958
|
this.activeStdinPipe = previousStdinPipe;
|
|
204785
204959
|
this.activeStdinEnded = previousStdinEnded;
|
|
@@ -210407,21 +210581,26 @@ function createWorkspaceRuntimeRunnerBridge(bridge) {
|
|
|
210407
210581
|
...requestWithoutLegacyStdin
|
|
210408
210582
|
} = request;
|
|
210409
210583
|
const activeStdinPipe = request.source !== "compile" && request.source !== "stdin" ? commandContext?.stdinPipe : void 0;
|
|
210584
|
+
const consumesLiveStdin = request.source !== "compile" && request.source !== "stdin";
|
|
210410
210585
|
const stdinPipe = request.stdinPipe ?? activeStdinPipe;
|
|
210411
|
-
const processBinding = commandContext ? bridge.bindProcess(
|
|
210586
|
+
const processBinding = commandContext ? bridge.bindProcess(
|
|
210587
|
+
commandContext,
|
|
210588
|
+
descriptorStdio,
|
|
210589
|
+
consumesLiveStdin
|
|
210590
|
+
) : {};
|
|
210412
210591
|
const signal = processBinding.signal ?? request.signal;
|
|
210413
210592
|
const runtimeIo = commandContext?.runtimeIo;
|
|
210414
210593
|
let acceptingRunnerEvents = true;
|
|
210415
210594
|
let result;
|
|
210416
210595
|
const kernelSyscalls = options.kernelSyscalls ? bridge.createKernelSyscallBridge(commandContext) : void 0;
|
|
210417
|
-
if (descriptorStdio && commandContext) {
|
|
210596
|
+
if (descriptorStdio && commandContext && consumesLiveStdin) {
|
|
210418
210597
|
bridge.startHostStandardInputPump(commandContext);
|
|
210419
210598
|
}
|
|
210420
210599
|
try {
|
|
210421
|
-
|
|
210422
|
-
...descriptorStdio ? requestWithoutLegacyStdin : request,
|
|
210600
|
+
const execution = runner({
|
|
210601
|
+
...descriptorStdio || !consumesLiveStdin ? requestWithoutLegacyStdin : request,
|
|
210423
210602
|
...processBinding.process ? { process: processBinding.process } : {},
|
|
210424
|
-
...stdinPipe && !descriptorStdio ? { stdinPipe: { buffer: stdinPipe.buffer } } : {},
|
|
210603
|
+
...stdinPipe && !descriptorStdio && consumesLiveStdin ? { stdinPipe: { buffer: stdinPipe.buffer } } : {},
|
|
210425
210604
|
...commandContext?.terminal ? { terminal: commandContext.terminal } : {},
|
|
210426
210605
|
...commandContext?.engineLease ? { engineLease: commandContext.engineLease } : {},
|
|
210427
210606
|
...signal ? { signal } : {},
|
|
@@ -210433,6 +210612,8 @@ function createWorkspaceRuntimeRunnerBridge(bridge) {
|
|
|
210433
210612
|
bridge.handleRuntimeCommandEvent(event, commandContext);
|
|
210434
210613
|
}
|
|
210435
210614
|
});
|
|
210615
|
+
await processBinding.replayStartupInput?.();
|
|
210616
|
+
result = await execution;
|
|
210436
210617
|
} finally {
|
|
210437
210618
|
acceptingRunnerEvents = false;
|
|
210438
210619
|
kernelSyscalls?.close();
|
|
@@ -211310,6 +211491,7 @@ function createRuntimeWorkspaceShellCommands(options) {
|
|
|
211310
211491
|
var PRINCIPAL_ACTOR2 = runtimeWorkspaceActorPreset("principal");
|
|
211311
211492
|
var RUNTIME_ACTOR = runtimeWorkspaceActorPreset("runtime");
|
|
211312
211493
|
var SYSTEM_ACTOR2 = runtimeWorkspaceActorPreset("system");
|
|
211494
|
+
var TERMINAL_STARTUP_INPUT_MAX_BYTES = 64 * 1024 - 1;
|
|
211313
211495
|
var TRACEKERNEL_SYSCALL_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
211314
211496
|
"E2BIG",
|
|
211315
211497
|
"EAGAIN",
|
|
@@ -211443,6 +211625,7 @@ var RuntimeProjectWorkspace = class {
|
|
|
211443
211625
|
processState = new WorkspaceProcessState();
|
|
211444
211626
|
terminalShells = /* @__PURE__ */ new Map();
|
|
211445
211627
|
terminalResourceIds = /* @__PURE__ */ new Map();
|
|
211628
|
+
pendingTerminalStartupInput = /* @__PURE__ */ new Map();
|
|
211446
211629
|
processProjection;
|
|
211447
211630
|
// Temporary 0.13 introspection aliases. The process state module remains
|
|
211448
211631
|
// authoritative; these preserve existing hardening probes while 0.14 moves
|
|
@@ -211624,17 +211807,24 @@ var RuntimeProjectWorkspace = class {
|
|
|
211624
211807
|
});
|
|
211625
211808
|
const withEvents = createWorkspaceRuntimeRunnerBridge({
|
|
211626
211809
|
resolveCommandContext: (context2) => this.resolveCommandContext(context2),
|
|
211627
|
-
bindProcess: (context2, descriptorStdio) => {
|
|
211810
|
+
bindProcess: (context2, descriptorStdio, consumesLiveStdin) => {
|
|
211628
211811
|
const executionHandle = this.processProjection.executionHandle(
|
|
211629
211812
|
context2.process
|
|
211630
211813
|
);
|
|
211631
211814
|
if (executionHandle) {
|
|
211632
211815
|
executionHandle.descriptorStdio = descriptorStdio;
|
|
211816
|
+
executionHandle.consumesLiveStdin = consumesLiveStdin;
|
|
211633
211817
|
}
|
|
211634
211818
|
const processSnapshot = this.processProjection.authoritativeSnapshot(
|
|
211635
211819
|
context2.process
|
|
211636
211820
|
);
|
|
211637
211821
|
return {
|
|
211822
|
+
replayStartupInput: () => this.resolvePendingTerminalStartupInput(
|
|
211823
|
+
context2.process.pid,
|
|
211824
|
+
descriptorStdio,
|
|
211825
|
+
context2.stdinPipe,
|
|
211826
|
+
consumesLiveStdin
|
|
211827
|
+
),
|
|
211638
211828
|
...executionHandle?.abortController?.signal ? { signal: executionHandle.abortController.signal } : {},
|
|
211639
211829
|
...executionHandle?.signalChannel ? { kernelSignals: executionHandle.signalChannel } : {},
|
|
211640
211830
|
...processSnapshot ? {
|
|
@@ -214182,24 +214372,106 @@ var RuntimeProjectWorkspace = class {
|
|
|
214182
214372
|
)
|
|
214183
214373
|
);
|
|
214184
214374
|
}
|
|
214185
|
-
kernelTerminalInputRoute(terminal) {
|
|
214375
|
+
kernelTerminalInputRoute(terminalSessionId, terminal) {
|
|
214186
214376
|
const hasDescriptorConsumer = this.traceKernelAuthority?.session.processSnapshots().some(
|
|
214187
|
-
(process32) => process32.sid === terminal.sessionId && process32.pgid === terminal.foregroundProcessGroupId && this.processState.executionHandles.get(process32.pid)?.descriptorStdio === true
|
|
214377
|
+
(process32) => process32.sid === terminal.sessionId && process32.pgid === terminal.foregroundProcessGroupId && this.processState.executionHandles.get(process32.pid)?.descriptorStdio === true && this.processState.executionHandles.get(process32.pid)?.consumesLiveStdin === true
|
|
214188
214378
|
) === true;
|
|
214189
|
-
|
|
214379
|
+
if (hasDescriptorConsumer) return "kernel";
|
|
214380
|
+
const foregroundPid = this.processState.terminalForeground.get(
|
|
214381
|
+
terminalSessionId
|
|
214382
|
+
);
|
|
214383
|
+
if (foregroundPid === void 0) return "pending";
|
|
214384
|
+
const executionHandle = this.processState.executionHandles.get(foregroundPid);
|
|
214385
|
+
if (executionHandle?.consumesLiveStdin !== true) return "pending";
|
|
214386
|
+
const descriptorStdio = executionHandle.descriptorStdio;
|
|
214387
|
+
return descriptorStdio === void 0 ? "pending" : descriptorStdio ? "kernel" : "legacy";
|
|
214388
|
+
}
|
|
214389
|
+
queueTerminalStartupInput(terminalSessionId, input = {}) {
|
|
214390
|
+
const pending2 = this.pendingTerminalStartupInput.get(terminalSessionId) ?? {
|
|
214391
|
+
chunks: [],
|
|
214392
|
+
byteLength: 0,
|
|
214393
|
+
eof: false
|
|
214394
|
+
};
|
|
214395
|
+
if (input.data) {
|
|
214396
|
+
const byteLength = new TextEncoder().encode(input.data).byteLength;
|
|
214397
|
+
if (pending2.byteLength + byteLength > TERMINAL_STARTUP_INPUT_MAX_BYTES) {
|
|
214398
|
+
return false;
|
|
214399
|
+
}
|
|
214400
|
+
pending2.chunks.push(input.data);
|
|
214401
|
+
pending2.byteLength += byteLength;
|
|
214402
|
+
}
|
|
214403
|
+
if (input.eof) pending2.eof = true;
|
|
214404
|
+
this.pendingTerminalStartupInput.set(terminalSessionId, pending2);
|
|
214405
|
+
return true;
|
|
214190
214406
|
}
|
|
214191
|
-
|
|
214407
|
+
async resolvePendingTerminalStartupInput(foregroundPid, descriptorStdio, stdinPipe, consumesLiveStdin = true) {
|
|
214408
|
+
const boundProcess = this.processProjection.find(foregroundPid);
|
|
214409
|
+
const boundSnapshot = boundProcess ? this.processProjection.authoritativeSnapshot(boundProcess) : void 0;
|
|
214410
|
+
const terminalSessionId = [...this.processState.terminalForeground].find(([, pid]) => {
|
|
214411
|
+
if (pid === foregroundPid) return true;
|
|
214412
|
+
const terminalProcess = this.processProjection.find(pid);
|
|
214413
|
+
const terminalSnapshot = terminalProcess ? this.processProjection.authoritativeSnapshot(terminalProcess) : void 0;
|
|
214414
|
+
return Boolean(
|
|
214415
|
+
boundSnapshot && terminalSnapshot && boundSnapshot.pgid === terminalSnapshot.pgid
|
|
214416
|
+
);
|
|
214417
|
+
})?.[0];
|
|
214418
|
+
if (!terminalSessionId) return;
|
|
214419
|
+
const pending2 = this.pendingTerminalStartupInput.get(terminalSessionId);
|
|
214420
|
+
if (!pending2) return;
|
|
214421
|
+
if (!consumesLiveStdin) return;
|
|
214422
|
+
this.pendingTerminalStartupInput.delete(terminalSessionId);
|
|
214423
|
+
if (!descriptorStdio) {
|
|
214424
|
+
if (!stdinPipe) return;
|
|
214425
|
+
try {
|
|
214426
|
+
for (const chunk2 of pending2.chunks) stdinPipe.write(chunk2);
|
|
214427
|
+
if (pending2.eof) stdinPipe.close();
|
|
214428
|
+
} catch {
|
|
214429
|
+
stdinPipe.close();
|
|
214430
|
+
}
|
|
214431
|
+
return;
|
|
214432
|
+
}
|
|
214192
214433
|
const authority = this.traceKernelAuthority;
|
|
214193
214434
|
const terminalId = this.terminalResourceIds.get(terminalSessionId);
|
|
214194
214435
|
const terminal = terminalId === void 0 ? void 0 : authority?.session.terminalSnapshots().find(
|
|
214195
214436
|
(candidate) => candidate.id === terminalId
|
|
214196
214437
|
);
|
|
214197
|
-
if (!authority || !terminal || terminal.closed) return
|
|
214438
|
+
if (!authority || !terminal || terminal.closed) return;
|
|
214439
|
+
const bytes = new TextEncoder().encode(pending2.chunks.join(""));
|
|
214440
|
+
await runPromise(
|
|
214441
|
+
gen2(function* () {
|
|
214442
|
+
if (bytes.byteLength > 0) {
|
|
214443
|
+
yield* authority.session.writeTerminalInput(terminal.id, bytes);
|
|
214444
|
+
}
|
|
214445
|
+
if (pending2.eof) {
|
|
214446
|
+
yield* authority.session.sendTerminalInputEof(terminal.id);
|
|
214447
|
+
}
|
|
214448
|
+
}).pipe(catchAll2(() => _void))
|
|
214449
|
+
);
|
|
214450
|
+
}
|
|
214451
|
+
discardPendingTerminalStartupInput(terminalSessionId, foregroundPid) {
|
|
214452
|
+
if (terminalSessionId && (foregroundPid === void 0 || this.processState.terminalForeground.get(terminalSessionId) === foregroundPid)) {
|
|
214453
|
+
this.pendingTerminalStartupInput.delete(terminalSessionId);
|
|
214454
|
+
}
|
|
214455
|
+
}
|
|
214456
|
+
writeKernelTerminalInput(terminalSessionId, data) {
|
|
214198
214457
|
const signalByte = new TextEncoder().encode(data).find(
|
|
214199
214458
|
(byte) => byte === 3 || byte === 28
|
|
214200
214459
|
);
|
|
214201
|
-
|
|
214202
|
-
|
|
214460
|
+
const authority = this.traceKernelAuthority;
|
|
214461
|
+
const terminalId = this.terminalResourceIds.get(terminalSessionId);
|
|
214462
|
+
const terminal = terminalId === void 0 ? void 0 : authority?.session.terminalSnapshots().find(
|
|
214463
|
+
(candidate) => candidate.id === terminalId
|
|
214464
|
+
);
|
|
214465
|
+
if (!authority || !terminal || terminal.closed) {
|
|
214466
|
+
if (signalByte !== void 0) return "rejected";
|
|
214467
|
+
return this.queueTerminalStartupInput(terminalSessionId, { data }) ? "pending" : "rejected";
|
|
214468
|
+
}
|
|
214469
|
+
if (signalByte === void 0) {
|
|
214470
|
+
const route = this.kernelTerminalInputRoute(terminalSessionId, terminal);
|
|
214471
|
+
if (route === "pending") {
|
|
214472
|
+
return this.queueTerminalStartupInput(terminalSessionId, { data }) ? "pending" : "rejected";
|
|
214473
|
+
}
|
|
214474
|
+
if (route === "legacy") return "legacy";
|
|
214203
214475
|
}
|
|
214204
214476
|
if (signalByte !== void 0) {
|
|
214205
214477
|
const signal = signalByte === 3 ? "SIGINT" : "SIGQUIT";
|
|
@@ -214229,8 +214501,16 @@ var RuntimeProjectWorkspace = class {
|
|
|
214229
214501
|
const terminal = terminalId === void 0 ? void 0 : authority?.session.terminalSnapshots().find(
|
|
214230
214502
|
(candidate) => candidate.id === terminalId
|
|
214231
214503
|
);
|
|
214232
|
-
if (!authority || !terminal || terminal.closed)
|
|
214233
|
-
|
|
214504
|
+
if (!authority || !terminal || terminal.closed) {
|
|
214505
|
+
this.queueTerminalStartupInput(terminalSessionId, { eof: true });
|
|
214506
|
+
return "pending";
|
|
214507
|
+
}
|
|
214508
|
+
const route = this.kernelTerminalInputRoute(terminalSessionId, terminal);
|
|
214509
|
+
if (route === "pending") {
|
|
214510
|
+
this.queueTerminalStartupInput(terminalSessionId, { eof: true });
|
|
214511
|
+
return "pending";
|
|
214512
|
+
}
|
|
214513
|
+
if (route === "legacy") return "legacy";
|
|
214234
214514
|
runFork2(
|
|
214235
214515
|
authority.session.sendTerminalInputEof(terminal.id).pipe(
|
|
214236
214516
|
catchAll2(() => _void)
|
|
@@ -215384,6 +215664,10 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
|
|
|
215384
215664
|
executionHandle.signalChannel?.close();
|
|
215385
215665
|
this.processState.executionHandles.delete(process32.pid);
|
|
215386
215666
|
if (options.terminalSessionId && this.processState.terminalForeground.get(options.terminalSessionId) === process32.pid) {
|
|
215667
|
+
this.discardPendingTerminalStartupInput(
|
|
215668
|
+
options.terminalSessionId,
|
|
215669
|
+
process32.pid
|
|
215670
|
+
);
|
|
215387
215671
|
this.processState.terminalForeground.delete(options.terminalSessionId);
|
|
215388
215672
|
}
|
|
215389
215673
|
clearKernelSignalHandler();
|
|
@@ -215638,6 +215922,10 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
|
|
|
215638
215922
|
executionHandle.signalChannel?.close();
|
|
215639
215923
|
this.processState.executionHandles.delete(process32.pid);
|
|
215640
215924
|
if (options.terminalSessionId && this.processState.terminalForeground.get(options.terminalSessionId) === process32.pid) {
|
|
215925
|
+
this.discardPendingTerminalStartupInput(
|
|
215926
|
+
options.terminalSessionId,
|
|
215927
|
+
process32.pid
|
|
215928
|
+
);
|
|
215641
215929
|
this.processState.terminalForeground.delete(options.terminalSessionId);
|
|
215642
215930
|
}
|
|
215643
215931
|
this.observeKernelReparentedChildren(process32.pid);
|
|
@@ -215944,6 +216232,7 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
|
|
|
215944
216232
|
const shellPromise = this.terminalShells.get(terminalSessionId);
|
|
215945
216233
|
this.terminalShells.delete(terminalSessionId);
|
|
215946
216234
|
this.terminalResourceIds.delete(terminalSessionId);
|
|
216235
|
+
this.pendingTerminalStartupInput.delete(terminalSessionId);
|
|
215947
216236
|
if (!shellPromise) return;
|
|
215948
216237
|
const disposal = shellPromise.then(async (shell) => {
|
|
215949
216238
|
const authority = this.traceKernelAuthority;
|
|
@@ -215998,7 +216287,8 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
|
|
|
215998
216287
|
signalForeground: (signal) => this.signalTerminalForeground(terminalSessionId, signal),
|
|
215999
216288
|
terminalInputRouter: {
|
|
216000
216289
|
write: (data) => this.writeKernelTerminalInput(terminalSessionId, data),
|
|
216001
|
-
end: () => this.endKernelTerminalInput(terminalSessionId)
|
|
216290
|
+
end: () => this.endKernelTerminalInput(terminalSessionId),
|
|
216291
|
+
reset: () => this.discardPendingTerminalStartupInput(terminalSessionId)
|
|
216002
216292
|
},
|
|
216003
216293
|
resizeTerminal: (columns, rows) => this.resizeKernelTerminal(terminalSessionId, columns, rows),
|
|
216004
216294
|
closeTerminal: () => this.closeTerminalShell(terminalSessionId),
|
|
@@ -216112,13 +216402,14 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
|
|
|
216112
216402
|
const descriptorStdio = this.cppRunner.capabilities?.descriptorStdio === true;
|
|
216113
216403
|
if (executionHandle) {
|
|
216114
216404
|
executionHandle.descriptorStdio = descriptorStdio;
|
|
216405
|
+
executionHandle.consumesLiveStdin = true;
|
|
216115
216406
|
}
|
|
216116
216407
|
if (descriptorStdio) {
|
|
216117
216408
|
this.startHostStandardInputPump(request.commandContext);
|
|
216118
216409
|
}
|
|
216119
216410
|
let result;
|
|
216120
216411
|
try {
|
|
216121
|
-
|
|
216412
|
+
const execution = this.cppRunner({
|
|
216122
216413
|
code: "",
|
|
216123
216414
|
source: "run",
|
|
216124
216415
|
scriptPath,
|
|
@@ -216143,6 +216434,12 @@ usage: tracekernelctl {status|reset|verbose [on|off|status]|kill <pid> [signal]|
|
|
|
216143
216434
|
this.handleRuntimeCommandEvent(event, request.commandContext);
|
|
216144
216435
|
}
|
|
216145
216436
|
});
|
|
216437
|
+
await this.resolvePendingTerminalStartupInput(
|
|
216438
|
+
request.commandContext.process.pid,
|
|
216439
|
+
descriptorStdio,
|
|
216440
|
+
request.stdinPipe
|
|
216441
|
+
);
|
|
216442
|
+
result = await execution;
|
|
216146
216443
|
} finally {
|
|
216147
216444
|
kernelSyscalls?.close();
|
|
216148
216445
|
}
|
|
@@ -219048,6 +219345,7 @@ async function createBrowserProjectWorkspace(options = {}) {
|
|
|
219048
219345
|
runtimeProviders: _runtimeProviders,
|
|
219049
219346
|
java,
|
|
219050
219347
|
javaRuntimeAssetBaseUrl,
|
|
219348
|
+
javaProjectWorkerUrl,
|
|
219051
219349
|
executionHost: executionHostOptions,
|
|
219052
219350
|
nodeProject,
|
|
219053
219351
|
typescriptProject,
|
|
@@ -219215,7 +219513,8 @@ async function createBrowserProjectWorkspace(options = {}) {
|
|
|
219215
219513
|
const builtInJavaFactory = hasProvider("java") && !java && !injectedJavaProvider && builtInJavaAvailable && javaProvider ? javaProvider[2].createJavaProjectClientFactory({
|
|
219216
219514
|
runtimeAssetBaseUrl: javaRuntimeAssetBaseUrl ?? javaProvider[2].resolveBuiltInTraceJVMRuntimeAssetBaseUrl(
|
|
219217
219515
|
options.assetBaseUrl ?? "/workers"
|
|
219218
|
-
)
|
|
219516
|
+
),
|
|
219517
|
+
workerUrl: javaProjectWorkerUrl ?? `${javaProvider[2].resolveBuiltInTraceJVMRuntimeAssetBaseUrl()}/browser-worker.js`
|
|
219219
219518
|
}) : void 0;
|
|
219220
219519
|
if (builtInJavaFactory) ownedWorkers.push(builtInJavaFactory);
|
|
219221
219520
|
const builtInJava = builtInJavaFactory ? {
|