import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";import{normalizeMcpClientConnectionDefinition,normalizeOpenApiConnectionDefinition}from"#internal/authored-definition/connection.js";import{readConnectionProtocol}from"#public/definitions/connections/protocol.js";async function compileConnectionDefinition(r,i){let a=await loadModuleBackedDefinition({agentRoot:r,kind:`connection`,source:i}),o=readConnectionProtocol(a),s=`Expected the connection export "${i.exportName??`default`}" from "${i.logicalPath}" to match the public Eve shape.`,c={connectionName:i.connectionName,exportName:i.exportName,logicalPath:i.logicalPath,sourceId:i.sourceId,sourceKind:`module`},l,u;if(o===`openapi`){let e=normalizeOpenApiConnectionDefinition(a,s);l={...c,description:e.description,protocol:`openapi`,url:e.baseUrl??``},u=e.auth}else{let e=normalizeMcpClientConnectionDefinition(a,s);l={...c,description:e.description,protocol:`mcp`,url:e.url},u=e.auth}let d=extractVercelConnectMarker(u);return d!==void 0&&(l.vercelConnect=d),l}function extractVercelConnectMarker(e){if(typeof e!=`object`||!e)return;let t=e.vercelConnect;if(typeof t!=`object`||!t)return;let n=t.connector;if(!(typeof n!=`string`||n.length===0))return{connector:n}}export{compileConnectionDefinition};