openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 5.52 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{$a as t,Ju as n,ci as r,ui as i}from"./_4____________________________.js";function a(e,n,r){let i=`configHints.${encodeURIComponent(e).replaceAll(`.`,`%2E`)}.${n}.`,a=r.trim().split(/\s+/).join(` `);return`${i}v1-${t(a).toString(36)}-${a.length.toString(36)}`}function o(){return(o=e((()=>{})))()}function s(e){return/^\$\{[^}]*\}$/.test(e.trim())}function c(e){return typeof e==`string`?e.trim().length>0&&!s(e):e!=null}function l(e){if(e)return Array.isArray(e.type)?e.type.find(e=>e!==`null`)??e.type[0]:e.type}function u(e){let t=Array.isArray(e.type)?e.type:e.type?[e.type]:[];return t.length>0&&!t.includes(`string`)||e.const!==void 0&&typeof e.const!=`string`||e.enum&&!e.enum.some(e=>typeof e==`string`)||e.allOf&&!e.allOf.every(u)||e.anyOf&&!e.anyOf.some(u)?!1:!e.oneOf||e.oneOf.some(u)}function d(e){return e.filter(e=>typeof e==`string`).join(`.`)}function f(e,t){let n=d(e),r=t[n];if(r)return{hint:r,hintPath:n};let i=e.map(String),a=D.get(t);if(!a){a=new Map;for(let[e,n]of Object.entries(t)){if(!e.includes(`*`))continue;let t=e.split(`.`),r=a.get(t.length)??[];r.push([t,n]),a.set(t.length,r)}D.set(t,a)}for(let[e,t]of a.get(i.length)??[])if(e.every((e,t)=>e===`*`||e===i[t]))return{hint:t,hintPath:e.join(`.`)}}function p(e,t){return f(e,t)?.hint}function m(e){return e.reduce((e,t)=>typeof t==`number`?`${e}[]`:e?`${e}.${t}`:t,``)}function h(e,t){for(let n=e.length;n>0;--n){let r=e.slice(0,n),i=p(r,t)?.sensitive??t[m(r)]?.sensitive;if(i!==void 0)return i}return!1}function g(e,t){let n=f(e,t);if(!n)return;let{hint:r,hintPath:o}=n;return{...r,label:r.label?i(a(o,`label`,r.label))??r.label:r.label,help:r.help?i(a(o,`help`,r.help))??r.help:r.help}}function _(e){return e.replace(/_/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/\s+/g,` `).replace(/^./,e=>e.toUpperCase())}function v(e){return`${JSON.stringify(e,null,2).trimEnd()}\n`}function y(e){let t=Array.isArray(e)?e:n(e)?Object.values(e):[];return e===`__OPENCLAW_REDACTED__`||t.some(y)}function b(e,t){if(Array.isArray(e)){let n=Array.isArray(t)?t:[];return e.map((e,t)=>b(e,n[t]))}if(!n(e))return e;let r=n(t)?t:null;return Object.fromEntries(Object.entries(e).flatMap(([e,t])=>{let i=r!==null&&Object.hasOwn(r,e),a=b(t,i?r[e]:void 0);return!i&&n(a)&&Object.keys(a).length===0?[]:[[e,a]]}))}function x(e,t){if(!t)return e;let r=b(e,t);return n(r)?r:e}function S(e,t,r,i,a){let o=t[r];if(o===void 0)return{ok:!1};let s=r===t.length-1,c=a===`copy`||a===`copy-set`||a===`copy-remove`,l=a===`remove`||a===`copy-remove`||a===`copy`&&i===void 0;if((a===`remove`||a===`copy-remove`)&&e==null)return{ok:!1};if(typeof o==`number`){if(e!=null&&!Array.isArray(e))return{ok:!1};let n=Array.isArray(e)?c?[...e]:e:[];if(s)return l?n.splice(o,1):n[o]=i,{ok:!0,value:n};let u=S(Object.hasOwn(n,o)?n[o]:void 0,t,r+1,i,a);return u.ok?(n[o]=u.value,{ok:!0,value:n}):u}let u=e??{};if(!n(u))return{ok:!1};let d=c?{...u}:u,f=s?{ok:!0,value:i}:S(Object.hasOwn(d,o)?d[o]:void 0,t,r+1,i,a);return f.ok?(s&&l?delete d[o]:Object.defineProperty(d,o,{value:f.value,enumerable:!0,configurable:!0,writable:!0}),{ok:!0,value:d}):f}function C(e,t,n,r=`copy`){return t.length===0?{ok:!0,value:r===`copy`?n:e}:S(e,t,0,n,r)}function w(e,t,n){S(e,t,0,n,`set`)}function T(e,t){S(e,t,0,void 0,`remove`)}function E(e){let t=(e.anyOf??e.oneOf??[]).filter(e=>l(e)!==`null`),n=t.find(e=>l(e)===`object`&&e.properties?.primary!==void 0),r=t.find(e=>l(e)===`string`&&!e.enum&&e.const===void 0);return t.length===2&&r?n:void 0}var D,O;function k(){return(k=e((()=>{o(),r(),D=new WeakMap,O=`__OPENCLAW_REDACTED__`})))()}function A(e){let t=[],n=[e],r=new Set;for(;n.length>0;){let e=n.pop();if(e&&!r.has(e)){r.add(e),t.push(e);for(let t=(e.allOf?.length??0)-1;t>=0;--t){let r=e.allOf?.[t];r&&n.push(r)}}}return t}function j(e){let t=e.find(e=>l(e)!==void 0)??e[0];return!t||e.length===1?t:{...t,allOf:[...t.allOf??[],...e.filter(e=>e!==t)]}}function M(e,t){let n=e.properties;return n&&Object.hasOwn(n,t)?n[t]:void 0}function N(e){return e.allOf?.length?new Set(A(e).flatMap(e=>e.required??[])):new Set(e.required)}function P(e){if(!e.allOf?.length)return Object.keys(e.properties??{});let t=A(e);return[...new Set(t.flatMap(e=>Object.keys(e.properties??{})))].filter(e=>t.every(t=>M(t,e)!==void 0||t.additionalProperties!==!1))}function F(e){if(!e.allOf?.length)return e.additionalProperties===!0?{}:e.additionalProperties;let t=A(e).map(e=>e.additionalProperties).filter(e=>e!==void 0);if(t.some(e=>e===!1))return!1;let n=t.filter(e=>!!e&&typeof e==`object`);return n.length>0?j(n):t.some(e=>e===!0)?{}:void 0}function I(e,t){if(!e.allOf?.length)return M(e,t);if(P(e).includes(t))return j(A(e).map(e=>M(e,t)).filter(e=>e!==void 0))}function L(e,t){let n=[];for(let r of A(e))if(Array.isArray(r.items)){let e=r.items[t]??(r.additionalItems&&typeof r.additionalItems==`object`?r.additionalItems:void 0);e&&n.push(e)}else r.items&&n.push(r.items);return j(n)}function R(e){let t=0,n;for(let r of A(e))if(Array.isArray(r.items)){let e=r.additionalItems!==null&&typeof r.additionalItems==`object`;t=Math.max(t,r.items.length+ +!!e),r.additionalItems===!1&&(n=Math.min(n??1/0,r.items.length))}else r.items&&(t=Math.max(t,1));return n!==void 0&&(t=Math.min(t,n)),Array.from({length:t},(e,t)=>t)}function z(){return(z=e((()=>{k()})))()}export{T as C,w as D,v as E,x as S,l as T,h as _,F as a,E as b,M as c,y as d,C as f,s as g,k as h,z as i,N as l,_ as m,R as n,P as o,p,A as r,I as s,L as t,O as u,c as v,u as w,d as x,g as y};