mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-29 01:02:03 +03:00
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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user