import{getAuthoredModuleExport,materializeAuthoredModuleExport}from"#internal/authored-module.js";import{join}from"node:path";import{toErrorMessage}from"#shared/errors.js";import{loadAuthoredModuleNamespace}from"#internal/authored-module-loader.js";async function loadModuleBackedDefinition(t){let n=getAuthoredModuleExport(await loadAuthoredModuleNamespace(join(t.agentRoot,t.source.logicalPath)),t.source);try{return await materializeAuthoredModuleExport(n)}catch(e){throw Error(`Failed to execute the ${t.kind} export "${t.source.exportName??`default`}" from "${t.displayPath??t.source.logicalPath}": ${toErrorMessage(e)}`)}}export{loadModuleBackedDefinition};