UNPKG

eve

Version:

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

1 lines • 1.74 kB
import{Client,ClientError}from"#client/index.js";import{WizardCancelledError}from"#setup/step.js";import{resolveVerifiedRemoteDevelopmentClient}from"#setup/verified-remote-client.js";import{runRemoteAuthFlow}from"#cli/dev/tui/remote-auth.js";const defaultDeps={createClient:e=>new Client(e),resolveVerifiedRemoteDevelopmentClient,runRemoteAuthFlow};async function inspectVerifiedRemoteAgent(e){let t={...defaultDeps,...e.deps},n=await t.resolveVerifiedRemoteDevelopmentClient({serverUrl:e.serverUrl,signal:e.signal,workspaceRoot:e.workspaceRoot});try{return inspection(await t.createClient(n.options).info(),verifiedScope(n))}catch(t){if(e.prompter===void 0||!isAuthenticationFailure(t)||!canAuthenticateInteractively(t,n))throw t}let r=await t.runRemoteAuthFlow({configureTrustedSources:!0,prompter:e.prompter,serverUrl:e.serverUrl,signal:e.signal,workspaceRoot:e.workspaceRoot});if(r.kind===`cancelled`)throw new WizardCancelledError;if(r.kind===`failed`)throw Error(r.message);let i={...n.options,auth:{vercelOidc:{token:r.resolveToken}},host:e.serverUrl,redirect:`manual`};return inspection(await t.createClient(i).info(),r.target.deployment.ownerId)}function inspection(e,t){return t===void 0?{info:e}:{info:e,vercelScope:t}}function verifiedScope(e){let t=e.deploymentResolution;return t?.kind===`resolved`?t.target.deployment.ownerId:void 0}function isAuthenticationFailure(e){return e instanceof ClientError&&(e.status>=300&&e.status<400||e.status===401||e.status===403)}function canAuthenticateInteractively(e,t){return e.status>=300&&e.status<400&&(e.headers.location??``).includes(`vercel.com/sso-api`)?!0:t.deploymentResolution?.kind===`resolved`||t.deploymentResolution?.kind===`forbidden`}export{inspectVerifiedRemoteAgent};