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(t,r){if(!DEVELOPMENT_SERVER_PROTOCOLS.has(t.protocol))throw new InvalidArgumentError(`Expected an absolute http(s) URL, received "${r}".`)}function assertSecureRemoteProtocol(n,r){if(n.protocol===`http:`&&!isLocalEveServerUrl(n))throw new InvalidArgumentError(`Remote servers must use https://; received "${r}". Only local hosts may use http://.`)}function parseDevelopmentServerUrl(t){let n=t.trim();try{let e=new URL(n);return assertDevelopmentServerProtocol(e,t),assertSecureRemoteProtocol(e,t),e.hash=``,e.toString()}catch(n){throw n instanceof InvalidArgumentError?n:new InvalidArgumentError(`Expected an absolute http(s) URL, received "${t}".`)}}export{parseDevelopmentServerUrl};