UNPKG

eve

Version:

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

1 lines 1.45 kB
import{hasEnvValue}from"#internal/resolve-model-endpoint-status.js";import{isChatGptModelRouting}from"#shared/chatgpt-model.js";import{getVercelOidcToken}from"#compiled/@vercel/oidc/index.js";import{buildAgentInfoResponse}from"#internal/nitro/routes/agent-info/build-agent-info-response.js";import{loadAgentInfoManifestData,resolveAgentInfoCompiledArtifactsSource}from"#internal/nitro/routes/agent-info/load-agent-info-data.js";import{getDefaultCodexTokenBroker}from"#public/models/openai/chatgpt/token-broker.js";async function createAgentInfoPayload(e){let t=await loadAgentInfoManifestData({compiledArtifactsSource:resolveAgentInfoCompiledArtifactsSource(e)}),n=t.manifest.config.dynamicModel===void 0?t.manifest.config.model.routing:void 0;return buildAgentInfoResponse(t,{mode:e.kind,gatewayCredentials:n===void 0?{apiKey:!1,oidc:!1}:await resolveGatewayCredentialPresence(n),...isChatGptModelRouting(n)?{chatgptAuth:await getDefaultCodexTokenBroker().refreshState()}:{}})}async function resolveGatewayCredentialPresence(e){let t=hasEnvValue(process.env.AI_GATEWAY_API_KEY);if(e.kind===`external`||t)return{apiKey:t,oidc:!1};try{return await getVercelOidcToken(),{apiKey:!1,oidc:!0}}catch{return{apiKey:!1,oidc:!1}}}async function handleAgentInfoRequest(e){return new Response(JSON.stringify(await createAgentInfoPayload(e)),{headers:{"cache-control":`no-store`,"content-type":`application/json; charset=utf-8`}})}export{handleAgentInfoRequest};