agent-device 0.17.10 → 0.18.1

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.
Files changed (160) hide show
  1. package/README.md +3 -2
  2. package/android-multitouch-helper/dist/{agent-device-android-multitouch-helper-0.17.10.apk → agent-device-android-multitouch-helper-0.18.1.apk} +0 -0
  3. package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.18.1.apk.sha256 +1 -0
  4. package/android-multitouch-helper/dist/{agent-device-android-multitouch-helper-0.17.10.manifest.json → agent-device-android-multitouch-helper-0.18.1.manifest.json} +4 -4
  5. package/android-snapshot-helper/dist/{agent-device-android-snapshot-helper-0.17.10.apk → agent-device-android-snapshot-helper-0.18.1.apk} +0 -0
  6. package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.18.1.apk.sha256 +1 -0
  7. package/android-snapshot-helper/dist/{agent-device-android-snapshot-helper-0.17.10.manifest.json → agent-device-android-snapshot-helper-0.18.1.manifest.json} +6 -6
  8. package/apple-runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.m +156 -0
  9. package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/project.pbxproj +10 -16
  10. package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+AXSnapshotFallback.swift +2 -0
  11. package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandExecution.swift +3 -1
  12. package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+CommandJournal.swift +2 -0
  13. package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+FlatSnapshotFiltering.swift +2 -4
  14. package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Interaction.swift +9 -36
  15. package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScrollGesture.swift +2 -0
  16. package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SequenceExecution.swift +2 -0
  17. package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Snapshot.swift +2 -0
  18. package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SnapshotCapturePlan.swift +2 -0
  19. package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TextEntry.swift +0 -1
  20. package/dist/src/1986.js +1 -0
  21. package/dist/src/2748.js +1 -1
  22. package/dist/src/2948.js +21 -21
  23. package/dist/src/314.js +1 -1
  24. package/dist/src/3340.js +8 -7
  25. package/dist/src/432.js +4 -4
  26. package/dist/src/4418.js +1 -1
  27. package/dist/src/4428.js +3 -3
  28. package/dist/src/485.js +1 -0
  29. package/dist/src/495.js +5 -0
  30. package/dist/src/5484.js +1 -1
  31. package/dist/src/5643.js +1 -0
  32. package/dist/src/587.js +1 -1
  33. package/dist/src/5913.js +4 -0
  34. package/dist/src/6849.js +1 -0
  35. package/dist/src/6918.js +1 -1
  36. package/dist/src/6967.js +1 -0
  37. package/dist/src/760.js +1 -0
  38. package/dist/src/7871.js +1 -0
  39. package/dist/src/8225.js +1 -1
  40. package/dist/src/8391.js +1 -0
  41. package/dist/src/8404.js +2 -0
  42. package/dist/src/8414.js +2 -0
  43. package/dist/src/8875.js +1 -1
  44. package/dist/src/8936.js +1 -0
  45. package/dist/src/9414.js +1 -0
  46. package/dist/src/9581.js +5 -5
  47. package/dist/src/9624.js +1 -1
  48. package/dist/src/9722.js +37 -37
  49. package/dist/src/android-adb.d.ts +19 -54
  50. package/dist/src/android-adb.js +1 -1
  51. package/dist/src/android.js +5 -5
  52. package/dist/src/apps.js +9 -11
  53. package/dist/src/audio-probe.js +1 -0
  54. package/dist/src/batch.d.ts +50 -25
  55. package/dist/src/batch.js +1 -1
  56. package/dist/src/cli-help.js +104 -37
  57. package/dist/src/cli.js +36 -27
  58. package/dist/src/contracts.d.ts +46 -122
  59. package/dist/src/contracts.js +1 -1
  60. package/dist/src/debug-symbols.js +3 -0
  61. package/dist/src/devices.js +1 -1
  62. package/dist/src/devices~1.js +1 -1
  63. package/dist/src/devices~2.js +1 -1
  64. package/dist/src/find.js +1 -1
  65. package/dist/src/finders.d.ts +2 -6
  66. package/dist/src/finders.js +1 -1
  67. package/dist/src/generic.js +1 -9
  68. package/dist/src/handler-utils.js +1 -0
  69. package/dist/src/index.d.ts +500 -182
  70. package/dist/src/index.js +1 -1
  71. package/dist/src/input-actions.js +1 -1
  72. package/dist/src/input-actions~1.js +1 -1
  73. package/dist/src/install-source.d.ts +0 -26
  74. package/dist/src/install-source.js +1 -1
  75. package/dist/src/interaction.js +1 -1
  76. package/dist/src/interactor.js +1 -0
  77. package/dist/src/internal/bin.js +1 -1
  78. package/dist/src/internal/companion-tunnel.js +1 -1
  79. package/dist/src/internal/png-worker.js +1 -1
  80. package/dist/src/lease.js +1 -1
  81. package/dist/src/linux.js +1 -1
  82. package/dist/src/metro.d.ts +10 -134
  83. package/dist/src/metro.js +1 -1
  84. package/dist/src/notifications.js +1 -1
  85. package/dist/src/react-native.js +1 -1
  86. package/dist/src/record-trace-recording.js +3 -3
  87. package/dist/src/record-trace.js +1 -1
  88. package/dist/src/remote-config.d.ts +28 -24
  89. package/dist/src/remote-config.js +1 -1
  90. package/dist/src/runner-sequence.js +1 -0
  91. package/dist/src/selector-runtime.js +1 -1
  92. package/dist/src/selectors.d.ts +7 -3
  93. package/dist/src/selectors.js +1 -1
  94. package/dist/src/server.js +2 -2
  95. package/dist/src/session.js +11 -8
  96. package/dist/src/simulator.js +2 -0
  97. package/dist/src/snapshot.js +2 -2
  98. package/dist/src/web.js +1 -1
  99. package/macos-helper/Sources/AgentDeviceMacOSHelper/AudioProbe.swift +297 -0
  100. package/macos-helper/Sources/AgentDeviceMacOSHelper/main.swift +30 -0
  101. package/package.json +15 -11
  102. package/server.json +2 -2
  103. package/android-multitouch-helper/README.md +0 -41
  104. package/android-multitouch-helper/dist/agent-device-android-multitouch-helper-0.17.10.apk.sha256 +0 -1
  105. package/android-snapshot-helper/README.md +0 -88
  106. package/android-snapshot-helper/dist/agent-device-android-snapshot-helper-0.17.10.apk.sha256 +0 -1
  107. package/dist/src/2133.js +0 -1
  108. package/dist/src/2577.js +0 -1
  109. package/dist/src/2954.js +0 -2
  110. package/dist/src/4291.js +0 -1
  111. package/dist/src/4723.js +0 -1
  112. package/dist/src/5628.js +0 -1
  113. package/dist/src/5910.js +0 -2
  114. package/dist/src/6024.js +0 -1
  115. package/dist/src/733.js +0 -1
  116. package/dist/src/7394.js +0 -6
  117. package/dist/src/8275.js +0 -2
  118. package/dist/src/8358.js +0 -4
  119. package/dist/src/9919.js +0 -6
  120. package/dist/src/android-snapshot-helper.d.ts +0 -359
  121. package/dist/src/android-snapshot-helper.js +0 -1
  122. package/dist/src/apple.js +0 -1
  123. package/ios-runner/AgentDeviceRunner/AgentDeviceRunner/AgentDeviceRunnerApp.swift +0 -17
  124. package/ios-runner/AgentDeviceRunner/AgentDeviceRunner/Assets.xcassets/AccentColor.colorset/Contents.json +0 -11
  125. package/ios-runner/AgentDeviceRunner/AgentDeviceRunner/Assets.xcassets/AppIcon.appiconset/Contents.json +0 -36
  126. package/ios-runner/AgentDeviceRunner/AgentDeviceRunner/Assets.xcassets/AppIcon.appiconset/logo.jpg +0 -0
  127. package/ios-runner/AgentDeviceRunner/AgentDeviceRunner/Assets.xcassets/Contents.json +0 -6
  128. package/ios-runner/AgentDeviceRunner/AgentDeviceRunner/Assets.xcassets/Logo.imageset/Contents.json +0 -21
  129. package/ios-runner/AgentDeviceRunner/AgentDeviceRunner/Assets.xcassets/Logo.imageset/logo.jpg +0 -0
  130. package/ios-runner/AgentDeviceRunner/AgentDeviceRunner/Assets.xcassets/PoweredBy.imageset/Contents.json +0 -21
  131. package/ios-runner/AgentDeviceRunner/AgentDeviceRunner/Assets.xcassets/PoweredBy.imageset/powered-by.png +0 -0
  132. package/ios-runner/AgentDeviceRunner/AgentDeviceRunner/ContentView.swift +0 -34
  133. package/ios-runner/README.md +0 -53
  134. package/ios-runner/RUNNER_PROTOCOL.md +0 -76
  135. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -0
  136. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunner.xcodeproj/xcshareddata/xcschemes/AgentDeviceRunner.xcscheme +0 -0
  137. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/AgentDeviceRunnerUITests-Bridging-Header.h +0 -0
  138. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/AgentDeviceRunnerUITests.entitlements +0 -0
  139. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.h +0 -0
  140. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerAXSnapshotBridge.m +0 -0
  141. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerObjCExceptionCatcher.h +0 -0
  142. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerObjCExceptionCatcher.m +0 -0
  143. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.h +0 -0
  144. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerSynthesizedGesture.m +0 -0
  145. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Alert.swift +0 -0
  146. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Environment.swift +0 -0
  147. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Exceptions.swift +0 -0
  148. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Lifecycle.swift +0 -0
  149. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Models.swift +0 -0
  150. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+ScreenRecorder.swift +0 -0
  151. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+SystemModal.swift +0 -0
  152. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+Transport.swift +0 -0
  153. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests+TvRemote.swift +0 -0
  154. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests/RunnerTests.swift +0 -0
  155. /package/{ios-runner → apple-runner}/AgentDeviceRunner/AgentDeviceRunnerUITests.xctestplan +0 -0
  156. /package/{ios-runner → apple-runner}/AgentDeviceRunner/RecordingScripts/recording-overlay.swift +0 -0
  157. /package/{ios-runner → apple-runner}/AgentDeviceRunner/RecordingScripts/recording-resize.swift +0 -0
  158. /package/{ios-runner → apple-runner}/AgentDeviceRunner/RecordingScripts/recording-trim.swift +0 -0
  159. /package/dist/src/{4069.js → 4917.js} +0 -0
  160. /package/dist/src/{9836.js → 893.js} +0 -0
package/dist/src/8875.js CHANGED
@@ -1 +1 @@
1
- import{AsyncLocalStorage as t}from"node:async_hooks";import{constants as e}from"node:fs";import{access as r,stat as n}from"node:fs/promises";import o from"node:path";import{spawn as i,spawnSync as u}from"node:child_process";import{Readable as d}from"node:stream";import{pipeline as s}from"node:stream/promises";import{AppError as a}from"./733.js";let f=/^[A-Za-z0-9][A-Za-z0-9._+-]*$/,c=[".com",".exe",".bat",".cmd"],l=new t;async function m(t,e){return t?await l.run(t,e):await e()}async function p(t){return await l.run(void 0,t)}async function w(t,e,r={}){let n=l.getStore()?.(t,e,r);return n?await n:await v(t,e,r)}async function h(t,e,r={}){let n=l.getStore()?.(t,e,r);return n?await n:await v(t,e,r)}function v(t,e,r={}){let n=O(t);return new Promise((o,u)=>{let d=i(n,e,{cwd:r.cwd,env:r.env,stdio:["pipe","pipe","pipe"],detached:r.detached,windowsHide:!0,shell:!1});r.onSpawn?.(d);let s="",f=r.binaryStdout?[]:void 0,c="",l=!1,m=P(r.timeoutMs),p=m?setTimeout(()=>{l=!0,H(d,r.detached)},m):null,w=B(d,r);r.binaryStdout||d.stdout.setEncoding("utf8"),d.stderr.setEncoding("utf8"),G(d,r.stdin).catch(o=>{var i,s,f,c;w.didAbort||l||(i=o)instanceof Error&&"code"in i&&"EPIPE"===i.code||(u((s=n,f=t,new a("COMMAND_FAILED",`Failed to write stdin for ${s}`,{cmd:f,args:e},(c=o)instanceof Error?c:void 0))),H(d,r.detached))}),d.stdout.on("data",t=>{if(r.binaryStdout)return void f?.push(Buffer.isBuffer(t)?t:Buffer.from(t));let e=String(t);s+=e,r.onStdoutChunk?.(e)}),d.stderr.on("data",t=>{let e=String(t);c+=e,r.onStderrChunk?.(e)}),d.on("error",r=>{p&&clearTimeout(p),w.dispose(),u(L(w,n,t,e,r))}),d.on("close",i=>{p&&clearTimeout(p),w.dispose();let d=i??1;if(!w.didAbort&&l&&m){var h,v,A,S,b,E;return void u((h=n,v=t,A=e,S=m,b=d,E=s,new a("COMMAND_FAILED",`${h} timed out after ${S}ms`,{cmd:v,args:A,stdout:E,stderr:c,exitCode:b,timeoutMs:S})))}let g=N(w,n,t,e,d,r.allowFailure,s,c);g?u(g):o({stdout:s,stderr:c,exitCode:d,stdoutBuffer:f?Buffer.concat(f):void 0})})})}async function A(t){let e=D(t);if(!e)return!1;if(o.isAbsolute(e))return F(e);let r=process.env.PATH;if(!r)return!1;let n=function(){if("win32"!==process.platform)return[""];let t=process.env.PATHEXT;if(!t)return c;let e=t.split(";").map(t=>t.trim().toLowerCase()).filter(t=>t.length>0);return e.length>0?e:c}();for(let t of r.split(o.delimiter)){let r=t.trim();if(r){for(let t of function(t,e){if("win32"!==process.platform)return[t];let r=t.toLowerCase();return e.some(t=>r.endsWith(t))?[t]:e.map(e=>`${t}${e}`)}(e,n))if(await F(o.join(r,t)))return!0}}return!1}async function S(t,e){let r=x(t,e,"executable");if(r){if(!await F(r))throw new a("TOOL_MISSING",`${e} points to a missing or non-executable file: ${r}`,{envName:e,path:r});return r}}async function b(t,e){let r=x(t,e,"file");if(r){if(!await T(r))throw new a("TOOL_MISSING",`${e} points to a missing or non-file path: ${r}`,{envName:e,path:r});return r}}function E(t,e,r={}){let n=O(t),o=u(n,e,{cwd:r.cwd,env:r.env,stdio:["pipe","pipe","pipe"],encoding:r.binaryStdout?void 0:"utf8",input:r.stdin,timeout:P(r.timeoutMs),windowsHide:!0,shell:!1,...void 0!==r.maxBuffer?{maxBuffer:r.maxBuffer}:{}});if(o.error){let i=o.error.code;if("ETIMEDOUT"===i)throw new a("COMMAND_FAILED",`${n} timed out after ${P(r.timeoutMs)}ms`,{cmd:t,args:e,timeoutMs:P(r.timeoutMs)},o.error);if("ENOENT"===i)throw I(n,t,o.error);throw C(n,t,e,o.error)}let i=r.binaryStdout?Buffer.isBuffer(o.stdout)?o.stdout:Buffer.from(o.stdout??""):void 0,d=r.binaryStdout?"":"string"==typeof o.stdout?o.stdout:(o.stdout??"").toString(),s="string"==typeof o.stderr?o.stderr:(o.stderr??"").toString(),f=o.status??1;if(0!==f&&!r.allowFailure)throw $(n,t,e,f,d,s);return{stdout:d,stderr:s,exitCode:f,stdoutBuffer:i}}function g(t,e,r={}){return y(t,e,r).pid}function y(t,e,r={}){let n=i(O(t),e,{cwd:r.cwd,env:r.env,stdio:r.stdio??"ignore",detached:!0,windowsHide:!0,shell:!1}),o=n.pid??0,u=new Promise(t=>{n.once("error",e=>{t({pid:o,error:e.message})}),n.once("exit",(e,r)=>{t({pid:o,..."number"==typeof e?{exitCode:e}:{},...r?{signal:r}:{}})})});return n.unref(),{pid:o,exited:u}}function M(t,e,r={}){let n=O(t),o=i(n,e,{cwd:r.cwd,env:r.env,stdio:r.stdio??["ignore","pipe","pipe"],detached:r.detached,windowsHide:!0,shell:!1}),u="",d="",s=r.captureOutput??!0,a=B(o,r);s&&(o.stdout?.setEncoding("utf8"),o.stderr?.setEncoding("utf8"),o.stdout?.on("data",t=>{u+=t}),o.stderr?.on("data",t=>{d+=t}));let f=new Promise((i,s)=>{o.on("error",r=>{a.dispose(),s(L(a,n,t,e,r))}),o.on("close",o=>{a.dispose();let f=o??1,c=N(a,n,t,e,f,r.allowFailure,u,d);c?s(c):i({stdout:u,stderr:d,exitCode:f})})});return{child:o,wait:f}}function O(t){let e=D(t);if(!e)throw new a("INVALID_ARGS",`Invalid executable command: ${JSON.stringify(t)}`,{cmd:t,hint:"Use a bare command name from PATH or an absolute executable path."});return e}function I(t,e,r){return new a("TOOL_MISSING",`${t} not found in PATH`,{cmd:e},r)}function C(t,e,r,n){return new a("COMMAND_FAILED",`Failed to run ${t}`,{cmd:e,args:r},n)}function _(t,e,r){return new a("COMMAND_FAILED","request canceled",{cmd:e,args:r,executable:t,reason:"request_canceled"})}function $(t,e,r,n,o,i){return new a("COMMAND_FAILED",`${t} exited with code ${n}`,{cmd:e,args:r,stdout:o,stderr:i,exitCode:n,processExitError:!0})}function L(t,e,r,n,o){return t.didAbort?_(e,r,n):"ENOENT"===o.code?I(e,r,o):C(e,r,n,o)}function N(t,e,r,n,o,i,u,d){return t.didAbort?_(e,r,n):0===o||i?null:$(e,r,n,o,u,d)}function x(t,e,r){let n=t?.trim();if(n){if(!o.isAbsolute(n)||n.includes("\0"))throw new a("INVALID_ARGS",`${e} must be an absolute ${r} path, not ${JSON.stringify(t)}`,{envName:e,path:t});return n}}function D(t){let e=t.trim();return!e||e.includes("\0")?null:o.isAbsolute(e)?e:e.includes("/")||e.includes("\\")?null:f.test(e)?e:null}async function F(t){try{if(!await T(t))return!1;return await r(t,"win32"===process.platform?e.F_OK:e.X_OK),!0}catch{return!1}}async function T(t){try{return(await n(t)).isFile()}catch{return!1}}function P(t){if(!Number.isFinite(t))return;let e=Math.floor(t);if(!(e<=0))return e}function B(t,e){let r=!1,n=()=>{r=!0,H(t,e.detached)};return e.signal?.aborted?n():e.signal?.addEventListener("abort",n,{once:!0}),{get didAbort(){return r},dispose:()=>{e.signal?.removeEventListener("abort",n)}}}function H(t,e){if(e&&t.pid&&"win32"!==process.platform)try{process.kill(-t.pid,"SIGKILL");return}catch{}t.kill("SIGKILL")}async function G(t,e){if(t.stdin){if(void 0===e)return void t.stdin?.end();await s(d.from([e]),t.stdin)}}export{F as isExecutablePath,S as resolveExecutableOverridePath,b as resolveFileOverridePath,w as runCmd,M as runCmdBackground,g as runCmdDetached,y as runCmdDetachedMonitored,h as runCmdStreaming,E as runCmdSync,A as whichCmd,m as withCommandExecutorOverride,p as withoutCommandExecutorOverride};
1
+ import{AsyncLocalStorage as t}from"node:async_hooks";import{constants as e}from"node:fs";import{access as r,stat as n}from"node:fs/promises";import o from"node:path";import{spawn as i,spawnSync as u}from"node:child_process";import{Readable as d}from"node:stream";import{pipeline as s}from"node:stream/promises";import{AppError as a}from"./485.js";let f=/^[A-Za-z0-9][A-Za-z0-9._+-]*$/,c=[".com",".exe",".bat",".cmd"],l=new t;async function m(t,e){return t?await l.run(t,e):await e()}async function p(t){return await l.run(void 0,t)}async function w(t,e,r={}){let n=l.getStore()?.(t,e,r);return n?await n:await v(t,e,r)}async function h(t,e,r={}){let n=l.getStore()?.(t,e,r);return n?await n:await v(t,e,r)}function v(t,e,r={}){let n=O(t);return new Promise((o,u)=>{let d=i(n,e,{cwd:r.cwd,env:r.env,stdio:["pipe","pipe","pipe"],detached:r.detached,windowsHide:!0,shell:!1});r.onSpawn?.(d);let s="",f=r.binaryStdout?[]:void 0,c="",l=!1,m=P(r.timeoutMs),p=m?setTimeout(()=>{l=!0,H(d,r.detached)},m):null,w=B(d,r);r.binaryStdout||d.stdout.setEncoding("utf8"),d.stderr.setEncoding("utf8"),G(d,r.stdin).catch(o=>{var i,s,f,c;w.didAbort||l||(i=o)instanceof Error&&"code"in i&&"EPIPE"===i.code||(u((s=n,f=t,new a("COMMAND_FAILED",`Failed to write stdin for ${s}`,{cmd:f,args:e},(c=o)instanceof Error?c:void 0))),H(d,r.detached))}),d.stdout.on("data",t=>{if(r.binaryStdout)return void f?.push(Buffer.isBuffer(t)?t:Buffer.from(t));let e=String(t);s+=e,r.onStdoutChunk?.(e)}),d.stderr.on("data",t=>{let e=String(t);c+=e,r.onStderrChunk?.(e)}),d.on("error",r=>{p&&clearTimeout(p),w.dispose(),u(L(w,n,t,e,r))}),d.on("close",i=>{p&&clearTimeout(p),w.dispose();let d=i??1;if(!w.didAbort&&l&&m){var h,v,A,S,b,E;return void u((h=n,v=t,A=e,S=m,b=d,E=s,new a("COMMAND_FAILED",`${h} timed out after ${S}ms`,{cmd:v,args:A,stdout:E,stderr:c,exitCode:b,timeoutMs:S})))}let g=N(w,n,t,e,d,r.allowFailure,s,c);g?u(g):o({stdout:s,stderr:c,exitCode:d,stdoutBuffer:f?Buffer.concat(f):void 0})})})}async function A(t){let e=D(t);if(!e)return!1;if(o.isAbsolute(e))return F(e);let r=process.env.PATH;if(!r)return!1;let n=function(){if("win32"!==process.platform)return[""];let t=process.env.PATHEXT;if(!t)return c;let e=t.split(";").map(t=>t.trim().toLowerCase()).filter(t=>t.length>0);return e.length>0?e:c}();for(let t of r.split(o.delimiter)){let r=t.trim();if(r){for(let t of function(t,e){if("win32"!==process.platform)return[t];let r=t.toLowerCase();return e.some(t=>r.endsWith(t))?[t]:e.map(e=>`${t}${e}`)}(e,n))if(await F(o.join(r,t)))return!0}}return!1}async function S(t,e){let r=x(t,e,"executable");if(r){if(!await F(r))throw new a("TOOL_MISSING",`${e} points to a missing or non-executable file: ${r}`,{envName:e,path:r});return r}}async function b(t,e){let r=x(t,e,"file");if(r){if(!await T(r))throw new a("TOOL_MISSING",`${e} points to a missing or non-file path: ${r}`,{envName:e,path:r});return r}}function E(t,e,r={}){let n=O(t),o=u(n,e,{cwd:r.cwd,env:r.env,stdio:["pipe","pipe","pipe"],encoding:r.binaryStdout?void 0:"utf8",input:r.stdin,timeout:P(r.timeoutMs),windowsHide:!0,shell:!1,...void 0!==r.maxBuffer?{maxBuffer:r.maxBuffer}:{}});if(o.error){let i=o.error.code;if("ETIMEDOUT"===i)throw new a("COMMAND_FAILED",`${n} timed out after ${P(r.timeoutMs)}ms`,{cmd:t,args:e,timeoutMs:P(r.timeoutMs)},o.error);if("ENOENT"===i)throw I(n,t,o.error);throw C(n,t,e,o.error)}let i=r.binaryStdout?Buffer.isBuffer(o.stdout)?o.stdout:Buffer.from(o.stdout??""):void 0,d=r.binaryStdout?"":"string"==typeof o.stdout?o.stdout:(o.stdout??"").toString(),s="string"==typeof o.stderr?o.stderr:(o.stderr??"").toString(),f=o.status??1;if(0!==f&&!r.allowFailure)throw $(n,t,e,f,d,s);return{stdout:d,stderr:s,exitCode:f,stdoutBuffer:i}}function g(t,e,r={}){return y(t,e,r).pid}function y(t,e,r={}){let n=i(O(t),e,{cwd:r.cwd,env:r.env,stdio:r.stdio??"ignore",detached:!0,windowsHide:!0,shell:!1}),o=n.pid??0,u=new Promise(t=>{n.once("error",e=>{t({pid:o,error:e.message})}),n.once("exit",(e,r)=>{t({pid:o,..."number"==typeof e?{exitCode:e}:{},...r?{signal:r}:{}})})});return n.unref(),{pid:o,exited:u}}function M(t,e,r={}){let n=O(t),o=i(n,e,{cwd:r.cwd,env:r.env,stdio:r.stdio??["ignore","pipe","pipe"],detached:r.detached,windowsHide:!0,shell:!1}),u="",d="",s=r.captureOutput??!0,a=B(o,r);s&&(o.stdout?.setEncoding("utf8"),o.stderr?.setEncoding("utf8"),o.stdout?.on("data",t=>{u+=t}),o.stderr?.on("data",t=>{d+=t}));let f=new Promise((i,s)=>{o.on("error",r=>{a.dispose(),s(L(a,n,t,e,r))}),o.on("close",o=>{a.dispose();let f=o??1,c=N(a,n,t,e,f,r.allowFailure,u,d);c?s(c):i({stdout:u,stderr:d,exitCode:f})})});return{child:o,wait:f}}function O(t){let e=D(t);if(!e)throw new a("INVALID_ARGS",`Invalid executable command: ${JSON.stringify(t)}`,{cmd:t,hint:"Use a bare command name from PATH or an absolute executable path."});return e}function I(t,e,r){return new a("TOOL_MISSING",`${t} not found in PATH`,{cmd:e},r)}function C(t,e,r,n){return new a("COMMAND_FAILED",`Failed to run ${t}`,{cmd:e,args:r},n)}function _(t,e,r){return new a("COMMAND_FAILED","request canceled",{cmd:e,args:r,executable:t,reason:"request_canceled"})}function $(t,e,r,n,o,i){return new a("COMMAND_FAILED",`${t} exited with code ${n}`,{cmd:e,args:r,stdout:o,stderr:i,exitCode:n,processExitError:!0})}function L(t,e,r,n,o){return t.didAbort?_(e,r,n):"ENOENT"===o.code?I(e,r,o):C(e,r,n,o)}function N(t,e,r,n,o,i,u,d){return t.didAbort?_(e,r,n):0===o||i?null:$(e,r,n,o,u,d)}function x(t,e,r){let n=t?.trim();if(n){if(!o.isAbsolute(n)||n.includes("\0"))throw new a("INVALID_ARGS",`${e} must be an absolute ${r} path, not ${JSON.stringify(t)}`,{envName:e,path:t});return n}}function D(t){let e=t.trim();return!e||e.includes("\0")?null:o.isAbsolute(e)?e:e.includes("/")||e.includes("\\")?null:f.test(e)?e:null}async function F(t){try{if(!await T(t))return!1;return await r(t,"win32"===process.platform?e.F_OK:e.X_OK),!0}catch{return!1}}async function T(t){try{return(await n(t)).isFile()}catch{return!1}}function P(t){if(!Number.isFinite(t))return;let e=Math.floor(t);if(!(e<=0))return e}function B(t,e){let r=!1,n=()=>{r=!0,H(t,e.detached)};return e.signal?.aborted?n():e.signal?.addEventListener("abort",n,{once:!0}),{get didAbort(){return r},dispose:()=>{e.signal?.removeEventListener("abort",n)}}}function H(t,e){if(e&&t.pid&&"win32"!==process.platform)try{process.kill(-t.pid,"SIGKILL");return}catch{}t.kill("SIGKILL")}async function G(t,e){if(t.stdin){if(void 0===e)return void t.stdin?.end();await s(d.from([e]),t.stdin)}}export{F as isExecutablePath,S as resolveExecutableOverridePath,b as resolveFileOverridePath,w as runCmd,M as runCmdBackground,g as runCmdDetached,y as runCmdDetachedMonitored,h as runCmdStreaming,E as runCmdSync,A as whichCmd,m as withCommandExecutorOverride,p as withoutCommandExecutorOverride};
@@ -0,0 +1 @@
1
+ import{URL as t}from"node:url";import{AppError as r}from"./485.js";function o(o){if(!o)return;let i=e(o.metroHost),p=n(o.metroPort),l="http",u=e(o.bundleUrl);if(u){var m;let o;try{o=new t(u)}catch(t){throw new r("INVALID_ARGS",`Invalid runtime bundle URL: ${u}`,{},t)}("http:"===o.protocol||"https:"===o.protocol)&&(i??=e(o.hostname),p??=n(o.port.length>0?Number(o.port):"https:"===(m=o.protocol)?443:"http:"===m?80:void 0),l="https:"===o.protocol?"https":"http")}if(i&&p)return{host:i,port:p,scheme:l}}function e(t){let r=t?.trim();return r&&r.length>0?r:void 0}function n(t){if(Number.isInteger(t)&&!(t<=0)&&!(t>65535))return t}export{o as resolveRuntimeTransportHints,e as trimRuntimeValue};
@@ -0,0 +1 @@
1
+ import{runCmdSync as e}from"./8875.js";import{sleep as r}from"./5560.js";let t=[/(^|[/\s"'=])dist\/src\/daemon\.js($|[\s"'])/,/(^|[/\s"'=])dist\/src\/internal\/daemon\.js($|[\s"'])/,/(^|[/\s"'=])src\/daemon\.ts($|[\s"'])/];function n(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(e,0),!0}catch(e){return"EPERM"===e.code}}function i(e){if(!Number.isInteger(e)||e<=0)return!1;try{return process.kill(-e,0),!0}catch(e){return"EPERM"===e.code}}function s(r){if(!Number.isInteger(r)||r<=0)return null;try{let t=e("ps",["-p",String(r),"-o","lstart="],{allowFailure:!0,timeoutMs:1e3});if(0!==t.exitCode)return null;let n=t.stdout.trim();return n.length>0?n:null}catch{return null}}function o(r){if(!Number.isInteger(r)||r<=0)return null;try{let t=e("ps",["-p",String(r),"-o","command="],{allowFailure:!0,timeoutMs:1e3});if(0!==t.exitCode)return null;let n=t.stdout.trim();return n.length>0?n:null}catch{return null}}function u(e,r){let i;if(!n(e))return!1;if(r){let t=s(e);if(!t||t!==r)return!1}let u=o(e);return!!u&&!!(i=u.toLowerCase().replaceAll("\\","/")).includes("agent-device")&&t.some(e=>e.test(i))}function l(e,r){try{return process.kill(e,r),!0}catch(r){let e=r.code;if("ESRCH"===e||"EPERM"===e)return!1;throw r}}async function c(e,t){if(!n(e))return!0;let i=Date.now();for(;Date.now()-i<t;)if(await r(50),!n(e))return!0;return!n(e)}async function a(e,r){!u(e,r.expectedStartTime)||!l(e,"SIGTERM")||await c(e,r.termTimeoutMs)||l(e,"SIGKILL")&&await c(e,r.killTimeoutMs)}export{u as isAgentDeviceDaemonProcess,n as isProcessAlive,i as isProcessGroupAlive,o as readProcessCommand,s as readProcessStartTime,a as stopProcessForTakeover,c as waitForProcessExit};
package/dist/src/9581.js CHANGED
@@ -1,15 +1,15 @@
1
- import{COMMON_COMMAND_SUPPORTED_FLAG_KEYS as e,listCommandFamilyCliSchemas as t,METRO_PREPARE_FLAGS as o,listCommandMetadata as a}from"./2948.js";let s={cdp:{usageOverride:"cdp [...args]",listUsageOverride:"cdp",helpDescription:"Run CDP commands for React Native diagnostics, JS heap usage, heap snapshots, and leak analysis",summary:"Inspect React Native CDP targets, JS heap growth, heap snapshots, retainers, and leak signals",positionalArgs:["args?"],allowsExtraPositionals:!0,supportedFlags:e},auth:{usageOverride:"auth status|login|logout",listUsageOverride:"auth",helpDescription:"Manage cloud login state used by remote daemon and cloud device workflows.",summary:"Manage cloud login state used by remote daemon and cloud device workflows",positionalArgs:["status|login|logout"],supportedFlags:["remoteConfig","stateDir"]},connect:{usageOverride:"connect [--remote-config <path>] [--daemon-base-url <url>] [--tenant <id>] [--run-id <id>] [--lease-id <id>] [--lease-backend <backend>] [--force] [--no-login]",helpDescription:"Connect to a remote daemon, authenticate when needed, and save remote session state. AGENT_DEVICE_CLOUD_BASE_URL is the bridge/control-plane API origin; use AGENT_DEVICE_DAEMON_AUTH_TOKEN=adc_live_... for CI/service-token automation.",listUsageOverride:"connect",summary:"Attach CLI commands to a saved remote daemon/cloud lease; inspect for remote runs, tenants, or service-token CI",allowedFlags:["remoteConfig","daemonBaseUrl","tenant","runId","leaseId","leaseBackend","force","noLogin"],supportedFlags:["stateDir","daemonAuthToken","session","platform",...o,"launchUrl"]},connection:{usageOverride:"connection status",listUsageOverride:"connection",helpDescription:"Inspect active remote connection state",summary:"Inspect the active saved remote connection before assuming commands are local",positionalArgs:["status"],supportedFlags:["remoteConfig","stateDir","session"]},disconnect:{helpDescription:"Disconnect remote daemon state, stop owned Metro companion, and release lease",listUsageOverride:"disconnect",summary:"Clear remote connection state, stop owned Metro companions, and release remote leases",allowedFlags:["shutdown"],supportedFlags:["remoteConfig","stateDir","session"]},mcp:{helpDescription:"Start the official stdio MCP server. It exposes structured command tools backed by the agent-device client.",summary:"Start MCP server"},proxy:{usageOverride:"proxy [--host <host>] [--port <port>] [--daemon-auth-token <token>] [--state-dir <path>]",listUsageOverride:"proxy",helpDescription:`Expose the local daemon HTTP contract through a tunnel-friendly reverse proxy.
1
+ import{COMMON_COMMAND_SUPPORTED_FLAG_KEYS as e,listCommandFamilyCliSchemas as t,METRO_PREPARE_FLAGS as o,listCommandMetadata as a}from"./2948.js";let n={cdp:{usageOverride:"cdp [...args]",listUsageOverride:"cdp",helpDescription:"Run CDP commands for React Native diagnostics, JS heap usage, heap snapshots, and leak analysis",summary:"Inspect React Native CDP targets, JS heap growth, heap snapshots, retainers, and leak signals",positionalArgs:["args?"],allowsExtraPositionals:!0,supportedFlags:e},auth:{usageOverride:"auth status|login|logout",listUsageOverride:"auth",helpDescription:"Manage cloud login state used by remote daemon and cloud device workflows.",summary:"Manage cloud login state used by remote daemon and cloud device workflows",positionalArgs:["status|login|logout"],supportedFlags:["remoteConfig","stateDir"]},connect:{usageOverride:"connect [cloud|proxy|browserstack|aws-device-farm] [--remote-config <path>] [--daemon-base-url <url>] [--tenant <id>] [--run-id <id>] [--lease-id <id>] [--lease-backend <backend>] [--force] [--no-login]",helpDescription:"Connect to a remote daemon, authenticate when needed, and save remote session state. AGENT_DEVICE_CLOUD_BASE_URL is the bridge/control-plane API origin; use AGENT_DEVICE_DAEMON_AUTH_TOKEN=adc_live_... for CI/service-token automation.",listUsageOverride:"connect",summary:"Attach CLI commands to a saved remote daemon/cloud lease; inspect for remote runs, tenants, or service-token CI",allowedFlags:["remoteConfig","daemonBaseUrl","tenant","runId","leaseId","leaseBackend","providerApp","providerOsVersion","providerProject","providerBuild","providerSessionName","awsProjectArn","awsDeviceArn","awsAppArn","awsRegion","awsInteractionMode","force","noLogin"],supportedFlags:["stateDir","daemonAuthToken","session","platform","device",...o,"launchUrl"]},connection:{usageOverride:"connection status",listUsageOverride:"connection",helpDescription:"Inspect active remote connection state",summary:"Inspect the active saved remote connection before assuming commands are local",positionalArgs:["status"],supportedFlags:["remoteConfig","stateDir","session"]},disconnect:{helpDescription:"Disconnect remote daemon state, stop owned Metro companion, and release lease",listUsageOverride:"disconnect",summary:"Clear remote connection state, stop owned Metro companions, and release remote leases",allowedFlags:["shutdown"],supportedFlags:["remoteConfig","stateDir","session"]},mcp:{helpDescription:"Start the official stdio MCP server. It exposes structured command tools backed by the agent-device client.",summary:"Start MCP server"},proxy:{usageOverride:"proxy [--host <host>] [--port <port>] [--daemon-auth-token <token>] [--state-dir <path>]",listUsageOverride:"proxy",helpDescription:`Expose the local daemon HTTP contract through a tunnel-friendly reverse proxy.
2
2
 
3
- Run this on the host that has access to simulators/devices, then point another machine at the printed daemon base URL with --daemon-base-url or AGENT_DEVICE_DAEMON_BASE_URL.
3
+ Run this on the host that has access to simulators/devices, expose the printed local proxy URL through a tunnel, then point another machine at the tunnel URL with connect proxy.
4
4
 
5
- The proxy starts or reuses a local HTTP daemon, accepts /health, /rpc, /upload, and /artifacts/*, and also accepts the same routes under /agent-device/*. Health is unauthenticated for reachability probes. Other routes require the generated bearer token printed at startup, or the explicit --daemon-auth-token value when provided. The proxy rewrites authorized client requests to the upstream daemon token instead of exposing the local daemon token.
5
+ The proxy starts or reuses a local HTTP daemon, accepts /health, /rpc, /upload and resumable /upload/* routes, and /artifacts/*, and also accepts the same routes under /agent-device/*. Health is unauthenticated for reachability probes. Other routes require the generated bearer token printed at startup, or the explicit --daemon-auth-token value when provided. The proxy rewrites authorized client requests to the upstream daemon token instead of exposing the local daemon token.
6
6
 
7
7
  Use the /agent-device base path when connecting through cloudflared, ngrok, or another shared origin. Treat the bearer token as a secret; anyone with it can control the proxied daemon. This direct proxy flow does not use agent-device auth.
8
8
 
9
9
  Examples:
10
10
  agent-device proxy --port 4310
11
11
  cloudflared tunnel --url http://127.0.0.1:4310
12
- agent-device devices --daemon-base-url https://example.trycloudflare.com/agent-device --daemon-auth-token <token>`,summary:"Expose a local daemon through cloudflared, ngrok, or another HTTP tunnel",allowedFlags:["proxyHost","proxyPort","daemonAuthToken","stateDir"]},"react-devtools":{usageOverride:"react-devtools [...args]",listUsageOverride:"react-devtools",helpDescription:"Run pinned agent-react-devtools commands for React Native performance profiling, component trees, props/state/hooks, and render analysis",summary:"Inspect React Native components, props, hooks, errors, slow renders, and rerender profiles",positionalArgs:["args?"],allowsExtraPositionals:!0,supportedFlags:e},web:{usageOverride:"web setup | web doctor",listUsageOverride:"web setup|doctor",helpDescription:`Install and inspect the managed web automation backend used by --platform web.
12
+ agent-device connect proxy --daemon-base-url https://example.trycloudflare.com/agent-device --daemon-auth-token <token>`,summary:"Expose a local daemon through cloudflared, ngrok, or another HTTP tunnel",allowedFlags:["proxyHost","proxyPort","daemonAuthToken","stateDir"]},"react-devtools":{usageOverride:"react-devtools [...args]",listUsageOverride:"react-devtools",helpDescription:"Run pinned agent-react-devtools commands for React Native performance profiling, component trees, props/state/hooks, and render analysis",summary:"Inspect React Native components, props, hooks, errors, slow renders, and rerender profiles",positionalArgs:["args?"],allowsExtraPositionals:!0,supportedFlags:e},web:{usageOverride:"web setup | web doctor",listUsageOverride:"web setup|doctor",helpDescription:`Install and inspect the managed web automation backend used by --platform web.
13
13
 
14
14
  First-run flow:
15
15
  agent-device web setup
@@ -19,4 +19,4 @@ First-run flow:
19
19
 
20
20
  Runtime web commands do not install the backend implicitly. If the managed backend is missing, run agent-device web setup. The backend is resolved only from the managed install in the effective agent-device state dir.
21
21
 
22
- Use web setup to install or reuse the pinned backend. Use web doctor after setup to verify browser backend health.`,summary:"Manage web automation backend",positionalArgs:["setup|doctor"],supportedFlags:["stateDir"]}},n=t(),r=new Map(a().map(t=>[t.name,{helpDescription:t.description,supportedFlags:e}]));function i(e){if(e)return c(e)}function d(e){let t=c(e);if(!t)throw Error(`Missing command schema for ${e}`);return t}function c(e){let t=Object.hasOwn(s,e)?s[e]:void 0;if(t)return t;let o=r.get(e),a=Object.hasOwn(n,e)?n[e]:void 0;if(o)return a?{...o,...a}:o}function l(e,t){let o=i(e);if(!o?.defaults)return!1;let a=!1;for(let[e,s]of Object.entries(o.defaults))void 0===t[e]&&(t[e]=s,a=!0);return a}export{l as applyCommandDefaults,d as getCliCommandSchema,i as getCommandSchema};
22
+ Use web setup to install or reuse the pinned backend. Use web doctor after setup to verify browser backend health.`,summary:"Manage web automation backend",positionalArgs:["setup|doctor"],supportedFlags:["stateDir"]}},r=t(),s=new Map(a().map(t=>[t.name,{helpDescription:t.description,supportedFlags:e}]));function i(e){if(e)return c(e)}function d(e){let t=c(e);if(!t)throw Error(`Missing command schema for ${e}`);return t}function c(e){let t=Object.hasOwn(n,e)?n[e]:void 0;if(t)return t;let o=s.get(e),a=Object.hasOwn(r,e)?r[e]:void 0;if(o)return a?{...o,...a}:o}function l(e,t){let o=i(e);if(!o?.defaults)return!1;let a=!1;for(let[e,n]of Object.entries(o.defaults))void 0===t[e]&&(t[e]=n,a=!0);return a}export{l as applyCommandDefaults,d as getCliCommandSchema,i as getCommandSchema};
package/dist/src/9624.js CHANGED
@@ -1 +1 @@
1
- import{emitDiagnostic as e}from"./432.js";import{AppError as t}from"./733.js";import{isClipboardShellUnsupported as i}from"./3340.js";import{resolveAndroidAdbExecutor as n}from"./2954.js";import{sleep as r}from"./5560.js";let o=new Set(["com.google.android.inputmethod.latin","com.samsung.android.honeyboard","com.touchtype.swiftkey","com.microsoft.swiftkey"]);function a(e){let t=u(e.packageName),i=(e.resourceId??"").toLowerCase(),n=u(e.activeInputMethodPackage);if(t&&n&&t===n)return{inputMethodOwned:!0,source:"active-input-method"};if(n&&i.startsWith(`${n}:id/`))return{inputMethodOwned:!0,source:"active-input-method-resource"};if(t&&o.has(t))return{inputMethodOwned:!0,source:"known-ime-package"};for(let e of o)if(i.startsWith(`${e}:id/`))return{inputMethodOwned:!0,source:"known-ime-resource"};return{inputMethodOwned:!1,source:"app"}}function d(e){return a(e).inputMethodOwned}function u(e){return(e??"").trim().toLowerCase()||void 0}let s=["mInputShown","mIsInputViewShown","isInputViewShown","mDecorViewVisible","mWindowVisible","mInShowWindow"],c=new Map([[2,"number"],[3,"phone"],[4,"datetime"]]),l=new Set([32,208]),p=new Set([128,224,144]);async function w(e){return await f(n(e))}async function f(i){var n,r,d;let w,f,m,h,_,I,y,C,g=await i(["shell","dumpsys","input_method"],{allowFailure:!0});if(0!==g.exitCode)throw new t("COMMAND_FAILED","Failed to query Android keyboard state",{stdout:g.stdout,stderr:g.stderr,exitCode:g.exitCode});return f=function(e){var t=function(e,t){let i=new Map,n=RegExp(`\\b(${t.join("|")})=([a-zA-Z]+)\\b`,"g");for(let t of e.matchAll(n)){let e=t[1],n=t[2]?.toLowerCase();e&&("true"===n||"false"===n)&&i.set(e,"true"===n)}return i}(e,s);if(0===t.size)return null;let i=A(t,["mWindowVisible","mDecorViewVisible","mInShowWindow"]);if(void 0!==i)return i;let n=t.get("mInputShown");return void 0!==n?n:A(t,["mIsInputViewShown","isInputViewShown"])??null}(n=g.stdout)??function(e){let t=e.match(/\bmImeWindowVis=0x([0-9a-fA-F]+)\b/),i=t?.[1];if(!i)return null;let n=Number.parseInt(i,16);return Number.isNaN(n)?null:(1&n)!=0}(n),m=(w=b(n,/\binputType=0x([0-9a-fA-F]+)\b/gi))?`0x${w.toLowerCase()}`:void 0,h=b(n,/\bpackageName=([A-Za-z0-9_.]+)\b/g),_=b(n,/\b(?:resourceId|resource-id)=([^\s,}]+)/g),y=function(e,t,i){return e||t?a({packageName:e,resourceId:t,activeInputMethodPackage:i}).inputMethodOwned?"ime":"app":"unknown"}(h,_,I=function(e){for(let t of[/\bmCurMethodId=([^\s]+)/i,/\bmCurId=([^\s]+)/i,/\bmCurrentInputMethodId=([^\s]+)/i,/\bcurMethodId=([^\s]+)/i]){let i=e.match(t),n=function(e){let t=(e??"").trim();if(!t)return;let i=(t.split("/")[0]??"").match(/[a-zA-Z0-9_.]+/);return u(i?.[0])}(i?.[1]);if(n)return n}}(n)),r=h,d=_,!I&&((C=u(r))&&o.has(C)||function(e){let t=(e??"").toLowerCase();for(let e of o)if(t.startsWith(`${e}:id/`))return!0;return!1}(d))&&e({level:"warn",phase:"android_input_ownership_fallback",data:{focusedPackage:r,focusedResourceId:d}}),{visible:f??!1,inputType:m,type:m?function(e){let t=Number.parseInt(e.replace(/^0x/i,""),16);if(Number.isNaN(t))return"unknown";let i=15&t,n=c.get(i);if(n)return n;if(1!==i)return"unknown";let r=4080&t;return l.has(r)?"email":p.has(r)?"password":"text"}(m):void 0,inputMethodPackage:I,focusedPackage:h,focusedResourceId:_,inputOwner:y}}async function m(e){return await h(n(e))}async function h(e){let i=await f(e),n=i,o=0;for(;n.visible&&o<2;)await e(["shell","input","keyevent","111"]),o+=1,await r(120),n=await f(e);if(i.visible&&n.visible)throw new t("UNSUPPORTED_OPERATION","Android keyboard dismiss is unavailable for the current IME without back navigation.",{attempts:o,inputType:n.inputType,type:n.type,inputMethodPackage:n.inputMethodPackage,focusedPackage:n.focusedPackage,focusedResourceId:n.focusedResourceId,inputOwner:n.inputOwner});return{attempts:o,wasVisible:i.visible,dismissed:i.visible&&!n.visible,visible:n.visible,inputType:n.inputType,type:n.type,inputMethodPackage:n.inputMethodPackage,focusedPackage:n.focusedPackage,focusedResourceId:n.focusedResourceId,inputOwner:n.inputOwner}}function b(e,t){let i;for(let n of e.matchAll(t))i=n[1];return i}function A(e,t){for(let i of t){let t=e.get(i);if(void 0!==t)return t}}async function _(e){return await I(n(e))}async function I(e){let t,i;return(i=(t=(await g(e,["shell","cmd","clipboard","get","text"],"read")).replace(/\r\n/g,"\n").replace(/\n$/,"")).match(/^clipboard text:\s*(.*)$/i))?i[1]??"":"null"===t.trim().toLowerCase()?"":t}async function y(e,t){await C(n(e),t)}async function C(e,t){await g(e,["shell","cmd","clipboard","set","text",t],"write")}async function g(e,n,r){let o=await e(n,{allowFailure:!0});if(i(o.stdout,o.stderr))throw new t("UNSUPPORTED_OPERATION",`Android shell clipboard ${r} is not supported on this device.`);if(0!==o.exitCode)throw new t("COMMAND_FAILED",`Failed to ${r} Android clipboard text`,{stdout:o.stdout,stderr:o.stderr,exitCode:o.exitCode});return o.stdout}export{m as dismissAndroidKeyboard,h as dismissAndroidKeyboardWithAdb,w as getAndroidKeyboardState,f as getAndroidKeyboardStatusWithAdb,d as isAndroidInputMethodOwnedNode,_ as readAndroidClipboardText,I as readAndroidClipboardWithAdb,y as writeAndroidClipboardText,C as writeAndroidClipboardWithAdb};
1
+ import{emitDiagnostic as e}from"./432.js";import{AppError as t}from"./485.js";import{isClipboardShellUnsupported as i,resolveAndroidAdbExecutor as n}from"./3340.js";import{sleep as r}from"./5560.js";let o=new Set(["com.google.android.inputmethod.latin","com.samsung.android.honeyboard","com.touchtype.swiftkey","com.microsoft.swiftkey"]);function a(e){let t=u(e.packageName),i=(e.resourceId??"").toLowerCase(),n=u(e.activeInputMethodPackage);if(t&&n&&t===n)return{inputMethodOwned:!0,source:"active-input-method"};if(n&&i.startsWith(`${n}:id/`))return{inputMethodOwned:!0,source:"active-input-method-resource"};if(t&&o.has(t))return{inputMethodOwned:!0,source:"known-ime-package"};for(let e of o)if(i.startsWith(`${e}:id/`))return{inputMethodOwned:!0,source:"known-ime-resource"};return{inputMethodOwned:!1,source:"app"}}function d(e){return a(e).inputMethodOwned}function u(e){return(e??"").trim().toLowerCase()||void 0}let s=["mInputShown","mIsInputViewShown","isInputViewShown","mDecorViewVisible","mWindowVisible","mInShowWindow"],c=new Map([[2,"number"],[3,"phone"],[4,"datetime"]]),l=new Set([32,208]),p=new Set([128,224,144]);async function w(e){return await f(n(e))}async function f(i){var n,r,d;let w,f,h,m,I,y,g,_,C=await i(["shell","dumpsys","input_method"],{allowFailure:!0});if(0!==C.exitCode)throw new t("COMMAND_FAILED","Failed to query Android keyboard state",{stdout:C.stdout,stderr:C.stderr,exitCode:C.exitCode});return f=function(e){var t=function(e,t){let i=new Map,n=RegExp(`\\b(${t.join("|")})=([a-zA-Z]+)\\b`,"g");for(let t of e.matchAll(n)){let e=t[1],n=t[2]?.toLowerCase();e&&("true"===n||"false"===n)&&i.set(e,"true"===n)}return i}(e,s);if(0===t.size)return null;let i=A(t,["mWindowVisible","mDecorViewVisible","mInShowWindow"]);if(void 0!==i)return i;let n=t.get("mInputShown");return void 0!==n?n:A(t,["mIsInputViewShown","isInputViewShown"])??null}(n=C.stdout)??function(e){let t=e.match(/\bmImeWindowVis=0x([0-9a-fA-F]+)\b/),i=t?.[1];if(!i)return null;let n=Number.parseInt(i,16);return Number.isNaN(n)?null:(1&n)!=0}(n),h=(w=b(n,/\binputType=0x([0-9a-fA-F]+)\b/gi))?`0x${w.toLowerCase()}`:void 0,m=b(n,/\bpackageName=([A-Za-z0-9_.]+)\b/g),I=b(n,/\b(?:resourceId|resource-id)=([^\s,}]+)/g),g=function(e,t,i){return e||t?a({packageName:e,resourceId:t,activeInputMethodPackage:i}).inputMethodOwned?"ime":"app":"unknown"}(m,I,y=function(e){for(let t of[/\bmCurMethodId=([^\s]+)/i,/\bmCurId=([^\s]+)/i,/\bmCurrentInputMethodId=([^\s]+)/i,/\bcurMethodId=([^\s]+)/i]){let i=e.match(t),n=function(e){let t=(e??"").trim();if(!t)return;let i=(t.split("/")[0]??"").match(/[a-zA-Z0-9_.]+/);return u(i?.[0])}(i?.[1]);if(n)return n}}(n)),r=m,d=I,!y&&((_=u(r))&&o.has(_)||function(e){let t=(e??"").toLowerCase();for(let e of o)if(t.startsWith(`${e}:id/`))return!0;return!1}(d))&&e({level:"warn",phase:"android_input_ownership_fallback",data:{focusedPackage:r,focusedResourceId:d}}),{visible:f??!1,inputType:h,type:h?function(e){let t=Number.parseInt(e.replace(/^0x/i,""),16);if(Number.isNaN(t))return"unknown";let i=15&t,n=c.get(i);if(n)return n;if(1!==i)return"unknown";let r=4080&t;return l.has(r)?"email":p.has(r)?"password":"text"}(h):void 0,inputMethodPackage:y,focusedPackage:m,focusedResourceId:I,inputOwner:g}}async function h(e){return await m(n(e))}async function m(e){let i=await f(e),n=i,o=0;for(;n.visible&&o<2;)await e(["shell","input","keyevent","111"]),o+=1,await r(120),n=await f(e);if(i.visible&&n.visible)throw new t("UNSUPPORTED_OPERATION","Android keyboard dismiss is unavailable for the current IME without back navigation.",{attempts:o,inputType:n.inputType,type:n.type,inputMethodPackage:n.inputMethodPackage,focusedPackage:n.focusedPackage,focusedResourceId:n.focusedResourceId,inputOwner:n.inputOwner});return{attempts:o,wasVisible:i.visible,dismissed:i.visible&&!n.visible,visible:n.visible,inputType:n.inputType,type:n.type,inputMethodPackage:n.inputMethodPackage,focusedPackage:n.focusedPackage,focusedResourceId:n.focusedResourceId,inputOwner:n.inputOwner}}function b(e,t){let i;for(let n of e.matchAll(t))i=n[1];return i}function A(e,t){for(let i of t){let t=e.get(i);if(void 0!==t)return t}}async function I(e){return await y(n(e))}async function y(e){let t,i;return(i=(t=(await C(e,["shell","cmd","clipboard","get","text"],"read")).replace(/\r\n/g,"\n").replace(/\n$/,"")).match(/^clipboard text:\s*(.*)$/i))?i[1]??"":"null"===t.trim().toLowerCase()?"":t}async function g(e,t){await _(n(e),t)}async function _(e,t){await C(e,["shell","cmd","clipboard","set","text",t],"write")}async function C(e,n,r){let o=await e(n,{allowFailure:!0});if(i(o.stdout,o.stderr))throw new t("UNSUPPORTED_OPERATION",`Android shell clipboard ${r} is not supported on this device.`);if(0!==o.exitCode)throw new t("COMMAND_FAILED",`Failed to ${r} Android clipboard text`,{stdout:o.stdout,stderr:o.stderr,exitCode:o.exitCode});return o.stdout}export{h as dismissAndroidKeyboard,m as dismissAndroidKeyboardWithAdb,w as getAndroidKeyboardState,f as getAndroidKeyboardStatusWithAdb,d as isAndroidInputMethodOwnedNode,I as readAndroidClipboardText,y as readAndroidClipboardWithAdb,g as writeAndroidClipboardText,_ as writeAndroidClipboardWithAdb};