@wrongstack/tools 0.310.1 → 0.313.0
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/_shell-pick.d.ts +5 -10
- package/dist/bash.js +184 -208
- package/dist/builtin.js +136 -172
- package/dist/index.js +136 -172
- package/dist/pack.js +136 -172
- package/dist/tool-tier.js +136 -172
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -9622,8 +9622,128 @@ import { buildChildEnv as buildChildEnv2 } from "@wrongstack/core/utils";
|
|
|
9622
9622
|
|
|
9623
9623
|
// src/bash.ts
|
|
9624
9624
|
init_output_spool();
|
|
9625
|
+
|
|
9626
|
+
// src/_shell-pick.ts
|
|
9627
|
+
var POSIX_DEFAULT = "cmd";
|
|
9628
|
+
function pickShell(platform7, command, env) {
|
|
9629
|
+
if (platform7 !== "win32") return POSIX_DEFAULT;
|
|
9630
|
+
const override = env.get("WRONGSTACK_SHELL")?.trim().toLowerCase();
|
|
9631
|
+
if (override === "cmd" || override === "cmd.exe") return "cmd";
|
|
9632
|
+
if (override === "powershell" || override === "powershell.exe") return "powershell";
|
|
9633
|
+
if (override === "pwsh" || override === "pwsh.exe") return "pwsh";
|
|
9634
|
+
if (looksLikePowerShell(command)) return "pwsh";
|
|
9635
|
+
return "cmd";
|
|
9636
|
+
}
|
|
9637
|
+
function looksLikePowerShell(command) {
|
|
9638
|
+
if (!command) return false;
|
|
9639
|
+
const trimmed = command.trimStart();
|
|
9640
|
+
if (/\.ps1\b/i.test(trimmed)) return true;
|
|
9641
|
+
if (/^\s*#requires\s/i.test(trimmed)) return true;
|
|
9642
|
+
if (/^\s*param\s*\(/i.test(trimmed)) return true;
|
|
9643
|
+
if (/\$[\w:{]/i.test(trimmed)) return true;
|
|
9644
|
+
if (/\$\(/.test(trimmed)) return true;
|
|
9645
|
+
if (/@\s*['"]/.test(trimmed)) return true;
|
|
9646
|
+
if (/&\s+\$/.test(trimmed)) return true;
|
|
9647
|
+
if (/(^|\s)@\s*\(/.test(trimmed)) return true;
|
|
9648
|
+
if (/(^|\s)@\{/.test(trimmed)) return true;
|
|
9649
|
+
if (/(?:^|[\s[({,;])(?:-eq|-ne|-lt|-gt|-le|-ge|-like|-notlike|-match|-notmatch|-contains|-notcontains|-in|-notin|-and|-or|-not|-band|-bor|-bxor|-replace|-isplit|-csplit|-osplit|-join|-is|-as|-f)(?:$|[\s\])},;])/i.test(
|
|
9650
|
+
trimmed
|
|
9651
|
+
)) {
|
|
9652
|
+
return true;
|
|
9653
|
+
}
|
|
9654
|
+
if (PS_VERB_RE.test(trimmed)) return true;
|
|
9655
|
+
if (/(?:^|[\s;&|])(gci|gi|gp|gcm|gps)\b/i.test(trimmed)) {
|
|
9656
|
+
return true;
|
|
9657
|
+
}
|
|
9658
|
+
if (looksLikePowerShellExtended(command)) return true;
|
|
9659
|
+
return false;
|
|
9660
|
+
}
|
|
9661
|
+
function looksLikePowerShellExtended(command) {
|
|
9662
|
+
if (!command) return false;
|
|
9663
|
+
const trimmed = command.trimStart();
|
|
9664
|
+
if (/(?:^|\s)[-/](?:WhatIf|Confirm|ErrorAction)(?::[^\s]+|\s|=|$)/i.test(trimmed)) {
|
|
9665
|
+
return true;
|
|
9666
|
+
}
|
|
9667
|
+
if (/(?:^|[\s;&|])(Where-Object|ForEach-Object|Select-Object|Sort-Object|Group-Object|Measure-Object|Compare-Object|Tee-Object)(?:\s|$)/i.test(
|
|
9668
|
+
trimmed
|
|
9669
|
+
)) {
|
|
9670
|
+
return true;
|
|
9671
|
+
}
|
|
9672
|
+
if (/\bWrite-(?:Host|Output|Error|Warning|Verbose|Debug|Information)(?:\s|$)/i.test(trimmed)) {
|
|
9673
|
+
return true;
|
|
9674
|
+
}
|
|
9675
|
+
if (/HK(?:LM|CU|CR|U|CC|DD|PD):\\/i.test(trimmed)) return true;
|
|
9676
|
+
if (/\[(?:string|int|bool|xml|double|float|decimal|char|byte|long|System\.)/i.test(trimmed)) {
|
|
9677
|
+
return true;
|
|
9678
|
+
}
|
|
9679
|
+
if (/^\s*<#|#>\s*$/m.test(trimmed)) return true;
|
|
9680
|
+
if (/(?:^|\s)[-//](?:AsPlainText|PipelineVariable|pv|FilterHashtable|OutVariable|ov)(?:\s|=|$)/i.test(
|
|
9681
|
+
trimmed
|
|
9682
|
+
)) {
|
|
9683
|
+
return true;
|
|
9684
|
+
}
|
|
9685
|
+
return false;
|
|
9686
|
+
}
|
|
9687
|
+
function wrapPowerShellScript(command) {
|
|
9688
|
+
const bootstrap = "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8;$ConfirmPreference='None';$WhatIfPreference=$false";
|
|
9689
|
+
return bootstrap + "\n$ErrorActionPreference='Stop'\n" + command + "\nif ($LASTEXITCODE -is [int]) { exit $LASTEXITCODE }";
|
|
9690
|
+
}
|
|
9691
|
+
var PS_VERB_RE = new RegExp(
|
|
9692
|
+
// Boundaries: start-of-string, whitespace, `;`, `&`, `|`, `(`, `{`, `,`.
|
|
9693
|
+
"(?:^|[\\s;&|\\(\\{,])(?:Get|Set|New|Remove|Add|Clear|Copy|Move|Rename|Test|Update|Write|Read|Push|Pop|Invoke|Start|Stop|Wait|Out|Format|Group|Measure|Compare|Resolve|ConvertTo|ConvertFrom|Convert|Import|Export|Select|Where|ForEach|Sort|Tee|Split|Join|Limit|Skip|Step|Trace|Debug|Register|Unregister|Enable|Disable|Restart|Suspend|Resume|Save|Open|Close|Lock|Unlock|Mount|Dismount|Enter|Exit|Use|Show|Hide|Find|Search|Watch|Initialize|Optimize|Compress|Expand|Merge|Checkpoint|Undo|Redo|Approve|Deny|Block|Grant|Revoke|Assert|Confirm|Receive|Send|Connect|Disconnect|Reset|Backup|Restore|Publish|Unpublish|Install|Uninstall|Build|Rebuild|Deploy|Submit|Process|Complete|Approve|Revoke|Pay|Refund|Decline|Receive|Send)-[A-Za-z][A-Za-z0-9]+(?:[\\-\\+][A-Za-z][A-Za-z0-9]+)*(?:$|[\\s\\-\\;\\&\\|\\(\\)\\{\\},])",
|
|
9694
|
+
"i"
|
|
9695
|
+
);
|
|
9696
|
+
function shellArgs(shell) {
|
|
9697
|
+
if (shell === "powershell" || shell === "pwsh") {
|
|
9698
|
+
return ["-NoLogo", "-NoProfile", "-NonInteractive", "-EncodedCommand"];
|
|
9699
|
+
}
|
|
9700
|
+
return ["/c"];
|
|
9701
|
+
}
|
|
9702
|
+
function diagnoseBashism(command, shell) {
|
|
9703
|
+
if (!command) return void 0;
|
|
9704
|
+
const isCmd = shell === "cmd";
|
|
9705
|
+
const hints = [];
|
|
9706
|
+
const add = (h) => {
|
|
9707
|
+
if (!hints.includes(h)) hints.push(h);
|
|
9708
|
+
};
|
|
9709
|
+
if (/\/dev\/null/.test(command)) {
|
|
9710
|
+
add(
|
|
9711
|
+
isCmd ? "use `nul` instead of `/dev/null` (e.g. `2>nul`)" : "use `$null` instead of `/dev/null` (e.g. `2>$null`)"
|
|
9712
|
+
);
|
|
9713
|
+
}
|
|
9714
|
+
if (/(^|[;&|]\s*)export\s+[A-Za-z_]\w*=/.test(command)) {
|
|
9715
|
+
add(
|
|
9716
|
+
isCmd ? "set env vars with `set NAME=value`, not `export`" : "set env vars with `$env:NAME = 'value'`, not `export`"
|
|
9717
|
+
);
|
|
9718
|
+
}
|
|
9719
|
+
if (/<<-?\s*['"]?[A-Za-z_]\w*/.test(command)) {
|
|
9720
|
+
add(
|
|
9721
|
+
isCmd ? "cmd has no heredocs \u2014 write the content to a file or use multiple `echo` lines" : "PowerShell has no heredocs \u2014 use a single-quoted here-string `@'\u2026'@` (closing `'@` at column 0)"
|
|
9722
|
+
);
|
|
9723
|
+
}
|
|
9724
|
+
if (shell === "powershell" && /(&&|\|\|)/.test(command)) {
|
|
9725
|
+
add(
|
|
9726
|
+
"Windows PowerShell 5.1 has no `&&`/`||` \u2014 separate commands with `;` (check `$LASTEXITCODE`)"
|
|
9727
|
+
);
|
|
9728
|
+
}
|
|
9729
|
+
if (/\brm\s+-[A-Za-z]*[rf]/.test(command)) {
|
|
9730
|
+
add(
|
|
9731
|
+
isCmd ? "`rm` is not a cmd builtin \u2014 use `del` (files) or `rmdir /s /q` (dirs)" : "use `Remove-Item -Recurse -Force` \u2014 the `rm -rf` bash flags don't exist in PowerShell"
|
|
9732
|
+
);
|
|
9733
|
+
}
|
|
9734
|
+
if (/\bwhich\s+\S/.test(command)) {
|
|
9735
|
+
add(
|
|
9736
|
+
isCmd ? "use `where <cmd>` instead of `which`" : "use `Get-Command <cmd>` instead of `which`"
|
|
9737
|
+
);
|
|
9738
|
+
}
|
|
9739
|
+
if (hints.length === 0) return void 0;
|
|
9740
|
+
const label = isCmd ? "cmd.exe" : shell === "pwsh" ? "PowerShell 7" : "Windows PowerShell";
|
|
9741
|
+
return `[wrongstack] This command failed and contains bash/POSIX syntax that ${label} does not accept \u2014 ${hints.join("; ")}. Rewrite it in ${isCmd ? "cmd" : "PowerShell"} syntax and retry.`;
|
|
9742
|
+
}
|
|
9743
|
+
|
|
9744
|
+
// src/bash.ts
|
|
9625
9745
|
init_util();
|
|
9626
|
-
|
|
9746
|
+
init_win32_resolve();
|
|
9627
9747
|
|
|
9628
9748
|
// src/bash-kill-guard.ts
|
|
9629
9749
|
import * as os3 from "node:os";
|
|
@@ -10470,126 +10590,8 @@ async function checkAndBlockKillCommand(command) {
|
|
|
10470
10590
|
return { blocked: false };
|
|
10471
10591
|
}
|
|
10472
10592
|
|
|
10473
|
-
// src/_shell-pick.ts
|
|
10474
|
-
var POSIX_DEFAULT = "cmd";
|
|
10475
|
-
function pickShell(platform7, command, env) {
|
|
10476
|
-
if (platform7 !== "win32") return POSIX_DEFAULT;
|
|
10477
|
-
const override = env.get("WRONGSTACK_SHELL")?.trim().toLowerCase();
|
|
10478
|
-
if (override === "cmd" || override === "cmd.exe") return "cmd";
|
|
10479
|
-
if (override === "powershell" || override === "powershell.exe") return "powershell";
|
|
10480
|
-
if (override === "pwsh" || override === "pwsh.exe") return "pwsh";
|
|
10481
|
-
if (looksLikePowerShell(command)) return "pwsh";
|
|
10482
|
-
return "cmd";
|
|
10483
|
-
}
|
|
10484
|
-
function looksLikePowerShell(command) {
|
|
10485
|
-
if (!command) return false;
|
|
10486
|
-
const trimmed = command.trimStart();
|
|
10487
|
-
if (/\.ps1\b/i.test(trimmed)) return true;
|
|
10488
|
-
if (/^\s*#requires\s/i.test(trimmed)) return true;
|
|
10489
|
-
if (/^\s*param\s*\(/i.test(trimmed)) return true;
|
|
10490
|
-
if (/\$[\w:{]/i.test(trimmed)) return true;
|
|
10491
|
-
if (/\$\(/.test(trimmed)) return true;
|
|
10492
|
-
if (/@\s*['"]/.test(trimmed)) return true;
|
|
10493
|
-
if (/&\s+\$/.test(trimmed)) return true;
|
|
10494
|
-
if (/(^|\s)@\s*\(/.test(trimmed)) return true;
|
|
10495
|
-
if (/(^|\s)@\{/.test(trimmed)) return true;
|
|
10496
|
-
if (/(?:^|[\s[({,;])(?:-eq|-ne|-lt|-gt|-le|-ge|-like|-notlike|-match|-notmatch|-contains|-notcontains|-in|-notin|-and|-or|-not|-band|-bor|-bxor|-replace|-isplit|-csplit|-osplit|-join|-is|-as|-f)(?:$|[\s\])},;])/i.test(
|
|
10497
|
-
trimmed
|
|
10498
|
-
)) {
|
|
10499
|
-
return true;
|
|
10500
|
-
}
|
|
10501
|
-
if (PS_VERB_RE.test(trimmed)) return true;
|
|
10502
|
-
if (/(?:^|[\s;&|])(gci|gi|gp|gcm|gps)\b/i.test(trimmed)) {
|
|
10503
|
-
return true;
|
|
10504
|
-
}
|
|
10505
|
-
if (looksLikePowerShellExtended(command)) return true;
|
|
10506
|
-
return false;
|
|
10507
|
-
}
|
|
10508
|
-
function looksLikePowerShellExtended(command) {
|
|
10509
|
-
if (!command) return false;
|
|
10510
|
-
const trimmed = command.trimStart();
|
|
10511
|
-
if (/(?:^|\s)[-/](?:WhatIf|Confirm|ErrorAction)(?::[^\s]+|\s|=|$)/i.test(trimmed)) {
|
|
10512
|
-
return true;
|
|
10513
|
-
}
|
|
10514
|
-
if (/(?:^|[\s;&|])(Where-Object|ForEach-Object|Select-Object|Sort-Object|Group-Object|Measure-Object|Compare-Object|Tee-Object)(?:\s|$)/i.test(
|
|
10515
|
-
trimmed
|
|
10516
|
-
)) {
|
|
10517
|
-
return true;
|
|
10518
|
-
}
|
|
10519
|
-
if (/\bWrite-(?:Host|Output|Error|Warning|Verbose|Debug|Information)(?:\s|$)/i.test(trimmed)) {
|
|
10520
|
-
return true;
|
|
10521
|
-
}
|
|
10522
|
-
if (/HK(?:LM|CU|CR|U|CC|DD|PD):\\/i.test(trimmed)) return true;
|
|
10523
|
-
if (/\[(?:string|int|bool|xml|double|float|decimal|char|byte|long|System\.)/i.test(trimmed)) {
|
|
10524
|
-
return true;
|
|
10525
|
-
}
|
|
10526
|
-
if (/^\s*<#|#>\s*$/m.test(trimmed)) return true;
|
|
10527
|
-
if (/(?:^|\s)[-//](?:AsPlainText|PipelineVariable|pv|FilterHashtable|OutVariable|ov)(?:\s|=|$)/i.test(
|
|
10528
|
-
trimmed
|
|
10529
|
-
)) {
|
|
10530
|
-
return true;
|
|
10531
|
-
}
|
|
10532
|
-
return false;
|
|
10533
|
-
}
|
|
10534
|
-
function wrapPowerShellScript(command) {
|
|
10535
|
-
const bootstrap = "[Console]::OutputEncoding = [System.Text.Encoding]::UTF8;$ConfirmPreference='None';$WhatIfPreference=$false";
|
|
10536
|
-
return bootstrap + "\n$ErrorActionPreference='Stop'\n" + command + "\nif ($LASTEXITCODE -is [int]) { exit $LASTEXITCODE }";
|
|
10537
|
-
}
|
|
10538
|
-
var PS_VERB_RE = new RegExp(
|
|
10539
|
-
// Boundaries: start-of-string, whitespace, `;`, `&`, `|`, `(`, `{`, `,`.
|
|
10540
|
-
"(?:^|[\\s;&|\\(\\{,])(?:Get|Set|New|Remove|Add|Clear|Copy|Move|Rename|Test|Update|Write|Read|Push|Pop|Invoke|Start|Stop|Wait|Out|Format|Group|Measure|Compare|Resolve|ConvertTo|ConvertFrom|Convert|Import|Export|Select|Where|ForEach|Sort|Tee|Split|Join|Limit|Skip|Step|Trace|Debug|Register|Unregister|Enable|Disable|Restart|Suspend|Resume|Save|Open|Close|Lock|Unlock|Mount|Dismount|Enter|Exit|Use|Show|Hide|Find|Search|Watch|Initialize|Optimize|Compress|Expand|Merge|Checkpoint|Undo|Redo|Approve|Deny|Block|Grant|Revoke|Assert|Confirm|Receive|Send|Connect|Disconnect|Reset|Backup|Restore|Publish|Unpublish|Install|Uninstall|Build|Rebuild|Deploy|Submit|Process|Complete|Approve|Revoke|Pay|Refund|Decline|Receive|Send)-[A-Za-z][A-Za-z0-9]+(?:[\\-\\+][A-Za-z][A-Za-z0-9]+)*(?:$|[\\s\\-\\;\\&\\|\\(\\)\\{\\},])",
|
|
10541
|
-
"i"
|
|
10542
|
-
);
|
|
10543
|
-
function shellArgs(shell) {
|
|
10544
|
-
if (shell === "powershell" || shell === "pwsh") {
|
|
10545
|
-
return ["-NoLogo", "-NoProfile", "-NonInteractive", "-Command", "-"];
|
|
10546
|
-
}
|
|
10547
|
-
return ["/c"];
|
|
10548
|
-
}
|
|
10549
|
-
function diagnoseBashism(command, shell) {
|
|
10550
|
-
if (!command) return void 0;
|
|
10551
|
-
const isCmd = shell === "cmd";
|
|
10552
|
-
const hints = [];
|
|
10553
|
-
const add = (h) => {
|
|
10554
|
-
if (!hints.includes(h)) hints.push(h);
|
|
10555
|
-
};
|
|
10556
|
-
if (/\/dev\/null/.test(command)) {
|
|
10557
|
-
add(
|
|
10558
|
-
isCmd ? "use `nul` instead of `/dev/null` (e.g. `2>nul`)" : "use `$null` instead of `/dev/null` (e.g. `2>$null`)"
|
|
10559
|
-
);
|
|
10560
|
-
}
|
|
10561
|
-
if (/(^|[;&|]\s*)export\s+[A-Za-z_]\w*=/.test(command)) {
|
|
10562
|
-
add(
|
|
10563
|
-
isCmd ? "set env vars with `set NAME=value`, not `export`" : "set env vars with `$env:NAME = 'value'`, not `export`"
|
|
10564
|
-
);
|
|
10565
|
-
}
|
|
10566
|
-
if (/<<-?\s*['"]?[A-Za-z_]\w*/.test(command)) {
|
|
10567
|
-
add(
|
|
10568
|
-
isCmd ? "cmd has no heredocs \u2014 write the content to a file or use multiple `echo` lines" : "PowerShell has no heredocs \u2014 use a single-quoted here-string `@'\u2026'@` (closing `'@` at column 0)"
|
|
10569
|
-
);
|
|
10570
|
-
}
|
|
10571
|
-
if (shell === "powershell" && /(&&|\|\|)/.test(command)) {
|
|
10572
|
-
add(
|
|
10573
|
-
"Windows PowerShell 5.1 has no `&&`/`||` \u2014 separate commands with `;` (check `$LASTEXITCODE`)"
|
|
10574
|
-
);
|
|
10575
|
-
}
|
|
10576
|
-
if (/\brm\s+-[A-Za-z]*[rf]/.test(command)) {
|
|
10577
|
-
add(
|
|
10578
|
-
isCmd ? "`rm` is not a cmd builtin \u2014 use `del` (files) or `rmdir /s /q` (dirs)" : "use `Remove-Item -Recurse -Force` \u2014 the `rm -rf` bash flags don't exist in PowerShell"
|
|
10579
|
-
);
|
|
10580
|
-
}
|
|
10581
|
-
if (/\bwhich\s+\S/.test(command)) {
|
|
10582
|
-
add(
|
|
10583
|
-
isCmd ? "use `where <cmd>` instead of `which`" : "use `Get-Command <cmd>` instead of `which`"
|
|
10584
|
-
);
|
|
10585
|
-
}
|
|
10586
|
-
if (hints.length === 0) return void 0;
|
|
10587
|
-
const label = isCmd ? "cmd.exe" : shell === "pwsh" ? "PowerShell 7" : "Windows PowerShell";
|
|
10588
|
-
return `[wrongstack] This command failed and contains bash/POSIX syntax that ${label} does not accept \u2014 ${hints.join("; ")}. Rewrite it in ${isCmd ? "cmd" : "PowerShell"} syntax and retry.`;
|
|
10589
|
-
}
|
|
10590
|
-
|
|
10591
10593
|
// src/bash.ts
|
|
10592
|
-
|
|
10594
|
+
init_process_registry();
|
|
10593
10595
|
var MAX_OUTPUT = 32768;
|
|
10594
10596
|
var DEFAULT_TIMEOUT_MS2 = 3e5;
|
|
10595
10597
|
var STREAM_FLUSH_INTERVAL_MS = 200;
|
|
@@ -10697,8 +10699,7 @@ var bashTool = {
|
|
|
10697
10699
|
plan = {
|
|
10698
10700
|
bin,
|
|
10699
10701
|
argv: shellArgs(shell2),
|
|
10700
|
-
|
|
10701
|
-
stdinBody: shell2 === "powershell" || shell2 === "pwsh" ? wrapPowerShellScript(input.command) : void 0
|
|
10702
|
+
commandArg: shell2 === "powershell" || shell2 === "pwsh" ? Buffer.from(wrapPowerShellScript(input.command), "utf16le").toString("base64") : input.command
|
|
10702
10703
|
};
|
|
10703
10704
|
} else {
|
|
10704
10705
|
const explicit = process.env["WRONGSTACK_SHELL"];
|
|
@@ -10712,10 +10713,10 @@ var bashTool = {
|
|
|
10712
10713
|
else bin = "/bin/bash";
|
|
10713
10714
|
} else bin = "/bin/bash";
|
|
10714
10715
|
}
|
|
10715
|
-
plan = { bin, argv: ["-c"],
|
|
10716
|
+
plan = { bin, argv: ["-c"], commandArg: input.command };
|
|
10716
10717
|
}
|
|
10717
10718
|
const shell = plan.bin;
|
|
10718
|
-
const args =
|
|
10719
|
+
const args = [...plan.argv, plan.commandArg];
|
|
10719
10720
|
const env = buildChildEnv2(ctx.session?.id);
|
|
10720
10721
|
const spawnCwd = ctx.workingDir ?? ctx.projectRoot;
|
|
10721
10722
|
const detached = !isWin5;
|
|
@@ -10724,26 +10725,10 @@ var bashTool = {
|
|
|
10724
10725
|
const child2 = spawn3(shell, args, {
|
|
10725
10726
|
cwd: spawnCwd,
|
|
10726
10727
|
env,
|
|
10727
|
-
|
|
10728
|
-
// and POSIX shells ignore stdin when given the command inline.
|
|
10729
|
-
stdio: [plan.useStdin ? "pipe" : "ignore", "ignore", "ignore"],
|
|
10730
|
-
// win32: CreateProcess IGNORES CREATE_NO_WINDOW (windowsHide) when
|
|
10731
|
-
// DETACHED_PROCESS (detached: true) is set, so the console-less
|
|
10732
|
-
// cmd.exe's grandchildren (node, dev servers) each allocate a fresh
|
|
10733
|
-
// VISIBLE console window. detached: false lets CREATE_NO_WINDOW
|
|
10734
|
-
// apply: the child gets a hidden console that grandchildren inherit.
|
|
10735
|
-
// Windows children survive parent exit either way. POSIX keeps
|
|
10736
|
-
// detached for the process-group kill semantics.
|
|
10728
|
+
stdio: ["ignore", "ignore", "ignore"],
|
|
10737
10729
|
detached: !isWin5,
|
|
10738
10730
|
windowsHide: true
|
|
10739
10731
|
});
|
|
10740
|
-
if (plan.useStdin) {
|
|
10741
|
-
try {
|
|
10742
|
-
child2.stdin?.write(plan.stdinBody ?? input.command);
|
|
10743
|
-
child2.stdin?.end();
|
|
10744
|
-
} catch {
|
|
10745
|
-
}
|
|
10746
|
-
}
|
|
10747
10732
|
const pid2 = child2.pid;
|
|
10748
10733
|
const stdoutBytes2 = 0;
|
|
10749
10734
|
const stderrBytes2 = 0;
|
|
@@ -10818,20 +10803,11 @@ var bashTool = {
|
|
|
10818
10803
|
const child = spawn3(shell, args, {
|
|
10819
10804
|
cwd: spawnCwd,
|
|
10820
10805
|
env,
|
|
10821
|
-
|
|
10822
|
-
// and POSIX shells ignore stdin when given the command inline.
|
|
10823
|
-
stdio: [plan.useStdin ? "pipe" : "ignore", "pipe", "pipe"],
|
|
10806
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
10824
10807
|
detached,
|
|
10825
10808
|
windowsHide: true,
|
|
10826
10809
|
...isWin5 ? {} : { signal: opts.signal }
|
|
10827
10810
|
});
|
|
10828
|
-
if (plan.useStdin) {
|
|
10829
|
-
try {
|
|
10830
|
-
child.stdin?.write(plan.stdinBody ?? input.command);
|
|
10831
|
-
child.stdin?.end();
|
|
10832
|
-
} catch {
|
|
10833
|
-
}
|
|
10834
|
-
}
|
|
10835
10811
|
const pid = child.pid;
|
|
10836
10812
|
let stdoutBytes = 0;
|
|
10837
10813
|
let stderrBytes = 0;
|
|
@@ -30950,8 +30926,8 @@ import {
|
|
|
30950
30926
|
} from "@wrongstack/core/observability";
|
|
30951
30927
|
init_output_spool();
|
|
30952
30928
|
init_util();
|
|
30953
|
-
init_process_registry();
|
|
30954
30929
|
init_win32_resolve();
|
|
30930
|
+
init_process_registry();
|
|
30955
30931
|
var MAX_OUTPUT4 = 32768;
|
|
30956
30932
|
var DEFAULT_TIMEOUT_MS4 = 3e5;
|
|
30957
30933
|
var STREAM_FLUSH_INTERVAL_MS2 = 200;
|
|
@@ -31061,15 +31037,14 @@ var pwshTool = {
|
|
|
31061
31037
|
}
|
|
31062
31038
|
const isWin5 = os11.platform() === "win32";
|
|
31063
31039
|
const bin = isWin5 ? resolvePowerShell("pwsh.exe") : "pwsh";
|
|
31064
|
-
const
|
|
31065
|
-
|
|
31040
|
+
const encodedCommand = Buffer.from(wrapPwshCommand(input.command), "utf16le").toString(
|
|
31041
|
+
"base64"
|
|
31042
|
+
);
|
|
31043
|
+
const args = [...shellArgs("pwsh"), encodedCommand];
|
|
31066
31044
|
const env = buildChildEnv2(ctx.session?.id);
|
|
31067
31045
|
let targetCwd;
|
|
31068
31046
|
try {
|
|
31069
|
-
targetCwd = await safeResolveReal(
|
|
31070
|
-
input.workdir ?? ctx.workingDir ?? ctx.projectRoot,
|
|
31071
|
-
ctx
|
|
31072
|
-
);
|
|
31047
|
+
targetCwd = await safeResolveReal(input.workdir ?? ctx.workingDir ?? ctx.projectRoot, ctx);
|
|
31073
31048
|
} catch (err) {
|
|
31074
31049
|
yield {
|
|
31075
31050
|
type: "final",
|
|
@@ -31090,13 +31065,9 @@ var pwshTool = {
|
|
|
31090
31065
|
cwd: targetCwd,
|
|
31091
31066
|
env,
|
|
31092
31067
|
detached,
|
|
31093
|
-
stdio: ["
|
|
31068
|
+
stdio: ["ignore", "ignore", "ignore"],
|
|
31094
31069
|
windowsHide: true
|
|
31095
31070
|
});
|
|
31096
|
-
if (child2.stdin) {
|
|
31097
|
-
child2.stdin.write(stdinBody);
|
|
31098
|
-
child2.stdin.end();
|
|
31099
|
-
}
|
|
31100
31071
|
const pid2 = child2.pid;
|
|
31101
31072
|
if (typeof pid2 === "number") {
|
|
31102
31073
|
registry.register({
|
|
@@ -31154,7 +31125,7 @@ Working directory: ${targetCwd}`,
|
|
|
31154
31125
|
cwd: targetCwd,
|
|
31155
31126
|
env,
|
|
31156
31127
|
detached,
|
|
31157
|
-
stdio: ["
|
|
31128
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
31158
31129
|
windowsHide: true
|
|
31159
31130
|
});
|
|
31160
31131
|
const pid = child.pid;
|
|
@@ -31195,14 +31166,7 @@ Working directory: ${targetCwd}`,
|
|
|
31195
31166
|
processGroupLeader: detached && child.pid === pid
|
|
31196
31167
|
});
|
|
31197
31168
|
}
|
|
31198
|
-
|
|
31199
|
-
child.stdin.write(stdinBody);
|
|
31200
|
-
child.stdin.end();
|
|
31201
|
-
}
|
|
31202
|
-
const timeoutMs = Math.min(
|
|
31203
|
-
Math.max(1e3, input.timeout_ms ?? DEFAULT_TIMEOUT_MS4),
|
|
31204
|
-
6e5
|
|
31205
|
-
);
|
|
31169
|
+
const timeoutMs = Math.min(Math.max(1e3, input.timeout_ms ?? DEFAULT_TIMEOUT_MS4), 6e5);
|
|
31206
31170
|
let timedOut = false;
|
|
31207
31171
|
const timers = [];
|
|
31208
31172
|
const killWithTimeout = (timeout) => {
|