openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 2.06 kB
JavaScript
import{t as AUTOMATIONS_TOOL_NAME}from"./automations-tool-name-CptnbJ9-.mjs";import{o as roleScopesAllow}from"./operator-scope-compat-TmgAKmD2.mjs";
//!src/security/dangerous-tools.ts
const DEFAULT_GATEWAY_HTTP_TOOL_DENY=[`exec`,`spawn`,`shell`,`fs_write`,`fs_delete`,`fs_move`,`apply_patch`,`terminal`,`portal`,`sessions_spawn`,`sessions_send`,`conversations_list`,`conversations_send`,`conversations_turn`,AUTOMATIONS_TOOL_NAME,`gateway`,`plugins`,`nodes`,`computer`,`mobile_ui`,`openclaw`];const GATEWAY_CONTROL_PLANE_TOOLS=[AUTOMATIONS_TOOL_NAME,`gateway`,`plugins`];const GATEWAY_OWNER_ONLY_CORE_TOOLS=[...GATEWAY_CONTROL_PLANE_TOOLS,`sessions`,`screen`,`terminal`,`portal`,`conversations_list`,`conversations_send`,`conversations_turn`,`nodes`,`computer`,`mobile_ui`,`openclaw`,`intent`];const gatewayOwnerOnlyCoreToolNames=new Set(GATEWAY_OWNER_ONLY_CORE_TOOLS);const retainedOperatorToolNames=new Set(GATEWAY_CONTROL_PLANE_TOOLS);function isGatewayOwnerOnlyCoreTool(e){return gatewayOwnerOnlyCoreToolNames.has(e)}function hasGatewayOwnerToolAuthority(e,t,n=false){if(n&&e!==true)return false;if(t){t.assertCurrent();return roleScopesAllow({role:`operator`,requestedScopes:[`operator.admin`],allowedScopes:t.scopes})}return e===true}function assertGatewayOwnerToolAuthority(e,t,n,r=false){if(!isGatewayOwnerOnlyCoreTool(e))return;if(!hasGatewayOwnerToolAuthority(t,n,r)||t!==true&&!retainedOperatorToolNames.has(e))throw new Error(r&&t!==true?`Owner-level tools cannot run on a tainted turn.`:`${e} requires current owner-level tool authority.`)}function resolveGatewayOwnerOnlyToolDenylist(e,t,n=false){if(t){const r=hasGatewayOwnerToolAuthority(e,t,n);return GATEWAY_OWNER_ONLY_CORE_TOOLS.filter(t=>!r||e!==true&&!retainedOperatorToolNames.has(t))}return GATEWAY_OWNER_ONLY_CORE_TOOLS.filter(t=>e!==true&&(e===false||t===`intent`))}export{hasGatewayOwnerToolAuthority as a,assertGatewayOwnerToolAuthority as i,GATEWAY_CONTROL_PLANE_TOOLS as n,resolveGatewayOwnerOnlyToolDenylist as o,GATEWAY_OWNER_ONLY_CORE_TOOLS as r,DEFAULT_GATEWAY_HTTP_TOOL_DENY as t};