UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

6 lines 4.73 kB
import{L as e,R as t,jt as n,q as r}from"./dist-BweCayKF.js";import i from"crypto";function a(e){return r(e)?e:typeof e==`object`&&e&&`card`in e?e.card:null}function o(e){return typeof e==`object`&&e&&`files`in e?e.files??[]:[]}function s(e){return typeof e==`object`&&e&&`attachments`in e?e.attachments??[]:[]}var c=class extends Error{adapter;code;constructor(e,t,n){super(e),this.name=`AdapterError`,this.adapter=t,this.code=n}},l=class extends c{retryAfter;constructor(e,t){super(`Rate limited by ${e}${t?`, retry after ${t}s`:``}`,e,`RATE_LIMITED`),this.name=`AdapterRateLimitError`,this.retryAfter=t}},u=class extends c{constructor(e,t){super(t||`Authentication failed for ${e}`,e,`AUTH_FAILED`),this.name=`AuthenticationError`}},d=class extends c{constructor(e,t){super(t,e,`VALIDATION_ERROR`),this.name=`ValidationError`}},f=class extends c{originalError;constructor(e,t,n){super(t||`Network error communicating with ${e}`,e,`NETWORK_ERROR`),this.name=`NetworkError`,this.originalError=n}};async function p(e,t){let{platform:n,throwOnUnsupported:r=!0}=t;if(Buffer.isBuffer(e))return e;if(e instanceof ArrayBuffer)return Buffer.from(e);if(e instanceof Blob){let t=await e.arrayBuffer();return Buffer.from(t)}if(r)throw new d(n,`Unsupported file data type`);return null}var m={slack:{primary:`primary`,danger:`danger`},gchat:{primary:`primary`,danger:`danger`},teams:{primary:`positive`,danger:`destructive`},discord:{primary:`primary`,danger:`danger`}};function h(e){return n=>t(n,e)}function g(e,t){if(e)return m[t][e]}function _(e,t={}){let{boldFormat:n=`*`,lineBreak:r=` `,platform:i}=t,a=i?h(i):e=>e,o=[];e.title&&o.push(`${n}${a(e.title)}${n}`),e.subtitle&&o.push(a(e.subtitle));for(let t of e.children){let e=v(t,a);e&&o.push(e)}return o.join(r)}function v(t,r){switch(t.type){case`text`:return r(t.content);case`link`:return`${r(t.label)} (${t.url})`;case`fields`:return t.children.map(e=>`${r(e.label)}: ${r(e.value)}`).join(` `);case`actions`:return null;case`section`:return t.children.map(e=>v(e,r)).filter(Boolean).join(` `);case`table`:return n(t.headers,t.rows);case`divider`:return`---`;default:return e(t)}}var y=`aes-256-gcm`,b=12,x=16,S=/^[0-9a-fA-F]{64}$/;function C(e,t){let n=i.randomBytes(b),r=i.createCipheriv(y,t,n,{authTagLength:x}),a=Buffer.concat([r.update(e,`utf8`),r.final()]),o=r.getAuthTag();return{iv:n.toString(`base64`),data:a.toString(`base64`),tag:o.toString(`base64`)}}function w(e,t){let n=Buffer.from(e.iv,`base64`),r=Buffer.from(e.data,`base64`),a=Buffer.from(e.tag,`base64`),o=i.createDecipheriv(y,t,n,{authTagLength:x});return o.setAuthTag(a),Buffer.concat([o.update(r),o.final()]).toString(`utf8`)}function T(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.iv==`string`&&typeof t.data==`string`&&typeof t.tag==`string`}function E(e){let t=e.trim(),n=S.test(t),r=Buffer.from(t,n?`hex`:`base64`);if(r.length!==32)throw Error(`Encryption key must decode to exactly 32 bytes (received ${r.length}). Use a 64-char hex string or 44-char base64 string.`);return r}var D=`http://`,O=`https://`;function k(e){let t=e.charCodeAt(0);return t>=65&&t<=90||t>=97&&t<=122}function A(e){let t=e.charCodeAt(0);return t>=48&&t<=57}function j(e){return e!==void 0&&(k(e)||A(e)||e===`_`)}function M(e){return k(e)||A(e)||e===`.`||e===`-`}function N(e){return e===`<`||e===`>`||e.trim()===``}function P(e,t,n){return e.slice(t,t+n.length).toLowerCase()===n}function F(e,t,n){let r=0;if(P(e,t,O)?r=O.length:P(e,t,D)&&(r=D.length),r===0||t+r>=n)return t;let i=t+r;for(;i<n&&!N(e[i]);)i+=1;return i}function I(e,t,n){if(!(k(e[t])||A(e[t]))||t>0&&M(e[t-1]))return t;let r=t;for(;r<n&&M(e[r]);)r+=1;let i=e[r];if(i!==`/`&&i!==`?`&&i!==`#`)return t;let a=e.slice(t,r),o=a.lastIndexOf(`.`),s=a.slice(o+1);if(o<=0||s.length<2)return t;for(let e of s)if(!k(e))return t;for(r+=1;r<n&&!N(e[r]);)r+=1;return r}function L(e,t,n){if(e[t]!=="`")return t;let r=e.startsWith("```",t),i=r?"```":"`",a=t+i.length,o=e.indexOf(i,a);if(o===-1||o>=n)return t;if(!r){let n=e.indexOf(` `,a);if(n!==-1&&n<o)return t}return o+i.length}function R(e,t,n,r,i){let a=``,o=t;for(;o<n;){let t=L(e,o,n);if(t>o){a+=e.slice(o,t),o=t;continue}if(i&&e[o]===`<`){let t=o+1;for(;t<n&&e[t]!==`>`&&e[t]!==` `&&e[t]!==`\r`;)t+=1;if(e[t]===`>`){a+=e.slice(o,t+1),o=t+1;continue}a+=R(e,o,t,r,!1),o=t;continue}let s=F(e,o,n);if(s>o){a+=e.slice(o,s),o=s;continue}let c=I(e,o,n);if(c>o){a+=e.slice(o,c),o=c;continue}if(e[o]===`@`&&e[o-1]!==`<`&&!j(e[o-1])&&j(e[o+1])){let t=o+2;for(;t<n&&j(e[t]);)t+=1;let i=e.slice(o,t);a+=r(i,i.slice(1)),o=t;continue}a+=e[o],o+=1}return a}function z(e,t){return R(e,0,e.length,t,!0)}export{_ as a,w as c,o as d,s as f,p as g,z as h,d as i,C as l,g as m,u as n,h as o,T as p,f as r,E as s,l as t,a as u};