UNPKG

eve

Version:

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

4 lines 2.89 kB
import"#compiled/commander/index.js";import{agentCommand}from"#cli/agent-command.js";import{loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{parseDevelopmentHeaderOption,resolveDevelopmentUrlTarget}from"#cli/dev/url-target.js";import{parseDevelopmentServerUrl}from"#cli/dev/url.js";import{FORCED_EXIT_BACKSTOP_MS,installShutdownSignal}from"#cli/shutdown.js";function registerAcpCommand(e){agentCommand(e.program.command(`acp`),e.applicationContext,e=>{let t=e.opts();return resolveDevelopmentUrlTarget(t,e.processedArgs[0])===void 0}).description(`Serve an eve agent through stable ACP v1 over stdio.`).argument(`[url]`,`Connect to an existing server URL`,parseDevelopmentServerUrl).option(`-u, --url <url>`,`Connect to an existing server URL`,parseDevelopmentServerUrl).option(`--scope <team>`,`Vercel team that owns the URL target`).option(`-H, --header <header>`,`Request header for a URL target, in "Name: value" form (repeatable)`,parseDevelopmentHeaderOption).addHelpText(`after`,` Without a URL, eve supervises a local development server. You can also pass a bare URL, for example: eve acp https://example.com ACP does not grant the agent access to the client's workspace or terminal. `).action(async(t,n)=>{let r=resolveDevelopmentUrlTarget(n,t);await loadDevelopmentEnvironmentFiles(e.applicationContext.root);let i=installShutdownSignal({exitAfterMs:FORCED_EXIT_BACKSTOP_MS});if(r!==void 0){try{await runAcp(e,{headers:r.headers,serverUrl:r.serverUrl,signal:i.signal,vercelScope:n.scope??process.env.EVE_VERCEL_SCOPE})}finally{i.dispose()}return}let a,o,closeServer=()=>a===void 0?Promise.resolve():(o??=a.close(),o.catch(()=>void 0),o);i.signal.addEventListener(`abort`,()=>void closeServer(),{once:!0});try{a=(e.startHost??await loadStartHost())(e.applicationContext.root,{existing:`reject`,host:`127.0.0.1`,output:`stderr`,port:0});let t=await Promise.race([a.start(),i.stopped.then(()=>void 0)]);if(t===void 0)return;await runAcp(e,{serverUrl:t.url,signal:i.signal,workspaceRoot:t.appRoot}),i.requestStop()}finally{await closeServer(),i.dispose()}})}async function runAcp(e,t){let n=e.runAcpServer??(await import(`#acp/server.js`)).runAcpServer,{vercelScope:r,...i}=t,a=typeof i.headers==`function`?void 0:i.headers,o=Object.keys(a??{}).some(e=>e.toLowerCase()===`authorization`);if(i.workspaceRoot!==void 0||o){await n({eveVersion:e.eveVersion,...i});return}let{options:s}=await(e.resolveVerifiedRemoteDevelopmentClient??(await import(`#setup/verified-remote-client.js`)).resolveVerifiedRemoteDevelopmentClient)({headers:a,serverUrl:i.serverUrl,signal:i.signal,vercelScope:r,workspaceRoot:e.applicationContext.root});await n({auth:s.auth,eveVersion:e.eveVersion,headers:s.headers,serverUrl:i.serverUrl,signal:i.signal})}async function loadStartHost(){return(await import(`#cli/dev/local-server-process.js`)).createDevelopmentServer}export{registerAcpCommand};