openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 7.92 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Ju as t,Mu as n,Yu as r}from"./_4____________________________.js";import{T as i,a,h as o,i as s,l as c,n as l,o as u,p as d,r as f,s as p,t as m,v as h,w as g,x as _}from"./config-form-utils-runtime-CqcGJa6w.js";function v(e){let t=n(e);return t.includes(`localservice.env.`)||!y.some(e=>t.endsWith(e))&&b.some(t=>t.test(e))}var y,b;function x(){return(x=e((()=>{y=[`maxtokens`,`maxoutputtokens`,`maxinputtokens`,`maxcompletiontokens`,`contexttokens`,`totaltokens`,`tokencount`,`tokenlimit`,`tokenbudget`,`passwordfile`],b=[/token$/i,/password/i,/secret/i,/api.?key/i,/encrypt.?key/i,/private.?key/i,/serviceaccount(?:ref)?$/i]})))()}function S(e,t){return`config-field-${e.length===0?`root`:e.map(e=>{let t=String(e),n=``;for(let e=0;e<t.length;e+=1)n+=t.charCodeAt(e).toString(16).padStart(4,`0`);return`${typeof e==`number`?`n`:`s`}${t.length}-${n}`}).join(`_`)}-${t}`}function C(e,t,n){return T(e,t,n,{visited:0},0,1)>0}function w(e,t,n){return T(e,t,n,{visited:0},0,1/0)}function T(e,t,n,r,i,a){if(i>E||++r.visited>D)return 1;if(e==null)return 0;let o=_(t);if((d(t,n)?.sensitive||v(o))&&h(e))return 1;let s=0,c=(e,o)=>(s+=T(e,[...t,o],n,r,i+1,a-s),s>=a);return Array.isArray(e)?e.some(c):typeof e==`object`&&Object.entries(e).some(([e,t])=>c(t,e)),s}var E,D;function O(){return(O=e((()=>{x(),o(),E=64,D=2e4})))()}function k(e){return Object.keys(e??{}).every(e=>q.has(e))}function A(e){let t=e.filter(e=>e!=null),n=t.length!==e.length;return{enumValues:j(t),nullable:n}}function j(e){let t=[];for(let n of e)t.some(e=>Object.is(e,n))||t.push(n);return t}function M(e){let t=new Set,n=Array.isArray(e.type)?e.type:e.type?[e.type]:[];for(let e of n)e!==`null`&&t.add(e);t.size===0&&(e.properties||e.additionalProperties)&&t.add(`object`);for(let n of e.allOf??[])for(let e of M(n))t.add(e);return t}function N(e){if(e.size===1)return e.values().next().value;if(e.size>1&&[...e].every(e=>e===`number`||e===`integer`))return e.has(`integer`)?`integer`:`number`}function P(e){return e.size>1&&N(e)===void 0}function F(e){return N(M(e))}function I(e){return!!(F(e)||e.items||e.enum||e.anyOf||e.oneOf||e.allOf)}function L(e){if(!R(e,Y))return!1;if(e.not===void 0)return!0;if(F(e)!==`object`||!t(e.not))return!1;let n=e.not.required;return r(n)&&n.length>0&&Object.keys(e.not).every(e=>e===`required`||q.has(e))}function R(e,n){return Object.keys(e).every(r=>n.has(r)||r===`propertyNames`&&t(e.propertyNames)&&g(e.propertyNames)&&H({type:`string`,...e.propertyNames},[]).unsupportedPaths.length===0)}function z(e){let t=Array.isArray(e.type)?e.type:e.type?[e.type]:[],n=e.nullable===!0||t.length===0||t.includes(`null`);return e.const!==void 0&&(n&&=e.const===null),e.enum&&(n&&=e.enum.some(e=>e===null)),e.allOf&&(n&&=e.allOf.every(z)),e.anyOf&&(n&&=e.anyOf.some(z)),e.oneOf&&(n&&=e.oneOf.filter(z).length===1),n}function B(e){let t=f(e);if(t.length<=1)return!1;let n=new Set(t.flatMap(e=>Object.keys(e.properties??{})));return t.some(e=>{let t=e.additionalProperties;return!!t&&typeof t==`object`&&Object.keys(t).length>0&&[...n].some(t=>!Object.hasOwn(e.properties??{},t))})}function V(e){return!e||typeof e!=`object`?{schema:null,unsupportedPaths:[`<root>`]}:H(e,[])}function H(e,t,n=!1,r,i){let o=e;if(!n&&!e.anyOf&&!e.oneOf&&!e.allOf&&Array.isArray(e.type)&&new Set(e.type.filter(e=>e!==`null`)).size>1&&(e.type.every(e=>e===`null`||X.has(e))||e.type.every(e=>[`string`,`object`,`null`].includes(e)))){let t=e.type.includes(`object`)?[`string`,...e.type.filter(e=>e!==`string`)]:e.type;o={...e,type:t.includes(`object`)?t:void 0,anyOf:t.map(e=>({type:e}))}}let s=new Set,d=e=>{for(let t of e.unsupportedPaths)s.add(t);return e.schema},f={...o},h=_(t)||`<root>`;if(L(o)||s.add(h),o.anyOf||o.oneOf){let e=K(o,t);return e?{schema:d(e),unsupportedPaths:Array.from(s)}:{schema:o,unsupportedPaths:[h]}}let g=Array.isArray(o.type)?o.type.filter(e=>e!==`null`):[],v=M(o),y=n&&!!r&&o.type===void 0&&v.size===0;y&&r&&v.add(r),n&&r&&v.size>0&&P(new Set([...v,r]))&&s.add(h),(new Set(g).size>1||P(v))&&s.add(h);let b=N(v),x=z(o)&&(i===void 0||i);if(o.allOf){let e=[];for(let n of o.allOf)!n||typeof n!=`object`?s.add(h):I(n)?e.push(d(H(n,t,!0,b,x))):(e.push(n),R(n,J)||s.add(h));f.allOf=e}f.type=b??o.type,f.nullable=x;let S=o.properties!==void 0||o.additionalProperties!==void 0,C=o.items!==void 0||o.additionalItems!==void 0;if(f.enum){let{enumValues:e,nullable:t}=A(f.enum);f.enum=e,f.enumIncludesNull=t&&x,e.length===0&&s.add(h)}o.allOf&&x&&!f.enumIncludesNull&&s.add(h);let w=(e,t,r)=>n&&r!==void 0&&!I(e)?(R(e,J)||s.add(r),e):d(H(e,t,n));if(b===`object`&&(!y||S)){let e=o.properties??{},n=new Set(u(o)),r=a(o);[...c(o)].some(e=>!n.has(e))&&!r&&s.add(h),B(o)&&s.add(h);let i={};for(let[n,r]of Object.entries(e)){let e=[...t,n];i[n]=w(r,e,_(e)||`<root>`)}if(f.properties=i,o.allOf)for(let e of u(o)){let n=p(o,e);n&&d(H(n,[...t,e]))}o.additionalProperties===!0?f.additionalProperties={}:o.additionalProperties===!1?f.additionalProperties=!1:o.additionalProperties&&typeof o.additionalProperties==`object`&&(k(o.additionalProperties)||(f.additionalProperties=w(o.additionalProperties,[...t,`*`])))}else if(b===`array`&&(!y||C)){if(Array.isArray(o.items)){let e=[];for(let n=0;n<o.items.length;n+=1){let r=o.items[n];r?e.push(w(r,[...t,n],h)):s.add(h)}f.items=e,f.additionalItems=o.additionalItems&&typeof o.additionalItems==`object`?w(o.additionalItems,[...t,`*`],h):o.additionalItems}else o.items?f.items=w(o.items,[...t,`*`],h):s.add(h);if(o.allOf)for(let e of l(o)){let n=m(o,e);n&&d(H(n,[...t,e]))}}else(!y||b!==`object`&&b!==`array`)&&b!==`string`&&b!==`number`&&b!==`integer`&&b!==`boolean`&&!f.enum&&!(n&&o.allOf)&&s.add(h);return{schema:f,unsupportedPaths:Array.from(s)}}function U(e){if(i(e)!==`object`)return!1;let t=e.properties?.source,n=e.properties?.provider,r=e.properties?.id;return!t||!n||!r?!1:typeof t.const==`string`&&i(n)===`string`&&i(r)===`string`}function W(e){let t=e.oneOf??e.anyOf;return!!(t?.length&&t.every(U))}function G(e){if(e.length!==2)return;let t=e.findIndex(e=>i(e)===`string`);if(!(t<0))return W(e[1-t])?e[t]:void 0}function K(e,t){if(e.allOf)return null;let n=e.anyOf??e.oneOf;if(!n)return null;let r=[],a=[],o=!1;for(let e of n){if(!e||typeof e!=`object`)return null;if(Array.isArray(e.enum)){let{enumValues:t,nullable:n}=A(e.enum);r.push(...t),o||=n}else if(`const`in e){if(e.const==null){o=!0;continue}r.push(e.const)}else i(e)===`null`?o=!0:a.push(e)}o&&=z(e);let s=G(a)??(r.length===0&&a.length===1?a[0]:void 0);if(s)return H({...e,...s,nullable:o||s.nullable,anyOf:void 0,oneOf:void 0,allOf:void 0},t);if(r.length>0&&a.length>0){let t=a.length===1?a[0]:void 0;if(t?.type!==`boolean`||Object.keys(t).length!==1||r.includes(`true`)||r.includes(`false`)||e.anyOf===void 0&&r.some(e=>typeof e==`boolean`))return a.every(e=>e.type===`string`)&&r.every(e=>typeof e==`string`||typeof e==`boolean`)&&!z(e)?{schema:{...e,nullable:o},unsupportedPaths:[]}:null;a.pop(),r.unshift(!0,!1)}return r.length>0&&a.length===0?{schema:{...e,enum:j(r),nullable:o,enumIncludesNull:o,anyOf:void 0,oneOf:void 0,allOf:void 0},unsupportedPaths:[]}:a.length>0&&r.length===0&&a.every(e=>{let t=i(e);return!!t&&Z.has(String(t))})?{schema:{...e,nullable:o},unsupportedPaths:[]}:null}var q,J,Y,X,Z;function Q(){return(Q=e((()=>{s(),O(),q=new Set([`$id`,`$schema`,`title`,`description`,`default`,`deprecated`,`nullable`,`enumIncludesNull`,`examples`,`readOnly`,`tags`,`writeOnly`,`x-tags`]),J=new Set([...q,`const`,`required`,`additionalProperties`,`minimum`,`maximum`,`exclusiveMinimum`,`exclusiveMaximum`,`multipleOf`,`minLength`,`maxLength`,`pattern`,`format`,`minItems`,`maxItems`,`uniqueItems`]),Y=new Set([...J,`type`,`properties`,`items`,`additionalItems`,`enum`,`anyOf`,`oneOf`,`allOf`,`not`]),X=new Set([`string`,`number`,`integer`,`boolean`]),Z=new Set([...X,`object`,`array`])})))()}export{C as a,v as c,w as i,Q as n,O as o,S as r,x as s,V as t};