sootsim 0.1.185 → 0.1.186

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 (157) hide show
  1. package/dist-cli/bin.js +3 -3
  2. package/dist-cli/chunks/{agent-VF756RZU.js → agent-HOCS7BA7.js} +2 -2
  3. package/dist-cli/chunks/{agent-wrapper-IAFL7ROV.js → agent-wrapper-OFIKO65K.js} +2 -2
  4. package/dist-cli/chunks/{app-fonts-VWLEC7ZA.js → app-fonts-PXVMBZZ7.js} +2 -2
  5. package/dist-cli/chunks/{assert-I55QVGG7.js → assert-OZS6AXZE.js} +2 -2
  6. package/dist-cli/chunks/beta-LUMNYREE.js +2 -0
  7. package/dist-cli/chunks/{camera-CYYBJH7W.js → camera-QJ2PKIJB.js} +2 -2
  8. package/dist-cli/chunks/{chunk-2T73IGB2.js → chunk-2B2D2EBR.js} +2 -2
  9. package/dist-cli/chunks/{chunk-ARNLQPMQ.js → chunk-353E6UCU.js} +2 -2
  10. package/dist-cli/chunks/chunk-3ISH4ZRW.js +1 -0
  11. package/dist-cli/chunks/{chunk-PIUKLO3W.js → chunk-4HVMPXJZ.js} +1 -1
  12. package/dist-cli/chunks/chunk-5TTEOJ4A.js +1 -0
  13. package/dist-cli/chunks/chunk-5XIRXMOS.js +971 -0
  14. package/dist-cli/chunks/chunk-6MJVRIUP.js +118 -0
  15. package/dist-cli/chunks/{chunk-EXFB33AZ.js → chunk-6OQVIQY7.js} +2 -2
  16. package/dist-cli/chunks/chunk-BU5CRHHR.js +24 -0
  17. package/dist-cli/chunks/{chunk-TUF6EPCQ.js → chunk-DPXVA7ZF.js} +2 -2
  18. package/dist-cli/chunks/{chunk-R4KLD4P4.js → chunk-FN64EREO.js} +2 -2
  19. package/dist-cli/chunks/{chunk-BI56RR3G.js → chunk-FUHNIWFL.js} +4 -4
  20. package/dist-cli/chunks/{chunk-WEJKLJ4B.js → chunk-GNGEYMS3.js} +2 -2
  21. package/dist-cli/chunks/{chunk-QTFCJYBF.js → chunk-I65LTDPY.js} +3 -3
  22. package/dist-cli/chunks/{chunk-BMCBPMTC.js → chunk-INIASYOZ.js} +1 -1
  23. package/dist-cli/chunks/{chunk-FUHXL6BW.js → chunk-KNICGV7H.js} +1 -1
  24. package/dist-cli/chunks/{chunk-E5DE33BU.js → chunk-LV7DFIBL.js} +1 -1
  25. package/dist-cli/chunks/{chunk-M3P67TBN.js → chunk-MAGDSBXT.js} +1 -1
  26. package/dist-cli/chunks/chunk-MP4CRGWM.js +2 -0
  27. package/dist-cli/chunks/{chunk-MADEJDFD.js → chunk-MPUCQL3Q.js} +1 -1
  28. package/dist-cli/chunks/{chunk-FY6DJGOS.js → chunk-N3PLEUYD.js} +39 -15
  29. package/dist-cli/chunks/{chunk-CYBRFHPU.js → chunk-NYYP5QQK.js} +2 -2
  30. package/dist-cli/chunks/{chunk-4OUQAR34.js → chunk-O2SQQXUO.js} +1 -1
  31. package/dist-cli/chunks/{chunk-K2THZIVC.js → chunk-OMFESSKA.js} +1 -1
  32. package/dist-cli/chunks/{chunk-C3UEINOZ.js → chunk-P5UT637B.js} +2 -2
  33. package/dist-cli/chunks/{chunk-C63EVPDN.js → chunk-POOE26UD.js} +2 -2
  34. package/dist-cli/chunks/{chunk-HQG4DRQ3.js → chunk-PTUTIFWJ.js} +1 -1
  35. package/dist-cli/chunks/{chunk-IJP257WP.js → chunk-QBLTH2F6.js} +1 -1
  36. package/dist-cli/chunks/{chunk-LJ3SOZBF.js → chunk-RAY2ZSNI.js} +2 -2
  37. package/dist-cli/chunks/{chunk-DZLBZGHN.js → chunk-RDM3LVH2.js} +2 -2
  38. package/dist-cli/chunks/chunk-RP5CVR6O.js +382 -0
  39. package/dist-cli/chunks/{chunk-PKZNXDUJ.js → chunk-TYV3FMBE.js} +2 -2
  40. package/dist-cli/chunks/{chunk-4NUQVW5P.js → chunk-U3BTJLRM.js} +17 -6
  41. package/dist-cli/chunks/{chunk-QQ4NSPAD.js → chunk-UATE6GSA.js} +2 -2
  42. package/dist-cli/chunks/chunk-V434ATFM.js +13 -0
  43. package/dist-cli/chunks/{chunk-GX6MKIFC.js → chunk-VGAD3CMW.js} +1 -1
  44. package/dist-cli/chunks/{chunk-LI4RLX6B.js → chunk-VPUJQTEO.js} +1 -1
  45. package/dist-cli/chunks/chunk-WBPTJ3WC.js +5 -0
  46. package/dist-cli/chunks/{chunk-NL5IFN4T.js → chunk-WFSLSEGX.js} +2 -2
  47. package/dist-cli/chunks/{chunk-TFZO277G.js → chunk-XFQOFRYY.js} +1 -1
  48. package/dist-cli/chunks/{chunk-TNHF6BON.js → chunk-XQ6PPMM6.js} +1 -1
  49. package/dist-cli/chunks/{chunk-FHJTTB3W.js → chunk-YYZGAZQI.js} +2 -2
  50. package/dist-cli/chunks/{chunk-WBY4JJ2K.js → chunk-ZE2O7AA5.js} +2 -2
  51. package/dist-cli/chunks/{chunk-X4KS33ZC.js → chunk-ZJ64K2PL.js} +2 -2
  52. package/dist-cli/chunks/cli-version-474OBNTF.js +2 -0
  53. package/dist-cli/chunks/{compat-ZJA3N4ZT.js → compat-BNXJOVMU.js} +3 -3
  54. package/dist-cli/chunks/control-6LPRGKTF.js +2 -0
  55. package/dist-cli/chunks/{cpu-profile-ACSQMVXY.js → cpu-profile-3KXOGOJP.js} +2 -2
  56. package/dist-cli/chunks/daemon-OMT3RVU4.js +2 -0
  57. package/dist-cli/chunks/{debug-W2ZOVTQO.js → debug-B3MN6772.js} +11 -10
  58. package/dist-cli/chunks/{detox-ANJO6T27.js → detox-YKSX4DUO.js} +2 -2
  59. package/dist-cli/chunks/{device-KPPN4KYD.js → device-NZX6AKQI.js} +2 -2
  60. package/dist-cli/chunks/{diagnose-5PEJYGES.js → diagnose-26HE6KS5.js} +2 -2
  61. package/dist-cli/chunks/drivers-2PZC4QA3.js +2 -0
  62. package/dist-cli/chunks/{electron-U456QLSQ.js → electron-XEUWIM47.js} +3 -3
  63. package/dist-cli/chunks/flow-P22NDT6V.js +2 -0
  64. package/dist-cli/chunks/help-ECGL4JSP.js +2 -0
  65. package/dist-cli/chunks/{hints-MBBQLMQU.js → hints-C56M4PMW.js} +2 -2
  66. package/dist-cli/chunks/{home-paths-KQKYP2SE.js → home-paths-EYH3RBPS.js} +2 -2
  67. package/dist-cli/chunks/inspect-LJYG4WC6.js +2 -0
  68. package/dist-cli/chunks/{install-desktop-OR6ZJ43X.js → install-desktop-UWHLWFKB.js} +3 -3
  69. package/dist-cli/chunks/{keys-JSQMBUE7.js → keys-Q37NM52E.js} +2 -2
  70. package/dist-cli/chunks/{login-DVMWAI3G.js → login-6E6ZEJRF.js} +4 -4
  71. package/dist-cli/chunks/{logout-RIVPFE5N.js → logout-A7QHH6DQ.js} +2 -2
  72. package/dist-cli/chunks/{maestro-TX6FPTVH.js → maestro-YJRGFGDQ.js} +2 -2
  73. package/dist-cli/chunks/optional-demo-registry-OVWOHGTW.js +2 -0
  74. package/dist-cli/chunks/{preview-3AD7WNA6.js → preview-3OYFVL4A.js} +2 -2
  75. package/dist-cli/chunks/{profile-HY55VFNR.js → profile-5Z2YGBCJ.js} +2 -2
  76. package/dist-cli/chunks/{react-HDRCKCKV.js → react-ZNFFE3VQ.js} +2 -2
  77. package/dist-cli/chunks/{record-HW4C7QYN.js → record-V4CBW3GG.js} +2 -2
  78. package/dist-cli/chunks/runtime-OC6S2C22.js +2 -0
  79. package/dist-cli/chunks/{screenshot-XFR3QN5T.js → screenshot-QWMRWTIQ.js} +2 -2
  80. package/dist-cli/chunks/{screenshot-mode-Y5CVO267.js → screenshot-mode-36EUFBF5.js} +2 -2
  81. package/dist-cli/chunks/{screenshots-RKUL2ZZT.js → screenshots-LOS6WHZN.js} +2 -2
  82. package/dist-cli/chunks/{screenshots-capture-RVNF75ZD.js → screenshots-capture-6D6TBI6A.js} +2 -2
  83. package/dist-cli/chunks/{serve-QMRYLWL5.js → serve-YWGZ2JSI.js} +16 -16
  84. package/dist-cli/chunks/{setup-ELNJS7AI.js → setup-JS35KZ6P.js} +3 -3
  85. package/dist-cli/chunks/{skills-GPSJYS4W.js → skills-2TRDAXNC.js} +2 -2
  86. package/dist-cli/chunks/{slides-OCFNPIFG.js → slides-AO5MBP5Q.js} +2 -2
  87. package/dist-cli/chunks/store-HQKPCA6W.js +2 -0
  88. package/dist-cli/chunks/telemetry-I2H25VVF.js +2 -0
  89. package/dist-cli/chunks/{telemetry-KFZQUFG5.js → telemetry-MBWJUKBU.js} +2 -2
  90. package/dist-cli/chunks/{test-Z2HZXCZM.js → test-TRP2O6AP.js} +3 -3
  91. package/dist-cli/chunks/{three-mode-NKJFCDYS.js → three-mode-VVNOGAZT.js} +2 -2
  92. package/dist-cli/chunks/{timeline-PRGQMQRR.js → timeline-4WDFXUXB.js} +2 -2
  93. package/dist-cli/chunks/{upgrade-3NW7JRRX.js → upgrade-NHQRFD4J.js} +2 -2
  94. package/dist-cli/chunks/upload-6C2EC56N.js +2 -0
  95. package/dist-cli/chunks/{version-FDTZRIYT.js → version-T7O46MZL.js} +2 -2
  96. package/dist-cli/chunks/{web-4N5QQEQJ.js → web-7YW2ISLF.js} +2 -2
  97. package/dist-cli/chunks/{what-happened-IX2RRCOS.js → what-happened-IDOUXSFI.js} +2 -2
  98. package/dist-cli/chunks/{whoami-QZ42FYYF.js → whoami-DQBR3UTO.js} +2 -2
  99. package/dist-lib/agent-daemon-client.cjs +1 -1
  100. package/dist-lib/agent-events.cjs +1 -1
  101. package/dist-lib/agent-sessions.cjs +1 -1
  102. package/dist-lib/attached-projects.cjs +1 -1
  103. package/dist-lib/auth/shared-session.cjs +1 -1
  104. package/dist-lib/backend-origin.cjs +1 -1
  105. package/dist-lib/beta.cjs +1 -1
  106. package/dist-lib/beta.mjs +1 -1
  107. package/dist-lib/bridge-constants.cjs +1 -1
  108. package/dist-lib/cli-constants.cjs +1 -1
  109. package/dist-lib/config.cjs +1 -1
  110. package/dist-lib/detox/index.cjs +1 -1
  111. package/dist-lib/dev-bundle-resolution.cjs +1 -1
  112. package/dist-lib/home-paths.cjs +2 -2
  113. package/dist-lib/host/bridge-host.cjs +77 -44
  114. package/dist-lib/host/fetch-proxy-handler.cjs +1 -1
  115. package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
  116. package/dist-lib/host/fetch-proxy-overrides.mjs +1 -1
  117. package/dist-lib/host/websocket-proxy.cjs +1 -1
  118. package/dist-lib/index.cjs +28 -1
  119. package/dist-lib/jump-to-source-babel.cjs +1 -1
  120. package/dist-lib/menu.cjs +1 -1
  121. package/dist-lib/menu.mjs +1 -1
  122. package/dist-lib/metro.cjs +28 -1
  123. package/dist-lib/profiles.cjs +1 -1
  124. package/dist-lib/render-mode.cjs +1 -1
  125. package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
  126. package/dist-lib/sdk.cjs +38 -10
  127. package/dist-lib/sdk.mjs +38 -10
  128. package/dist-lib/skills.cjs +283 -254
  129. package/dist-lib/vite.cjs +28 -1
  130. package/package.json +1 -1
  131. package/src/home-paths.ts +8 -1
  132. package/src/host/bridge-host.ts +15 -1
  133. package/src/runtime-assets.ts +70 -0
  134. package/src/vite-plugin.ts +9 -0
  135. package/dist-cli/chunks/beta-X6YPQVZH.js +0 -2
  136. package/dist-cli/chunks/chunk-7OAUPGLN.js +0 -23
  137. package/dist-cli/chunks/chunk-IGJHME3T.js +0 -1
  138. package/dist-cli/chunks/chunk-JRL7PFNZ.js +0 -463
  139. package/dist-cli/chunks/chunk-KOKIECMB.js +0 -118
  140. package/dist-cli/chunks/chunk-OAHGYDJR.js +0 -13
  141. package/dist-cli/chunks/chunk-PDLQWZN4.js +0 -2
  142. package/dist-cli/chunks/chunk-SL6565MR.js +0 -1
  143. package/dist-cli/chunks/chunk-V4M2R6FZ.js +0 -2
  144. package/dist-cli/chunks/chunk-V5JEPE3P.js +0 -5
  145. package/dist-cli/chunks/chunk-XU5EMZ4B.js +0 -264
  146. package/dist-cli/chunks/cli-version-ICHQMND6.js +0 -2
  147. package/dist-cli/chunks/control-CZFSYSYG.js +0 -2
  148. package/dist-cli/chunks/daemon-337B4P3B.js +0 -2
  149. package/dist-cli/chunks/drivers-MSDIFHBD.js +0 -2
  150. package/dist-cli/chunks/flow-JL3SC6HC.js +0 -2
  151. package/dist-cli/chunks/help-PA4RTR5X.js +0 -2
  152. package/dist-cli/chunks/inspect-ZP5SM4EW.js +0 -987
  153. package/dist-cli/chunks/optional-demo-registry-ONYG6DUI.js +0 -2
  154. package/dist-cli/chunks/runtime-RHHPW5WO.js +0 -2
  155. package/dist-cli/chunks/store-MBKDUQEQ.js +0 -2
  156. package/dist-cli/chunks/telemetry-46XXIUEE.js +0 -2
  157. package/dist-cli/chunks/upload-QVDVJ6ZK.js +0 -2
