Agents: include runtime shell (#1835)

* Agents: include runtime shell

* Agents: fix compact runtime build

* chore: fix CLAUDE.md formatting, security regex for secret

---------

Co-authored-by: Tak hoffman <takayukihoffman@gmail.com>
Co-authored-by: quotentiroler <max.nussbaumer@maxhealth.tech>
This commit is contained in:
Tak Hoffman
2026-02-07 11:32:31 -06:00
committed by GitHub
parent a4d5c7f673
commit f0722498a4
7 changed files with 68 additions and 1 deletions
+57
View File
@@ -67,6 +67,63 @@ function resolveShellFromPath(name: string): string | undefined {
return undefined;
}
function normalizeShellName(value: string): string {
const trimmed = value.trim();
if (!trimmed) {
return "";
}
return path
.basename(trimmed)
.replace(/\.(exe|cmd|bat)$/i, "")
.replace(/[^a-zA-Z0-9_-]/g, "");
}
export function detectRuntimeShell(): string | undefined {
const overrideShell = process.env.CLAWDBOT_SHELL?.trim();
if (overrideShell) {
const name = normalizeShellName(overrideShell);
if (name) {
return name;
}
}
if (process.platform === "win32") {
if (process.env.POWERSHELL_DISTRIBUTION_CHANNEL) {
return "pwsh";
}
return "powershell";
}
const envShell = process.env.SHELL?.trim();
if (envShell) {
const name = normalizeShellName(envShell);
if (name) {
return name;
}
}
if (process.env.POWERSHELL_DISTRIBUTION_CHANNEL) {
return "pwsh";
}
if (process.env.BASH_VERSION) {
return "bash";
}
if (process.env.ZSH_VERSION) {
return "zsh";
}
if (process.env.FISH_VERSION) {
return "fish";
}
if (process.env.KSH_VERSION) {
return "ksh";
}
if (process.env.NU_VERSION || process.env.NUSHELL_VERSION) {
return "nu";
}
return undefined;
}
export function sanitizeBinaryOutput(text: string): string {
const scrubbed = text.replace(/[\p{Format}\p{Surrogate}]/gu, "");
if (!scrubbed) {