@kaeawc/auto-mobile 0.0.90 → 0.0.92

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 (280) hide show
  1. package/README.md +7 -0
  2. package/README.md.backup +7 -0
  3. package/dist/build-info.json +12 -11
  4. package/dist/schemas/README.md +16 -0
  5. package/dist/schemas/prototype-icon-names.json +302 -0
  6. package/dist/schemas/prototype-platform-permissions.json +75 -0
  7. package/dist/schemas/test-plan.schema.json +2 -2
  8. package/dist/src/chunk-09442h7v.js +4 -0
  9. package/dist/src/chunk-0dfnyfkh.js +5 -0
  10. package/dist/src/chunk-0e4gm1kj.js +5 -0
  11. package/dist/src/chunk-0eb8576f.js +4 -0
  12. package/dist/src/chunk-0rjm4nx7.js +5 -0
  13. package/dist/src/chunk-0w1spptt.js +6 -0
  14. package/dist/src/chunk-1zmh2eak.js +4 -0
  15. package/dist/src/chunk-28k63ha3.js +5 -0
  16. package/dist/src/chunk-2d4wmp8b.js +4 -0
  17. package/dist/src/chunk-2e6s75qv.js +78 -0
  18. package/dist/src/chunk-2v7tw1nj.js +5 -0
  19. package/dist/src/chunk-32jpxz2y.js +323 -0
  20. package/dist/src/chunk-34zxqcmq.js +5 -0
  21. package/dist/src/chunk-3jmvqygr.js +238 -0
  22. package/dist/src/chunk-3swvfhqt.js +5 -0
  23. package/dist/src/chunk-44bt78m9.js +5 -0
  24. package/dist/src/chunk-488vt2bp.js +4 -0
  25. package/dist/src/chunk-4fgdhcwx.js +5 -0
  26. package/dist/src/chunk-4jp2se4w.js +4 -0
  27. package/dist/src/chunk-4pfftt07.js +5 -0
  28. package/dist/src/chunk-4vhr9e4t.js +4 -0
  29. package/dist/src/chunk-4xd6zs3y.js +15 -0
  30. package/dist/src/chunk-51567pg8.js +4 -0
  31. package/dist/src/chunk-5agqsfev.js +4 -0
  32. package/dist/src/chunk-5d706gmr.js +4 -0
  33. package/dist/src/chunk-5kd4rqk7.js +5 -0
  34. package/dist/src/chunk-5s645vr4.js +4 -0
  35. package/dist/src/chunk-61t538bm.js +4 -0
  36. package/dist/src/chunk-6d3mmqxt.js +54 -0
  37. package/dist/src/chunk-6hyt398x.js +5 -0
  38. package/dist/src/chunk-6mnr8kpm.js +4 -0
  39. package/dist/src/chunk-6pg7bqck.js +4 -0
  40. package/dist/src/chunk-79q5xsdc.js +42 -0
  41. package/dist/src/chunk-7bdgand3.js +4 -0
  42. package/dist/src/chunk-84cp9dw5.js +4 -0
  43. package/dist/src/chunk-86f2h5ww.js +5 -0
  44. package/dist/src/chunk-8cghfzb2.js +19 -0
  45. package/dist/src/chunk-8en08r7q.js +5 -0
  46. package/dist/src/chunk-950qcq1e.js +10 -0
  47. package/dist/src/chunk-9rkfyt6q.js +5 -0
  48. package/dist/src/chunk-9tf2p9y9.js +5 -0
  49. package/dist/src/chunk-9y5bcy28.js +6 -0
  50. package/dist/src/chunk-a2sc4jm0.js +5 -0
  51. package/dist/src/chunk-a4k9rt7z.js +5 -0
  52. package/dist/src/chunk-aa5ng3d1.js +4 -0
  53. package/dist/src/chunk-ajsrz473.js +5 -0
  54. package/dist/src/chunk-b3h0a6ca.js +4 -0
  55. package/dist/src/chunk-b4cxdzwy.js +20 -0
  56. package/dist/src/chunk-b6a737qt.js +4 -0
  57. package/dist/src/chunk-bn64x5z5.js +5 -0
  58. package/dist/src/chunk-bvh649za.js +12 -0
  59. package/dist/src/chunk-c9nk1r78.js +5 -0
  60. package/dist/src/chunk-c9tyfg4j.js +26 -0
  61. package/dist/src/chunk-cfsdfqnm.js +4 -0
  62. package/dist/src/chunk-cxyf04jc.js +7 -0
  63. package/dist/src/chunk-d57432wq.js +4 -0
  64. package/dist/src/chunk-da08tx5v.js +4 -0
  65. package/dist/src/chunk-eka89q3k.js +4 -0
  66. package/dist/src/chunk-f2tc08m2.js +4 -0
  67. package/dist/src/chunk-f8tnk179.js +5 -0
  68. package/dist/src/chunk-f9s1kkhx.js +5 -0
  69. package/dist/src/chunk-fbp8a4rx.js +4 -0
  70. package/dist/src/chunk-fd2z0sze.js +4 -0
  71. package/dist/src/chunk-fk927f4q.js +54 -0
  72. package/dist/src/chunk-fxmr3a0f.js +4 -0
  73. package/dist/src/chunk-gaqwhd44.js +4 -0
  74. package/dist/src/chunk-ggtd5x5a.js +5 -0
  75. package/dist/src/chunk-gndcfrm7.js +4 -0
  76. package/dist/src/chunk-h3n4adc6.js +310 -0
  77. package/dist/src/chunk-h5pjbb83.js +4 -0
  78. package/dist/src/chunk-hgnnh302.js +4 -0
  79. package/dist/src/chunk-hmke8nhx.js +5 -0
  80. package/dist/src/chunk-j2bx12hn.js +4 -0
  81. package/dist/src/chunk-j70y1a2g.js +4 -0
  82. package/dist/src/chunk-jdqvcq0a.js +5 -0
  83. package/dist/src/chunk-jhnbfj19.js +55 -0
  84. package/dist/src/chunk-js1jpyxp.js +6 -0
  85. package/dist/src/chunk-kbjq0qvb.js +4 -0
  86. package/dist/src/chunk-kfwx57xd.js +4 -0
  87. package/dist/src/chunk-km0dy5vc.js +71 -0
  88. package/dist/src/chunk-kzwctna2.js +4 -0
  89. package/dist/src/chunk-m9ehyehy.js +4 -0
  90. package/dist/src/chunk-mct91p1f.js +4 -0
  91. package/dist/src/chunk-mf9spd4g.js +5 -0
  92. package/dist/src/chunk-mgrcansb.js +4 -0
  93. package/dist/src/chunk-mqc1d0eb.js +6 -0
  94. package/dist/src/chunk-n1zmpk0z.js +4 -0
  95. package/dist/src/chunk-ncyjf63g.js +4 -0
  96. package/dist/src/chunk-nr64d21q.js +973 -0
  97. package/dist/src/chunk-nwm2pq5v.js +168 -0
  98. package/dist/src/chunk-pm06b05d.js +9 -0
  99. package/dist/src/chunk-q50s00ry.js +4 -0
  100. package/dist/src/chunk-qv2918jt.js +4 -0
  101. package/dist/src/chunk-qwye1958.js +14 -0
  102. package/dist/src/chunk-r0f1q783.js +5 -0
  103. package/dist/src/chunk-r14wwk37.js +18 -0
  104. package/dist/src/chunk-r20pe1nv.js +5 -0
  105. package/dist/src/chunk-r8z9pfve.js +5 -0
  106. package/dist/src/chunk-rdpgkjf6.js +4 -0
  107. package/dist/src/chunk-rkr0dks9.js +5 -0
  108. package/dist/src/chunk-rn84t3sf.js +11 -0
  109. package/dist/src/chunk-s123kn7n.js +4 -0
  110. package/dist/src/chunk-s1zq65ny.js +4 -0
  111. package/dist/src/chunk-s73qn3fx.js +4 -0
  112. package/dist/src/chunk-sjn0nj4p.js +5 -0
  113. package/dist/src/chunk-sns0c35v.js +7 -0
  114. package/dist/src/chunk-stfzjr9y.js +8 -0
  115. package/dist/src/chunk-sz1a7p43.js +4 -0
  116. package/dist/src/chunk-t4dr5c8v.js +8 -0
  117. package/dist/src/chunk-tc8k9c1j.js +4 -0
  118. package/dist/src/chunk-teznhase.js +4 -0
  119. package/dist/src/chunk-ty9xgmz4.js +4 -0
  120. package/dist/src/chunk-tyazf3sk.js +145 -0
  121. package/dist/src/chunk-v6npjrjm.js +5 -0
  122. package/dist/src/chunk-v90es00d.js +4 -0
  123. package/dist/src/chunk-vbvtzkwz.js +5 -0
  124. package/dist/src/chunk-vefd8qee.js +8 -0
  125. package/dist/src/chunk-vs9r72ta.js +17 -0
  126. package/dist/src/chunk-w2mwa0jk.js +4 -0
  127. package/dist/src/chunk-w7zsh13a.js +9 -0
  128. package/dist/src/chunk-w88k0bgr.js +4 -0
  129. package/dist/src/chunk-wry6skrm.js +4 -0
  130. package/dist/src/chunk-wzdt0enk.js +4 -0
  131. package/dist/src/chunk-xhhv854c.js +4 -0
  132. package/dist/src/chunk-y58270hd.js +4 -0
  133. package/dist/src/chunk-yk0hmbex.js +4 -0
  134. package/dist/src/chunk-ympy4fdz.js +28 -0
  135. package/dist/src/chunk-yw436axy.js +4 -0
  136. package/dist/src/chunk-z04jrpjy.js +5 -0
  137. package/dist/src/chunk-z2xznczw.js +4 -0
  138. package/dist/src/chunk-z4xnrgps.js +4 -0
  139. package/dist/src/chunk-z7csyszv.js +4 -0
  140. package/dist/src/chunk-z8t0v07j.js +11 -0
  141. package/dist/src/chunk-z916af47.js +228 -0
  142. package/dist/src/chunk-zcr8he8q.js +5 -0
  143. package/dist/src/chunk-zd9vmkzn.js +9 -0
  144. package/dist/src/chunk-zg67wjkh.js +5 -0
  145. package/dist/src/chunk-zj939v0h.js +5 -0
  146. package/dist/src/chunk-zkdjwtc1.js +4 -0
  147. package/dist/src/chunk-zkv5kzt6.js +4 -0
  148. package/dist/src/daemon/processEntry.js +4 -0
  149. package/dist/src/index.js +4 -2797
  150. package/dist/src/runtime/bunRuntimeGuard.js +4 -0
  151. package/dist/src/utils/workers/iosBundleExtractWorker.js +2 -3
  152. package/node_modules/strtok3/lib/BufferSizeError.js +1 -1
  153. package/node_modules/strtok3/lib/TokenWriter.js +151 -0
  154. package/node_modules/strtok3/lib/core.js +1 -0
  155. package/node_modules/strtok3/package.json +2 -2
  156. package/node_modules/token-types/LICENSE.txt +9 -9
  157. package/node_modules/token-types/{lib → dist/lib}/index.js +21 -3
  158. package/node_modules/token-types/package.json +81 -81
  159. package/package.json +10 -10
  160. package/schemas/README.md +16 -0
  161. package/schemas/prototype-icon-names.json +302 -0
  162. package/schemas/prototype-platform-permissions.json +75 -0
  163. package/schemas/test-plan.schema.json +2 -2
  164. package/node_modules/@borewit/text-codec/README.md +0 -87
  165. package/node_modules/@jimp/diff/node_modules/pixelmatch/README.md +0 -110
  166. package/node_modules/@jimp/diff/node_modules/pixelmatch/node_modules/pngjs/README.md +0 -433
  167. package/node_modules/@jimp/file-ops/dist/browser/index.js +0 -8
  168. package/node_modules/@jimp/js-png/README.md +0 -35
  169. package/node_modules/@jimp/js-png/src/__image_snapshots__/index-node-test-ts-png-should-use-png-options-1-snap.png +0 -0
  170. package/node_modules/@jimp/js-png/src/output.png +0 -0
  171. package/node_modules/@jimp/js-png/vitest.config.browser.mjs +0 -3
  172. package/node_modules/@jimp/plugin-resize/README.md +0 -12
  173. package/node_modules/@jimp/plugin-resize/vitest.config.browser.mjs +0 -3
  174. package/node_modules/@tokenizer/inflate/README.md +0 -114
  175. package/node_modules/@tokenizer/token/README.md +0 -19
  176. package/node_modules/await-to-js/README.md +0 -82
  177. package/node_modules/debug/README.md +0 -481
  178. package/node_modules/exif-parser/README.md +0 -83
  179. package/node_modules/file-type/readme.md +0 -667
  180. package/node_modules/ieee754/README.md +0 -51
  181. package/node_modules/mime/README.md +0 -178
  182. package/node_modules/ms/readme.md +0 -59
  183. package/node_modules/parse-bmfont-xml/README.md +0 -74
  184. package/node_modules/parse-bmfont-xml/lib/browser.js +0 -85
  185. package/node_modules/parse-bmfont-xml/node_modules/xml2js/README.md +0 -507
  186. package/node_modules/pngjs/README.md +0 -287
  187. package/node_modules/sax/README.md +0 -228
  188. package/node_modules/strtok3/README.md +0 -736
  189. package/node_modules/tinycolor2/README.md +0 -492
  190. package/node_modules/tinycolor2/cjs/test.js +0 -2191
  191. package/node_modules/tinycolor2/cjs/test_template.js +0 -26
  192. package/node_modules/tinycolor2/deno_asserts@0.168.0.mjs +0 -807
  193. package/node_modules/tinycolor2/esm/test.js +0 -2189
  194. package/node_modules/tinycolor2/esm/test_template.js +0 -24
  195. package/node_modules/tinycolor2/tinycolor.js +0 -1191
  196. package/node_modules/token-types/README.md +0 -120
  197. package/node_modules/uint8array-extras/readme.md +0 -318
  198. package/node_modules/xml-parse-from-string/README.md +0 -35
  199. package/node_modules/xmlbuilder/README.md +0 -86
  200. package/node_modules/zod/README.md +0 -208
  201. package/node_modules/zod/v4/locales/ar.d.cts +0 -4
  202. package/node_modules/zod/v4/locales/ar.d.ts +0 -4
  203. package/node_modules/zod/v4/locales/az.d.cts +0 -4
  204. package/node_modules/zod/v4/locales/az.d.ts +0 -4
  205. package/node_modules/zod/v4/locales/be.d.cts +0 -4
  206. package/node_modules/zod/v4/locales/be.d.ts +0 -4
  207. package/node_modules/zod/v4/locales/ca.d.cts +0 -4
  208. package/node_modules/zod/v4/locales/ca.d.ts +0 -4
  209. package/node_modules/zod/v4/locales/cs.d.cts +0 -4
  210. package/node_modules/zod/v4/locales/cs.d.ts +0 -4
  211. package/node_modules/zod/v4/locales/de.d.cts +0 -4
  212. package/node_modules/zod/v4/locales/de.d.ts +0 -4
  213. package/node_modules/zod/v4/locales/en.d.cts +0 -5
  214. package/node_modules/zod/v4/locales/en.d.ts +0 -5
  215. package/node_modules/zod/v4/locales/eo.d.cts +0 -5
  216. package/node_modules/zod/v4/locales/eo.d.ts +0 -5
  217. package/node_modules/zod/v4/locales/es.d.cts +0 -4
  218. package/node_modules/zod/v4/locales/es.d.ts +0 -4
  219. package/node_modules/zod/v4/locales/fa.d.cts +0 -4
  220. package/node_modules/zod/v4/locales/fa.d.ts +0 -4
  221. package/node_modules/zod/v4/locales/fi.d.cts +0 -4
  222. package/node_modules/zod/v4/locales/fi.d.ts +0 -4
  223. package/node_modules/zod/v4/locales/fr-CA.d.cts +0 -4
  224. package/node_modules/zod/v4/locales/fr-CA.d.ts +0 -4
  225. package/node_modules/zod/v4/locales/fr.d.cts +0 -4
  226. package/node_modules/zod/v4/locales/fr.d.ts +0 -4
  227. package/node_modules/zod/v4/locales/he.d.cts +0 -4
  228. package/node_modules/zod/v4/locales/he.d.ts +0 -4
  229. package/node_modules/zod/v4/locales/hu.d.cts +0 -4
  230. package/node_modules/zod/v4/locales/hu.d.ts +0 -4
  231. package/node_modules/zod/v4/locales/id.d.cts +0 -4
  232. package/node_modules/zod/v4/locales/id.d.ts +0 -4
  233. package/node_modules/zod/v4/locales/index.d.cts +0 -39
  234. package/node_modules/zod/v4/locales/index.d.ts +0 -39
  235. package/node_modules/zod/v4/locales/it.d.cts +0 -4
  236. package/node_modules/zod/v4/locales/it.d.ts +0 -4
  237. package/node_modules/zod/v4/locales/ja.d.cts +0 -4
  238. package/node_modules/zod/v4/locales/ja.d.ts +0 -4
  239. package/node_modules/zod/v4/locales/kh.d.cts +0 -4
  240. package/node_modules/zod/v4/locales/kh.d.ts +0 -4
  241. package/node_modules/zod/v4/locales/ko.d.cts +0 -4
  242. package/node_modules/zod/v4/locales/ko.d.ts +0 -4
  243. package/node_modules/zod/v4/locales/mk.d.cts +0 -4
  244. package/node_modules/zod/v4/locales/mk.d.ts +0 -4
  245. package/node_modules/zod/v4/locales/ms.d.cts +0 -4
  246. package/node_modules/zod/v4/locales/ms.d.ts +0 -4
  247. package/node_modules/zod/v4/locales/nl.d.cts +0 -4
  248. package/node_modules/zod/v4/locales/nl.d.ts +0 -4
  249. package/node_modules/zod/v4/locales/no.d.cts +0 -4
  250. package/node_modules/zod/v4/locales/no.d.ts +0 -4
  251. package/node_modules/zod/v4/locales/ota.d.cts +0 -4
  252. package/node_modules/zod/v4/locales/ota.d.ts +0 -4
  253. package/node_modules/zod/v4/locales/pl.d.cts +0 -4
  254. package/node_modules/zod/v4/locales/pl.d.ts +0 -4
  255. package/node_modules/zod/v4/locales/ps.d.cts +0 -4
  256. package/node_modules/zod/v4/locales/ps.d.ts +0 -4
  257. package/node_modules/zod/v4/locales/pt.d.cts +0 -4
  258. package/node_modules/zod/v4/locales/pt.d.ts +0 -4
  259. package/node_modules/zod/v4/locales/ru.d.cts +0 -4
  260. package/node_modules/zod/v4/locales/ru.d.ts +0 -4
  261. package/node_modules/zod/v4/locales/sl.d.cts +0 -4
  262. package/node_modules/zod/v4/locales/sl.d.ts +0 -4
  263. package/node_modules/zod/v4/locales/sv.d.cts +0 -4
  264. package/node_modules/zod/v4/locales/sv.d.ts +0 -4
  265. package/node_modules/zod/v4/locales/ta.d.cts +0 -4
  266. package/node_modules/zod/v4/locales/ta.d.ts +0 -4
  267. package/node_modules/zod/v4/locales/th.d.cts +0 -4
  268. package/node_modules/zod/v4/locales/th.d.ts +0 -4
  269. package/node_modules/zod/v4/locales/tr.d.cts +0 -5
  270. package/node_modules/zod/v4/locales/tr.d.ts +0 -5
  271. package/node_modules/zod/v4/locales/ua.d.cts +0 -4
  272. package/node_modules/zod/v4/locales/ua.d.ts +0 -4
  273. package/node_modules/zod/v4/locales/ur.d.cts +0 -4
  274. package/node_modules/zod/v4/locales/ur.d.ts +0 -4
  275. package/node_modules/zod/v4/locales/vi.d.cts +0 -4
  276. package/node_modules/zod/v4/locales/vi.d.ts +0 -4
  277. package/node_modules/zod/v4/locales/zh-CN.d.cts +0 -4
  278. package/node_modules/zod/v4/locales/zh-CN.d.ts +0 -4
  279. package/node_modules/zod/v4/locales/zh-TW.d.cts +0 -4
  280. package/node_modules/zod/v4/locales/zh-TW.d.ts +0 -4
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{Vz,V3,zB,Ba,wg,Eoe,Rg,Gm,la}from"./chunk-32jpxz2y.js";import"./chunk-z8t0v07j.js";import"./chunk-mf9spd4g.js";export{Vz as DARWIN_PS_LSTART_ENV,Ba as compareProcessGenerationTokens,Gm as currentDaemonProcessGenerationToken,V3 as daemonGenerationMatches,zB as darwinProcessGenerationToken,Eoe as processGenerationReadIsCheap,Rg as readDarwinProcessGenerationToken,wg as readLinuxProcessGenerationToken,la as readProcessGenerationTokenForPid};
3
+
4
+ //# debugId=5C5CD79B1E2BF9BE64756E2164756E21
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{XC,dp,QW,nk,ik,ii}from"./chunk-h3n4adc6.js";import"./chunk-32jpxz2y.js";import"./chunk-z8t0v07j.js";import"./chunk-mf9spd4g.js";export{ii as AndroidEmulatorClient,nk as AndroidEmulatorUnavailableError,ik as AndroidOfflineProbeError,dp as boundedEmulatorOutputTail,QW as emulatorLaunchOutputSource,XC as resetAndroidInventoryEnrichmentCache};
3
+
4
+ //# debugId=32C517F304785CC564756E2164756E21
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{V,c,cr,X,ane,dne,aY,cY,lne,une,pne,NR,t$,Aie,_Y}from"./chunk-79q5xsdc.js";import{_9}from"./chunk-z916af47.js";var QI={capability:ane,fields:E};function E(l){let e=[];return X(l,(o,t)=>{if(o.type==="stack"&&o.transition==="zoom")e.push(`${t}.transition`);cr(o,t,(i,a,r)=>{if(r==="stackTransition"&&i==="zoom")e.push(a);return i})}),e}function P(l,e,o,t){let i=QI.fields(l);if(i.length===0)return[];if(o(QI.capability)&&(e!=="ios"||t===void 0||t>=18))return[];let a=t===void 0?"":` (device iOS ${t})`;return[{platform:e,construct:"stack.zoom",effect:"substituted",paths:i.slice(0,20),...i.length>20?{total:i.length}:{},detail:e==="ios"?`Native zoom needs iOS 18 or later${a} and prototype_zoom_transition_v1; this agent uses platform push. Reduced motion crossfades; motion off is instant.`:"This CtrlProxy lacks prototype_zoom_transition_v1 and substitutes fadeThrough for zoom. Reduced motion crossfades; motion off is instant."}]}function x(l,e,o){if(e!=="ios"||o===void 0||o>=26)return[];let t=t$(l);return t.length?[{platform:e,construct:"scroll.edgeEffect",effect:"substituted",paths:t.slice(0,20),...t.length>20?{total:t.length}:{},detail:"Scroll edge effects use a scrollability-aware gradient fade on iOS before 26 (soft 24 dp, hard 8 dp; fadeEdges overrides lengths; none disables only the default fallback; explicit fadeEdges still apply)."}]:[]}var q=new Set(["button","iconButton","fab","chip","switch","checkbox","radioGroup","select","segmentedButton","tabBar","bottomNav","datePicker","timePicker","pasteButton"]);function I(l,e){if(e==="predictiveBack")return l.type!=="stack";return e==="indication"&&!q.has(String(l.type))&&!l.onTap&&!l.onLongPress&&!l.onDoubleTap}function F(l,e,o,t){if(o==="android")return I(l,e)?"ignored":void 0;if(NR.includes(e))return;if(e==="hover")return;if(e==="buttonStyle"&&l.type==="button")return t===void 0||t<26?"substituted":void 0;return"ignored"}function O(l,e,o){let t={ignored:[],substituted:[]};X(l,(r,n)=>{for(let f of Object.keys(c(r[e])??{})){let u=F(r,f,e,o);if(u){let p=f==="tab"?".role":f==="sheet"?".sizing":"";t[u].push(`${n}.${e}.${f}${p}`)}}});let i=c(l);for(let r of["window","theme"])if(c(c(i?.[r])?.[e]))t.ignored.push(`${r}.${e}`);let a={ignored:"These namespace fields have no applicable native chrome or interaction in this renderer; custom tab bars, app bars and sheets retain observable identities.",substituted:"Glass buttons use the bordered style below iOS 26; when the OS version is unknown this fallback may apply."};return["ignored","substituted"].flatMap((r)=>{let n=t[r];return n.length?[{platform:e,construct:"platformNamespace",effect:r,paths:n.slice(0,20),...n.length>20?{total:n.length}:{},detail:a[r]}]:[]})}var S=V.designCoverage;function N(l){if(c(c(l)?.theme)?.design!=="platform")return[];let e=[];return X(l,(o,t)=>{let i=o.type;if(typeof i==="string"&&Object.hasOwn(S,i)&&S[i].ios==="material")e.push(t)}),e}var gq={minimumIOS:"17.0",placeholder:"questionmark.square",mapped:{ac_unit:{symbol:"snowflake"},access_alarm:{symbol:"alarm",filled:"alarm.fill",outlined:"alarm"},access_time:{symbol:"clock",filled:"clock.fill",outlined:"clock"},accessibility:{symbol:"figure.arms.open"},accessible:{symbol:"figure.roll"},account_balance:{symbol:"building.columns",filled:"building.columns.fill",outlined:"building.columns"},account_balance_wallet:{symbol:"wallet.pass",filled:"wallet.pass.fill",outlined:"wallet.pass"},account_box:{symbol:"person.crop.square",filled:"person.crop.square.fill",outlined:"person.crop.square"},account_circle:{symbol:"person.crop.circle",filled:"person.crop.circle.fill",outlined:"person.crop.circle"},add:{symbol:"plus"},add_a_photo:{symbol:"camera.badge.ellipsis"},add_alarm:{symbol:"alarm"},add_box:{symbol:"plus.square.fill",filled:"plus.square.fill",outlined:"plus.square"},add_circle:{symbol:"plus.circle.fill",filled:"plus.circle.fill",outlined:"plus.circle"},add_circle_outline:{symbol:"plus.circle",outlined:"plus.circle"},add_photo_alternate:{symbol:"photo.badge.plus",filled:"photo.badge.plus.fill",outlined:"photo.badge.plus"},add_shopping_cart:{symbol:"cart.badge.plus",filled:"cart.fill.badge.plus",outlined:"cart.badge.plus"},airplay:{symbol:"airplayvideo"},alarm:{symbol:"alarm",filled:"alarm.fill",outlined:"alarm"},alarm_add:{symbol:"alarm"},album:{symbol:"opticaldisc",filled:"opticaldisc.fill",outlined:"opticaldisc"},analytics:{symbol:"chart.bar",filled:"chart.bar.fill",outlined:"chart.bar"},apps:{symbol:"square.grid.3x3",filled:"square.grid.3x3.fill",outlined:"square.grid.3x3"},archive:{symbol:"archivebox",filled:"archivebox.fill",outlined:"archivebox"},arrow_back:{symbol:"arrow.left"},arrow_back_ios:{symbol:"chevron.left"},arrow_downward:{symbol:"arrow.down"},arrow_drop_down:{symbol:"arrowtriangle.down.fill",filled:"arrowtriangle.down.fill",outlined:"arrowtriangle.down"},arrow_forward:{symbol:"arrow.right"},arrow_forward_ios:{symbol:"chevron.right"},arrow_left:{symbol:"arrowtriangle.left.fill",filled:"arrowtriangle.left.fill",outlined:"arrowtriangle.left"},arrow_right:{symbol:"arrowtriangle.right.fill",filled:"arrowtriangle.right.fill",outlined:"arrowtriangle.right"},arrow_upward:{symbol:"arrow.up"},article:{symbol:"doc.text",filled:"doc.text.fill",outlined:"doc.text"},assignment:{symbol:"clipboard",filled:"clipboard.fill",outlined:"clipboard"},attach_file:{symbol:"paperclip"},attach_money:{symbol:"dollarsign"},audiotrack:{symbol:"music.note"},autorenew:{symbol:"arrow.triangle.2.circlepath"},backspace:{symbol:"delete.left",filled:"delete.left.fill",outlined:"delete.left"},bar_chart:{symbol:"chart.bar",filled:"chart.bar.fill",outlined:"chart.bar"},battery_alert:{symbol:"battery.0percent"},battery_charging_full:{symbol:"battery.100percent.bolt"},battery_full:{symbol:"battery.100percent"},battery_std:{symbol:"battery.100percent"},bedtime:{symbol:"moon",filled:"moon.fill",outlined:"moon"},block:{symbol:"nosign"},book:{symbol:"book",filled:"book.fill",outlined:"book"},bookmark:{symbol:"bookmark",filled:"bookmark.fill",outlined:"bookmark"},bookmark_border:{symbol:"bookmark",outlined:"bookmark"},bookmarks:{symbol:"bookmark"},brush:{symbol:"paintbrush",filled:"paintbrush.fill",outlined:"paintbrush"},build:{symbol:"wrench.and.screwdriver",filled:"wrench.and.screwdriver.fill",outlined:"wrench.and.screwdriver"},cached:{symbol:"arrow.triangle.2.circlepath"},calendar_month:{symbol:"calendar"},calendar_today:{symbol:"calendar"},call:{symbol:"phone",filled:"phone.fill",outlined:"phone"},call_end:{symbol:"phone.down",filled:"phone.down.fill",outlined:"phone.down"},camera:{symbol:"camera.aperture"},camera_alt:{symbol:"camera",filled:"camera.fill",outlined:"camera"},campaign:{symbol:"megaphone",filled:"megaphone.fill",outlined:"megaphone"},cancel:{symbol:"xmark.circle",filled:"xmark.circle.fill",outlined:"xmark.circle"},category:{symbol:"square.grid.2x2"},chat:{symbol:"bubble.left"},chat_bubble:{symbol:"bubble.left",filled:"bubble.left.fill",outlined:"bubble.left"},chat_bubble_outline:{symbol:"bubble.left",outlined:"bubble.left"},check:{symbol:"checkmark"},check_box:{symbol:"checkmark.square.fill",filled:"checkmark.square.fill",outlined:"checkmark.square"},check_box_outline_blank:{symbol:"square",outlined:"square"},check_circle:{symbol:"checkmark.circle",filled:"checkmark.circle.fill",outlined:"checkmark.circle"},chevron_left:{symbol:"chevron.left"},chevron_right:{symbol:"chevron.right"},circle:{symbol:"circle.fill",filled:"circle.fill",outlined:"circle"},clear:{symbol:"xmark"},close:{symbol:"xmark"},cloud:{symbol:"cloud",filled:"cloud.fill",outlined:"cloud"},code:{symbol:"chevron.left.forwardslash.chevron.right"},collections:{symbol:"photo.on.rectangle"},color_lens:{symbol:"paintpalette",filled:"paintpalette.fill",outlined:"paintpalette"},comment:{symbol:"bubble.left",filled:"bubble.left.fill",outlined:"bubble.left"},compare_arrows:{symbol:"arrow.left.arrow.right"},computer:{symbol:"desktopcomputer"},contacts:{symbol:"person.crop.rectangle",filled:"person.crop.rectangle.fill",outlined:"person.crop.rectangle"},content_copy:{symbol:"doc.on.doc",filled:"doc.on.doc.fill",outlined:"doc.on.doc"},content_cut:{symbol:"scissors"},content_paste:{symbol:"clipboard",filled:"clipboard.fill",outlined:"clipboard"},create:{symbol:"pencil"},credit_card:{symbol:"creditcard",filled:"creditcard.fill",outlined:"creditcard"},crop:{symbol:"crop"},crop_free:{symbol:"viewfinder"},dark_mode:{symbol:"moon",filled:"moon.fill",outlined:"moon"},dashboard:{symbol:"square.grid.2x2",filled:"square.grid.2x2.fill",outlined:"square.grid.2x2"},date_range:{symbol:"calendar"},delete:{symbol:"trash",filled:"trash.fill",outlined:"trash"},delete_forever:{symbol:"trash"},delete_outline:{symbol:"trash",outlined:"trash"},description:{symbol:"doc.text",filled:"doc.text.fill",outlined:"doc.text"},dialpad:{symbol:"circle.grid.3x3",filled:"circle.grid.3x3.fill",outlined:"circle.grid.3x3"},directions:{symbol:"arrow.triangle.turn.up.right.diamond",filled:"arrow.triangle.turn.up.right.diamond.fill",outlined:"arrow.triangle.turn.up.right.diamond"},directions_bike:{symbol:"bicycle"},directions_bus:{symbol:"bus",filled:"bus.fill",outlined:"bus"},directions_car:{symbol:"car",filled:"car.fill",outlined:"car"},directions_run:{symbol:"figure.run"},directions_walk:{symbol:"figure.walk"},done:{symbol:"checkmark.circle",filled:"checkmark.circle.fill",outlined:"checkmark.circle"},download:{symbol:"arrow.down.to.line"},drag_handle:{symbol:"equal"},drag_indicator:{symbol:"line.3.horizontal"},eco:{symbol:"leaf",filled:"leaf.fill",outlined:"leaf"},edit:{symbol:"pencil"},edit_note:{symbol:"square.and.pencil"},email:{symbol:"envelope",filled:"envelope.fill",outlined:"envelope"},emoji_emotions:{symbol:"face.smiling",filled:"face.smiling.fill",outlined:"face.smiling"},equalizer:{symbol:"slider.vertical.3"},error:{symbol:"exclamationmark.circle",filled:"exclamationmark.circle.fill",outlined:"exclamationmark.circle"},error_outline:{symbol:"exclamationmark.circle",outlined:"exclamationmark.circle"},event:{symbol:"calendar"},event_available:{symbol:"calendar.badge.checkmark"},event_busy:{symbol:"calendar.badge.minus"},event_note:{symbol:"calendar"},exit_to_app:{symbol:"rectangle.portrait.and.arrow.right",filled:"rectangle.portrait.and.arrow.right.fill",outlined:"rectangle.portrait.and.arrow.right"},expand_less:{symbol:"chevron.up"},expand_more:{symbol:"chevron.down"},fast_forward:{symbol:"forward",filled:"forward.fill",outlined:"forward"},fast_rewind:{symbol:"backward",filled:"backward.fill",outlined:"backward"},favorite:{symbol:"heart",filled:"heart.fill",outlined:"heart"},favorite_border:{symbol:"heart",outlined:"heart"},feedback:{symbol:"exclamationmark.bubble",filled:"exclamationmark.bubble.fill",outlined:"exclamationmark.bubble"},file_copy:{symbol:"doc.on.doc",filled:"doc.on.doc.fill",outlined:"doc.on.doc"},file_download:{symbol:"arrow.down.to.line"},file_upload:{symbol:"arrow.up.to.line"},filter_alt:{symbol:"line.3.horizontal.decrease"},filter_list:{symbol:"line.3.horizontal.decrease"},fitness_center:{symbol:"dumbbell",filled:"dumbbell.fill",outlined:"dumbbell"},flag:{symbol:"flag",filled:"flag.fill",outlined:"flag"},flight:{symbol:"airplane"},folder:{symbol:"folder",filled:"folder.fill",outlined:"folder"},folder_open:{symbol:"folder"},format_align_left:{symbol:"text.alignleft"},format_bold:{symbol:"bold"},format_list_bulleted:{symbol:"list.bullet"},format_list_numbered:{symbol:"list.number"},forum:{symbol:"bubble.left.and.bubble.right",filled:"bubble.left.and.bubble.right.fill",outlined:"bubble.left.and.bubble.right"},fullscreen:{symbol:"arrow.up.left.and.arrow.down.right"},fullscreen_exit:{symbol:"arrow.down.right.and.arrow.up.left"},gps_fixed:{symbol:"scope"},graphic_eq:{symbol:"waveform"},grid_view:{symbol:"square.grid.2x2",filled:"square.grid.2x2.fill",outlined:"square.grid.2x2"},group:{symbol:"person.2",filled:"person.2.fill",outlined:"person.2"},groups:{symbol:"person.3",filled:"person.3.fill",outlined:"person.3"},headphones:{symbol:"headphones"},headset:{symbol:"headphones"},help:{symbol:"questionmark.circle",filled:"questionmark.circle.fill",outlined:"questionmark.circle"},help_outline:{symbol:"questionmark.circle",outlined:"questionmark.circle"},highlight_off:{symbol:"xmark.circle",filled:"xmark.circle.fill",outlined:"xmark.circle"},history:{symbol:"clock.arrow.circlepath"},home:{symbol:"house",filled:"house.fill",outlined:"house"},hotel:{symbol:"bed.double",filled:"bed.double.fill",outlined:"bed.double"},hourglass_empty:{symbol:"hourglass"},hourglass_full:{symbol:"hourglass"},house:{symbol:"house",filled:"house.fill",outlined:"house"},image:{symbol:"photo",filled:"photo.fill",outlined:"photo"},inbox:{symbol:"tray",filled:"tray.fill",outlined:"tray"},info:{symbol:"info.circle",filled:"info.circle.fill",outlined:"info.circle"},keyboard_arrow_down:{symbol:"chevron.down"},keyboard_arrow_left:{symbol:"chevron.left"},keyboard_arrow_right:{symbol:"chevron.right"},keyboard_arrow_up:{symbol:"chevron.up"},layers:{symbol:"square.3.layers.3d"},library_add:{symbol:"rectangle.stack.badge.plus",filled:"rectangle.stack.fill.badge.plus",outlined:"rectangle.stack.badge.plus"},library_music:{symbol:"music.note.list"},light_mode:{symbol:"sun.max",filled:"sun.max.fill",outlined:"sun.max"},link:{symbol:"link"},list:{symbol:"list.bullet"},local_hospital:{symbol:"cross.case",filled:"cross.case.fill",outlined:"cross.case"},local_movies:{symbol:"film",filled:"film.fill",outlined:"film"},location_on:{symbol:"mappin.and.ellipse"},lock:{symbol:"lock",filled:"lock.fill",outlined:"lock"},logout:{symbol:"rectangle.portrait.and.arrow.right",filled:"rectangle.portrait.and.arrow.right.fill",outlined:"rectangle.portrait.and.arrow.right"},mail:{symbol:"envelope",filled:"envelope.fill",outlined:"envelope"},mail_outline:{symbol:"envelope",outlined:"envelope"},menu:{symbol:"line.3.horizontal"},mic:{symbol:"mic",filled:"mic.fill",outlined:"mic"},mic_off:{symbol:"mic.slash",filled:"mic.slash.fill",outlined:"mic.slash"},monitor_heart:{symbol:"waveform.path.ecg.rectangle",filled:"waveform.path.ecg.rectangle.fill",outlined:"waveform.path.ecg.rectangle"},more_horiz:{symbol:"ellipsis"},more_vert:{symbol:"ellipsis"},music_note:{symbol:"music.note"},notifications:{symbol:"bell",filled:"bell.fill",outlined:"bell"},notifications_off:{symbol:"bell.slash",filled:"bell.slash.fill",outlined:"bell.slash"},pause:{symbol:"pause.fill",filled:"pause.fill",outlined:"pause"},person:{symbol:"person",filled:"person.fill",outlined:"person"},phone:{symbol:"phone",filled:"phone.fill",outlined:"phone"},photo:{symbol:"photo",filled:"photo.fill",outlined:"photo"},photo_album:{symbol:"photo.on.rectangle"},photo_camera:{symbol:"camera",filled:"camera.fill",outlined:"camera"},place:{symbol:"mappin.and.ellipse"},play_arrow:{symbol:"play.fill",filled:"play.fill",outlined:"play"},play_circle:{symbol:"play.circle",filled:"play.circle.fill",outlined:"play.circle"},psychology:{symbol:"brain.head.profile",filled:"brain.head.profile.fill",outlined:"brain.head.profile"},public:{symbol:"globe"},push_pin:{symbol:"pin",filled:"pin.fill",outlined:"pin"},qr_code_scanner:{symbol:"qrcode.viewfinder"},radio_button_checked:{symbol:"largecircle.fill.circle"},radio_button_unchecked:{symbol:"circle",outlined:"circle"},redo:{symbol:"arrow.uturn.forward"},refresh:{symbol:"arrow.clockwise"},remove:{symbol:"minus"},repeat:{symbol:"repeat"},replay:{symbol:"arrow.counterclockwise"},reply:{symbol:"arrowshape.turn.up.left",filled:"arrowshape.turn.up.left.fill",outlined:"arrowshape.turn.up.left"},report_problem:{symbol:"exclamationmark.triangle",filled:"exclamationmark.triangle.fill",outlined:"exclamationmark.triangle"},restaurant:{symbol:"fork.knife"},save:{symbol:"square.and.arrow.down",filled:"square.and.arrow.down.fill",outlined:"square.and.arrow.down"},save_alt:{symbol:"arrow.down.to.line"},schedule:{symbol:"clock",filled:"clock.fill",outlined:"clock"},school:{symbol:"graduationcap",filled:"graduationcap.fill",outlined:"graduationcap"},science:{symbol:"testtube.2"},search:{symbol:"magnifyingglass"},security:{symbol:"shield",filled:"shield.fill",outlined:"shield"},sell:{symbol:"tag",filled:"tag.fill",outlined:"tag"},send:{symbol:"paperplane",filled:"paperplane.fill",outlined:"paperplane"},sensors:{symbol:"sensor",filled:"sensor.fill",outlined:"sensor"},settings:{symbol:"gearshape",filled:"gearshape.fill",outlined:"gearshape"},share:{symbol:"square.and.arrow.up",filled:"square.and.arrow.up.fill",outlined:"square.and.arrow.up"},shopping_bag:{symbol:"bag",filled:"bag.fill",outlined:"bag"},shopping_basket:{symbol:"basket",filled:"basket.fill",outlined:"basket"},shopping_cart:{symbol:"cart",filled:"cart.fill",outlined:"cart"},shuffle:{symbol:"shuffle"},skip_next:{symbol:"forward.end.fill",filled:"forward.end.fill",outlined:"forward.end"},skip_previous:{symbol:"backward.end.fill",filled:"backward.end.fill",outlined:"backward.end"},slideshow:{symbol:"play.rectangle",filled:"play.rectangle.fill",outlined:"play.rectangle"},sms:{symbol:"bubble.left",filled:"bubble.left.fill",outlined:"bubble.left"},sort:{symbol:"arrow.up.arrow.down"},speaker:{symbol:"speaker"},speed:{symbol:"speedometer"},star:{symbol:"star",filled:"star.fill",outlined:"star"},star_border:{symbol:"star",outlined:"star"},star_half:{symbol:"star.leadinghalf.filled"},stop:{symbol:"stop.fill",filled:"stop.fill",outlined:"stop"},storage:{symbol:"externaldrive"},store:{symbol:"storefront",filled:"storefront.fill",outlined:"storefront"},storefront:{symbol:"storefront",filled:"storefront.fill",outlined:"storefront"},support:{symbol:"lifepreserver",filled:"lifepreserver.fill",outlined:"lifepreserver"},swap_horiz:{symbol:"arrow.left.arrow.right"},swap_vert:{symbol:"arrow.up.arrow.down"},sync:{symbol:"arrow.triangle.2.circlepath"},system_update_alt:{symbol:"arrow.down.square"},thumb_down:{symbol:"hand.thumbsdown",filled:"hand.thumbsdown.fill",outlined:"hand.thumbsdown"},thumb_up:{symbol:"hand.thumbsup",filled:"hand.thumbsup.fill",outlined:"hand.thumbsup"},timer:{symbol:"timer"},today:{symbol:"calendar"},toggle_off:{symbol:"switch.2"},toggle_on:{symbol:"switch.2"},touch_app:{symbol:"hand.tap",filled:"hand.tap.fill",outlined:"hand.tap"},translate:{symbol:"character.bubble",filled:"character.bubble.fill",outlined:"character.bubble"},trending_down:{symbol:"arrow.down.right"},trending_up:{symbol:"arrow.up.right"},tune:{symbol:"slider.horizontal.3"},undo:{symbol:"arrow.uturn.backward"},update:{symbol:"clock.arrow.circlepath"},upload:{symbol:"arrow.up.to.line"},verified:{symbol:"checkmark.seal",filled:"checkmark.seal.fill",outlined:"checkmark.seal"},verified_user:{symbol:"checkmark.shield",filled:"checkmark.shield.fill",outlined:"checkmark.shield"},visibility:{symbol:"eye",filled:"eye.fill",outlined:"eye"},visibility_off:{symbol:"eye.slash",filled:"eye.slash.fill",outlined:"eye.slash"},volume_down:{symbol:"speaker.wave.1",filled:"speaker.wave.1.fill",outlined:"speaker.wave.1"},volume_off:{symbol:"speaker.slash",filled:"speaker.slash.fill",outlined:"speaker.slash"},volume_up:{symbol:"speaker.wave.3",filled:"speaker.wave.3.fill",outlined:"speaker.wave.3"},wallet:{symbol:"wallet.pass",filled:"wallet.pass.fill",outlined:"wallet.pass"},warning:{symbol:"exclamationmark.triangle",filled:"exclamationmark.triangle.fill",outlined:"exclamationmark.triangle"},wifi:{symbol:"wifi"},work:{symbol:"briefcase",filled:"briefcase.fill",outlined:"briefcase"},work_outline:{symbol:"briefcase",outlined:"briefcase"},zoom_in:{symbol:"plus.magnifyingglass"},zoom_out:{symbol:"minus.magnifyingglass"}},unmapped:["android","backup","bluetooth","bluetooth_connected","bluetooth_disabled","broken_image","calculate","cloud_done","cloud_download","cloud_upload","crop_169","delivery_dining","devices","explore","exposure_neg_1","face","group_add","phone_iphone","receipt","receipt_long","rocket_launch","satellite","videocam","videocam_off"]};var B={bounce:"scale 1 \u2192 1.2 \u2192 1",pulse:"alpha 1 \u2192 0.4 \u2192 1",scale:"scale to 1.15 while the trigger is truthy",variableColor:"an alpha sweep",wiggle:"rotation \xB110\xB0",rotate:"rotation 0 \u2192 360\xB0",breathe:"scale 1 \u2192 1.06 with alpha",replace:"crossfade with scale on name changes",drawOn:"crossfade"},z={wiggle:{minimum:18,fallback:"bounce"},rotate:{minimum:18,fallback:"none"},breathe:{minimum:18,fallback:"pulse"},drawOn:{minimum:26,fallback:"replace"}};function Y(l,e,o,t){if(l==="android")return`Android approximates ${e} with ${B[e]}.`;return t===void 0?`On iOS below ${o.minimum}, ${e} falls back to ${o.fallback}; the connected OS version is unknown.`:`On iOS ${t}, ${e} falls back to ${o.fallback} (native ${e} needs iOS ${o.minimum}).`}function D(l,e){if(l.paths.length<20)l.paths.push(e);else l.total=(l.total??l.paths.length)+1}function w(l,e,o){let t=new Map;return X(l,(i,a)=>{let r=c(i.effect)?.type;if(i.type!=="icon"||typeof r!=="string")return;let n=z[r];if(e==="ios"&&(!n||o!==void 0&&o>=n.minimum))return;let f=Y(e,r,n,o),u=t.get(f);if(u){D(u,`${a}.effect`);return}t.set(f,{platform:e,construct:"icon.effect",effect:e==="ios"&&n.fallback==="none"?"ignored":"substituted",paths:[`${a}.effect`],detail:f})}),[...t.values()]}var L=new Set(["home","search","settings","person","favorite","add","close","check","arrow_back","arrow_forward","chevron_left","chevron_right","menu","more_vert","share","edit","delete","info","warning","notifications","star","shopping_cart","help","refresh","done","cancel","play_arrow","pause","stop","mail","phone","location_on","calendar_today","visibility","lock","logout","alarm","schedule","event","today","remove","expand_more","expand_less","more_horiz","account_circle","send","bookmark","thumb_up","photo_camera","image","music_note","wifi","sort","filter_list","content_copy"]),J6=[{construct:"searchBar",platform:"ios",effect:"substituted",detail:"iOS draws the search field inside the prototype window instead of using SwiftUI .searchable, which requires a NavigationStack; results remain ordinary observable child nodes.",occurrencePath:({node:l,path:e})=>l?.type==="searchBar"?e:void 0},{construct:"searchBar.icons",platform:"ios",effect:"substituted",detail:"iOS maps searchBar leading and trailing icons to SF Symbols; it never draws Android Material glyphs.",occurrencePath:({icon:l,path:e,nodeType:o})=>l!==void 0&&o==="searchBar"?e:void 0}],X6=[{construct:"node.id",platform:"ios",effect:"substituted",capability:dne,detail:"An iOS agent without prototype_identifier_test_tag_only_v1 uses id as the accessibility identifier (and <id>.<part> for composite parts) when testTag is absent; Android gives such a node no identifier, so set testTag for an identifier on both.",occurrencePath:({node:l,path:e})=>l?.id!==void 0&&l.testTag===void 0?`${e}.id`:void 0},{construct:"bottomSheet.dismissOnSwipe",platform:"ios",effect:"ignored",capability:cY,detail:"An iOS agent without prototype_bottom_sheet_drag_v1 has no swipe-to-dismiss and the sheet closes only through its openWhen key or a scrim tap; Android supports swipe-to-dismiss by default.",occurrencePath:({node:l,path:e})=>l?.type==="bottomSheet"&&l.dismissOnSwipe!==!1?`${e}.dismissOnSwipe`:void 0},{construct:"bottomSheet.detents",platform:"ios",effect:"ignored",capability:cY,detail:"An iOS agent without prototype_bottom_sheet_drag_v1 opens the sheet at its first detent and cannot drag to the others; Android supports dragging between detents.",occurrencePath:({node:l,path:e})=>l?.type==="bottomSheet"&&Array.isArray(l.detents)&&l.detents.length>1?`${e}.detents`:void 0},{construct:"icon.name",platform:"ios",effect:"substituted",capability:lne,detail:"This iOS agent lacks prototype_icon_sf_symbols_v1 and draws a placeholder for names outside its legacy mapping; relaunch with a current agent. Android draws the Material icon.",occurrencePath:({icon:l,path:e})=>l!==void 0&&!L.has(l)?e:void 0},{construct:"icon.variant",platform:"ios",effect:"ignored",capability:pne,detail:"This iOS agent lacks prototype_icon_sf_symbols_v1 and ignores icon variants; relaunch with a current agent. Android draws the requested Material style.",occurrencePath:({node:l,path:e})=>l?.type==="icon"&&l.variant!==void 0?`${e}.variant`:void 0},{construct:"textField.variant",platform:"ios",effect:"substituted",capability:aY,detail:"An iOS agent without prototype_text_field_material_style_v1 has no native outlined text field; the agent draws a rounded outline around a standard SwiftUI TextField. Android draws the Material outlined field.",occurrencePath:({node:l,path:e})=>l?.type==="textField"&&l.variant==="outlined"?`${e}.variant`:void 0},{construct:"textField.label",platform:"ios",effect:"substituted",capability:aY,detail:"An iOS agent without prototype_text_field_material_style_v1 has no native floating label; the agent draws the label as a caption above the field that does not animate. Android draws the Material floating label.",occurrencePath:({node:l,path:e})=>l?.type==="textField"&&l.label!==void 0?`${e}.label`:void 0},{construct:"stack",platform:"ios",effect:"substituted",detail:"Platform, slide and zoom support interactive edge pop; only the composed sharedAxisX/Y and fadeThrough patterns pop non-interactively. Pattern values and source require prototype_stack_patterns_v1. iOS pops a stack with the left-edge swipe (no system back button chrome); Android uses system Back above depth 1. Explicit stack or push/replace transitions require prototype_stack_transitions_v1. iOS Reduce Motion uses fades; Android animator or transition scale 0 makes transitions instant.",occurrencePath:({node:l,path:e})=>l?.type==="stack"?e:void 0},{construct:"carousel",platform:"ios",effect:"substituted",detail:"iOS has no Material carousel: every variant draws fixed-width items (itemWidth) in a snapping horizontal scroll, without the multiBrowse or hero size changes, and all items stay in the hierarchy. Android composes only the visible items.",occurrencePath:({node:l,path:e})=>l?.type==="carousel"?e:void 0}],k=gq.mapped;function M(l){if(l.construct==="icon.name")return{...l,detail:"iOS draws SF Symbols; these names have no SF Symbol equivalent, so a placeholder symbol is drawn.",occurrencePath:({icon:e,path:o})=>e!==void 0&&!Object.hasOwn(k,e)?o:void 0};if(l.construct==="icon.variant")return{...l,effect:"substituted",detail:"SF Symbols have no rounded, sharp or twoTone style; filled/outlined require a table form. For these variants iOS draws the name's default symbol.",occurrencePath:({node:e,path:o})=>{if(e?.type!=="icon"||typeof e.name!=="string"||!Object.hasOwn(k,e.name))return;let t=k[e.name],i=e.variant;return i==="rounded"||i==="sharp"||i==="twoTone"||i==="filled"&&t.filled===void 0||i==="outlined"&&t.outlined===void 0?`${o}.variant`:void 0}};return l}var T=V.definitions;function G(l,e){return l===void 0||l===null||e.name==="iosNamespace"||e.name==="androidNamespace"}function y(l,e,o,{found:t,nodeType:i}){if(G(l,e))return;switch(e.kind){case"ref":U(l,e.name,o,{found:t,nodeType:i});break;case"strings":break;case"screenMap":Object.entries(l).forEach(([a,r])=>y(r,e.item,`${o}[${JSON.stringify(a)}]`,{found:t}));break;case"array":l.forEach((a,r)=>y(a,e.item,`${o}[${r}]`,{found:t,nodeType:i}));break;case"object":Z(l,e,o,{found:t,nodeType:i});break;case"tagged":{let a=l,r=e.variants?.[String(a.type)];if(r)y(l,r,o,{found:t,nodeType:i});break}}}function Z(l,e,o,{found:t,nodeType:i}){for(let[a,r]of Object.entries(e.fields??{}))y(l[a],r.rule,o?`${o}.${a}`:a,{found:t,nodeType:i})}function U(l,e,o,{found:t,nodeType:i}){if(e==="iconName"&&typeof l==="string")t.push({path:o,icon:l,nodeType:i});if(e==="node")t.push({path:o,node:l}),i=String(l.type);y(l,e==="menuItem"?T.menuItem.options[0]:T[e],o,{found:t,nodeType:i})}function A7(l,e,o,t){let a=[...x(l,e,t),...P(l,e,o,t)],r=e==="android"?"ios":"android",n=_9(l,r),u=[...n.length?[{platform:e,construct:"platformNamespace",effect:"ignored",paths:n.slice(0,20),...n.length>20?{total:n.length}:{},detail:`${r} namespace blocks are ignored on ${e}.`}]:[],...O(l,e,t)];if(e==="android")return[..._Y(l,e),...u,...a,...w(l,e)];let p=[];y(l.root,{kind:"ref",name:"node"},"root",{found:p});let R=o(une),_=[...X6,...J6].flatMap((m)=>{let s=R?M(m):m;if(s.capability&&o(s.capability))return[];let d=p.flatMap((b)=>{let v=s.occurrencePath(b);return v===void 0?[]:[{path:v,icon:b.icon}]});if(d.length===0)return[];return[{platform:s.platform,construct:s.construct,effect:s.effect,paths:d.slice(0,20).map(({path:b})=>b),...d.length>20?{total:d.length}:{},...s.construct==="icon.name"?{values:[...new Set(d.map(({icon:b})=>b))].sort()}:{},detail:s.detail}]}),h=p.flatMap(({node:m,path:s})=>m?.type==="text"&&Array.isArray(m.spans)?m.spans.flatMap((d,b)=>typeof d==="object"&&d!==null&&("onTap"in d)?[`${s}.spans[${b}].onTap`]:[]):[]);if(h.length>0)_.push({platform:"ios",construct:"rich-text-links",effect:"substituted",paths:h.slice(0,20),...h.length>20?{total:h.length}:{},detail:"Tappable text spans render as links; the agent does not expose them as separate accessibility elements or semantic links. Use tapAt on the span."});let A=["menu","select"].flatMap((m)=>{let s=p.filter(({node:d})=>d?.type===m).map(({path:d})=>d);return s.length===0?[]:[{platform:"ios",construct:m,effect:"substituted",paths:s.slice(0,20),...s.length>20?{total:s.length}:{},detail:"iOS draws menu/select in the prototype window rather than the system Menu/Picker popup so observe and tapOn can reach the items."}]}),g=N(l);if(g.length)_.push({platform:"ios",construct:"design.fallback",effect:"substituted",paths:g.slice(0,20),...g.length>20?{total:g.length}:{},detail:"These nodes have no native iOS coverage yet and keep the Material drawing (see designCoverage)."});return[..._,...a,...A,..._Y(l,e),...u,...w(l,e,t)]}function T7(l,e){if(e===void 0||!l.strings)return[];let o=Aie(l,e);return o.length?[{platform:"all",construct:"strings.fallback",effect:"substituted",paths:o.slice(0,20).map((t)=>`strings.default.${t}`),values:o.slice(0,20),...o.length>20?{total:o.length}:{},detail:`Locale ${e}: referenced keys fall through to default: ${o.slice(0,20).join(", ")}.`}]:[]}
3
+ export{QI,gq,J6,X6,A7,T7};
4
+
5
+ //# debugId=FC4F1E841A1054F764756E2164756E21
@@ -0,0 +1,19 @@
1
+ // @bun
2
+ import{L}from"./chunk-32jpxz2y.js";import{Nr,i,l,nt,e}from"./chunk-z8t0v07j.js";import{r7,n7,fS,Dc,Jf,ZN,i7,hS,QN,o7}from"./chunk-a2sc4jm0.js";import{an,HR}from"./chunk-ggtd5x5a.js";import{KQ,qc,rL,YQ,Ct,vr,oL,Fh,dT,fT,cw,ei,Zd,Qd,So,d5,Xr,ht,mv,ss,Pee,qh,ct,np}from"./chunk-h3n4adc6.js";import{yq,Ly,jl,Ar,Nu,lt,it,E7,V0,NA,he,wq,z0,FS,em,uh,ph,Q6,Rq,_7,x7,C7,j0,D7,M7,e4,t4,Ux,K0,n4,i4,o4,s4,B7,$7,U7,mh,G0,q7,a4,V7}from"./chunk-tyazf3sk.js";import{y,A,Z,z,f,kt,ee,P,IR}from"./chunk-79q5xsdc.js";import{iA,mS,jN,Kf}from"./chunk-44bt78m9.js";import{r,t}from"./chunk-9rkfyt6q.js";var Q=new Map;function YH(n,o){if(o===void 0)Q.delete(n);else Q.set(n,o)}function De(n){return Q.get(n)}function xZ(){Q.clear()}var A6=50;function ie(n){return{...n,...n.processExit?{processExit:{...n.processExit}}:{},...n.session?{session:{...n.session}}:{},recovery:{...n.recovery,policy:{...n.recovery.policy},attempts:n.recovery.attempts.map((o)=>({...o}))}}}class T6{timer;idGenerator;maxRetained;incidents=new Map;constructor(n=i,o=L,s=A6){this.timer=n;this.idGenerator=o;this.maxRetained=s}async open(n){let o=this.timer.now(),s={id:`emulator-loss-${this.idGenerator.next()}`,observedAtMs:o,updatedAtMs:o,deviceId:n.deviceId,...n.avdName?{avdName:n.avdName}:{},detectionPath:n.detectionPath,...n.processExit?{processExit:{...n.processExit}}:{},...n.outputTail?{outputTail:n.outputTail}:{},...n.outputUnavailable==="adopted"?{outputUnavailable:n.outputUnavailable}:{},...n.lastAdbState?{lastAdbState:n.lastAdbState}:{},...n.session?{session:{...n.session}}:{},recovery:{policy:{...n.recoveryPolicy},attempts:[]}};return this.incidents.set(s.id,s),this.prune(),ie(s)}async recordRecoveryAttempt(n,o){let s=this.incidents.get(n);if(!s)return;s.recovery.attempts.push({...o}),s.updatedAtMs=this.timer.now()}async completeRecovery(n,o,s={}){let a=this.incidents.get(n);if(!a)return;if(a.recovery.outcome=o,s.replacementDeviceId)a.replacementDeviceId=s.replacementDeviceId;if(a.session&&s.sessionState)a.session.state=s.sessionState;a.updatedAtMs=this.timer.now()}async get(n){let o=this.incidents.get(n);return o?ie(o):void 0}async list(n=this.maxRetained){let o=Array.from(this.incidents.values());return(n<=0?[]:o.slice(-n)).reverse().map(ie)}prune(){while(this.incidents.size>this.maxRetained){let n=this.incidents.keys().next().value;if(n===void 0)return;this.incidents.delete(n)}}}var Ze=1000;function ke(n){if(!qh(n))return;let o=n.slice(Pee.length),s=";incident=",a=o.indexOf(s),c=a===-1?o:o.slice(0,a),d=a===-1?void 0:o.slice(a+s.length)||void 0;return c?new Xr(c,n,d):void 0}function OI(n){if(!n)return;let o=ss(n);if(o)throw o}function CZ(n,o){return n===void 0?void 0:Math.max(0,n-Math.max(0,o)-Ze)}function k6(n,o){if(!ht(n))return;return{code:d5,deviceId:n.deviceId,...o?{sessionUuid:o}:{},...n.incidentId?{incidentId:n.incidentId}:{},reason:"confirmed-unavailable"}}function DZ(n,o){if(!o)return n;let s=o.session?.state;return{...n,detectionPath:o.detectionPath,...o.avdName?{avdName:o.avdName}:{},...o.replacementDeviceId?{replacementDeviceId:o.replacementDeviceId}:{},...s?{sessionState:s}:{},...o.session?{heartbeat:{lastHeartbeatMs:o.session.lastHeartbeatMs,hasReceivedHeartbeat:o.session.hasReceivedHeartbeat,timeoutMs:o.session.heartbeatTimeoutMs}}:{},recovery:{status:o.recovery.outcome??"pending",attempts:o.recovery.attempts.length},retry:{sameSession:s==="active"||s==="awaiting-device",requiresNewSession:s==="released"}}}function OZ(n,o){if(!o||o.assignedDevice===n.deviceId||n.sessionState==="released")return n;return{...n,sessionState:n.sessionState===void 0||n.sessionState==="recovering"?"active":n.sessionState,retry:{sameSession:!0,requiresNewSession:!1},replacementDeviceId:n.replacementDeviceId??o.assignedDevice,recovery:n.recovery??{status:"recovered",attempts:0}}}function E6(n,o,s){let a=()=>n.markRequestCancelled(o);if(s.aborted)a();else s.addEventListener("abort",a,{once:!0});return()=>s.removeEventListener("abort",a)}class tA extends t{failure;constructor(n){super(ZN(n));this.failure=n;this.name="DaemonBoundSessionLostError"}}import{createHash as et}from"crypto";import{readFileSync as tt}from"fs";import{resolve as ot}from"path";var W="unknown";function st(n){let o=tt(n);return et("sha256").update(o).digest("hex").slice(0,16)}function rt(n,o=st){if(!n)return{entryScript:"",buildId:W};let s=ot(n);try{return{entryScript:s,buildId:o(s)}}catch(a){return e.warn(`Failed to compute build identity: ${r(a)}`,a),{entryScript:s,buildId:W}}}var ae=null;function No(){if(!ae)ae=rt(process.argv[1]);return ae}function Te(n){return n.length>0&&n!==W}function $d(n,o){if(Te(n.buildId)&&Te(o.buildId))return n.buildId===o.buildId;if(n.entryScript.length>0&&o.entryScript.length>0)return n.entryScript===o.entryScript;return!0}function ji(n){return`${n.buildId} (${n.entryScript||"unknown"})`}function ks(n){return{entryScript:n.entryScript??"",buildId:n.buildId??W}}function JH(){return{get version(){return ei},build:No()}}var dt=f({code:ee("daemon_identity_mismatch"),phase:ee("daemon-preflight"),executionStarted:ee(!1),reason:P(["version","build"]),daemon:f({version:y(),build:f({buildId:y(),entryScript:y()})}),client:f({clientVersion:y().optional(),clientBuildId:y().optional(),clientEntryScript:y().optional()})});function we(n){return dt.safeParse(n).success}function ce(n){if(typeof n!=="string")return;let o=n.trim();return o.length>0?o:void 0}function I6(n){return{clientVersion:ce(n.clientVersion),clientBuildId:ce(n.clientBuildId),clientEntryScript:ce(n.clientEntryScript)}}function ut(n){return(n.clientVersion?.length??0)>0||(n.clientBuildId?.length??0)>0}function MZ(n,o){if(!ut(o))return{ok:!0};let s={entryScript:o.clientEntryScript??"",buildId:o.clientBuildId??"unknown"};if(!$d(n.build,s))return{ok:!1,reason:"build",message:`AutoMobile daemon build mismatch: the shared daemon socket is served by a different build than this client. daemon build=${ji(n.build)}, client build=${ji(s)}. Restart the daemon from this client's checkout to resolve the skew.`};let a=o.clientVersion;if(a){let c=n.version.trim();if(an(a)!==a?c.length>0&&HR(c)!==HR(a):(()=>{let m=an(a),p=an(c);return m.length>0&&p.length>0&&m!==p})())return{ok:!1,reason:"version",message:`AutoMobile daemon version mismatch: the shared daemon socket is served by daemon=${n.version||"unknown"} but this client is ${a}. Restart the daemon from this client's build (e.g. \`auto-mobile --daemon restart\`) so the per-uid socket serves a matching version.`}}return{ok:!0}}class MI extends t{failure;constructor(n,o){super(`Daemon preflight failed; no device operation started. ${o}`);this.failure=n;this.name="DaemonHandshakeMismatchError"}}function BN(n=!1){return{code:dT,retryable:!0,...n?{requestMayHaveDispatched:!0}:{}}}function $N(n){return{code:n.code,retryable:!0,daemonShuttingDown:n}}function NI(n=!1){return{error:{code:dT,message:Fh,retryable:!0,...n?{requestMayHaveDispatched:!0}:{}}}}function de(n){return typeof n==="object"&&n!==null}function le(n){return de(n)&&n.code===dT&&n.retryable===!0}function mt(n){return de(n)&&le(n.error)}function _6(n){return de(n)&&mt(n.structuredContent)}function NZ(n){return BN(_6(n)&&np(n)?.error.requestMayHaveDispatched===!0)}class fe extends Error{constructor(n,o){super(n,o);this.name="DaemonUnavailableError"}}function Y(n){if(n instanceof fe)return n;return new fe(`Daemon socket connection lost: ${n.message}`,{cause:n})}class Ud extends fe{requestMayHaveDispatched;constructor(n=!1){super(Fh);this.requestMayHaveDispatched=n;this.name="DaemonShuttingDownError"}}var Ae="device_control_transport_failure";class Uf extends Error{failure;constructor(n,o){super(n);this.failure=o;this.name="DeviceControlTransportError"}}function pt(n){return n.code===Ae&&n.transport==="daemon_loopback_http"&&typeof n.toolName==="string"&&n.toolName.length>0}function ft(n){let o={};if(n.deviceId!==void 0){if(typeof n.deviceId!=="string")return;o.deviceId=n.deviceId}if(n.deviceSessionUuid!==void 0){if(typeof n.deviceSessionUuid!=="string")return;o.deviceSessionUuid=n.deviceSessionUuid}if(n.sessionUuid!==void 0){if(typeof n.sessionUuid!=="string")return;o.sessionUuid=n.sessionUuid}if(n.routingSessionUuid!==void 0){if(typeof n.routingSessionUuid!=="string")return;o.routingSessionUuid=n.routingSessionUuid}return o}function gt(n){return typeof n.sessionValid==="boolean"&&typeof n.deviceSessionValid==="boolean"&&(n.phase==="connect"||n.phase==="response")&&typeof n.retryable==="boolean"&&typeof n.reconnectAttempted==="boolean"&&typeof n.replayAttempted==="boolean"}function XH(n){if(!n||typeof n!=="object"||Array.isArray(n))return;let o=n,s=ft(o);if(!pt(o)||!s||!gt(o))return;return{code:Ae,transport:"daemon_loopback_http",toolName:o.toolName,...s,sessionValid:o.sessionValid,deviceSessionValid:o.deviceSessionValid,phase:o.phase,retryable:o.retryable,reconnectAttempted:o.reconnectAttempted,replayAttempted:o.replayAttempted}}function FZ(n){return typeof n==="string"&&De(n)==="replay"}var X="daemon_overloaded";class zs extends Error{failure;constructor(n,o){super(n);this.failure=o;this.name="McpOverloadError"}}var Cu="daemon_queue_timeout";function ZH(n){return n instanceof Error&&"code"in n&&n.code===Cu}class xr extends Error{toolName;timeoutMs;origin;code;constructor(n){let o=n.detail?` (${n.detail})`:"";super(`MCP timeout: ${n.toolName} exceeded ${n.timeoutMs}ms at ${n.origin}${o}`);if(this.name="McpTimeoutError",this.toolName=n.toolName,this.timeoutMs=n.timeoutMs,this.origin=n.origin,n.code!==void 0)this.code=n.code}}function vt(n){return typeof n==="number"&&Number.isFinite(n)&&n>=0}function Ce(n){if(!n||typeof n!=="object"||Array.isArray(n))return;let o=n;if(o.code!==X||o.retryable!==!0||o.reason!=="insufficient_forward_budget"||![o.retryAfterMs,o.queueWaitMs,o.remainingTimeoutMs].every(vt))return;return{code:X,retryable:!0,retryAfterMs:o.retryAfterMs,reason:"insufficient_forward_budget",queueWaitMs:o.queueWaitMs,remainingTimeoutMs:o.remainingTimeoutMs}}async function Et(n,o,s){let a=new n4({classification:s.classification,...s.responseMode!==void 0&&{responseMode:s.responseMode},...s.keepAliveMs!==void 0&&{keepAliveMs:s.keepAliveMs}});return await n.connect(a),a.handleMessage(o,{...s.request!==void 0&&{request:s.request},...s.authInfo!==void 0&&{authInfo:s.authInfo}})}var pe=4194304,ue=100;function Me(n){return`Payload Too Large: Request body must not exceed ${n} bytes`}function Oe(n){if(n===void 0)return pe;if(typeof n!=="number"||!Number.isFinite(n)||n<=0)throw RangeError(`maxRequestBodySize must be a positive number of bytes, got ${String(n)}`);return n}async function Pe(n,o=pe){if(Number(n.headers.get("content-length"))>o)return{tooLarge:!0};if(n.body===null)return{tooLarge:!1,text:""};let s=n.body.getReader(),a=new TextDecoder,c=0,d="";try{for(;;){let{done:u,value:m}=await s.read();if(u)break;if(c+=m.byteLength,c>o)return{tooLarge:!0};d+=a.decode(m,{stream:!0})}}finally{s.releaseLock()}return{tooLarge:!1,text:d+a.decode()}}var x6=class{sessionIdGenerator;_started=!1;_hasHandledRequest=!1;_closed=!1;_streamMapping=new Map;_requestToStreamMapping=new Map;_requestResponseMap=new Map;_initialized=!1;_enableJsonResponse=!1;_standaloneSseStreamId="_GET_stream";_eventStore;_onsessioninitialized;_onsessionclosed;_allowedHosts;_allowedOrigins;_enableDnsRebindingProtection;_retryInterval;_supportedProtocolVersions;_keepAliveMs;_maxRequestBodySize;_scopeChallengeResolver;sessionId;onclose;onerror;onmessage;constructor(n={}){this.sessionIdGenerator=n.sessionIdGenerator,this._enableJsonResponse=n.enableJsonResponse??!1,this._eventStore=n.eventStore,this._onsessioninitialized=n.onsessioninitialized,this._onsessionclosed=n.onsessionclosed,this._allowedHosts=n.allowedHosts,this._allowedOrigins=n.allowedOrigins,this._enableDnsRebindingProtection=n.enableDnsRebindingProtection??!1,this._retryInterval=n.retryInterval,this._supportedProtocolVersions=n.supportedProtocolVersions??Ly,this._keepAliveMs=n.keepAliveMs??Ux,this._maxRequestBodySize=Oe(n.maxRequestBodySize)}startKeepAlive(n,o){if(this._closed)return;let s=K0(this._keepAliveMs,()=>{try{n.enqueue(o.encode(`: keepalive
3
+
4
+ `))}catch{if(s!==void 0)clearInterval(s)}});return s}setScopeChallengeResolver(n){this._scopeChallengeResolver=n}async start(){if(this._started)throw Error("Transport already started");this._started=!0}setSupportedProtocolVersions(n){this._supportedProtocolVersions=n}createJsonErrorResponse(n,o,s,a){let c={code:o,message:s};if(a?.data!==void 0)c.data=a.data;return Response.json({jsonrpc:"2.0",error:c,id:null},{status:n,headers:{"Content-Type":"application/json",...a?.headers}})}async _checkScopeChallenge(n,o){if(!this._scopeChallengeResolver)return;let s=await i4(n.filter((a)=>em(a)),o,this._scopeChallengeResolver);return s===void 0?void 0:s4(s,o4(o))}validateRequestHeaders(n){if(!this._enableDnsRebindingProtection)return;if(this._allowedHosts&&this._allowedHosts.length>0){let o=n.headers.get("host");if(!o||!this._allowedHosts.includes(o)){let s=`Invalid Host header: ${o}`;return this.onerror?.(Error(s)),this.createJsonErrorResponse(403,-32000,s)}}if(this._allowedOrigins&&this._allowedOrigins.length>0){let o=n.headers.get("origin");if(o&&!this._allowedOrigins.includes(o)){let s=`Invalid Origin header: ${o}`;return this.onerror?.(Error(s)),this.createJsonErrorResponse(403,-32000,s)}}}async handleRequest(n,o){if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");if(!this.sessionIdGenerator&&this._hasHandledRequest)throw Error("Stateless transport cannot be reused across requests. Create a new transport per request.");this._hasHandledRequest=!0;let s=this.validateRequestHeaders(n);if(s)return s;switch(n.method){case"POST":return this.handlePostRequest(n,o);case"GET":return this.handleGetRequest(n);case"DELETE":return this.handleDeleteRequest(n);default:return this.handleUnsupportedRequest()}}supportsEmptySSEData(n){return this._supportedProtocolVersions.includes(n)&&n>="2025-11-25"}async writePrimingEvent(n,o,s,a){if(!this._eventStore)return;if(!this.supportsEmptySSEData(a))return;let c=await this._eventStore.storeEvent(s,{}),d=`id: ${c}
5
+ data:
6
+
7
+ `;if(this._retryInterval!==void 0)d=`id: ${c}
8
+ retry: ${this._retryInterval}
9
+ data:
10
+
11
+ `;n.enqueue(o.encode(d))}async handleGetRequest(n){if(!n.headers.get("accept")?.includes("text/event-stream"))return this.onerror?.(Error("Not Acceptable: Client must accept text/event-stream")),this.createJsonErrorResponse(406,-32000,"Not Acceptable: Client must accept text/event-stream");let o=this.validateSession(n);if(o)return o;let s=this.validateProtocolVersion(n);if(s)return s;if(this._eventStore){let p=n.headers.get("last-event-id");if(p)return this.replayEvents(p)}if(this._streamMapping.get(this._standaloneSseStreamId)!==void 0)return this.onerror?.(Error("Conflict: Only one SSE stream is allowed per session")),this.createJsonErrorResponse(409,-32000,"Conflict: Only one SSE stream is allowed per session");let a=new TextEncoder,c,d,u=new ReadableStream({start:(p)=>{c=p},cancel:()=>{if(d!==void 0)clearInterval(d);if(this._streamMapping.get(this._standaloneSseStreamId)?.controller===c)this._streamMapping.delete(this._standaloneSseStreamId)}}),m={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"};if(this.sessionId!==void 0)m["mcp-session-id"]=this.sessionId;return this._streamMapping.set(this._standaloneSseStreamId,{controller:c,encoder:a,cleanup:()=>{if(d!==void 0)clearInterval(d);this._streamMapping.delete(this._standaloneSseStreamId);try{c.close()}catch{}}}),d=this.startKeepAlive(c,a),new Response(u,{headers:m})}async replayEvents(n){if(!this._eventStore)return this.onerror?.(Error("Event store not configured")),this.createJsonErrorResponse(400,-32000,"Event store not configured");try{let o;if(this._eventStore.getStreamIdForEventId){if(o=await this._eventStore.getStreamIdForEventId(n),!o)return this.onerror?.(Error("Invalid event ID format")),this.createJsonErrorResponse(400,-32000,"Invalid event ID format");if(this._streamMapping.get(o)!==void 0)return this.onerror?.(Error("Conflict: Stream already has an active connection")),this.createJsonErrorResponse(409,-32000,"Conflict: Stream already has an active connection")}let s={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"};if(this.sessionId!==void 0)s["mcp-session-id"]=this.sessionId;let a=new TextEncoder,c,d,u=!1,m,p=new ReadableStream({start:(b)=>{c=b},cancel:()=>{if(u=!0,d!==void 0)clearInterval(d);if(m!==void 0&&this._streamMapping.get(m)?.controller===c)this._streamMapping.delete(m)}}),g=new Set;if(m=await this._eventStore.replayEventsAfter(n,{send:async(b,R)=>{if(g.add(b),!this.writeSSEEvent(c,a,R,b))try{c.close()}catch{}}}),this._closed||u){try{c.close()}catch{}return this.createJsonErrorResponse(404,-32001,"Session not found")}if(this._streamMapping.get(m)?.cleanup(),this._streamMapping.set(m,{controller:c,encoder:a,replayedEventIds:g,cleanup:()=>{if(d!==void 0)clearInterval(d);this._streamMapping.delete(m);try{c.close()}catch{}}}),m!==this._standaloneSseStreamId){if(![...this._requestToStreamMapping.values()].includes(m)){this._streamMapping.delete(m);try{c.close()}catch{}}}if(this._streamMapping.get(m)?.controller===c)d=this.startKeepAlive(c,a);return new Response(p,{headers:s})}catch(o){return this.onerror?.(o),this.createJsonErrorResponse(500,-32000,"Error replaying events")}}writeSSEEvent(n,o,s,a){try{let c=`event: message
12
+ `;if(a)c+=`id: ${a}
13
+ `;return c+=`data: ${JSON.stringify(s)}
14
+
15
+ `,n.enqueue(o.encode(c)),!0}catch(c){return this.onerror?.(c),!1}}handleUnsupportedRequest(){return this.onerror?.(Error("Method not allowed.")),Response.json({jsonrpc:"2.0",error:{code:-32000,message:"Method not allowed."},id:null},{status:405,headers:{Allow:"GET, POST, DELETE","Content-Type":"application/json"}})}async handlePostRequest(n,o){try{let s=n.headers.get("accept");if(!s?.includes("application/json")||!s.includes("text/event-stream"))return this.onerror?.(Error("Not Acceptable: Client must accept both application/json and text/event-stream")),this.createJsonErrorResponse(406,-32000,"Not Acceptable: Client must accept both application/json and text/event-stream");if(!t4(n.headers.get("content-type")))return this.onerror?.(Error("Unsupported Media Type: Content-Type must be application/json")),this.createJsonErrorResponse(415,-32000,"Unsupported Media Type: Content-Type must be application/json");let a=n,c;if(o?.parsedBody===void 0)try{let S=await Pe(n,this._maxRequestBodySize);if(S.tooLarge){let h=Me(this._maxRequestBodySize);return this.onerror?.(Error(h)),this.createJsonErrorResponse(413,-32000,h)}c=JSON.parse(S.text)}catch(S){return this.onerror?.(S),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON")}else c=o.parsedBody;if(Array.isArray(c)&&c.length>ue)return this.onerror?.(Error(`Invalid Request: Batch must not exceed ${ue} messages`)),this.createJsonErrorResponse(400,-32600,`Invalid Request: Batch must not exceed ${ue} messages`);let d;try{d=Array.isArray(c)?c.map((S)=>Nu.parse(S)):[Nu.parse(c)]}catch(S){return this.onerror?.(S),this.createJsonErrorResponse(400,-32700,"Parse error: Invalid JSON-RPC message")}if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");let u=d.some((S)=>Q6(S));if(u){if(this._initialized&&this.sessionId!==void 0)return this.onerror?.(Error("Invalid Request: Server already initialized")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Server already initialized");if(d.length>1)return this.onerror?.(Error("Invalid Request: Only one initialization request is allowed")),this.createJsonErrorResponse(400,-32600,"Invalid Request: Only one initialization request is allowed");if(this.sessionId=this.sessionIdGenerator?.(),this._initialized=!0,this.sessionId&&this._onsessioninitialized)await Promise.resolve(this._onsessioninitialized(this.sessionId))}if(!u){let S=this.validateSession(n);if(S)return S;let h=this.validateProtocolVersion(n);if(h)return h}if(this._closed)return this.createJsonErrorResponse(404,-32001,"Session not found");let m;try{m=await this._checkScopeChallenge(d,o?.authInfo)}catch(S){return this.onerror?.(S),this.createJsonErrorResponse(500,-32603,"Internal server error")}if(m)return m;if(!d.some((S)=>em(S))){for(let S of d)this.onmessage?.(S,{authInfo:o?.authInfo,request:a});return new Response(null,{status:202})}let p=crypto.randomUUID(),g=d.find((S)=>Q6(S)),b=g?g.params.protocolVersion:n.headers.get("mcp-protocol-version")??yq;if(this._enableJsonResponse)return new Promise((S)=>{this._streamMapping.set(p,{resolveJson:S,cleanup:()=>{this._streamMapping.delete(p)}});for(let h of d)if(em(h))this._requestToStreamMapping.set(h.id,p);for(let h of d)this.onmessage?.(h,{authInfo:o?.authInfo,request:a})});let R=new TextEncoder,v,E,M=new ReadableStream({start:(S)=>{v=S},cancel:()=>{if(E!==void 0)clearInterval(E);if(this._streamMapping.get(p)?.controller===v)this._streamMapping.delete(p)}}),T={"Content-Type":"text/event-stream","Cache-Control":"no-cache, no-transform",Connection:"keep-alive","X-Accel-Buffering":"no"};if(this.sessionId!==void 0)T["mcp-session-id"]=this.sessionId;for(let S of d)if(em(S))this._streamMapping.set(p,{controller:v,encoder:R,cleanup:()=>{if(E!==void 0)clearInterval(E);this._streamMapping.delete(p);try{v.close()}catch{}}}),this._requestToStreamMapping.set(S.id,p);await this.writePrimingEvent(v,R,p,b);for(let S of d){let h,D;if(em(S)&&this._eventStore&&this.supportsEmptySSEData(b))h=()=>{this.closeSSEStream(S.id)},D=()=>{this.closeStandaloneSSEStream()};this.onmessage?.(S,{authInfo:o?.authInfo,request:a,closeSSEStream:h,closeStandaloneSSEStream:D})}if(this._streamMapping.get(p)?.controller===v)E=this.startKeepAlive(v,R);return new Response(M,{status:200,headers:T})}catch(s){return this.onerror?.(s),this.createJsonErrorResponse(400,-32700,"Parse error",{data:String(s)})}}async handleDeleteRequest(n){let o=this.validateSession(n);if(o)return o;let s=this.validateProtocolVersion(n);if(s)return s;try{return await Promise.resolve(this._onsessionclosed?.(this.sessionId)),new Response(null,{status:200})}finally{await this.close()}}validateSession(n){if(this.sessionIdGenerator===void 0)return;if(!this._initialized)return this.onerror?.(Error("Bad Request: Server not initialized")),this.createJsonErrorResponse(400,-32000,"Bad Request: Server not initialized");let o=n.headers.get("mcp-session-id");if(!o)return this.onerror?.(Error("Bad Request: Mcp-Session-Id header is required")),this.createJsonErrorResponse(400,-32000,"Bad Request: Mcp-Session-Id header is required");if(o!==this.sessionId)return this.onerror?.(Error("Session not found")),this.createJsonErrorResponse(404,-32001,"Session not found")}validateProtocolVersion(n){let o=n.headers.get("mcp-protocol-version");if(o!==null&&!this._supportedProtocolVersions.includes(o)){let s=`Bad Request: Unsupported protocol version: ${o} (supported versions: ${this._supportedProtocolVersions.join(", ")})`;return this.onerror?.(Error(s)),this.createJsonErrorResponse(400,-32000,s)}}async close(){if(this._closed)return;this._closed=!0;for(let{cleanup:n}of this._streamMapping.values())n();this._streamMapping.clear(),this._requestResponseMap.clear(),this.onclose?.()}closeSSEStream(n){let o=this._requestToStreamMapping.get(n);if(!o)return;let s=this._streamMapping.get(o);if(s)s.cleanup()}closeStandaloneSSEStream(){let n=this._streamMapping.get(this._standaloneSseStreamId);if(n)n.cleanup()}async send(n,o){let s=o?.relatedRequestId;if(uh(n)||ph(n))s=n.id;if(s===void 0){if(uh(n)||ph(n))throw Error("Cannot send a response on a standalone SSE stream unless resuming a previous client request");let d;if(this._eventStore)d=await this._eventStore.storeEvent(this._standaloneSseStreamId,n);let u=this._streamMapping.get(this._standaloneSseStreamId);if(u===void 0)return;if(u.controller&&u.encoder&&(d===void 0||!u.replayedEventIds?.has(d)))this.writeSSEEvent(u.controller,u.encoder,n,d);return}let a=this._requestToStreamMapping.get(s);if(!a)throw Error(`No connection established for request ID: ${String(s)}`);let c=this._streamMapping.get(a);if(!this._enableJsonResponse){let d;if(this._eventStore)d=await this._eventStore.storeEvent(a,n),c=this._streamMapping.get(a);if(c?.controller&&c?.encoder&&(d===void 0||!c.replayedEventIds?.has(d)))this.writeSSEEvent(c.controller,c.encoder,n,d)}if(uh(n)||ph(n)){this._requestResponseMap.set(s,n);let d=[...this._requestToStreamMapping.entries()].filter(([u,m])=>m===a).map(([u])=>u);if(d.every((u)=>this._requestResponseMap.has(u))){if(!c){if(this._enableJsonResponse)throw Error(`No connection established for request ID: ${String(s)}`);if(!this._eventStore){this.onerror?.(Error(`Response for request ID ${String(s)} is undeliverable: per-request stream is disconnected and no eventStore is configured`));for(let u of d)this._requestResponseMap.delete(u),this._requestToStreamMapping.delete(u);return}for(let u of d)this._requestResponseMap.delete(u),this._requestToStreamMapping.delete(u);return}if(this._enableJsonResponse&&c.resolveJson){let u={"Content-Type":"application/json"};if(this.sessionId!==void 0)u["mcp-session-id"]=this.sessionId;let m=d.map((p)=>this._requestResponseMap.get(p));if(m.length===1)c.resolveJson(Response.json(m[0],{status:200,headers:u}));else c.resolveJson(Response.json(m,{status:200,headers:u}));c.cleanup()}else c.cleanup();for(let u of d)this._requestResponseMap.delete(u),this._requestToStreamMapping.delete(u)}}}};function F(n){if(n===null||typeof n!=="object"||Array.isArray(n))return null;let{method:o,id:s}=n;if(typeof o!=="string")return null;return typeof s==="string"||typeof s==="number"?s:null}function q(n,o,s,a,c=null){return Response.json({jsonrpc:"2.0",error:{code:o,message:s,...a!==void 0&&{data:a}},id:c},{status:n,...n===405&&{headers:{Allow:"POST"}}})}function te(n,o=null){return q(n.httpStatus,n.code,n.message,n.data,o)}function H(n){return n instanceof Error?n:Error(String(n))}function J(n=null){return q(500,-32603,"Internal server error",void 0,n)}function Ie(n){if(n.transport!==void 0)throw Error("The factory returned an instance that is still serving another request. Return a new instance for each request.")}function yt(n,o,s,a){return async(c,d)=>{if(c.method.toUpperCase()!=="POST")return q(405,-32000,"Method not allowed.");try{let u=await n({era:"legacy",...d?.authInfo!==void 0&&{authInfo:d.authInfo},requestInfo:c}),m=new x6({sessionIdGenerator:void 0,...s!==void 0&&{keepAliveMs:s},...a!==void 0&&{maxRequestBodySize:a}});await u.connect(m);let p=()=>{m.close().catch(()=>{}),u.close().catch(()=>{})};c.signal?.addEventListener("abort",p,{once:!0});let g=await m.handleRequest(c,{...d?.authInfo!==void 0&&{authInfo:d.authInfo},...d?.parsedBody!==void 0&&{parsedBody:d.parsedBody}});if(g.body===null||e4(g.headers.get("content-type"))!=="text/event-stream")return p(),g;let b=g.body.getReader(),R=!1,v=()=>{if(!R)R=!0,p()},E=new ReadableStream({pull:async(M)=>{try{let{done:T,value:S}=await b.read();if(T){v(),M.close();return}if(S!==void 0)M.enqueue(S)}catch(T){v(),M.error(T)}},cancel:(M)=>(v(),b.cancel(M).catch(()=>{}))});return new Response(E,{status:g.status,statusText:g.statusText,headers:g.headers})}catch(u){try{o?.(H(u))}catch{}return J(F(d?.parsedBody))}}}function qe(n){return{protocolVersionHeader:n.headers.get("mcp-protocol-version")??void 0,mcpMethodHeader:n.headers.get("mcp-method")??void 0,mcpNameHeader:n.headers.get("mcp-name")??void 0}}async function St(n,o,s=!0,a=pe){let c=n.method.toUpperCase(),d,u=o,m=n,p=!1;if(c==="POST"){if(u===void 0){if(s)m=n.clone();let g;try{let b=await Pe(n,a);if(b.tooLarge)return{step:"body-too-large"};g=b.text}catch{return{step:"unreadable-body"}}try{d=g.length===0?void 0:JSON.parse(g)}catch{p=!0}if(!p&&d!==void 0)u=d}else d=u;if(p||d===void 0)return{step:"no-json-body",forwardRequest:m}}return{step:"classified",outcome:j0({httpMethod:c,...qe(n),...d!==void 0&&{body:d}}),body:d,parsedBody:u,forwardRequest:m}}function LZ(n,o={}){let{legacy:s,onerror:a,responseMode:c}=o,d=Oe(o.maxRequestBodySize);if(typeof s==="function")throw TypeError("The 'legacy' option only accepts 'stateless' or 'reject', not a handler function. To serve 2025-era traffic with your own handler, route in user land with the exported isLegacyRequest(request) predicate in front of a strict (legacy: 'reject') handler.");let u=new Set,m=!1,p=(h)=>{try{a?.(h)}catch{}},g=o.bus??new G0(p),b=q7(g),R=V7({bus:g,maxSubscriptions:o.maxSubscriptions??a4,keepAliveMs:o.keepAliveMs??Ux,onerror:p});if(c==="json")console.warn("responseMode: 'json' drops mid-call notifications. subscriptions/listen streams are always served over SSE regardless; other notifications emitted before a result are dropped.");let v=s==="reject"?void 0:yt(n,p,o.keepAliveMs,d);async function E(h,D,w){let I=h.classification.revision;if(I===void 0||!NA.includes(I)){let x=new wq({supported:[...NA],requested:I??"unknown"});return p(x),q(400,x.code,x.message,x.data,F(h.message))}let C=C7({httpMethod:D.method,...qe(D)},h);if(C!==void 0)return p(Error(`Rejected inbound request (${C.cell}): ${C.message}`)),te(C,F(h.message));let U=h.messageKind==="request"?FS(h.message.params):void 0,G=U?.[Ar];if(h.messageKind==="request"){let x=E7(h.message.method);if(x!==void 0){let O=V0(x,G);if(O!==void 0){let N=new z0({requiredCapabilities:O});return p(N),q(x7(N.code,"ladder"),N.code,N.message,N.data,h.message.id)}}}let _=await n({era:"modern",...w!==void 0&&{authInfo:w},requestInfo:D}),k=_ instanceof mh?_.server:_;if(Ie(k),h.messageKind==="request"&&h.message.method==="subscriptions/listen"){let x=k.getCapabilities(),O=U7(k);return _.close().catch(p),R.serve(h.message,D.signal,x,O)}if(h.messageKind==="request"&&h.message.method==="tools/call"&&_ instanceof mh){let x=h.message.params,O=typeof x?.name==="string"?x.name:void 0,N=O===void 0?void 0:_.toolInputSchemaJson(O);if(N!==void 0){let re=Rq(N);if(re.declarations!==void 0&&re.declarations.length>0){let K=_7(re.declarations,x?.arguments,D.headers);if(K!==void 0)return _.close().catch(p),p(Error(`Rejected inbound request (${K.cell}): ${K.message}`)),te(K,h.message.id)}}}if(h.messageKind==="request"&&_ instanceof mh)try{let x=await i4([h.message],w,(O)=>_.resolveScopeChallenge(O));if(x!==void 0)return _.close().catch(p),s4(x,o4(w))}catch(x){return _.close().catch(p),p(H(x)),J(h.message.id)}if(Ie(k),M7(k,I),$7(k,NA),U!==void 0)B7(k,{clientInfo:U[jl],clientCapabilities:G});let Re=k.onclose;u.add(k);let xe=()=>{if(u.delete(k),k.onclose===xe)k.onclose=Re;Re?.()};k.onclose=xe;try{let x=await Et(_,h.message,{classification:h.classification,request:D,...w!==void 0&&{authInfo:w},...c!==void 0&&{responseMode:c},...o.keepAliveMs!==void 0&&{keepAliveMs:o.keepAliveMs}});if(h.messageKind==="notification")queueMicrotask(()=>void k.close().catch(()=>{}));return x}catch(x){if(x instanceof it&&x.code===lt.ConnectionClosed)return new Response(null,{status:499});return await k.close().catch(()=>{}),u.delete(k),p(H(x)),J(F(h.message))}}async function M(h,D,w,I){if(v!==void 0)return v(D,{...w!==void 0&&{authInfo:w},...I!==void 0&&{parsedBody:I}});let C=D7(h,NA);if(C===void 0)return new Response(null,{status:202});return p(Error(`Rejected 2025-era request on a modern-only endpoint (${C.cell}): ${C.message}`)),te(C,F(I))}async function T(h,D){let w=D?.authInfo;if(h.method.toUpperCase()==="POST"&&!t4(h.headers.get("content-type")))return p(Error("Unsupported Media Type: Content-Type must be application/json")),q(415,-32000,"Unsupported Media Type: Content-Type must be application/json");let I=await St(h,D?.parsedBody,!0,d);if(I.step==="unreadable-body")return q(400,-32700,"Parse error: the request body could not be read");if(I.step==="body-too-large")return q(413,-32000,Me(d));if(I.step==="no-json-body"){if(v!==void 0)return v(I.forwardRequest,{...w!==void 0&&{authInfo:w}});return q(400,-32700,"Parse error: the request body is not valid JSON")}let{outcome:C,body:U,parsedBody:G,forwardRequest:_}=I;try{switch(C.kind){case"reject":return p(Error(`Rejected inbound request (${C.cell}): ${C.message}`)),te(C,F(U));case"modern":return await E(C,h,w);case"legacy":return await M(C,_,w,G)}}catch(k){return p(H(k)),J(F(U))}}return{fetch:async(h,D)=>{if(m)throw Error("This MCP handler has been closed");try{return await T(h,D)}catch(w){return p(H(w)),J(F(D?.parsedBody))}},notify:b,bus:g,close:async()=>{m=!0,R.closeAll();let h=[...u].map((D)=>D.close().catch(()=>{}));u.clear(),await Promise.all(h)}}}var ne="v1.";function me(n){let o="";for(let s of n)o+=String.fromCodePoint(s);return btoa(o).replaceAll("+","-").replaceAll("/","_").replace(/=+$/,"")}function bt(n,o){if(n.length!==o.length)return!1;let s=0;for(let a=0;a<n.length;a++)s|=n.codePointAt(a)^o.codePointAt(a);return s===0}function _e(n){let o=n.replaceAll("-","+").replaceAll("_","/"),s=atob(o),a=new Uint8Array(s.length);for(let c=0;c<s.length;c++)a[c]=s.codePointAt(c);return a}function BZ(n){let o=globalThis.crypto?.subtle;if(o===void 0)throw TypeError("createRequestStateCodec requires the Web Crypto API (globalThis.crypto.subtle); see https://ts.sdk.modelcontextprotocol.io/v2/troubleshooting for the Node.js polyfill instructions");let s=typeof n.key==="string"?new TextEncoder().encode(n.key):Uint8Array.from(n.key);if(s.byteLength<32)throw RangeError(`createRequestStateCodec: key must be at least 32 bytes (got ${s.byteLength})`);let a=n.ttlSeconds??600;if(!Number.isFinite(a))throw RangeError("createRequestStateCodec: ttlSeconds must be a finite number");let c=n.bind,d,u=()=>d??=o.importKey("raw",s,{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"]),m=new TextEncoder,p="mcp.requestState.bind:",g=async(b)=>me(new Uint8Array(await o.sign("HMAC",await u(),m.encode(p+b))).slice(0,16));return{async mint(b,R){let v={p:b,exp:Math.floor(Date.now()/1000)+a};if(c!==void 0){if(R===void 0)throw TypeError("createRequestStateCodec: mint() requires ctx when a bind callback is configured");v.b=await g(c(R))}let E=me(m.encode(JSON.stringify(v)));return`${ne}${E}.${me(new Uint8Array(await o.sign("HMAC",await u(),m.encode(ne+E))))}`},async verify(b,R){let v=b.lastIndexOf(".");if(!b.startsWith(ne)||v<=3)throw Error("malformed");let E=b.slice(3,v),M;try{M=_e(b.slice(v+1))}catch{throw Error("malformed")}if(!await o.verify("HMAC",await u(),M,m.encode(ne+E)))throw Error("mac");let T;try{T=JSON.parse(new TextDecoder("utf-8",{fatal:!0}).decode(_e(E)))}catch{throw Error("malformed")}if(typeof T.exp!=="number"||T.exp<Math.floor(Date.now()/1000))throw Error("expired");if(c!==void 0){let S=await g(c(R));if(T.b===void 0||!bt(T.b,S))throw Error("bind")}else if(T.b!==void 0)throw Error("bind");return T.p}}}var Ey="io.modelcontextprotocol/tasks",Rt=-32021,xt=-32602,C6={resultType:"complete"};function V(n){return typeof n==="object"&&n!==null&&!Array.isArray(n)}function Ne(n){return V(n)&&D6(n[Ar])}function Iy(n){return Ne(n.envelope)||Ne(n.meta)}function D6(n){if(!V(n)||!V(n.extensions))return!1;return V(n.extensions[Ey])}function Hf(n){return V(n)&&n.resultType==="task"&&typeof n.taskId==="string"}function UN(){return new he(Rt,"Missing required client capability",{requiredCapabilities:{extensions:{[Ey]:{}}}})}function FI(n){return new he(xt,n==="expired"?"Failed to retrieve task: Task has expired":"Failed to retrieve task: Task not found")}function Le(n){return new Date(n).toISOString()}function Fe(n){return{taskId:n.taskId,status:n.status,...n.statusMessage!==null&&{statusMessage:n.statusMessage},createdAt:Le(n.createdAtMs),lastUpdatedAt:Le(n.lastUpdatedAtMs),ttlMs:n.expiresAtMs===null?null:n.expiresAtMs-n.createdAtMs,pollIntervalMs:n.pollIntervalMs}}function $Z(n){return{resultType:"task",...Fe(n)}}function UZ(n){let o=Fe(n);switch(n.status){case"input_required":return{resultType:"complete",...o,inputRequests:n.inputRequests??{}};case"completed":return{resultType:"complete",...o,result:n.result??{content:[]}};case"failed":return{resultType:"complete",...o,error:n.error??{code:-32603,message:"Internal error"}};default:return{resultType:"complete",...o}}}var Dt=["tasks/get","tasks/update","tasks/cancel"];function QH(n){return Dt.includes(n)}function HN(n){if(!oe(n)||typeof n.ownerKey!=="string"||n.ownerKey.trim().length===0||typeof n.declared!=="boolean")return;return{ownerKey:n.ownerKey,declared:n.declared}}function O6(){return{[Ar]:{extensions:{[Ey]:{}}}}}function oe(n){return typeof n==="object"&&n!==null&&!Array.isArray(n)}var HZ=IR({});function qZ(n){return{resultType:"complete",...oe(n)?n:{}}}function VZ(n){if(!oe(n)||typeof n.taskId!=="string"||typeof n.status!=="string"||typeof n.createdAt!=="string"||"isError"in n||"structuredContent"in n||n.content!==void 0&&!(Array.isArray(n.content)&&n.content.length===0))return;let o={resultType:"task",...n};return delete o.content,o}function WZ(n){if(!(n instanceof he)||typeof n.code!=="number")return;let o=`MCP error ${n.code}: `,s=n.message.startsWith(o)?n.message.slice(o.length):n.message;return{code:n.code,message:s,...n.data!==void 0&&{data:n.data}}}function eq(n){return oe(n)&&typeof n.code==="number"&&typeof n.message==="string"}function zZ(n){return new he(n.code,n.message,n.data)}var LI=f({port:A().finite().optional(),host:y().optional(),strictPort:Z().optional(),debug:Z().optional(),debugPerf:Z().optional(),planExecutionLockScope:P(["session","global"]).optional(),runnerReadinessTimeoutMs:A().finite().optional(),videoQualityPreset:y().optional(),videoTargetBitrateKbps:A().finite().optional(),videoMaxThroughputMbps:A().finite().optional(),videoFps:A().finite().optional(),videoFormat:y().optional(),videoMaxArchiveSizeMb:A().finite().optional(),toolOutputsDir:y().optional(),networkMockable:Z().optional(),embeddedSdk:Z().optional(),enabledTools:z(y()).optional(),disabledTools:z(y()).optional(),dismissKeyboardAfterInput:Z().optional(),eventAllMarkers:z(y()).optional(),eventAllMarkersCliOverride:Z().optional(),noUiPerfMode:Z().optional(),memPerfAudit:Z().optional(),accessibilityAudit:Z().optional(),accessibilityLevel:y().optional(),accessibilityFailureMode:y().optional(),accessibilityMinSeverity:y().optional(),accessibilityUseBaseline:Z().optional(),predictiveUi:Z().optional(),rawElementSearch:Z().optional(),skipCtrlProxyDownload:Z().optional(),toolCallRecording:Z().optional(),noNavigationScreenshots:Z().optional(),noWaitForPollingOverhead:Z().optional(),noA11yIncludeNotImportantViews:Z().optional(),noA11yReportViewIds:Z().optional(),noA11yRetrieveInteractiveWindows:Z().optional(),noOcclusion:Z().optional(),observeResultIncludeElements:Z().optional(),toolResultsNoStructuredContent:Z().optional(),actionsDiffObserve:Z().optional(),actionsNoObserve:Z().optional(),actionsCompactMetadata:Z().optional()});var Ue=256,B=2000,Tt=f({unavailableSockets:z(f({code:ee("AUXILIARY_SOCKET_UNAVAILABLE"),holderPid:A().int().positive().optional(),holderVersion:y().optional(),holderVerified:Z().optional(),name:y(),socketPath:y().min(1)})).optional(),reportedPidFilePath:y().min(1).optional(),reportedSocketPath:y().min(1).optional(),reportedSockets:kt(y(),y().min(1)).optional(),launchNonce:y().optional(),processStartedAt:A().finite().optional(),dbPath:y().min(1).optional(),pid:A().int().positive().optional(),version:y().trim().min(1),buildId:y().optional(),entryScript:y().optional(),releaseVersion:y().optional(),startedAt:A().finite().optional(),processGenerationToken:y().optional(),processGenerationTokenUtc:y().optional(),activeProvisioning:Z().optional(),structuredSessionNotFound:Z().optional(),structuredToolErrorCodes:Z().optional(),acceptanceCapabilityFingerprint:y().nullable().optional()}),wt=f({options:LI.optional(),effectiveDebug:Z().optional()});function At(n){if(we(n.handshakeFailure))return new MI(n.handshakeFailure,n.error||"Daemon identity mismatch");if(le(n.daemonShuttingDown))return new Ud(n.daemonShuttingDown.requestMayHaveDispatched===!0);let o=Ce(n.overloadFailure);if(o)return new zs(n.error||"Daemon rejected overloaded MCP work",o);return}function It(n){let o=i7(n.boundSessionLoss);if(o)return new tA(o);let s=XH(n.transportFailure);if(s)return new Uf(n.error||"Device-control transport failure",s);return}function _t(n){let o=n7(n.requestFailureCause),s=o?Error(o.message):void 0;if(s&&o)s.name=o.name;return new t(n.error||"Unknown error from daemon",{cause:s})}var Mt=f({state:P(["live","suspect","lapsed"]),remainingMs:A().finite().nonnegative(),holdRemainingMs:A().finite().nonnegative()});function Ot(n){let o=Mt.safeParse(n.result?.liveness);return o.success?o.data:void 0}function Pt(n){if(typeof n.releaseReason!=="string"||n.releaseReason.length===0)return{};return Jf(n.releaseReason,typeof n.idleTimeoutMs==="number"?n.idleTimeoutMs:void 0)}function qt(n){return{...typeof n.retryable==="boolean"?{retryable:n.retryable}:{},...typeof n.retryAfterMs==="number"?{retryAfterMs:n.retryAfterMs}:{},...typeof n.nextAction==="string"?{nextAction:n.nextAction}:{},...n.details&&typeof n.details==="object"?{details:n.details}:{}}}function Be(n){return n===void 0?{}:{tasks:n}}function Nt(n){return eq(n.jsonRpcError)?{jsonRpcError:n.jsonRpcError}:{}}function ge(n){let o=At(n)??It(n)??_t(n),s=[n.code,n.handshakeFailure?.code,n.daemonShuttingDown?.code,n.overloadFailure?.code,n.boundSessionLoss?.code,n.transportFailure?.code].find((d)=>d!==void 0),a=Dc(n);if(a!==void 0)Object.assign(o,{daemonInstance:a});if(s===void 0)return o;let c=s===fS?Ot(n):void 0;return Object.assign(o,{code:s,...Nt(n),...qt(n),...c?{livenessOwnerHold:c}:{},...Pt(n)})}function tq(n,o){let s=Tt.safeParse(n);if(!s.success)throw new t("Daemon preflight failed: the socket owner returned no version identity; no device operation started. Restart the daemon from this client installation.");let a=wt.safeParse(n);if(!a.success)throw new t("Daemon preflight failed: the socket owner returned a valid identity but malformed startup options; no device operation started. Restart the daemon from this client installation.");let{releaseVersion:c,...d}=s.data;return{running:!0,...d,socketPath:o,...a.data.options?{options:a.data.options}:{},...a.data.effectiveDebug!==void 0?{effectiveDebug:a.data.effectiveDebug}:{},...c?{assetVersion:c}:{}}}function He(n,o){if(!o.trim()||n.inboundClosed)return;let s;try{s=JSON.parse(o)}catch(d){e.error(`Error parsing daemon response: ${d}`);return}let a=o7.safeParse(s);if(a.success){Lt(n,a.data);return}let c=r7.safeParse(s);if(c.success){n.handleResponse(c.data);return}e.warn("Dropped daemon frame: invalid response or notification envelope")}function Lt(n,o){if(o.method===QN&&o.requestId!==void 0&&typeof o.timeoutMs==="number"){n.adoptPendingRequestBudget(o.requestId,o.timeoutMs);return}if(o.method===hS&&o.progressToken!==void 0){if(o.requestId!==void 0)n.extendPendingRequestOnProgress(o.requestId,o.progressToken)}for(let s of n.notificationHandlers)try{s(o)}catch(a){e.warn(`Daemon notification handler failed for ${o.method}: ${a}`)}}function $e(n,o){if(o.id===null){if(n.pendingRequests.size!==1){e.warn(`Received uncorrelatable daemon response with ${n.pendingRequests.size} pending requests; dropping response`);return}let a=new t(o.error??"Daemon could not parse a socket request"),c=n.pendingRequests.values().next().value;if(!c)return;n.timer.clearTimeout(c.timeout),c.removeAbortListener?.(),c.reject(a),n.pendingRequests.clear();return}let s=n.pendingRequests.get(o.id);if(!s&&n.cancelledRequestIds.delete(o.id)){e.debug(`Dropped daemon response for cancelled request ID: ${o.id}`);return}if(!s){e.warn(`Received response for unknown request ID: ${o.id}`);return}if(n.timer.clearTimeout(s.timeout),s.removeAbortListener?.(),n.pendingRequests.delete(o.id),o.success)s.resolve(o);else s.reject(ge(o))}function Je(n,o,s,a){let{signal:c}=a,d=()=>{},u=()=>{d(),n.timedOutRequestAbortCleanups.delete(o)};return new Promise((m,p)=>{let g=a.armTimeout(p,u);n.pendingRequests.set(o,{...a.entry,resolve:(E)=>{m(E.result)},reject:p,timeout:g,removeAbortListener:u}),a.onRegistered?.();let b=(E)=>{n.timer.clearTimeout(g),u(),n.pendingRequests.delete(o),p(E)},R=n.socket();if(!R||c?.aborted){b(c?.aborted?a.abortError():a.socketLostError());return}try{R.write(s)}catch(E){b(a.writeError(E));return}if(!c)return;let v=()=>{let E=n.pendingRequests.get(o);if(!E&&!n.timedOutRequestAbortCleanups.has(o))return;if(n.timer.clearTimeout(E?.timeout??g),n.pendingRequests.delete(o),u(),n.sendCancelFrame(o),a.destroyOnAbort)n.socket()?.destroy();if(E)p(a.abortError())};if(c.addEventListener("abort",v,{once:!0}),d=()=>c.removeEventListener("abort",v),c.aborted)v()})}import{existsSync as $t}from"fs";import{platform as Jt}from"os";function se(n){let{value:o,encoded:s}=YQ(n);if(s&&n.type==="mcp_request"&&n.method==="tools/call"){let a=o.params;if(a&&typeof a==="object"){let c=a.arguments&&typeof a.arguments==="object"&&!Array.isArray(a.arguments)?a.arguments:{};a.arguments={...c,[rL]:!0}}}return JSON.stringify(o)+`
16
+ `}function je(n,o){for(let s=o+1;s<n.length;s++)if(n[s]==="\\")s++;else if(n[s]==='"')return s;return-1}function Ve(n,o){let s=n?.toString("utf8");if(!s?.startsWith('{"'))return;try{let a=je(s,1);if(JSON.parse(s.slice(1,a+1))!=="id")return null;if(!s.slice(a+1).startsWith(':"'))return;let d=a+2,u=je(s,d),m=JSON.parse(s.slice(d,u+1));return o(m)?m:null}catch{e.debug("Oversized daemon frame head contained no complete response id");return}}import{createConnection as Ft}from"net";function ze(n,o,s){return new Promise((a,c)=>{let d=!1,u=void 0,m=()=>{},p=()=>n.getSocket()!==null&&n.getSocket()!==u,g=(v)=>{if(p())return;n.timer.clearTimeout(b),m(),n.setConnected(!1),n.setSocket(null),u?.destroy();let E=Y(v);if(n.rejectPendingRequests(E,!0),!d)d=!0,c(E)},b=n.timer.setTimeout(()=>{g(new fe(`Failed to connect to daemon within ${o}ms`))},o);if(s){let v=()=>g(new fe("Daemon connection attempt aborted",{cause:s.reason}));s.addEventListener("abort",v,{once:!0}),m=()=>s.removeEventListener("abort",v)}let R=Ft(n.socketPath,()=>{if(d||!u||u.destroyed||p())return;if(n.timer.clearTimeout(b),m(),n.resetInbound(),n.setConnected(!0),e.info(`Connected to daemon at ${n.socketPath}`),!d)d=!0,a()});if(u=R,d){u.on("error",()=>{}),u.destroy();return}n.setSocket(u),u.on("data",(v)=>{if(p())return;n.handleData(typeof v==="string"?Buffer.from(v):v)}),u.on("error",(v)=>{if(p())return;e.error(`Daemon socket error: ${v.message}`),g(v)}),u.once("close",()=>ve(n,R))})}function ve(n,o){let s=n.getSocket();if(s!==null&&s!==o||n.hasClosedSocket(o))return;if(n.handleSocketClosed(o),n.hasPendingRequests())n.rejectPendingRequests(new fe("Daemon socket connection lost: connection closed"),!0)}import{createConnection as Ut}from"net";import{statSync as Bt}from"fs";import{platform as Ht}from"os";async function Ge(n,o={}){let s=o.timer??i;if(Ht()!=="win32")try{if(!Bt(n).isSocket())return!1}catch(a){return e.debug(`src/daemon/client/client.ts fallback failed: ${a}`,a),!1}return new Promise((a)=>{let c=!1,d=(g)=>{if(!c)c=!0,o.signal?.removeEventListener("abort",u),a(g)},u=()=>{s.clearTimeout(p),m.destroy(),d(!1)},m=Ut(n,()=>{s.clearTimeout(p),m.destroy(),d(!0)});m.on("error",()=>{s.clearTimeout(p),m.destroy(),d(!1)});let p=s.setTimeout(()=>{m.destroy(),d(!1)},o.timeoutMs??1000);if(o.signal?.aborted)u();else o.signal?.addEventListener("abort",u,{once:!0})})}function Ke(n,o){let s=n instanceof Error?n:new fe(String(n)),a=o.pidFilePath??vr,c=So(a);if(!c||typeof c.pid!=="number")return s;if((o.isProcessRunning??((u)=>nt(u,{debugLog:e.debug})))(c.pid))return s;return new fe(`${s.message} \u2014 the recorded daemon PID ${c.pid} is not running; the socket may be stale and will be reclaimed automatically the next time the daemon starts (run \`--daemon restart\` if this persists)`)}class _y extends Error{toolName;origin;constructor(n){let o=n.detail?` (${n.detail})`:"";super(`Daemon disconnected before ${n.toolName} responded at ${n.origin}${o}`);this.name="DaemonDisconnectError",this.toolName=n.toolName,this.origin=n.origin}}class xy extends fe{constructor(n,o){super(n,o);this.name="DaemonRequestNotDeliveredError"}}function Qe(n,o,s=process.env){let a=jN(n,s);return iA(n,s)!==void 0?a:Math.max(a,mS(o)??0)}class Ee extends t{limitBytes;constructor(n){super(`Daemon response frame exceeded ${n} bytes; the daemon connection was closed.`);this.limitBytes=n;this.name="DaemonFrameTooLargeError"}}class ya{socket=null;socketPath;connectionTimeout;timer;pendingRequests=new Map;cancelledRequestIds=new Set;timedOutRequestAbortCleanups=new Map;framer;inboundClosed=!1;closedSockets=new WeakSet;connected=!1;connectInFlight=null;notificationHandlers=new Set;connectionClosedHandlers=new Set;recoveryOptions;clientIdentity;idGenerator;platform;maxInboundFrameBytes;env;constructor(n=Ct,o=oL,s=i,{recoveryOptions:a={},clientIdentity:c,idGenerator:d=L,platformOverride:u=Jt(),maxInboundFrameBytes:m=KQ,env:p=process.env}={}){this.socketPath=n,this.connectionTimeout=o,this.timer=s,this.recoveryOptions=a,this.clientIdentity=c===void 0?JH():c,this.idGenerator=d,this.platform=u,this.maxInboundFrameBytes=m,this.env=p,this.framer=this.createInboundFramer()}get testHooks(){return{attachSocket:(n)=>{this.socket=n,this.connected=!0,this.inboundClosed=!1,this.framer=this.createInboundFramer()},simulateIncomingData:(n)=>this.handleData(n),findPendingRequestIdByProgressToken:(n)=>[...this.pendingRequests].find(([,o])=>o.progressToken===n)?.[0],hasPendingRequest:(n)=>this.pendingRequests.has(n),connection:()=>({connected:this.connected,socket:this.socket}),socketClosed:(n)=>ve(this.connectorHost(),n),declaredIdentity:()=>this.clientIdentity,socketPathObservable:()=>this.socketPathObservable()}}handshakeFields(){if(!this.clientIdentity)return{};return{clientVersion:this.clientIdentity.version,clientBuildId:this.clientIdentity.build.buildId,clientEntryScript:this.clientIdentity.build.entryScript}}static async isAvailable(n=Ct,o={}){return Ge(n,o)}async connect(n=this.connectionTimeout,o){if(this.connected)return;if(this.connectInFlight)try{await l(this.connectInFlight,{timer:this.timer,timeoutMs:n,signal:o,label:"Daemon connection attempt",timeoutError:()=>this.annotateStaleSocketHint(new fe(`Failed to connect to daemon within ${n}ms`))});return}catch(a){if(o?.aborted&&a===o.reason)throw this.annotateStaleSocketHint(new fe("Daemon connection attempt aborted",{cause:o.reason}));throw a}let s=(async()=>{let a=this.timer.now()+n;try{if(this.clientIdentity!==null&&!Qd())await Zd();await this.connectOnce(this.remainingConnectTimeout(a,n),o)}catch(c){throw this.annotateStaleSocketHint(c)}})();this.connectInFlight=s;try{await s}finally{this.connectInFlight=null}}annotateStaleSocketHint(n){return Ke(n,this.recoveryOptions)}remainingConnectTimeout(n,o){let s=n-this.timer.now();if(s<=0)throw new fe(`Failed to connect to daemon within ${o}ms`);return s}socketPathObservable(){return this.platform==="win32"||$t(this.socketPath)}async connectOnce(n,o){if(this.connected)return;if(o?.aborted)throw new fe("Daemon connection attempt aborted",{cause:o.reason});if(!this.socketPathObservable())throw new fe(`Daemon socket not found: ${this.socketPath}`);return ze(this.connectorHost(),n,o)}connectorHost(){return{timer:this.timer,socketPath:this.socketPath,getSocket:()=>this.socket,setSocket:(n)=>{this.socket=n},setConnected:(n)=>{this.connected=n},resetInbound:()=>{this.framer=this.createInboundFramer(),this.inboundClosed=!1},handleData:(n)=>this.handleData(n),handleSocketClosed:(n)=>this.handleSocketClosed(n),hasClosedSocket:(n)=>this.closedSockets.has(n),hasPendingRequests:()=>this.pendingRequests.size>0,rejectPendingRequests:(n,o)=>this.rejectPendingRequests(n,o)}}rejectPendingRequests(n,o){for(let s of this.timedOutRequestAbortCleanups.values())s();for(let[,{reject:s,timeout:a,removeAbortListener:c,disconnectCause:d}]of this.pendingRequests)this.timer.clearTimeout(a),c?.(),s(o?new fe(n.message,{cause:d}):n);this.pendingRequests.clear()}handleData(n){if(!this.inboundClosed)this.framer.push(n)}createInboundFramer(){return new qc(this.maxInboundFrameBytes,{onLine:(n)=>this.handleInboundLine(n),onOverflow:(n)=>this.handleInboundOverflow(n)})}handleInboundLine(n){return He({inboundClosed:this.inboundClosed,handleResponse:this.handleResponse.bind(this),extendPendingRequestOnProgress:this.extendPendingRequestOnProgress.bind(this),adoptPendingRequestBudget:this.adoptPendingRequestBudget.bind(this),notificationHandlers:this.notificationHandlers,pendingRequests:this.pendingRequests,timer:this.timer,cancelledRequestIds:this.cancelledRequestIds},n)}handleResponse(n){if(n.id!==null)this.timedOutRequestAbortCleanups.get(n.id)?.();$e({pendingRequests:this.pendingRequests,timer:this.timer,cancelledRequestIds:this.cancelledRequestIds},n)}handleInboundOverflow(n){let o=new Ee(this.maxInboundFrameBytes);e.warn(o.message);let s=Ve(n,(d)=>this.pendingRequests.has(d)),a=s===void 0&&this.pendingRequests.size===1?this.pendingRequests.keys().next().value:s,c=this.socket;for(let[d,u]of this.pendingRequests)this.timer.clearTimeout(u.timeout),u.removeAbortListener?.(),u.reject(d===a?o:new fe(`Daemon socket connection lost: another frame on the connection exceeded ${this.maxInboundFrameBytes} bytes`,{cause:o}));this.pendingRequests.clear();try{this.handleSocketClosed(c)}finally{c?.destroy()}}handleSocketClosed(n){for(let o of this.timedOutRequestAbortCleanups.values())o();if(n)this.closedSockets.add(n);this.connected=!1,this.socket=null,this.inboundClosed=!0,this.framer=this.createInboundFramer(),e.info("Daemon socket connection closed");for(let o of this.connectionClosedHandlers)o()}extendPendingRequestOnProgress(n,o){let s=this.pendingRequests.get(n);if(s?.progressToken!==o||!s.deadline||s.requestTimeoutMs===void 0)return;let a=this.timer.now();s.deadline.extendOnProgress(a,s.requestTimeoutMs);let c=s.deadline.value-a;if(c<=0)return;this.timer.clearTimeout(s.timeout),s.timeout=this.scheduleRequestTimeout(n,s.toolName,c,s.reject)}adoptPendingRequestBudget(n,o){let s=this.pendingRequests.get(n);if(!s||s.requestTimeoutMs===void 0||!Number.isFinite(o)||o<=0||o===s.requestTimeoutMs)return;let a=this.timer.now();if(s.deadline)s.deadline=new Kf(a,o);s.requestTimeoutMs=o,this.timer.clearTimeout(s.timeout),s.timeout=this.scheduleRequestTimeout(n,s.toolName,o,s.reject)}scheduleResponseBackstop(n,o,s){let a=Math.min(s,Nr);return this.timer.setTimeout(()=>{if(s>a){let c=this.pendingRequests.get(n);if(c)c.timeout=this.scheduleResponseBackstop(n,o,s-a)}else o()},a)}scheduleRequestTimeout(n,o,s,a){return this.scheduleResponseBackstop(n,()=>{this.pendingRequests.get(n)?.removeAbortListener?.(),this.pendingRequests.delete(n),this.sendCancelFrame(n),a(new xr({toolName:o,timeoutMs:s,origin:"DaemonClient.sendRequest",detail:`no response from the daemon within budget + grace (${s}ms + ${B}ms)`}))},s+B)}sendCancelFrame(n){let o=this.socket;if(!o||o.destroyed)return;let s=this.idGenerator.next();this.rememberCancelledRequestId(n),this.rememberCancelledRequestId(s);let a={id:s,type:"daemon_request",method:cw,params:{requestId:n},...this.handshakeFields()};try{o.write(se(a))}catch(c){e.debug(`Daemon cancel frame for ${n} not sent: ${c}`)}}rememberCancelledRequestId(n){if(this.cancelledRequestIds.add(n),this.cancelledRequestIds.size>Ue){let o=this.cancelledRequestIds.values().next().value;if(o!==void 0)this.timedOutRequestAbortCleanups.get(o)?.(),this.cancelledRequestIds.delete(o)}}onNotification(n){return this.notificationHandlers.add(n),()=>{this.notificationHandlers.delete(n)}}onConnectionClosed(n){return this.connectionClosedHandlers.add(n),()=>{this.connectionClosedHandlers.delete(n)}}async subscribeToNotifications(n){await this.callDaemonMethod(fT,{},{...n,abortMode:"request"})}async getDaemonStatus(n){let o=new ya(this.socketPath,this.connectionTimeout,this.timer,{recoveryOptions:{},clientIdentity:null});try{let s=await o.callDaemonMethod("ide/status",{},{timeoutMs:n});return tq(s,this.socketPath)}finally{await o.close()}}async callTool(n,o,s,a={}){return this.sendRequest("tools/call",{name:n,arguments:o},s,a)}async relayTaskMethod(n,o,s,{signal:a}={}){return this.sendRequest(n,o,void 0,{signal:a,tasks:s})}async readResource(n,o={},{signal:s}={}){return this.sendRequest("resources/read",{uri:n,...o},void 0,{signal:s})}async sendRequest(n,o,s,{onRequestId:a,signal:c,tasks:d}={}){if(c?.throwIfAborted(),!this.connected)try{await l(()=>this.connect(),{timer:this.timer,signal:c,label:`Daemon request ${n} connection`})}catch(E){if(E instanceof fe)throw new xy(E.message,{cause:E});throw E}c?.throwIfAborted();let u=this.idGenerator.next(),m={id:u,type:"mcp_request",method:n,params:o,...s!==void 0?{progressToken:s}:{},acceptsRequestBudget:!0,...Be(d),...this.handshakeFields()},p=Qe(m,this.connectionTimeout,this.env);m.timeoutMs=p,m.requestedTimeoutMs=mS(iA(m,this.env));let g=se(m),b=n==="tools/call"?o?.name??n:n,R=new _y({toolName:b,origin:"DaemonClient.sendRequest"}),v=s!==void 0?new Kf(this.timer.now(),p):void 0;return this.send(u,g,{entry:{toolName:b,progressToken:s,deadline:v,requestTimeoutMs:p,disconnectCause:R},signal:c,armTimeout:(E)=>this.scheduleRequestTimeout(u,b,p,E),onRegistered:()=>a?.(u),socketLostError:()=>new xy("Socket connection lost"),writeError:(E)=>new xy(`Daemon socket write failed: ${r(E)}`,{cause:E}),abortError:()=>c?.reason,destroyOnAbort:!1})}async callDaemonMethod(n,o={},s={}){let a=s.timeoutMs??this.connectionTimeout;if(!Number.isFinite(a)||a<=0)throw new fe(`Daemon request ${n} has no remaining timeout`);if(s.signal?.aborted)throw new fe(`Daemon request ${n} aborted`,{cause:s.signal.reason});let c=this.timer.now()+a;if(!this.connected)await this.connect(this.remainingConnectTimeout(c,a),s.signal);if(s.signal?.aborted)throw new fe(`Daemon request ${n} aborted`,{cause:s.signal.reason});let d=c-this.timer.now();if(d<=0)throw new xr({toolName:n,timeoutMs:a,origin:"DaemonClient.callDaemonMethod"});let u=this.idGenerator.next(),m=new _y({toolName:n,origin:"DaemonClient.callDaemonMethod"}),p={id:u,type:"daemon_request",method:n,params:o,timeoutMs:d,...this.handshakeFields()};return this.send(u,se(p),{entry:{toolName:n,disconnectCause:m},signal:s.signal,armTimeout:(g,b)=>this.scheduleResponseBackstop(u,()=>{if(this.pendingRequests.delete(u),s.cancelOnTimeout!==!1)b(),this.sendCancelFrame(u);else{if(s.signal)this.timedOutRequestAbortCleanups.set(u,b);this.rememberCancelledRequestId(u)}g(new xr({toolName:n,timeoutMs:a,origin:"DaemonClient.callDaemonMethod",detail:`no response from the daemon within budget + grace (${d}ms + ${B}ms)`}))},d+B),socketLostError:()=>new fe("Socket connection lost"),writeError:(g)=>Y(g instanceof Error?g:Error(String(g))),abortError:()=>new fe(`Daemon request ${n} aborted`,{cause:s.signal?.reason}),destroyOnAbort:s.abortMode!=="request"})}send(n,o,s){let a={socket:()=>this.socket,pendingRequests:this.pendingRequests,timedOutRequestAbortCleanups:this.timedOutRequestAbortCleanups,timer:this.timer,sendCancelFrame:(c)=>this.sendCancelFrame(c)};return Je(a,n,o,s)}async close(){this.connected=!1,this.rejectPendingRequests(new fe("Socket connection closed"),!0);let n=this.socket;if(n)await new Promise((o)=>{let s=(d)=>{if(n.off("close",a),this.timer.clearTimeout(c),d)e.warn("Daemon socket close did not complete before the bounded teardown timeout; proceeding safely");o()},a=()=>s(!1),c=this.timer.setTimeout(()=>s(!0),1000);n.once("close",a),n.destroy()}),this.socket=null;this.notificationHandlers.clear(),this.connectionClosedHandlers.clear()}}class dS extends fe{code="daemon_restart_pending";retryable=!0;constructor(){super("Daemon restart is pending; retry provisionDevice after the replacement becomes ready.");this.name="DaemonRestartPendingError"}}function M6(n){return{error:{code:n.code,message:n.message,retryable:n.retryable}}}function jZ(n){let o=M6(n);return{content:[{type:"text",text:JSON.stringify(o)}],structuredContent:o,isError:!0}}var We="another session acquired it while this call was in flight, so the call was cancelled. Acquire the device (setActiveDevice) and retry with that session's sessionUuid, or wait for the holder to release it.";function Ul(n){return{executionId:n.id,startTime:n.startTime,sessionClockStartTime:n.sessionClockStartTime}}function ye(n){return n.deviceControlCall!==!0&&(n.readOnlySessionAccess===!0||n.deviceReadCall===!0)}function Se(n,o){let s=n.readDeadlineMs?.()??Number.POSITIVE_INFINITY;return o?s+(n.sessionClockOffsetMs??0):s}function jt(n,o){if(n===void 0||n.requestCancelled===!0||n.abortController.signal.aborted)return!1;let s=Se(n,!0),a=Number.isFinite(s)?s:n.sessionClockStartTime+o.undatedForMs;return o.at<=a}function be(n,o,s){if(s===void 0)return!1;if(n===s.excludeExecutionId)return!0;if(s.sessionClockStartedAtOrBefore!==void 0&&(o===void 0||o.sessionClockStartTime>s.sessionClockStartedAtOrBefore))return!0;if(s.liveOnSessionClock&&!jt(o,s.liveOnSessionClock))return!0;return s.excludeReads===!0&&o!==void 0&&ye(o)}function Ye(n){if(n===void 0)return!0;return n.startedAtOrBefore===void 0&&n.sessionClockStartedAtOrBefore===void 0&&n.liveOnSessionClock===void 0&&n.excludeExecutionId===void 0&&n.onlyToolName===void 0&&n.onlySessionUuid===void 0&&!n.excludeReads}class Xe{executions=new Map;sessionExecutions=new Map;deviceExecutions=new Map;deviceLastActivityAt=new Map;sessionUuidExecutions=new Map;autolockSessionExecutions=new Map;executionEndListeners=new Set;sessionExecutionEndListeners=new Set;timer;idGenerator;daemonRestartPrepared=!1;daemonMaintenancePrepared=!1;activeProvisionDeviceQuery;autolockSessionResolver;sessionClockOffsetProvider=()=>0;constructor(n=i,o=L){this.timer=n,this.idGenerator=o}setSessionClockOffsetProvider(n){this.sessionClockOffsetProvider=n}setActiveProvisionDeviceQuery(n){this.activeProvisionDeviceQuery=n}setAutolockSessionResolver(n){this.autolockSessionResolver=n}startExecution(n,o,s,{transportSessionId:a,unresolvedAutolockMcpSessionId:c}={}){if(this.isDaemonRestartPrepared()||this.isDaemonMaintenancePrepared())throw new dS;let d=this.idGenerator.next(),u=this.timer.now(),m={id:d,toolName:n,sessionId:o,transportSessionId:a,sessionUuid:s,provisionalAutolockSessionUuid:c?this.autolockSessionResolver?.autolockSessionForMcpSession(c):void 0,startTime:u,sessionClockStartTime:u+this.sessionClockOffsetProvider(u),abortController:new AbortController};if(this.executions.set(d,m),o)this.registerSessionExecution(o,d);if(a&&a!==o)this.registerSessionExecution(a,d);if(s){let p=this.sessionUuidExecutions.get(s)??new Set;p.add(d),this.sessionUuidExecutions.set(s,p)}return m}prepareForDaemonRestart(){return this.prepareForDaemonRestartAdmission(!1)}prepareForAdmittedDaemonRestart(){if(!this.daemonMaintenancePrepared)return"restart_pending";return this.prepareForDaemonRestartAdmission(!0)}prepareForDaemonRestartAdmission(n){if(this.daemonRestartPrepared)return"restart_pending";if(this.daemonMaintenancePrepared&&!n)return"restart_pending";if(this.executions.size>0||this.activeProvisionDeviceQuery?.hasActiveProvisionDeviceOperation())return"active_operations";return this.daemonRestartPrepared=!0,"accepted"}clearDaemonRestartPreparation(){this.daemonRestartPrepared=!1}prepareForDaemonMaintenance(n){if(this.daemonMaintenancePrepared)return"maintenance_pending";if(n>0)return"active_sessions";if(this.executions.size>0||this.daemonRestartPrepared)return"active_operations";return this.daemonMaintenancePrepared=!0,"accepted"}clearDaemonMaintenancePreparation(){this.daemonMaintenancePrepared=!1}isDaemonRestartPrepared(){return this.daemonRestartPrepared}isDaemonMaintenancePrepared(){return this.daemonMaintenancePrepared}endExecution(n){let o=this.executions.get(n);if(!o)return;if(this.executions.delete(n),o.unsubscribeDeadlineExtensions?.(),this.unregisterDeviceExecutions(n,o.deviceIds),o.sessionId)this.unregisterSessionExecution(o.sessionId,n);if(o.transportSessionId&&o.transportSessionId!==o.sessionId)this.unregisterSessionExecution(o.transportSessionId,n);if(o.sessionUuid){let s=this.sessionUuidExecutions.get(o.sessionUuid);if(s?.delete(n),s?.size===0)this.sessionUuidExecutions.delete(o.sessionUuid)}if(o.resolvedAutolockSessionUuid)this.unregisterAutolockSessionExecution(o.resolvedAutolockSessionUuid,n);this.notifySessionExecutionEnded(o);for(let s of this.executionEndListeners)s()}onSessionExecutionEnded(n){return this.sessionExecutionEndListeners.add(n),()=>{this.sessionExecutionEndListeners.delete(n)}}getSessionClockStartTime(n){return this.executions.get(n)?.sessionClockStartTime}setExecutionDeadline(n,o,s){let a=this.executions.get(n);if(a)a.readDeadlineMs=o,a.sessionClockOffsetMs=this.sessionClockOffsetProvider(),a.unsubscribeDeadlineExtensions?.(),a.unsubscribeDeadlineExtensions=s?.(()=>{a.sessionClockOffsetMs=this.sessionClockOffsetProvider()})}getLatestSessionExecutionDeadlineMs(n,o={}){let s=this.sessionUuidExecutions.get(n),a=this.autolockSessionExecutions.get(n),c;for(let d of this.executions.values())if((d.provisionalAutolockSessionUuid===n||s?.has(d.id)||a?.has(d.id))&&!(o.excludeReads&&ye(d))){let m=Se(d,o.onSessionClock);c=c===void 0?m:Math.max(c,m)}return c}markSessionAdmitted(n){let o=this.executions.get(n);if(o)o.sessionAdmitted=!0}unmarkSessionAdmitted(n){let o=this.executions.get(n);if(o)o.sessionAdmitted=!1}markSessionlessDeviceUse(n,o){let s=this.executions.get(n);if(s)s.sessionlessDeviceUse??=new Set,s.sessionlessDeviceUse.add(o),s.sessionlessControlUse??=new Set,s.sessionlessControlUse.add(o)}unmarkSessionlessDeviceUse(n,o){let s=this.executions.get(n);if(s?.sessionlessControlUse?.delete(o),!s?.sessionlessReadReadiness?.has(o))s?.sessionlessDeviceUse?.delete(o)}markSessionlessReadReadiness(n,o,s){let a=this.executions.get(n);if(!a)return;a.sessionlessDeviceUse??=new Set,a.sessionlessDeviceUse.add(o),a.sessionlessReadReadiness??=new Map;let c=a.sessionlessReadReadiness.get(o)??new Set;c.add(s),a.sessionlessReadReadiness.set(o,c)}unmarkSessionlessReadReadiness(n,o,s){let a=this.executions.get(n);if(!a)return;let c=a.sessionlessReadReadiness?.get(o);if(c?.delete(s),!c?.size){if(a.sessionlessReadReadiness?.delete(o),!a.sessionlessControlUse?.has(o))a.sessionlessDeviceUse?.delete(o)}}cancelSessionlessDeviceUse(n,o={}){let s=0;for(let a of this.executions.values()){if(a.id===o.excludeExecutionId||!a.sessionlessDeviceUse?.has(n)||a.abortController.signal.aborted)continue;let c=new ct(a.toolName,n,void 0,{remedy:We});if(a.sessionlessControlUse?.has(n))this.abortExecution(a,c);else if(!this.cancelReadReadiness(a,n,c))continue;s++,e.info(`[ExecutionTracker] Cancelled sessionless execution ${a.id} on ${n}: a session acquired the device (tool=${a.toolName})`)}return s}cancelReadReadiness(n,o,s){let a=[...n.sessionlessReadReadiness?.get(o)??[]].filter((c)=>!c.signal.aborted);for(let c of a)c.abort(s);return a.length>0}markDeviceReadCall(n,o){let s=this.executions.get(n);if(s&&s.toolName===o&&!s.deviceControlCall)s.deviceReadCall=!0}markDeviceControlCall(n){let o=this.executions.get(n);if(o)o.deviceControlCall=!0,o.deviceReadCall=!1}getAdmittedSessionUse(n){let o=this.executions.get(n);if(!o?.sessionAdmitted||o.deviceReadCall||o.readOnlySessionAccess)return;return o.sessionUuid??o.resolvedAutolockSessionUuid}markReadOnlySessionAccess(n){let o=this.executions.get(n);if(o)o.readOnlySessionAccess=!0}markRequestCancelled(n){let o=this.executions.get(n);if(o)o.requestCancelled=!0}notifySessionExecutionEnded(n){let o=[...new Set([n.sessionUuid,n.resolvedAutolockSessionUuid,n.provisionalAutolockSessionUuid].filter((a)=>typeof a==="string"&&a.length>0))];if(o.length===0)return;let s=n.sessionAdmitted===!0&&!n.readOnlySessionAccess;for(let a of this.sessionExecutionEndListeners)try{a(o,{admitted:s,toolName:n.toolName})}catch(c){e.warn(`[ExecutionTracker] Session execution-end listener failed: ${r(c)}`)}}getActiveExecutionCount(){return this.executions.size}getActiveDeviceSessionExecutionCount(n){return new Set([...this.sessionUuidExecutions.get(n)??[],...this.autolockSessionExecutions.get(n)??[],...this.unresolvedAutolockExecutionIds(n)]).size}async cancelSessionExecutions(n,o="unspecified"){return this.cancelExecutionsForKey(n,this.sessionExecutions,"sessionId",{cancelReason:o})}async cancelToolExecutions(n,o="unspecified"){let s=Array.from(this.executions.values()).filter((a)=>a.toolName===n).map((a)=>a.id);return this.cancelExecutionIds(s,"toolName",n,{cancelReason:o})}async waitForToolExecutionsToEnd(n,o){return await this.waitUntilNoneActive(()=>this.hasActiveToolExecutionGlobal(n),o)}async waitForSessionExecutionsToEnd(n,o){return await this.waitUntilNoneActive(()=>this.hasActiveSessionExecutions(n),o)}async waitUntilNoneActive(n,o){if(!n())return!0;return await new Promise((s)=>{let a=!1,c={},d=(m)=>{if(a)return;if(a=!0,this.executionEndListeners.delete(u),c.handle!==void 0)this.timer.clearTimeout(c.handle);s(m)},u=()=>{if(!n())d(!0)};this.executionEndListeners.add(u),c.handle=this.timer.setTimeout(()=>d(!1),o),u()})}async cancelSessionUuidExecutions(n,o="unspecified",s={}){return this.cancelExecutionsForKey(n,this.sessionUuidExecutions,"sessionUuid",{cancelReason:o,...s})}bindDeviceExecution(n,o,s={}){let a=this.executions.get(n);if(!a)return;let c=a.revokedDeviceBindings?.get(o);if(c){if(s.skipRevoked)return;throw new t(c.message,{cause:c})}a.deviceIds??=new Set,a.deviceIds.add(o);let d=this.deviceExecutions.get(o)??new Set;d.add(n),this.deviceExecutions.set(o,d),this.deviceLastActivityAt.set(o,this.timer.now())}getActiveDeviceExecutionCount(n){return this.deviceExecutions.get(n)?.size??0}getDeviceIdleForMs(n){let o=this.deviceLastActivityAt.get(n);return o===void 0?null:Math.max(0,this.timer.now()-o)}async cancelDeviceExecutions(n,o="unspecified",s={}){if(s.onlySessionUuid!==void 0)this.revokeSessionDeviceBindings(n,o,s);return this.cancelExecutionIds(this.deviceExecutions.get(n),"deviceId",n,{cancelReason:o,...s})}revokeSessionDeviceBindings(n,o,s){let a=o instanceof Error?o:new t(o);for(let c of this.executions.values())if(c.id!==s.excludeExecutionId&&(s.onlyToolName===void 0||c.toolName===s.onlyToolName)&&(s.onlyToolName===void 0||c.deviceIds?.has(n))&&this.isInCancellationScope(c,s))c.revokedDeviceBindings??=new Map,c.revokedDeviceBindings.set(n,a)}hasActiveDeviceExecutions(n,o){return this.hasActiveExecutionsForKey(this.deviceExecutions,n,o)}async waitForDeviceExecutionsToEnd(n,o,s){return this.waitForExecutionsToEnd(()=>this.hasActiveDeviceExecutions(n,s),o)}async cancelDeviceSessionExecutions(n,o="unspecified",s={}){let a=new Set([...this.sessionUuidExecutions.get(n)??[],...this.autolockSessionExecutions.get(n)??[],...this.unresolvedAutolockExecutionIds(n)]);return this.cancelExecutionIds(a,"deviceSessionUuid",n,{cancelReason:o,...s})}async waitForDeviceSessionExecutionsToEnd(n,o,s){return this.waitForExecutionsToEnd(()=>this.hasActiveDeviceSessionExecutions(n,s),o)}async waitForExecutionsToEnd(n,o){if(!n())return!0;return await new Promise((s)=>{let a=!1,c={},d=(m)=>{if(a)return;if(a=!0,this.executionEndListeners.delete(u),c.handle!==void 0)this.timer.clearTimeout(c.handle);s(m)},u=()=>{if(!n())d(!0)};this.executionEndListeners.add(u),c.handle=this.timer.setTimeout(()=>d(!1),o),u()})}hasActiveDeviceSessionExecutions(n,o){return this.hasActiveSessionUuidExecutions(n,o)||this.hasActiveAutolockSessionExecutions(n,o)}hasActiveSessionUuidExecutions(n,o){return this.hasActiveExecutionsForKey(this.sessionUuidExecutions,n,o)}hasActiveSessionExecutions(n,o){return this.hasActiveExecutionsForKey(this.sessionExecutions,n,o)}setResolvedAutolockSessionUuid(n,o){let s=this.executions.get(n);if(!s)return;let a=s.provisionalAutolockSessionUuid;if(s.provisionalAutolockSessionUuid=void 0,s.resolvedAutolockSessionUuid===o){if(a&&a!==o)for(let c of this.executionEndListeners)c();return}if(s.resolvedAutolockSessionUuid)this.unregisterAutolockSessionExecution(s.resolvedAutolockSessionUuid,n);if(s.resolvedAutolockSessionUuid=o,o){let c=this.autolockSessionExecutions.get(o)??new Set;c.add(n),this.autolockSessionExecutions.set(o,c)}for(let c of this.executionEndListeners)c()}hasActiveAutolockSessionExecutions(n,o){return this.hasActiveExecutionsForKey(this.autolockSessionExecutions,n,o)||this.unresolvedAutolockExecutionIds(n).some((s)=>{let a=this.executions.get(s);return!be(s,a,o)&&(o?.onlyToolName===void 0||a?.toolName===o.onlyToolName)&&(o?.startedAtOrBefore===void 0||a!==void 0&&a.startTime<=o.startedAtOrBefore)})}unresolvedAutolockExecutionIds(n){let o=[];for(let s of this.executions.values())if(s.provisionalAutolockSessionUuid===n)o.push(s.id);return o}hasActiveToolExecution(n,o){if(o.scope==="global")return this.hasActiveToolExecutionGlobal(n);if(o.sessionUuid)return this.hasActiveToolExecutionForKey(n,this.sessionUuidExecutions,o.sessionUuid);if(o.sessionId)return this.hasActiveToolExecutionForKey(n,this.sessionExecutions,o.sessionId);return this.hasActiveToolExecutionGlobal(n)}hasActiveToolExecutionGlobal(n){for(let o of this.executions.values())if(o.toolName===n)return!0;return!1}unregisterDeviceExecutions(n,o){for(let s of o??[]){this.deviceLastActivityAt.set(s,this.timer.now());let a=this.deviceExecutions.get(s);if(a?.delete(n),a?.size===0)this.deviceExecutions.delete(s)}}registerSessionExecution(n,o){let s=this.sessionExecutions.get(n)??new Set;s.add(o),this.sessionExecutions.set(n,s)}unregisterSessionExecution(n,o){let s=this.sessionExecutions.get(n);if(s?.delete(o),s?.size===0)this.sessionExecutions.delete(n)}unregisterAutolockSessionExecution(n,o){let s=this.autolockSessionExecutions.get(n);if(s?.delete(o),s?.size===0)this.autolockSessionExecutions.delete(n)}hasActiveExecutionsForKey(n,o,s){let a=n.get(o);if(!a||a.size===0)return!1;if(Ye(s))return!0;return Array.from(a).some((c)=>{let d=this.executions.get(c);return d!==void 0&&!be(c,d,s)&&(s?.onlyToolName===void 0||d.toolName===s.onlyToolName)&&this.belongsToSessionFilter(d,s?.onlySessionUuid)&&(s?.startedAtOrBefore===void 0||d.startTime<=s.startedAtOrBefore)})}isInCancellationScope(n,o){return this.belongsToSessionFilter(n,o.onlySessionUuid)||o.includeExecutionIds?.includes(n.id)===!0}belongsToSessionFilter(n,o){return o===void 0||n.sessionUuid===o||n.resolvedAutolockSessionUuid===o||n.provisionalAutolockSessionUuid===o}hasActiveToolExecutionForKey(n,o,s){let a=o.get(s);if(!a||a.size===0)return!1;for(let c of a)if(this.executions.get(c)?.toolName===n)return!0;return!1}async cancelExecutionsForKey(n,o,s,{cancelReason:a="unspecified",...c}={}){return this.cancelExecutionIds(o.get(n),s,n,{cancelReason:a,...c})}async cancelExecutionIds(n,o,s,{cancelReason:a="unspecified",...c}={}){if(!n)return 0;let d=0;for(let u of n){let m=this.executions.get(u);if(!m)continue;if(m.id===c.excludeExecutionId||c.onlyToolName!==void 0&&m.toolName!==c.onlyToolName||!this.isInCancellationScope(m,c))continue;this.abortExecution(m,a),d++,e.info(`[ExecutionTracker] Cancelled execution ${u} for ${o}=${s} (tool=${m.toolName}, reason=${r(a)})`)}return d}abortExecution(n,o){if(qh(o)){let s=ke(o)??Error(o);if(n.cancelReason=s,ht(s))mv(n.abortController.signal,s);n.abortController.abort(s)}else if(o instanceof Error)n.cancelReason=o,n.abortController.abort(o);else n.abortController.abort()}}var j=new Xe;
17
+ export{YH,xZ,A6,T6,OI,CZ,k6,DZ,OZ,E6,tA,No,$d,ji,ks,JH,I6,MZ,MI,BN,$N,NI,_6,NZ,fe,Ud,Uf,XH,FZ,zs,Cu,ZH,xr,x6,LZ,BZ,Ey,C6,Iy,D6,Hf,UN,FI,$Z,UZ,QH,HN,O6,HZ,qZ,VZ,WZ,eq,zZ,LI,tq,_y,xy,ya,dS,M6,jZ,Ul,j};
18
+
19
+ //# debugId=15869A73483B61F364756E2164756E21
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{v}from"./chunk-h3n4adc6.js";import{g,E}from"./chunk-mf9spd4g.js";import{i,l}from"./chunk-z8t0v07j.js";var D=g.MANAGED_ADB_SERVER.name,M=g.MANAGED_ADB_SERVER.legacyName,m=5000;function d(e=process.env){let r=E(g.MANAGED_ADB_SERVER,e);return r?.trim().toLowerCase()==="1"||r?.trim().toLowerCase()==="true"}async function o2(e={}){let r=e.environment??process.env;if(!d(r))return;let o=e.shutdownTimeoutMs??m,a=e.timer??i,t=new AbortController,s=(e.adbFactory??v).create(),n=`Managed ADB server shutdown timed out after ${o}ms`;await l(s.execute(["kill-server"],{timeoutMs:o,noRetry:!0,signal:t.signal}),{timer:a,timeoutMs:o,label:"Managed ADB server shutdown",timeoutError:()=>Error(n),onTimeout:()=>t.abort(Error(n))})}
3
+ export{o2};
4
+
5
+ //# debugId=31D42D8EDAF1A0BC64756E2164756E21
@@ -0,0 +1,10 @@
1
+ // @bun
2
+ function moe(e){if(e.bun)return null;return`auto-mobile requires the Bun runtime (>= 1.4.4), but it was started with ${e.node?`Node.js ${e.node}`:"this JavaScript runtime"}.
3
+ Run it with Bun instead:
4
+ bun dist/src/index.js <args>
5
+ bunx @kaeawc/auto-mobile@latest <args>
6
+ Install Bun from https://bun.sh.
7
+ `}function foe(e){let t=moe(e.versions);if(t===null)return!0;return e.writeStderr(t),e.exit(1),!1}foe({versions:process.versions,writeStderr:(e)=>{process.stderr.write(e)},exit:(e)=>process.exit(e)});
8
+ export{moe,foe};
9
+
10
+ //# debugId=5160505FBCE5C88364756E2164756E21
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{Pl}from"./chunk-2v7tw1nj.js";function wp(n){if(n instanceof Error){let e=[n.name,n.message].filter(Boolean).join(": "),o=n.stack?.split(`
3
+ `).slice(0,3).join(" \u2190 "),i="cause"in n&&n.cause!==void 0?wp(n.cause):"";return[e||"Error",o,i?`cause=${i}`:""].filter(Boolean).join(" | ")}if(n===null||n===void 0)return String(n);if(typeof n==="object"){if(Object.keys(n).length===0)return`${Object.prototype.toString.call(n)} (no enumerable keys)`;return Pl(()=>JSON.stringify(n),()=>Object.prototype.toString.call(n))}return String(n)}function r(n){return Pl(()=>{if(n instanceof Error)return n.message;return String(n)},()=>Pl(()=>Object.prototype.toString.call(n),()=>"Unknown error"))}class t extends Error{constructor(n,e){super(n,e);let o=e?.containerFailure??(e?.cause instanceof t?e.cause.containerFailure:void 0);if(o)this.containerFailure=o}}function u(n,e){if(n instanceof t)return n;let o=r(n);return new t(`${e}: ${o}`,{cause:n})}function yt(n,e){return new t(`${e} is not supported on platform '${n}'. Supported platforms: android, ios.`)}export{wp,r,t,u,yt};
4
+
5
+ //# debugId=E1CAB873E461C44964756E2164756E21
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ function C(e,r,t,o,n){if(o==="m")throw TypeError("Private method is not writable");if(o==="a"&&!n)throw TypeError("Private accessor was defined without a setter");if(typeof r==="function"?e!==r||!n:!r.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return o==="a"?n.call(e,t):n?n.value=t:r.set(e,t),t}function d(e,r,t,o){if(t==="a"&&!o)throw TypeError("Private accessor was defined without a getter");if(typeof r==="function"?e!==r||!o:!r.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?o:t==="a"?o.call(e):o?o.value:r.get(e)}function Gl(e){return typeof e==="object"&&e!==null&&(("name"in e)&&e.name==="AbortError"||("message"in e)&&String(e.message).includes("FetchRequestCanceledException"))}var BS=(e)=>{if(e instanceof Error)return e;if(typeof e==="object"&&e!==null){try{let r=Object.prototype.toString.call(e);if(r==="[object Error]"||r==="[object DOMException]"){let t=Error(e.message,e.cause?{cause:e.cause}:{});if(e.stack)t.stack=e.stack;if(e.cause&&!t.cause)t.cause=e.cause;if(e.name)t.name=e.name;return t}}catch{}try{return Error(JSON.stringify(e))}catch{}}return Error(e)};var J=(()=>{class e extends Error{constructor(r,t){super(r,t);Object.defineProperty(this,"name",{value:new.target._errorName,writable:!0,configurable:!0})}}return e._errorName="AnthropicError",e})(),jr=(()=>{class e extends J{constructor(r,t,o,n,a){super(`${e.makeMessage(r,t,o)}`);this.status=r,this.headers=n,this.requestID=n?.get("request-id"),this.workspaceID=n?.get("anthropic-workspace-id"),this.error=t;let s=t??{};this.apiMessage=s.error?.message??null,this.type=a??s.error?.type??null;let l=s.error?.details?.error_code;this.errorCode=typeof l==="string"?l:null,this.details=s.error?.details??null}static makeMessage(r,t,o){let n=t?.message?typeof t.message==="string"?t.message:JSON.stringify(t.message):t?JSON.stringify(t):o;if(r&&n)return`${r} ${n}`;if(r)return`${r} status code (no body)`;if(n)return n;return"(no status code or body)"}static generate(r,t,o,n){if(!r||!n)return new jy({message:o,cause:BS(t)});let a=t,s=b.get(r);if(s)return new s(r,a,o,n);if(r>=500)return new BA(r,a,o,n);return new e(r,a,o,n)}}return e._errorName="APIError",e})(),Gs=(()=>{class e extends jr{constructor({message:r}={}){super(void 0,void 0,r||"Request was aborted.",void 0)}}return e._errorName="APIUserAbortError",e})(),jy=(()=>{class e extends jr{constructor({message:r,cause:t}){super(void 0,void 0,r||"Connection error.",void 0);if(t)this.cause=t}}return e._errorName="APIConnectionError",e})(),oF=(()=>{class e extends jy{constructor({message:r}={}){super({message:r??"Request timed out."})}}return e._errorName="APIConnectionTimeoutError",e})(),G7=(()=>{class e extends J{constructor(r,{cause:t}={}){super(r??"Retryable error.");if(t!==void 0)this.cause=t}}return e._errorName="RetryableError",e})(),Le=(()=>{class e extends jr{}return e._errorName="BadRequestError",e})(),y4=(()=>{class e extends jr{}return e._errorName="AuthenticationError",e})(),Qo=(()=>{class e extends jr{}return e._errorName="PermissionDeniedError",e})(),rm=(()=>{class e extends jr{}return e._errorName="NotFoundError",e})(),v4=(()=>{class e extends jr{}return e._errorName="RequestTimeoutError",e})(),Fc=(()=>{class e extends jr{}return e._errorName="ConflictError",e})(),sF=(()=>{class e extends jr{}return e._errorName="PreconditionFailedError",e})(),aF=(()=>{class e extends jr{}return e._errorName="ContentTooLargeError",e})(),b4=(()=>{class e extends jr{}return e._errorName="UnprocessableEntityError",e})(),Wx=(()=>{class e extends jr{}return e._errorName="RateLimitError",e})(),S4=(()=>{class e extends jr{}return e._errorName="RequestHeaderFieldsTooLargeError",e})(),w4=(()=>{class e extends jr{}return e._errorName="ClientClosedRequestError",e})(),BA=(()=>{class e extends jr{}return e._errorName="InternalServerError",e})(),R4=(()=>{class e extends BA{}return e._errorName="NotImplementedError",e})(),$S=(()=>{class e extends BA{}return e._errorName="ServiceUnavailableError",e})(),P4=(()=>{class e extends BA{}return e._errorName="GatewayTimeoutError",e})(),cF=(()=>{class e extends BA{}return e._errorName="OverloadedError",e})(),b=new Map([[400,Le],[401,y4],[403,Qo],[404,rm],[408,v4],[409,Fc],[412,sF],[413,aF],[422,b4],[429,Wx],[431,S4],[499,w4],[501,R4],[503,$S],[504,P4],[529,cF]]);var E=/^[a-z][a-z0-9+.-]*:/i,Y7=(e)=>E.test(e),sc=(e)=>(sc=Array.isArray,sc(e)),dF=sc;function zx(e){if(typeof e!=="object")return{};return e??{}}function A4(e){if(!e)return!0;for(let r in e)return!1;return!0}function x(e,r){return Object.prototype.hasOwnProperty.call(e,r)}function Fo(e){return e!=null&&typeof e==="object"&&!Array.isArray(e)}var Iq=(e,r)=>{if(typeof r!=="number"||!Number.isInteger(r))throw new J(`${e} must be an integer`);if(r<0)throw new J(`${e} must be a positive integer`);return r},$A=["apiKey","authToken","credentials","config","profile"];var _q=(e)=>{try{return JSON.parse(e)}catch(r){return}};function Fu(e){}function J7(e){let r=0;for(let n of e)r+=n.length;let t=new Uint8Array(r),o=0;for(let n of e)t.set(n,o),o+=n.length;return t}var m;function US(e){let r;return(m??(r=new globalThis.TextEncoder,m=r.encode.bind(r)))(e)}var y;function HS(e){let r;return(y??(r=new globalThis.TextDecoder,y=r.decode.bind(r)))(e)}var xt=(e)=>{if(typeof globalThis.process<"u")return globalThis.process.env?.[e]?.trim()||void 0;if(typeof globalThis.Deno<"u")return globalThis.Deno.env?.get?.(e)?.trim()||void 0;return};var lF="warn",u={off:0,error:200,warn:300,info:400,debug:500},xq=(e,r,t)=>{if(!e)return;if(x(u,e))return e;t.warn(`${r} was set to ${JSON.stringify(e)}, expected one of ${JSON.stringify(Object.keys(u))}`);return};function i(){}function c(e,r,t){if(!r||u[e]>u[t])return i;else return r[e].bind(r)}var _={error:i,warn:i,info:i,debug:i},g=new WeakMap;function f(e,r){let t=g.get(e);if(t&&t[0]===r)return t[1];let o={error:c("error",e,r),warn:c("warn",e,r),info:c("info",e,r),debug:c("debug",e,r)};return g.set(e,[r,o]),o}function Ze(e){let r=e.logger,t=e.logLevel??"off";if(!r)return _;return f(r,t)}var h,p;function Cq(){let e=xt("ANTHROPIC_LOG");if(!p||e!==h)h=e,p=f(console,xq(e,"process.env['ANTHROPIC_LOG']",f(console,lF))??lF);return p}function hh(e,r,t){if(e.debug===i)return;e.debug(r,N(t))}var N=(e)=>{if(e.options)e.options={...e.options},delete e.options.headers,delete e.options.__span;if(e.headers)e.headers=Object.fromEntries((e.headers instanceof Headers?[...e.headers]:Object.entries(e.headers)).map(([r,t])=>[r,r.toLowerCase()==="authorization"||r.toLowerCase()==="proxy-authorization"||r.toLowerCase()==="api-key"||r.toLowerCase()==="x-api-key"||r.toLowerCase()==="x-amz-security-token"||r.toLowerCase()==="cookie"||r.toLowerCase()==="set-cookie"?"***":t]));if("retryOfRequestLogID"in e){if(e.retryOfRequestLogID)e.retryOf=e.retryOfRequestLogID;delete e.retryOfRequestLogID}return e};function Ys(e,r){return e instanceof jr&&e.status===r}function O(e){return e instanceof jr&&typeof e.status==="number"&&e.status>=400&&e.status<500}function UA(e){return O(e)&&!Ys(e,408)&&!Ys(e,409)&&!Ys(e,429)}function Dq(e,r,t){return Math.min(r*2**e,t)}function X7(e,r){return e+Math.random()*(r-e)}function Oq(e){return e*(1-Math.random()*0.25)}var It=(()=>{class e extends Error{constructor(r){let t=typeof r==="string"?r:r.map((o)=>{if(o.type==="text")return o.text;return`[${o.type}]`}).join(" ");super(t);this.name="ToolError",this.content=r}}return e})();var T4=15000,w=5000;function uF(e,r){if(!(e>=w))throw new J(`${r} must be at least ${w}ms (got ${e}); to run without memory sync, pass \`memorySyncIntervalMs: null\` to the worker instead`)}function HA(){let e,r;return{promise:new Promise((o,n)=>{e=o,r=n}),resolve:e,reject:r}}
3
+ export{C,d,Gl,BS,J,jr,Gs,jy,oF,G7,Le,y4,Qo,rm,v4,Fc,sF,aF,b4,Wx,S4,w4,BA,R4,$S,P4,cF,Y7,sc,dF,zx,A4,Fo,Iq,$A,_q,Fu,J7,US,HS,xt,lF,xq,Ze,Cq,hh,Ys,UA,Dq,X7,Oq,It,T4,uF,HA};
4
+
5
+ //# debugId=229D45B2B9DFF0C064756E2164756E21
@@ -0,0 +1,6 @@
1
+ // @bun
2
+ import{i,Ae,Xe,e}from"./chunk-z8t0v07j.js";import{g}from"./chunk-mf9spd4g.js";import{wo,Ro,en,Ce,P5,Kee,Gee,tn,fi,Qi,e3}from"./chunk-h3n4adc6.js";import{n,a,s}from"./chunk-79q5xsdc.js";import{r,t}from"./chunk-9rkfyt6q.js";import E from"path";var k="AutoMobile Network Identity Probe.app",L="dev.jasonpearson.automobile.networkfilter",C="dev.jasonpearson.automobile.networkfilter.provider",q=E.posix.join("Contents","MacOS","network-filter-controller"),B=E.posix.join("Contents","Library","SystemExtensions",`${C}.systemextension`),S="/Applications",N=g.NETWORK_FILTER_APP_PATH.name,M=g.NETWORK_FILTER_TEAM_ID.name,zp="auto-mobile --ios-network-filter install",W=`Open System Settings > General > Login Items & Extensions > Network Extensions (macOS 13 and 14: System Settings > Privacy & Security, then Allow) and enable "AutoMobile Network Identity Probe". Allow the content filter when macOS asks, then run \`${zp}\` again. AutoMobile never approves the extension for you.`,K=`Restart macOS to finish installing the Network Extension, then run \`${zp}\` again.`;function I(o=S){return E.join(o,k)}function R(o){return E.join(o,q)}function V(o){return E.join(o,B)}import v from"path";var z=127;class d{async run(o,l,p={}){try{let c=await wo((m)=>Ro(o,[...l],m),{timeoutMs:p.timeoutMs,maxBuffer:16777216,killSignal:"SIGKILL"},{command:o,args:[...l]},{preserveError:!0});return{exitCode:0,stdout:c.stdout,stderr:c.stderr,timedOut:!1}}catch(c){let m=c;return e.debug(`[NETWORK_FILTER] ${o} exited unsuccessfully: ${r(c)}`),{exitCode:typeof m.code==="number"?m.code:z,stdout:String(m.stdout??""),stderr:String(m.stderr??(typeof m.code==="string"?m.code:"")),timedOut:m.killed===!0&&m.signal==="SIGKILL"}}}}import*as u from"fs/promises";var X=448,Z=384;async function j(o){try{let l=await u.stat(o);if(l.isDirectory())return"directory";return l.isFile()?"file":null}catch(l){return e.debug(`[NETWORK_FILTER] ${o} is not statable: ${r(l)}`),null}}class f{async isDirectory(o){return await j(o)==="directory"}async isFile(o){return await j(o)==="file"}async readText(o){try{return await u.readFile(o,"utf8")}catch(l){return e.debug(`[NETWORK_FILTER] ${o} is not readable: ${r(l)}`),null}}async writeText(o,l){await u.writeFile(o,l,{encoding:"utf8",mode:Z})}async ensureDir(o){await u.mkdir(o,{recursive:!0,mode:X})}async remove(o){await u.rm(o,{recursive:!0,force:!0})}async rename(o,l){await u.rename(o,l)}}var Q="network-filter",Y="network-filter.json",ee=60000,te=60000,x="local-override";class T{downloader;checksumCalculator;fileSystem;commandRunner;cacheDir;timer;cache;env;downloadTimeoutMs;expectedChecksumOverride;releaseUrlOverride;inFlight=null;constructor(o={}){this.downloader=o.downloader??new fi,this.checksumCalculator=o.checksumCalculator??new tn,this.fileSystem=o.fileSystem??new f,this.commandRunner=o.commandRunner??new d,this.cacheDir=o.cacheDir??Xe(Q),this.timer=o.timer??i,this.cache=new Qi({downloader:this.downloader,checksumCalculator:this.checksumCalculator,fileSystem:this.fileSystem,timer:this.timer}),this.env=o.env??process.env,this.downloadTimeoutMs=o.downloadTimeoutMs??ee,this.expectedChecksumOverride=o.expectedChecksum,this.releaseUrlOverride=o.releaseUrl}get cacheDirectory(){return this.cacheDir}async ensure(){if(this.inFlight)return this.inFlight;return this.inFlight=this.doEnsure().finally(()=>{this.inFlight=null}),this.inFlight}async doEnsure(){let o=this.env[N]?.trim();if(o)return this.resolveOverride(o);let l=en(Ce(this.env)),p=this.expectedChecksumOverride??Gee(this.env);if(p.length===0)throw new t(`No Network Extension app is published for AutoMobile ${l}: the release checksum registry has no networkFilterSha256 for this version, so no download can be trusted. Upgrade AutoMobile, or set ${N} to a locally built, Developer ID signed app.`);let c=await this.tryCache(p);if(c)return e.info("[NETWORK_FILTER] Reusing verified release app",{path:c}),{appPath:c,source:"release",version:l,sha256:p};return{appPath:await this.download(p,l),source:"release",version:l,sha256:p}}async resolveOverride(o){let l=Ae(o,this.env);if(!l.endsWith(".app")||!await this.fileSystem.isDirectory(l))throw new t(`${N} must point at an app bundle directory ending in .app, but ${l} is not one. Build it with scripts/ios/build-network-filter-probe.sh signed.`);if(!await this.fileSystem.isFile(R(l)))throw new t(`${N} points at ${l}, which has no Contents/MacOS/network-filter-controller. Build it with scripts/ios/build-network-filter-probe.sh signed.`);return{appPath:l,source:"override",version:x,sha256:null}}get metadataPath(){return v.join(this.cacheDir,Y)}get appDir(){return v.join(this.cacheDir,"app")}get cachedAppPath(){return v.join(this.appDir,k)}async tryCache(o){return await this.cache.isCached({label:"[NETWORK_FILTER]",subject:"app",expectedSha256:o,metadataPath:this.metadataPath,parseMetadata:(p)=>re(p)?p:null,verifyArtifact:()=>this.fileSystem.isFile(R(this.cachedAppPath))})?this.cachedAppPath:null}async download(o,l){await this.fileSystem.ensureDir(this.cacheDir);let p=v.join(this.cacheDir,`${P5}.download`),c=v.join(this.cacheDir,"app.download");return await this.cache.fetch({label:"[NETWORK_FILTER]",expectedSha256:o,url:this.releaseUrlOverride??Kee(this.env),archivePath:p,metadataPath:this.metadataPath,downloadTimeoutMs:this.downloadTimeoutMs,mismatchError:(m,w)=>new t(`Network Extension app checksum verification failed. Expected: ${m}, Got: ${w}. The downloaded release asset is corrupted or tampered; nothing was installed.`),timeoutError:()=>new t(`Timed out downloading the Network Extension app after ${this.downloadTimeoutMs}ms. Check GitHub Release asset availability or set ${N} for a local build.`),publish:async(m,w)=>{await this.fileSystem.remove(c),await this.fileSystem.ensureDir(c);let F=await this.commandRunner.run("ditto",["-x","-k",m,c],{timeoutMs:te});if(F.exitCode!==0)throw new t(`Unable to unpack the Network Extension app archive with ditto (exit ${F.exitCode}): ${F.stderr.trim()||"no output"}`);let y=v.join(c,k);if(!await this.fileSystem.isFile(R(y)))throw new t(`The Network Extension release asset does not contain ${k} with its controller executable.`);return await this.fileSystem.remove(this.appDir),await this.fileSystem.rename(c,this.appDir),e.info("[NETWORK_FILTER] Downloaded and verified release app",{path:this.cachedAppPath,sha256:w}),{version:l,sha256:w??o,downloadedAt:this.timer.now()}},discard:()=>this.fileSystem.remove(c),settle:()=>this.fileSystem.remove(p)}),this.cachedAppPath}}function re(o){return typeof o==="object"&&o!==null&&"sha256"in o&&typeof o.sha256==="string"}var U=30000;function H(o,l){let p=`${l}=`,m=o.split(/\r?\n/).find((w)=>w.startsWith(p))?.slice(p.length).trim();return m&&m.length>0?m:null}class A{runner;constructor(o=new d){this.runner=o}async inspect(o){let l=await this.runner.run("codesign",["--verify","--deep","--strict",o],{timeoutMs:U});return{verified:l.exitCode===0,verifyDetail:l.stderr.trim(),app:await this.identity(o),provider:await this.identity(V(o))}}async identity(o){let l=await this.runner.run("codesign",["-dvvv",o],{timeoutMs:U}),p=`${l.stderr}
3
+ ${l.stdout}`;return{identifier:H(p,"Identifier"),teamIdentifier:e3(p),cdhash:H(p,"CDHash")}}}var ie=/^[A-Z0-9]{10}$/;function D(o,l){return[ne(o),J("app",o.app.identifier,L),J("provider",o.provider.identifier,C),oe(o),ae(o.app.teamIdentifier,l)].filter((p)=>p!==null)}function ne(o){if(o.verified)return null;return`codesign --verify --deep --strict failed${o.verifyDetail?`: ${o.verifyDetail}`:""}`}function J(o,l,p){return l===p?null:`${o} identifier is ${l??"missing"}, expected ${p}`}function oe(o){let l=o.app.teamIdentifier;if(l===null||!ie.test(l))return`app is not signed by a Developer ID team (TeamIdentifier ${l??"not set"})`;let p=o.provider.teamIdentifier;return p===l?null:`provider team ${p??"not set"} differs from app team ${l}`}function ae(o,l){if(!l||o===l)return null;return`signing team ${o??"not set"} does not match the pinned team ${l}`}var se=30000,le=s({version:a().optional(),state:n(),detail:n()});function pe(o){let p=o.split(/\r?\n/).map((c)=>c.trim()).filter((c)=>c.startsWith("{")).at(-1);if(p===void 0)return null;try{let c=le.safeParse(JSON.parse(p));return c.success?c.data:null}catch(c){return e.debug(`[NETWORK_FILTER] controller output is not JSON: ${r(c)}`),null}}function ce(o){if(o.timedOut)return{state:"unavailable",controllerState:null,detail:"network-filter-controller did not exit in time; activation may still have completed.",nextSteps:`Run \`${zp}\` again to reconcile.`};let l=pe(o.stdout);if(l===null)return{state:"failed",controllerState:null,detail:`network-filter-controller exited ${o.exitCode} without a JSON result`+(o.stderr.trim()?`: ${o.stderr.trim()}`:".")};let p={controllerState:l.state,detail:l.detail};switch(l.state){case"ready":return o.exitCode===0?{...p,state:"ready"}:{...p,state:"failed"};case"approval_required":return/restart/i.test(l.detail)?{...p,state:"restart_required",nextSteps:K}:{...p,state:"approval_required",nextSteps:W};case"unavailable":return{...p,state:"unavailable"};default:return{...p,state:"failed"}}}async function _(o,l,p,c=se){let m=await o.run(R(l),[p],{timeoutMs:c});return ce(m)}import P from"path";var me=120000;class O{runner;fileSystem;constructor(o=new d,l=new f){this.runner=o;this.fileSystem=l}async exists(o){return this.fileSystem.isDirectory(o)}async install(o,l,p){if(!p.replace&&await this.exists(l))throw new t(`Refusing to overwrite the existing ${l}.`);let c=P.join(P.dirname(l),`.${P.basename(l)}.partial`);await this.fileSystem.remove(c);let m=await this.runner.run("ditto",[o,c],{timeoutMs:me});if(m.exitCode!==0)throw await this.fileSystem.remove(c),new t(`Unable to copy the Network Extension app to ${P.dirname(l)} (ditto exit ${m.exitCode}): ${m.stderr.trim()||"no output"}. Installing into /Applications needs an administrator account.`);await this.fileSystem.remove(l),await this.fileSystem.rename(c,l)}}import de from"path";var G="install-receipt.json";function b(o){return de.join(o,G)}class t0{fileSystem;commandRunner;cacheDir;env;destination;constructor(o={}){this.fileSystem=o.fileSystem??new f,this.commandRunner=o.commandRunner??new d,this.cacheDir=o.cacheDir,this.env=o.env??process.env,this.destination=I(o.installDir??S)}async inspect(o={}){let l=this.env[N]?.trim()?x:en(Ce(this.env)),p={installed:!1,installedPath:this.destination,installedVersion:null,expectedVersion:l,report:null};if(!await this.fileSystem.isDirectory(this.destination))return p;let c=this.cacheDir??new T({env:this.env}).cacheDirectory;return{...p,installed:!0,installedVersion:await this.readReceiptVersion(c),report:await _(this.commandRunner,this.destination,"status",o.timeoutMs)}}async readReceiptVersion(o){let l=await this.fileSystem.readText(b(o));if(l===null)return null;try{let p=JSON.parse(l);return typeof p==="object"&&p!==null&&"version"in p&&typeof p.version==="string"?p.version:null}catch(p){return e.debug(`[NETWORK_FILTER] Ignoring unreadable install receipt: ${r(p)}`),null}}}function ue(o){let l=o[M]?.trim();return l&&l.length>0?l:null}class uoe{appSource;verifier;fileInstaller;commandRunner;fileSystem;timer;env;platform;destination;constructor(o={}){this.env=o.env??process.env,this.commandRunner=o.commandRunner??new d,this.fileSystem=o.fileSystem??new f,this.appSource=o.appSource??new T({env:this.env,commandRunner:this.commandRunner,fileSystem:this.fileSystem}),this.verifier=o.verifier??new A(this.commandRunner),this.fileInstaller=o.fileInstaller??new O(this.commandRunner,this.fileSystem),this.timer=o.timer??i,this.platform=o.platform??process.platform,this.destination=I(o.installDir??S)}async install(o={}){let l={action:"none",installedPath:this.destination};if(this.platform!=="darwin")return{...l,state:"unavailable",detail:"The Network Extension app only runs on macOS hosts."};let p,c;try{p=await this.appSource.ensure(),c=await this.verifier.inspect(p.appPath)}catch(h){return e.warn(`[NETWORK_FILTER] Unable to prepare the app: ${r(h)}`,h),{...l,state:"failed",detail:r(h)}}let m={source:p.source,version:p.version},w=D(c,ue(this.env));if(w.length>0)return{...l,...m,state:"failed",detail:`Refusing to install ${p.appPath}: ${w.join("; ")}.`};let F;try{let h=await this.place(p,c,o.upgrade===!0);if("refused"in h)return{...l,...m,state:"failed",...h.refused};F=h.action}catch(h){return e.warn(`[NETWORK_FILTER] Unable to install the app: ${r(h)}`,h),{...l,...m,state:"failed",detail:r(h)}}await this.writeReceipt(p,c);let y=await this.activate();return{...m,action:F,installedPath:this.destination,state:y.state,detail:y.detail,nextSteps:y.nextSteps,controllerState:y.controllerState}}async place(o,l,p){if(!await this.fileInstaller.exists(this.destination))return await this.fileInstaller.install(o.appPath,this.destination,{replace:!1}),{action:"installed"};let c=await this.verifier.inspect(this.destination);if(c.app.cdhash!==null&&c.app.cdhash===l.app.cdhash&&c.app.teamIdentifier===l.app.teamIdentifier&&D(c,null).length===0)return{action:"unchanged"};if(!p)return{refused:{detail:`${this.destination} already exists with a different version or signature (installed CDHash ${c.app.cdhash??"unknown"}, team ${c.app.teamIdentifier??"not set"}). It was left unchanged.`,nextSteps:`Run \`${zp} --upgrade\` to replace it.`}};return await this.fileInstaller.install(o.appPath,this.destination,{replace:!0}),{action:"upgraded"}}async writeReceipt(o,l){let p={version:o.version,source:o.source,sha256:o.sha256,cdhash:l.app.cdhash,installedAt:this.timer.now()};try{await this.fileSystem.ensureDir(this.appSource.cacheDirectory),await this.fileSystem.writeText(b(this.appSource.cacheDirectory),JSON.stringify(p,null,2))}catch(c){e.warn(`[NETWORK_FILTER] Unable to write the install receipt: ${r(c)}`,c)}}async activate(){try{return await _(this.commandRunner,this.destination,"activate")}catch(o){return e.warn(`[NETWORK_FILTER] Activation failed: ${r(o)}`,o),{state:"failed",controllerState:null,detail:r(o)}}}}
4
+ export{zp,t0,uoe};
5
+
6
+ //# debugId=84EE47BA92F186A164756E2164756E21
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{lI,ui,Fl,Vs}from"./chunk-nwm2pq5v.js";import{y,Z,f,ee}from"./chunk-79q5xsdc.js";var r7=f({type:ee("mcp_response"),id:y().nullable(),success:Z(),error:y().optional()}).passthrough();function n7(e){if(!e||typeof e!=="object"||Array.isArray(e))return;let n=e;if(typeof n.name!=="string"||n.name.length===0||typeof n.message!=="string"||n.message.length===0)return;return{name:n.name,message:n.message}}var rc="daemon_session_not_found",Gf="liveness_owner_superseded",Yf="liveness_owner_unowned",aA="liveness_owner_not_owner",Hl="daemon_session_suspect",GN="daemon_instance_changed",fS="liveness_owner_conflict",YN="liveness_owner_is_proxy",Du="daemon_tool_unavailable";function JN(e){return e!==null&&typeof e==="object"&&"code"in e&&e.code===Du}var Vp="daemon_unknown_tool",Wp="daemon_session_not_active";function aq(e){if(e===null||typeof e!=="object"||!("code"in e))return;return e.code}var XN="bound_session_lost";function Es(e){if(e===null||typeof e!=="object"||!("releaseReason"in e))return;let{releaseReason:n}=e;return typeof n==="string"&&n.length>0?n:void 0}function Dc(e){if(e===null||typeof e!=="object"||!("daemonInstance"in e))return;let{daemonInstance:n}=e;return typeof n==="string"&&n.length>0?n:void 0}function Jf(e,n){if(!e)return{};return{releaseReason:e,...ui(e),...Fl(e,n)}}function B6(e){if(e===null||typeof e!=="object"||!("idleTimeoutMs"in e))return;let{idleTimeoutMs:n}=e;return typeof n==="number"&&Number.isSafeInteger(n)&&n>0?n:void 0}var t="owner-disconnected",s="heartbeat-timeout";function ZN(e){let n=`Device session ${e.sessionUuid} is no longer active (${e.reason}). `,o="Acquire a new device session before continuing.";if(e.reason===s)return`${n}The daemon stopped receiving this session's liveness heartbeats, so it released the device; check that the client process holding the session is still running. Acquire a new device session before continuing.`;if(e.reason===t)return`${n}The client connection that owned this session closed, so the daemon released the device. Acquire a new device session before continuing.`;if(Vs(e.reason))return`${n}The daemon shut down or restarted, or the device restarted, and this session was not restored. Acquire a new device session before continuing.`;return lI(e.reason)?`${n}The session was released after sitting idle past its window; time the host spent asleep counts toward that window. Acquire a new device session before continuing.`:`${n}Acquire a new device session before continuing.`}function r(e,n){return[e.sessionId===n,typeof e.deviceId==="string",typeof e.releaseReason==="string",typeof e.releasedAtMs==="number"&&Number.isFinite(e.releasedAtMs),typeof e.terminal==="boolean"].every(Boolean)}function i(e){if(!e||typeof e!=="object"||Array.isArray(e))return!1;let n=e;return[typeof n.lastHeartbeatMs==="number"&&Number.isFinite(n.lastHeartbeatMs),typeof n.hasReceivedHeartbeat==="boolean",typeof n.timeoutMs==="number"&&Number.isFinite(n.timeoutMs),typeof n.ageMs==="number"&&Number.isFinite(n.ageMs)].every(Boolean)}function a(e,n){if(!e||typeof e!=="object"||Array.isArray(e))return;let o=e;if(!r(o,n)||!i(o.heartbeat))return;return{sessionId:n,deviceId:o.deviceId,releaseReason:o.releaseReason,releasedAtMs:o.releasedAtMs,terminal:o.terminal,...typeof o.ownerPid==="number"&&Number.isInteger(o.ownerPid)?{ownerPid:o.ownerPid}:{},...typeof o.cliIdleTimeoutMs==="number"&&Number.isSafeInteger(o.cliIdleTimeoutMs)&&o.cliIdleTimeoutMs>0?{cliIdleTimeoutMs:o.cliIdleTimeoutMs}:{},heartbeat:o.heartbeat}}function i7(e){if(!e||typeof e!=="object"||Array.isArray(e))return;let n=e;if(n.code!==XN||typeof n.sessionUuid!=="string"||n.sessionUuid.trim().length===0||typeof n.reason!=="string"||n.reason.trim().length===0)return;let o=a(n.release,n.sessionUuid);return{code:XN,sessionUuid:n.sessionUuid,reason:n.reason,...ui(n.reason),...o?{release:o}:{}}}var hS="notifications/progress",QN="notifications/automobile/requestBudget",cA="resources/subscribe",e0="resources/unsubscribe",o7=f({type:ee("daemon_notification"),method:y()}).passthrough();
3
+ export{r7,n7,rc,Gf,Yf,aA,Hl,GN,fS,YN,Du,JN,Vp,Wp,aq,XN,Es,Dc,Jf,B6,ZN,i7,hS,QN,cA,e0,o7};
4
+
5
+ //# debugId=7E8C099D425E99F964756E2164756E21
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{nr,wr,Xe,dn,e}from"./chunk-z8t0v07j.js";import{QS,Kr,pe,xs,v,ii,cg,hB,dg,ck}from"./chunk-h3n4adc6.js";import{r,t,u}from"./chunk-9rkfyt6q.js";class xu extends t{code;snapshotName;reasons;retryable=!1;constructor(n,i,a,s=[]){super(a);this.code=n;this.snapshotName=i;this.reasons=s;this.name="SnapshotFixtureRefusedError"}toPayload(){return{code:this.code,snapshotName:this.snapshotName,retryable:this.retryable,...this.reasons.length>0?{reasons:[...this.reasons]}:{}}}}import*as w from"path";function ky(n,i){let a=(s)=>{throw new t(`Invalid ${n} '${i}': ${s}. Use a single path segment without path separators, '.'/'..', or an absolute path.`)};if(typeof i!=="string"||i.trim().length===0){a(`${n} must be a non-empty string`);return}if(i.includes("\x00")){a(`${n} contains a NUL byte`);return}if(i.includes("/")||i.includes("\\")){a(`${n} contains a path separator`);return}if(i==="."||i===".."){a(`${n} is a path traversal segment`);return}if(w.isAbsolute(i)||w.win32.isAbsolute(i)){a(`${n} is an absolute path`);return}}function Bf(n){if(ky("snapshot name",n),DI(n))throw new t("Broker baseline snapshots are reserved and cannot be accessed by deviceSnapshot tools")}var R6="automobile-broker-baseline-v1";function DI(n){return n.toLowerCase().startsWith("automobile-broker-baseline-")}import{promises as p}from"fs";import*as d from"path";var Bd=".replacing",jH="ios",KH="android";function _Z(n){let i=n.toLowerCase();if(i===jH||i===KH)return{kind:"scope-root",name:i};if(i.endsWith(Bd))return{kind:"suffix",suffix:Bd};return}async function b(n){let i=await p.open(n,"r");try{await i.sync()}finally{await i.close()}}class $f{syncDirectory;syncFile;basePath;constructor(n,i=b,a=(s)=>s.sync()){this.syncDirectory=i;this.syncFile=a;this.basePath=n||Xe(dn.SNAPSHOTS)}getBasePath(){return this.basePath}async ensureSnapshotsDirectory(){try{await p.mkdir(this.basePath,{recursive:!0})}catch(n){throw e.error(`Failed to create snapshots directory: ${n}`),n}}getSnapshotPath(n){return d.join(this.basePath,n)}getSnapshotPathWithOptions(n,i){if(i?.platform==="ios"&&i.deviceId)return ky("iOS device id",i.deviceId),d.join(this.basePath,jH,i.deviceId,n);if(i?.platform==="android"&&i.avdName)return ky("Android AVD name",i.avdName),d.join(this.basePath,KH,i.avdName,n);return this.getSnapshotPath(n)}getSettingsPath(n,i){return d.join(this.getSnapshotPathWithOptions(n,i),"settings.json")}getMetadataPath(n,i){return d.join(this.getSnapshotPathWithOptions(n,i),"metadata.json")}getAppDataPath(n,i){let a=i?.platform==="ios"?"app-data":"app_data";return d.join(this.getSnapshotPathWithOptions(n,i),a)}async snapshotDirectoryExists(n,i){try{return await p.access(this.getSnapshotPathWithOptions(n,i)),!0}catch(a){return e.debug(`src/utils/DeviceSnapshotStore.ts fallback failed: ${a}`,a),!1}}async replaceSnapshotData(n,i,a){let s=this.getSnapshotPathWithOptions(n,i),o=`${s}${Bd}`,c=this.getJournalPath(s);await this.recoverSnapshotData(n,i);let m=await this.pathExists(s);if(await this.writeJournal(c,m?"pending-existing":"pending-new"),m){try{await p.rename(s,o)}catch(h){if(h.code!=="ENOENT")throw h;await this.writeJournal(c,"pending-new")}await this.syncParent(s)}let l;try{l=await a()}catch(h){try{await this.recoverSnapshotData(n,i)}catch(g){e.warn(`Failed to roll back snapshot '${n}' after a failed overwrite; prior data may be stranded at '${o}': ${g}`)}throw h}await this.writeJournal(c,"committed");try{await this.recoverSnapshotData(n,i)}catch(h){e.warn(`Failed to clean committed snapshot journal '${c}'; it will be cleaned up on the next capture: ${h}`)}return l}async recoverSnapshotData(n,i){let a=this.getSnapshotPathWithOptions(n,i),s=`${a}${Bd}`,o=this.getJournalPath(a),c=this.getTempJournalPath(o),m=d.dirname(a);await p.mkdir(m,{recursive:!0});let l=await nr(m);if(l.includes(d.basename(c)))await p.rm(c);let h=l.includes(d.basename(o))?await p.readFile(o,"utf-8"):void 0,g=await this.pathExists(s);if(h===void 0){if(g)await this.recoverLegacyAside(a,s);return}if(h!=="pending-existing"&&h!=="pending-new"&&h!=="committed")throw Error(`Invalid snapshot journal at '${o}': '${h}'`);if(h==="committed")await p.rm(s,{recursive:!0,force:!0});else if(g){if(h!=="pending-existing")throw Error(`Unexpected set-aside snapshot for new capture at '${s}'`);await p.rm(a,{recursive:!0,force:!0}),await p.rename(s,a)}else if(h==="pending-new")await p.rm(a,{recursive:!0,force:!0});await this.syncParent(a),await p.rm(o),await this.syncParent(a)}async discardSnapshotArtifacts(n,i){let a=this.getSnapshotPathWithOptions(n,i),s=this.getJournalPath(a),o=[];for(let c of[`${a}${Bd}`,s,this.getTempJournalPath(s)])try{await p.rm(c,{recursive:!0,force:!0})}catch(m){e.warn(`Failed to discard snapshot artifact '${c}'`,m),o.push(c)}return o}async listLeftoverSnapshotJournals(n){let i=[],a=await this.readJournalDirectory(this.getBasePath());if(this.collectJournalEntries(a,void 0,i,n.maxEntries))return{entries:i,truncated:!0};let s=0;for(let o of["android","ios"]){if(!a.some((l)=>l.name===o&&l.isDirectory()))continue;let c=d.join(this.getBasePath(),o),m=await this.readJournalDirectory(c);for(let l of m){if(!l.isDirectory()||!this.isSafeJournalSegment(l.name))continue;if(s>=n.maxScopeDirectories)return{entries:i,truncated:!0};s++;let h=o==="android"?{platform:o,avdName:l.name}:{platform:o,deviceId:l.name},g=await this.readJournalDirectory(d.join(c,l.name));if(this.collectJournalEntries(g,h,i,n.maxEntries))return{entries:i,truncated:!0}}}return{entries:i,truncated:!1}}async readJournalDirectory(n){try{return(await wr(n)).sort((a,s)=>a.name<s.name?-1:a.name>s.name?1:0)}catch(i){if(i.code==="ENOENT")return e.debug(`Snapshot journal directory '${n}' does not exist`,i),[];throw u(i,`Failed to enumerate snapshot journals in '${n}'`)}}isSafeJournalSegment(n){try{return ky("snapshot journal segment",n),!0}catch(i){return e.debug(`Skipping unsafe snapshot journal segment '${n}'`,i),!1}}collectJournalEntries(n,i,a,s){let o=new Set;for(let c of n){if(!c.name.endsWith(Bd)||c.isSymbolicLink())continue;let m=c.name.endsWith(".journal.tmp.replacing")?".journal.tmp.replacing":c.name.endsWith(".journal.replacing")?".journal.replacing":Bd,l=c.name.slice(0,-m.length);if(!this.isSafeJournalSegment(l)||o.has(l))continue;if(!i&&["android","ios"].includes(l))continue;if(o.add(l),a.length>=s)return!0;if(a.push({snapshotName:l,options:i}),a.length>=s)return!0}return!1}async recoverLegacyAside(n,i){if(await this.pathExists(n))e.warn(`Removing legacy set-aside snapshot '${i}' because '${n}' exists`),await p.rm(i,{recursive:!0,force:!0});else e.warn(`Restoring legacy set-aside snapshot '${i}' to '${n}'`),await p.rename(i,n);await this.syncParent(n)}getJournalPath(n){return`${n}.journal${Bd}`}getTempJournalPath(n){return`${n.slice(0,-Bd.length)}.tmp${Bd}`}async writeJournal(n,i){let a=this.getTempJournalPath(n),s=await p.open(a,"wx");try{await s.writeFile(i),await this.syncFile(s)}finally{await s.close()}await p.rename(a,n),await this.syncParent(n)}async syncParent(n){try{await this.syncDirectory(d.dirname(n))}catch(i){let a=i.code;if(a==="EPERM"||a==="EINVAL"||a==="EISDIR"||a==="ENOTSUP"){e.debug(`Skipping unsupported directory sync for '${n}': ${i}`);return}throw i}}async pathExists(n){return(await nr(d.dirname(n))).includes(d.basename(n))}async deleteSnapshotData(n,i){let a=this.getSnapshotPathWithOptions(n,i);try{await p.rm(a,{recursive:!0,force:!0})}catch(s){e.warn(`Failed to delete snapshot data '${n}': ${s}`)}}generateSnapshotName(n){let a=new Date().toISOString().replace(/[:.]/g,"-").replace("T","_").split(".")[0];if(n)return`${n.replace(/[^a-zA-Z0-9-_]/g,"_")}_${a}`;return`snapshot_${a}`}async getSnapshotSizeBytes(n,i){let a=this.getSnapshotPathWithOptions(n,i),s;try{s=await wr(a)}catch(o){if(o.code==="ENOENT")return e.debug(`Snapshot archive ${a} does not exist: ${o}`),0;return e.warn(`Failed to read snapshot archive ${a}: ${o}`,o),null}return this.getDirectorySizeFromEntries(a,s)}async getDirectorySize(n){let i;try{i=await wr(n)}catch(a){return e.debug(`Failed to get directory size for ${n}: ${a}`),null}return this.getDirectorySizeFromEntries(n,i)}async getDirectorySizeFromEntries(n,i){let a=0;for(let s of i){let o=d.join(n,s.name);if(s.isDirectory()){let c=await this.getDirectorySize(o);if(c===null)return null;a+=c}else{let c=await this.getFileSize(o);if(c===null)return null;a+=c}}return a}async listSubdirectoryNames(n){try{return(await wr(n)).filter((a)=>a.isDirectory()).map((a)=>a.name)}catch(i){return e.debug(`Failed to list subdirectories of ${n}: ${i}`),null}}async listFileNames(n){try{return(await wr(n)).filter((a)=>a.isFile()).map((a)=>a.name)}catch(i){return e.debug(`Failed to list files of ${n}: ${i}`),null}}async getFileSize(n){try{return(await p.stat(n)).size}catch(i){return e.debug(`Failed to stat ${n} while measuring a directory: ${i}`),null}}}async function GH(n,i){if(!n)return null;return(await i()).find((s)=>s.name===n)?.deviceId??null}import*as P from"path";var Hp="default_boot",D=".avd",A=".ini";class P6{directories;avdDirectories;emulator;adbFactory;consoleBusyRegistry;constructor(n=new $f,{avdDirectories:i=new Kr,emulator:a=new ii,adbFactory:s=v,consoleBusyRegistry:o=xs}={}){this.consoleBusyRegistry=o,this.directories=n,this.avdDirectories=i,this.emulator=a,this.adbFactory=s}async measureVmSnapshotBytes(n,i){let a=await this.resolveSnapshotsRoot(n);if(!a)return null;return this.directories.getDirectorySize(P.join(a,i))}async listAvdSnapshotDirectories(n){let i=await this.resolveSnapshotsRoot(n);if(!i)return[];let a=await this.directories.listSubdirectoryNames(i);if(!a)return[];let s=[];for(let o of a){if(DI(o))continue;let c=P.join(i,o);s.push({snapshotName:o,directoryPath:c,sizeBytes:await this.directories.getDirectorySize(c)})}return s}async listKnownAvdNames(){let n=this.avdDirectories.getAvdHome(),i=new Set;for(let[a,s]of[[await this.directories.listSubdirectoryNames(n),D],[await this.directories.listFileNames(n),A]])for(let o of a??[])if(o.endsWith(s)&&o.length>s.length)i.add(o.slice(0,-s.length));return Array.from(i)}async findLiveEmulatorSerial(n){if(!n)return null;try{return await GH(n,()=>this.emulator.getBootedDevices(!0))}catch(i){return e.warn(`[AvdSnapshot] Failed to look up a live emulator for AVD '${n}': ${r(i)}`,i),null}}async deleteVmSnapshot(n,i,a,s){if(DI(i))return{reclaimed:!1,reason:"Broker baseline snapshot is reserved"};let o=this.adbFactory.create({deviceId:n,name:n,platform:"android"}),c;try{c=cg("delete",i)}catch(y){let f=r(y);return e.warn(`[AvdSnapshot] ${f}`,y),{reclaimed:!1,reason:f}}let m=s===void 0?void 0:new AbortController,l=m?pe(m.signal):void 0,h,g;try{g=await this.consoleBusyRegistry.runExclusive(n,async()=>o.execute(c.split(" "),{timeoutMs:a,waitForProcessSettlementAfterAbort:!0,...m?{signal:l,beforeDispatch:async(y)=>{let f=await this.emulator.resolveAvdNameForSerial(n,{signal:l,timeoutMs:y??a,consoleExclusiveOwner:!0});if(f!==s)throw h=`Skipping VM snapshot delete for '${i}': serial '${n}' expected AVD '${s}' but currently hosts '${f??"no longer live"}'`,e.warn(`[AvdSnapshot] ${h}`),m.abort(),Error(h)}}:{}}))}catch(y){if(h!==void 0)return{reclaimed:!1,reason:h};let f=ck("delete",i,y);return e.warn(`[AvdSnapshot] ${f}`,y),{reclaimed:!1,reason:f}}let S=dg("delete",i,g);if(S.ok)return{reclaimed:!0};if(hB(S.errorMessage))return e.debug(`[AvdSnapshot] ${S.errorMessage}`),{reclaimed:!0};return e.warn(`[AvdSnapshot] ${S.errorMessage}`),{reclaimed:!1,reason:S.errorMessage}}async resolveSnapshotsRoot(n){if(!n)return null;let i=await this.avdDirectories.resolveAvdDirectory(n);if(!i)return null;return P.join(i,QS)}}
3
+ export{xu,ky,Bf,R6,DI,Bd,jH,KH,_Z,$f,GH,Hp,P6};
4
+
5
+ //# debugId=ADC6BD250D9D475864756E2164756E21
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{R$,w2,R2,P2,A2}from"./chunk-4pfftt07.js";import"./chunk-32jpxz2y.js";import"./chunk-z8t0v07j.js";import"./chunk-mf9spd4g.js";export{R$ as DEFAULT_APPEARANCE_APPLY_DEADLINE_MS,w2 as startAppearanceSyncScheduler,R2 as stopAppearanceSyncScheduler,A2 as syncAppearanceForDevice,P2 as triggerAppearanceSync};
3
+
4
+ //# debugId=436D04EE2335C3DC64756E2164756E21
@@ -0,0 +1,5 @@
1
+ // @bun
2
+ import{i,e}from"./chunk-z8t0v07j.js";import{_s,w,Dt,KV,vn,Tv,ep,bn,xa}from"./chunk-h3n4adc6.js";import{Ur}from"./chunk-6d3mmqxt.js";import{ho}from"./chunk-0e4gm1kj.js";import{sP,vE,zO,aP,bE,Vg}from"./chunk-t4dr5c8v.js";import{kM}from"./chunk-qwye1958.js";import{t}from"./chunk-9rkfyt6q.js";var f="to start a device gesture recording";async function l(n,o,s,r=()=>{return}){let d=await n.getBootedDevices(s??"either");await Ur(d,"device-gesture-recording-resolve");let c=s?d.filter((a)=>a.platform===s):d,u=s?`connected ${s} devices`:"connected devices";if(o){let a=c.find((R)=>R.deviceId===o);if(!a)throw new t(`Device ${o} not found among ${u}.`);return a}if(c.length===0)throw new t(`No ${u} found.`);if(c.length===1)return c[0];let v=r(),m=c.find((a)=>a.deviceId===v);if(m)return m;throw new t(`Multiple ${u}; specify deviceId. Found: ${c.map((a)=>a.deviceId).join(", ")}`)}var G=async(n)=>{let o=w.sessionManager(),s=w.devicePool();if(!o||!s)return;await Tv({action:n.action,deviceId:n.device.deviceId,platform:n.device.platform,requesterSessionUuid:n.requesterSessionUuid,sessionManager:o,gate:s})};function p(n,o=(s)=>{if(!s)return;let r=w.sessionManager();return r?r.getDeviceForSession(s)??void 0:ho(s)?.device.deviceId}){return{selectDevice:(s,r,d)=>{let c=n(),u=d?.trim()||void 0;return l(c.getPlatformDeviceManager(),s,r,()=>o(u))},readyDevice:(s,r)=>n().ensureDeviceReady(s.platform,s.deviceId,{sessionId:r})}}function h(n){return typeof n?.sessionUuid==="string"?{...n,sessionUuid:n.sessionUuid.trim()||void 0}:n}var S=(n)=>{if(n===void 0)return;if(n==="android"||n==="ios")return n;throw Error(`Unsupported platform value: ${String(n)}`)};class D extends xa{authenticator;admissionGate;deviceResolution;bindingGate;constructor(n=Dt(KV),o=i,s=bn("deviceGestureRecording"),{admissionGate:r=_s,deviceResolution:d=p(()=>{throw new t("Inject device readiness before recording gestures.")}),bindingGate:c=G}={}){super(n,o,"DeviceGestureRecording");this.authenticator=s,this.admissionGate=r,this.deviceResolution=d,this.bindingGate=c}async handleRequest(n){let o=h(n),s=o?.command;if(!s)throw Error("Request missing command field.");switch(s){case"start":{if(o.deviceId!==void 0){let d=kM(o.deviceId,o.sessionUuid);if(d)return d}let r=w.isInitialized();if(!r)this.authenticator.authorize({sessionUuid:o.sessionUuid,deviceId:o.deviceId});if(o.deviceId!==void 0)this.admissionGate.assertDeviceActionable(o.deviceId,f);return this.handleStart(o,r)}case"stop":return this.handleStop(o);case"status":{this.authenticator.authorize({sessionUuid:o.sessionUuid,deviceId:o.deviceId,admitViewer:!0});let r=aP();if(!r)return{success:!0};return{success:!0,recording:r}}default:throw Error(`Unsupported device gesture recording command: ${String(s)}`)}}async handleStart(n,o){let s=S(n.platform),r=await this.deviceResolution.selectDevice(n.deviceId,s,n.sessionUuid);this.admissionGate.assertDeviceActionable(r.deviceId,f);let d=kM(r.deviceId,n.sessionUuid);if(d)return d;if(!o)ep(this.authenticator,{sessionUuid:n.sessionUuid,deviceId:r.deviceId});await this.bindingGate({action:"deviceGestureRecording start",device:r,requesterSessionUuid:n.sessionUuid});let c=kM(r.deviceId,n.sessionUuid,!0);if(c)return c;if(o)ep(this.authenticator,{sessionUuid:n.sessionUuid,deviceId:r.deviceId});let u=await this.deviceResolution.readyDevice(r,n.sessionUuid),v=await bE(u,void 0,void 0,{ownerSessionUuid:n.sessionUuid});return{success:!0,recordingId:v.recordingId,startedAt:v.startedAt,deviceId:v.deviceId,platform:v.platform}}async handleStop(n){if(n.recordingId)try{let r=await zO(n.recordingId,n.sessionUuid);if(r)return this.toStopResponse(r)}catch(r){return this.toStopFailure(r)}let o=aP(),s=!o&&n.recordingId?vE(n.recordingId,n.sessionUuid):void 0;if(s)return this.toStopResponse(s);if(this.authenticator.authorize({sessionUuid:n.sessionUuid,deviceId:o?.deviceId??n.deviceId}),!o)throw new t("No active recording. Start a recording before stopping.");if(n.deviceId!==void 0&&o.deviceId!==n.deviceId)throw new t(`No active recording found for device ${n.deviceId}.`);return await this.bindingGate({action:"deviceGestureRecording stop",device:{deviceId:o.deviceId,platform:o.platform},requesterSessionUuid:n.sessionUuid}),Vg(n.recordingId,n.planName).then((r)=>this.toStopResponse(r)).catch((r)=>this.toStopFailure(r))}toStopFailure(n){if(!(n instanceof sP))throw n;return e.warn(`[DeviceGestureRecording] ${n.message}`,n),{success:!1,error:n.message,reason:n.reason}}toStopResponse(n){return{success:!0,recordingId:n.recordingId,startedAt:n.startedAt,stoppedAt:n.stoppedAt,deviceId:n.deviceId,platform:n.platform,planName:n.planName,planContent:n.planContent,stepCount:n.stepCount,durationMs:n.durationMs,...n.error?{error:n.error}:{}}}createErrorResponse(n,o){return{success:!1,error:o}}}var g=new vn;function d2(){return g.instance?.getSocketPath()??Dt(KV)}async function l2(n){await g.start(()=>new D(void 0,void 0,void 0,{deviceResolution:p(()=>n)}))}async function u2(){await g.stop()}
3
+ export{d2,l2,u2};
4
+
5
+ //# debugId=981F6F662CC8DEA564756E2164756E21
@@ -0,0 +1,4 @@
1
+ // @bun
2
+ import{ge}from"./chunk-h3n4adc6.js";import"./chunk-z8t0v07j.js";import"./chunk-mf9spd4g.js";export{ge as IOSCtrlProxyManager};
3
+
4
+ //# debugId=721B64D57AC5CCED64756E2164756E21