@elizaos/core 1.6.2-alpha.2 → 1.6.2-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -346,7 +346,7 @@ ${G.content.text}`});return`${K?`Conversation: ${O.slice(-5)}
346
346
  `)}).join(J.every((u)=>!u.text&&!u.description)?", ":`
347
347
  `)})`:null,G=new Date(P.createdAt||0),f=G.getHours().toString().padStart(2,"0"),A=G.getMinutes().toString().padStart(2,"0"),V=`${f}:${A}`,C=gV(P.createdAt||0),E=O?`(${z}'s internal thought: ${O})`:null,R=`${V} (${C}) [${P.entityId}]`,I=_?`${R} ${z}: ${_}`:null,D=j&&j.length>0?`${I?"":R} (${z}'s actions: ${j.join(", ")})`:null;return[I,E,D,w].filter(Boolean).join(`
348
348
  `)}).join(`
349
- `)},gV=($)=>{let K=new Date().getTime()-$,P=Math.abs(K),_=Math.floor(P/1000),j=Math.floor(_/60),O=Math.floor(j/60),z=Math.floor(O/24);if(P<60000)return"just now";if(j<60)return`${j} minute${j!==1?"s":""} ago`;if(O<24)return`${O} hour${O!==1?"s":""} ago`;return`${z} day${z!==1?"s":""} ago`},Am=/```json\n([\s\S]*?)\n```/;function LV($){if(!$)return null;let q=$.match(/<response>([\s\S]*?)<\/response>/),K;if(q)K=q[1],r8.debug("Found response XML block");else{let z=((J)=>{let w=0,G=J.length;while(w<G){let f=J.indexOf("<",w);if(f===-1)break;if(J.startsWith("</",f)||J.startsWith("<!--",f)||J.startsWith("<?",f)){w=f+1;continue}let A=f+1,V="";while(A<G){let b=J[A];if(/^[A-Za-z0-9_-]$/.test(b)){V+=b,A++;continue}break}if(!V){w=f+1;continue}let C=J.indexOf(">",A);if(C===-1)break;let E=J.slice(f,C+1);if(/\/\s*>$/.test(E)){w=C+1;continue}let R=`</${V}>`,I=1,D=C+1;while(I>0&&D<G){let b=J.indexOf(`<${V}`,D),u=J.indexOf(R,D);if(u===-1)break;if(b!==-1&&b<u){let y=J.indexOf(">",b+1);if(y===-1)break;let c=J.slice(b,y+1);if(/\/\s*>$/.test(c))D=y+1;else I++,D=y+1}else I--,D=u+R.length}if(I===0){let b=D-R.length,u=J.slice(C+1,b);return{tag:V,content:u}}w=C+1}return null})($);if(!z)return r8.warn("Could not find XML block in text"),r8.debug({textPreview:$.substring(0,200)+"..."},"Text content"),null;K=z.content,r8.debug(`Found XML block with tag: ${z.tag}`)}let P={},j=((O)=>{let z=[],J=O.length,w=0;while(w<J){let G=O.indexOf("<",w);if(G===-1)break;if(O.startsWith("</",G)||O.startsWith("<!--",G)||O.startsWith("<?",G)){w=G+1;continue}let f=G+1,A="";while(f<J){let y=O[f];if(/^[A-Za-z0-9_-]$/.test(y)){A+=y,f++;continue}break}if(!A){w=G+1;continue}let V=O.indexOf(">",f);if(V===-1)break;let C=O.slice(G,V+1);if(/\/\s*>$/.test(C)){w=V+1;continue}let E=`</${A}>`,R=1,I=V+1;while(R>0&&I<J){let y=O.indexOf(`<${A}`,I),c=O.indexOf(E,I);if(c===-1)break;if(y!==-1&&y<c){let m=O.indexOf(">",y+1);if(m===-1)break;let q$=O.slice(y,m+1);if(!/\/\s*>$/.test(q$))R++;I=m+1}else R--,I=c+E.length}if(R!==0){w=V+1;continue}let D=I-E.length,u=O.slice(V+1,D).replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&apos;/g,"'").trim();z.push({key:A,value:u}),w=I}return z})(K);for(let{key:O,value:z}of j)if(O==="actions"||O==="providers"||O==="evaluators")P[O]=z?z.split(",").map((J)=>J.trim()):[];else if(O==="simple")P[O]=z.toLowerCase()==="true";else P[O]=z;if(Object.keys(P).length===0)return r8.warn("No key-value pairs extracted from XML content"),r8.debug({xmlPreview:K.substring(0,200)+"..."},"XML content was"),null;return P}function E_$($){let q=null,K=$.match(Am);try{if(K)q=JSON.parse(hV(K[1].trim()));else q=JSON.parse(hV($.trim()))}catch(P){return null}if(q&&typeof q==="object"&&!Array.isArray(q))return q;return null}var hV=($)=>{return $=$.replace(/\{\s+/,"{").replace(/\s+\}/,"}").trim(),$=$.replace(/("[\w\d_-]+")\s*: \s*(?!"|\[)([\s\S]+?)(?=(,\s*"|\}$))/g,'$1: "$2"'),$=$.replace(/"([^"]+)"\s*:\s*'([^']*)'/g,(q,K,P)=>`"${K}": "${P}"`),$=$.replace(/("[\w\d_-]+")\s*:\s*([A-Za-z_]+)(?!["\w])/g,'$1: "$2"'),$};function h_$($,q){if($.length<=q)return $;let K=$.lastIndexOf(".",q-1);if(K!==-1){let j=$.slice(0,K+1).trim();if(j.length>0)return j}let P=$.lastIndexOf(" ",q-1);if(P!==-1){let j=$.slice(0,P).trim();if(j.length>0)return`${j}...`}return`${$.slice(0,q-3).trim()}...`}async function R_$($,q=512,K=20){r8.debug("[splitChunks] Starting text split");let P=3.5,j=await new z7({chunkSize:Number(Math.floor(q*P)),chunkOverlap:Number(Math.floor(K*P))}).splitText($);return r8.debug({numberOfChunks:j.length,averageChunkSize:j.reduce((O,z)=>O+z.length,0)/j.length},"[splitChunks] Split complete"),j}async function I_$($,q,K){if(!$)throw Error("Trim tokens received a null prompt");if($.length<q/5)return $;if(q<=0)throw Error("maxTokens must be positive");let P=await K.useModel(Sq.TEXT_TOKENIZER_ENCODE,{prompt:$});if(P.length<=q)return $;let _=P.slice(-q);return await K.useModel(Sq.TEXT_TOKENIZER_DECODE,{tokens:_})}function nW(){let $=new WeakSet;return function(q,K){if(typeof K==="object"&&K!==null){if($.has(K))return"[Circular]";$.add(K)}return K}}function D_$($){if(!$)return!1;let q=["YES","Y","TRUE","T","1","ON","ENABLE"],K=["NO","N","FALSE","F","0","OFF","DISABLE"],P=$.trim().toUpperCase();if(q.includes(P))return!0;if(K.includes(P))return!1;return!1}var Gm=i$.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,"Invalid UUID format");function Vm($){let q=Gm.safeParse($);return q.success?q.data:null}function D7($){if(typeof $==="number")$=$.toString();if(typeof $!=="string")throw TypeError("Value must be string");let q=Vm($);if(q)return q;let K=encodeURIComponent($),_=Sm(K).slice(0,16);return _[8]=_[8]&63|128,_[6]=_[6]&15|0,Nm(_)}async function g_$($){if(!iW())return;let q=$.map(async(K)=>{let P=encodeURIComponent(K),_=await bV(P);f_.set(P,_)});await Promise.all(q)}var f_=new Map,yO=null;function iW(){if(yO!==null)return yO;try{if(typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.subtle&&typeof globalThis.crypto.subtle.digest==="function")return yO=!0,!0}catch{}return yO=!1,!1}function Sm($){let q=f_.get($);if(q)return q;let K=uV($);if(f_.set($,K),iW())bV($).then((P)=>{f_.set($,P)}).catch(()=>{});if(f_.size>1e4)Array.from(f_.keys()).slice(0,5000).forEach((_)=>f_.delete(_));return K}async function bV($){if(iW())try{let K=new TextEncoder().encode($),P=await globalThis.crypto.subtle.digest("SHA-1",K);return new Uint8Array(P)}catch{}return uV($)}function uV($){let q=Mm($),K=q.length,P=new Uint8Array(K+9+63>>>6<<6);P.set(q),P[K]=128;let _=K*8,j=new DataView(P.buffer);j.setUint32(P.length-4,_>>>0,!1),j.setUint32(P.length-8,Math.floor(_/4294967296)>>>0,!1);let O=1732584193,z=4023233417,J=2562383102,w=271733878,G=3285377520,f=new Uint32Array(80);for(let C=0;C<P.length;C+=64){for(let u=0;u<16;u++)f[u]=j.getUint32(C+u*4,!1);for(let u=16;u<80;u++){let y=f[u-3]^f[u-8]^f[u-14]^f[u-16];f[u]=y<<1|y>>>31}let E=O,R=z,I=J,D=w,b=G;for(let u=0;u<80;u++){let y,c;if(u<20)y=R&I|~R&D,c=1518500249;else if(u<40)y=R^I^D,c=1859775393;else if(u<60)y=R&I|R&D|I&D,c=2400959708;else y=R^I^D,c=3395469782;let m=(E<<5|E>>>27)+y+b+c+f[u]>>>0;b=D,D=I,I=(R<<30|R>>>2)>>>0,R=E,E=m}O=O+E>>>0,z=z+R>>>0,J=J+I>>>0,w=w+D>>>0,G=G+b>>>0}let A=new Uint8Array(20),V=new DataView(A.buffer);return V.setUint32(0,O,!1),V.setUint32(4,z,!1),V.setUint32(8,J,!1),V.setUint32(12,w,!1),V.setUint32(16,G,!1),A}function Mm($){if(typeof TextEncoder<"u")return new TextEncoder().encode($);let q=[];for(let K=0;K<$.length;K++){let P=$.charCodeAt(K);if(P<128)q.push(P);else if(P<2048)q.push(192|P>>6,128|P&63);else if(P<55296||P>=57344)q.push(224|P>>12,128|P>>6&63,128|P&63);else{K++;let _=65536+((P&1023)<<10|$.charCodeAt(K)&1023);q.push(240|_>>18,128|_>>12&63,128|_>>6&63,128|_&63)}}return new Uint8Array(q)}function Nm($){let q=[];for(let K=0;K<$.length;K++){let P=$[K].toString(16).padStart(2,"0");q.push(P)}return q.slice(0,4).join("")+"-"+q.slice(4,6).join("")+"-"+q.slice(6,8).join("")+"-"+q.slice(8,10).join("")+"-"+q.slice(10,16).join("")}var L_$=($)=>{if($.startsWith("image/"))return"image";if($.startsWith("video/"))return"video";if($.startsWith("audio/"))return"audio";if($.includes("pdf")||$.includes("document")||$.startsWith("text/"))return"document";return};function b_$($){return`http://localhost:${xK("SERVER_PORT","3000")}${$}`}var yV=i$.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,"Invalid UUID format"),Cm=i$.object({text:i$.string().optional(),thought:i$.string().optional(),actions:i$.array(i$.string()).optional(),providers:i$.array(i$.string()).optional(),source:i$.string().optional(),target:i$.string().optional(),url:i$.string().optional(),inReplyTo:yV.optional(),attachments:i$.array(i$.any()).optional(),channelType:i$.nativeEnum(l7).optional()}).passthrough(),Em=i$.object({name:i$.string(),content:Cm}),hm=i$.object({directory:i$.string(),shared:i$.boolean().optional()}),Rm=i$.union([i$.string(),i$.object({path:i$.string(),shared:i$.boolean().optional()}),hm]),Im=i$.union([i$.string(),i$.function().optional()]),Dm=i$.object({all:i$.array(i$.string()).optional(),chat:i$.array(i$.string()).optional(),post:i$.array(i$.string()).optional()}).optional(),gm=i$.record(i$.string(),i$.union([i$.string(),i$.boolean(),i$.number(),i$.any()])).optional(),Lm=i$.record(i$.string(),i$.union([i$.string(),i$.boolean(),i$.number()])).optional(),bm=i$.object({id:yV.optional(),name:i$.string().min(1,"Character name is required"),username:i$.string().optional(),system:i$.string().optional(),templates:i$.record(i$.string(),Im).optional(),bio:i$.union([i$.string(),i$.array(i$.string())]),messageExamples:i$.array(i$.array(Em)).optional(),postExamples:i$.array(i$.string()).optional(),topics:i$.array(i$.string()).optional(),adjectives:i$.array(i$.string()).optional(),knowledge:i$.array(Rm).optional(),plugins:i$.array(i$.string()).optional(),settings:gm,secrets:Lm,style:Dm}).strict();function pV($){let q=bm.safeParse($);if(q.success)return{success:!0,data:q.data};return{success:!1,error:{message:`Character validation failed: ${q.error.message}`,issues:q.error.issues}}}function x_$($){try{let q=JSON.parse($);return pV(q)}catch(q){return{success:!1,error:{message:`Invalid JSON: ${q instanceof Error?q.message:"Unknown JSON parsing error"}`}}}}function c_$($){return pV($).success}function B8(){return typeof Buffer<"u"&&typeof Buffer.from==="function"}function Uo($){let q=$.replace(/[^0-9a-fA-F]/g,"");if(B8())return Buffer.from(q,"hex");let K=new Uint8Array(q.length/2);for(let P=0;P<K.length;P++)K[P]=parseInt(q.substr(P*2,2),16);return K}function Fo($,q="utf8"){if(B8()){let P=q==="utf-8"?"utf8":q;return Buffer.from($,P)}if(q==="base64"){let P=atob($),_=new Uint8Array(P.length);for(let j=0;j<P.length;j++)_[j]=P.charCodeAt(j);return _}return new TextEncoder().encode($)}function PM($){if(B8()&&Buffer.isBuffer($))return $.toString("hex");let q=$ instanceof Uint8Array?$:new Uint8Array($),K="";for(let P=0;P<q.length;P++){let _=q[P].toString(16);K+=_.length===1?"0"+_:_}return K}function ao($,q="utf8"){if(B8()&&Buffer.isBuffer($)){let _=q==="utf-8"?"utf8":q;return $.toString(_)}let K=$ instanceof Uint8Array?$:new Uint8Array($);if(q==="hex")return PM(K);if(q==="base64"){let _="";for(let j=0;j<K.length;j++)_+=String.fromCharCode(K[j]);return btoa(_)}return new TextDecoder().decode(K)}function Qo($){if(!$)return!1;if(B8()&&Buffer.isBuffer($))return!0;return $ instanceof Uint8Array||$ instanceof ArrayBuffer||typeof $==="object"&&$.buffer instanceof ArrayBuffer&&typeof $.byteLength==="number"&&!Array.isArray($)}function eo($){if(B8())return Buffer.alloc($);return new Uint8Array($)}function so($){if(B8())return Buffer.from($);return new Uint8Array($)}function $r($){if(B8()&&$.every((_)=>Buffer.isBuffer(_)))return Buffer.concat($);let q=0;for(let _ of $)q+=_.length;let K=new Uint8Array(q),P=0;for(let _ of $){let j=_ instanceof Uint8Array?_:new Uint8Array(_);K.set(j,P),P+=j.length}return K}function qr($,q,K){if(B8()&&Buffer.isBuffer($))return $.slice(q,K);return($ instanceof Uint8Array?$:new Uint8Array($)).slice(q,K)}function Kr($,q){if($.length!==q.length)return!1;let K=$ instanceof Uint8Array?$:new Uint8Array($),P=q instanceof Uint8Array?q:new Uint8Array(q);for(let _=0;_<K.length;_++)if(K[_]!==P[_])return!1;return!0}function _r($){return $.length}function Pr($){if(B8())try{return(Bq(),w6(tq)).randomBytes($)}catch{}let q=new Uint8Array($);if(typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.getRandomValues)globalThis.crypto.getRandomValues(q);else for(let K=0;K<$;K++)q[K]=Math.floor(Math.random()*256);return q}var oK={fromHex:Uo,fromString:Fo,fromBytes:so,toHex:PM,toString:ao,isBuffer:Qo,alloc:eo,concat:$r,slice:qr,equals:Kr,byteLength:_r,randomBytes:Pr};var r_$=($,q)=>{if(!$.length||q<=0)return"";let K=$.filter((O)=>O.examples&&Array.isArray(O.examples)&&O.examples.length>0);if(!K.length)return"";let P=K.map((O)=>[...O.examples||[]]),_=[],j=P.map((O,z)=>O.length>0?z:-1).filter((O)=>O!==-1);while(_.length<q&&j.length>0){let O=Math.floor(Math.random()*j.length),z=j[O],J=P[z],w=Math.floor(Math.random()*J.length);if(_.push(J.splice(w,1)[0]),J.length===0)j.splice(O,1)}return Or(_)},Or=($)=>{return $.map((K)=>{let P=Array.from({length:5},()=>GO({dictionaries:[VO]}));return`
349
+ `)},gV=($)=>{let K=new Date().getTime()-$,P=Math.abs(K),_=Math.floor(P/1000),j=Math.floor(_/60),O=Math.floor(j/60),z=Math.floor(O/24);if(P<60000)return"just now";if(j<60)return`${j} minute${j!==1?"s":""} ago`;if(O<24)return`${O} hour${O!==1?"s":""} ago`;return`${z} day${z!==1?"s":""} ago`},Am=/```json\n([\s\S]*?)\n```/;function LV($){if(!$)return null;let q=$.match(/<response>([\s\S]*?)<\/response>/),K;if(q)K=q[1],r8.debug("Found response XML block");else{let z=((J)=>{let w=0,G=J.length;while(w<G){let f=J.indexOf("<",w);if(f===-1)break;if(J.startsWith("</",f)||J.startsWith("<!--",f)||J.startsWith("<?",f)){w=f+1;continue}let A=f+1,V="";while(A<G){let b=J[A];if(/^[A-Za-z0-9_-]$/.test(b)){V+=b,A++;continue}break}if(!V){w=f+1;continue}let C=J.indexOf(">",A);if(C===-1)break;let E=J.slice(f,C+1);if(/\/\s*>$/.test(E)){w=C+1;continue}let R=`</${V}>`,I=1,D=C+1;while(I>0&&D<G){let b=J.indexOf(`<${V}`,D),u=J.indexOf(R,D);if(u===-1)break;if(b!==-1&&b<u){let y=J.indexOf(">",b+1);if(y===-1)break;let c=J.slice(b,y+1);if(/\/\s*>$/.test(c))D=y+1;else I++,D=y+1}else I--,D=u+R.length}if(I===0){let b=D-R.length,u=J.slice(C+1,b);return{tag:V,content:u}}w=C+1}return null})($);if(!z)return r8.warn("Could not find XML block in text"),r8.debug({textPreview:$.substring(0,200)+"..."},"Text content"),null;K=z.content,r8.debug(`Found XML block with tag: ${z.tag}`)}let P={},j=((O)=>{let z=[],J=O.length,w=0;while(w<J){let G=O.indexOf("<",w);if(G===-1)break;if(O.startsWith("</",G)||O.startsWith("<!--",G)||O.startsWith("<?",G)){w=G+1;continue}let f=G+1,A="";while(f<J){let y=O[f];if(/^[A-Za-z0-9_-]$/.test(y)){A+=y,f++;continue}break}if(!A){w=G+1;continue}let V=O.indexOf(">",f);if(V===-1)break;let C=O.slice(G,V+1);if(/\/\s*>$/.test(C)){w=V+1;continue}let E=`</${A}>`,R=1,I=V+1;while(R>0&&I<J){let y=O.indexOf(`<${A}`,I),c=O.indexOf(E,I);if(c===-1)break;if(y!==-1&&y<c){let m=O.indexOf(">",y+1);if(m===-1)break;let q$=O.slice(y,m+1);if(!/\/\s*>$/.test(q$))R++;I=m+1}else R--,I=c+E.length}if(R!==0){w=V+1;continue}let D=I-E.length,u=O.slice(V+1,D).replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&apos;/g,"'").trim();z.push({key:A,value:u}),w=I}return z})(K);for(let{key:O,value:z}of j)if(O==="actions"||O==="providers"||O==="evaluators")P[O]=z?z.split(",").map((J)=>J.trim()):[];else if(O==="simple")P[O]=z.toLowerCase()==="true";else P[O]=z;if(Object.keys(P).length===0)return r8.warn("No key-value pairs extracted from XML content"),r8.debug({xmlPreview:K.substring(0,200)+"..."},"XML content was"),null;return P}function E_$($){let q=null,K=$.match(Am);try{if(K)q=JSON.parse(hV(K[1].trim()));else q=JSON.parse(hV($.trim()))}catch(P){return null}if(q&&typeof q==="object"&&!Array.isArray(q))return q;return null}var hV=($)=>{return $=$.replace(/\{\s+/,"{").replace(/\s+\}/,"}").trim(),$=$.replace(/("[\w\d_-]+")\s*: \s*(?!"|\[)([\s\S]+?)(?=(,\s*"|\}$))/g,'$1: "$2"'),$=$.replace(/"([^"]+)"\s*:\s*'([^']*)'/g,(q,K,P)=>`"${K}": "${P}"`),$=$.replace(/("[\w\d_-]+")\s*:\s*([A-Za-z_]+)(?!["\w])/g,'$1: "$2"'),$};function h_$($,q){if($.length<=q)return $;let K=$.lastIndexOf(".",q-1);if(K!==-1){let j=$.slice(0,K+1).trim();if(j.length>0)return j}let P=$.lastIndexOf(" ",q-1);if(P!==-1){let j=$.slice(0,P).trim();if(j.length>0)return`${j}...`}return`${$.slice(0,q-3).trim()}...`}async function R_$($,q=512,K=20){r8.debug("[splitChunks] Starting text split");let P=3.5,j=await new z7({chunkSize:Number(Math.floor(q*P)),chunkOverlap:Number(Math.floor(K*P))}).splitText($);return r8.debug({numberOfChunks:j.length,averageChunkSize:j.reduce((O,z)=>O+z.length,0)/j.length},"[splitChunks] Split complete"),j}async function I_$($,q,K){if(!$)throw Error("Trim tokens received a null prompt");if($.length<q/5)return $;if(q<=0)throw Error("maxTokens must be positive");let P=await K.useModel(Sq.TEXT_TOKENIZER_ENCODE,{prompt:$});if(P.length<=q)return $;let _=P.slice(-q);return await K.useModel(Sq.TEXT_TOKENIZER_DECODE,{tokens:_})}function nW(){let $=new WeakSet;return function(q,K){if(typeof K==="object"&&K!==null){if($.has(K))return"[Circular]";$.add(K)}return K}}function D_$($){if(!$)return!1;let q=["YES","Y","TRUE","T","1","ON","ENABLE"],K=["NO","N","FALSE","F","0","OFF","DISABLE"],P=$.trim().toUpperCase();if(q.includes(P))return!0;if(K.includes(P))return!1;return!1}var Gm=i$.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,"Invalid UUID format");function Vm($){let q=Gm.safeParse($);return q.success?q.data:null}function D7($){if(typeof $==="number")$=$.toString();if(typeof $!=="string")throw TypeError("Value must be string");let q=Vm($);if(q)return q;let K=encodeURIComponent($),_=Sm(K).slice(0,16);return _[8]=_[8]&63|128,_[6]=_[6]&15|0,Nm(_)}async function g_$($){if(!iW())return;let q=$.map(async(K)=>{let P=encodeURIComponent(K),_=await bV(P);f_.set(P,_)});await Promise.all(q)}var f_=new Map,yO=null;function iW(){if(yO!==null)return yO;try{if(typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.subtle&&typeof globalThis.crypto.subtle.digest==="function")return yO=!0,!0}catch{}return yO=!1,!1}function Sm($){let q=f_.get($);if(q)return q;let K=uV($);if(f_.set($,K),iW())bV($).then((P)=>{f_.set($,P)}).catch(()=>{});if(f_.size>1e4)Array.from(f_.keys()).slice(0,5000).forEach((_)=>f_.delete(_));return K}async function bV($){if(iW())try{let K=new TextEncoder().encode($),P=await globalThis.crypto.subtle.digest("SHA-1",K);return new Uint8Array(P)}catch{}return uV($)}function uV($){let q=Mm($),K=q.length,P=new Uint8Array(K+9+63>>>6<<6);P.set(q),P[K]=128;let _=K*8,j=new DataView(P.buffer);j.setUint32(P.length-4,_>>>0,!1),j.setUint32(P.length-8,Math.floor(_/4294967296)>>>0,!1);let O=1732584193,z=4023233417,J=2562383102,w=271733878,G=3285377520,f=new Uint32Array(80);for(let C=0;C<P.length;C+=64){for(let u=0;u<16;u++)f[u]=j.getUint32(C+u*4,!1);for(let u=16;u<80;u++){let y=f[u-3]^f[u-8]^f[u-14]^f[u-16];f[u]=y<<1|y>>>31}let E=O,R=z,I=J,D=w,b=G;for(let u=0;u<80;u++){let y,c;if(u<20)y=R&I|~R&D,c=1518500249;else if(u<40)y=R^I^D,c=1859775393;else if(u<60)y=R&I|R&D|I&D,c=2400959708;else y=R^I^D,c=3395469782;let m=(E<<5|E>>>27)+y+b+c+f[u]>>>0;b=D,D=I,I=(R<<30|R>>>2)>>>0,R=E,E=m}O=O+E>>>0,z=z+R>>>0,J=J+I>>>0,w=w+D>>>0,G=G+b>>>0}let A=new Uint8Array(20),V=new DataView(A.buffer);return V.setUint32(0,O,!1),V.setUint32(4,z,!1),V.setUint32(8,J,!1),V.setUint32(12,w,!1),V.setUint32(16,G,!1),A}function Mm($){if(typeof TextEncoder<"u")return new TextEncoder().encode($);let q=[];for(let K=0;K<$.length;K++){let P=$.charCodeAt(K);if(P<128)q.push(P);else if(P<2048)q.push(192|P>>6,128|P&63);else if(P<55296||P>=57344)q.push(224|P>>12,128|P>>6&63,128|P&63);else{K++;let _=65536+((P&1023)<<10|$.charCodeAt(K)&1023);q.push(240|_>>18,128|_>>12&63,128|_>>6&63,128|_&63)}}return new Uint8Array(q)}function Nm($){let q=[];for(let K=0;K<$.length;K++){let P=$[K].toString(16).padStart(2,"0");q.push(P)}return q.slice(0,4).join("")+"-"+q.slice(4,6).join("")+"-"+q.slice(6,8).join("")+"-"+q.slice(8,10).join("")+"-"+q.slice(10,16).join("")}var L_$=($)=>{if($.startsWith("image/"))return"image";if($.startsWith("video/"))return"video";if($.startsWith("audio/"))return"audio";if($.includes("pdf")||$.includes("document")||$.startsWith("text/"))return"document";return};function b_$($){return`http://localhost:${xK("SERVER_PORT","3000")}${$}`}var yV=i$.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,"Invalid UUID format"),Cm=i$.object({text:i$.string().optional(),thought:i$.string().optional(),actions:i$.array(i$.string()).optional(),providers:i$.array(i$.string()).optional(),source:i$.string().optional(),target:i$.string().optional(),url:i$.string().optional(),inReplyTo:yV.optional(),attachments:i$.array(i$.object()).optional(),channelType:i$.enum(l7).optional()}).passthrough(),Em=i$.object({name:i$.string(),content:Cm}),hm=i$.object({directory:i$.string(),shared:i$.boolean().optional()}),Rm=i$.union([i$.string(),i$.object({path:i$.string(),shared:i$.boolean().optional()}),hm]),Im=i$.union([i$.string(),i$.function().optional()]),Dm=i$.object({all:i$.array(i$.string()).optional(),chat:i$.array(i$.string()).optional(),post:i$.array(i$.string()).optional()}).optional(),gm=i$.record(i$.string(),i$.union([i$.string(),i$.boolean(),i$.number(),i$.object()])).optional(),Lm=i$.record(i$.string(),i$.union([i$.string(),i$.boolean(),i$.number()])).optional(),bm=i$.object({id:yV.optional(),name:i$.string().min(1,"Character name is required"),username:i$.string().optional(),system:i$.string().optional(),templates:i$.record(i$.string(),Im).optional(),bio:i$.union([i$.string(),i$.array(i$.string())]),messageExamples:i$.array(i$.array(Em)).optional(),postExamples:i$.array(i$.string()).optional(),topics:i$.array(i$.string()).optional(),adjectives:i$.array(i$.string()).optional(),knowledge:i$.array(Rm).optional(),plugins:i$.array(i$.string()).optional(),settings:gm,secrets:Lm,style:Dm}).strict();function pV($){let q=bm.safeParse($);if(q.success)return{success:!0,data:q.data};return{success:!1,error:{message:`Character validation failed: ${q.error.message}`,issues:q.error.issues}}}function x_$($){try{let q=JSON.parse($);return pV(q)}catch(q){return{success:!1,error:{message:`Invalid JSON: ${q instanceof Error?q.message:"Unknown JSON parsing error"}`}}}}function c_$($){return pV($).success}function B8(){return typeof Buffer<"u"&&typeof Buffer.from==="function"}function Uo($){let q=$.replace(/[^0-9a-fA-F]/g,"");if(B8())return Buffer.from(q,"hex");let K=new Uint8Array(q.length/2);for(let P=0;P<K.length;P++)K[P]=parseInt(q.substr(P*2,2),16);return K}function Fo($,q="utf8"){if(B8()){let P=q==="utf-8"?"utf8":q;return Buffer.from($,P)}if(q==="base64"){let P=atob($),_=new Uint8Array(P.length);for(let j=0;j<P.length;j++)_[j]=P.charCodeAt(j);return _}return new TextEncoder().encode($)}function PM($){if(B8()&&Buffer.isBuffer($))return $.toString("hex");let q=$ instanceof Uint8Array?$:new Uint8Array($),K="";for(let P=0;P<q.length;P++){let _=q[P].toString(16);K+=_.length===1?"0"+_:_}return K}function ao($,q="utf8"){if(B8()&&Buffer.isBuffer($)){let _=q==="utf-8"?"utf8":q;return $.toString(_)}let K=$ instanceof Uint8Array?$:new Uint8Array($);if(q==="hex")return PM(K);if(q==="base64"){let _="";for(let j=0;j<K.length;j++)_+=String.fromCharCode(K[j]);return btoa(_)}return new TextDecoder().decode(K)}function Qo($){if(!$)return!1;if(B8()&&Buffer.isBuffer($))return!0;return $ instanceof Uint8Array||$ instanceof ArrayBuffer||typeof $==="object"&&$.buffer instanceof ArrayBuffer&&typeof $.byteLength==="number"&&!Array.isArray($)}function eo($){if(B8())return Buffer.alloc($);return new Uint8Array($)}function so($){if(B8())return Buffer.from($);return new Uint8Array($)}function $r($){if(B8()&&$.every((_)=>Buffer.isBuffer(_)))return Buffer.concat($);let q=0;for(let _ of $)q+=_.length;let K=new Uint8Array(q),P=0;for(let _ of $){let j=_ instanceof Uint8Array?_:new Uint8Array(_);K.set(j,P),P+=j.length}return K}function qr($,q,K){if(B8()&&Buffer.isBuffer($))return $.slice(q,K);return($ instanceof Uint8Array?$:new Uint8Array($)).slice(q,K)}function Kr($,q){if($.length!==q.length)return!1;let K=$ instanceof Uint8Array?$:new Uint8Array($),P=q instanceof Uint8Array?q:new Uint8Array(q);for(let _=0;_<K.length;_++)if(K[_]!==P[_])return!1;return!0}function _r($){return $.length}function Pr($){if(B8())try{return(Bq(),w6(tq)).randomBytes($)}catch{}let q=new Uint8Array($);if(typeof globalThis<"u"&&globalThis.crypto&&globalThis.crypto.getRandomValues)globalThis.crypto.getRandomValues(q);else for(let K=0;K<$;K++)q[K]=Math.floor(Math.random()*256);return q}var oK={fromHex:Uo,fromString:Fo,fromBytes:so,toHex:PM,toString:ao,isBuffer:Qo,alloc:eo,concat:$r,slice:qr,equals:Kr,byteLength:_r,randomBytes:Pr};var r_$=($,q)=>{if(!$.length||q<=0)return"";let K=$.filter((O)=>O.examples&&Array.isArray(O.examples)&&O.examples.length>0);if(!K.length)return"";let P=K.map((O)=>[...O.examples||[]]),_=[],j=P.map((O,z)=>O.length>0?z:-1).filter((O)=>O!==-1);while(_.length<q&&j.length>0){let O=Math.floor(Math.random()*j.length),z=j[O],J=P[z],w=Math.floor(Math.random()*J.length);if(_.push(J.splice(w,1)[0]),J.length===0)j.splice(O,1)}return Or(_)},Or=($)=>{return $.map((K)=>{let P=Array.from({length:5},()=>GO({dictionaries:[VO]}));return`
350
350
  ${K.map((j)=>{let O=`${j.name}: ${j.content.text}`;for(let z=0;z<P.length;z++)O=O.replaceAll(`{{name${z+1}}}`,P[z]);return O}).join(`
351
351
  `)}`}).join(`
