openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
52 lines (51 loc) • 2.54 kB
JavaScript
import { n as normalizeAgentId } from "./agent-id-CQjtp2ft.mjs";
import "./session-key-CqAyZeVk.mjs";
import { r as resolveAgentConfig } from "./agent-scope-config-DmXgFGKP.mjs";
import { r as textResult } from "./tool-results-CcV0sxnb.mjs";
import { n as failedTextResult } from "./common-njQNtpnW.mjs";
import { m as renderExecOutputText, r as EXEC_RETENTION_CAP_NOTE } from "./bash-tools.exec-output-CrrdoikE.mjs";
//#region src/agents/bash-tools.exec-support.ts
function attachExecApprovalReview(e, t) {
if (t) {
e.details.approvalReviews = [t];
e.details.approvalReviewOutcome = t.status === "approved" ? "approved" : "denied";
}
return e;
}
function buildExecForegroundResult(e) {
const t = e.warningText?.trim() ? `${e.warningText}\n\n` : "";
const n = e.aggregateOutputDropped ? EXEC_RETENTION_CAP_NOTE : "";
const r = e.outcome;
const i = {
status: r.status,
exitCode: r.status === "failed" ? r.exitCode ?? null : r.exitCode,
exitSignal: r.exitSignal,
...r.status === "failed" ? { failureKind: r.failureKind } : {},
exitReason: r.exitReason,
durationMs: r.durationMs,
aggregated: r.aggregated,
...r.status === "failed" ? { timedOut: r.timedOut } : {},
noOutputTimedOut: r.noOutputTimedOut,
cwd: e.cwd
};
if (e.outcome.status === "failed") {
const r = e.outcome.failureKind === "signal" && e.outcome.exitReason === "signal" && e.outcome.oomScoreWrapperSelected === true && (e.outcome.exitSignal === "SIGKILL" || e.outcome.exitSignal === 9) ? "\n\nOpenClaw selected its Linux OOM-score wrapper, which attempts to set this child's oom_score_adj to 1000. SIGKILL alone does not identify whether the Linux OOM killer, an operator, or another process sent it. Check cgroup memory events or kernel logs. If they show memory pressure, narrow the command or adjust memory, concurrency, or resource limits." : "";
const a = `${n}${t}${e.outcome.reason}${r}`;
const o = `${n}${t}${e.outcome.message}${r}`;
return failedTextResult(a, {
...i,
status: "failed",
message: o
});
}
const a = `${n}${t}${renderExecOutputText(e.outcome.aggregated)}`;
return textResult(a, i);
}
function resolveExecReviewerDefaults(e) {
if (e.defaults?.reviewer) return e.defaults.reviewer;
const t = e.defaults?.config;
const n = e.agentId ? normalizeAgentId(e.agentId) : void 0;
return (n && t ? resolveAgentConfig(t, n)?.tools?.exec : void 0)?.reviewer ?? t?.tools?.exec?.reviewer;
}
//#endregion
export { buildExecForegroundResult as n, resolveExecReviewerDefaults as r, attachExecApprovalReview as t };