UNPKG

eve

Version:

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

1 lines 3.85 kB
import{remoteHost}from"./target.js";import{clipVisible,stripAnsi,visibleLength}from"#cli/ui/terminal-text.js";import{formatModelSummary}from"#shared/model-summary.js";function formatDevBuildStatus(e,t){let n=e.phase===`complete`;return`${n?t.glyph.success:t.glyph.validating} ${n?e.summary.replace(/ changed$/u,` updated`):`${e.summary.replace(/ (?:added|changed|removed)$/u,``)} updating…`}`}function renderModel(e){if(e.model===void 0)return;let t=e.theme.colors,n={model:e.model};if(e.reasoning!==void 0&&(n.reasoning=e.reasoning),e.fastMode===!0&&(n.fastGlyph=e.theme.glyph.fast),e.remote!==void 0){n.model=stripAnsi(e.model).replace(/\s+/gu,` `).trim();let r=stripAnsi(formatModelSummary(n)).replace(/\s+/gu,` `).trim();return t.dim(r)}return t.dim(formatModelSummary(n))}function renderServerPort(e){if(e.remote!==void 0||e.serverPort===void 0)return;let t=e.theme.colors;return t.inverse(t.gray(` :${e.serverPort} `))}const EXTERNAL_PROVIDER_DISPLAY_NAMES={codex:`chatgpt-sub`};function renderEndpoint(e){if(e.remote!==void 0||e.endpoint===void 0)return;let t=e.theme.colors,n=e.theme.glyph,clause=(e,n)=>`${t.dim(`via `)}${e}${t.dim(n)}`;if(e.endpoint.kind===`external`){let r=EXTERNAL_PROVIDER_DISPLAY_NAMES[e.endpoint.provider]??e.endpoint.provider;return{text:`${t.dim(`via ${r}`)}${n.external}`,standalone:!1}}if(e.endpoint.kind===`chatgpt`)switch(e.endpoint.state){case`ready`:return{text:`${t.dim(`via chatgpt-sub`)}${n.external}`,standalone:!1};case`checking`:return{text:t.dim(`chatgpt-sub checking…`),standalone:!0};case`signed-out`:case`reauth-required`:return{text:t.yellow(`${n.warning} chatgpt-sub login · /model`),standalone:!0};case`unavailable`:return{text:t.yellow(`${n.warning} chatgpt-sub unavailable`),standalone:!0}}if(!e.endpoint.connected)return{text:t.yellow(`${n.warning} ai-gateway`),standalone:!0};if(e.endpoint.credential===`api-key`)return{text:clause(`ai-gateway`,`(api-key)`),standalone:!1};let r=e.vercel?.identity?.projectName;return{text:clause(`ai-gateway`,`(${r===void 0?`oidc`:`oidc:${r}`})`),standalone:!1}}function buildStatusLine(e){let{theme:t,width:n}=e,r=t.colors,i=e.devBuild===void 0?void 0:formatDevBuildStatus(e.devBuild,t),a=e.logLevel===void 0?void 0:r.cyan(`logs: ${e.logLevel}`),o=renderServerPort(e),s=renderModel(e),c=e.remote===void 0?void 0:formatRemoteStatus(e.remote,t),l=renderEndpoint(e),u=c?.full??o,d=c?.badge??o,f=l!==void 0&&!l.standalone&&s!==void 0,p=f?`${s} ${l.text}`:s,m=l===void 0||f?void 0:l.text,compose=(e,t)=>{let n=t.filter(e=>e!==void 0).join(` `);return e===void 0||n.length===0?e??n:`${e} ${n}`},h=[compose(u,[a,p,m]),compose(u,[a,s]),compose(u,[a]),compose(d,[a]),compose(d,[])];if(i!==void 0){for(let e of h){let t=visibleLength(e),r=visibleLength(i);if(!(t+(t>0?2:0)+r>n))return`${e}${` `.repeat(n-t-r)}${i}`}return clipVisible(i,n)}if(h[0].length===0)return;for(let e of h)if(e.length>0&&visibleLength(e)<=n)return e;let g=h.findLast(e=>e.length>0);return clipVisible(g,n)}function formatRemoteStatus(e,t){let n=t.colors,r=e.deployment===void 0?remoteHost(e.target):`${e.deployment.projectName} (${e.deployment.environment})`,i=formatRemoteBadge(` ${t.unicode?`↗`:`->`} ${r} `,e.connection.state,t),a;switch(e.connection.state){case`checking`:a=n.dim(`Checking access…`);break;case`ready`:break;case`auth-required`:a=n.yellow(`Authenticate via OIDC`);break;case`authenticating`:a=n.dim(`Authenticating via OIDC…`);break;case`auth-failed`:a=n.yellow(`Authentication failed`);break;case`unavailable`:a=n.yellow(`Remote unavailable`)}return{badge:i,full:a===void 0?i:`${i} ${a}`}}function formatRemoteBadge(e,t,n){let r=n.colors;switch(t){case`checking`:return r.inverse(r.gray(e));case`ready`:return r.inverse(r.blue(e));case`unavailable`:case`auth-required`:case`authenticating`:case`auth-failed`:return r.inverse(r.yellow(e))}}export{buildStatusLine};