openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.95 kB
JavaScript
import{l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{r as truncateUtf16Safe}from"./utf16-slice-DA3Mllbx.mjs";import{n as sanitizeTerminalText}from"./safe-text-B_QTgn0s.mjs";import{t as formatErrorMessage}from"./errors-D37BJTfI.mjs";
//!src/infra/exec-auto-review.ts
const EXEC_AUTO_REVIEW_DENIAL_GUIDANCE=`Do not attempt the same outcome through a workaround, indirect execution, or policy circumvention. Proceed only with a materially safer alternative, or ask the user to approve this exact command after explaining the risk.`;const EXEC_AUTO_REVIEW_SHELL_STARTUP_WARNING=`Exec auto-review skipped: login or interactive shell startup requires human approval`;const EXEC_AUTO_REVIEW_DISPATCH_IDENTITY_WARNING=`Exec auto-review skipped: dispatch chain cannot be bound`;function formatExecAutoReviewAssessment(e){return`risk=${e.risk}${e.userAuthorization?`, authorization=${e.userAuthorization}`:``}`}function normalizeExecAutoReviewRationale(e,t){const n=normalizeOptionalString(e);const r=sanitizeTerminalText(n??t).replace(/[\p{Cf}\u2028\u2029]/gu,``).replace(/\s+/gu,` `).trim();return truncateUtf16Safe(r||t,500)}function buildExecAutoReviewFailureDecision(e,t){return{decision:`ask`,risk:`unknown`,rationale:normalizeExecAutoReviewRationale(`${e}: ${formatErrorMessage(t)}`,e)}}async function resolveExecAutoReviewDecision(e,t){try{return await e(t)}catch(e){return buildExecAutoReviewFailureDecision(`exec reviewer failed`,e)}}const defaultExecAutoReviewer=e=>{return{decision:`ask`,rationale:`no model-backed exec reviewer is configured for ${e.host}`,risk:e.analysis.inlineEval?`medium`:`unknown`}};export{defaultExecAutoReviewer as a,resolveExecAutoReviewDecision as c,buildExecAutoReviewFailureDecision as i,EXEC_AUTO_REVIEW_DISPATCH_IDENTITY_WARNING as n,formatExecAutoReviewAssessment as o,EXEC_AUTO_REVIEW_SHELL_STARTUP_WARNING as r,normalizeExecAutoReviewRationale as s,EXEC_AUTO_REVIEW_DENIAL_GUIDANCE as t};