UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 2.94 kB
import{_ as e,c as t,f as n,g as r,l as i}from"./openclaw-state-read-schemas-CLrAtqTl.mjs";import"./openclaw-state-read-runtime-snapshot-DNALz0gh.mjs";const a=/^(?:[0-9a-f]{2})*$/;function hexToBytes(e){if(!a.test(e))throw Error(`expected lowercase hex`);let t=new Uint8Array(e.length/2);for(let n=0;n<t.length;n+=1)t[n]=Number.parseInt(e.slice(n*2,n*2+2),16);return t}hexToBytes(`302e020100300506032b657004220420`);const o=/^iroh:[0-9a-f]{64}$/;function isIrohEndpointKey(e){return typeof e==`string`&&o.test(e)}const s=[`approve_device`,`bind`,`invite`,`manage_members`],c=[`owner_device`,`peer_key`];var SchemaError=class extends Error{};function fail(e,t){throw new SchemaError(`${e}: ${t}`)}function predicate(e,t){return(n,r)=>{e(n)||fail(r,t)}}const l=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/;function isText(e){return typeof e==`string`&&e.length<=256&&!l.test(e)}const u=predicate(isText,`expected well-formed string`),d=predicate(isIrohEndpointKey,`expected iroh:<64 hex>`);function oneOf(e){return predicate(t=>typeof t==`string`&&e.includes(t),`expected one of ${e.join(`, `)}`)}function list(e,t=0,n=256){return(r,i)=>{(!Array.isArray(r)||r.length<t||r.length>n)&&fail(i,`expected list`),r.forEach((t,n)=>e(t,`${i}[${n}]`)),r.every(e=>typeof e==`string`)&&new Set(r).size!==r.length&&fail(i,`duplicate entries`)}}const f=/* @__PURE__ */ new WeakSet;function optional(e){let wrapped=(t,n)=>e(t,n);return f.add(wrapped),wrapped}function object(e){return(t,n)=>{(typeof t!=`object`||!t||Array.isArray(t))&&fail(n,`expected object`);let r=t;for(let t of Object.keys(r))Object.hasOwn(e,t)||fail(`${n}.${t}`,`unknown field`);for(let[t,i]of Object.entries(e)){if(!Object.hasOwn(r,t)){if(f.has(i))continue;fail(`${n}.${t}`,`missing field`)}i(r[t],`${n}.${t}`)}}}const p=/[\u0000-\u001f\u007f]/,nodeText=e=>predicate(t=>isText(t)&&t.length>0&&t.length<=e&&!p.test(t),`expected non-empty text of at most ${e} UTF-16 code units without control characters`),m=object({display_name:nodeText(128),platform:nodeText(64),commands:list(nodeText(128),0,64),caps:list(nodeText(128),0,64)});function isMemberRole(e){return typeof e==`string`&&/^[a-z][a-z0-9_-]{0,63}$/.test(e)}oneOf([`owner`]),oneOf(s),oneOf([`account_id`]),oneOf([`email`]),oneOf([`add`]),oneOf([`add_member_device`]),oneOf([`add_node`]),oneOf([`remove_node`]),oneOf([`remove`]),oneOf([`set_role`]),oneOf([`revoke_device`]),oneOf([`add_owner_device`]),optional(object({peer_key:d,label:u,description:m})),oneOf([`deny_invite`]),oneOf(c),oneOf(s);const h={peerKey:e().regex(/^iroh:[a-f0-9]{64}$/),authority:r({clawId:e().min(1).max(256),rootPub:e().min(1).max(256),listedSeq:n().int().nonnegative().max(2**53-1),ownerDevice:e().min(1).max(256).optional()})},g=t(`kind`,[r({kind:i(`owner`),...h}),r({kind:i(`node`),...h}),r({kind:i(`member`),...h,accountId:e().min(1).max(256),role:e().refine(isMemberRole,`Invalid member role name`)})]);export{g as t};