UNPKG

eve

Version:

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

1 lines • 1.56 kB
import{createDevelopmentServer}from"#internal/nitro/host/start-development-server.js";import{getDevelopmentSandboxRunId}from"#execution/sandbox/development-run.js";import{reconcileCleanupIntents,recordCleanupIntent}from"#cli/dev/local-server-cleanup.js";const options=JSON.parse(process.argv[2]??`{}`),server=createDevelopmentServer(process.cwd(),{...options,onBootProgress:e=>send({type:`progress`,event:e})});let stopping=!1,removeCleanupIntent;reconcileCleanupIntents(process.cwd()).catch(()=>void 0);const send=e=>{try{process.connected&&process.send?.(e,()=>{})}catch{}},stop=()=>{if(stopping)return;stopping=!0,console.log=console.warn=console.error=()=>{},process.stdout.on(`error`,()=>{}),process.stderr.on(`error`,()=>{});let e=server.close();process.connected&&process.disconnect?.(),e.then(async()=>{await intentReady.catch(()=>void 0),await removeCleanupIntent?.().catch(()=>void 0),process.exit(0)},()=>process.exit(1))};process.on(`message`,e=>{e.type===`shutdown`&&stop()}),process.once(`disconnect`,stop),process.once(`SIGINT`,stop),process.once(`SIGTERM`,stop);const intentReady=server.start().then(async e=>{let t=getDevelopmentSandboxRunId();e.kind===`started`&&t!==void 0&&(removeCleanupIntent=await recordCleanupIntent(process.cwd(),{ownerPid:process.pid,runId:t})),send({type:`started`,handle:e}),e.kind===`existing`&&process.connected&&process.disconnect?.()},e=>{let t=e instanceof Error?e:Error(String(e));send({type:`failed`,message:t.message,stack:t.stack}),process.exitCode=1,process.connected&&process.disconnect?.()});export{};