eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
4 lines • 1.83 kB
JavaScript
function registryItemProgress(e){return(t,n,r)=>{e.setNavigation?.(void 0),e.replaceContent?.(),e.setStatus(`Adding ${t.title??t.name} · ${n+1} of ${r}`)}}function registryResultTone(e){if(e.failures.length>0&&e.items.length===0)return`error`;if(!e.outcomes?.some(e=>e.kind===`cancelled`))return e.items.length>0?`success`:void 0}function joinedTitles(e){return e.length===0?``:e.length===1?e[0]:e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(`, `)}, and ${e.at(-1)}`}function formatFailureMessage(e){return e.replace(" Try again with `",`
Try again with \``)}function resultHeadline(e,t){let n=e.filter(e=>e.kind===`failed`).length,r=e.filter(e=>e.kind===`cancelled`).length;if(n===0&&r===0)return`Added ${joinedTitles(t)}`;let i=e.length-n-r,a=[i>0?`${i} added`:void 0,n>0?`${n} failed`:void 0,r>0?`${r} cancelled`:void 0].filter(e=>e!==void 0);return`${e.length} ${e.length===1?`addition`:`additions`}: ${a.join(`, `)}`}function formatRegistrySessionResult(e){let t=e.outcomes??[...e.items.map(e=>({kind:`installed`,...e})),...e.failures.map(e=>({kind:`failed`,...e}))],n=[resultHeadline(t,e.items.map(e=>e.title))];for(let e of t){let t=e.kind===`installed`?`✓`:e.kind===`failed`?`⨯`:`–`;if(n.push(``,` ${t} ${e.title}`),e.kind===`cancelled`){n.push(` Cancelled.`);continue}if(e.kind===`failed`){n.push(...formatFailureMessage(e.message).split(`
`).map(e=>` ${e}`));continue}if(e.facts.length===0&&e.output.length===0){n.push(` Installed.`);continue}let r=Math.max(0,...e.facts.map(e=>e.label.length));for(let t of e.facts)n.push(` ${t.label.padEnd(r)} ${t.value}`);for(let t of e.output)n.push(` ${t}`)}return e.cancelled===!0&&n.push(``,`Setup stopped before the remaining selections were added.`),n.join(`
`)}export{formatRegistrySessionResult,registryItemProgress,registryResultTone};