@@ -0,0 +1,382 @@
1
+ /*! sootsim v0.1.186 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as Ue}from"./chunk-2B2D2EBR.js";import{a as He}from"./chunk-UATE6GSA.js";import{a as Je}from"./chunk-353E6UCU.js";import{a as oe,b as je,c as se,d as ae,e as Le,f as le,g as de,h as Ve,i as ce,j as We}from"./chunk-5XIRXMOS.js";import{h as De,p as Ce,r as Ne,v as Be}from"./chunk-V434ATFM.js";import{f as Ee}from"./chunk-WBPTJ3WC.js";import{h as Re,m as Oe}from"./chunk-YYZGAZQI.js";import{I as ne,m as $e,n as Fe,o as Pe,p as Ae}from"./chunk-N3PLEUYD.js";import{a as ke}from"./chunk-OMFESSKA.js";import{g as ie,h as re,i as Me}from"./chunk-BU5CRHHR.js";import{a as _e}from"./chunk-INIASYOZ.js";import{a as xe,b as ee}from"./chunk-POOE26UD.js";import{d as te,e as Ie}from"./chunk-LV7DFIBL.js";import{g as Te}from"./chunk-KNICGV7H.js";import*as O from"fs";import{tmpdir as ze}from"os";import*as b from"path";import*as v from"fs";import*as g from"path";import{spawnSync as st}from"child_process";import*as M from"vm";var at=3e5,lt=`
3
+ let input = '';
4
+ process.stdin.on('data', (c) => { input += c });
5
+ process.stdin.on('end', async () => {
6
+ try {
7
+ const req = JSON.parse(input);
8
+ const res = await fetch(req.url, {
9
+ method: req.method,
10
+ headers: req.headers,
11
+ body: req.body === undefined || req.body === null ? undefined : req.body,
12
+ });
13
+ const body = await res.text();
14
+ const headers = {};
15
+ for (const [k, v] of res.headers.entries()) {
16
+ headers[k] = headers[k] ? headers[k] + ',' + v : v;
17
+ }
18
+ process.stdout.write(JSON.stringify({ ok: res.ok, status: res.status, body, headers }));
19
+ } catch (err) {
20
+ process.stdout.write(JSON.stringify({ __error: (err && err.message) || String(err) }));
21
+ process.exitCode = 1;
22
+ }
23
+ });
24
+ `;function N(o,e,t){if(t?.multipartForm)throw new Error("http: multipartForm is not supported by sootsim yet");let n={...process.env};for(let a of Object.keys(n))(a.startsWith("BUN_INSPECT")||a==="NODE_OPTIONS")&&delete n[a];let i=st(process.execPath,["-e",lt],{input:JSON.stringify({url:o,method:e,headers:t?.headers,body:t?.body}),encoding:"utf8",timeout:at,maxBuffer:64*1024*1024,env:n});if(i.error)throw new Error(`http ${e} ${o} failed: ${i.error.message}`);let r;try{r=JSON.parse(i.stdout||"")}catch{throw new Error(`http ${e} ${o} failed: no response (${(i.stderr||"").trim().slice(0,200)})`)}let s=r;if(s.__error)throw new Error(`http ${e} ${o} failed: ${s.__error}`);return s}var dt=/(?<!\\)\$\{([^$]*)\}/g,ct=/\\(\$\{[^$]*\})/g,ut=/^[A-Za-z_$][A-Za-z0-9_$]*$/,H=class{context;envBinding=new Map;envScopeStack=[];syncedEnvKeys=new Set;output={};maestro;constructor(e={}){this.maestro={copiedText:null,platform:e.platform??"ios"};let t=e.onLog??(i=>console.log(`[flow] js: ${i}`)),n={output:this.output,maestro:this.maestro,http:{get:(i,r)=>N(i,"GET",r),post:(i,r)=>N(i,"POST",r),put:(i,r)=>N(i,"PUT",r),delete:(i,r)=>N(i,"DELETE",r),request:(i,r)=>N(i,(r?.method??"GET").toUpperCase(),r)},console:{log:(...i)=>t(i.map(r=>typeof r=="string"?r:Ke(r)).join(" "))}};this.context=M.createContext(n),M.runInContext(`
25
+ globalThis.__maestroScope = new Proxy(globalThis, {
26
+ has() { return true },
27
+ get(target, key) { return target[key] },
28
+ })
29
+ function json(text) { return JSON.parse(text) }
30
+ function relativePoint(x, y) {
31
+ var xPercent = Math.ceil(x * 100) + '%'
32
+ var yPercent = Math.ceil(y * 100) + '%'
33
+ return xPercent + ',' + yPercent
34
+ }
35
+ `,this.context);for(let[i,r]of Object.entries(process.env))r!==void 0&&this.envBinding.set(i,r)}putEnv(e,t){this.envBinding.set(e,t)}setCopiedText(e){this.maestro.copiedText=e}enterEnvScope(){this.envScopeStack.push(new Map(this.envBinding))}leaveEnvScope(){let e=this.envScopeStack.pop();if(e){this.envBinding.clear();for(let[t,n]of e)this.envBinding.set(t,n)}}evaluate(e,t={}){let n=t.env;if(n&&Object.keys(n).length>0){this.enterEnvScope();try{for(let[i,r]of Object.entries(n))this.envBinding.set(i,r);return this.evalRaw(e)}finally{this.leaveEnvScope()}}return this.evalRaw(e)}evalRaw(e){this.syncEnvToContext();let t=e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${");return M.runInContext(`(function(){ with(__maestroScope){ return eval(\`${t}\`) } })()`,this.context)}syncEnvToContext(){let e=M.runInContext("globalThis",this.context);for(let t of this.syncedEnvKeys)this.envBinding.has(t)||delete e[t];this.syncedEnvKeys=new Set;for(let[t,n]of this.envBinding)try{e[t]=n,this.syncedEnvKeys.add(t)}catch{}}evaluateStringTemplate(e){return e.replace(dt,(n,i)=>{if(i.trim().length===0)return"";let r=this.evaluate(i);if(r===void 0&&ut.test(i.trim()))throw new Error(`missing variable for flow placeholder: ${i.trim()}`);return Ke(r)}).replace(ct,(n,i)=>i)}interpolateStep(e){return this.interpolateValue(e,null)}interpolateValue(e,t){return typeof e=="string"?t==="evalScript"?e:this.evaluateStringTemplate(e):Array.isArray(e)?t==="commands"||t==="onFlowStart"||t==="onFlowComplete"?e:e.map(n=>this.interpolateValue(n,t)):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).map(([n,i])=>[n,this.interpolateValue(i,n)])):e}};function Ke(o){if(o===void 0)return"undefined";if(o===null)return"null";if(typeof o=="object")try{return JSON.stringify(o)}catch{return String(o)}return String(o)}function qe(o){if(o==null)return!1;if(typeof o=="boolean")return o;let e=String(o);if(e.trim().length===0||e.toLowerCase()==="false"||e==="undefined"||e==="null")return!1;let t=Number(e);return!(!Number.isNaN(t)&&t===0)}var K=1e4,q=393,R=852;function h(o){return new Promise(e=>setTimeout(e,o))}function fe(o){return!!(o&&typeof o=="object"&&!Array.isArray(o))}function B(o,e){if(!fe(o))return null;let t=o[e];return typeof t=="string"&&t.length>0?t:null}function ft(o,e){return fe(o)?o[e]===!0:!1}function pt(o){if(!o)return null;let e=o.recentApps;if(Array.isArray(e))for(let n of e){let i=B(n,"id");if(i)return i}let t=o.surfaceBindings;return B(t,"app:one")||B(t,"app:two")||null}function ht(o){return o?g.basename(o)===".maestro"?g.dirname(o):o:process.cwd()}function mt(o,e,t){let n=e.endsWith(".png")?e:`${e}.png`;if(g.isAbsolute(n))return n;if(t.mode==="flow"&&/[\\/]/.test(n)){let i=n.startsWith("./")||n.startsWith("../")?t.flowDir??process.cwd():ht(t.flowDir);return g.resolve(i,n)}return g.join(o,n)}function wt(o){if(typeof o=="string")return{path:o,withFrame:!1};let e=o.path?.trim()||o.name?.trim();if(!e)throw new Error("takeScreenshot object form requires path or name");return{path:e,withFrame:o.withFrame===!0,layers:o.layers}}function ue(o){let[e,t]=o.split(",").map(i=>i.trim()),n=(i,r)=>i.endsWith("%")?Number.parseFloat(i)/100*r:Number.parseFloat(i);return{x:n(e,q),y:n(t,R)}}function gt(o){switch(o){case"back":return{back:!0};case"hideKeyboard":return{hideKeyboard:!0};case"waitForAnimationToEnd":return{waitForAnimationToEnd:!0};case"stopApp":return{stopApp:!0};case"clearState":return{clearState:!0};case"clearKeychain":return{clearKeychain:!0};case"eraseText":return{eraseText:50};case"scroll":case"scrollDown":return{scroll:{direction:"DOWN"}};case"scrollUp":return{scroll:{direction:"UP"}};default:return{[o]:!0}}}function yt(o){let e=o.split(/^---$/m),t=e.length>1?e[e.length-1]:o,n=je.parse(t);return Array.isArray(n)?n:[]}var G=class{constructor(e,t){this.bridge=e;this.opts=t}stepDelay=0;js=new H({platform:"ios",onLog:e=>console.log(`[flow] js: ${e}`)});firstLaunchDone=!1;profilingEnabled=!1;recordingEnabled=!1;recordingAccessChecked=!1;recordingStartedAtMs=null;lastRecordingDurationMs=null;lastVisualSettledAtMs=0;simRouteHint=null;lastFailedStep=null;get simId(){return this.opts.simId}setSimRouteHint(e){this.simRouteHint=this.normalizeSimRoute(e)}normalizeSimRoute(e){if(!e)return null;try{let t=new URL(e);t.searchParams.delete("inspectOpen");let n=t.searchParams.toString();return`${t.origin}${t.pathname}${n?`?${n}`:""}`}catch{return e}}async refreshSimId(){if(this.opts.simId)try{let e=await this.bridge.listSims(),t=e.find(l=>l.id===this.opts.simId);if(t&&(this.simRouteHint=this.normalizeSimRoute(t.url||t.origin)),e.find(l=>l.id===this.opts.simId&&l.readyState==="open")||!this.simRouteHint)return;let i=this.simRouteHint&&e.find(l=>l.readyState==="open"&&this.normalizeSimRoute(l.url||l.origin)===this.simRouteHint);if(!i)return;let r=e.find(l=>l.isPrimary&&l.readyState==="open"),s=e.find(l=>l.readyState==="open"),a=i??r??s;a&&(this.opts.simId=a.id,console.log(` [flow] sim rotated to ${a.id}`))}catch{}}async evaluate(e,t){return this.bridge.send({type:"evaluate",simId:this.opts.simId,code:e},t?{timeoutMs:t}:void 0)}async callTest(e,...t){return this.bridge.send({type:"call",simId:this.opts.simId,path:`__sootsimTest.${e}`,args:t})}async waitForTree(e=K){let t=Date.now()+e,n=Date.now(),i=null,r=0,s=0,a=-1,l=n;for(;Date.now()<t;){try{let d=await this.evaluate($e,8e3);if(r=0,d?.externalError)throw new Error(`app failed to load: ${d.externalError}`);if(d){let m=Date.now();d.nodes!==a&&(a=d.nodes,l=m);let P=d.flag===!0&&Pe(d),w=d.flag!==!0&&Ae(d);if((P||w)&&d.externalReady!==!1&&!d.externalError&&!d.loadingText&&m-l>=Fe)return}}catch(d){if(i=d instanceof Error?d:new Error(String(d)),i.message.startsWith("app failed to load:"))throw i;if(r++,r>=4)throw new Error(`target sim is not responding to the bridge (${i.message}). it is likely a stale orphan \u2014 run \`sootsim list\`, then close it with \`sootsim close <id>\` or start a fresh one with \`sootsim open --new <port>\`.`);await this.refreshSimId()}let p=Date.now()-n;p-s>=5e3&&(s=p,console.log(` [flow] waiting for app to be ready\u2026 (${Math.round(p/1e3)}s)`)),await h(500)}throw i?.message.startsWith("app failed to load:")?i:new Error(`app not ready after ${e}ms`)}async ensureRecordingStarted(){if(!this.opts.recordingOutputDir)throw new Error("recording output directory not configured");this.recordingAccessChecked||(await He("flow --video",{originOverride:this.opts.billingOriginOverride,allowGitHubAuth:this.opts.allowGitHubRecording}),this.recordingAccessChecked=!0);let e=Date.now(),t=await this.evaluate(`(() => {
36
+ const rec = window.__sootsimRecorder
37
+ if (!rec) return { ok: false, error: 'recorder unavailable on this page' }
38
+ const format = ${JSON.stringify(this.opts.recordingFormat??"webm")}
39
+ if (rec.state() === 'recording') return { ok: true, format }
40
+ return rec.start({ format, fps: 24 })
41
+ })()`);if(!t?.ok)throw new Error(t?.error||"recording unavailable on this page");this.recordingStartedAtMs||(this.recordingStartedAtMs=e)}async startRecording(){this.recordingEnabled=!0,await this.ensureRecordingStarted()}prepareRecording(){this.recordingEnabled=!0}getLastRecordingDurationMs(){return this.lastRecordingDurationMs}async stopRecording(){if(!this.recordingEnabled||!this.opts.recordingOutputDir)return null;this.recordingEnabled=!1;let e=Date.now(),t=await this.evaluate("window.__sootsimRecorder.stop()");if(!t?.ok)throw this.recordingStartedAtMs=null,new Error(t?.error||"recording stop failed");this.lastRecordingDurationMs=this.recordingStartedAtMs?Math.max(1,e-this.recordingStartedAtMs):null,this.recordingStartedAtMs=null;let n=[],i=0;for(;;){let l=await this.evaluate(`window.__sootsimRecorder.getBlobBase64({ offset: ${i}, chunk: 2097152 })`);if(!l||(n.push(Buffer.from(l.data,"base64")),i=l.offset,l.done))break}if(n.length===0)throw new Error("recording requested but no video buffer was produced");v.mkdirSync(this.opts.recordingOutputDir,{recursive:!0});let s=(t.mime||this.opts.recordingFormat||"video/webm").includes("mp4")?"mp4":"webm",a=g.join(this.opts.recordingOutputDir,`sootsim-${Date.now()}.${s}`);return v.writeFileSync(a,Buffer.concat(n)),a}async waitForRecordingTail(e){if(!this.recordingEnabled)return;let t=Math.max(0,Math.round(e.maxMs));if(t<=0)return;if(!e.smart){await h(t);return}let n=await ce({bridge:this.bridge,simId:this.opts.simId,maxMs:t,pollMs:80,stablePolls:6,strict:!0});await this.waitForVisualSettle(),console.log(n.settled?` [flow] recording tail settled in ${n.elapsed}ms`:` [flow] recording tail reached ${n.elapsed}ms budget`)}async findElement(e){if(e.childOf!=null||typeof e.index=="number")return this.findElementScoped(e);let t=!!e.text&&/[.*+?^$()[\]{}|\\]/.test(e.text);return this.evaluate(`(async () => {
42
+ const test = window.__sootsimTest
43
+ if (!test) return null
44
+ let node = null
45
+ if (${JSON.stringify(!!e.text)}) {
46
+ node = await test.findByText(${JSON.stringify(e.text||"")})
47
+ // maestro matches a text selector against the element's ACCESSIBILITY
48
+ // text too, not just rendered glyphs \u2014 icon-only buttons (e.g. bluesky's
49
+ // "Pin to Home" / "Mute accounts" pin/menu controls) carry the label on
50
+ // accessibilityLabel with no visible text node, so findByText misses
51
+ // them. fall back to an exact a11y-label match, mirroring the real
52
+ // driver. findByLabel resolves a node, but its info shape omits nodeId/
53
+ // isTextInput; re-resolve through findByTestId/findById when it exposes
54
+ // an id so tapOn still gets a resolveTapTarget-able nodeId.
55
+ if (!node) {
56
+ const labelled = await test.findByLabel?.(${JSON.stringify(e.text||"")})
57
+ if (labelled) {
58
+ const reId = labelled.testID || labelled.id
59
+ node =
60
+ (reId &&
61
+ ((await test.findByTestId?.(reId)) || (await test.findById?.(reId)))) ||
62
+ labelled
63
+ }
64
+ }
65
+ if (!node && ${JSON.stringify(t)} && test.queryAll) {
66
+ // regex selector fallback: match the pattern against each visible
67
+ // node's text; prefer the narrowest matching node so a tight <text>
68
+ // wins over a wide container that merely contains it.
69
+ let re = null
70
+ try { re = new RegExp(${JSON.stringify(e.text||"")}) } catch (e) { re = null }
71
+ if (re) {
72
+ const all = (await test.queryAll({ pruneHidden: true })) || []
73
+ const hits = all.filter(
74
+ (n) =>
75
+ n && n.absolutePosition && n.layout &&
76
+ typeof n.text === 'string' && re.test(n.text),
77
+ )
78
+ hits.sort((a, b) => (a.text || '').length - (b.text || '').length)
79
+ if (hits[0]) node = hits[0]
80
+ }
81
+ }
82
+ }
83
+ if (!node && ${JSON.stringify(!!e.id)}) {
84
+ node = (await test.findByTestId(${JSON.stringify(e.id||"")})) || (await test.findById(${JSON.stringify(e.id||"")}))
85
+ }
86
+ if (!node || !node.absolutePosition || !node.layout) return null
87
+ return {
88
+ nodeId: typeof node.nodeId === 'number' ? node.nodeId : null,
89
+ id: node.id || null,
90
+ testID: node.testID || null,
91
+ text: node.text || null,
92
+ absolutePosition: node.absolutePosition,
93
+ layout: node.layout,
94
+ isTextInput: !!node.isTextInput,
95
+ }
96
+ })()`)}async findElementScoped(e){let t=typeof e.index=="number"?e.index:0;return this.evaluate(`(async () => {
97
+ const test = window.__sootsimTest
98
+ if (!test || !test.queryAll) return null
99
+ // NOT pruneHidden: that over-filters (it dropped every postDropdownBtn in a
100
+ // feed and made index:0 resolve to nothing \u2014 worse than findByTestId). reach
101
+ // for the same set findByTestId sees, then PREFER on-screen ones below.
102
+ const filter = {}
103
+ if (${JSON.stringify(!!e.id)}) filter.hasId = ${JSON.stringify(e.id||"")}
104
+ if (${JSON.stringify(!!e.text)}) filter.hasText = ${JSON.stringify(e.text||"")}
105
+ let candidates = (await test.queryAll(filter)) || []
106
+ // a11y-label fallback (icon-only buttons) for text matchers, mirroring
107
+ // findElement's simple path.
108
+ if (${JSON.stringify(!!e.text)} && candidates.length === 0) {
109
+ const all = (await test.queryAll({})) || []
110
+ candidates = all.filter((n) => (n.accessibilityLabel || '') === ${JSON.stringify(e.text||"")})
111
+ }
112
+ candidates = candidates.filter((n) => n && n.absolutePosition && n.layout)
113
+ // prefer on-screen matches (findByTestId's visible-first behavior); only
114
+ // fall back to off-screen ones when nothing is on-screen, so index: still
115
+ // resolves a target that needs scrolling into view.
116
+ const onScreen = candidates.filter((n) => {
117
+ const cy = n.absolutePosition.y + n.layout.height / 2
118
+ return cy > 0 && cy < ${R}
119
+ })
120
+ if (onScreen.length > 0) candidates = onScreen
121
+ ${e.childOf?`
122
+ const container = ${e.childOf.id?`(await test.findByTestId(${JSON.stringify(e.childOf.id)})) || (await test.findById(${JSON.stringify(e.childOf.id)}))`:`await test.findByText(${JSON.stringify(e.childOf.text||"")})`}
123
+ if (!container || !container.absolutePosition || !container.layout) return null
124
+ const x0 = container.absolutePosition.x
125
+ const y0 = container.absolutePosition.y
126
+ const x1 = x0 + container.layout.width
127
+ const y1 = y0 + container.layout.height
128
+ candidates = candidates.filter((n) => {
129
+ const cx = n.absolutePosition.x + n.layout.width / 2
130
+ const cy = n.absolutePosition.y + n.layout.height / 2
131
+ return cx >= x0 && cx <= x1 && cy >= y0 && cy <= y1
132
+ })`:""}
133
+ const node = candidates[${t}]
134
+ if (!node) return null
135
+ return {
136
+ nodeId: typeof node.nodeId === 'number' ? node.nodeId : null,
137
+ id: node.id || null,
138
+ testID: node.testID || null,
139
+ text: node.text || null,
140
+ absolutePosition: node.absolutePosition,
141
+ layout: node.layout,
142
+ isTextInput: !!node.isTextInput,
143
+ }
144
+ })()`)}async resolveTapTarget(e){return this.evaluate(`(async () => {
145
+ const test = window.__sootsimTest
146
+ if (!test?.resolveTapTarget) return null
147
+ return await test.resolveTapTarget(${e})
148
+ })()`)}async activatePressTarget(e){let t=e.id?{id:e.id,testID:e.id,text:null}:{id:null,testID:null,text:e.text??null};return this.evaluate(`(async () => {
149
+ const test = window.__sootsimTest
150
+ if (!test) return null
151
+ const node = ${e.id?`(await test.findByTestId?.(${JSON.stringify(e.id)})) || (await test.findById?.(${JSON.stringify(e.id)}))`:`await test.findByText?.(${JSON.stringify(e.text||"")})`}
152
+ let point = null
153
+ if (node?.absolutePosition && node?.layout) {
154
+ point = {
155
+ x: node.absolutePosition.x + node.layout.width / 2,
156
+ y: node.absolutePosition.y + node.layout.height / 2,
157
+ }
158
+ if (typeof node.nodeId === 'number' && test.resolveTapTarget) {
159
+ const resolved = await test.resolveTapTarget(node.nodeId)
160
+ if (
161
+ resolved &&
162
+ Number.isFinite(resolved.cx) &&
163
+ Number.isFinite(resolved.cy)
164
+ ) {
165
+ point = { x: resolved.cx, y: resolved.cy }
166
+ }
167
+ }
168
+ }
169
+ ${e.id?`const direct = await test.activatePressById?.(${JSON.stringify(e.id)})`:`const direct = await test.activatePressByText?.(${JSON.stringify(e.text||"")})`}
170
+ if (direct?.ok && point) {
171
+ window.dispatchEvent(
172
+ new CustomEvent('sootsim:agentAction', {
173
+ detail: { type: 'tap', x: point.x, y: point.y, target: ${JSON.stringify(t)} },
174
+ }),
175
+ )
176
+ }
177
+ return direct || null
178
+ })()`)}async activatePressAt(e,t){return this.evaluate(`(async () => {
179
+ const test = window.__sootsimTest
180
+ if (!test?.activatePressAt) return null
181
+ const direct = await test.activatePressAt(${e}, ${t})
182
+ if (direct?.ok) {
183
+ window.dispatchEvent(
184
+ new CustomEvent('sootsim:agentAction', {
185
+ detail: { type: 'tap', x: ${e}, y: ${t} },
186
+ }),
187
+ )
188
+ }
189
+ return direct
190
+ })()`)}async tap(e,t,n){return await this.bridge.send({type:"tap",simId:this.opts.simId,x:e,y:t,target:n})}async tapOn(e){let t=typeof e=="string"?{text:e}:e;if(t.point){let l=ue(t.point);(await this.activatePressAt(l.x,l.y))?.ok||await this.tap(l.x,l.y),await h(300);return}let n=5e3,i=150,r=Date.now()+n,s=await this.findElement({text:t.text,id:t.id});for(;!s&&Date.now()<r;)await h(i),s=await this.findElement({text:t.text,id:t.id});if(s){let l=s.isTextInput?4:1;for(let p=0;p<l;p++){let d=p===0?s:await this.findElement({text:t.text,id:t.id});if(!d)break;let m=typeof d.nodeId=="number"?await this.resolveTapTarget(d.nodeId):null,P=m?.cx??d.absolutePosition.x+d.layout.width/2,w=m?.cy??d.absolutePosition.y+d.layout.height/2;if((await this.tap(P,w,{id:t.id??m?.target?.id??d.id??null,testID:t.id??m?.target?.testID??d.testID??null,text:t.text??m?.target?.text??m?.target?.accessibilityLabel??d.text??d.accessibilityLabel??null,type:m?.target?.type??d.type??null}))?.hit===!0){if(await h(300),!d.isTextInput||await this.waitForFocusedTextInput(600,d))return;continue}break}}if((await this.activatePressTarget(t))?.ok){await h(300);return}throw new Error(`tapOn: element not found: ${JSON.stringify(t)}`)}async tapAtCoords(e,t){await this.tap(e,t),await h(300)}async doubleTapAtCoords(e,t,n=80){let i=Math.max(0,Math.round(n));if(!await this.evaluate(`(async () => {
191
+ const interact = window.__sootsimInteract
192
+ if (interact?.doubleTap) {
193
+ return !!(await interact.doubleTap(${e}, ${t}, ${i}))
194
+ }
195
+ if (!interact?.tap) return false
196
+ const first = await interact.tap(${e}, ${t})
197
+ if (!first || first.hit === false) return false
198
+ await new Promise((resolve) => setTimeout(resolve, ${i}))
199
+ const second = await interact.tap(${e}, ${t})
200
+ return !!second && second.hit !== false
201
+ })()`))throw new Error(`doubleTapAtCoords failed at (${e}, ${t})`);await h(300)}async assertVisible(e){let t=typeof e=="string"?{text:e}:e;for(let r=0;r<15;r++){if(await this.isElementVisible(t))return;await h(200)}let n=await this.findElement(t),i=n?` (matched node at y=${Math.round(n.absolutePosition.y)} h=${Math.round(n.layout.height)} \u2014 off-screen)`:" (no matching node in tree)";throw new Error(`assertVisible: ${JSON.stringify(t)} not visible${i}`)}async assertNotVisible(e){let t=typeof e=="string"?{text:e}:e;if(await this.isElementVisible(t)){let n=await this.findElement(t),i=n?` at (${Math.round(n.absolutePosition.x)},${Math.round(n.absolutePosition.y)})`:"";throw new Error(`assertNotVisible: ${JSON.stringify(t)} IS visible${i}`)}}async isElementVisible(e){let t=await this.findElement(e);return!!(t&&t.absolutePosition.y+t.layout.height>0&&t.absolutePosition.y<R)}async inputText(e){if(!await this.waitForFocusedTextInput())throw new Error("inputText: no focused TextInput; tap the input and wait for focus before typing");await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"type",text:e}),await h(200)}focusedTextInputMatches(e,t){if(!t||typeof t.nodeId=="number"&&typeof e.nodeId=="number"&&t.nodeId===e.nodeId)return!0;let n=t.testID??null,i=e.testID??null;if(n&&i&&n===i)return!0;let r=t.id??null,s=e.id??null;return!!(r&&s&&r===s)}async waitForFocusedTextInput(e=1500,t){let n=Date.now()+e;for(;Date.now()<n;){try{let i=await this.callTest("getFocusedNode");if(i&&this.focusedTextInputMatches(i,t))return!0}catch{}await h(50)}return!1}async pressKey(e){await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"press",text:e}),await h(120)}async dispatchKey(e){await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dispatchKey",text:e}),await h(120)}async hideKeyboard(){try{await this.callTest("blurFocusedTextInput")}catch{}await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dismiss"});let e=Date.now()+3e3;for(;Date.now()<e;){let t=await this.evaluate(`(() => {
202
+ const keyboard =
203
+ window.__sootsimKeyboard ??
204
+ window.SootSim?.bridges?.keyboard ??
205
+ null
206
+ const test = window.__sootsimTest
207
+ return {
208
+ visible: !!keyboard?.isVisible?.(),
209
+ focused: !!test?.isTextInputFocused?.(),
210
+ }
211
+ })()`);if(!t?.visible&&!t?.focused){await h(80);return}await h(80)}}async eraseText(e){for(let t=0;t<e;t++)await this.bridge.send({type:"keyboard",simId:this.opts.simId,action:"dispatchKey",text:"Backspace"});await h(100)}async waitFor(e){let t=Date.now()+(e.timeout||K);for(;Date.now()<t;){if(await this.findElement(e))return;await h(200)}let n=await this.findElement(e),i=n?` (matched node y=${Math.round(n.absolutePosition.y)} \u2014 still off-screen at deadline)`:"";throw new Error(`waitFor: ${JSON.stringify(e)} not found after ${e.timeout||K}ms${i}`)}async takeScreenshot(e){if(!this.hasFreshVisualSettle())try{await this.waitForVisualSettle(),await h(250)}catch{}let t=wt(e),n=mt(this.opts.screenshotDir,t.path,{mode:this.opts.screenshotPathMode??"dir",flowDir:this.opts.flowDir});v.mkdirSync(g.dirname(n),{recursive:!0});let i=t.layers??this.opts.screenshotLayers,r={type:"screenshot",simId:this.opts.simId};i&&i!=="full"&&(r.layers=i);let a=(await this.bridge.send(r)).replace(/^data:image\/png;base64,/,""),l=Buffer.from(a,"base64");if(t.withFrame){let p=await this.readCurrentDeviceModel();if(!p)throw new Error("could not read current device model for framed screenshot");let d=await Ue(l,p);v.writeFileSync(n,d),console.log(`[flow] screenshot: ${n} (frame: ${p})`);return}v.writeFileSync(n,l),console.log(`[flow] screenshot: ${n}`)}async readCurrentDeviceModel(){let e=await this.bridge.send({type:"call",simId:this.opts.simId,path:"SootSim.bridges.settings.get",args:[]}),t=e&&typeof e.deviceModel=="string"?e.deviceModel:null;return!t||!(t in Te)?null:t}async captureFailureScreenshot(e){v.mkdirSync(g.dirname(e),{recursive:!0});let n=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");v.writeFileSync(e,Buffer.from(n,"base64"))}async captureFailureBundle(e,t){v.mkdirSync(e,{recursive:!0});let n=(d,m)=>{try{v.writeFileSync(g.join(e,d),m)}catch{}},i=async d=>{try{return await this.bridge.send({type:"evaluate",simId:this.opts.simId,code:d})}catch{return null}},r=await i(`(async () => {
212
+ const out = {
213
+ simId: window.__sootsimBridge?.id ?? window.SootSim?.state?.simId ?? null,
214
+ url: location.href,
215
+ title: document.title,
216
+ hidden: document.hidden,
217
+ }
218
+ try {
219
+ const params = new URL(location.href).searchParams
220
+ const bundle = params.get('bundle')
221
+ if (bundle) {
222
+ const baseMatch = bundle.match(/^https?:\\/\\/[^/]+/)
223
+ if (baseMatch) {
224
+ const res = await fetch(baseMatch[0] + '/', {
225
+ headers: { 'expo-platform': 'ios' },
226
+ cache: 'no-store',
227
+ })
228
+ if (res.ok) {
229
+ out.manifest = await res.json().catch(() => null)
230
+ }
231
+ }
232
+ }
233
+ } catch {}
234
+ return out
235
+ })()`);n("error.json",JSON.stringify({message:t.error.message,stack:t.error.stack,stepIndex:t.stepIndex,stepKind:t.stepKind,stepTarget:t.stepTarget,capturedAt:new Date().toISOString(),sim:r??null},null,2));try{let m=(await this.bridge.send({type:"screenshot",simId:this.opts.simId})).replace(/^data:image\/png;base64,/,"");n("screenshot.png",Buffer.from(m,"base64"))}catch{}let s=await i(`(async () => {
236
+ const t = window.__sootsimTest
237
+ const mainShell = window.SootSim?.bridges?.mainShell
238
+ if (!t) return { error: 'no test bridge' }
239
+ let shell = null
240
+ try {
241
+ shell = typeof mainShell?.getState === 'function' ? await mainShell.getState() : null
242
+ } catch {}
243
+ const all = await t.queryAll({ pruneHidden: true })
244
+ return { shell, nodes: all, url: location.href, title: document.title }
245
+ })()`);s&&n("describe.json",JSON.stringify(s,null,2));let a=await i("(async () => await window.__sootsimTest?.dumpAccessibilityTree?.(20))()");typeof a=="string"&&n("a11y.txt",a);let l=await i("(async () => await window.__sootsimTest?.dumpTree?.(15))()");typeof l=="string"&&n("tree.txt",l);let p=await i(`(() => {
246
+ const c = window.__sootsimConsole
247
+ return {
248
+ errors: c?.getErrors?.() ?? [],
249
+ warnings: c?.getWarnings?.() ?? [],
250
+ requests: (window.__sootsimGetFailedRequests?.() ?? []),
251
+ }
252
+ })()`);return p&&n("console.json",JSON.stringify(p,null,2)),e}async swipe(e="UP",t=300){let n=q/2,i=R/2,r=200,s=n,a=i,l=n,p=i;switch(e.toUpperCase()){case"UP":a+=r,p-=r;break;case"DOWN":a-=r,p+=r;break;case"LEFT":s+=r,l-=r;break;case"RIGHT":s-=r,l+=r;break}let d=Math.max(10,Math.round(t/16));await this.drag(s,a,l,p,d,16)}async drag(e,t,n,i,r=12,s=16){if(!(await this.evaluate(`(async () => {
253
+ const interact = window.__sootsimInteract
254
+ if (!interact?.drag) return { ok: false }
255
+ const value = await interact.drag(${e}, ${t}, ${n}, ${i}, ${Math.max(1,Math.round(r))}, ${Math.max(0,Math.round(s))})
256
+ return { ok: !!value, value }
257
+ })()`))?.ok)throw new Error("drag failed");await h(300)}async swipeCoords(e,t,n=300){let i=ue(e),r=ue(t),s=Math.max(10,Math.round(n/16));await this.drag(i.x,i.y,r.x,r.y,s,16)}async swipeFrom(e,t="UP",n=300){let i=await this.findElement(e);if(!i)throw new Error(`swipeFrom: element not found: ${JSON.stringify(e)}`);let r=i.absolutePosition.x+i.layout.width/2,s=i.absolutePosition.y+i.layout.height/2,a=180,l=r,p=s;switch(t.toUpperCase()){case"UP":p-=a;break;case"DOWN":p+=a;break;case"LEFT":l-=a;break;case"RIGHT":l+=a;break}let d=Math.max(10,Math.round(n/16));await this.drag(r,s,l,p,d,16)}async scrollTo(e,t,n){let i=await this.callTest("scrollTo",e,t,n,!1);if(!i?.ok)throw new Error(`scrollTo failed: ${i?.reason||"unknown error"}`);await h(250)}async pinch(e){let t=await this.evaluate(`(async () => {
258
+ const interact = window.__sootsimInteract
259
+ if (!interact?.pinch) return { ok: false, reason: 'no interact.pinch' }
260
+ const ok = await interact.pinch(
261
+ ${e.from[0]}, ${e.from[1]}, ${e.from[2]}, ${e.from[3]},
262
+ ${e.to[0]}, ${e.to[1]}, ${e.to[2]}, ${e.to[3]},
263
+ ${e.steps||12}, ${e.stepMs||16}
264
+ )
265
+ return { ok: !!ok, reason: ok ? null : 'pinch returned false' }
266
+ })()`);if(!t?.ok)throw new Error(`pinch failed: ${t?.reason||"unknown error"}`);await h(250)}async dumpTree(e=6){let t=await this.bridge.send({type:"tree",simId:this.opts.simId,depth:e});return console.log("[flow] tree:"),console.log(typeof t=="string"?t:JSON.stringify(t,null,2)),typeof t=="string"?t:JSON.stringify(t)}async assertTreeContains(e){if(!(await this.dumpTree(8)).includes(e))throw new Error(`assertTreeContains: "${e}" not in tree`)}async waitForAnimationToEnd(e=2e3){let t=Math.max(0,Math.round(e));if(t<=0)return;(await ce({bridge:this.bridge,simId:this.opts.simId,maxMs:t,pollMs:32,stablePolls:2,strict:!0})).settled&&this.markVisualSettled()}async back(){try{await this.tapOn("\u2039")}catch{await this.tapOn("<")}}async scrollUntilVisible(e){let t=Date.now()+(e.timeout||15e3),n=e.direction?.toUpperCase()||"DOWN",i=n==="DOWN"?"UP":n==="UP"?"DOWN":n;for(;Date.now()<t;){let r=await this.findElement({text:e.element});if(r&&r.absolutePosition.y>=0&&r.absolutePosition.y+r.layout.height>0&&r.absolutePosition.y<R-50){if(e.centerElement){let s=R/2,a=r.absolutePosition.y-s;if(Math.abs(a)>100){let l=Math.min(150,Math.abs(a)*.5),p=a>0?s-l:s+l;await this.drag(q/2,s,q/2,p,10,16)}}return}await this.swipe(i,250),await h(500)}throw new Error(`scrollUntilVisible: "${e.element}" not found`)}async extendedWaitUntil(e){let t=Date.now()+(e.timeout||K);for(;Date.now()<t;){let n=e.visible?await this.isElementVisible(typeof e.visible=="string"?{text:e.visible}:e.visible):!0,i=e.notVisible?!await this.isElementVisible(typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible):!0;if(n&&i)return;await h(200)}throw new Error("extendedWaitUntil timed out")}async reloadGuestApp(e){if(e){let i=!1;for(let r=0;r<3&&!i;r++)try{i=await this.evaluate(oe(!0),2e4)}catch{await h(1e3)}i||console.warn(" warn: tenant storage clear did not ack \u2014 hard-reloading anyway (worker reset follows)")}await this.evaluate("window.location.reload()").catch(()=>{}),await h(500),await this.refreshSimId()}async softReloadGuestApp(e){if(!await this.evaluate(oe(e),12e4))throw new Error("guest app soft reload bridge unavailable")}async rearmCaptureAfterRuntimeReload(){if(!this.recordingEnabled&&!this.profilingEnabled)return;let e=Date.now()+1e4,t=null;for(;Date.now()<e;){await this.refreshSimId();try{this.recordingEnabled&&await this.ensureRecordingStarted(),this.profilingEnabled&&await this.startProfile();return}catch(n){t=n,await h(250)}}throw new Error(`capture re-arm failed after app reload: ${t instanceof Error?t.message:String(t)}`)}async launchApp(e){await this.refreshSimId(),e&&typeof e=="object"&&e.arguments&&console.log("[flow] launchApp.arguments ignored (sootsim has no native process)");let t=!!(e&&typeof e=="object"&&e.clearState),n=ft(e,"resetRuntime");if(!this.firstLaunchDone&&!t)this.firstLaunchDone=!0,n?(this.recordingEnabled&&await this.ensureRecordingStarted(),await this.softReloadGuestApp(!1),await this.launchShellAppFromHomeIfNeeded(e),await this.waitForTree(12e4)):await this.launchShellAppFromHomeIfNeeded(e),await this.waitForTree(3e4);else if(this.firstLaunchDone=!0,await this.reloadGuestApp(t),await this.waitForTree(12e4),this.opts.onAfterLaunch)try{await this.opts.onAfterLaunch()}catch(i){console.warn(` warn: onAfterLaunch hook threw: ${i instanceof Error?i.message:i}`)}this.profilingEnabled&&await this.startProfile(),this.recordingEnabled&&(await this.waitForVisualSettle(),await this.ensureRecordingStarted())}async waitForVisualSettle(){try{await this.evaluate(`new Promise((resolve) => {
267
+ requestAnimationFrame(() => {
268
+ requestAnimationFrame(() => {
269
+ requestAnimationFrame(() => {
270
+ setTimeout(resolve, 180)
271
+ })
272
+ })
273
+ })
274
+ })`),this.markVisualSettled()}catch{await h(180),this.markVisualSettled()}}markVisualSettled(){this.lastVisualSettledAtMs=Date.now()}hasFreshVisualSettle(){return Date.now()-this.lastVisualSettledAtMs<750}resolveShellLaunchAppId(e,t){if(typeof e=="string"&&e.length>0)return e;if(fe(e)){let n=B(e,"appId")||B(e,"id");if(n)return n}return pt(t)||"connect"}async waitForShellAppLaunched(e,t){let n=Date.now()+t,i=null;for(;Date.now()<n;){try{i=await ne(this.bridge)}catch{i=null}if(i?.state==="app"&&i.activeApp===e&&i.showSwitcher===!1&&typeof i.launchProgress=="number"&&i.launchProgress>=.98)return;await h(16)}}async launchShellAppFromHomeIfNeeded(e){let t=null;try{t=await ne(this.bridge)}catch{return!1}if(t?.state!=="home"||t.activeApp!=null)return!1;let n=this.resolveShellLaunchAppId(e,t);return this.recordingEnabled&&await this.ensureRecordingStarted(),await Re(this.bridge,"launchApp",1e3,n),await this.waitForShellAppLaunched(n,1e3),!0}async startProfile(){let e=await this.evaluate(`(() => {
275
+ if (!window.__sootsimShellPerf) {
276
+ return { error: "shell frame profile unavailable (__sootsimShellPerf missing on the page)" }
277
+ }
278
+ window.__sootsimShellPerf.start()
279
+ return { started: true }
280
+ })()`);if(e?.error)throw new Error(e.error);this.profilingEnabled=!0}async stopProfile(){let e=await this.evaluate(`(async () => {
281
+ if (!window.__sootsimShellPerf) {
282
+ return { error: "shell frame profile unavailable (__sootsimShellPerf missing on the page)" }
283
+ }
284
+ return await window.__sootsimShellPerf.stop()
285
+ })()`);if(this.profilingEnabled=!1,e?.error)throw new Error(e.error);return e}async stopApp(){await this.reloadGuestApp(!1),await this.rearmCaptureAfterRuntimeReload()}async clearState(){await this.reloadGuestApp(!0),await this.rearmCaptureAfterRuntimeReload()}clearKeychain(){console.warn("[flow] clearKeychain: sootsim has no keychain surface \u2014 no-op (warning)")}async copyTextFrom(e){let t=typeof e=="string"?{id:e}:e,n=await this.findElement(t);if(!n)throw new Error(`copyTextFrom: element not found: ${JSON.stringify(t)}`);let i=n.text??n.testID??"";this.js.setCopiedText(i),this.js.putEnv("maestroCopiedText",i),console.log(`[flow] copied text: ${JSON.stringify(i)}`)}evalScript(e){let n=/(?<!\\)\$\{[^$]*\}/.test(e)?this.js.evaluateStringTemplate(e):this.js.evaluate(e);n!==void 0&&n!==""&&console.log("[flow] evalScript ->",n)}runScript(e){let t=typeof e=="string"?{file:e}:e;if(!t.file)throw new Error("runScript requires a file");let n=g.resolve(this.opts.flowDir,t.file),i=v.readFileSync(n,"utf8");this.js.evaluate(i,{env:t.env}),console.log(`[flow] runScript: ${t.file} done`)}async openLink(e){let t=typeof e=="string"?e:e.link;if(!t)throw new Error("openLink: missing link");let n=await this.callTest("openDeepLink",t);if(!n?.ok)throw new Error(`openLink failed: ${n?.error||"no test bridge"}`);await h(300)}async evaluateWhen(e){if(e.visible!==void 0){let t=typeof e.visible=="string"?{text:e.visible}:e.visible;return!!await this.findElement(t)}if(e.notVisible!==void 0){let t=typeof e.notVisible=="string"?{text:e.notVisible}:e.notVisible;return!await this.findElement(t)}return e.platform!==void 0?e.platform.toLowerCase()===this.js.maestro.platform.toLowerCase():e.true!==void 0?qe(e.true):!0}isOptional(e){if(e.optional===!0)return!0;let n=Object.entries(e).find(([r])=>r!=="when"&&r!=="optional"),i=n?n[1]:void 0;return!!(i&&typeof i=="object"&&"optional"in i&&i.optional)}async runStep(e,t){let n=typeof e=="string"?gt(e):e,i=Object.keys(n).find(s=>s!=="when")||Object.keys(n)[0];console.log(`[flow] step ${t+1}: ${i}`);let r;try{r=this.js.interpolateStep(n)}catch(s){if(this.isOptional(n)){console.log(`[flow] (optional, skipped: ${s.message.slice(0,80)})`);return}throw this.lastFailedStep={index:t,kind:i,target:n[i]},s}if(r.when&&!await this.evaluateWhen(r.when)){console.log("[flow] (when: predicate false, skipped)");return}try{let s=!!(r.extendedWaitUntil||r.waitFor||r.scrollUntilVisible||r.launchApp||r.runFlow||r.runScript),a=1e4,l=this.runStepInner(r);if(s)await l;else{let d=null,m=new Promise((P,w)=>{d=setTimeout(()=>{w(new Error(`step watchdog: ${i} made no progress in ${a}ms \u2014 bridge or bundle probably hung`))},a)});try{await Promise.race([l,m])}finally{d&&clearTimeout(d)}}let p=!!(r.assertVisible||r.assertNotVisible||r.extendedWaitUntil||r.waitFor);this.stepDelay>0&&!p&&await h(this.stepDelay)}catch(s){if(this.isOptional(r)){console.log(`[flow] (optional, skipped: ${s.message.slice(0,80)})`);return}throw this.lastFailedStep={index:t,kind:i,target:r[i]},s}}async runStepInner(e){if(e.tapOn)await this.tapOn(e.tapOn);else if(e.scrollUntilVisible)await this.scrollUntilVisible(e.scrollUntilVisible);else if(e.extendedWaitUntil)await this.extendedWaitUntil(e.extendedWaitUntil);else if(e.assertVisible)await this.assertVisible(e.assertVisible);else if(e.assertNotVisible)await this.assertNotVisible(e.assertNotVisible);else if(e.inputText)await this.inputText(e.inputText);else if(e.pressKey)await this.pressKey(e.pressKey);else if(e.dispatchKey)await this.dispatchKey(e.dispatchKey);else if(e.waitFor)await this.waitFor(e.waitFor);else if(e.takeScreenshot)await this.takeScreenshot(e.takeScreenshot);else if(e.swipe)e.swipe.start&&e.swipe.end?await this.swipeCoords(e.swipe.start,e.swipe.end,e.swipe.duration):e.swipe.from?await this.swipeFrom(e.swipe.from,e.swipe.direction,e.swipe.duration):await this.swipe(e.swipe.direction,e.swipe.duration);else if(e.scroll)await this.swipe(e.scroll.direction==="DOWN"?"UP":"DOWN");else if(e.scrollTo){let t=typeof e.scrollTo.nodeId=="number"?{nodeId:e.scrollTo.nodeId}:e.scrollTo.id;if(!t)throw new Error("scrollTo requires id or nodeId");await this.scrollTo(t,e.scrollTo.x,e.scrollTo.y)}else if(e.pinch)await this.pinch(e.pinch);else if(e.waitForAnimationToEnd){let t=e.waitForAnimationToEnd;await this.waitForAnimationToEnd(typeof t=="number"?t:typeof t=="object"&&typeof t.timeout=="number"?t.timeout:2e3)}else if(e.back)await this.back();else if(e.hideKeyboard)await this.hideKeyboard();else if(e.launchApp)await this.launchApp(e.launchApp);else if(typeof e.wait=="number")await h(e.wait);else if(e.dumpTree)await this.dumpTree(e.dumpTree);else if(e.tapAtCoords)await this.tapAtCoords(e.tapAtCoords.x,e.tapAtCoords.y);else if(e.doubleTapAtCoords)await this.doubleTapAtCoords(e.doubleTapAtCoords.x,e.doubleTapAtCoords.y,e.doubleTapAtCoords.gapMs);else if(e.assertTreeContains)await this.assertTreeContains(e.assertTreeContains);else if(typeof e.eraseText=="number")await this.eraseText(e.eraseText);else if(e.repeat&&Array.isArray(e.repeat.commands)){let t=e.repeat.times,n=t==null||t===""?Number.MAX_SAFE_INTEGER:Number(t);if(!Number.isFinite(n))throw new Error(`repeat.times is not a number: ${t}`);let i=e.repeat.when??e.repeat.condition,r=async()=>i?this.evaluateWhen(i):!0,s=i?n:Math.min(n,1e3),a=0;for(;a<s&&await r();){for(let l=0;l<e.repeat.commands.length;l++)await this.runStep(e.repeat.commands[l],l);a++}}else if(e.stopApp!==void 0)await this.stopApp();else if(e.clearState!==void 0)await this.clearState();else if(e.clearKeychain!==void 0)this.clearKeychain();else if(e.copyTextFrom!==void 0)await this.copyTextFrom(e.copyTextFrom);else if(typeof e.evalScript=="string")this.evalScript(e.evalScript);else if(e.runScript){let t=e.runScript,n=typeof t=="string"?void 0:t.when;if(n&&!await this.evaluateWhen(n)){console.log("[flow] runScript skipped (when predicate false)");return}this.runScript(t)}else if(e.openLink!==void 0)await this.openLink(e.openLink);else if(e.runFlow){let t=e.runFlow,n=typeof t=="string"?t:t.file,i=typeof t=="string"?void 0:t.commands,r=typeof t=="string"?void 0:t.env,s=typeof t=="string"?void 0:t.when;if(s&&!await this.evaluateWhen(s)){console.log(`[flow] runFlow skipped (when predicate false): ${n??"inline commands"}`);return}if(!n&&!i)throw new Error("runFlow requires either file or commands");this.js.enterEnvScope();try{if(r)for(let[a,l]of Object.entries(r))this.js.putEnv(a,l);if(n){let a=g.resolve(this.opts.flowDir,n),l=v.readFileSync(a,"utf8"),p=this.opts.flowDir;this.opts.flowDir=g.dirname(a);try{await this.runFlow(yt(l))}finally{this.opts.flowDir=p}}else if(i)for(let a=0;a<i.length;a++)await this.runStep(i[a],a)}finally{this.js.leaveEnvScope()}}else throw new Error(`unsupported flow step: ${JSON.stringify(e)}`)}async runFlow(e){let t=[],n=[],i=[];for(let s of e){let a=Object.keys(s);if(a.length===1&&a[0]==="onFlowStart"&&Array.isArray(s.onFlowStart)){t.push(...s.onFlowStart);continue}if(a.length===1&&a[0]==="onFlowComplete"&&Array.isArray(s.onFlowComplete)){n.push(...s.onFlowComplete);continue}i.push(s)}if(t.length>0){console.log(`[flow] onFlowStart (${t.length} steps)`);for(let s=0;s<t.length;s++)await this.runStep(t[s],s)}let r=null;try{await this.runFlowBody(i)}catch(s){r=s instanceof Error?s:new Error(String(s))}if(n.length>0){console.log(`[flow] onFlowComplete (${n.length} steps)`);for(let s=0;s<n.length;s++)try{await this.runStep(n[s],s)}catch(a){console.warn(`[flow] onFlowComplete step ${s+1} failed: ${a instanceof Error?a.message:a}`)}}if(r)throw r}async runFlowBody(e){for(let t=0;t<e.length;t++){let n=e[t],i=typeof n.wait=="number"?n.wait:0,r=typeof n.waitFor?.timeout=="number"?n.waitFor.timeout:0,s=Math.max(6e4,i+15e3,r+15e3);if(n.runFlow||n.launchApp){await this.runStep(n,t);continue}await Promise.race([this.runStep(n,t),new Promise((a,l)=>setTimeout(()=>l(new Error(`step ${t+1} (${Object.keys(n)[0]}) exceeded ${s}ms deadline`)),s))])}}};async function bt(o){if(!o)return"";let e=o.trim();if(!e)return"";if(/^\d+$/.test(e)||e.startsWith("http://")||e.startsWith("https://"))return e;let n=(await ke()).find(i=>i.name.toLowerCase()===e.toLowerCase());return n?String(n.preferredPort):e}async function vt(){let o=await Ee(),e=o.find(n=>n.patched);if(e)return`http://localhost:${e.port}/__soot/`;let t=o[0];return t?`http://localhost:${t.port}/__soot/`:null}async function Ye(o){(o.length===0||o.includes("--help")||o.includes("-h"))&&(console.log(`
286
+ sootsim flow \u2014 run flows or manage a draft
287
+
288
+ usage:
289
+ sootsim flow <flow.yaml> [options]
290
+ sootsim flow start
291
+ sootsim flow keep
292
+ sootsim flow end [--output <path>] [--validate] [--video]
293
+ sootsim flow validate <path>
294
+
295
+ options:
296
+ --record record a webm artifact while the flow runs
297
+ --profile capture perf stats while the flow runs
298
+ --out <dir> output directory (default: /tmp/sootsim-recordings)
299
+ --device <model> override the flow frontmatter device for this run
300
+ --slow <ms> delay between steps for natural pacing
301
+ --tail-wait <ms> hold the recording open after the last step so the
302
+ final UI state is captured (default: smart idle up to
303
+ 6000ms for --preview, fixed 2000ms for --record, 0 otherwise)
304
+ --url <url> load this target before running the flow
305
+ --screenshot-paths <mode>
306
+ screenshot path mode: dir (default) or flow
307
+ --no-shell capture every screenshot tenant-only (no status bar,
308
+ keyboard, notification center, or other shell overlays).
309
+ use for clean demo asset sets. per-step \`layers:\`
310
+ still wins over this default.
311
+ --shell-only inverse \u2014 capture shell chrome only
312
+ --replace <m>=<f> replace a Metro module with a local file for this run
313
+ --new open a fresh sim before running the flow
314
+ --driver <id> when paired with --new, launch through a specific
315
+ driver from the registry (e.g. playwright for
316
+ hermetic CI runs); see 'sootsim list --drivers'
317
+ --headless pass headless=true to the launch driver (useful
318
+ with --driver playwright)
319
+ --headed force a fresh, VISIBLE window for this run (implies
320
+ --new; overrides --headless). use when you want to
321
+ watch the flow run live even if the current sim is
322
+ headless or stale
323
+ --electron prefer opening the target in the desktop companion
324
+ --sim <id> target a specific current sim
325
+ --validate replay the drafted flow before clearing it
326
+ --video replay and record the drafted flow before clearing it
327
+ --preview record events+video, upload, and print /preview/<id>
328
+ --preview-open open the uploaded preview link after a successful run
329
+ --preview-origin <url>
330
+ upload target for --preview (default: auto)
331
+ --preview-public-origin <url>
332
+ public link origin for --preview (default: sootsim.com
333
+ for prod uploads)
334
+ --owner <org> associate preview upload with a linked org repo
335
+ --repo <repo> repo name for --owner; user must belong to the team
336
+
337
+ frontmatter (top of flow.yaml between --- markers):
338
+ app: 8081 load this target before the flow starts
339
+ device: iphone-14 set the live device model for this flow run
340
+ electron: true prefer the desktop companion sim for this flow
341
+
342
+ default runtime:
343
+ bridge-backed flow playback against the current sim
344
+ if no current sim exists, flow opens the discovered target first
345
+ recording and profiling both run on the same bridge-backed path
346
+
347
+ examples:
348
+ sootsim flow login.yaml
349
+ sootsim flow demo.yaml --url 8081 --record --slow 500 --out ./recordings
350
+ sootsim flow demo.yaml --sim a2
351
+ sootsim flow start
352
+ sootsim flow keep
353
+ sootsim flow end --output ./flows/draft.yaml
354
+ sootsim flow end --output ./flows/draft.yaml --validate
355
+ sootsim flow end --output ./flows/draft.yaml --video
356
+ sootsim flow validate ./flows/draft.yaml
357
+
358
+ flow extension:
359
+ takeScreenshot: hero
360
+ takeScreenshot:
361
+ path: marketing/hero
362
+ withFrame: true
363
+ `),process.exit(0));let e=o[0];O.existsSync(e)||(console.error(` error: ${e} not found`),process.exit(1));let t=f=>o.find((u,y)=>o[y-1]===f),n=o.includes("--profile"),i=o.includes("--headed"),r=o.includes("--new")||i,s=t("--out")||"/tmp/sootsim-recordings",a=t("--screenshots")||(t("--out")?s:"/tmp/sootsim-flow"),l=t("--screenshot-paths")==="flow"?"flow":"dir",p=o.includes("--no-shell")?"tenant":o.includes("--shell-only")?"shell":void 0,d=t("--device")?.trim()||"",m=o.includes("--slow")?+(t("--slow")||"500"):0,P=o.includes("--electron"),w=o.includes("--preview"),_=await Je(t("--preview-origin")),pe=t("--preview-public-origin"),Xe=o.includes("--preview-open"),he=t("--owner")?.trim()||"",me=t("--repo")?.trim()||"",Ze=o.flatMap((f,u)=>o[u-1]==="--replace"?["--replace",f]:[]),Qe=o.flatMap((f,u)=>o[u-1]==="--remap"?["--remap",f]:[]),I=o.includes("--record")||w,et=o.includes("--tail-wait")?Math.max(0,+(t("--tail-wait")||"2000")):I?w?6e3:2e3:0,tt=O.readFileSync(e,"utf8"),{frontmatter:x,steps:$}=se(tt);$.length===0&&(console.error(" error: flow file must contain a YAML array of steps"),process.exit(1));let D=d||x.device||"",j=P||x.electron===!0,nt=x.app===void 0||x.app===null?"":typeof x.app=="number"?String(x.app):x.app,z=await bt(nt),we={stripBooleanFlags:["--record","--profile","--electron","--new","--preview","--preview-open","--headless","--headed"],stripValueFlags:["--out","--device","--slow","--tail-wait","--url","--replace","--remap","--screenshots","--screenshot-paths","--preview-origin","--preview-public-origin","--driver"]},S=ie(o,we),it=t("--url")||"";j&&!_e()&&(console.error(" error: desktop companion not found. install or build it first with `bun run build:electron`"),process.exit(1));let ge=j?"desktop companion":"bridge",rt=z?` | target: ${z}`:"";console.log(`
364
+ sootsim flow \u2014 ${b.basename(e)}
365
+ ${$.length} steps | ${ge}${rt}${I?" | recording":""}${n?" | profiling":""}${m?` | ${m}ms delay`:""}
366
+ `),w&&xe({event:"preview_flow_started",properties:{flowName:b.basename(e),stepCount:$.length,mode:ge,electron:j,record:I,profile:n,previewOrigin:_}});let k=it||z||"",Y=r||j&&S.simIdSource!=="flag",ye=t("--driver")||"",X=!1,Z=new Set,be=!1;if(!k&&!Y&&S.simIdSource==="none"){let f=Me(S);try{let u=await f.listSims(),y=u.find(J=>J.isPrimary&&J.readyState==="open"),U=u.find(J=>J.readyState==="open"),Se=y??U;Se&&(be=!0,console.log(` reusing active sim: ${Se.id}`))}catch{}finally{f.close()}}if(!k&&!be&&(Y||S.simIdSource==="none")){let f=await vt();f||(console.error(" error: no current sim and no sootsim target found"),await ee(),process.exit(1)),k=f}if(k&&D){let f=new URL(await De(k));f.searchParams.set("device",D),k=f.toString()}if(k){let f=[k];if(f.push(...Ze),f.push(...Qe),Y&&f.push("--new"),f.push("--no-describe"),S.simIdSource==="flag"&&S.simId&&f.push("--sim",S.simId),ye&&(f.push("--driver",ye),X=!0),o.includes("--headless")&&!i&&f.push("--headless"),await Ne(f,{port:S.wsPort,timeoutMs:S.commandTimeoutMs}),X){let u=te();u&&Z.add(u)}}let A=ie(o,we),L=A.simIdSource==="flag"?A.simId:te()||A.simId,ot=A.simIdSource==="flag"?"flag":L?"saved":"none",E=re(A.wsPort,{commandTimeoutMs:A.commandTimeoutMs,simId:L,simIdSource:ot}),c,ve=async()=>{if(!D)return!1;let f=await E.send({type:"evaluate",simId:c.simId,code:"window.location.href"});if(typeof f=="string"&&f.length>0){let u=new URL(f);u.searchParams.set("device",D),c.setSimRouteHint(u.toString())}return!!await E.send({type:"call",simId:c.simId,path:"SootSim.bridges.settings.set",args:["deviceModel",D]})};if(c=new G(E,{screenshotDir:a,flowDir:b.dirname(b.resolve(e)),screenshotPathMode:l,screenshotLayers:p,simId:L,recordingOutputDir:I?s:void 0,recordingFormat:w?"mp4":"webm",billingOriginOverride:w?_:void 0,allowGitHubRecording:I,onAfterLaunch:async()=>{await ve()&&await c.waitForTree(12e4),w&&await E.send({type:"evaluate",simId:c.simId,code:`(() => {
367
+ const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
368
+ return r?.start?.() ?? false
369
+ })()`})}}),m&&(c.stepDelay=m),c.js.putEnv("MAESTRO_FILENAME",b.basename(e,b.extname(e))),x.env&&typeof x.env=="object")for(let[f,u]of Object.entries(x.env))c.js.putEnv(f,u);let F=null,T=null,C=null,Q=null,V=0,W=!!$[0]?.launchApp;try{W||await c.waitForTree(12e4),await ve()&&!W&&await c.waitForTree(12e4),w&&!W&&!process.env.SOOTSIM_PREVIEW_RESET_DONE&&await c.launchApp({clearState:!0}),I&&(W?c.prepareRecording():await c.startRecording()),n&&await c.startProfile(),w&&(await E.send({type:"evaluate",simId:c.simId,code:`(() => {
370
+ const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
371
+ return r?.start?.() ?? false
372
+ })()`})||console.warn(" warn: eventRecorder.start() returned false \u2014 preview will upload bundle without replay events")),await c.runFlow($),n&&(F=await c.stopProfile()),await c.waitForRecordingTail({maxMs:et,smart:w}),I&&(T=await c.stopRecording(),C=c.getLastRecordingDurationMs()),w&&(Q=await E.send({type:"evaluate",simId:c.simId,code:`(() => {
373
+ const r = window.SootSim?.bridges?.eventRecorder ?? window.__sootsimEventRecorder
374
+ return r?.stop?.() ?? []
375
+ })()`}),console.log(` captured ${Q.length} replay events`));let u=$.filter(y=>y&&typeof y=="object"&&"takeScreenshot"in y).length;console.log(`
376
+ + completed (${$.length} steps)`),u>0&&console.log(` screenshots: ${u} \u2192 ${a}`),F&&Ge(F),T&&console.log(` video: ${T}`),console.log()}catch(f){if(n&&!F)try{F=await c.stopProfile()}catch{}if(I&&!T)try{T=await c.stopRecording(),C=c.getLastRecordingDurationMs()}catch(u){console.warn(` recording stop failed: ${u?.message||String(u)}`)}console.error(`
377
+ x failed: ${f.message}
378
+ `),F&&(console.log(" partial profile:"),Ge(F)),T&&console.log(` partial video: ${T}`);try{let u=c.lastFailedStep,y=u?`step-${String(u.index+1).padStart(2,"0")}-${u.kind}`:"unstaged",U=b.join(a,y);await c.captureFailureBundle(U,{error:f,stepIndex:u?.index,stepKind:u?.kind,stepTarget:u?.target}),console.log(` failure bundle: ${U}`),console.log(" (contents: screenshot.png, describe.json, a11y.txt, tree.txt, console.json, error.json)")}catch(u){try{let y=b.join(a,"error.png");await c.captureFailureScreenshot(y),console.log(` error screenshot: ${y}`)}catch{}console.log(` (failure bundle capture failed: ${u instanceof Error?u.message:String(u)})`)}await Oe(E,{errorsCommand:`sootsim get errors 5${c.simId?` --sim ${c.simId}`:""}`,warningsCommand:`sootsim get warnings 5${c.simId?` --sim ${c.simId}`:""}`,requestsCommand:`sootsim get requests 5${c.simId?` --sim ${c.simId}`:""}`}),V=1}finally{E.close()}if(V===0&&w)try{let f=await xt(Q??[]),u=["--origin",_,"--events",f];pe&&u.push("--public-origin",pe),T&&u.push("--video",T),T&&C&&Number.isFinite(C)&&u.push("--video-duration-ms",String(Math.round(C))),c.simId&&u.push("--sim",c.simId),Xe&&u.push("--open"),he&&u.push("--owner",he),me&&u.push("--repo",me),console.log(`
379
+ preparing preview upload\u2026`);let{runUpload:y}=await import("./upload-6C2EC56N.js");await y(u,{})}catch(f){console.error(` preview upload failed: ${f?.message||f}`),V=1}return X?(c.simId&&Z.add(c.simId),await St(S.wsPort,S.commandTimeoutMs,[...Z])):c.simId&&c.simId!==L&&Ie(c.simId),await ee(),V}async function St(o,e,t){let n=[...new Set(t.filter(Boolean))];if(n.length===0)return;let i=re(o,{commandTimeoutMs:e});try{let r=await i.listSims(),s=n.filter(l=>r.some(p=>p.id===l&&p.readyState==="open"));if(s.length===0)return;let a=await Be(i,o,e,s);await Ce(r,s),a.closed.length>0&&console.log(` closed flow sim(s): ${a.closed.join(", ")}`),a.remaining.length>0&&console.warn(` warn: flow sim(s) still connected after close: ${a.remaining.join(", ")}`)}catch(r){console.warn(` warn: failed to close flow sim(s): ${r instanceof Error?r.message:String(r)}`)}finally{i.close()}}async function xt(o){let{gzipSync:e}=await import("zlib"),t=o.map(r=>JSON.stringify(r)).join(`
380
+ `)+(o.length?`
381
+ `:""),n=e(Buffer.from(t,"utf8")),i=b.join(ze(),`sootsim-events-${Date.now()}.jsonl.gz`);return O.writeFileSync(i,n),console.log(` events: ${o.length} written to ${i} (${n.length} bytes gz)`),i}async function Tt(o){let e=o[0],t=n=>o.find((i,r)=>o[r-1]===n);switch(e){case"start":{let{path:n,state:i}=Le();console.log(" flow draft started"),console.log(` session: ${n}`),console.log(` steps: ${i.steps.length}`);return}case"keep":case"good":{let n=de();if(n.active||(console.error(" no active flow draft \u2014 run `sootsim flow start` first"),process.exit(1)),!n.kept){console.log(" no pending action to keep");return}console.log(` kept: ${n.candidate.summary}`),console.log(` steps: ${n.stepCount}`);return}case"end":{let n=t("--output")||(o[1]&&!o[1].startsWith("-")?o[1]:void 0),i=o.includes("--validate")||o.includes("--video"),r=o.includes("--video"),s=de();s.active&&s.kept&&console.log(` auto-kept trailing action: ${s.candidate.summary}`);let a=Ve(n||(i?kt():void 0));if(a.active||(console.error(" no active flow draft \u2014 run `sootsim flow start` first"),process.exit(1)),!a.valid){console.error(" flow draft is not valid:");for(let l of a.issues)console.error(` - ${l}`);console.error(" draft preserved \u2014 keep at least one real interaction or run `sootsim flow start` to reset"),process.exit(1)}if(i){let l=Et(o,a.outputPath),p=await Ye(l);if(p!==0){console.error(`
382
+ validation failed \u2014 draft preserved so you can keep iterating`),process.exitCode=p;return}le(),console.log(` flow draft validated (${a.stepCount} step${a.stepCount===1?"":"s"})`),a.outputPath&&console.log(` saved: ${a.outputPath}`),r&&console.log(" video: recorded during validation run");return}if(le(),console.log(` flow draft ended (${a.stepCount} step${a.stepCount===1?"":"s"})`),a.outputPath){console.log(` saved: ${a.outputPath}`),console.log(` next: sootsim flow ${a.outputPath} --record`);return}console.log(""),process.stdout.write(a.yaml);return}case"validate":{let n=o[1];(!n||n.startsWith("-"))&&(console.error(" usage: sootsim flow validate <path>"),process.exit(1));let i=ae(n);if(i.length>0){console.error(` x ${n} failed validation:`);for(let r of i)console.error(` - ${r}`);process.exit(1)}console.log(` + ${n} looks valid`);return}}}function It(o){return o[0]==="--sim"&&o.length>=2?[...o.slice(2),"--sim",o[1]]:o}async function Qt(o){let e=It(o),t=e[0];if(t==="start"||t==="keep"||t==="good"||t==="end"||t==="validate")return await Tt(e),0;let n=await Ye(e);return n!==0&&(process.exitCode=n),n}function Ge(o){console.log(""),We(o)}function kt(){return b.join(ze(),`sootsim-flow-draft-${Date.now()}.yaml`)}function Et(o,e){if(!e)throw new Error("validated flow draft requires an output path");let t=[e];for(let n=1;n<o.length;n++){let i=o[n];if(!(i==="--validate"||i==="--video")){if(i==="--output"){n+=1;continue}n===1&&!i.startsWith("-")||t.push(i)}}return!t.includes("--record")&&o.includes("--video")&&t.push("--record"),t}export{vt as a,Ye as b,It as c,Qt as d};
@@ -1,3 +1,3 @@
1
- /*! sootsim v0.1.185 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as s}from"./chunk-LJ3SOZBF.js";import{o}from"./chunk-BI56RR3G.js";import{chmodSync as p,existsSync as d,mkdirSync as g,readFileSync as I,rmSync as f,writeFileSync as _}from"node:fs";import{dirname as y,join as h,resolve as k}from"node:path";function i(){return h(o(),"credentials.json")}function S(){let n=i();if(!d(n))return null;try{let t=JSON.parse(I(n,"utf8"));return t.version!==1||typeof t.apiKey!="string"||!t.apiKey.startsWith("sk_sootsim_")?null:t.apiKey}catch{return null}}function w(n){if(!n.startsWith("sk_sootsim_"))throw new Error("api key must start with sk_sootsim_");let t=i();g(y(k(t)),{recursive:!0}),_(t,JSON.stringify({version:1,apiKey:n,savedAt:new Date().toISOString()},null,2)+`
1
+ /*! sootsim v0.1.186 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as s}from"./chunk-RAY2ZSNI.js";import{o}from"./chunk-FUHNIWFL.js";import{chmodSync as p,existsSync as d,mkdirSync as g,readFileSync as I,rmSync as f,writeFileSync as _}from"node:fs";import{dirname as y,join as h,resolve as k}from"node:path";function i(){return h(o(),"credentials.json")}function S(){let n=i();if(!d(n))return null;try{let t=JSON.parse(I(n,"utf8"));return t.version!==1||typeof t.apiKey!="string"||!t.apiKey.startsWith("sk_sootsim_")?null:t.apiKey}catch{return null}}function w(n){if(!n.startsWith("sk_sootsim_"))throw new Error("api key must start with sk_sootsim_");let t=i();g(y(k(t)),{recursive:!0}),_(t,JSON.stringify({version:1,apiKey:n,savedAt:new Date().toISOString()},null,2)+`
3
3
  `);try{p(t,384)}catch{}}function E(){f(i(),{force:!0})}var m=["ghs_","ghp_","gho_","ghu_","github_pat_"];function O(n){return!!(n&&n.length>=20&&m.some(t=>n.startsWith(t)))}function A(){let n=process.env.SOOT_INSTALLATION_TOKEN?.trim(),t=process.env.GITHUB_TOKEN?.trim(),r=n||t;if(!O(r))return null;let e=(process.env.SOOT_REPO||process.env.GITHUB_REPOSITORY||"").trim();if(!e)return null;let[l,u]=e.includes("/")?e.split("/",2):[null,null],c=(process.env.SOOT_REPO_ID||process.env.GITHUB_REPOSITORY_ID||"").trim(),a=(process.env.SOOT_INSTALLATION_ID||process.env.GITHUB_APP_INSTALLATION_ID||"").trim();return{kind:"github",token:r,repoId:e,repositoryId:c||null,owner:l||null,repo:u||null,installationId:a||null,source:n?"soot-runner":"github-actions"}}function x(){let n=process.env.SOOTSIM_API_KEY?.trim();if(n&&n.startsWith("sk_sootsim_"))return{kind:"api-key",secret:n,source:"env"};let t=A();if(t)return t;let r=S();if(r)return{kind:"api-key",secret:r,source:"file"};let e=s();return e?.token?{kind:"session",token:e.token,origin:e.origin}:null}function H(n){return n.kind==="api-key"?`Bearer ${n.secret}`:`Bearer ${n.token}`}function N(n){return!n||n.kind!=="github"?null:{repoId:n.repoId,owner:n.owner??void 0,repo:n.repo??void 0,installationId:n.installationId}}export{S as a,w as b,E as c,x as d,H as e,N as f};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.185 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as u,b as w}from"./chunk-BMCBPMTC.js";import{a as h,b as g,c as v}from"./chunk-HQG4DRQ3.js";import{a as m,c as f}from"./chunk-WBY4JJ2K.js";import{c as p}from"./chunk-E5DE33BU.js";function x(){let e=h();return e?{available:!0,reason:null,detail:e}:{available:!1,reason:"no chromium-family browser found (chrome, chromium, edge, brave, arc)"}}async function I(e){if(e.headless)return{launched:!1,message:"the chromium driver launches a visible browser window and cannot run headless \u2014 a headless `chrome --headless=new` process exits immediately and the sim never connects. for headless automation use `--driver playwright`."};let r=h();if(!r)return{launched:!1,message:"chromium not found \u2014 install chrome or run `sootsim list --drivers`"};if(!e.url)return{launched:!1,message:"chromium driver requires a target url"};if(e.profileId||e.ephemeralProfile)return{launched:!1,message:"profiles require electron or playwright; browser tabs use your current Chrome profile"};try{let t=await v(e.url,{detached:e.detached??!0});return{launched:!0,message:`chromium launched \u2192 ${e.url}`,pid:t.pid,target:t.target??r,attachUrl:e.url}}catch(t){return{launched:!1,message:`chromium spawn failed: ${t instanceof Error?t.message:String(t)}`}}}var y={id:"chromium",name:"chromium",description:"system chrome / chromium / edge \u2014 visible window (headless: use playwright)",kind:"browser",availability:x,launch:I};function _(){let e=u();return e?{available:!0,reason:null,detail:`${e.kind} @ ${e.path}`}:{available:!1,reason:"sootsim desktop app not installed (run `sootsim install-desktop`)"}}async function M(e){let r=u();if(!r)return{launched:!1,message:"sootsim desktop app not installed"};try{let t=await w(e.url,r,{device:e.device,profileId:e.profileId,ephemeralProfile:e.ephemeralProfile});return t.launched?{launched:!0,message:e.url?`electron launched via ${t.via} \u2192 ${e.url}`:`electron launched via ${t.via}`,target:t.target,attachUrl:e.url}:{launched:!1,message:"desktop companion failed to start"}}catch(t){return{launched:!1,message:`electron launch failed: ${t instanceof Error?t.message:String(t)}`}}}var b={id:"electron",name:"electron",description:"sootsim desktop companion app (native window, menu bar)",kind:"native",availability:_,launch:M};import{spawn as C}from"child_process";import{closeSync as A,mkdtempSync as E,openSync as L,readFileSync as W}from"fs";import{createRequire as R}from"module";import{tmpdir as P}from"os";import{join as S}from"path";var N=`
1
+ /*! sootsim v0.1.186 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as u,b as w}from"./chunk-INIASYOZ.js";import{a as h,b as g,c as v}from"./chunk-PTUTIFWJ.js";import{a as m,c as f}from"./chunk-ZE2O7AA5.js";import{c as p}from"./chunk-LV7DFIBL.js";function T(){let e=h();return e?{available:!0,reason:null,detail:e}:{available:!1,reason:"no chromium-family browser found (chrome, chromium, edge, brave, arc)"}}async function I(e){if(e.headless)return{launched:!1,message:"the chromium driver launches a visible browser window and cannot run headless \u2014 a headless `chrome --headless=new` process exits immediately and the sim never connects. for headless automation use `--driver playwright`."};let r=h();if(!r)return{launched:!1,message:"chromium not found \u2014 install chrome or run `sootsim list --drivers`"};if(!e.url)return{launched:!1,message:"chromium driver requires a target url"};if(e.profileId||e.ephemeralProfile)return{launched:!1,message:"profiles require electron or playwright; browser tabs use your current Chrome profile"};try{let t=await v(e.url,{detached:e.detached??!0});return{launched:!0,message:`chromium launched \u2192 ${e.url}`,pid:t.pid,target:t.target??r,attachUrl:e.url}}catch(t){return{launched:!1,message:`chromium spawn failed: ${t instanceof Error?t.message:String(t)}`}}}var y={id:"chromium",name:"chromium",description:"system chrome / chromium / edge \u2014 visible window (headless: use playwright)",kind:"browser",availability:T,launch:I};function _(){let e=u();return e?{available:!0,reason:null,detail:`${e.kind} @ ${e.path}`}:{available:!1,reason:"sootsim desktop app not installed (run `sootsim install-desktop`)"}}async function M(e){let r=u();if(!r)return{launched:!1,message:"sootsim desktop app not installed"};try{let t=await w(e.url,r,{device:e.device,profileId:e.profileId,ephemeralProfile:e.ephemeralProfile});return t.launched?{launched:!0,message:e.url?`electron launched via ${t.via} \u2192 ${e.url}`:`electron launched via ${t.via}`,target:t.target,attachUrl:e.url}:{launched:!1,message:"desktop companion failed to start"}}catch(t){return{launched:!1,message:`electron launch failed: ${t instanceof Error?t.message:String(t)}`}}}var b={id:"electron",name:"electron",description:"sootsim desktop companion app (native window, menu bar)",kind:"native",availability:_,launch:M};import{spawn as C}from"child_process";import{closeSync as E,mkdtempSync as A,openSync as L,readFileSync as W}from"fs";import{createRequire as R}from"module";import{tmpdir as S}from"os";import{join as P}from"path";var N=`
3
3
  const modulePath = process.env.SOOTSIM_PW_MODULE;
4
4
  const url = process.env.SOOTSIM_PW_URL;
5
5
  const headless = process.env.SOOTSIM_PW_HEADLESS === '1';
@@ -18,6 +18,13 @@ const cdpPort = process.env.SOOTSIM_PW_CDP_PORT || '';
18
18
  // iOS Safari proxy \u2014 headless webkit keeps the real Apple GPU while headless
19
19
  // chromium falls back to SwiftShader software rendering for canvas/WebGL.
20
20
  const browserEngine = process.env.SOOTSIM_PW_BROWSER || 'chromium';
21
+ // page viewport as '<w>x<h>'. the caller sizes it from the device profile;
22
+ // the fallback is phone-shaped because the page hosts a phone sim \u2014 the
23
+ // playwright default (1280x720 desktop) letterboxes the device frame.
24
+ const viewportSpec = /^(\\d+)x(\\d+)$/.exec(process.env.SOOTSIM_PW_VIEWPORT || '');
25
+ const viewport = viewportSpec
26
+ ? { width: Number(viewportSpec[1]), height: Number(viewportSpec[2]) }
27
+ : { width: 600, height: 900 };
21
28
  const closeTimeoutMs = Number(process.env.SOOTSIM_PW_CLOSE_TIMEOUT_MS || 2500);
22
29
  const connectAckFile = process.env.SOOTSIM_PW_CONNECTED_ACK_FILE || '';
23
30
  const { existsSync, mkdtempSync, rmSync, unlinkSync } = require('fs');
@@ -219,7 +226,7 @@ const cleanupProfile = () => {
219
226
  // persistent-context profile dir still appears on the root process
220
227
  // cmdline (--user-data-dir / -profile), which is what reapChrome()'s
221
228
  // pgrep sweep keys on; helpers die via the recursive killTree.
222
- context = await pw[browserEngine].launchPersistentContext(profileDir, { headless });
229
+ context = await pw[browserEngine].launchPersistentContext(profileDir, { headless, viewport });
223
230
  process.stderr.write('[playwright-driver] launched ' + browserEngine + '\\n');
224
231
  } else {
225
232
  const pinnedChannel = process.env.SOOTSIM_PW_CHANNEL || '';
@@ -227,7 +234,7 @@ const cleanupProfile = () => {
227
234
  ? [pinnedChannel]
228
235
  : ['chrome', null]; // null = bundled chromium
229
236
  const launchWith = async (channel) => {
230
- const opts = channel ? { headless, channel } : { headless };
237
+ const opts = channel ? { headless, channel, viewport } : { headless, viewport };
231
238
  // headless chromium backgrounds/occludes the renderer and throttles rAF +
232
239
  // timers to ~1fps, which silently starves combined/video frame capture
233
240
  // (was 47 frames over 63s -> frozen-looking mp4). keep the render loop at
@@ -240,6 +247,10 @@ const cleanupProfile = () => {
240
247
  '--disable-renderer-backgrounding',
241
248
  ];
242
249
  if (cdpPort) opts.args.push('--remote-debugging-port=' + cdpPort);
250
+ // headed: size the OS window to the (phone-shaped) viewport too, plus
251
+ // room for chrome's own toolbar, so the window isn't desktop-shaped
252
+ // around a letterboxed page.
253
+ if (!headless) opts.args.push('--window-size=' + viewport.width + ',' + (viewport.height + 88));
243
254
  // ALWAYS persistent: every chrome process inherits --user-data-dir=<dir>
244
255
  // in its cmdline, which is how reapChrome() finds the whole tree (root +
245
256
  // helpers) on shutdown. without a unique dir there is no way to attribute
@@ -332,6 +343,6 @@ const cleanupProfile = () => {
332
343
  process.stderr.write(String((err && err.stack) || err) + '\\n');
333
344
  process.exit(1);
334
345
  });
335
- `;function D(){let e=[process.cwd()+"/"];try{process.argv[1]&&e.push(process.argv[1])}catch{}for(let r of e)try{let t=R(r);for(let n of["playwright","playwright-chromium","playwright-core"])try{return{spec:n,modulePath:t.resolve(n)}}catch{}}catch{}return null}function U(){let e=D();return e?{available:!0,reason:null,detail:`resolved via ${e.spec}`}:{available:!1,reason:"playwright not installed in the current workspace"}}function $(e,r){return process.platform!=="linux"||e.headless||process.env.DISPLAY||process.env.WAYLAND_DISPLAY||!/missing x server|cannot open display|x server|x11/i.test(r)?null:" hint: linux without DISPLAY/WAYLAND_DISPLAY \u2014 rerun without --headed (or add --headless) to run playwright headless."}function F(e){return e.profileId?m(f(e.profileId).id):e.ephemeralProfile?E(S(P(),"sootsim-playwright-profile-")):""}async function q(e){let r=D();if(!r)return{launched:!1,message:"playwright not installed \u2014 run `bun add -D playwright` first"};if(!e.url)return{launched:!1,message:"playwright driver requires a target url"};let t=S(P(),`sootsim-playwright-host-${Date.now().toString(36)}-${process.pid}.log`),n=`${t}.connected`,a=L(t,"a");try{let o=p(),c=C(process.execPath,["-e",N],{detached:!0,stdio:["ignore","ignore",a],env:{...process.env,SOOTSIM_PW_MODULE:r.modulePath,SOOTSIM_PW_URL:e.url,SOOTSIM_PW_HEADLESS:e.headless??!0?"1":"0",SOOTSIM_PW_USERDATADIR:F(e),SOOTSIM_PW_CDP_PORT:e.cdpPort?String(e.cdpPort):"",SOOTSIM_PW_BROWSER:e.browser??"",SOOTSIM_PW_CONNECTED_ACK_FILE:n,SOOTSIM_PW_CONNECT_TIMEOUT_MS:String(e.connectTimeoutMs??12e4),SOOTSIM_PW_OWNER_PID:o&&o>1?String(o):""}});c.unref();let d=await new Promise(i=>{let l=setTimeout(()=>i(null),4e3);c.once("exit",T=>{clearTimeout(l),i(T??0)})});if(d!==null){let i=W(t,"utf8").trim(),l=$(e,i);return{launched:!1,message:`playwright host exited early (code ${d}) \u2014 host log ${t}${i?`:
346
+ `;function k(){let e=[process.cwd()+"/"];try{process.argv[1]&&e.push(process.argv[1])}catch{}for(let r of e)try{let t=R(r);for(let o of["playwright","playwright-chromium","playwright-core"])try{return{spec:o,modulePath:t.resolve(o)}}catch{}}catch{}return null}function $(){let e=k();return e?{available:!0,reason:null,detail:`resolved via ${e.spec}`}:{available:!1,reason:"playwright not installed in the current workspace"}}function U(e,r){return process.platform!=="linux"||e.headless||process.env.DISPLAY||process.env.WAYLAND_DISPLAY||!/missing x server|cannot open display|x server|x11/i.test(r)?null:" hint: linux without DISPLAY/WAYLAND_DISPLAY \u2014 rerun without --headed (or add --headless) to run playwright headless."}function F(e){return e.profileId?m(f(e.profileId).id):e.ephemeralProfile?A(P(S(),"sootsim-playwright-profile-")):""}async function q(e){let r=k();if(!r)return{launched:!1,message:"playwright not installed \u2014 run `bun add -D playwright` first"};if(!e.url)return{launched:!1,message:"playwright driver requires a target url"};let t=P(S(),`sootsim-playwright-host-${Date.now().toString(36)}-${process.pid}.log`),o=`${t}.connected`,a=L(t,"a");try{let n=p(),c=C(process.execPath,["-e",N],{detached:!0,stdio:["ignore","ignore",a],env:{...process.env,SOOTSIM_PW_MODULE:r.modulePath,SOOTSIM_PW_URL:e.url,SOOTSIM_PW_HEADLESS:e.headless??!0?"1":"0",SOOTSIM_PW_USERDATADIR:F(e),SOOTSIM_PW_CDP_PORT:e.cdpPort?String(e.cdpPort):"",SOOTSIM_PW_BROWSER:e.browser??"",SOOTSIM_PW_VIEWPORT:e.viewport?`${e.viewport.width}x${e.viewport.height}`:"",SOOTSIM_PW_CONNECTED_ACK_FILE:o,SOOTSIM_PW_CONNECT_TIMEOUT_MS:String(e.connectTimeoutMs??12e4),SOOTSIM_PW_OWNER_PID:n&&n>1?String(n):""}});c.unref();let d=await new Promise(i=>{let l=setTimeout(()=>i(null),4e3);c.once("exit",x=>{clearTimeout(l),i(x??0)})});if(d!==null){let i=W(t,"utf8").trim(),l=U(e,i);return{launched:!1,message:`playwright host exited early (code ${d}) \u2014 host log ${t}${i?`:
336
347
  ${i}`:""}${l?`
337
- ${l}`:""}`}}return{launched:!0,message:`playwright chrome launched \u2192 ${e.url}`,pid:c.pid,target:r.spec,attachUrl:e.url,connectAckFile:n,diagnosticLogPath:t}}catch(o){return{launched:!1,message:`playwright launch failed: ${o instanceof Error?o.message:String(o)}`}}finally{A(a)}}var k={id:"playwright",name:"playwright",description:"programmatic chromium via the playwright package \u2014 headless default",kind:"automation",availability:U,launch:q};function H(){return process.platform!=="darwin"&&process.platform!=="linux"&&process.platform!=="win32"?{available:!1,reason:`unsupported platform: ${process.platform}`}:{available:!0,reason:null,detail:process.platform==="darwin"?"open(1)":process.platform==="win32"?"cmd /c start":"xdg-open(1)"}}async function G(e){if(e.headless)return{launched:!1,message:"system driver does not support --headless; use chromium or playwright"};if(!e.url)return{launched:!1,message:"system driver requires a target url"};if(e.profileId||e.ephemeralProfile)return{launched:!1,message:"profiles require electron or playwright; browser tabs use your current browser profile"};try{let r=await g(e.url,{detached:e.detached??!0,newWindow:e.newWindow});return{launched:!0,message:`${r.via} launch \u2192 ${e.url}`,pid:r.pid,target:r.target,attachUrl:e.url}}catch(r){return{launched:!1,message:`system launch failed: ${r instanceof Error?r.message:String(r)}`}}}var O={id:"system",name:"system",description:"shared browser launcher \u2014 system default or chromium window",kind:"delegate",availability:H,launch:G};var s=[y,b,k,O];function le(){return s}function ce(e){return s.find(r=>r.id===e)??null}function ue(e,r){if(e)return s.find(n=>n.id===e)??null;for(let t of r){let n=s.find(a=>a.id===t);if(n&&n.availability().available)return n}return null}function he(){return s.map(e=>{let r=e.availability();return{id:e.id,name:e.name,kind:e.kind,description:e.description,available:r.available,reason:r.reason,detail:r.detail??null}})}export{y as a,b,k as c,O as d,s as e,le as f,ce as g,ue as h,he as i};
348
+ ${l}`:""}`}}return{launched:!0,message:`playwright chrome launched \u2192 ${e.url}`,pid:c.pid,target:r.spec,attachUrl:e.url,connectAckFile:o,diagnosticLogPath:t}}catch(n){return{launched:!1,message:`playwright launch failed: ${n instanceof Error?n.message:String(n)}`}}finally{E(a)}}var D={id:"playwright",name:"playwright",description:"programmatic chromium via the playwright package \u2014 headless default",kind:"automation",availability:$,launch:q};function H(){return process.platform!=="darwin"&&process.platform!=="linux"&&process.platform!=="win32"?{available:!1,reason:`unsupported platform: ${process.platform}`}:{available:!0,reason:null,detail:process.platform==="darwin"?"open(1)":process.platform==="win32"?"cmd /c start":"xdg-open(1)"}}async function G(e){if(e.headless)return{launched:!1,message:"system driver does not support --headless; use chromium or playwright"};if(!e.url)return{launched:!1,message:"system driver requires a target url"};if(e.profileId||e.ephemeralProfile)return{launched:!1,message:"profiles require electron or playwright; browser tabs use your current browser profile"};try{let r=await g(e.url,{detached:e.detached??!0,newWindow:e.newWindow});return{launched:!0,message:`${r.via} launch \u2192 ${e.url}`,pid:r.pid,target:r.target,attachUrl:e.url}}catch(r){return{launched:!1,message:`system launch failed: ${r instanceof Error?r.message:String(r)}`}}}var O={id:"system",name:"system",description:"shared browser launcher \u2014 system default or chromium window",kind:"delegate",availability:H,launch:G};var s=[y,b,D,O];function le(){return s}function ce(e){return s.find(r=>r.id===e)??null}function ue(e,r){if(e)return s.find(o=>o.id===e)??null;for(let t of r){let o=s.find(a=>a.id===t);if(o&&o.availability().available)return o}return null}function he(){return s.map(e=>{let r=e.availability();return{id:e.id,name:e.name,kind:e.kind,description:e.description,available:r.available,reason:r.reason,detail:r.detail??null}})}export{y as a,b,D as c,O as d,s as e,le as f,ce as g,ue as h,he as i};
@@ -1,5 +1,5 @@
1
- /*! sootsim v0.1.185 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
- import{a as p}from"./chunk-ARNLQPMQ.js";import{d as c,e as l}from"./chunk-PKZNXDUJ.js";import{a}from"./chunk-LJ3SOZBF.js";async function g(e,t){if(t)return t.replace(/\/$/,"");if(e.kind==="session"&&e.origin)return e.origin.replace(/\/$/,"");let i=a();return i?.origin?i.origin.replace(/\/$/,""):(await p()).replace(/\/$/,"")}async function m(e,t={}){let i=c();if(i||(process.stderr.write(`
1
+ /*! sootsim v0.1.186 | (c) 2026 Tamagui LLC | Proprietary — see LICENSE */
2
+ import{a as p}from"./chunk-353E6UCU.js";import{d as c,e as l}from"./chunk-TYV3FMBE.js";import{a}from"./chunk-RAY2ZSNI.js";async function g(e,t){if(t)return t.replace(/\/$/,"");if(e.kind==="session"&&e.origin)return e.origin.replace(/\/$/,"");let i=a();return i?.origin?i.origin.replace(/\/$/,""):(await p()).replace(/\/$/,"")}async function m(e,t={}){let i=c();if(i||(process.stderr.write(`
3
3
  sootsim ${e} needs auth before it can check recording access.
4
4
 
5
5
  pick one: