agent-device 0.21.34 → 0.21.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.34.apk → agent-device-android-ime-helper-0.21.35.apk} +0 -0
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.35.apk.sha256 +1 -0
- package/android/ime-helper/dist/{agent-device-android-ime-helper-0.21.34.manifest.json → agent-device-android-ime-helper-0.21.35.manifest.json} +4 -4
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.34.apk → agent-device-android-snapshot-helper-0.21.35.apk} +0 -0
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.35.apk.sha256 +1 -0
- package/android/snapshot-helper/dist/{agent-device-android-snapshot-helper-0.21.34.manifest.json → agent-device-android-snapshot-helper-0.21.35.manifest.json} +7 -7
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Keyboard.swift +27 -18
- package/dist/apple/runner/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextInputProbe.swift +26 -7
- package/dist/src/agent-browser-provider.js +1 -1
- package/dist/src/agent-device-client.js +1 -1
- package/dist/src/ai-sdk.d.ts +1 -1
- package/dist/src/alert.js +1 -1
- package/dist/src/android-adb.d.ts +1 -1
- package/dist/src/app-backend.js +1 -1
- package/dist/src/app-launch.js +1 -1
- package/dist/src/app-lifecycle.js +1 -1
- package/dist/src/app-log-reconnect.js +1 -1
- package/dist/src/app-log-runtime2.js +2 -2
- package/dist/src/app-log-session-resource.js +1 -1
- package/dist/src/app-resolution.js +2 -2
- package/dist/src/app-state-runtime.d.ts +1 -1
- package/dist/src/apple-runner-platform.js +1 -1
- package/dist/src/application-lifecycle-interaction.js +1 -1
- package/dist/src/artifact-download.js +1 -1
- package/dist/src/back-mode.js +1 -1
- package/dist/src/cli-config.js +1 -1
- package/dist/src/cli-help.js +3 -2
- package/dist/src/cli.js +2 -2
- package/dist/src/client-types.d.ts +17 -4
- package/dist/src/cloud-artifacts.d.ts +2 -2
- package/dist/src/command-metadata.js +41 -41
- package/dist/src/command-schema.js +3 -1
- package/dist/src/command-tools.js +1 -1
- package/dist/src/composed-inventory-gateways.js +1 -1
- package/dist/src/composite-resource-admission.js +1 -1
- package/dist/src/connection-runtime.js +1 -1
- package/dist/src/connection.js +5 -5
- package/dist/src/contract.d.ts +2 -1
- package/dist/src/contracts.d.ts +1 -1
- package/dist/src/daemon-client-lease-beat.js +1 -1
- package/dist/src/daemon-client.js +2 -2
- package/dist/src/daemon-command-registry.js +1 -1
- package/dist/src/daemon-composition.js +1 -1
- package/dist/src/daemon-policy-file.js +1 -1
- package/dist/src/debug-symbols-facade.js +1 -1
- package/dist/src/destination-tunnel-dialer.js +27 -0
- package/dist/src/device-claim-recovery.js +1 -1
- package/dist/src/device-claims.js +1 -1
- package/dist/src/device-input-state.d.ts +1 -1
- package/dist/src/device-readiness-runtime.js +1 -1
- package/dist/src/device-selection-resolver.js +1 -1
- package/dist/src/device.js +1 -1
- package/dist/src/discovery.js +1 -1
- package/dist/src/doctor-facade.js +1 -1
- package/dist/src/durable-resource.js +1 -1
- package/dist/src/explicit-session-resolution.js +1 -1
- package/dist/src/find.js +1 -1
- package/dist/src/generic.js +1 -1
- package/dist/src/gesture-admission.js +1 -1
- package/dist/src/gesture-plan-types.d.ts +1 -1
- package/dist/src/gesture-runtime.js +1 -1
- package/dist/src/human-control.js +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/instance-client.js +1 -1
- package/dist/src/interaction.js +1 -1
- package/dist/src/interaction2.js +1 -1
- package/dist/src/interactor.js +5 -5
- package/dist/src/interactor4.js +1 -1
- package/dist/src/interactors.js +1 -1
- package/dist/src/internal/bin.js +1 -1
- package/dist/src/inventory2.js +1 -1
- package/dist/src/ios-client.js +4 -4
- package/dist/src/launch-confirmation.js +1 -1
- package/dist/src/lease-context.js +1 -1
- package/dist/src/lease-registry-scope.js +1 -1
- package/dist/src/lease.js +1 -1
- package/dist/src/leased-recording-retention.js +1 -1
- package/dist/src/legacy.js +1 -1
- package/dist/src/limrun.d.ts +6 -1
- package/dist/src/local-interactor-operation-set.js +1 -1
- package/dist/src/log-stream.js +2 -28
- package/dist/src/mechanics.js +1 -1
- package/dist/src/metro.d.ts +1 -1
- package/dist/src/network-har.js +2 -0
- package/dist/src/open-target-resolution.js +1 -1
- package/dist/src/perf-facade.js +1 -1
- package/dist/src/perf-target.js +1 -1
- package/dist/src/platform-runtime-daemon-services.js +1 -1
- package/dist/src/platform-runtime-open-target.js +1 -1
- package/dist/src/platform-runtime-operation-host.js +3 -3
- package/dist/src/platform-runtime-runtime-hints.js +1 -1
- package/dist/src/platform-runtime-unavailable.js +1 -1
- package/dist/src/platform-runtime.js +1 -1
- package/dist/src/platform-runtime2.js +1 -1
- package/dist/src/plugin-inventory.js +1 -1
- package/dist/src/provider-device-runtime.d.ts +1 -1
- package/dist/src/provider-plugin.d.ts +1 -1
- package/dist/src/proxy.js +2 -2
- package/dist/src/react-native.js +1 -1
- package/dist/src/record-runtime-response.js +1 -1
- package/dist/src/record-runtime.js +1 -1
- package/dist/src/record-trace.js +1 -1
- package/dist/src/registry.js +1 -1
- package/dist/src/replay-maestro-backend.js +3 -3
- package/dist/src/replay-script-selection.js +1 -1
- package/dist/src/replay.d.ts +1 -1
- package/dist/src/request-runtime-binding.js +1 -1
- package/dist/src/result-serialization.js +2 -1
- package/dist/src/runner-client.js +1 -1
- package/dist/src/runner-dev-tools-security.js +1 -1
- package/dist/src/runner-device-readiness.js +1 -1
- package/dist/src/runner-retention.js +1 -1
- package/dist/src/runner-selector-query.js +1 -1
- package/dist/src/runner-startup-transport.js +1 -1
- package/dist/src/runner.js +1 -1
- package/dist/src/runtime-admission.js +1 -1
- package/dist/src/runtime-deployment.js +1 -1
- package/dist/src/runtime-session.js +1 -1
- package/dist/src/runtime.js +2 -2
- package/dist/src/runtime3.js +4 -4
- package/dist/src/runtime4.js +1 -1
- package/dist/src/runtime5.js +1 -1
- package/dist/src/runtime6.js +1 -1
- package/dist/src/runtime7.js +1 -1
- package/dist/src/runtime8.js +1 -1
- package/dist/src/runtime9.js +1 -1
- package/dist/src/screen-recording-resource-recovery.js +1 -1
- package/dist/src/screen-recording-session-resource.js +1 -1
- package/dist/src/screen-recording-transport.js +1 -1
- package/dist/src/screenshot-density.js +1 -1
- package/dist/src/screenshot-runtime.js +1 -1
- package/dist/src/sdk-batch-runner.js +2 -2
- package/dist/src/sdk-batch.js +2 -2
- package/dist/src/sdk-contracts.d.ts +4 -1
- package/dist/src/sdk-device.js +1 -1
- package/dist/src/sdk-finders.d.ts +1 -1
- package/dist/src/sdk-remote-config.d.ts +8 -1
- package/dist/src/sdk-remote-config.js +1 -1
- package/dist/src/sdk-selectors.d.ts +1 -1
- package/dist/src/selector-runtime.js +1 -1
- package/dist/src/server-startup.js +1 -1
- package/dist/src/server.js +1 -1
- package/dist/src/session-artifact-paths.js +1 -1
- package/dist/src/session-device-resolution.js +1 -1
- package/dist/src/session-open.js +1 -1
- package/dist/src/session-runtime.js +1 -1
- package/dist/src/session-selector.js +1 -1
- package/dist/src/session-store.js +1 -1
- package/dist/src/session2.js +4 -4
- package/dist/src/settle-observation-capture.js +1 -1
- package/dist/src/simctl.js +1 -1
- package/dist/src/simulator-boot.js +1 -1
- package/dist/src/snapshot-diagnostics.js +1 -1
- package/dist/src/snapshot-runtime-binding.js +1 -1
- package/dist/src/snapshot-runtime-capture-input.js +1 -1
- package/dist/src/snapshot-runtime.js +1 -1
- package/dist/src/snapshot.js +1 -1
- package/dist/src/src.js +1 -1
- package/dist/src/src3.js +4 -4
- package/dist/src/src4.js +1 -1
- package/dist/src/src9.js +1 -1
- package/dist/src/store.js +1 -1
- package/dist/src/telephony-runtime.js +1 -1
- package/dist/src/touch-runtime2.js +1 -1
- package/dist/src/transport.js +2 -2
- package/dist/src/tv-remote-runtime.js +1 -1
- package/dist/src/tv-remote.js +1 -1
- package/dist/src/type-text-runtime.js +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/android/ime-helper/dist/agent-device-android-ime-helper-0.21.34.apk.sha256 +0 -1
- package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.34.apk.sha256 +0 -1
- package/dist/src/session-capture-binding.js +0 -1
- package/dist/src/session-teardown.js +0 -1
package/dist/src/transport.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{R as e}from"./sdk-contracts.js";import t from"node:crypto";import
|
|
1
|
+
import{R as e}from"./sdk-contracts.js";import{Gt as t,Kt as n,Xt as r,Yt as i,qt as a}from"./sdk-batch.js";import{m as o}from"./observability.js";import s from"node:crypto";import c from"node:path";const l=`/agent-device`,u=`x-agent-device-tenant`,d=`x-agent-device-network-access`,f=`public-only`;function p(e){return m(e,l)}function m(e,t){let n=e.endsWith(`/`)?e:`${e}/`;return new URL(t.replace(/^\/+/,``),n).toString()}function h(e){let t=e?.trim();return t?{authorization:`Bearer ${t}`,"x-agent-device-token":t}:{}}function g(e){if(!e)return;let t=e.trim();if(t&&/^[a-zA-Z0-9._-]{1,128}$/.test(t))return t}function _(e,t){return t.startsWith(`${e}:`)}function v(e){let t=e?.trim();return t?{[u]:t}:{}}function y(e){let t=e?.trim();return t?{"x-agent-device-lease-id":t}:{}}const b=`x-agent-device-instance`,x=`x-agent-device-upstream-instance`,S=`x-agent-device-instance-mismatch`;function C(e,t,n){return{jsonrpc:`2.0`,id:e,error:{code:-32001,message:t,data:n}}}function w(e,t,n={}){return{ok:!0,service:e,version:t,rpcProtocolVersion:2,...n.instanceId===void 0?{}:{instanceId:n.instanceId},...n.hostArch===void 0?{}:{hostArch:n.hostArch},...n.leaseBackends===void 0?{}:{leaseBackends:n.leaseBackends},...n.upstream===void 0?{}:{upstream:n.upstream}}}const T=`/tmp`;function E(e,t){return c.posix.join(T,`${A(e)}${k(t)}`)}function D(e){return c.posix.join(T,A(e))}function O(e,t,n){let r=k(n),i=c.posix.basename(e,r);return e===c.posix.join(T,`${i}${r}`)&&i.startsWith(`agent-device-${t}-`)&&/^\d+-[a-z0-9]+$/.test(i.slice(`agent-device-${t}-`.length))}function k(e){return e.startsWith(`.`)?e:`.${e}`}function A(e){return`agent-device-${e}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function j(e){if(e.area===`frames`)return Object.freeze({kind:`frames`,request:e,use:t});if(e.area===`memory`)return e.action===`snapshot`?Object.freeze({kind:`memory-snapshot`,request:e,use:a}):Object.freeze({kind:`memory-sample`,request:e,use:n});if(e.area===`trace`)return e.action===`start`?Object.freeze({kind:`capture-start`,request:e,use:i}):Object.freeze({kind:`capture-stop`,request:e});switch(e.action){case`start`:return Object.freeze({kind:`capture-start`,request:e,use:i});case`stop`:return Object.freeze({kind:`capture-stop`,request:e});case`report`:return Object.freeze({kind:`profile-report`,request:e,use:r})}}function M(t){let n=t.positionals??[],r=n[0]?.toLowerCase();if(r===`frames`){let i=n[1]?.toLowerCase();if(i!==void 0&&i!==`sample`||n.length>2||t.kind!==void 0)throw new e(`INVALID_ARGS`,`perf action must be frames, memory sample|snapshot, cpu profile start|stop|report, or trace start|stop`);return Object.freeze({area:r,action:`sample`})}if(r===`memory`)return N(n,t);if(r===`cpu`)return P(n,t.outPath);if(r===`trace`)return F(n,t.outPath);throw new e(`INVALID_ARGS`,`perf requires frames, memory, cpu, or trace`)}function N(t,n){let r=(t[1]??`sample`).toLowerCase();if(r!==`sample`&&r!==`snapshot`)throw new e(`INVALID_ARGS`,`perf memory requires sample or snapshot`);if(n.kind!==void 0&&r!==`snapshot`)throw new e(`INVALID_ARGS`,`--kind is only supported with perf memory snapshot`);if(r===`sample`&&t.length>2)throw new e(`INVALID_ARGS`,`perf memory sample does not accept additional positionals`);if(r===`snapshot`&&t.length>3)throw new e(`INVALID_ARGS`,`perf memory snapshot accepts at most one positional kind`);let i=n.kind??t[2];if(i!==void 0&&!o(i))throw new e(`INVALID_ARGS`,`perf memory snapshot --kind must be android-hprof or memgraph`);return Object.freeze({area:`memory`,action:r,...i===void 0?{}:{kind:i},...n.outPath===void 0?{}:{outPath:n.outPath}})}function P(t,n){if(t[1]?.toLowerCase()!==`profile`)throw new e(`INVALID_ARGS`,`perf cpu requires profile`);let r=t[2]?.toLowerCase();if(r!==`start`&&r!==`stop`&&r!==`report`)throw new e(`INVALID_ARGS`,`perf cpu profile action must be start, stop, or report`);let i=t[3]?.toLowerCase();if(i!==`xctrace`&&i!==`simpleperf`)throw new e(`INVALID_ARGS`,`perf cpu profile requires --kind xctrace or simpleperf`);let a=n??t[5];return Object.freeze({area:`cpu`,subject:`profile`,action:r,kind:i,...t[4]?{template:t[4]}:{},...a?{outPath:a}:{},...t[6]?{tracePath:t[6]}:{}})}function F(t,n){let r=t[1]?.toLowerCase();if(r!==`start`&&r!==`stop`)throw new e(`INVALID_ARGS`,`perf trace action must be start or stop`);let i=t[2]?.toLowerCase();if(i!==`xctrace`&&i!==`perfetto`)throw new e(`INVALID_ARGS`,`perf trace requires --kind xctrace or perfetto`);let a=n??t[4];return Object.freeze({area:`trace`,action:r,kind:i,...t[3]?{template:t[3]}:{},...a?{outPath:a}:{}})}function I(e,t){let n=[],r=e+t.toString(),i=r.indexOf(`
|
|
2
2
|
`);for(;i!==-1;){let e=r.slice(0,i).trim();r=r.slice(i+1),e&&n.push(e),i=r.indexOf(`
|
|
3
|
-
`)}return{lines:n,buffer:r}}async function
|
|
3
|
+
`)}return{lines:n,buffer:r}}async function L(e){return e===`https:`?(await import(`node:https`)).default:(await import(`node:http`)).default}function R(e){return new Promise((t,n)=>{let r=``;e.setEncoding(`utf8`),e.on(`data`,e=>{r+=e}),e.on(`end`,()=>t(r)),e.on(`error`,n)})}async function z(t,n,r){let i=[],a=0;for await(let o of t){let t=Buffer.isBuffer(o)?o:Buffer.from(o);if(a+=t.length,a>n)throw new e(`INVALID_ARGS`,r);i.push(t)}return Buffer.concat(i)}function B(e,t){let n=s.createHash(`sha256`).update(e).digest(),r=s.createHash(`sha256`).update(t).digest();return s.timingSafeEqual(n,r)}export{E as C,g as E,D as S,_ as T,p as _,B as a,m as b,l as c,d,f,h as g,w as h,R as i,b as l,x as m,L as n,M as o,u as p,z as r,j as s,I as t,S as u,y as v,O as w,C as x,v as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as e}from"./sdk-contracts.js";import{wn as t}from"./sdk-batch.js";import{c as n,o as r,s as i}from"./touch-runtime.js";function a(e){return typeof e!=`string`||e.trim().length===0?Object.freeze({status:`unreadable`,reason:`no-text-at-point`}):Object.freeze({status:`read`,text:e})}function o(e){return Object.freeze({readTextAtPoint:e.readTextAtPoint})}function s(e){return Object.freeze({readTextAtPoint:async n=>{let r=e.signal;r.throwIfAborted();let i=await e.resolveInteractor(e.device,{...n.execution,appBundleId:n.options?.appBundleId,signal:r});if(typeof i.readTextAtPoint!=`function`)throw t(`Runtime owner advertised readTextAtPoint without an interactor implementation`);return a(await i.readTextAtPoint(n.point,{appBundleId:n.options?.appBundleId,surface:n.options?.surface,signal:r,...n.options?.target?{target:n.options.target}:{}}))}})}function c(e){return Object.freeze({focusPoint:e.focus})}function l(e,t){return Object.freeze({focusPoint:async n=>{e.throwIfAborted(),await(await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e})).focus(n.point.x,n.point.y)}})}function u(e){return l(e.signal,r(e))}function d(e){return l(e.signal,i({...e,operation:`focus`}))}function ee(e){let t=t=>t??e.unsupported;return Object.freeze({performGesturePlan:t(e.plan),performDirectionalFlingPlan:t(e.directionalFling),performMultiTouchGesturePlan:t(e.multiTouch),performTargetAuthoredDrag:t(e.targetAuthoredDrag),gestureViewport:t(e.viewport)})}function f(e,n,r){let i=async e=>{let i=await p(n,r,e);if(typeof i.performGesture!=`function`)throw t(`Runtime owner advertised gesture execution without an interactor implementation`);return await i.performGesture(e.plan)};return Object.freeze({...e.performGesturePlan.available?{performGesturePlan:i}:{},...e.performDirectionalFlingPlan.available?{performDirectionalFlingPlan:i}:{},...e.performMultiTouchGesturePlan.available?{performMultiTouchGesturePlan:i}:{},...e.performTargetAuthoredDrag.available?{performTargetAuthoredDrag:i}:{},...e.gestureViewport.available?{gestureViewport:async e=>{let i=await p(n,r,e);if(typeof i.gestureViewport!=`function`)throw t(`Runtime owner advertised gestureViewport without an interactor implementation`);return await i.gestureViewport()}}:{}})}async function p(e,t,n){return e.throwIfAborted(),await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e})}function m(e){return f(e.facts,e.signal,r(e))}function h(e){return f(e.facts,e.signal,i({...e,operation:`gesture`}))}function g(e){let t=e??{},n=_(t.pixels),r=_(t.x1),i=_(t.y1),a=_(t.x2),o=_(t.y2),s=r===void 0||i===void 0||a===void 0||o===void 0?void 0:{x:r/2+a/2,y:i/2+o/2};return{report:t,...n===void 0?{}:{pixels:n},...s===void 0?{}:{midpoint:s}}}function _(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function v(e){return Object.freeze({scrollDirection:e.scroll})}function y(e,t){return Object.freeze({scrollDirection:async n=>(e.throwIfAborted(),g(await(await t({...n.execution,appBundleId:n.target?.appBundleId,signal:e})).scroll(n.direction,n.options)))})}function te(e){return y(e.signal,r(e))}function ne(e){return y(e.signal,i({...e,operation:`scroll`}))}const re=`audio-probe`;function ie(e){return Object.freeze({audioProbeStart:e.capture,audioProbeReattach:e.capture,audioProbeCleanup:e.capture,audioProbeQuery:e.query})}const ae=`perf-capture`;function b(e){return Object.freeze({perfFrames:e.frames,perfMemorySample:e.memorySample,perfMemorySnapshot:e.memorySnapshot,perfNativeCaptureStart:e.nativeCapture,perfNativeCaptureReattach:e.nativeCapture,perfNativeCaptureCleanup:e.nativeCapture,perfProfileReport:e.profileReport})}function x(e){return Object.freeze({captureScreenshot:e.capture})}function S(e,t){return Object.freeze({captureScreenshot:async n=>await(await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e})).screenshot(n.outPath,n.options)??{}})}function C(e){return S(e.signal,r(e))}function w(e){return S(e.signal,i({...e,operation:`screenshot`}))}function T(e){return Object.freeze({findText:e.findText,querySelector:e.querySelector})}function E(e,t){return t.signal===void 0?e:AbortSignal.any([e,t.signal])}function D(e){return Object.freeze({captureSnapshot:e.capture,captureSnapshotWithCustomActions:e.customActions,captureSnapshotWithoutActiveApp:e.withoutActiveApp})}function O(t){let n=async n=>{await k(t,n);let r=E(t.signal,n),i={...n.execution,appBundleId:n.options?.appBundleId,signal:r},a=t.ownership===`local`?await t.resolveInteractor(t.device,i):t.resolveInteractor(i);if(!a)throw new e(`UNSUPPORTED_OPERATION`,`Provider-owned snapshot operation has no bound provider interactor.`,{reason:`provider-runtime-interactor-missing`,deviceId:t.device.id});let o=await a.snapshot({...n.options,signal:r});if(!M(o))return o;if(!t.presentIosAcquisition)throw new e(`COMMAND_FAILED`,`Acquired iOS snapshot has no host presentation owner.`,{reason:`ios-snapshot-presenter-missing`,deviceId:t.device.id});return await t.presentIosAcquisition(o,n.options)};return Object.freeze({captureSnapshot:n,captureSnapshotWithCustomActions:n,captureSnapshotWithoutActiveApp:n})}async function k(t,n){if(n.options?.observeOnly!==!0)return;let{isHandheldAppleDevice:r}=await import(`./sdk-device.js`).then(e=>e.d);if(!(t.ownership===`local`&&r(t.device)))throw new e(`UNSUPPORTED_OPERATION`,`observe-only snapshot requires a local iOS or iPadOS runner.`)}function A(e){return O({...e,ownership:`local`})}function j(e){return O({...e,ownership:`provider`})}function M(e){return`stage`in e&&e.stage===`acquired`}function N(e){return Object.freeze({typeText:e.type})}function P(e,t){return Object.freeze({typeText:async n=>(e.throwIfAborted(),await(await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e})).type(n.text,n.delayMs))})}function F(e){return P(e.signal,r(e))}function I(e){return P(e.signal,i({...e,operation:`type`}))}function L(e){return Object.freeze({setViewport:e.setViewport})}function R(e){return Object.freeze({back:e.back})}function z(e,t){return Object.freeze({back:async n=>{e.throwIfAborted(),await(await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e})).back(n.mode)}})}function B(e){return Object.freeze({readAlert:e.read,awaitAlert:e.wait,acceptAlert:e.accept,dismissAlert:e.dismiss})}async function V(e,t,n){return e.throwIfAborted(),await t({...n.execution,appBundleId:n.appBundleId,signal:e})}function H(e,t){return{...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs},...e.appBundleId===void 0?{}:{appBundleId:e.appBundleId},...e.surface===void 0?{}:{surface:e.surface},...t?{signal:t}:{}}}const U={readAlert:`alert get`,awaitAlert:`alert wait`,acceptAlert:`alert accept`,dismissAlert:`alert dismiss`};function oe(e,t,n){return Object.freeze({[e]:async r=>{let i=await V(t,n,r),{requireInteractorMethod:a}=await import(`./touch-runtime.js`).then(e=>e.a);return await a(i[e],U[e]).call(i,H(r,t))}})}function W(e){return Object.freeze({triggerAppEvent:e.triggerAppEvent})}function G(e,t){return Object.freeze({triggerAppEvent:async n=>{e.throwIfAborted(),await(await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e})).open(n.eventUrl,{appBundleId:n.options?.appBundleId})}})}const K=[`home`,`appSwitcher`,`actionButton`,`volumeUp`,`volumeDown`,`power`,`mute`,`sleep`,`wake`,`mediaPlayPause`,`mediaNext`,`mediaPrevious`,`mediaRewind`,`mediaFastForward`],q={home:`home`,appSwitcher:`app-switcher`,actionButton:`action-button`,volumeUp:`volume-up`,volumeDown:`volume-down`,power:`power`,mute:`mute`,sleep:`sleep`,wake:`wake`,mediaPlayPause:`media-play-pause`,mediaNext:`media-next`,mediaPrevious:`media-previous`,mediaRewind:`media-rewind`,mediaFastForward:`media-fast-forward`};function se(e){let t={};for(let n of K)t[n]=e[n]??e.unsupported;return Object.freeze(t)}const ce=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`hardware-button is not supported on Android TV targets; use tv-remote.`}),le=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`hardware-button is supported on Android emulators and physical devices.`}),ue=Object.freeze({available:!0}),de=K.filter(e=>e!==`home`&&e!==`appSwitcher`&&e!==`actionButton`);function fe(e){let t=pe(e),n={};for(let e of de)n[e]=t;return n}function pe(e){return e.kind===`simulator`?le:e.target===`tv`?ce:ue}function me(e,t,r){let i=async i=>{t.throwIfAborted();let a=await r({...i.execution,appBundleId:i.options?.appBundleId,signal:t});await n(a[e],q[e]).call(a)};return Object.freeze({[e]:i})}function he(e){let t=t=>t??e.unsupported;return Object.freeze({readClipboard:t(e.read),writeClipboard:t(e.write)})}const J={readClipboard:`clipboard read`,writeClipboard:`clipboard write`};async function Y(e,t,n){return e.throwIfAborted(),await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e})}async function X(e,t){let{requireInteractorMethod:n}=await import(`./touch-runtime.js`).then(e=>e.a);return n(e[t],J[t])}function ge(e,t){return Object.freeze({readClipboard:async n=>{let r=await Y(e,t,n);return await(await X(r,`readClipboard`)).call(r)}})}function _e(e,t){return Object.freeze({writeClipboard:async n=>{let r=await Y(e,t,n);await(await X(r,`writeClipboard`)).call(r,n.text)}})}function ve(e){let t=t=>t??e.unsupported;return Object.freeze({keyboardStatus:t(e.status),keyboardDismiss:t(e.dismiss),keyboardEnter:t(e.enter)})}async function ye(e,t,n){return e.throwIfAborted(),await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e})}const Z={keyboardStatus:`keyboard status`,keyboardDismiss:`keyboard dismiss`,keyboardEnter:`keyboard enter`};function be(e,t,n){let r=async r=>{let i=await ye(t,n,r),{requireInteractorMethod:a}=await import(`./touch-runtime.js`).then(e=>e.a);return await a(i[e],Z[e]).call(i)};return Object.freeze({[e]:r})}const xe=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`orientation auto is only supported on ADB-backed Android.`});function Q(e){return Object.freeze({setOrientation:e.orientation,unlockOrientation:e.unlock??xe})}function Se(e,t){return Object.freeze({setOrientation:async n=>(e.throwIfAborted(),await(await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e})).setOrientation(n.rotation))})}function Ce(e,t){return Object.freeze({unlockOrientation:async n=>{e.throwIfAborted();let r=await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e}),{requireInteractorMethod:i}=await import(`./touch-runtime.js`).then(e=>e.a);await i(r.unlockOrientation,`orientation auto`).call(r)}})}function we(e){let{tvRemote:t,buttonSupport:n}=e;return Object.freeze({tvRemote:t.available&&n?Object.freeze({available:!0,subjects:Object.freeze(Object.fromEntries(n.supported.map(e=>[e,{available:!0}]))),unlisted:n.unsupported}):t})}const $=`tv-remote`;function Te(e,t){return Object.freeze({tvRemote:async n=>{e.throwIfAborted();let r=await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e}),{requireInteractorMethod:i}=await import(`./touch-runtime.js`).then(e=>e.a);await i(r.tvRemote,$).call(r,n.button,n.durationMs)}})}export{j as A,ie as B,R as C,I as D,F as E,w as F,h as G,ne as H,x as I,d as J,ee as K,ae as L,D as M,T as N,N as O,C as P,b as R,oe as S,L as T,v as U,te as V,m as W,s as X,c as Y,o as Z,se as _,Ce as a,U as b,be as c,ge as d,_e as f,me as g,fe as h,Se as i,E as j,A as k,ve as l,q as m,Te as n,Q as o,he as p,u as q,we as r,Z as s,$ as t,J as u,W as v,z as w,B as x,G as y,re as z};
|
|
1
|
+
import{R as e}from"./sdk-contracts.js";import{En as t}from"./sdk-batch.js";import{c as n,o as r,s as i}from"./touch-runtime.js";function a(e){return typeof e!=`string`||e.trim().length===0?Object.freeze({status:`unreadable`,reason:`no-text-at-point`}):Object.freeze({status:`read`,text:e})}function o(e){return Object.freeze({readTextAtPoint:e.readTextAtPoint})}function s(e){return Object.freeze({readTextAtPoint:async n=>{let r=e.signal;r.throwIfAborted();let i=await e.resolveInteractor(e.device,{...n.execution,appBundleId:n.options?.appBundleId,signal:r});if(typeof i.readTextAtPoint!=`function`)throw t(`Runtime owner advertised readTextAtPoint without an interactor implementation`);return a(await i.readTextAtPoint(n.point,{appBundleId:n.options?.appBundleId,surface:n.options?.surface,signal:r,...n.options?.target?{target:n.options.target}:{}}))}})}function c(e){return Object.freeze({focusPoint:e.focus})}function l(e,t){return Object.freeze({focusPoint:async n=>{e.throwIfAborted(),await(await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e})).focus(n.point.x,n.point.y)}})}function u(e){return l(e.signal,r(e))}function d(e){return l(e.signal,i({...e,operation:`focus`}))}function ee(e){let t=t=>t??e.unsupported;return Object.freeze({performGesturePlan:t(e.plan),performDirectionalFlingPlan:t(e.directionalFling),performMultiTouchGesturePlan:t(e.multiTouch),performTargetAuthoredDrag:t(e.targetAuthoredDrag),gestureViewport:t(e.viewport)})}function f(e,n,r){let i=async e=>{let i=await p(n,r,e);if(typeof i.performGesture!=`function`)throw t(`Runtime owner advertised gesture execution without an interactor implementation`);return await i.performGesture(e.plan)};return Object.freeze({...e.performGesturePlan.available?{performGesturePlan:i}:{},...e.performDirectionalFlingPlan.available?{performDirectionalFlingPlan:i}:{},...e.performMultiTouchGesturePlan.available?{performMultiTouchGesturePlan:i}:{},...e.performTargetAuthoredDrag.available?{performTargetAuthoredDrag:i}:{},...e.gestureViewport.available?{gestureViewport:async e=>{let i=await p(n,r,e);if(typeof i.gestureViewport!=`function`)throw t(`Runtime owner advertised gestureViewport without an interactor implementation`);return await i.gestureViewport()}}:{}})}async function p(e,t,n){return e.throwIfAborted(),await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e})}function m(e){return f(e.facts,e.signal,r(e))}function h(e){return f(e.facts,e.signal,i({...e,operation:`gesture`}))}function g(e){let t=e??{},n=_(t.pixels),r=_(t.x1),i=_(t.y1),a=_(t.x2),o=_(t.y2),s=r===void 0||i===void 0||a===void 0||o===void 0?void 0:{x:r/2+a/2,y:i/2+o/2};return{report:t,...n===void 0?{}:{pixels:n},...s===void 0?{}:{midpoint:s}}}function _(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function v(e){return Object.freeze({scrollDirection:e.scroll})}function y(e,t){return Object.freeze({scrollDirection:async n=>(e.throwIfAborted(),g(await(await t({...n.execution,appBundleId:n.target?.appBundleId,signal:e})).scroll(n.direction,n.options)))})}function te(e){return y(e.signal,r(e))}function ne(e){return y(e.signal,i({...e,operation:`scroll`}))}const re=`audio-probe`;function ie(e){return Object.freeze({audioProbeStart:e.capture,audioProbeReattach:e.capture,audioProbeCleanup:e.capture,audioProbeQuery:e.query})}const ae=`perf-capture`;function b(e){return Object.freeze({perfFrames:e.frames,perfMemorySample:e.memorySample,perfMemorySnapshot:e.memorySnapshot,perfNativeCaptureStart:e.nativeCapture,perfNativeCaptureReattach:e.nativeCapture,perfNativeCaptureCleanup:e.nativeCapture,perfProfileReport:e.profileReport})}function x(e){return Object.freeze({captureScreenshot:e.capture})}function S(e,t){return Object.freeze({captureScreenshot:async n=>await(await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e})).screenshot(n.outPath,n.options)??{}})}function C(e){return S(e.signal,r(e))}function w(e){return S(e.signal,i({...e,operation:`screenshot`}))}function T(e){return Object.freeze({findText:e.findText,querySelector:e.querySelector})}function E(e,t){return t.signal===void 0?e:AbortSignal.any([e,t.signal])}function D(e){return Object.freeze({captureSnapshot:e.capture,captureSnapshotWithCustomActions:e.customActions,captureSnapshotWithoutActiveApp:e.withoutActiveApp})}function O(t){let n=async n=>{await k(t,n);let r=E(t.signal,n),i={...n.execution,appBundleId:n.options?.appBundleId,signal:r},a=t.ownership===`local`?await t.resolveInteractor(t.device,i):t.resolveInteractor(i);if(!a)throw new e(`UNSUPPORTED_OPERATION`,`Provider-owned snapshot operation has no bound provider interactor.`,{reason:`provider-runtime-interactor-missing`,deviceId:t.device.id});let o=await a.snapshot({...n.options,signal:r});if(!M(o))return o;if(!t.presentIosAcquisition)throw new e(`COMMAND_FAILED`,`Acquired iOS snapshot has no host presentation owner.`,{reason:`ios-snapshot-presenter-missing`,deviceId:t.device.id});return await t.presentIosAcquisition(o,n.options)};return Object.freeze({captureSnapshot:n,captureSnapshotWithCustomActions:n,captureSnapshotWithoutActiveApp:n})}async function k(t,n){if(n.options?.observeOnly!==!0)return;let{isHandheldAppleDevice:r}=await import(`./sdk-device.js`).then(e=>e.f);if(!(t.ownership===`local`&&r(t.device)))throw new e(`UNSUPPORTED_OPERATION`,`observe-only snapshot requires a local iOS or iPadOS runner.`)}function A(e){return O({...e,ownership:`local`})}function j(e){return O({...e,ownership:`provider`})}function M(e){return`stage`in e&&e.stage===`acquired`}function N(e){return Object.freeze({typeText:e.type})}function P(e,t){return Object.freeze({typeText:async n=>(e.throwIfAborted(),await(await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e})).type(n.text,n.delayMs))})}function F(e){return P(e.signal,r(e))}function I(e){return P(e.signal,i({...e,operation:`type`}))}function L(e){return Object.freeze({setViewport:e.setViewport})}function R(e){return Object.freeze({back:e.back})}function z(e,t){return Object.freeze({back:async n=>{e.throwIfAborted(),await(await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e})).back(n.mode)}})}function B(e){return Object.freeze({readAlert:e.read,awaitAlert:e.wait,acceptAlert:e.accept,dismissAlert:e.dismiss})}async function V(e,t,n){return e.throwIfAborted(),await t({...n.execution,appBundleId:n.appBundleId,signal:e})}function H(e,t){return{...e.timeoutMs===void 0?{}:{timeoutMs:e.timeoutMs},...e.appBundleId===void 0?{}:{appBundleId:e.appBundleId},...e.surface===void 0?{}:{surface:e.surface},...t?{signal:t}:{}}}const U={readAlert:`alert get`,awaitAlert:`alert wait`,acceptAlert:`alert accept`,dismissAlert:`alert dismiss`};function oe(e,t,n){return Object.freeze({[e]:async r=>{let i=await V(t,n,r),{requireInteractorMethod:a}=await import(`./touch-runtime.js`).then(e=>e.a);return await a(i[e],U[e]).call(i,H(r,t))}})}function W(e){return Object.freeze({triggerAppEvent:e.triggerAppEvent})}function G(e,t){return Object.freeze({triggerAppEvent:async n=>{e.throwIfAborted(),await(await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e})).open(n.eventUrl,{appBundleId:n.options?.appBundleId})}})}const K=[`home`,`appSwitcher`,`actionButton`,`volumeUp`,`volumeDown`,`power`,`mute`,`sleep`,`wake`,`mediaPlayPause`,`mediaNext`,`mediaPrevious`,`mediaRewind`,`mediaFastForward`],q={home:`home`,appSwitcher:`app-switcher`,actionButton:`action-button`,volumeUp:`volume-up`,volumeDown:`volume-down`,power:`power`,mute:`mute`,sleep:`sleep`,wake:`wake`,mediaPlayPause:`media-play-pause`,mediaNext:`media-next`,mediaPrevious:`media-previous`,mediaRewind:`media-rewind`,mediaFastForward:`media-fast-forward`};function se(e){let t={};for(let n of K)t[n]=e[n]??e.unsupported;return Object.freeze(t)}const ce=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`hardware-button is not supported on Android TV targets; use tv-remote.`}),le=Object.freeze({available:!1,reason:`unsupported-device-kind`,hint:`hardware-button is supported on Android emulators and physical devices.`}),ue=Object.freeze({available:!0}),de=K.filter(e=>e!==`home`&&e!==`appSwitcher`&&e!==`actionButton`);function fe(e){let t=pe(e),n={};for(let e of de)n[e]=t;return n}function pe(e){return e.kind===`simulator`?le:e.target===`tv`?ce:ue}function me(e,t,r){let i=async i=>{t.throwIfAborted();let a=await r({...i.execution,appBundleId:i.options?.appBundleId,signal:t});await n(a[e],q[e]).call(a)};return Object.freeze({[e]:i})}function he(e){let t=t=>t??e.unsupported;return Object.freeze({readClipboard:t(e.read),writeClipboard:t(e.write)})}const J={readClipboard:`clipboard read`,writeClipboard:`clipboard write`};async function Y(e,t,n){return e.throwIfAborted(),await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e})}async function X(e,t){let{requireInteractorMethod:n}=await import(`./touch-runtime.js`).then(e=>e.a);return n(e[t],J[t])}function ge(e,t){return Object.freeze({readClipboard:async n=>{let r=await Y(e,t,n);return await(await X(r,`readClipboard`)).call(r)}})}function _e(e,t){return Object.freeze({writeClipboard:async n=>{let r=await Y(e,t,n);await(await X(r,`writeClipboard`)).call(r,n.text)}})}function ve(e){let t=t=>t??e.unsupported;return Object.freeze({keyboardStatus:t(e.status),keyboardDismiss:t(e.dismiss),keyboardEnter:t(e.enter)})}async function ye(e,t,n){return e.throwIfAborted(),await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e})}const Z={keyboardStatus:`keyboard status`,keyboardDismiss:`keyboard dismiss`,keyboardEnter:`keyboard enter`};function be(e,t,n){let r=async r=>{let i=await ye(t,n,r),{requireInteractorMethod:a}=await import(`./touch-runtime.js`).then(e=>e.a);return await a(i[e],Z[e]).call(i)};return Object.freeze({[e]:r})}const xe=Object.freeze({available:!1,reason:`unsupported-platform-leaf`,hint:`orientation auto is only supported on ADB-backed Android.`});function Q(e){return Object.freeze({setOrientation:e.orientation,unlockOrientation:e.unlock??xe})}function Se(e,t){return Object.freeze({setOrientation:async n=>(e.throwIfAborted(),await(await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e})).setOrientation(n.rotation))})}function Ce(e,t){return Object.freeze({unlockOrientation:async n=>{e.throwIfAborted();let r=await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e}),{requireInteractorMethod:i}=await import(`./touch-runtime.js`).then(e=>e.a);await i(r.unlockOrientation,`orientation auto`).call(r)}})}function we(e){let{tvRemote:t,buttonSupport:n}=e;return Object.freeze({tvRemote:t.available&&n?Object.freeze({available:!0,subjects:Object.freeze(Object.fromEntries(n.supported.map(e=>[e,{available:!0}]))),unlisted:n.unsupported}):t})}const $=`tv-remote`;function Te(e,t){return Object.freeze({tvRemote:async n=>{e.throwIfAborted();let r=await t({...n.execution,appBundleId:n.options?.appBundleId,signal:e}),{requireInteractorMethod:i}=await import(`./touch-runtime.js`).then(e=>e.a);await i(r.tvRemote,$).call(r,n.button,n.durationMs)}})}export{j as A,ie as B,R as C,I as D,F as E,w as F,h as G,ne as H,x as I,d as J,ee as K,ae as L,D as M,T as N,N as O,C as P,b as R,oe as S,L as T,v as U,te as V,m as W,s as X,c as Y,o as Z,se as _,Ce as a,U as b,be as c,ge as d,_e as f,me as g,fe as h,Se as i,E as j,A as k,ve as l,q as m,Te as n,Q as o,he as p,u as q,we as r,Z as s,$ as t,J as u,W as v,z as w,B as x,G as y,re as z};
|
package/dist/src/tv-remote.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime.js";import{R as t}from"./sdk-contracts.js";import{C as n,N as r,w as i}from"./sdk-device.js";import{Xr as a}from"./sdk-batch.js";const o={min:.01,max:1},s={flagKey:`screenshotMaxSize`,cliToken:`--max-size`,envVar:`AGENT_DEVICE_SCREENSHOT_MAX_SIZE`,publicOptionKey:`maxSize`,migration:{screenshot:`screenshot --max-size was removed; use --scale <0.01-1> (or AGENT_DEVICE_SCREENSHOT_SCALE) to downscale proportionally`,record:`record --max-size was removed; recordings capture at native resolution`}};function c(e,t){return t&&Object.hasOwn(t,s.flagKey)?s.migration[e]:void 0}function l(e,n){if(Object.hasOwn(n,s.publicOptionKey)||Object.hasOwn(n,s.flagKey))throw new t(`INVALID_ARGS`,s.migration[e])}const u={selectorInvalid:`CROP_SELECTOR_INVALID`,targetNotFound:`CROP_TARGET_NOT_FOUND`,targetAmbiguous:`CROP_TARGET_AMBIGUOUS`,captureUnreadable:`CROP_CAPTURE_UNREADABLE`,captureIncomplete:`CROP_CAPTURE_INCOMPLETE`,emptyIntersection:`CROP_EMPTY_INTERSECTION`,partialIntersection:`CROP_PARTIAL_INTERSECTION`,targetNotAccepted:`CROP_TARGET_NOT_ACCEPTED`,frameMismatch:`CROP_FRAME_MISMATCH`,pendingPixelIdentityEvidence:`PENDING_PIXEL_IDENTITY_EVIDENCE`},d={macOsHelperSurfaceFixedFrame:`SCREENSHOT_FULLSCREEN_MACOS_HELPER_SURFACE_FIXED_FRAME`},f=[`out`,`overlayRefs`,`screenshotCropOn`,`screenshotPixelDensity`,`screenshotFullscreen`,`screenshotScale`,`screenshotNoStabilize`,`screenshotNormalizeStatusBar`],p=[{key:`screenshotCropOn`,names:[`--crop-on`],type:`string`,usageLabel:`--crop-on <selector-expression>`,usageDescription:`Screenshot: crop the capture to the frame of the selector resolved on the same screen`,projectConfig:!1,recorded:!0},{key:`screenshotPixelDensity`,names:[`--pixel-density`],type:`int`,min:1,usageLabel:`--pixel-density <n>`,usageDescription:`Screenshot: output PNG pixel density in pixels per logical point (currently supported on iOS simulators)`,projectConfig:!0,recorded:!0},{key:`screenshotFullscreen`,names:[`--fullscreen`,`--full`,`-f`],type:`boolean`,usageLabel:`--fullscreen, --full, -f`,usageDescription:`Screenshot: on web capture the full page; on macOS app sessions capture the full desktop instead of the app window`,projectConfig:!0,recorded:!0},{key:`screenshotScale`,names:[`--scale`],type:`number`,min:o.min,max:o.max,usageLabel:`--scale <0.01-1>`,usageDescription:`Screenshot: resize both dimensions by this factor (or use AGENT_DEVICE_SCREENSHOT_SCALE)`,projectConfig:!0,recorded:!0},{key:`screenshotNoStabilize`,names:[`--no-stabilize`],type:`boolean`,usageLabel:`--no-stabilize`,usageDescription:`Screenshot: capture immediately without Android status-bar stabilization (the default)`,projectConfig:!0,recorded:!0},{key:`screenshotNormalizeStatusBar`,names:[`--normalize-status-bar`],type:`boolean`,usageLabel:`--normalize-status-bar`,usageDescription:`Screenshot: temporarily normalize iOS simulator or ADB-backed Android status-bar chrome for deterministic screenshot diffs; ADB-backed Android waits for transient UI to fade`,projectConfig:!0,recorded:!0}],m=[{tokens:[`--fullscreen`,`--full`,`-f`],key:`screenshotFullscreen`},{tokens:[`--no-stabilize`],key:`screenshotNoStabilize`},{tokens:[`--normalize-status-bar`],key:`screenshotNormalizeStatusBar`}],h=[{token:`--pixel-density`,key:`screenshotPixelDensity`,label:`screenshot --pixel-density`}],g=[{token:`--scale`,key:`screenshotScale`,label:`screenshot --scale`,min:o.min,max:o.max}],ee=[{token:`--crop-on`,key:`screenshotCropOn`,label:`screenshot --crop-on`}];function te(e){return v({overlayRefs:e?.overlayRefs,cropOn:e?.screenshotCropOn,pixelDensity:e?.screenshotPixelDensity,fullscreen:e?.screenshotFullscreen,scale:e?.screenshotScale,stabilize:e?.screenshotNoStabilize===void 0?void 0:!e.screenshotNoStabilize,normalizeStatusBar:e?.screenshotNormalizeStatusBar})}function _(e={}){return v({overlayRefs:e.overlayRefs,screenshotCropOn:e.screenshotCropOn??e.cropOn,screenshotPixelDensity:e.screenshotPixelDensity??e.pixelDensity,screenshotFullscreen:e.screenshotFullscreen??e.fullscreen,screenshotScale:e.screenshotScale,screenshotNoStabilize:e.screenshotNoStabilize??(e.stabilize===void 0?void 0:!e.stabilize),screenshotNormalizeStatusBar:e.screenshotNormalizeStatusBar??e.normalizeStatusBar})}function ne(e={}){return _({...e,screenshotScale:e.screenshotScale??e.scale})}function re(e){let{min:n,max:r}=o;if(e.scale!==void 0&&(!Number.isFinite(e.scale)||e.scale<n||e.scale>r))throw new t(`INVALID_ARGS`,`screenshot scale must be between ${n} and ${r}`)}function ie(e,t){typeof t?.screenshotPixelDensity==`number`&&e.push(`--pixel-density`,String(t.screenshotPixelDensity)),t?.screenshotFullscreen&&e.push(`--fullscreen`),typeof t?.screenshotScale==`number`&&e.push(`--scale`,String(t.screenshotScale)),t?.screenshotNoStabilize&&e.push(`--no-stabilize`),t?.screenshotNoStabilize===!1&&e.push(`--no-stabilize=false`),t?.screenshotNormalizeStatusBar&&e.push(`--normalize-status-bar`)}function ae(e){let{args:n,flags:r,index:i}=e,a=n[i];if(a===s.cliToken)throw new t(`INVALID_ARGS`,s.migration.screenshot);return oe(a,r,i)??se({args:n,index:i,flags:r,token:a})??ce({args:n,index:i,flags:r,token:a})??le({args:n,index:i,flags:r,token:a})??{handled:!1}}function v(e){return Object.fromEntries(Object.entries(e).filter(e=>e[1]!==void 0))}function oe(e,t,n){if(e===`--no-stabilize=false`)return t.screenshotNoStabilize=!1,{handled:!0,nextIndex:n};let r=m.find(t=>t.tokens.some(t=>t===e));if(r)return t[r.key]=!0,{handled:!0,nextIndex:n}}function se(e){let n=h.find(t=>t.token===e.token);if(!n)return;let r=Number(e.args[e.index+1]);if(!Number.isInteger(r)||r<1)throw new t(`INVALID_ARGS`,`${n.label} requires a positive integer`);return e.flags[n.key]=r,{handled:!0,nextIndex:e.index+1}}function ce(e){let n=g.find(t=>t.token===e.token);if(!n)return;let r=Number(e.args[e.index+1]);if(!Number.isFinite(r)||r<n.min||r>n.max)throw new t(`INVALID_ARGS`,`${n.label} requires a number from ${n.min} to ${n.max}`);return e.flags[n.key]=r,{handled:!0,nextIndex:e.index+1}}function le(e){let n=ee.find(t=>t.token===e.token);if(!n)return;let r=e.args[e.index+1];if(typeof r!=`string`||r.length===0)throw new t(`INVALID_ARGS`,`${n.label} requires a selector expression`);return e.flags[n.key]=r,{handled:!0,nextIndex:e.index+1}}function y(e,n={message:e=>`Invalid value: ${e}`}){let r=new Set(e),i=n.normalize??(e=>e);return{is:e=>typeof e==`string`&&r.has(e),parse:e=>{let a=i(e??``);if(r.has(a))return a;throw new t(`INVALID_ARGS`,n.message(e??``))}}}const ue=[`up`,`down`,`left`,`right`,`top`,`bottom`],de=[`up`,`down`,`left`,`right`],fe=[`left`,`right`,`left-edge`,`right-edge`],pe=[`one-way`,`ping-pong`],me=1e4,he=6e4,ge=y(de,{message:e=>`Unknown direction: ${e}`}),b=.6;function _e(e){let t=e.direction,n=t===`up`||t===`down`,r=n?e.referenceHeight:e.referenceWidth,i=n?e.referenceWidth:e.referenceHeight,a=D(e.amount),o=e.pixels===void 0?Math.round(r*a):O(e.pixels),s=x(r),c=Math.max(1,r-s*2),l=Math.max(1,Math.min(o,c)),u=Math.round(l/2),d=Math.round(r/2),f={axisStart:d-u,axisEnd:d+u,cross:Math.round(i/2)},p=x(i),m=e.container?ye(f,e.container,n,{axis:{min:s,max:r-s},cross:{min:p,max:i-p},crossFrame:{min:0,max:i}}):f,h=m.axisEnd-m.axisStart,g=h<l;return{direction:t,...ve(t,m),referenceWidth:e.referenceWidth,referenceHeight:e.referenceHeight,amount:e.amount,pixels:g?h:l,...g?{requestedPixels:l}:{}}}function ve(e,t){let n=e===`up`||e===`down`,r=n?{x:t.cross,y:t.axisStart}:{x:t.axisStart,y:t.cross},i=n?{x:t.cross,y:t.axisEnd}:{x:t.axisEnd,y:t.cross},[a,o]=e===`up`||e===`left`?[r,i]:[i,r];return{x1:a.x,y1:a.y,x2:o.x,y2:o.y}}function x(e){return Math.max(1,Math.round(e*.1))}function ye(e,t,n,r){let i=S(n?t.y:t.x,n?t.height:t.width,r.axis),a=n?t.x:t.y,o=n?t.width:t.height,s=S(a,o,r.cross)??S(a,o,r.crossFrame);if(!i||!s)return e;let c=e.cross>=s.min&&e.cross<=s.max?e.cross:Math.round((s.min+s.max)/2);if(e.axisEnd-e.axisStart>=i.max-i.min)return{axisStart:i.min,axisEnd:i.max,cross:c};let l=e.axisStart<i.min?i.min-e.axisStart:Math.min(0,i.max-e.axisEnd);return{axisStart:e.axisStart+l,axisEnd:e.axisEnd+l,cross:c}}function S(e,t,n){let r=Math.max(n.min,Math.ceil(e)+8),i=Math.min(n.max,Math.floor(e+t)-1-8);return i>r?{min:r,max:i}:void 0}function be(e){D(e.amount),e.pixels!==void 0&&O(e.pixels)}function xe(e,t){if(e===`left`||e===`right`){let n=C(e,t);return{preset:e,x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,referenceWidth:n.referenceWidth,referenceHeight:n.referenceHeight}}let[n,r]=e===`left-edge`?[99,15]:[1,85],i=T(w(t,n,50),t,8),a=T(w(t,r,50),t,8);return{preset:e,x1:i.x,y1:i.y,x2:a.x,y2:a.y,referenceWidth:t.referenceWidth,referenceHeight:t.referenceHeight}}function Se(e,t){switch(e){case`up`:return{x:0,y:-t};case`down`:return{x:0,y:t};case`left`:return{x:-t,y:0};case`right`:return{x:t,y:0}}}function C(e,t){let n=e===`left`||e===`up`,r=n?85:15,i=n?15:85,a=e===`up`||e===`down`,o=T(w(t,a?50:r,a?r:50),t,8),s=T(w(t,a?50:i,a?i:50),t,8);return{direction:e,x1:o.x,y1:o.y,x2:s.x,y2:s.y,referenceWidth:t.referenceWidth,referenceHeight:t.referenceHeight}}function Ce(e){let t=Te(e);if(t)return{referenceWidth:t.width,referenceHeight:t.height}}function w(e,t,n){let r=Math.trunc(e.referenceWidth*t/100),i=Math.trunc(e.referenceHeight*n/100);return{x:Number.isFinite(r)?r:0,y:Number.isFinite(i)?i:0}}function T(e,t,n){return{x:k(e.x,n,t.referenceWidth),y:k(e.y,n,t.referenceHeight)}}function we(e){return ge.parse(e)}function Te(e){let t=e.filter(e=>a(e)&&E(e.rect)).map(e=>e.rect).sort((e,t)=>(t?.width??0)*(t?.height??0)-(e?.width??0)*(e?.height??0))[0];if(t)return t;let n=e.map(e=>e.rect).filter(E);if(n.length===0)return;let r=Math.max(...n.map(e=>e.x+e.width)),i=Math.max(...n.map(e=>e.y+e.height));if(!(r<=0||i<=0))return{x:0,y:0,width:r,height:i}}function E(e){return!!e&&e.width>0&&e.height>0}function D(e){if(e===void 0)return b;if(!Number.isFinite(e)||e<=0)throw new t(`INVALID_ARGS`,`scroll amount must be a positive number`);return e}function O(e){if(!Number.isFinite(e)||e<=0)throw new t(`INVALID_ARGS`,`scroll pixels must be a positive integer`);return Math.max(1,Math.round(e))}function k(e,t,n){let r=Math.round(t);if(!Number.isFinite(r))return 0;let i=Math.max(r,Math.round(n-t));return!Number.isFinite(i)||!Number.isFinite(e)?r:Math.min(i,Math.max(r,Math.round(e)))}const A=Object.freeze({reason:`scroll_keyboard_occludes_surface`,hint:"The on-screen keyboard covers the surface this scroll would swipe, so it cannot reach it. Run `keyboard dismiss` and retry, accepting that it drops focus (re-tap the field to keep typing), or scroll before focusing the field."});function Ee(e,t){if(!j(e)||!j(t))return{kind:`unobstructed`};let n=e.x+e.width/2;if(n<t.x||n>=t.x+t.width)return{kind:`unobstructed`};let r=t.y;if(r>=e.y+e.height||t.y+t.height<=e.y)return{kind:`unobstructed`};let i=Math.max(0,r-12-e.y);return i<.15*e.height?{kind:`occluded`,keyboardMinY:r,visibleHeight:i}:{kind:`avoided`,viewport:{...e,height:i},keyboardMinY:r}}function De(e,n){return new t(`COMMAND_FAILED`,`scroll ${e} refused: the keyboard leaves ${n.visibleHeight}px of ${n.viewportHeight}px visible, below the 15% needed for a swipe`,{keyboardMinY:n.keyboardMinY,visibleHeight:n.visibleHeight,viewportHeight:n.viewportHeight,minVisibleFraction:.15,...A})}function j(e){return[e.x,e.y,e.width,e.height].every(e=>Number.isFinite(e))&&e.width>0&&e.height>0}const Oe=1e4,ke=12e4;function Ae(e){let t=e.trim().toLowerCase();return t?/^(vertical|horizontal)\s+scroll\s+bar(?:,?\s*\d+\s+pages?)?$/.test(t):!1}function je(e,t){if(!(e?.trim().toLowerCase()??``).includes(`vertical scroll bar`))return null;let n=Me(t);return n===null?null:n<=1?{above:!1,below:!0}:n>=99?{above:!0,below:!1}:{above:!0,below:!0}}function Me(e){if(!e)return null;let t=/^(\d{1,3})%$/.exec(e.trim());if(!t)return null;let n=Number(t[1]);return Number.isFinite(n)?Math.max(0,Math.min(100,n)):null}const Ne=1e4,Pe=.65;function Fe(e,t){return{...e,releaseBehavior:t===void 0?`controlled`:`inertial`}}function Ie(e,n=`scroll accepts either a relative amount or --pixels, not both`){if(e.amount!==void 0&&e.pixels!==void 0)throw new t(`INVALID_ARGS`,n)}function Le(e){if(e.maxPasses!==void 0){if(e.until===void 0)throw new t(`INVALID_ARGS`,`scroll maxPasses requires until`,{reason:`scroll_max_passes_requires_until`});if(!Number.isInteger(e.maxPasses)||e.maxPasses<1||e.maxPasses>200)throw new t(`INVALID_ARGS`,`scroll maxPasses must be an integer from 1 to 200`,{reason:`scroll_max_passes_invalid`})}if(e.until!==void 0&&e.edge!==void 0)throw new t(`INVALID_ARGS`,`scroll ${e.edge} already scrolls to the ${e.edge} edge and cannot take --until`,{hint:`Use scroll ${e.edge===`bottom`?`down`:`up`} --until <selector> to stop at the target, or scroll ${e.edge} to reach the edge.`})}function Re(e,n={}){if(e===void 0)return;let r=n.field??`scroll durationMs`,i=n.max??1e4,a=n.invalidMessage??`${r} must be a non-negative integer`;if(!Number.isFinite(e)||!Number.isInteger(e)||e<0)throw new t(`INVALID_ARGS`,a);if(e>i)throw new t(`INVALID_ARGS`,`${r} must be a non-negative integer at most ${i}`);return e}const ze=[`android`,`harmonyos`,`apple`,`vega`,`linux`];function Be(e){let{booted:t,kind:n,...r}=e;return r}const Ve={platform:`web`,id:`agent-browser-chrome`,name:`Agent Browser Chrome`,kind:`device`,target:`desktop`,booted:!0};function He(e){let t=We();for(let n of e){let e=Ge(n);t[e].available+=1,n.booted===!0&&(t[e].booted+=1)}return t}function Ue(e,t){return e.filter(e=>r(e,t.platform)&&(t.target===void 0||(e.target??`mobile`)===t.target)&&(t.kind===void 0||e.kind===t.kind)&&(t.booted===void 0||e.booted===t.booted))}function We(){return{android:{available:0,booted:0},harmonyos:{available:0,booted:0},apple:{available:0,booted:0},vega:{available:0,booted:0},linux:{available:0,booted:0},web:{available:0,booted:0}}}function Ge(e){return n(e)||i(e)?`apple`:e.platform}const Ke=new Set([`DEVICE_CLAIM_LIVE_OWNER`,`DEVICE_CLAIM_RECOVERY_PENDING`,`DEVICE_CLAIM_OWNER_UNCERTAIN`]);function qe(e){return Ke.has(e)}const M=`native-panel`,N=[`portrait`,`portrait-upside-down`,`landscape-left`,`landscape-right`],P={portrait:0,"landscape-left":1,"portrait-upside-down":2,"landscape-right":3};function Je(e){return N.find(t=>P[t]===e)}function Ye(e){return typeof e==`string`&&N.includes(e)}function Xe(e){return P[e]*90}function Ze(e){return P[e]%2==0?`PORTRAIT`:`LANDSCAPE`}function Qe(e){if(e===void 0)throw new t(`INVALID_ARGS`,`orientation requires an orientation argument. Use portrait|portrait-upside-down|landscape-left|landscape-right.`);switch(e?.trim().toLowerCase()){case`portrait`:return`portrait`;case`portrait-upside-down`:case`upside-down`:return`portrait-upside-down`;case`landscape-left`:case`left`:return`landscape-left`;case`landscape-right`:case`right`:return`landscape-right`;default:throw new t(`INVALID_ARGS`,`Invalid rotation: ${e}. Use portrait|portrait-upside-down|landscape-left|landscape-right.`)}}const $e=[...N,`auto`];function et(e){return e?.trim().toLowerCase()===`auto`?`auto`:Qe(e)}const F=[`volume-up`,`volume-down`,`power`,`mute`,`sleep`,`wake`,`media-play-pause`,`media-next`,`media-previous`,`media-rewind`,`media-fast-forward`],tt=`<${F.join(`|`)}>`,I={volumeUp:`volume-up`,volumeDown:`volume-down`,power:`power`,mute:`mute`,sleep:`sleep`,wake:`wake`,mediaPlayPause:`media-play-pause`,mediaNext:`media-next`,mediaPrevious:`media-previous`,mediaRewind:`media-rewind`,mediaFastForward:`media-fast-forward`},nt=new Map(Object.entries(I).map(([e,t])=>[t,e]));function rt(e){let n=e?.toLowerCase(),r=n===void 0?void 0:nt.get(n);if(r)return r;throw new t(`INVALID_ARGS`,`hardware-button button must be one of: ${F.join(`, `)}.`)}function it(e){if(e.length!==1)throw new t(`INVALID_ARGS`,`hardware-button requires exactly one button: ${F.join(`, `)}.`);return rt(e[0])}const at=[`closed`,`half-open`,`open`],L=`closed|half-open|open`;function ot(e){if(Number.isFinite(e))return e<=st?`closed`:e>=ct?`open`:`half-open`}const st=1,ct=179;function R(e){if(e===void 0)throw new t(`INVALID_ARGS`,`fold requires a pose argument. Use ${L}.`);switch(e.trim().toLowerCase()){case`closed`:case`close`:case`fold`:case`folded`:return`closed`;case`half-open`:case`half`:case`half-unfolded`:case`partially-open`:case`book`:return`half-open`;case`open`:case`unfold`:case`unfolded`:case`fully-open`:case`flat`:return`open`;default:throw new t(`INVALID_ARGS`,`Invalid fold pose: ${e}. Use ${L}.`)}}const z=6e4;function lt(e){if(e.keyframes===void 0){if(e.pose===void 0)throw new t(`INVALID_ARGS`,`fold requires a pose or keyframes`);if(typeof e.pose!=`string`)throw new t(`INVALID_ARGS`,`fold pose must be a string`);return{pose:R(e.pose)}}if(e.pose!==void 0)throw new t(`INVALID_ARGS`,`fold accepts either pose or keyframes`);return{keyframes:B(e.keyframes)}}function B(e){if(!Array.isArray(e)||e.length<2||e.length>64)throw new t(`INVALID_ARGS`,`fold requires 2–64 keyframes`);let n=e.map(ut);if(n[0].atMs!==0||n.some((e,t)=>t>0&&e.atMs<=n[t-1].atMs))throw new t(`INVALID_ARGS`,`Fold keyframes must start at 0ms and increase strictly`);return n}function V(e,t){return typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=t}function ut(e){if(!e||typeof e!=`object`||Array.isArray(e))throw new t(`INVALID_ARGS`,`Each fold keyframe requires atMs and angle`);let{atMs:n,angle:r}=e;if(Object.keys(e).some(e=>e!==`atMs`&&e!==`angle`))throw new t(`INVALID_ARGS`,`Fold keyframes only accept atMs and angle`);if(!V(n,6e4)||!Number.isSafeInteger(n))throw new t(`INVALID_ARGS`,`Fold keyframe times must be integers from 0 to ${z}ms`);if(!V(r,180))throw new t(`INVALID_ARGS`,`Fold keyframe angles must be finite numbers from 0 to 180`);return{atMs:n,angle:r}}function dt(e){let n;try{n=JSON.parse(e)}catch{throw new t(`INVALID_ARGS`,`--keyframes requires a JSON array of {atMs, angle} objects`)}return B(n)}const H=[`call`,`accept`,`cancel`],U=[...H,`sms`],W=`telephony call|accept|cancel <number> | telephony sms <number> <text>`,ft=/^\+?\d{1,15}$/,pt=/[\u0000-\u0009\u000b-\u001f\u007f-\u009f]/;function mt(e){if(e===void 0)throw new t(`INVALID_ARGS`,`telephony requires an action. Use ${W}.`);let n=typeof e==`string`?e.trim().toLowerCase():void 0,r=U.find(e=>e===n);if(!r)throw new t(`INVALID_ARGS`,`Invalid telephony action: ${String(e)}. Use ${U.join(`, `)}.`);return r}function G(e){let n=mt(e.action),r=_t(e.number,n);if(n!==`sms`){if(e.text!==void 0)throw new t(`INVALID_ARGS`,`telephony ${n} takes only a phone number.`);return{action:n,number:r}}return{action:n,number:r,text:vt(e.text)}}function ht(e){let[t,n,...r]=e;return G({action:t,number:n,text:r.length>0?r.join(` `):void 0})}function gt(e){return e.action===`sms`?[e.action,e.number,e.text]:[e.action,e.number]}function _t(e,n){if(typeof e!=`string`||e.trim()===``)throw new t(`INVALID_ARGS`,`telephony ${n} requires a phone number.`);let r=e.trim();if(!ft.test(r))throw new t(`INVALID_ARGS`,`Invalid phone number: ${r}.`,{hint:`Use digits with an optional leading +, for example 5551234 or +15551234567.`});return r}function vt(e){if(typeof e!=`string`||e===``)throw new t(`INVALID_ARGS`,`telephony sms requires message text.`);let n=e.replaceAll(`\r
|
|
1
|
+
import{r as e}from"./rolldown-runtime.js";import{R as t}from"./sdk-contracts.js";import{P as n,T as r,w as i}from"./sdk-device.js";import{Xr as a}from"./sdk-batch.js";const o={min:.01,max:1},s={flagKey:`screenshotMaxSize`,cliToken:`--max-size`,envVar:`AGENT_DEVICE_SCREENSHOT_MAX_SIZE`,publicOptionKey:`maxSize`,migration:{screenshot:`screenshot --max-size was removed; use --scale <0.01-1> (or AGENT_DEVICE_SCREENSHOT_SCALE) to downscale proportionally`,record:`record --max-size was removed; recordings capture at native resolution`}};function c(e,t){return t&&Object.hasOwn(t,s.flagKey)?s.migration[e]:void 0}function l(e,n){if(Object.hasOwn(n,s.publicOptionKey)||Object.hasOwn(n,s.flagKey))throw new t(`INVALID_ARGS`,s.migration[e])}const u={selectorInvalid:`CROP_SELECTOR_INVALID`,targetNotFound:`CROP_TARGET_NOT_FOUND`,targetAmbiguous:`CROP_TARGET_AMBIGUOUS`,captureUnreadable:`CROP_CAPTURE_UNREADABLE`,captureIncomplete:`CROP_CAPTURE_INCOMPLETE`,emptyIntersection:`CROP_EMPTY_INTERSECTION`,partialIntersection:`CROP_PARTIAL_INTERSECTION`,targetNotAccepted:`CROP_TARGET_NOT_ACCEPTED`,frameMismatch:`CROP_FRAME_MISMATCH`,pendingPixelIdentityEvidence:`PENDING_PIXEL_IDENTITY_EVIDENCE`},d={macOsHelperSurfaceFixedFrame:`SCREENSHOT_FULLSCREEN_MACOS_HELPER_SURFACE_FIXED_FRAME`},f=[`out`,`overlayRefs`,`screenshotCropOn`,`screenshotPixelDensity`,`screenshotFullscreen`,`screenshotScale`,`screenshotNoStabilize`,`screenshotNormalizeStatusBar`],p=[{key:`screenshotCropOn`,names:[`--crop-on`],type:`string`,usageLabel:`--crop-on <selector-expression>`,usageDescription:`Screenshot: crop the capture to the frame of the selector resolved on the same screen`,projectConfig:!1,recorded:!0},{key:`screenshotPixelDensity`,names:[`--pixel-density`],type:`int`,min:1,usageLabel:`--pixel-density <n>`,usageDescription:`Screenshot: output PNG pixel density in pixels per logical point (currently supported on iOS simulators)`,projectConfig:!0,recorded:!0},{key:`screenshotFullscreen`,names:[`--fullscreen`,`--full`,`-f`],type:`boolean`,usageLabel:`--fullscreen, --full, -f`,usageDescription:`Screenshot: on web capture the full page; on macOS app sessions capture the full desktop instead of the app window`,projectConfig:!0,recorded:!0},{key:`screenshotScale`,names:[`--scale`],type:`number`,min:o.min,max:o.max,usageLabel:`--scale <0.01-1>`,usageDescription:`Screenshot: resize both dimensions by this factor (or use AGENT_DEVICE_SCREENSHOT_SCALE)`,projectConfig:!0,recorded:!0},{key:`screenshotNoStabilize`,names:[`--no-stabilize`],type:`boolean`,usageLabel:`--no-stabilize`,usageDescription:`Screenshot: capture immediately without Android status-bar stabilization (the default)`,projectConfig:!0,recorded:!0},{key:`screenshotNormalizeStatusBar`,names:[`--normalize-status-bar`],type:`boolean`,usageLabel:`--normalize-status-bar`,usageDescription:`Screenshot: temporarily normalize iOS simulator or ADB-backed Android status-bar chrome for deterministic screenshot diffs; ADB-backed Android waits for transient UI to fade`,projectConfig:!0,recorded:!0}],m=[{tokens:[`--fullscreen`,`--full`,`-f`],key:`screenshotFullscreen`},{tokens:[`--no-stabilize`],key:`screenshotNoStabilize`},{tokens:[`--normalize-status-bar`],key:`screenshotNormalizeStatusBar`}],h=[{token:`--pixel-density`,key:`screenshotPixelDensity`,label:`screenshot --pixel-density`}],g=[{token:`--scale`,key:`screenshotScale`,label:`screenshot --scale`,min:o.min,max:o.max}],ee=[{token:`--crop-on`,key:`screenshotCropOn`,label:`screenshot --crop-on`}];function te(e){return v({overlayRefs:e?.overlayRefs,cropOn:e?.screenshotCropOn,pixelDensity:e?.screenshotPixelDensity,fullscreen:e?.screenshotFullscreen,scale:e?.screenshotScale,stabilize:e?.screenshotNoStabilize===void 0?void 0:!e.screenshotNoStabilize,normalizeStatusBar:e?.screenshotNormalizeStatusBar})}function _(e={}){return v({overlayRefs:e.overlayRefs,screenshotCropOn:e.screenshotCropOn??e.cropOn,screenshotPixelDensity:e.screenshotPixelDensity??e.pixelDensity,screenshotFullscreen:e.screenshotFullscreen??e.fullscreen,screenshotScale:e.screenshotScale,screenshotNoStabilize:e.screenshotNoStabilize??(e.stabilize===void 0?void 0:!e.stabilize),screenshotNormalizeStatusBar:e.screenshotNormalizeStatusBar??e.normalizeStatusBar})}function ne(e={}){return _({...e,screenshotScale:e.screenshotScale??e.scale})}function re(e){let{min:n,max:r}=o;if(e.scale!==void 0&&(!Number.isFinite(e.scale)||e.scale<n||e.scale>r))throw new t(`INVALID_ARGS`,`screenshot scale must be between ${n} and ${r}`)}function ie(e,t){typeof t?.screenshotPixelDensity==`number`&&e.push(`--pixel-density`,String(t.screenshotPixelDensity)),t?.screenshotFullscreen&&e.push(`--fullscreen`),typeof t?.screenshotScale==`number`&&e.push(`--scale`,String(t.screenshotScale)),t?.screenshotNoStabilize&&e.push(`--no-stabilize`),t?.screenshotNoStabilize===!1&&e.push(`--no-stabilize=false`),t?.screenshotNormalizeStatusBar&&e.push(`--normalize-status-bar`)}function ae(e){let{args:n,flags:r,index:i}=e,a=n[i];if(a===s.cliToken)throw new t(`INVALID_ARGS`,s.migration.screenshot);return oe(a,r,i)??se({args:n,index:i,flags:r,token:a})??ce({args:n,index:i,flags:r,token:a})??le({args:n,index:i,flags:r,token:a})??{handled:!1}}function v(e){return Object.fromEntries(Object.entries(e).filter(e=>e[1]!==void 0))}function oe(e,t,n){if(e===`--no-stabilize=false`)return t.screenshotNoStabilize=!1,{handled:!0,nextIndex:n};let r=m.find(t=>t.tokens.some(t=>t===e));if(r)return t[r.key]=!0,{handled:!0,nextIndex:n}}function se(e){let n=h.find(t=>t.token===e.token);if(!n)return;let r=Number(e.args[e.index+1]);if(!Number.isInteger(r)||r<1)throw new t(`INVALID_ARGS`,`${n.label} requires a positive integer`);return e.flags[n.key]=r,{handled:!0,nextIndex:e.index+1}}function ce(e){let n=g.find(t=>t.token===e.token);if(!n)return;let r=Number(e.args[e.index+1]);if(!Number.isFinite(r)||r<n.min||r>n.max)throw new t(`INVALID_ARGS`,`${n.label} requires a number from ${n.min} to ${n.max}`);return e.flags[n.key]=r,{handled:!0,nextIndex:e.index+1}}function le(e){let n=ee.find(t=>t.token===e.token);if(!n)return;let r=e.args[e.index+1];if(typeof r!=`string`||r.length===0)throw new t(`INVALID_ARGS`,`${n.label} requires a selector expression`);return e.flags[n.key]=r,{handled:!0,nextIndex:e.index+1}}function y(e,n={message:e=>`Invalid value: ${e}`}){let r=new Set(e),i=n.normalize??(e=>e);return{is:e=>typeof e==`string`&&r.has(e),parse:e=>{let a=i(e??``);if(r.has(a))return a;throw new t(`INVALID_ARGS`,n.message(e??``))}}}const ue=[`up`,`down`,`left`,`right`,`top`,`bottom`],de=[`up`,`down`,`left`,`right`],fe=[`left`,`right`,`left-edge`,`right-edge`],pe=[`one-way`,`ping-pong`],me=1e4,he=6e4,ge=y(de,{message:e=>`Unknown direction: ${e}`}),b=.6;function _e(e){let t=e.direction,n=t===`up`||t===`down`,r=n?e.referenceHeight:e.referenceWidth,i=n?e.referenceWidth:e.referenceHeight,a=D(e.amount),o=e.pixels===void 0?Math.round(r*a):O(e.pixels),s=x(r),c=Math.max(1,r-s*2),l=Math.max(1,Math.min(o,c)),u=Math.round(l/2),d=Math.round(r/2),f={axisStart:d-u,axisEnd:d+u,cross:Math.round(i/2)},p=x(i),m=e.container?ye(f,e.container,n,{axis:{min:s,max:r-s},cross:{min:p,max:i-p},crossFrame:{min:0,max:i}}):f,h=m.axisEnd-m.axisStart,g=h<l;return{direction:t,...ve(t,m),referenceWidth:e.referenceWidth,referenceHeight:e.referenceHeight,amount:e.amount,pixels:g?h:l,...g?{requestedPixels:l}:{}}}function ve(e,t){let n=e===`up`||e===`down`,r=n?{x:t.cross,y:t.axisStart}:{x:t.axisStart,y:t.cross},i=n?{x:t.cross,y:t.axisEnd}:{x:t.axisEnd,y:t.cross},[a,o]=e===`up`||e===`left`?[r,i]:[i,r];return{x1:a.x,y1:a.y,x2:o.x,y2:o.y}}function x(e){return Math.max(1,Math.round(e*.1))}function ye(e,t,n,r){let i=S(n?t.y:t.x,n?t.height:t.width,r.axis),a=n?t.x:t.y,o=n?t.width:t.height,s=S(a,o,r.cross)??S(a,o,r.crossFrame);if(!i||!s)return e;let c=e.cross>=s.min&&e.cross<=s.max?e.cross:Math.round((s.min+s.max)/2);if(e.axisEnd-e.axisStart>=i.max-i.min)return{axisStart:i.min,axisEnd:i.max,cross:c};let l=e.axisStart<i.min?i.min-e.axisStart:Math.min(0,i.max-e.axisEnd);return{axisStart:e.axisStart+l,axisEnd:e.axisEnd+l,cross:c}}function S(e,t,n){let r=Math.max(n.min,Math.ceil(e)+8),i=Math.min(n.max,Math.floor(e+t)-1-8);return i>r?{min:r,max:i}:void 0}function be(e){D(e.amount),e.pixels!==void 0&&O(e.pixels)}function xe(e,t){if(e===`left`||e===`right`){let n=C(e,t);return{preset:e,x1:n.x1,y1:n.y1,x2:n.x2,y2:n.y2,referenceWidth:n.referenceWidth,referenceHeight:n.referenceHeight}}let[n,r]=e===`left-edge`?[99,15]:[1,85],i=T(w(t,n,50),t,8),a=T(w(t,r,50),t,8);return{preset:e,x1:i.x,y1:i.y,x2:a.x,y2:a.y,referenceWidth:t.referenceWidth,referenceHeight:t.referenceHeight}}function Se(e,t){switch(e){case`up`:return{x:0,y:-t};case`down`:return{x:0,y:t};case`left`:return{x:-t,y:0};case`right`:return{x:t,y:0}}}function C(e,t){let n=e===`left`||e===`up`,r=n?85:15,i=n?15:85,a=e===`up`||e===`down`,o=T(w(t,a?50:r,a?r:50),t,8),s=T(w(t,a?50:i,a?i:50),t,8);return{direction:e,x1:o.x,y1:o.y,x2:s.x,y2:s.y,referenceWidth:t.referenceWidth,referenceHeight:t.referenceHeight}}function Ce(e){let t=Te(e);if(t)return{referenceWidth:t.width,referenceHeight:t.height}}function w(e,t,n){let r=Math.trunc(e.referenceWidth*t/100),i=Math.trunc(e.referenceHeight*n/100);return{x:Number.isFinite(r)?r:0,y:Number.isFinite(i)?i:0}}function T(e,t,n){return{x:k(e.x,n,t.referenceWidth),y:k(e.y,n,t.referenceHeight)}}function we(e){return ge.parse(e)}function Te(e){let t=e.filter(e=>a(e)&&E(e.rect)).map(e=>e.rect).sort((e,t)=>(t?.width??0)*(t?.height??0)-(e?.width??0)*(e?.height??0))[0];if(t)return t;let n=e.map(e=>e.rect).filter(E);if(n.length===0)return;let r=Math.max(...n.map(e=>e.x+e.width)),i=Math.max(...n.map(e=>e.y+e.height));if(!(r<=0||i<=0))return{x:0,y:0,width:r,height:i}}function E(e){return!!e&&e.width>0&&e.height>0}function D(e){if(e===void 0)return b;if(!Number.isFinite(e)||e<=0)throw new t(`INVALID_ARGS`,`scroll amount must be a positive number`);return e}function O(e){if(!Number.isFinite(e)||e<=0)throw new t(`INVALID_ARGS`,`scroll pixels must be a positive integer`);return Math.max(1,Math.round(e))}function k(e,t,n){let r=Math.round(t);if(!Number.isFinite(r))return 0;let i=Math.max(r,Math.round(n-t));return!Number.isFinite(i)||!Number.isFinite(e)?r:Math.min(i,Math.max(r,Math.round(e)))}const A=Object.freeze({reason:`scroll_keyboard_occludes_surface`,hint:"The on-screen keyboard covers the surface this scroll would swipe, so it cannot reach it. Run `keyboard dismiss` and retry, accepting that it drops focus (re-tap the field to keep typing), or scroll before focusing the field."});function Ee(e,t){if(!j(e)||!j(t))return{kind:`unobstructed`};let n=e.x+e.width/2;if(n<t.x||n>=t.x+t.width)return{kind:`unobstructed`};let r=t.y;if(r>=e.y+e.height||t.y+t.height<=e.y)return{kind:`unobstructed`};let i=Math.max(0,r-12-e.y);return i<.15*e.height?{kind:`occluded`,keyboardMinY:r,visibleHeight:i}:{kind:`avoided`,viewport:{...e,height:i},keyboardMinY:r}}function De(e,n){return new t(`COMMAND_FAILED`,`scroll ${e} refused: the keyboard leaves ${n.visibleHeight}px of ${n.viewportHeight}px visible, below the 15% needed for a swipe`,{keyboardMinY:n.keyboardMinY,visibleHeight:n.visibleHeight,viewportHeight:n.viewportHeight,minVisibleFraction:.15,...A})}function j(e){return[e.x,e.y,e.width,e.height].every(e=>Number.isFinite(e))&&e.width>0&&e.height>0}const Oe=1e4,ke=12e4;function Ae(e){let t=e.trim().toLowerCase();return t?/^(vertical|horizontal)\s+scroll\s+bar(?:,?\s*\d+\s+pages?)?$/.test(t):!1}function je(e,t){if(!(e?.trim().toLowerCase()??``).includes(`vertical scroll bar`))return null;let n=Me(t);return n===null?null:n<=1?{above:!1,below:!0}:n>=99?{above:!0,below:!1}:{above:!0,below:!0}}function Me(e){if(!e)return null;let t=/^(\d{1,3})%$/.exec(e.trim());if(!t)return null;let n=Number(t[1]);return Number.isFinite(n)?Math.max(0,Math.min(100,n)):null}const Ne=1e4,Pe=.65;function Fe(e,t){return{...e,releaseBehavior:t===void 0?`controlled`:`inertial`}}function Ie(e,n=`scroll accepts either a relative amount or --pixels, not both`){if(e.amount!==void 0&&e.pixels!==void 0)throw new t(`INVALID_ARGS`,n)}function Le(e){if(e.maxPasses!==void 0){if(e.until===void 0)throw new t(`INVALID_ARGS`,`scroll maxPasses requires until`,{reason:`scroll_max_passes_requires_until`});if(!Number.isInteger(e.maxPasses)||e.maxPasses<1||e.maxPasses>200)throw new t(`INVALID_ARGS`,`scroll maxPasses must be an integer from 1 to 200`,{reason:`scroll_max_passes_invalid`})}if(e.until!==void 0&&e.edge!==void 0)throw new t(`INVALID_ARGS`,`scroll ${e.edge} already scrolls to the ${e.edge} edge and cannot take --until`,{hint:`Use scroll ${e.edge===`bottom`?`down`:`up`} --until <selector> to stop at the target, or scroll ${e.edge} to reach the edge.`})}function Re(e,n={}){if(e===void 0)return;let r=n.field??`scroll durationMs`,i=n.max??1e4,a=n.invalidMessage??`${r} must be a non-negative integer`;if(!Number.isFinite(e)||!Number.isInteger(e)||e<0)throw new t(`INVALID_ARGS`,a);if(e>i)throw new t(`INVALID_ARGS`,`${r} must be a non-negative integer at most ${i}`);return e}const ze=[`android`,`harmonyos`,`apple`,`vega`,`linux`];function Be(e){let{booted:t,kind:n,...r}=e;return r}const Ve={platform:`web`,id:`agent-browser-chrome`,name:`Agent Browser Chrome`,kind:`device`,target:`desktop`,booted:!0};function He(e){let t=We();for(let n of e){let e=Ge(n);t[e].available+=1,n.booted===!0&&(t[e].booted+=1)}return t}function Ue(e,t){return e.filter(e=>n(e,t.platform)&&(t.target===void 0||(e.target??`mobile`)===t.target)&&(t.kind===void 0||e.kind===t.kind)&&(t.booted===void 0||e.booted===t.booted))}function We(){return{android:{available:0,booted:0},harmonyos:{available:0,booted:0},apple:{available:0,booted:0},vega:{available:0,booted:0},linux:{available:0,booted:0},web:{available:0,booted:0}}}function Ge(e){return i(e)||r(e)?`apple`:e.platform}const Ke=new Set([`DEVICE_CLAIM_LIVE_OWNER`,`DEVICE_CLAIM_RECOVERY_PENDING`,`DEVICE_CLAIM_OWNER_UNCERTAIN`]);function qe(e){return Ke.has(e)}const M=`native-panel`,N=[`portrait`,`portrait-upside-down`,`landscape-left`,`landscape-right`],P={portrait:0,"landscape-left":1,"portrait-upside-down":2,"landscape-right":3};function Je(e){return N.find(t=>P[t]===e)}function Ye(e){return typeof e==`string`&&N.includes(e)}function Xe(e){return P[e]*90}function Ze(e){return P[e]%2==0?`PORTRAIT`:`LANDSCAPE`}function Qe(e){if(e===void 0)throw new t(`INVALID_ARGS`,`orientation requires an orientation argument. Use portrait|portrait-upside-down|landscape-left|landscape-right.`);switch(e?.trim().toLowerCase()){case`portrait`:return`portrait`;case`portrait-upside-down`:case`upside-down`:return`portrait-upside-down`;case`landscape-left`:case`left`:return`landscape-left`;case`landscape-right`:case`right`:return`landscape-right`;default:throw new t(`INVALID_ARGS`,`Invalid rotation: ${e}. Use portrait|portrait-upside-down|landscape-left|landscape-right.`)}}const $e=[...N,`auto`];function et(e){return e?.trim().toLowerCase()===`auto`?`auto`:Qe(e)}const F=[`volume-up`,`volume-down`,`power`,`mute`,`sleep`,`wake`,`media-play-pause`,`media-next`,`media-previous`,`media-rewind`,`media-fast-forward`],tt=`<${F.join(`|`)}>`,I={volumeUp:`volume-up`,volumeDown:`volume-down`,power:`power`,mute:`mute`,sleep:`sleep`,wake:`wake`,mediaPlayPause:`media-play-pause`,mediaNext:`media-next`,mediaPrevious:`media-previous`,mediaRewind:`media-rewind`,mediaFastForward:`media-fast-forward`},nt=new Map(Object.entries(I).map(([e,t])=>[t,e]));function rt(e){let n=e?.toLowerCase(),r=n===void 0?void 0:nt.get(n);if(r)return r;throw new t(`INVALID_ARGS`,`hardware-button button must be one of: ${F.join(`, `)}.`)}function it(e){if(e.length!==1)throw new t(`INVALID_ARGS`,`hardware-button requires exactly one button: ${F.join(`, `)}.`);return rt(e[0])}const at=[`closed`,`half-open`,`open`],L=`closed|half-open|open`;function ot(e){if(Number.isFinite(e))return e<=st?`closed`:e>=ct?`open`:`half-open`}const st=1,ct=179;function R(e){if(e===void 0)throw new t(`INVALID_ARGS`,`fold requires a pose argument. Use ${L}.`);switch(e.trim().toLowerCase()){case`closed`:case`close`:case`fold`:case`folded`:return`closed`;case`half-open`:case`half`:case`half-unfolded`:case`partially-open`:case`book`:return`half-open`;case`open`:case`unfold`:case`unfolded`:case`fully-open`:case`flat`:return`open`;default:throw new t(`INVALID_ARGS`,`Invalid fold pose: ${e}. Use ${L}.`)}}const z=6e4;function lt(e){if(e.keyframes===void 0){if(e.pose===void 0)throw new t(`INVALID_ARGS`,`fold requires a pose or keyframes`);if(typeof e.pose!=`string`)throw new t(`INVALID_ARGS`,`fold pose must be a string`);return{pose:R(e.pose)}}if(e.pose!==void 0)throw new t(`INVALID_ARGS`,`fold accepts either pose or keyframes`);return{keyframes:B(e.keyframes)}}function B(e){if(!Array.isArray(e)||e.length<2||e.length>64)throw new t(`INVALID_ARGS`,`fold requires 2–64 keyframes`);let n=e.map(ut);if(n[0].atMs!==0||n.some((e,t)=>t>0&&e.atMs<=n[t-1].atMs))throw new t(`INVALID_ARGS`,`Fold keyframes must start at 0ms and increase strictly`);return n}function V(e,t){return typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=t}function ut(e){if(!e||typeof e!=`object`||Array.isArray(e))throw new t(`INVALID_ARGS`,`Each fold keyframe requires atMs and angle`);let{atMs:n,angle:r}=e;if(Object.keys(e).some(e=>e!==`atMs`&&e!==`angle`))throw new t(`INVALID_ARGS`,`Fold keyframes only accept atMs and angle`);if(!V(n,6e4)||!Number.isSafeInteger(n))throw new t(`INVALID_ARGS`,`Fold keyframe times must be integers from 0 to ${z}ms`);if(!V(r,180))throw new t(`INVALID_ARGS`,`Fold keyframe angles must be finite numbers from 0 to 180`);return{atMs:n,angle:r}}function dt(e){let n;try{n=JSON.parse(e)}catch{throw new t(`INVALID_ARGS`,`--keyframes requires a JSON array of {atMs, angle} objects`)}return B(n)}const H=[`call`,`accept`,`cancel`],U=[...H,`sms`],W=`telephony call|accept|cancel <number> | telephony sms <number> <text>`,ft=/^\+?\d{1,15}$/,pt=/[\u0000-\u0009\u000b-\u001f\u007f-\u009f]/;function mt(e){if(e===void 0)throw new t(`INVALID_ARGS`,`telephony requires an action. Use ${W}.`);let n=typeof e==`string`?e.trim().toLowerCase():void 0,r=U.find(e=>e===n);if(!r)throw new t(`INVALID_ARGS`,`Invalid telephony action: ${String(e)}. Use ${U.join(`, `)}.`);return r}function G(e){let n=mt(e.action),r=_t(e.number,n);if(n!==`sms`){if(e.text!==void 0)throw new t(`INVALID_ARGS`,`telephony ${n} takes only a phone number.`);return{action:n,number:r}}return{action:n,number:r,text:vt(e.text)}}function ht(e){let[t,n,...r]=e;return G({action:t,number:n,text:r.length>0?r.join(` `):void 0})}function gt(e){return e.action===`sms`?[e.action,e.number,e.text]:[e.action,e.number]}function _t(e,n){if(typeof e!=`string`||e.trim()===``)throw new t(`INVALID_ARGS`,`telephony ${n} requires a phone number.`);let r=e.trim();if(!ft.test(r))throw new t(`INVALID_ARGS`,`Invalid phone number: ${r}.`,{hint:`Use digits with an optional leading +, for example 5551234 or +15551234567.`});return r}function vt(e){if(typeof e!=`string`||e===``)throw new t(`INVALID_ARGS`,`telephony sms requires message text.`);let n=e.replaceAll(`\r
|
|
2
2
|
`,`
|
|
3
3
|
`);if(pt.test(n))throw new t(`INVALID_ARGS`,`telephony sms text must not contain control characters.`,{hint:`Line breaks (LF or CRLF) are allowed; tabs, lone carriage returns, and other control characters are not.`});return n}var yt=e({FOLD_POSE_USAGE:()=>L,FOLD_SCREEN_COORDINATE_SPACE:()=>M,HARDWARE_BUTTON_NAME_LABELS:()=>I,MAX_FOLD_DURATION_MS:()=>z,MAX_FOLD_KEYFRAMES:()=>64,TELEPHONY_USAGE:()=>W}),bt=e({TV_REMOTE_ANDROID_KEYCODE_PATTERN:()=>J,TV_REMOTE_BUTTONS:()=>q,TV_REMOTE_BUTTON_USAGE:()=>Y,isTvRemoteButton:()=>X,parseTvRemoteButton:()=>St,toAndroidTvRemoteKeyevent:()=>Et,toAppleTvRemoteButton:()=>Tt,toVegaTvRemoteKey:()=>Q,tvRemoteButtonsForPlatform:()=>wt,tvRemoteDurationMode:()=>$});const xt={android:`longpress`,apple:`exact`,vega:`exact`},K={up:{aliases:[],androidKeyevent:`KEYCODE_DPAD_UP`,appleRemoteButton:`up`,vegaKey:`KEY_UP`},down:{aliases:[],androidKeyevent:`KEYCODE_DPAD_DOWN`,appleRemoteButton:`down`,vegaKey:`KEY_DOWN`},left:{aliases:[],androidKeyevent:`KEYCODE_DPAD_LEFT`,appleRemoteButton:`left`,vegaKey:`KEY_LEFT`},right:{aliases:[],androidKeyevent:`KEYCODE_DPAD_RIGHT`,appleRemoteButton:`right`,vegaKey:`KEY_RIGHT`},select:{aliases:[`ok`,`center`,`enter`],androidKeyevent:`KEYCODE_DPAD_CENTER`,appleRemoteButton:`select`,vegaKey:`KEY_ENTER`},menu:{aliases:[],androidKeyevent:`KEYCODE_MENU`,appleRemoteButton:`menu`,vegaKey:`KEY_MENU`},home:{aliases:[],androidKeyevent:`KEYCODE_HOME`,appleRemoteButton:`home`,vegaKey:`KEY_HOMEPAGE`},back:{aliases:[],androidKeyevent:`KEYCODE_BACK`,appleRemoteButton:`menu`,vegaKey:`KEY_BACK`},"volume-up":{aliases:[],androidKeyevent:`24`},"volume-down":{aliases:[],androidKeyevent:`25`},mute:{aliases:[],androidKeyevent:`164`},power:{aliases:[],androidKeyevent:`26`},sleep:{aliases:[],androidKeyevent:`223`},wake:{aliases:[],androidKeyevent:`224`},"media-play-pause":{aliases:[],androidKeyevent:`85`},"media-next":{aliases:[],androidKeyevent:`87`},"media-previous":{aliases:[],androidKeyevent:`88`},"media-rewind":{aliases:[],androidKeyevent:`89`},"media-fast-forward":{aliases:[],androidKeyevent:`90`},"channel-up":{aliases:[],androidKeyevent:`166`},"channel-down":{aliases:[],androidKeyevent:`167`},"last-channel":{aliases:[],androidKeyevent:`229`},guide:{aliases:[],androidKeyevent:`172`},info:{aliases:[],androidKeyevent:`165`},captions:{aliases:[],androidKeyevent:`175`},"tv-input":{aliases:[],androidKeyevent:`178`},"color-red":{aliases:[],androidKeyevent:`183`},"color-green":{aliases:[],androidKeyevent:`184`},"color-yellow":{aliases:[],androidKeyevent:`185`},"color-blue":{aliases:[],androidKeyevent:`186`}},q=Object.keys(K),J=/^android-keycode:(?:[1-9][0-9]{0,8}|1[0-9]{9}|20[0-9]{8}|21[0-3][0-9]{7}|214[0-6][0-9]{6}|2147[0-3][0-9]{5}|21474[0-7][0-9]{4}|214748[0-2][0-9]{3}|2147483[0-5][0-9]{2}|21474836[0-3][0-9]|214748364[0-7])(?![\s\S])/,Y=`<${q.join(`|`)}|android-keycode:<n>>`;function St(e){let n=e?.toLowerCase();if(X(n))return n;let r=n?Ot.get(n):void 0;if(r)return r;throw new t(`INVALID_ARGS`,`tv-remote button must be one of: ${q.join(`, `)}, or android-keycode:<n> with n from 1 to 2147483647.`)}function X(e){return Z(e)||Ct(e)}function Z(e){return typeof e==`string`&&Object.hasOwn(K,e)}function Ct(e){return typeof e==`string`&&J.test(e)}function wt(e){let t=e===`apple`?`appleRemoteButton`:`vegaKey`;return q.filter(e=>t in K[e])}function Tt(e){let t=Z(e)?K[e]:void 0;if(t&&`appleRemoteButton`in t)return t.appleRemoteButton;throw Dt(e,`tvOS`)}function Et(e){return Z(e)?K[e].androidKeyevent:e.slice(16)}function Q(e){let t=Z(e)?K[e]:void 0;if(t&&`vegaKey`in t)return t.vegaKey;throw Dt(e,`Vega OS`)}function Dt(e,n){return new t(`UNSUPPORTED_OPERATION`,`TV remote button ${e} is not supported on ${n}.`,{reason:`unsupported-platform-leaf`})}function $(e){return xt[e]}const Ot=new Map(q.flatMap(e=>K[e].aliases.map(t=>[t,e])));export{Oe as $,Ze as A,te as At,Ve as B,M as C,o as Ct,z as D,c as Dt,tt as E,ae as Et,dt as F,Pe as G,Ue as H,R as I,Le as J,Ne as K,it as L,ot as M,re as Mt,Ye as N,$e as O,_ as Ot,lt as P,Ae as Q,et as R,L as S,d as St,I as T,ie as Tt,qe as U,He as V,Be as W,Fe as X,Re as Y,je as Z,ht as _,De as _t,St as a,pe as at,P as b,f as bt,Q as c,he as ct,bt as d,_e as dt,ke as et,yt as f,xe as ft,G as g,we as gt,W as h,Ce as ht,X as i,A as it,Xe as j,l as jt,Je as k,ne as kt,wt as l,be as lt,H as m,Se as mt,q as n,de as nt,Et as o,me as ot,U as p,Ee as pt,Ie as q,Y as r,ue as rt,Tt as s,fe as st,J as t,b as tt,$ as u,C as ut,gt as v,y as vt,F as w,p as wt,at as x,u as xt,N as y,s as yt,ze as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{R as e}from"./sdk-contracts.js";import{
|
|
1
|
+
import{R as e}from"./sdk-contracts.js";import{pn as t}from"./sdk-batch.js";import{r as n}from"./success-text.js";import{n as r}from"./snapshot-runtime-capture-input.js";import{m as i}from"./selector-pipeline-policy.js";import{n as a}from"./runtime-admission.js";function o(e){let t=e?.trim().split(/\s+/,1)[0];if(!t||!t.startsWith(`@`)||t.length<3)return null;let n=t.slice(1);return/^[A-Za-z_-]*\d[\w-]*$/i.test(n)||/^(?:ref|node|element|el)[\w-]*$/i.test(n)?t:null}async function s(e){let n=await a({command:`type`,device:e.device,use:t,inspectFacts:e.inspectFacts,platformServices:e.platformServices,bindDevice:e.bindDevice});if(n.type===`response`)return{ok:!1,response:n.response};let r=n.runtime;return{ok:!0,typeText:async(e,t)=>await c(r,e,t)}}async function c(t,r,a){let s=o(r[0]);if(s)throw new e(`INVALID_ARGS`,`type does not accept a target ref like "${s}"`,{hint:`Use fill ${s} "text" to target that field, or press ${s} then type "text" to append.`});let c=r.join(` `);if(!c)throw new e(`INVALID_ARGS`,`type requires text`);let u=i(a.delayMs??0,`delay-ms`,0,1e4),d=(await t.operations.typeText(l(c,u,a)))?.textEntryRoute;return{...d===void 0?{}:{textEntryRoute:d},text:c,delayMs:u,...n(`Typed ${Array.from(c).length} chars`)}}function l(e,t,n){return{text:e,delayMs:t,...n.appBundleId===void 0?{}:{options:{appBundleId:n.appBundleId}},execution:r(n)}}export{s as n,c as t};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agent-device",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.35",
|
|
4
4
|
"description": "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.",
|
|
5
5
|
"mcpName": "io.github.callstack/agent-device",
|
|
6
6
|
"license": "MIT",
|
package/server.json
CHANGED
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
"url": "https://github.com/callstack/agent-device",
|
|
8
8
|
"source": "github"
|
|
9
9
|
},
|
|
10
|
-
"version": "0.21.
|
|
10
|
+
"version": "0.21.35",
|
|
11
11
|
"packages": [
|
|
12
12
|
{
|
|
13
13
|
"registryType": "npm",
|
|
14
14
|
"identifier": "agent-device",
|
|
15
|
-
"version": "0.21.
|
|
15
|
+
"version": "0.21.35",
|
|
16
16
|
"transport": {
|
|
17
17
|
"type": "stdio"
|
|
18
18
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
915960cc9505f9bdcd32561429e685764405af423dc61414e47e447307837e4e agent-device-android-ime-helper-0.21.34.apk
|
package/android/snapshot-helper/dist/agent-device-android-snapshot-helper-0.21.34.apk.sha256
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
5a751cabaac477692ef59bed1c8233f25c6b35ca18eaf771b477d18542b91a8b agent-device-android-snapshot-helper-0.21.34.apk
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{R as e}from"./sdk-contracts.js";function t(t){let n=t.read(t.resolveCurrent()??t.initialSession),r=()=>{if(t.assertAdmissionOpen(),t.read(t.requireCurrent()))throw new e(`COMMAND_FAILED`,`Session capture resource has changed`,{reason:`session_resource_changed`,session:t.address})};return Object.freeze({address:t.address,sessionDir:t.sessionDir,read:()=>{let e=t.resolveCurrent();return e!==void 0&&(n=t.read(e)),n},assertAdoptable:r,canPersist:()=>{let e=t.resolveCurrent();return e!==void 0&&t.read(e)===void 0},adopt:e=>{r(),t.write(e),n=e},clear:e=>{let r=t.resolveCurrent();if(r===void 0)return`retired`;let i=t.read(r);return n=i,i?.handle!==e.handle||i.envelope.fence.token!==e.envelope.fence.token||i.envelope.fence.generation!==e.envelope.fence.generation?`resource-changed`:(t.write(void 0),n=void 0,`cleared`)}})}function n(e,n,r){return t({address:n.address,sessionDir:e.resolveSessionDir(n.address),initialSession:n.session,resolveCurrent:()=>e.resolveCurrent(n),requireCurrent:()=>e.requireCurrent(n),assertAdmissionOpen:()=>e.assertAdmissionOpen(n.address),...r})}function r(e,t){return n(e,t,{read:e=>e.audioProbe,write:n=>{e.update(t,{audioProbe:n})}})}function i(e,t){return n(e,t,{read:e=>e.perfCapture,write:n=>{e.update(t,{perfCapture:n})}})}function a(e,t){return n(e,t,{read:e=>e.screenRecording,write:n=>{e.update(t,{screenRecording:n})}})}function o(t,n,r){let i,o=()=>{if(i)throw t.requireCurrent(i.ref),new e(`COMMAND_FAILED`,`Recording draft has already been published`,{reason:`session_resource_changed`,session:n});t.assertPublishable(n)},s=Object.freeze({address:n,sessionDir:t.resolveSessionDir(n),read:()=>i?.binding.read(),assertAdoptable:o,canPersist:()=>!i&&t.lookup(n)===void 0,adopt:s=>{if(o(),r.screenRecording)throw new e(`COMMAND_FAILED`,`Recording draft already owns a resource`,{reason:`session_resource_changed`,session:n});let c=t.publish(n,r),l=a(t,c);l.adopt(s),i=Object.freeze({ref:c,binding:l})},clear:e=>i?.binding.clear(e)??`retired`});return Object.freeze({binding:s,requireRef:()=>{if(!i)throw TypeError(`Screen recording did not publish its session`);return i.ref}})}export{a,i,r as n,n as r,o as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{R as e}from"./sdk-contracts.js";import{_t as t}from"./sdk-io.js";import"./diagnostics.js";import{n}from"./runtime-slots.js";import{p as r,r as i,s as a}from"./screen-recording-session-resource.js";import{c as o}from"./artifact-tracking.js";import{a as s,i as c,n as l}from"./session-capture-binding.js";import u from"node:crypto";import{rmSync as d}from"node:fs";import f from"node:os";import p from"node:path";import m from"node:fs/promises";const h={label:`Materialized paths`,plural:!0,expiredHint:`Materialized paths are released automatically when their TTL expires; re-run the command that materialized them if the paths are still needed.`},g=Symbol(`materializedPaths`),_=()=>n(g,()=>new Map,e=>{for(let t of e.values()){clearTimeout(t.timer);try{d(t.rootPath,{recursive:!0,force:!0})}catch{}}});async function v(e){let t=await m.mkdtemp(p.join(f.tmpdir(),`agent-device-materialized-`));try{let n=await C(e.installablePath,p.join(t,`installable`)),r=e.archivePath?await C(e.archivePath,p.join(t,`archive`)):void 0,i=u.randomUUID(),a=e.ttlMs??9e5,o=Date.now()+a,s=setTimeout(()=>{x(i)},a);return _().set(i,{rootPath:t,installablePath:n,archivePath:r,tenantId:e.tenantId,sessionName:e.sessionName,expiresAt:o,timer:s}),{materializationId:i,installablePath:n,...r?{archivePath:r}:{},expiresAt:new Date(o).toISOString()}}catch(e){throw await m.rm(t,{recursive:!0,force:!0}),e}}async function y(e,t){await S(e,o(_(),e,t,h))}async function b(e){let t=Array.from(_().entries()).filter(([,t])=>t.sessionName===e);await Promise.all(t.map(async([e,t])=>{await S(e,t)}))}async function x(e){let t=_().get(e);if(t)try{await S(e,t)}catch{}}async function S(e,t){clearTimeout(t.timer),_().delete(e),await m.rm(t.rootPath,{recursive:!0,force:!0})}async function C(e,t){let n=await m.stat(e);await m.mkdir(t,{recursive:!0});let r=p.join(t,p.basename(e));return n.isDirectory()?(await m.cp(e,r,{recursive:!0}),r):(await m.copyFile(e,r),r)}function w(e){return e.device.platform===`web`}function T(e){return e.toArray().filter(e=>e.device.platform===`web`).map(e=>e.name)}async function E(e){let t=e.sessionStore.refresh(e.ref);if(!t.session.appLog)return;let{forceCleanupSessionAppLog:n}=await import(`./app-log-session-resource.js`).then(e=>e.n);await n({...e,ref:t})}async function D(e){let t=c(e.sessionStore,e.ref);t.read()&&await a({binding:t,intent:`disposal`})}async function O(e,t){await t.stopSnapshotHelper(e.device)}async function k(e){let{ref:t,sessionStore:n,platformCleanup:r}=e,i=n.resolveCurrent(t)??t.session,a=t.address;await r.closeManagedBrowser({device:i.device,sessionName:a,stateDir:n.resolveDaemonStateDir(),openSessionNames:()=>T(n)})}async function A(e){let t=[];for(let{step:n,run:r}of e)try{await r()}catch(e){t.push({step:n,error:e})}return t}function j(n){if(n.failures.length===0)return;let r=n.failures.map(({step:e})=>e),i=n.failures.map(({step:e,error:t})=>`${e}: ${t instanceof Error?t.message:String(t)}`);return t({level:`error`,phase:n.phase,data:{session:n.sessionName,failedSteps:r,errors:i}}),new e(`COMMAND_FAILED`,`Session cleanup left ${n.failures.length} resource(s) unreleased: ${i.join(`; `)}`,{reason:`session_cleanup_incomplete`,session:n.sessionName,failedSteps:r,hint:`Some session resources failed to release. The session was retired; inspect the session log, device state, and retained claims before recovery. Do not retry close on the retired session.`})}async function M(t){let{ref:n,sessionStore:r}=t,i=r.resolveCurrent(n)??n.session,a=n.address;if(!t.platformCleanup)throw new e(`INTERNAL_ERROR`,`Platform resource cleanup was not supplied by root runtime composition`);let o=t.platformCleanup,s=[{step:`recording`,run:()=>N({ref:n,sessionStore:r})},...t.appLog===`run`?[{step:`app_log`,run:()=>E({ref:n,sessionStore:r})}]:[],{step:`audio_probe`,run:()=>P({ref:n,sessionStore:r})},{step:`perf_capture`,run:()=>D({ref:n,sessionStore:r})},{step:`platform_snapshot_helper`,run:()=>O(i,o)},{step:`web_browser`,run:()=>k({ref:n,sessionStore:r,platformCleanup:o})}];s.push({step:`materialized_paths`,run:()=>b(a)});let c=j({sessionName:a,phase:`session_teardown_cleanup_failed`,failures:await A(s)});if(c)throw c}async function N(e){let t=s(e.sessionStore,e.ref);if(!t.read())return;let n=await i({binding:t,intent:`disposal`});if(!e.ref.session.lease)return;let{retainLeasedSessionRecording:r}=await import(`./leased-recording-retention.js`);r(e.ref,n)}async function P(e){let t=l(e.sessionStore,e.ref);t.read()&&await r({binding:t,intent:`disposal`})}export{D as a,w as c,b as d,v as f,E as i,T as l,N as n,O as o,j as r,M as s,P as t,y as u};
|