openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
28 lines (27 loc) • 1.12 kB
JavaScript
import { T as normalizeExecutableToken, f as isShellWrapperExecutable, m as resolveShellWrapperTransportArgv, t as POSIX_PARSEABLE_SHELL_WRAPPERS } from "./shell-wrapper-resolution-BEK558J4.mjs";
//#region src/infra/command-explainer/format.ts
function spanToCommandSpan(e) {
if (!Number.isSafeInteger(e.startIndex) || !Number.isSafeInteger(e.endIndex)) return null;
if (e.startIndex < 0 || e.endIndex <= e.startIndex) return null;
return {
startIndex: e.startIndex,
endIndex: e.endIndex
};
}
function isUnsupportedShellWrapperArgv(e) {
const t = (resolveShellWrapperTransportArgv([...e]) ?? e)[0];
if (!t) return false;
const n = normalizeExecutableToken(t);
return isShellWrapperExecutable(n) && !POSIX_PARSEABLE_SHELL_WRAPPERS.has(n);
}
function formatCommandSpans(e) {
if (e.topLevelCommands.some((e) => isUnsupportedShellWrapperArgv(e.argv))) return [];
const t = [];
for (const n of [...e.topLevelCommands, ...e.nestedCommands]) {
const e = spanToCommandSpan(n.executableSpan);
if (e) t.push(e);
}
return t;
}
//#endregion
export { isUnsupportedShellWrapperArgv as n, formatCommandSpans as t };