UNPKG

eve

Version:

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

1 lines 2.07 kB
import{resolveTuiDisplayOptions}from"./ui-options.js";import{resolveTuiTitle}from"./tui/target.js";import{randomUUID}from"node:crypto";import{findEveProjectContext}from"#internal/project-context.js";import{devBootPhase}from"#internal/dev-boot-progress.js";import{resumeDevelopmentRuntimeArtifacts,suspendDevelopmentRuntimeArtifacts}from"#services/dev-client/runtime-artifacts.js";async function runInteractiveDevelopmentUi(e){let t=await devBootPhase(`loading interactive UI`,async()=>e.runDevelopmentTui??(await import(`#cli/dev/tui/tui.js`)).runDevelopmentTui,e.report),n=e.server.appRoot??e.applicationRoot,r=await findEveProjectContext(n),i=r?.environmentRoot??n,a=r?.kind===`workspace-member`?r.member.appRoot:void 0,o=e.remoteTarget===void 0||e.existingLocalServer?{kind:`local`,serverUrl:e.server.serverUrl,workspaceRoot:i,agentRoot:a}:{kind:`remote`,serverUrl:e.server.serverUrl,workspaceRoot:i,agentRoot:a},s=resolveTuiDisplayOptions(e.options),c=resolveTuiTitle({name:e.options.name,target:o});c!==void 0&&(s.name=c);let l={target:o,initialInput:e.options.input,onboard:e.options.onboard,onBootProgress:e.report,onOnboardingStep:e.onOnboardingStep,onOnboardingTerminal:e.onOnboardingTerminal,lifecycle:e.lifecycle,...s};e.startup!==void 0&&(l.startup=e.startup),o.kind===`local`&&(l.withExclusiveTerminal=async t=>{let n=randomUUID();if(!await suspendDevelopmentRuntimeArtifacts({leaseId:n,serverUrl:e.server.serverUrl}))throw Error(`Could not pause the development server for integration setup.`);let r;try{r={ok:!0,value:await t()}}catch(e){r={error:e,ok:!1}}let i={leaseId:n,serverUrl:e.server.serverUrl,silent:!0};if(await resumeDevelopmentRuntimeArtifacts(i)===void 0&&await resumeDevelopmentRuntimeArtifacts(i)===void 0)throw Error(`Could not resume the eve development server after integration setup. Restart eve dev before making further source changes.`,r.ok?void 0:{cause:r.error});if(!r.ok)throw r.error;return r.value}),e.remoteTarget?.headers===void 0?await t(l):await t({...l,headers:e.remoteTarget.headers})}export{runInteractiveDevelopmentUi};