UNPKG

agent-device

Version:

Open source device layer for AI coding agents: a CLI, MCP server, and typed Node.js API to control mobile, web, TV, and desktop apps on devices and simulators, locally or in the cloud.

1 lines • 673 B
import{rt as e}from"./sdk-io.js";import"./command.js";const t=/[\p{Cc}\p{Cf}]/u;function n(e){if(t.test(e))return!1;try{let{protocol:t}=new URL(e);return t===`http:`||t===`https:`}catch{return!1}}function r(e,t){return e===`darwin`?{command:`open`,args:[t],ignoresExitStatus:!1}:e===`win32`?{command:`rundll32.exe`,args:[`url.dll,FileProtocolHandler`,t],ignoresExitStatus:!0}:{command:`xdg-open`,args:[t],ignoresExitStatus:!1}}async function i(t){if(!n(t))return!1;let i=r(process.platform,t);try{let{exitCode:t}=await e(i.command,i.args,{allowFailure:!0,timeoutMs:5e3});return i.ignoresExitStatus||t===0}catch{return!1}}export{n as isSafeBrowserUrl,i as openUrlInBrowser};