UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

65 lines (64 loc) • 2.47 kB
//#region src/plugin-sdk/agent-harness-exec-review-runtime.ts /** * Review an exec request using the configured model without executing it. * Handle all three results explicitly: `allow-once` with low/medium risk permits * one execution; `ask` routes to human approval; `deny` must not run or escalate * to human approval and must return the rationale and rejection guidance to the * agent. Provider failures, timeouts, and invalid responses become `ask`; * detected reviewer-directed prompt injection becomes high-risk `deny`. * Facade loading or reviewer construction errors may still reject the promise. */ async function reviewExecRequestWithConfiguredModel(e) { const { createModelExecAutoReviewer: t } = await import("../exec-auto-reviewer-BABANvdR.mjs"); return t({ cfg: e.cfg, agentId: e.agentId, reviewer: e.reviewer })(e.input); } /** * Build review input for a supported shell command, or return `undefined` when * this helper cannot review it. This does not authorize execution; consumers of * the subsequent review must handle `allow-once`, `deny`, and `ask` explicitly. */ async function buildExecAutoReviewInputForShellCommand(e) { const [{ evaluateShellAllowlistWithAuthorization: t }, { detectUnsafeExecControlShellCommand: n }, { detectInlineEvalInSegments: r }, { isBlockedShellWrapperCommand: i }] = await Promise.all([ import("../exec-approvals-CeiEVVNO.mjs"), import("../exec-control-command-guard-Bm2vwg89.mjs"), import("../risks-Bg-pYCak.mjs"), import("../exec-wrapper-resolution-CO3IVndV.mjs") ]); const a = e.command.trim(); const o = e.host; if (!a) return; const s = await t({ command: a, allowlist: [], safeBins: /* @__PURE__ */ new Set(), cwd: e.cwd ?? void 0, platform: process.platform }); const [c] = s.segments; if (!(s.analysisOk && s.segments.length === 1 && c !== void 0 && c.raw.trim() === a)) return; if (c.resolution?.policyBlocked === true || i(c.argv)) return; if (await n(a) !== null) return; const l = r(s.segments) !== null; const u = c.argv.some((e) => e.startsWith("<<")); return { command: a, argv: c.argv, cwd: e.cwd ?? null, envKeys: e.envKeys, host: o, reason: l ? "strict-inline-eval" : u ? "heredoc" : "approval-required", analysis: { parsed: true, allowlistMatched: false, inlineEval: l, ...u ? { heredoc: u } : {} }, agent: e.agent }; } //#endregion export { buildExecAutoReviewInputForShellCommand, reviewExecRequestWithConfiguredModel };