@mutagent/cli 0.1.363 → 0.1.364
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/dist/bin/cli.js +35 -3
- package/package.json +1 -1
package/dist/bin/cli.js
CHANGED
|
@@ -25554,6 +25554,8 @@ function delay(ms, signal) {
|
|
|
25554
25554
|
}
|
|
25555
25555
|
|
|
25556
25556
|
// src/lib/helix-native-session.ts
|
|
25557
|
+
var TEARDOWN_SIGNALS = ["SIGTERM", "SIGHUP"];
|
|
25558
|
+
var EOF_SETTLE_MS = 100;
|
|
25557
25559
|
async function runNativeSession(options) {
|
|
25558
25560
|
const controller = new AbortController;
|
|
25559
25561
|
const inputController = new AbortController;
|
|
@@ -25615,6 +25617,24 @@ async function runNativeSession(options) {
|
|
|
25615
25617
|
});
|
|
25616
25618
|
};
|
|
25617
25619
|
process.on("SIGINT", onSigint);
|
|
25620
|
+
const guardsEof = options.rpc && options.closeInput !== undefined;
|
|
25621
|
+
const parentPid = process.ppid;
|
|
25622
|
+
const onTeardown = (sig) => {
|
|
25623
|
+
detach();
|
|
25624
|
+
removeTeardownListeners();
|
|
25625
|
+
if (process.listenerCount(sig) === 0)
|
|
25626
|
+
process.kill(process.pid, sig);
|
|
25627
|
+
};
|
|
25628
|
+
const teardownListeners = TEARDOWN_SIGNALS.map((sig) => [sig, () => {
|
|
25629
|
+
onTeardown(sig);
|
|
25630
|
+
}]);
|
|
25631
|
+
const removeTeardownListeners = () => {
|
|
25632
|
+
for (const [sig, listener] of teardownListeners)
|
|
25633
|
+
process.removeListener(sig, listener);
|
|
25634
|
+
};
|
|
25635
|
+
if (guardsEof)
|
|
25636
|
+
for (const [sig, listener] of teardownListeners)
|
|
25637
|
+
process.on(sig, listener);
|
|
25618
25638
|
options.signal?.addEventListener("abort", detach, { once: true });
|
|
25619
25639
|
if (options.signal?.aborted)
|
|
25620
25640
|
detach();
|
|
@@ -25641,10 +25661,21 @@ async function runNativeSession(options) {
|
|
|
25641
25661
|
}
|
|
25642
25662
|
if (inputController.signal.aborted || !inputState.ended)
|
|
25643
25663
|
return;
|
|
25644
|
-
|
|
25664
|
+
const closeInput = options.closeInput;
|
|
25665
|
+
if (closeInput === undefined) {
|
|
25645
25666
|
throw new MutagentError("NOT_SUPPORTED", "This transport cannot forward native stdin EOF.", "Use a server and image with explicit close-input support; no signal was sent.", 1);
|
|
25646
25667
|
}
|
|
25647
|
-
|
|
25668
|
+
await new Promise((resolve9) => {
|
|
25669
|
+
setTimeout(resolve9, EOF_SETTLE_MS);
|
|
25670
|
+
});
|
|
25671
|
+
if (inputController.signal.aborted)
|
|
25672
|
+
return;
|
|
25673
|
+
if (process.ppid !== parentPid) {
|
|
25674
|
+
notice("The parent process exited; detaching. Session " + options.reference + " keeps its input open.");
|
|
25675
|
+
detach();
|
|
25676
|
+
return;
|
|
25677
|
+
}
|
|
25678
|
+
const closed = await closeInput(inputController.signal);
|
|
25648
25679
|
if (!closed.closed) {
|
|
25649
25680
|
throw new MutagentError("RPC_INPUT_REJECTED", "The session did not confirm stdin closure.", "Check the session: mutagent helix session ls. No signal was sent in place of EOF.", 1);
|
|
25650
25681
|
}
|
|
@@ -25718,6 +25749,7 @@ async function runNativeSession(options) {
|
|
|
25718
25749
|
await inputTask;
|
|
25719
25750
|
await interruptTask;
|
|
25720
25751
|
process.removeListener("SIGINT", onSigint);
|
|
25752
|
+
removeTeardownListeners();
|
|
25721
25753
|
if (options.rpc)
|
|
25722
25754
|
input2.removeListener("end", onInputEnd);
|
|
25723
25755
|
options.signal?.removeEventListener("abort", detach);
|
|
@@ -29356,4 +29388,4 @@ if (isAgentInvocation(rawArgs)) {
|
|
|
29356
29388
|
program.parse(argvForCommander, { from: "user" });
|
|
29357
29389
|
}
|
|
29358
29390
|
|
|
29359
|
-
//# debugId=
|
|
29391
|
+
//# debugId=B55AD472D31665B264756E2164756E21
|
package/package.json
CHANGED