UNPKG

eve

Version:

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

3 lines 827 B
const ERROR_HEADLINE_PATTERN=/^\s*(?:message|name):\s*\S|^\s*[A-Z][\w$]*Error\b/u;function presentDiagnostic(e,t){let n=e.split(` `);if(n.length<=4&&e.length<=600)return{kind:`inline`,text:e};let r=n.findIndex(e=>e.trim().length>0),i=r===-1?`Diagnostic output`:n[r].trim(),a=n.slice(r+1).find(e=>ERROR_HEADLINE_PATTERN.test(e))?.trim(),o=1+(a===void 0?0:1),s={kind:`stored`,summary:clip(i),omittedLines:Math.max(0,n.length-o),path:t};return a===void 0?s:{...s,headline:clip(a)}}function formatStoredDiagnostic(e){let t=e.omittedLines,n=t===0?`diagnostic details`:`${t} diagnostic line${t===1?``:`s`}`,r=[e.summary];return e.headline!==void 0&&r.push(e.headline),r.push(`… ${n} · details: ${e.path}`),r.join(` `)}function clip(e){return e.length<=240?e:`${e.slice(0,239)}…`}export{formatStoredDiagnostic,presentDiagnostic};