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.27 kB
JavaScript
import{C as e,F as t,v as n}from"./sdk-contracts.js";import{l as r}from"./host2.js";import{t as i}from"./runner-startup-transport.js";import{m as a,x as o}from"./runner-contract.js";import{s}from"./runner-session-types.js";import{A as c,j as l}from"./runner-lease.js";import{C as u,d,l as f,p,y as m}from"./runner-disposal.js";function h(e){let t=s(e.startupTimeoutMs),n=t??6e5,r=new AbortController,i=setTimeout(()=>{r.abort(g(n,t!==void 0))},n);i.unref?.();let a=o(e),l=a?AbortSignal.any([a,r.signal]):r.signal;return{phase:c(n,l),timeoutMs:n,explicit:t!==void 0,exhausted:r.signal,close:()=>clearTimeout(i)}}function g(e,t){return new n(`COMMAND_FAILED`,`Apple runner start exceeded its ${t?`startup timeout`:`default start budget`} of ${e}ms`,{reason:`runner_start_budget_exhausted`,timeoutMs:e,retriable:!0,hint:t?"Raise the startup timeout, or run `prepare ios-runner` first so the runner is built before it is needed.":"Run `prepare ios-runner --timeout <ms>` so the cold build has a budget of your choosing; the session runner.log names the step that stalled."})}async function _(t,n,r){return r?await new Promise((i,o)=>{let s=r.aborted?`already-spent`:d(n,r),c=()=>{if(o(e(void 0,r.reason)),t.catch(y),a(r.reason)){s===`interested`&&u(n,r),m(n);return}p(n,r)&&f(n.deviceId)};r.aborted?c():r.addEventListener(`abort`,c,{once:!0}),t.then(i,o).finally(()=>{r.removeEventListener(`abort`,c),s===`interested`&&u(n,r)})}):await t}function v(e,t){let n=t.signal?void 0:o(t);if(!n||d(e,n)!==`interested`)return()=>{};let r=()=>{p(e,n)&&f(e.deviceId)};return n.addEventListener(`abort`,r,{once:!0}),()=>{n.removeEventListener(`abort`,r),u(e,n)}}function y(e){if(t(e))return;let i=e instanceof n?e:void 0;r({level:`warn`,phase:`ios_runner_detached_start_failed`,data:{code:i?.code,reason:i?.details?.reason,error:e instanceof Error?e.message:String(e)}})}function b(e){let t=Math.floor(e.phase.deadline?.remainingMs()??e.timeoutMs);return e.explicit?t:Math.min(i,t)}function x(e,t){let n=l(t.phase,`runner_xctestrun_build`)??t.timeoutMs,r=s(e.buildTimeoutMs);return r===void 0?n:Math.min(r,n)}export{h as openRunnerStartBudget,_ as raceRunnerStartAgainstCaller,v as reserveRunnerStartOwnerInterest,x as resolveRunnerBuildTimeoutMs,b as resolveRunnerLaunchReadinessMs};