UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

46 lines (45 loc) • 1.52 kB
import { n as normalizeAgentId } from "./agent-id-CQjtp2ft.mjs"; //#region src/config/native-runtime-consent.ts function resolveConsentAgentKey(e, t) { const n = e?.agents?.entries; if (!n || Object.hasOwn(n, t)) return t; const r = normalizeAgentId(t); return Object.keys(n).find((e) => normalizeAgentId(e) === r) ?? t; } function hasRememberedNativeRuntimeConsent(e, t, n) { const r = resolveConsentAgentKey(e, t); return e?.agents?.entries?.[r]?.nativeRuntimeConsent?.includes(n) === true; } /** Stages explicit operator consent in the same config commit as agent setup. */ function rememberNativeRuntimeConsent(e, t, n) { if (hasRememberedNativeRuntimeConsent(e, t, n)) return e; const r = resolveConsentAgentKey(e, t); const i = e.agents?.entries?.[r]; return { ...e, agents: { ...e.agents, entries: { ...e.agents?.entries, [r]: { ...i, nativeRuntimeConsent: [...i?.nativeRuntimeConsent ?? [], n] } } } }; } /** * Remembered agent consent covers an owner's chat that has not chosen a narrower mode itself: * its unset modes count as Full access with sandbox off. A sandbox from agent config still applies, * and an explicit chat mode is never replaced. */ function withOwnerNativeConsentModes(e, t, n) { return t === true && !n ? { ...e, permissionMode: e.permissionMode ?? "full", sandboxMode: e.sandboxMode ?? "off" } : e; } //#endregion export { rememberNativeRuntimeConsent as n, withOwnerNativeConsentModes as r, hasRememberedNativeRuntimeConsent as t };