UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 3.19 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Fu as t,Iu as n,Ju as r,Uu as i,_l as a,tu as o,xl as s}from"./_4____________________________.js";function c(e){return e===p.SECURITY_UNAVAILABLE||e===p.DOWNLOAD_BLOCKED}function l(e){if(e.code||e.version||e.warning)return{...e.code?{clawhubTrustCode:e.code}:{},...e.version?{version:e.version}:{},...e.warning?{warning:e.warning}:{}}}function u(e){if(r(e))return l({code:c(e.clawhubTrustCode)?e.clawhubTrustCode:void 0,version:n(e.version),warning:n(e.warning)})}function d(e){let t=i(e),n=i(t?.details),r=typeof n?.warning==`string`?n.warning.trim():``;return t?.code===a.INVALID_REQUEST&&n?.code===`CLAWHUB_RISK_ACKNOWLEDGEMENT_REQUIRED`&&r?{code:f,warning:r}:null}var f,p;function m(){return(m=e((()=>{s(),f=`CLAWHUB_RISK_ACKNOWLEDGEMENT_REQUIRED`,p={SECURITY_UNAVAILABLE:`clawhub_security_unavailable`,DOWNLOAD_BLOCKED:`clawhub_download_blocked`}})))()}var h,g;function _(){return(_=e((()=>{h=[{id:`channels`,label:`Channels`},{id:`providers`,label:`Providers`},{id:`tools`,label:`Tools`},{id:`contracts`,label:`Contracts`},{id:`hooks`,label:`Hooks`},{id:`mcpServers`,label:`MCP servers`},{id:`cliCommands`,label:`CLI commands`},{id:`cliBackends`,label:`CLI backends`},{id:`skills`,label:`Skills`},{id:`dangerousConfigFlags`,label:`Dangerous configuration flags`}],g=h.map(e=>e.id)})))()}function v(e,t){return Object.keys(e).every(e=>t.includes(e))}function y(e){let t=i(e);if(!t||!v(t,g))return;let n={};for(let e of g){let r=t[e];if(r!==void 0){if(!Array.isArray(r)||!r.every(o))return;n[e]=r}}return n}function b(e){let t=i(e);if(!t||t.capabilityConsentCode!==`PLUGIN_CAPABILITY_CONSENT_REQUIRED`||!v(t,[`capabilityConsentCode`,`pluginId`,`reviewToken`,`widened`,`acceptedAt`])||!o(t.pluginId)||!o(t.reviewToken)||t.acceptedAt!==void 0&&!o(t.acceptedAt))return;let n=t.widened===void 0?void 0:y(t.widened);if(t.widened===void 0||n)return{capabilityConsentCode:x,pluginId:t.pluginId,reviewToken:t.reviewToken,...n?{widened:n}:{},...t.acceptedAt===void 0?{}:{acceptedAt:t.acceptedAt}}}var x;function S(){return(S=e((()=>{_(),x=`PLUGIN_CAPABILITY_CONSENT_REQUIRED`})))()}function C(e){let n=i(e);if(!n)return;let r=t(n.ruleId),a=t(n.message),o=n.severity;if(!r||!a||o!==`info`&&o!==`warn`&&o!==`critical`)return;let s=o,c=t(n.file),l=t(n.evidence),u=n.line;if(!(n.file!==void 0&&!c||n.evidence!==void 0&&!l||u!==void 0&&(typeof u!=`number`||!Number.isSafeInteger(u)||u<=0)))return{ruleId:r,severity:s,message:a,...c?{file:c}:{},...u===void 0?{}:{line:u},...l?{evidence:l}:{}}}function w(e){let n=i(e);if(!n)return;let r=t(n.targetName),a=t(n.reason),o=n.targetType,s=n.requestMode;if(n.installPolicyCode!==`install_policy_warning_acknowledgement_required`||!r||!a||o!==`skill`&&o!==`plugin`||s!==`install`&&s!==`update`)return;let c=o,l=s,u;if(n.findings!==void 0){if(!Array.isArray(n.findings))return;u=[];for(let e of n.findings){let t=C(e);if(!t)return;u.push(t)}}return{installPolicyCode:T,targetName:r,targetType:c,requestMode:l,reason:a,...u?{findings:u}:{}}}var T;function E(){return(E=e((()=>{T=`install_policy_warning_acknowledgement_required`})))()}export{g as a,d as c,b as i,u as l,w as n,_ as o,S as r,m as s,E as t};