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 • 2.59 kB
import{C as e,v as t}from"./sdk-contracts.js";import{c as n}from"./host2.js";import r from"node:fs";import i from"node:path";const a={iphonesimulator:`iPhoneSimulator`,iphoneos:`iPhoneOS`,appletvsimulator:`AppleTVSimulator`,appletvos:`AppleTVOS`,macosx:`MacOSX`,xrsimulator:`XRSimulator`,xros:`XROS`,watchsimulator:`WatchSimulator`,watchos:`WatchOS`},o=`/var/db/xcode_select_link`,s=`The Apple runner cache is keyed on the toolchain version, so a cache decision cannot be made without it. Check that \`xcode-select -p\` or DEVELOPER_DIR names a full Xcode install. If ${o} names a deleted Xcode, run \`sudo xcode-select -s <Xcode.app>\`.`;var c=class extends Error{file;detail;constructor(e,t){super(`${e}: ${t}`),this.file=e,this.detail=t}};function l(r,i){if(i?.aborted)throw e({phase:`apple_toolchain_identity`});let a=n();try{let e=d(a),t=m(e),n=h(e,r);return{xcodeVersion:t.version,xcodeBuildVersion:t.buildVersion,sdkName:r,sdkVersion:n.version,sdkBuildVersion:n.buildVersion}}catch(e){throw e instanceof c?new t(`COMMAND_FAILED`,`Could not read the Xcode toolchain versions the Apple runner cache is keyed on (${e.message})`,{reason:`apple_toolchain_unreadable`,...a===void 0?{}:{developerDir:a},file:e.file,detail:e.detail,hint:s}):e}}function u(){try{return m(d(n())).version}catch(e){if(e instanceof c)return;throw e}}function d(e){let t=e?.trim()||f()||`/Applications/Xcode.app/Contents/Developer`,n=g(t)??t,a=i.join(n,`Contents`,`Developer`);return r.existsSync(a)?a:n}function f(){if(p(()=>r.readlinkSync(`/var/db/xcode_select_link`))!==void 0)return p(()=>r.realpathSync(o))}function p(e){try{return e()}catch(e){let t=e.code;if(t===`ENOENT`)return;throw new c(o,t??String(e))}}function m(e){let t=i.join(e,`..`,`version.plist`),n=_(t);return{version:v(n,`CFBundleShortVersionString`,t),buildVersion:v(n,`ProductBuildVersion`,t)}}function h(e,t){let n=a[t],r=i.join(e,`Platforms`,`${n}.platform`,`Developer`,`SDKs`,`${n}.sdk`),o=i.join(r,`SDKSettings.json`),s=i.join(r,`System/Library/CoreServices/SystemVersion.plist`);return{version:y(_(o),`Version`,o),buildVersion:v(_(s),`ProductBuildVersion`,s)}}function g(e){try{return r.realpathSync(e)||void 0}catch{return}}function _(e){try{return r.readFileSync(e,`utf8`)}catch(t){throw new c(e,t.code??String(t))}}function v(e,t,n){let r=RegExp(`<key>${t}</key>\\s*<string>([^<]*)</string>`).exec(e)?.[1]?.trim();if(!r)throw new c(n,`no ${t}`);return r}function y(e,t,n){let r;try{r=JSON.parse(e)[t]}catch{throw new c(n,`not JSON`)}if(typeof r!=`string`||!r.trim())throw new c(n,`no ${t}`);return r.trim()}export{l as n,u as t};