openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
53 lines (52 loc) • 1.96 kB
JavaScript
//#region src/plugin-sdk/agent-harness-exec-review-runtime.ts
async function reviewExecRequestWithConfiguredModel(params) {
const { createModelExecAutoReviewer } = await import("./exec-auto-reviewer-Bs5cW_kH.js");
return createModelExecAutoReviewer({
cfg: params.cfg,
agentId: params.agentId,
reviewer: params.reviewer
})(params.input);
}
async function buildExecAutoReviewInputForShellCommand(params) {
const [{ commandRequiresSecurityAuditSuppressionApproval, evaluateShellAllowlist }, { detectUnsafeExecControlShellCommand }, { detectPolicyInlineEval }] = await Promise.all([
import("./exec-approvals-CrGGa48s.js"),
import("./exec-control-command-guard-B9cd68bE.js"),
import("./policy-CDGEzbs1.js")
]);
const command = params.command.trim();
if (!command) return;
const allowlistEval = evaluateShellAllowlist({
command,
allowlist: [],
safeBins: /* @__PURE__ */ new Set(),
cwd: params.cwd ?? void 0,
platform: process.platform
});
const [segment] = allowlistEval.segments;
if (!(allowlistEval.analysisOk && allowlistEval.segments.length === 1 && segment !== void 0 && segment.raw.trim() === command)) return;
if (commandRequiresSecurityAuditSuppressionApproval({
command,
cwd: params.cwd ?? void 0,
segments: allowlistEval.segments
})) return;
if (detectUnsafeExecControlShellCommand(command) !== null) return;
const inlineEval = detectPolicyInlineEval(allowlistEval.segments) !== null;
const heredoc = segment.argv.some((token) => token.startsWith("<<"));
return {
command,
argv: segment.argv,
cwd: params.cwd ?? null,
envKeys: params.envKeys,
host: params.host,
reason: inlineEval ? "strict-inline-eval" : heredoc ? "heredoc" : "approval-required",
analysis: {
parsed: true,
allowlistMatched: false,
inlineEval,
...heredoc ? { heredoc } : {}
},
agent: params.agent
};
}
//#endregion
export { reviewExecRequestWithConfiguredModel as n, buildExecAutoReviewInputForShellCommand as t };