UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

45 lines (44 loc) • 3.07 kB
import { n as formatConcreteConfigPath, o as readObjectPath, r as parseConcreteConfigPath } from "./dot-path-BJ4tyWKJ.mjs"; //#region src/system-agent/delegated-change-policy.ts /** Only host-authored explanations may be attached to an exact approval request. */ var DelegatedChangeApprovalRequiredError = class extends Error {}; /** Permission edits cannot use the delegation grant they would broaden. */ function describeDelegatedChangePolicyApproval(e, t) { if (e.kind !== "config-set" && e.kind !== "config-unset" && e.kind !== "config-set-ref") return; const n = parseConcreteConfigPath(e.path); const r = n[0] === "agents" ? [ "agents", "entries", n[2], "tools", "openclaw", "autoApproveChanges" ] : [ "tools", "openclaw", "autoApproveChanges" ]; if (!n.slice(0, Math.min(n.length, r.length)).every((e, t) => e === r[t])) return; if (n.length === r.length && e.kind === "config-set" && e.value.trim() === "false") return; let i = "This proposal may change tools.openclaw.autoApproveChanges or its per-agent overrides and future approval behavior. Review the proposed policy carefully; its resulting authority has not been established here."; let a = "tools.openclaw.autoApproveChanges or the relevant per-agent override"; if (n.length === r.length) { a = formatConcreteConfigPath(n); const r = t ? readObjectPath(t, n) : void 0; const o = typeof r === "boolean" ? String(r) : r === void 0 && t ? "unset" : void 0; if (e.kind === "config-set" && e.value.trim() === "true") { i = o ? `This proposal changes ${a} from ${o} to true.` : `This proposal sets ${a} to true.`; i += " Approving saves standing authorization for future permitted delegated changes, including changes that can enable Gateway-host code execution."; if (n[0] === "tools") i += " Per-agent overrides still take precedence."; } else if (e.kind === "config-unset") { i = `This proposal removes ${a}${o ? ` (currently ${o})` : ""}.`; if (n[0] === "agents" && t) { const e = t.tools?.openclaw?.autoApproveChanges; i += e === void 0 ? " This agent will inherit the global default: permitted changes may be automatic under Full Access." : ` This agent will inherit tools.openclaw.autoApproveChanges: ${e}. ${e ? "This supplies standing authorization for future permitted delegated changes, including changes that can enable Gateway-host code execution." : "This requires individual approval, including in Full Access."}`; } else i += " Future automatic changes depend on Full Access and per-agent overrides; removing a setting does not necessarily disable automatic changes."; } } return `${i} Exact approval is required for this policy change. Approve this proposal, or edit ${a} directly through operator configuration. To keep the current policy, deny this proposal. Containment, inherited authority, and operation limits still apply. See https://docs.openclaw.ai/gateway/permission-modes#delegated-setup-and-repair.`; } //#endregion export { describeDelegatedChangePolicyApproval as n, DelegatedChangeApprovalRequiredError as t };