UNPKG

eve

Version:

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

1 lines 3.05 kB
import{remoteHost}from"./target.js";import{clipVisible,stripAnsi,visibleLength}from"#cli/ui/terminal-text.js";import{formatModelSummary}from"#shared/model-summary.js";function renderModel(e){if(e.model===void 0)return;let t=e.theme.colors,r={model:e.model};if(e.reasoning!==void 0&&(r.reasoning=e.reasoning),e.fastMode===!0&&(r.fastGlyph=e.theme.glyph.fast),e.remote!==void 0){r.model=stripAnsi(e.model).replace(/\s+/gu,` `).trim();let a=stripAnsi(formatModelSummary(r)).replace(/\s+/gu,` `).trim();return t.dim(a)}return t.dim(formatModelSummary(r))}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.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:n,width:i}=e,a=n.colors,o=e.logLevel===void 0?void 0:a.cyan(`logs: ${e.logLevel}`),s=renderServerPort(e),c=renderModel(e),l=e.vercel?.pendingDeploy?a.yellow(`/deploy pending`):void 0,u=e.remote===void 0?void 0:formatRemoteStatus(e.remote,n),d=renderEndpoint(e),f=u?.full??s,p=u?.badge??s,m=d!==void 0&&!d.standalone&&c!==void 0,h=m?`${c} ${d.text}`:c,g=d===void 0||m?void 0:d.text,compose=(e,t)=>{let n=t.filter(e=>e!==void 0).join(` `);return e===void 0||n.length===0?e??n:`${e} ${n}`},_=[compose(f,[o,h,g,l]),compose(f,[o,c,l]),compose(f,[o,l]),compose(f,[o]),compose(p,[o]),compose(p,[])];if(_[0].length!==0){for(let e of _)if(e.length>0&&visibleLength(e)<=i)return e;return clipVisible(_.findLast(e=>e.length>0),i)}}function formatRemoteStatus(t,n){let r=n.colors,i=t.deployment===void 0?remoteHost(t.target):`${t.deployment.projectName} (${t.deployment.environment})`,a=formatRemoteBadge(` ${n.unicode?`↗`:`->`} ${i} `,t.connection.state,n),o;switch(t.connection.state){case`checking`:o=r.dim(`Checking access…`);break;case`ready`:break;case`auth-required`:o=r.yellow(`Authenticate via OIDC`);break;case`authenticating`:o=r.dim(`Authenticating via OIDC…`);break;case`auth-failed`:o=r.yellow(`Authentication failed`);break;case`unavailable`:o=r.yellow(`Remote unavailable`);break}return{badge:a,full:o===void 0?a:`${a} ${o}`}}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};