352
352
  `)};function n_$($){if(!$?.length)return"";return[...$].sort(()=>Math.random()-0.5).map((q)=>q.name).join(", ")}function i_$($){if(!$?.length)return"";return[...$].sort(()=>Math.random()-0.5).map((q)=>`- **${q.name}**: ${q.description||"No description available"}`).join(`
@@ -633,5 +633,5 @@ Data: ${JSON.stringify(K.metadata)}
633
633
  `}`}).join(`
634
634
  `)}var HP$=!0,JP$=!1,TP$={check:async()=>({status:"not-applicable",environment:"browser"}),isHealthy:()=>!0};export{Vm as validateUuid,pV as validateCharacter,n4$ as updateWorldSettings,WM as unsaltWorldSettings,Vr as unsaltSettingValue,h_$ as truncateToCompleteSentence,I_$ as trimTokens,ao as toString,PM as toHex,D7 as stringToUuid,R_$ as splitChunks,qr as slice,P4$ as shouldRespondTemplate,Y8$ as setEnv,TP$ as serverHealth,Sr as saltWorldSettings,Gr as saltSettingValue,nW as safeReplacer,T_$ as recentLogs,Pr as randomBytes,g_$ as prewarmUuidCache,j4$ as postCreationTemplate,LV as parseKeyValueXml,E_$ as parseJSONObjectFromText,D_$ as parseBooleanFromText,x_$ as parseAndValidateCharacter,hV as normalizeJsonString,W4$ as multiStepSummaryTemplate,z4$ as multiStepDecisionTemplate,O4$ as messageHandlerTemplate,c6 as logger,c_$ as isValidCharacter,JP$ as isNode,Q_$ as isMessageMetadata,a_$ as isFragmentMetadata,q4$ as isFragmentMemory,F_$ as isDocumentMetadata,$4$ as isDocumentMemory,e_$ as isDescriptionMetadata,s_$ as isCustomMetadata,Qo as isBuffer,HP$ as isBrowser,t4$ as initializeOnboarding,W8$ as initBrowserEnvironment,v4$ as imageDescriptionTemplate,v8$ as hasEnv,i4$ as getWorldSettings,w4$ as getUserServerRole,ur as getTypedService,C_ as getSalt,tG as getNumberEnv,K4$ as getMemoryText,b_$ as getLocalServerUrl,N4 as getEnvironment,xK as getEnv,vP$ as getEntityDetails,L_$ as getContentTypeFromMimeType,z8$ as getBooleanEnv,Fo as fromString,Uo as fromHex,so as fromBytes,gV as formatTimestamp,N_$ as formatPosts,C_$ as formatMessages,zP$ as formatEntities,i_$ as formatActions,n_$ as formatActionNames,Z4$ as findWorldsForOwner,YP$ as findEntityByName,Kr as equals,B4$ as encryptedCharacter,zM as encryptStringValue,YM as encryptObjectValues,J_$ as elizaLogger,rG as detectEnvironment,Q4$ as defineService,U4$ as decryptedCharacter,QO as decryptStringValue,QO as decryptSecret,vM as decryptObjectValues,H_$ as customLevels,H8$ as currentRuntime,N_ as createUniqueUuid,kr as createSettingFromConfig,yr as createServiceError,Mr as createService,U_$ as createMessageMemory,I7 as createLogger,$r as concat,S_$ as composePromptFromState,IV as composePrompt,r_$ as composeActionExamples,r4$ as clearSaltCache,bm as characterSchema,_r as byteLength,Y4$ as booleanFooter,Rr as asUUID,eo as alloc,M_$ as addHeader,v_$ as __loggerTestHooks,cr as VECTOR_DIMS,GM as TeeType,AM as TEEMode,br as ServiceType,HM as ServiceBuilder,Kj as Service,fr as Semaphore,VM as SOCKET_MESSAGE_TYPE,XM as Role,kM as PlatformPrefix,Sq as ModelType,ZM as MemoryType,r4 as MODEL_SETTINGS,yH as EventType,iG as Environment,Nr as ElizaOS,jr as DatabaseAdapter,uH as ContentType,l7 as ChannelType,oK as BufferUtils,RH as BM25,fM as AgentStatus,IH as AgentRuntime};
635
635
 
636
- //# debugId=B1F757EEF555B97F64756E2164756E21
636
+ //# debugId=FCCD00C00C08C8DA64756E2164756E21
637
637
  //# sourceMappingURL=index.browser.js.map