UNPKG

eve

Version:

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

1 lines 921 B
import{InvalidArgumentError}from"#compiled/commander/index.js";import{isLocalEveServerUrl}from"#services/dev-client/local-host.js";const DEVELOPMENT_SERVER_PROTOCOLS=new Set([`http:`,`https:`]);function assertDevelopmentServerProtocol(e,t){if(!DEVELOPMENT_SERVER_PROTOCOLS.has(e.protocol))throw new InvalidArgumentError(`Expected an absolute http(s) URL, received "${t}".`)}function assertSecureRemoteProtocol(e,t){if(e.protocol===`http:`&&!isLocalEveServerUrl(e))throw new InvalidArgumentError(`Remote servers must use https://; received "${t}". Only local hosts may use http://.`)}function parseDevelopmentServerUrl(e){let t=e.trim();try{let n=new URL(t);return assertDevelopmentServerProtocol(n,e),assertSecureRemoteProtocol(n,e),n.hash=``,n.toString()}catch(t){throw t instanceof InvalidArgumentError?t:new InvalidArgumentError(`Expected an absolute http(s) URL, received "${e}".`)}}export{parseDevelopmentServerUrl};