@testmuai/kane-cli 0.8.14 → 0.8.16

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 (191) hide show
  1. package/dist/{ChatSurface-AVL3TJA2.js → ChatSurface-5JEEFY34.js} +1 -1
  2. package/dist/{ChromeProfilePicker-WJZJOZ6Z.js → ChromeProfilePicker-6IVAYCWJ.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-65BQF5G5.js → CliFeedbackPrompt-K4IN7S6J.js} +1 -1
  4. package/dist/{CliUploadProgress-HEBZYKGN.js → CliUploadProgress-MI4H4LKT.js} +1 -1
  5. package/dist/{ConfigView-JEVQ2SO4.js → ConfigView-CJY5MB6H.js} +1 -1
  6. package/dist/EvidenceViewOffer-ABKTGD4K.js +2 -0
  7. package/dist/FolderPicker-RQIVS7ZR.js +2 -0
  8. package/dist/{InfoBox-KM5DLBCV.js → InfoBox-RP6RDCG7.js} +1 -1
  9. package/dist/{LinksBox-FQA36GTV.js → LinksBox-QOQJ3S2I.js} +1 -1
  10. package/dist/{ProfilesView-76KGHTMK.js → ProfilesView-BZEBT6R5.js} +1 -1
  11. package/dist/{ProjectPicker-65YOU46H.js → ProjectPicker-J42MEJRQ.js} +1 -1
  12. package/dist/{SaveSessionPrompt-QD6BNTWO.js → SaveSessionPrompt-MKAIUVX7.js} +1 -1
  13. package/dist/SingleShotApp-TZZ2J7ZO.js +2 -0
  14. package/dist/{SummaryBox-N2B6DUDD.js → SummaryBox-JQJKGYDM.js} +1 -1
  15. package/dist/TestMdRunView-2YVGGFLU.js +2 -0
  16. package/dist/{TestrunEvidenceTable-3WLQVTF4.js → TestrunEvidenceTable-FYDS3ZVU.js} +1 -1
  17. package/dist/{WhoamiView-T26HA4ZZ.js → WhoamiView-F4PPB7SN.js} +1 -1
  18. package/dist/{app-download-XKZWFMEK.js → app-download-RA4CGTC5.js} +1 -1
  19. package/dist/{auth-PPJANIMZ.js → auth-TAT427C3.js} +1 -1
  20. package/dist/{binary-DKWWODT2.js → binary-OFPMBJ34.js} +1 -1
  21. package/dist/{bind-62AZYFAY.js → bind-LY362KX7.js} +2 -2
  22. package/dist/{bootstrap-6IJNZIPT.js → bootstrap-RCDB5OWA.js} +1 -1
  23. package/dist/bridge-E2NGMJYM.js +2 -0
  24. package/dist/{changelog-UTGJ7FSP.js → changelog-ZC3LHV2Z.js} +1 -1
  25. package/dist/{chunk-O5AS2ZIX.js → chunk-23MVD7GY.js} +1 -1
  26. package/dist/{chunk-X74PP5NJ.js → chunk-2GWMENG5.js} +1 -1
  27. package/dist/{chunk-75I46VTM.js → chunk-3AVBUEBL.js} +2 -2
  28. package/dist/chunk-3LXN6AV5.js +5 -0
  29. package/dist/{chunk-NOLYYHVG.js → chunk-3MVEGB2I.js} +1 -1
  30. package/dist/{chunk-42FHKRPA.js → chunk-4LVZLLTN.js} +3 -3
  31. package/dist/{chunk-73ULUGBM.js → chunk-4PWYSDZR.js} +1 -1
  32. package/dist/{chunk-7RAI77XD.js → chunk-4WEVTED6.js} +1 -1
  33. package/dist/{chunk-CGT4NFQN.js → chunk-5ACSALRU.js} +3 -3
  34. package/dist/{chunk-SX56MVUO.js → chunk-5VZAWKDF.js} +1 -1
  35. package/dist/{chunk-2BFXT7VQ.js → chunk-6HCY5LJO.js} +14 -14
  36. package/dist/{chunk-XGHMZJGI.js → chunk-7P6FSGRD.js} +2 -2
  37. package/dist/{chunk-UXH3RMQ7.js → chunk-7QUFOWMU.js} +1 -1
  38. package/dist/{chunk-O2APH6TZ.js → chunk-7XMDCGIZ.js} +1 -1
  39. package/dist/{chunk-LL5DQO6V.js → chunk-AAT4O22C.js} +1 -1
  40. package/dist/{chunk-FFFB5BXL.js → chunk-AGKE5WF3.js} +1 -1
  41. package/dist/{chunk-OH2NSBO6.js → chunk-BCJNIDS3.js} +1 -1
  42. package/dist/{chunk-3BHRGHIZ.js → chunk-BK42G6RI.js} +1 -1
  43. package/dist/{chunk-YHR2YAN5.js → chunk-BY2MU3ZS.js} +1 -1
  44. package/dist/{chunk-AC7BPO4X.js → chunk-C6JFTSIQ.js} +1 -1
  45. package/dist/chunk-CAOZKSQ3.js +8 -0
  46. package/dist/{chunk-DA57DXCF.js → chunk-CDWUZ54U.js} +1 -1
  47. package/dist/{chunk-3YX3RQXO.js → chunk-CR7UWQ76.js} +1 -1
  48. package/dist/{chunk-LR5DJ6EN.js → chunk-CVNHUDT4.js} +1 -1
  49. package/dist/{chunk-MLRO7OH3.js → chunk-DSWHEEHN.js} +1 -1
  50. package/dist/{chunk-6LGED4FC.js → chunk-E44OHYDS.js} +2 -2
  51. package/dist/{chunk-BJYGWXVP.js → chunk-ECIGXPLN.js} +1 -1
  52. package/dist/{chunk-QJ5O27SJ.js → chunk-EMAKLNDV.js} +1 -1
  53. package/dist/{chunk-B2ZGG7WM.js → chunk-F2XTOZTN.js} +1 -1
  54. package/dist/{chunk-ARG56PJG.js → chunk-FQFVAFWK.js} +1 -1
  55. package/dist/{chunk-SFTFHFG3.js → chunk-FWPRUGJJ.js} +1 -1
  56. package/dist/{chunk-4K5XTIJ6.js → chunk-FYJ62EVY.js} +1 -1
  57. package/dist/{chunk-N7ZRF5K3.js → chunk-G2ZMNVYN.js} +1 -1
  58. package/dist/{chunk-J7NRD4Q7.js → chunk-GCMJDOAE.js} +1 -1
  59. package/dist/{chunk-WBHSPN55.js → chunk-GGD7NKPL.js} +2 -2
  60. package/dist/{chunk-WOA7VCGA.js → chunk-H6S7L2I2.js} +1 -1
  61. package/dist/{chunk-RBHQXWR7.js → chunk-HBMNUT6E.js} +1 -1
  62. package/dist/{chunk-ZWHPIR2Z.js → chunk-HYCOX7AB.js} +2 -2
  63. package/dist/{chunk-RQLU4NDG.js → chunk-ICUTARPB.js} +1 -1
  64. package/dist/{chunk-YHVG7V3E.js → chunk-IJTSA34Q.js} +1 -1
  65. package/dist/chunk-IQDZ6YMY.js +18 -0
  66. package/dist/{chunk-ZA4M4O7E.js → chunk-IYOPWIG4.js} +2 -2
  67. package/dist/{chunk-7L25ZNNP.js → chunk-IZ5CTC6M.js} +1 -1
  68. package/dist/{chunk-GKZ2KVE6.js → chunk-J2LWXO55.js} +1 -1
  69. package/dist/{chunk-BAKJPQGU.js → chunk-KPL2XHYF.js} +1 -1
  70. package/dist/{chunk-WR42Q3HU.js → chunk-KYZKPNPQ.js} +1 -1
  71. package/dist/chunk-L45HDSJ7.js +15 -0
  72. package/dist/{chunk-4BBDKWM3.js → chunk-MD3S2RXN.js} +1 -1
  73. package/dist/{chunk-JH6E632O.js → chunk-MU3I453X.js} +1 -1
  74. package/dist/{chunk-C74ABM24.js → chunk-MZYPDLD3.js} +1 -1
  75. package/dist/{chunk-GESG672R.js → chunk-NADKZKGS.js} +1 -1
  76. package/dist/{chunk-2RMHDOP4.js → chunk-NMBFAIXZ.js} +1 -1
  77. package/dist/chunk-NN6UG2BE.js +11 -0
  78. package/dist/chunk-NPKB7EK3.js +7 -0
  79. package/dist/{chunk-MNE5VMHT.js → chunk-O3ZKP4DY.js} +1 -1
  80. package/dist/{chunk-KOL6ZWOQ.js → chunk-OUWOLCCS.js} +1 -1
  81. package/dist/{chunk-GPIXV7AV.js → chunk-OYY566GN.js} +1 -1
  82. package/dist/{chunk-3SPOJWRA.js → chunk-PDTFQGQF.js} +1 -1
  83. package/dist/{chunk-Q7XBMBMR.js → chunk-Q7LZ5QJV.js} +1 -1
  84. package/dist/{chunk-X5276I5H.js → chunk-QMZLIHBS.js} +2 -2
  85. package/dist/chunk-QXUPBIV3.js +93 -0
  86. package/dist/{chunk-SQDQADWD.js → chunk-RCYYE6ED.js} +1 -1
  87. package/dist/{chunk-6F6YI3ZG.js → chunk-SF5QPR6T.js} +1 -1
  88. package/dist/{chunk-22QIVSQR.js → chunk-SWTJMTBY.js} +1 -1
  89. package/dist/{chunk-O6U2HU5M.js → chunk-TBYYPGHF.js} +1 -1
  90. package/dist/{chunk-SGHP44WS.js → chunk-TGBXIV7O.js} +1 -1
  91. package/dist/{chunk-P3JUE2RM.js → chunk-TWZ6NZWE.js} +4 -4
  92. package/dist/{chunk-L6MOO4WT.js → chunk-U466V5JN.js} +1 -1
  93. package/dist/{chunk-OO5GMBVI.js → chunk-U7BVK5IX.js} +1 -1
  94. package/dist/{chunk-IQ7NGOAT.js → chunk-UAFCBZ3P.js} +1 -1
  95. package/dist/{chunk-JKX57HA7.js → chunk-UEG4LJD6.js} +1 -1
  96. package/dist/{chunk-NBMLBCJ3.js → chunk-ULGFPKC7.js} +1 -1
  97. package/dist/{chunk-KOPP4CJW.js → chunk-V4JR5JCK.js} +1 -1
  98. package/dist/{chunk-ZKEOPIQ3.js → chunk-VATOIZYG.js} +1 -1
  99. package/dist/{chunk-WILT62DP.js → chunk-VOTIGXQ4.js} +1 -1
  100. package/dist/chunk-VWOAEF7J.js +2 -0
  101. package/dist/{chunk-VNFCX2SH.js → chunk-W4Y3PG7F.js} +1 -1
  102. package/dist/{chunk-RH6KFHJB.js → chunk-WECVT7WE.js} +1 -1
  103. package/dist/{chunk-QPUVOVD7.js → chunk-WML5KSGQ.js} +1 -1
  104. package/dist/{chunk-PGU64EWQ.js → chunk-WPNNRMTP.js} +1 -1
  105. package/dist/{chunk-IQ7GPETF.js → chunk-XGL3RSI5.js} +1 -1
  106. package/dist/{chunk-JJJSDDQ2.js → chunk-Z2GDSCPS.js} +1 -1
  107. package/dist/chunk-Z4KRSLAM.js +2 -0
  108. package/dist/{chunk-EMSLJTYN.js → chunk-Z5DGFN7R.js} +1 -1
  109. package/dist/{chunk-NDCRJXYF.js → chunk-ZLIYWELJ.js} +1 -1
  110. package/dist/{chunk-K7K23DIQ.js → chunk-ZYEFWJNZ.js} +1 -1
  111. package/dist/{config-3AKWRTFS.js → config-WETHR632.js} +1 -1
  112. package/dist/{cover-cmd-ZLAWMEC2.js → cover-cmd-J3CTQT3R.js} +1 -1
  113. package/dist/{credentials-Q4WH5CBN.js → credentials-RQPAP5KY.js} +1 -1
  114. package/dist/{deps-bundle-RVZK6LZJ.js → deps-bundle-F47ZDYIM.js} +1 -1
  115. package/dist/{deps-resolve-6F2U4TJP.js → deps-resolve-URKD4QCB.js} +1 -1
  116. package/dist/{dispatch-46BETGXY.js → dispatch-KOZAJQDW.js} +1 -1
  117. package/dist/{doctor-WRPG56HH.js → doctor-J44UKALC.js} +1 -1
  118. package/dist/{evidence-XWR32HWP.js → evidence-KRNDKDCT.js} +1 -1
  119. package/dist/{evolve-cmd-27ZQN6YB.js → evolve-cmd-CEYGGIWA.js} +1 -1
  120. package/dist/{explain-cmd-JCJTXVZY.js → explain-cmd-USGRZFBY.js} +1 -1
  121. package/dist/{extract-bind-D5BYYGYA.js → extract-bind-X4QRQX53.js} +2 -2
  122. package/dist/{extract-cmd-CCYW7FIY.js → extract-cmd-RKEE32FN.js} +1 -1
  123. package/dist/{gaps-cmd-3VJKQ25D.js → gaps-cmd-WL6P6YKS.js} +1 -1
  124. package/dist/{generate-headless-2M6UT3IK.js → generate-headless-LSQHOR3G.js} +2 -2
  125. package/dist/index.js +147 -149
  126. package/dist/{ingest-cmd-HVTUK264.js → ingest-cmd-TQ4ARSDE.js} +1 -1
  127. package/dist/install-47CRHVU6.js +2 -0
  128. package/dist/{interactive-bind-OJCYNQPI.js → interactive-bind-FPC4RYEW.js} +3 -3
  129. package/dist/{lifecycle-cmd-GWFGUGTC.js → lifecycle-cmd-DB5EFO2O.js} +1 -1
  130. package/dist/{list-cmd-AXDW64OY.js → list-cmd-UWGJRGKF.js} +1 -1
  131. package/dist/{list-commands-YNZ6EFIF.js → list-commands-Q77CAQJ2.js} +1 -1
  132. package/dist/login-flow-RSNR5HY2.js +2 -0
  133. package/dist/{maintenance-cmd-QEMK6YNV.js → maintenance-cmd-EJ2RAMWB.js} +1 -1
  134. package/dist/{mobile-prompts-OXHA5GHJ.js → mobile-prompts-PPPPKRS2.js} +1 -1
  135. package/dist/objective-variable-gate-BCKULIFQ.js +2 -0
  136. package/dist/{open-provider-E5VUGFNE.js → open-provider-XIGABCD3.js} +1 -1
  137. package/dist/{persist-recorded-session-KWPH37HI.js → persist-recorded-session-MK4HCDOY.js} +1 -1
  138. package/dist/pipeline-XDWHEZ5S.js +2 -0
  139. package/dist/prepare-target-NR3MTLLI.js +2 -0
  140. package/dist/{reconcile-cmd-V7TDYETT.js → reconcile-cmd-VJPEY7YD.js} +1 -1
  141. package/dist/{reconcile-deps-X6IGH4CA.js → reconcile-deps-T5YX6HRG.js} +2 -2
  142. package/dist/{reconcile-engine-OGXSIE7O.js → reconcile-engine-GELPXSLV.js} +1 -1
  143. package/dist/{recording-banner-IZWN2XFY.js → recording-banner-3ET3PMSV.js} +1 -1
  144. package/dist/registry-3XMA4FOC.js +2 -0
  145. package/dist/{require-project-folder-PEEUITK6.js → require-project-folder-ZLKONKKP.js} +1 -1
  146. package/dist/{resolve-run-intent-JGXXE45Y.js → resolve-run-intent-3SXUS676.js} +1 -1
  147. package/dist/{resolver-TY7XLJBN.js → resolver-G7NGWACO.js} +1 -1
  148. package/dist/{review-cmd-74YTPT7E.js → review-cmd-6DNGXV5E.js} +1 -1
  149. package/dist/{run-DN4XARP2.js → run-MUVZVTTC.js} +1 -1
  150. package/dist/{run-GRYWYKIH.js → run-UJLRTKTO.js} +1 -1
  151. package/dist/{run-test-md-DFCKCQ4T.js → run-test-md-RI5RXVFU.js} +2 -2
  152. package/dist/{skill-installer-GRU3HOYF.js → skill-installer-CAO2NJZP.js} +1 -1
  153. package/dist/{spawner-LNMD4NJF.js → spawner-H6IDWY5U.js} +1 -1
  154. package/dist/{store-guard-Q4MYZQHF.js → store-guard-PIA2DYZX.js} +1 -1
  155. package/dist/{sync-cmd-H6Y5EB3L.js → sync-cmd-VFVTFIIJ.js} +1 -1
  156. package/dist/{sync-setup-THGRBKTA.js → sync-setup-R7BZDE24.js} +1 -1
  157. package/dist/tcg-generate-QADJKNYZ.js +2 -0
  158. package/dist/testmd-actions-EXSVQRHQ.js +2 -0
  159. package/dist/testmd-sync-2CXNIPJ7.js +2 -0
  160. package/dist/token-refresh-5TVNSL4U.js +2 -0
  161. package/dist/{validate-basic-RCBEELSB.js → validate-basic-MN5NDCT2.js} +1 -1
  162. package/dist/{variable-receipt-JHRW73Z6.js → variable-receipt-SIABUC74.js} +1 -1
  163. package/dist/{verdicts-XFXDRND4.js → verdicts-ZXXBKTOZ.js} +1 -1
  164. package/dist/{version-check-Z774UWW3.js → version-check-TDGK5REB.js} +1 -1
  165. package/dist/{view-cmd-I4LQGJ2X.js → view-cmd-RLO7AP4X.js} +1 -1
  166. package/dist/{walk-session-FP52IGLB.js → walk-session-ATWNUGHX.js} +1 -1
  167. package/dist/{with-telemetry-P6RUPWBH.js → with-telemetry-CLSDKQAG.js} +1 -1
  168. package/package.json +11 -11
  169. package/dist/EvidenceViewOffer-5MB4ZXKM.js +0 -2
  170. package/dist/FolderPicker-SYFXH6D5.js +0 -2
  171. package/dist/SingleShotApp-U54ETXS3.js +0 -2
  172. package/dist/TestMdRunView-WA4TC5PT.js +0 -2
  173. package/dist/bridge-X5DEJL6F.js +0 -2
  174. package/dist/chunk-53MPG2J3.js +0 -11
  175. package/dist/chunk-IICQ5KRD.js +0 -5
  176. package/dist/chunk-KN65CUNT.js +0 -15
  177. package/dist/chunk-L4M7753M.js +0 -2
  178. package/dist/chunk-LBNADEQN.js +0 -8
  179. package/dist/chunk-LNV7C2YO.js +0 -6
  180. package/dist/chunk-M7DN6FO3.js +0 -17
  181. package/dist/chunk-ZZTZJPT2.js +0 -88
  182. package/dist/install-5WJLE7XT.js +0 -2
  183. package/dist/login-flow-PRXFPRYZ.js +0 -2
  184. package/dist/objective-variable-gate-76GYUHEP.js +0 -2
  185. package/dist/pipeline-A2OGF4XW.js +0 -2
  186. package/dist/prepare-target-P6BWJZBZ.js +0 -2
  187. package/dist/registry-GOLIFVK5.js +0 -2
  188. package/dist/tcg-generate-SZZ7MJXY.js +0 -2
  189. package/dist/testmd-actions-MRIUOOXO.js +0 -2
  190. package/dist/testmd-sync-UYVJ47BN.js +0 -2
  191. package/dist/token-refresh-KN5JK2U4.js +0 -2
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as y}from"./chunk-B2ZGG7WM.js";import{existsSync as V,readdirSync as N,readFileSync as w}from"fs";import{join as g}from"path";var U="--variables",R=["smart","environment","secrets","totp"],O=/^[a-z][a-z0-9_]*$/;function D(e){return typeof e=="string"?e.trim().length>0:typeof e=="number"&&Number.isFinite(e)}function p(e,r,n){let t=JSON.parse(e);if(!(!t||typeof t!="object")){for(let[o,l]of Object.entries(t))if(l&&typeof l=="object"&&"value"in l){let c={has_value:D(l.value),source:r},i=/^(?:global|secrets\.user|environment)\.(.+)$/.exec(o);n.set(i?i[1]:o,c)}}}function h(e,r){if(!V(e))return;let n;try{n=N(e).filter(t=>t.endsWith(".json")).sort()}catch{return}for(let t of n){let o=g(e,t);try{p(w(o,"utf-8"),o,r)}catch{}}}function G(e){return{globalDir:g(y,"variables"),localDir:g(e,".testmuai","variables")}}function L(e){let r=new Map;if(h(e.globalDir,r),h(e.localDir,r),e.file&&V(e.file))try{p(w(e.file,"utf-8"),e.file,r)}catch{}if(e.inline)try{p(e.inline,U,r)}catch{}return r}function u(e){let r=e.trim();if(!r)return null;let n=r.split(/[.[]/).map(t=>t.trim()).filter(Boolean);return n.length===0||R.includes(n[0])?null:n[0]==="global"?n[1]??null:n[0]}function P(e){if(!e||!e.trim())return"variable name is empty";let r=e.split(".")[0];return r==="global"||R.includes(r)?`'${e}' starts with a runtime namespace (global/secrets/smart/environment/totp) \u2014 declare the bare name`:O.test(e)?null:`'${e}' is not lower_snake_case (letters, digits, underscores; starts with a letter)`}import{basename as T}from"path";var K="objective",F=/(\\?)\{\{\s*([^{}]+?)\s*\}\}/g;function m(e){let r=[];if(!e)return r;for(let n of e.matchAll(F)){if(n[1])continue;let t=u(n[2]??"");t&&!r.includes(t)&&r.push(t)}return r}var M=/\b(?:store|save|extract|remember|capture)\b/i,z=/\bas\s+(?:['"`]([A-Za-z_][A-Za-z0-9_]*)['"`]|([A-Za-z_][A-Za-z0-9_]*)(?=\s*(?:,|$)))/gi,C=new Set(["a","an","the"]);function S(e){let r=[];if(!e)return r;for(let n of e.split(/[.;\n]/))if(M.test(n))for(let t of n.matchAll(z)){let o=t[1]??t[2];!o||C.has(o.toLowerCase())||r.includes(o)||r.push(o)}return r}function E(e,r,n){let t=r.get(e);return t?t.has_value?null:{name:e,reason:"value_missing",file:t.source,used_by:[n]}:{name:e,reason:"not_declared",used_by:[n]}}function Q(e,r,n,t=[]){let o=new Set([...t,...S(e)]),l=[];for(let c of m(e)){if(o.has(c))continue;let i=E(c,r,n);i&&l.push(i)}return l}function X(e,r,n={}){let t=e.rootGlobal.variables??{},o=new Set(n.produced??[]),l=n.authorFrom??0,c=[];for(let i of e.steps){let I=i.flatIndex-1>=l,f=S(i.objective);if(!I){for(let s of f)o.add(s);continue}let k={file:T(i.sourceFile),step:i.flatIndex},j=i.config.variables??{},d=new Map;for(let[s,a]of Object.entries(t))d.set(u(s)??s,a.value);for(let[s,a]of Object.entries(j))d.set(u(s)??s,a.value);let b=new Set,v=(s,a)=>{if(o.has(s)||f.includes(s))return;let x=d.get(s);if(x===void 0){b.add(s);return}if(a.has(s)){b.add(s);return}a.add(s);for(let A of m(x))v(A,a);a.delete(s)};for(let s of m(i.objective))v(s,new Set);let _=[];for(let s of b){let a=E(s,r,k);a&&_.push(a)}c.push(_);for(let s of f)o.add(s)}return $(c)}function Y(e){let r=new Set,n=e&&typeof e=="object"?e:null;for(let t of n?.prior_runs??[])for(let o of Object.keys(t.variables??{}))r.add(o);return[...r]}function $(e){let r=new Map;for(let n of e)for(let t of n){let o=r.get(t.name);o?o.used_by.push(...t.used_by):r.set(t.name,{...t,used_by:[...t.used_by]})}return[...r.values()].sort((n,t)=>n.name<t.name?-1:1)}export{U as a,G as b,L as c,P as d,K as e,m as f,Q as g,X as h,Y as i,$ as j};
@@ -1,8 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as h}from"./chunk-VZ7KXRXB.js";import{c as _}from"./chunk-EYOCNMUM.js";import{dirname as F,isAbsolute as T,resolve as j}from"path";var k=["db","api","js","smartui","network_query","network_assertion"];var a=class extends Error{constructor(r,o,e){super(`[${o}${e!=null?`:${e}`:""}] ${r}`);this.file=o;this.line=e;this.name="TestMdParseError"}};var R=["if","elif","else","end-if","while","end-while"];var C={"end-if":"if","end-while":"while"};function v(n,t){let r=[],o=()=>r[r.length-1];for(let i of t){let s=i.controlFlow;if(s==="if"||s==="while"){r.push({kind:s,id:i.index,branch:0,elseSeen:!1}),i.block={id:i.index,branch:0,depth:r.length};continue}if(s==="elif"||s==="else"){let l=o();if(!l||l.kind!=="if")throw new a(`@${s} outside an open @if`,n,i.headingLine);if(l.elseSeen)throw new a(`@${s} after @else`,n,i.headingLine);l.branch+=1,l.elseSeen=s==="else",i.block={id:l.id,branch:l.branch,depth:r.length};continue}if(s==="end-if"||s==="end-while"){let l=o(),f=C[s];if(!l||l.kind!==f)throw new a(`@${s} without an open @${f}`,n,i.headingLine);i.block={id:l.id,branch:-1,depth:r.length},r.pop();continue}let c=o();c&&(i.block={id:c.id,branch:c.branch,depth:r.length})}let e=o();if(e){let i=t.find(s=>s.index===e.id);throw new a(`unclosed @${e.kind} block`,n,i?.headingLine)}}var P=new Set(["username","access_key","oauth","profile","project_id","folder_id"]),$=new Set(["mode","max_steps","timeout","global_context","local_context","variables","session_context","code_export","code_language","url","target","chrome_profile","cdp_endpoint","ws_endpoint","headless","app","no_reset","os_version","device_name","on_lock_conflict","tags","assurance"]),O=new Set(["optional"]),Y=new Set(["optional","variables"]),M=new Set(["target","chrome_profile","cdp_endpoint","ws_endpoint","headless"]),N=new Set(["app","no_reset","os_version","device_name"]),B=new Set(["mode","on_lock_conflict","tags","assurance"]);function we(n,t){let r=t.split(`
3
- `),{global:o,bodyStartLine:e}=I(n,r),{title:i,steps:s}=oe(n,r,e);return{path:n,title:i,global:o,steps:s}}function I(n,t){if(t[0]?.trim()!=="---")return{global:{},bodyStartLine:0};let r=-1;for(let c=1;c<t.length;c++)if(t[c].trim()==="---"){r=c;break}if(r===-1)throw new a("frontmatter is missing closing '---'",n,1);let o=t.slice(1,r).join(`
4
- `),e;try{e=h(o)??{}}catch(c){throw new a(`invalid YAML in frontmatter: ${c.message}`,n,1)}if(E(n,e,"frontmatter",1),e.on_lock_conflict!==void 0){let c=e.on_lock_conflict;if(c!=="readonly"&&c!=="fail"&&c!=="wait")throw new a(`on_lock_conflict must be 'readonly' | 'fail' | 'wait', got: ${JSON.stringify(c)}`,n,1)}if(L(n,e,1),e.assurance!==void 0){let c=e.assurance;if(c===null||typeof c!="object"||Array.isArray(c))throw new a("assurance must be a mapping with sub-keys {id, base}",n,1);let l=c;for(let f of Object.keys(l))if(f!=="id"&&f!=="base")throw new a(`unknown assurance sub-key '${f}' \u2014 the engine block allows only {id, base}`,n,1);if(typeof l.id!="string"||l.id.length===0)throw new a("assurance.id must be a non-empty string (logical id)",n,1);if(l.base!==void 0&&!(typeof l.base=="string"&&/^sha256:[0-9a-f]+$/.test(l.base)))throw new a("assurance.base must be a 'sha256:<hex>' string",n,1)}if(e.tags!==void 0){let c=e.tags,l=Array.isArray(c)?c.map(f=>String(f)).join(","):String(c);e.tags=G(l,n,1)}if(e.target!==void 0&&(e.target=q(e.target,n,1)),e.app!==void 0&&(e.app=H(e.app,n,1)),e.no_reset!==void 0&&typeof e.no_reset!="boolean")throw new a(`no_reset must be boolean: got ${typeof e.no_reset}`,n,1);if(e.os_version!==void 0&&typeof e.os_version!="string")if(typeof e.os_version=="number")e.os_version=String(e.os_version);else throw new a(`os_version must be a string: got ${typeof e.os_version}`,n,1);let i=e.target,s=i==="emulator"||i==="simulator";if(s&&e.app===void 0)throw new a(`target: ${String(i)} needs an app \u2014 add \`app: <path-to-build | AppId>\``,n,1);if(!s&&e.app!==void 0)throw new a("app requires a mobile target \u2014 add `target: emulator` or `target: simulator`",n,1);if(!s&&e.no_reset!==void 0)throw new a("no_reset requires a mobile target \u2014 add `target: emulator` or `target: simulator`",n,1);if(!s&&e.os_version!==void 0)throw new a("os_version requires a mobile target \u2014 add `target: emulator` or `target: simulator`",n,1);if(e.device_name!==void 0&&typeof e.device_name!="string")throw new a(`device_name must be a string: got ${typeof e.device_name}`,n,1);if(!s&&e.device_name!==void 0)throw new a("device_name requires a mobile target \u2014 add `target: emulator` or `target: simulator`",n,1);return{global:e,bodyStartLine:r+1}}function G(n,t,r){let e=n.trim().replace(/^\[/,"").replace(/\]$/,"").split(",").map(i=>i.trim().toLowerCase());if(e.length===0||e.some(i=>i.length===0))throw new a("tags must be a non-empty list of non-empty strings",t,r);return[...new Set(e)]}var V=new Set(["chrome","cdp","ws","emulator","simulator"]),W="target must be one of 'chrome' | 'cdp' | 'ws' (web) or 'emulator' | 'simulator' (mobile, with a root `app:` key)";function q(n,t,r){if(typeof n=="string"&&V.has(n))return n;throw n!==null&&typeof n=="object"&&!Array.isArray(n)?new a(`the mapping form of target is no longer accepted \u2014 write flat keys:
5
- target: emulator | simulator
6
- app: <path-to-build | AppId>`,t,r):new a(`${W} \u2014 got: ${JSON.stringify(n)}`,t,r)}function H(n,t,r){if(typeof n!="string"||n.trim().length===0)throw new a("app must be a build (e.g. ./builds/app-debug.apk) or an app id from your cloud uploads",t,r);let o=n.trim();if(!/\.(apk|zip)$/i.test(o)&&!/^APP\d{6,}$/.test(o))throw new a(`app '${o}' is not a build \u2014 expected a path ending in .apk or .zip, or an app id from your cloud uploads.`,t,r);return z(o,t)}function z(n,t){return/^APP[0-9A-Za-z_-]+$/.test(n)||T(n)?n:j(F(t),n)}function be(n){let t=n.target;if(!(t!=="emulator"&&t!=="simulator"))return{platform:_(t)??"",app:n.app??"",...n.no_reset!==void 0?{no_reset:n.no_reset}:{},...n.os_version!==void 0?{os_version:n.os_version}:{},...n.device_name!==void 0?{device_name:n.device_name}:{}}}function ye(n){let t=n.target;return t==="chrome"||t==="cdp"||t==="ws"?t:void 0}var D=/\s@verifies\s+(ac-[\w.:\/-]+(?:\s*,\s*ac-[\w.:\/-]+)*)\s*$/;function J(n,t,r){let o=D.exec(t);if(o)return{label:t.slice(0,o.index).trim(),verifies:o[1].split(",").map(i=>i.trim())};let e=t.lastIndexOf("@verifies");if(e>0&&/\s/.test(t[e-1])){let i=t.slice(e+9).split(/[\s,]+/).filter(s=>s.length>0);if(i.length===0||i.every(s=>s.startsWith("ac-")))throw new a("malformed @verifies directive \u2014 expected '@verifies ac-<id>[, ac-<id>\u2026]' at the end of the heading",n,r)}return{label:t,verifies:[]}}var S=k.join("|"),U=new RegExp(`^(.*\\S)\\s+@(${S})\\s*$`),Z=new RegExp(`^@(${S})\\s*$`);function Q(n,t,r,o){let e=Z.exec(t);if(e)throw new a(`replay-only marker @${e[1]} needs a step label before it (e.g. '## Step 3 @${e[1]}')`,n,r);let i=U.exec(t);if(!i)return null;let s=i[2];if(o)throw new a(`only one replay-only marker per step \u2014 found @${o} and @${s}`,n,r);return{label:i[1].trim(),replayOnly:s}}var x=R.join("|"),X=new RegExp(`^(.*\\S)\\s+@(${x})\\s*$`),ee=new RegExp(`^@(${x})\\s*$`);function ne(n,t,r,o){let e=ee.exec(t);if(e)throw new a(`control-flow marker @${e[1]} needs a step label before it (e.g. '## banner is visible @${e[1]}')`,n,r);let i=X.exec(t);if(!i)return null;let s=i[2];if(o)throw new a(`only one control-flow marker per step \u2014 found @${o} and @${s}`,n,r);return{label:i[1].trim(),controlFlow:s}}function te(n,t,r){let o=t,e,i,s=()=>{let l=Q(n,o,r,e);l&&({label:o,replayOnly:e}=l);let f=ne(n,o,r,i);f&&({label:o,controlFlow:i}=f)};s();let c=J(n,o,r);if(o=c.label,s(),e&&i)throw new a(`@${i} is a control-flow marker and @${e} a replay-only marker \u2014 a step carries one or the other`,n,r);return{label:o,verifies:c.verifies,...e?{replayOnly:e}:{},...i?{controlFlow:i}:{}}}function oe(n,t,r){let o,e=r;for(;e<t.length&&t[e].trim()==="";)e++;let i=e<t.length?/^#\s+(.+?)\s*$/.exec(t[e]):null;i&&(o=i[1],e++);let s=[];for(let l=e;l<t.length;l++)/^##\s/.test(t[l])&&s.push(l);let c=[];for(let l=0;l<s.length;l++){let f=s[l],g=s[l+1]??t.length,m=t[f].replace(/^##\s+/,"").trim(),{label:w,verifies:d,replayOnly:p,controlFlow:u}=te(n,m,f+1),b=t.slice(f+1,g),{config:A,body:y,optional:K}=re(n,f+1,b);if(p&&y.kind==="import_ref")throw new a(`@${p} is a replay-only marker for objective steps \u2014 it cannot mark an @import row`,n,f+1);if(u&&y.kind==="import_ref")throw new a(`@${u} is a control-flow marker for objective steps \u2014 it cannot mark an @import row`,n,f+1);c.push({index:l+1,heading:w,verifies:d,config:A,body:y,headingLine:f+1,optional:K,...p?{replayOnly:p}:{},...u?{controlFlow:u}:{}})}return v(n,c),{title:o,steps:c}}function re(n,t,r){let o=0;for(;o<r.length&&r[o].trim()==="";)o++;let e,i=t;if(o<r.length&&/^```yaml\s*$/.test(r[o])){let d=o;i=t+d,o++;let p=-1;for(;o<r.length;){if(/^```\s*$/.test(r[o])){p=o;break}o++}if(p===-1)throw new a("step-config fenced ```yaml block is not closed",n,i);let u=r.slice(d+1,p).join(`
7
- `);try{e=h(u)??{}}catch(b){throw new a(`invalid YAML in step config: ${b.message}`,n,i)}o=p+1}let s=ie(r.slice(o)),c=s.filter(d=>d.trim()!=="");if(c.length>0&&/^@session\s+/.test(c[0].trim()))throw new a("@session is no longer supported (iteration 3); use @import instead",n,t);let l=/^@import\s+(\S.*)$/,g=s.filter(d=>l.test(d.trim())).length>0;if(g&&c.length!==1)throw new a("step body must be exactly one of prose / @import",n,t);let m=!1,w;if(e){if(E(n,e,g?"step config (ref)":"step config (objective)",i),L(n,e,i),typeof e.optional=="boolean")m=e.optional;else if(e.optional!==void 0)throw new a(`step config 'optional' must be boolean: got ${typeof e.optional}`,n,i);let d={...e};delete d.optional,g&&delete d.variables,!g&&Object.keys(d).length>0&&(w=d)}if(g){let p=l.exec(c[0].trim())[1].trim(),u=e?.variables;return{body:{kind:"import_ref",path:p,...u&&Object.keys(u).length>0?{bindings:u}:{}},optional:m}}return{body:{kind:"objective",text:s.join(`
8
- `).trim()},config:w,optional:m}}function ie(n){let t=0,r=n.length;for(;t<r&&n[t].trim()==="";)t++;for(;r>t&&n[r-1].trim()==="";)r--;return n.slice(t,r)}function L(n,t,r){let o=t.variables;if(o==null)return;if(typeof o!="object"||Array.isArray(o))throw new a("variables must be an object map",n,r);let e={};for(let[i,s]of Object.entries(o))if(typeof s=="string")e[i]={value:s};else if(s&&typeof s=="object"&&!Array.isArray(s)&&typeof s.value=="string")e[i]=s;else throw new a(`variable '${i}' must be a string or { value: ... } object`,n,r);t.variables=e}function E(n,t,r,o){for(let e of Object.keys(t)){if(P.has(e))throw new a(`auth/identity keys are CLI-only: ${e}`,n,o);if(r==="frontmatter"){if(O.has(e))throw new a(`step-only key in frontmatter: ${e}`,n,o);if(!$.has(e))throw new a(`unknown config key: ${e}`,n,o)}else if(r==="step config (objective)"){if(!$.has(e)&&!O.has(e))throw new a(`unknown config key: ${e}`,n,o);if(M.has(e))throw new a(`chrome config is global-only: ${e}`,n,o);if(N.has(e))throw new a(`'${e}' is global-only: the whole run drives one app`,n,o);if(B.has(e))throw new a(`'${e}' is run-level and cannot be set per-step`,n,o)}else if(!Y.has(e))throw new a(`step config on @import may only contain 'optional' / 'variables': got ${e}`,n,o)}}export{we as a,be as b,ye as c,D as d};
@@ -1,6 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{e as U}from"./chunk-EHN5HTUD.js";import{b as J,c as P,e as q,i as z,j as Q,k as X,l as Y,m as A}from"./chunk-KN65CUNT.js";import{a as G}from"./chunk-LBNADEQN.js";import{copyFileSync as le,cpSync as ue,existsSync as $,mkdirSync as pe,readFileSync as Oe,readdirSync as ce,rmSync as Te,writeFileSync as Ae}from"fs";import{dirname as _e,isAbsolute as Ee,join as y,relative as Le,resolve as Ke}from"path";import{writeFileSync as ge,mkdirSync as Se,readFileSync as ye}from"fs";import{dirname as Re,basename as Z}from"path";function te(e){let t=e.outPath??P(e.sourcePath);Se(Re(t),{recursive:!0});let s=[];s.push("---"),s.push(`test: ../${Z(e.sourcePath)}`),s.push(`status: ${e.overallStatus}`),s.push(`started: ${e.startedISO}`),s.push(`duration_s: ${e.durationS}`),s.push(`session_id: ${e.sessionId}`),s.push("---",""),s.push(`# ${e.title??Z(e.sourcePath)} \u2014 Result`,"");for(let l=0;l<e.rootSteps.length;l++){let d=e.rootSteps[l],r=e.outcomes.find(p=>p.rootStepIndex===l+1);if(s.push(xe(d,r)),r?.stepMd5&&s.push(`md5: ${r.stepMd5}`),r?.status==="failed"&&r.reason&&s.push(`Reason: ${r.reason}`),r?.softFailures?.length)for(let p of r.softFailures){let o=p.reason?`: ${p.reason}`:"";s.push(`\u26A0 optional sub-step ${p.subStepIndex} failed${o}`)}d.body.kind==="objective"&&r?.status!=="skipped"&&s.push(d.body.text),s.push("")}return ge(t,s.join(`
3
- `),"utf8"),t}function xe(e,t){if(!t)return`## ${e.heading} (no outcome)`;let s=t.duration_s!=null?`${t.duration_s}s`:"\u2014";if(t.status==="skipped")return`## ${e.heading} \u23ED skipped`;let l=t.softFailed?" (optional)":"";if(t.refKind&&t.status==="passed"){let d=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2713 passed (via @${t.refKind} ${t.refLabel} \u2014 ${t.inlinedCount} inlined steps, ${s}${d})`}if(t.refKind&&t.status==="failed"){let d=t.failedSubStepIndex&&t.failedSubStepIndex.length>0?` \u2014 at sub-step ${t.failedSubStepIndex.join(" \u2192 sub-step ")}`:"",r=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2717 failed${l} (via @${t.refKind} ${t.refLabel}${d}, ${s}${r})`}return t.status==="passed"?`## ${e.heading} \u2713 passed (${s})`:`## ${e.heading} \u2717 failed${l} (${s})`}var Ie=/^##\s+(.+?)\s+(✓ passed|✗ failed(?:\s+\(optional\))?|⏭ skipped)(?:\s+\((.*)\))?\s*$/,ke=/via\s+@\w+\s+(\S+).*?(?:→\s+(\S+))?\s*$/,be=/^md5:\s+([a-f0-9]{32})\s*$/;function ee(e,t){for(let s=t;s<e.length&&!/^##\s/.test(e[s]);s++){if(e[s].trim()==="")continue;let l=be.exec(e[s]);return l?l[1]:null}return null}function M(e){let s=ye(e,"utf8").split(`
4
- `),l="passed";if(s[0]?.trim()==="---")for(let r=1;r<s.length&&s[r].trim()!=="---";r++){let p=/^status:\s+(passed|failed|interrupted)\s*$/.exec(s[r]);p&&(l=p[1])}let d=[];for(let r=0;r<s.length;r++){let p=Ie.exec(s[r]);if(!p)continue;let o=p[1],n=p[2],c=p[3]??"",m=n.startsWith("\u2713")?"passed":n.startsWith("\u23ED")?"skipped":"failed";if(/via\s+@/.test(c)){let f=ke.exec(c),v=f?.[1]??"",x=f?.[2]??null;d.push({kind:"import",heading:o,status:m,md5:ee(s,r+1),importPath:v,helperResultRelPath:x})}else d.push({kind:"objective",heading:o,status:m,md5:ee(s,r+1)})}return{overallStatus:l,steps:d}}import{copyFileSync as se,existsSync as H,mkdirSync as ve,writeFileSync as ne,promises as Ue}from"fs";import{join as F,dirname as re,basename as we}from"path";async function ie(e){for(let t=0;t<e.totalRunDirs;t++){let s=e.runIndex+t,l=F(e.sessionDir,"runs",String(s)),d=F(e.stagingStepDir,"flows",String(t));ve(d,{recursive:!0});let r=F(d,"actions.ndjson");if(e.packTestDir){let n=F(e.packTestDir,"logs",`${s}-actions.ndjson`);if(H(n)){se(n,r);continue}let c=re(re(e.packTestDir)),m=we(e.packTestDir),R=H(c)?await U(c,`tests/${m}/logs/${s}-actions.ndjson`).catch(()=>null):null;ne(r,R??"");continue}let p=[F(l,"run-test","actions.ndjson"),F(l,"actions.ndjson")],o=!1;for(let n of p)if(H(n)){se(n,r),o=!0;break}o||ne(r,"")}}import{existsSync as _,readdirSync as Pe}from"fs";import{dirname as $e,join as j,basename as W}from"path";function et(e,t){let s=[];return e.steps.forEach((l,d)=>{let r=t[d];l.block||!l.replayOnly||!r||r.kind!=="author"||s.push({flatIndex:l.flatIndex,file:l.owningFile,heading:l.trace[l.trace.length-1].heading,kind:l.replayOnly,reason:r.reason})}),s}function tt(e){let t=[],s=new Set,l=new Map;function d(n){if(l.has(n))return l.get(n);let c=P(n),m=_(c)?M(c):null;return l.set(n,m),m}let r=new Map;function p(n){if(r.has(n))return r.get(n);let c=j(n,"Result.md"),m=_(c)?M(c):null;return r.set(n,m),m}function o(n){for(let c=1;c<n.trace.length;c++){let m=n.trace[c-1],R=d(m.file);if(!R)continue;let f=R.steps[m.stepIndex-1];if(f){if(f.kind!=="import")return{kind:"author",reason:"structure-mismatch"};if(W(f.importPath)!==W(n.trace[c].file))return{kind:"author",reason:"structure-mismatch"};if(f.md5!=null&&f.md5!==m.rowMd5)return{kind:"author",reason:"structure-mismatch"}}}return null}for(let n of e.steps){let c=n.trace[n.trace.length-1].stepIndex,m=n.replayOnly;if(n.block){let h=d(n.owningFile)?.steps[c-1],D=n.controlFlow!==void 0,O=h?.kind==="objective"&&h.status==="skipped";if(D||O){t.push({kind:"replay",recordingDir:"",flowCount:0,unrecorded:!0,...m?{replayOnly:m}:{}});continue}}let R=s.has(n.owningFile);for(let h=0;h<n.trace.length-1&&!R;h++)s.has(n.trace[h].file)&&(R=!0);if(R&&!m){t.push({kind:"author",reason:d(n.owningFile)===null?"no-result-md":"downstream-of-divergence"});continue}let f=o(n);if(f){for(let h=0;h<n.trace.length;h++)s.add(n.trace[h].file);if(!m){t.push(f);continue}}let v=d(n.owningFile),x;if(v===null&&n.trace.length>1){let h=V(n.trace);x=oe(n,p(h),c,h)}else x=oe(n,v,c);if(m&&x.kind==="replay"&&(x={...x,replayOnly:m}),t.push(x),x.kind==="author"){s.add(n.owningFile);for(let h=0;h<n.trace.length-1;h++)s.add(n.trace[h].file)}}return t}function oe(e,t,s,l=null){if(!t)return{kind:"author",reason:"no-result-md"};let d=t.steps[s-1];if(!d)return{kind:"author",reason:"no-result-md"};if(d.kind!=="objective")return{kind:"author",reason:"structure-mismatch"};if(d.status!=="passed")return{kind:"author",reason:"recorded-failed"};let r=A(e);if(r!==d.md5)return{kind:"author",reason:"md5-mismatch"};let p=l===null?X(e.owningFile,s,r.slice(0,8)):j(l,".internal","steps",`${s}-${r.slice(0,8)}`),o=De(p);return o===0?{kind:"author",reason:"missing-recording"}:{kind:"replay",recordingDir:p,flowCount:o}}function De(e){let t=j(e,"flows");if(!_(t))return 0;let s;try{s=Pe(t,{withFileTypes:!0}).filter(d=>d.isDirectory()&&/^\d+$/.test(d.name)).map(d=>parseInt(d.name,10))}catch{return 0}if(s.length===0)return 0;let l=Math.max(...s);for(let d=0;d<=l;d++)if(!_(j(t,String(d),"actions.ndjson")))return 0;return l+1}function st(e){return e.some(t=>t.kind==="author")}function nt(e){for(let t=0;t<e.length;t++)if(e[t].kind==="author")return t;return e.length}function V(e){let t=r=>{let p=W(r);return p.endsWith("_test.md")?p.slice(0,-8):p.endsWith(".md")?p.slice(0,-3):p},s=t(e[0].file),l=t(e[e.length-1].file),d=e.slice(0,-1).map(r=>String(r.stepIndex));return j($e(e[e.length-1].file),`helper-output-${l}-${s}-${d.join("-")}`)}function rt(e){return Array.from({length:e.flowCount},(t,s)=>j(e.recordingDir,"flows",String(s),"actions.ndjson"))}import{existsSync as de,mkdirSync as Me,rmSync as Fe,cpSync as je}from"fs";function ae(e,t){de(e)&&(de(t)&&Fe(t,{recursive:!0,force:!0}),Me(t,{recursive:!0}),je(e,t,{recursive:!0}))}async function St(e){let t=new Map;for(let o of e.stepRunRecords)t.set(o.testmdStepIndex,o);let s=e.authoredFlatIdx??new Set,l=[],d=[],r=new Map,p=o=>{if(r.has(o))return r.get(o);let n=y(o,"Result.md"),c=$(n)?M(n):null;return r.set(o,c),c};for(let o of e.resolvedTest.unitFiles){let n=o.file===e.resolvedTest.rootPath,c=G(o.file,Oe(o.file,"utf8")),m=P(o.file),R=$(m)?M(m):null,f=[],v=[],x=[],h=[];if(!n)for(let a of e.resolvedTest.steps){if(a.owningFile!==o.file||a.trace.length<2)continue;let i=V(a.trace);h.includes(i)||h.push(i)}let D=a=>{if(R!==null)return null;for(let i of h){let w=p(i)?.steps[a-1];if(w)return{row:w,dir:i}}return null},O=[],E=!1,B=!1,L=!1,K=!1;for(let a of c.steps){let i=a.index,u=R?.steps[i-1];if(a.body.kind==="objective"){let g=e.resolvedTest.steps.filter(S=>S.owningFile===o.file&&S.trace[S.trace.length-1].stepIndex===i&&t.has(S.flatIndex)),I=g.length>0?g[g.length-1]:null;if(I){E=!0,s.has(I.flatIndex)&&(B=!0);let S=A(I),k;n?k=e.outcomes.find(he=>he.rootStepIndex===i)??{rootStepIndex:i,status:"skipped"}:k={rootStepIndex:i,status:fe(I,e.outcomes)},k.status==="failed"&&(L=!0),k.stepMd5==null&&(k.stepMd5=S),f.push(k),v.push({stepIndex:i,md5:S,rec:t.get(I.flatIndex)}),(!u||u.kind!=="objective"||u.status!==k.status||k.status==="passed"&&u.md5!==S)&&(K=!0)}else if(u&&u.kind==="objective")f.push({rootStepIndex:i,status:u.status,...u.md5?{stepMd5:u.md5}:{}}),x.push(i);else if(!n&&D(i)?.row.kind==="objective"){let S=D(i),k=S.row;f.push({rootStepIndex:i,status:k.status,...k.md5?{stepMd5:k.md5}:{}}),O.push({psIdx:i,dir:S.dir})}else n?f.push(e.outcomes.find(S=>S.rootStepIndex===i)??{rootStepIndex:i,status:"skipped"}):f.push({rootStepIndex:i,status:"skipped"});continue}let w=Ee(a.body.path)?a.body.path:Ke(_e(o.file),a.body.path),T=Y({path:a.body.path,bindings:a.body.bindings,optional:a.optional??!1}),N=Le(J(o.file),P(w)),C=e.resolvedTest.steps.filter(g=>g.trace.some((I,S)=>S<g.trace.length-1&&I.file===o.file&&I.stepIndex===i)&&t.has(g.flatIndex));if(C.length>0){E=!0;let g;if(n)g=e.outcomes.find(I=>I.rootStepIndex===i)??{rootStepIndex:i,status:"passed",refKind:"import",refLabel:a.body.path};else{let I=C.some(S=>fe(S,e.outcomes)==="failed");g={rootStepIndex:i,status:I?"failed":"passed",refKind:"import",refLabel:a.body.path,inlinedCount:C.length}}g.status==="failed"&&(L=!0),g.stepMd5==null&&(g.stepMd5=T),g.helperResultRelPath==null&&(g.helperResultRelPath=N),f.push(g),(!u||u.kind!=="import"||u.status!==g.status||u.md5!==T)&&(K=!0)}else if(u&&u.kind==="import")f.push({rootStepIndex:i,status:u.status,refKind:"import",refLabel:u.importPath,...u.md5?{stepMd5:u.md5}:{},...u.helperResultRelPath?{helperResultRelPath:u.helperResultRelPath}:{}});else if(!n&&D(i)?.row.kind==="import"){let g=D(i).row;f.push({rootStepIndex:i,status:g.status,refKind:"import",refLabel:a.body.path})}else n?f.push(e.outcomes.find(g=>g.rootStepIndex===i)??{rootStepIndex:i,status:"skipped",refKind:"import",refLabel:a.body.path}):f.push({rootStepIndex:i,status:"skipped",refKind:"import",refLabel:a.body.path})}if(!(n||E&&(B||L||R===null||K)))continue;l.push(o.file);let b=z(o.file);pe(y(b,".internal"),{recursive:!0});for(let a of v){let i=y(b,".internal","steps",`${a.stepIndex}-${a.md5.slice(0,8)}`);pe(i,{recursive:!0}),await ie({sessionDir:e.sessionDir,runIndex:a.rec.runIndex,totalRunDirs:a.rec.totalRunDirs,stagingStepDir:i,packTestDir:e.packTestDir})}if(x.length>0){let a=Q(o.file);if($(a))for(let i of ce(a)){let u=parseInt(i.split("-")[0]??"",10);!Number.isNaN(u)&&x.includes(u)&&ue(y(a,i),y(b,".internal","steps",i),{recursive:!0})}}for(let a of O){let i=y(a.dir,".internal","steps");if($(i))for(let u of ce(i))parseInt(u.split("-")[0]??"",10)===a.psIdx&&ue(y(i,u),y(b,".internal","steps",u),{recursive:!0})}let me=f.some(a=>a.status==="failed");if(te({sourcePath:o.file,title:c.title,rootSteps:c.steps,outcomes:f,overallStatus:n?e.overallStatus:me?"failed":"passed",startedISO:e.startedISO,durationS:n?e.durationS:0,sessionId:e.sessionId,outPath:y(b,"Result.md")}),n){let a={};e.commitId&&(a.commit_id=e.commitId),e.tmsIds.testId&&(a.test_id=e.tmsIds.testId),e.tmsIds.testcaseId&&(a.testcase_id=e.tmsIds.testcaseId),e.tmsIds.projectId&&(a.project_id=e.tmsIds.projectId),e.tmsIds.folderId&&(a.folder_id=e.tmsIds.folderId),e.tmsIds.orgId&&(a.org_id=e.tmsIds.orgId),e.tmsIds.sessionName&&(a.session_name=e.tmsIds.sessionName),Ae(y(b,".internal","meta.json"),JSON.stringify(a,null,2)+`
5
- `,"utf8");let i=y(e.sessionDir,"execution.json");if($(i))try{le(i,y(b,".internal","execution.json"))}catch{}if(e.codeExportDir){let u=e.codeExportLanguage??"python",w=e.codeExportFramework??"playwright",T=y(b,`${w}-${u}-code`);try{ae(e.codeExportDir,T)}catch(N){process.stderr.write(`warn: codegen copy failed: ${N.message}
6
- `)}}}else if(o.kind==="test"||o.kind==="module"){let a=q(o.file);if($(a))try{le(a,y(b,".internal","meta.json"))}catch{}}!n&&h.length>0&&f.every(i=>i.status!=="skipped")&&d.push({unitFile:o.file,dirs:h.filter(i=>$(i))})}return{changedUnitFiles:l,legacySweep:d}}function yt(e){for(let t of e)try{Te(t,{recursive:!0,force:!0})}catch{}}function fe(e,t){let s=e.trace[0].stepIndex,l=t.find(o=>o.rootStepIndex===s);if(!l)return"skipped";if(l.status==="passed")return"passed";if(l.status==="skipped")return"skipped";let d=e.trace.slice(1).map(o=>o.stepIndex),r=l.failedSubStepIndex??[],p=Math.min(d.length,r.length);for(let o=0;o<p;o++)if(d[o]!==r[o])return d[o]<r[o]?"passed":"skipped";return d.length===r.length?"failed":d.length<r.length?"passed":"skipped"}export{te as a,et as b,tt as c,st as d,nt as e,rt as f,ae as g,St as h,yt as i};
@@ -1,17 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as m}from"./chunk-VZ7KXRXB.js";import{a as _}from"./chunk-TDPWFYTJ.js";import{b as h}from"./chunk-B2ZGG7WM.js";import{randomUUID as O}from"crypto";import{mkdirSync as D,writeFileSync as b,appendFileSync as A,existsSync as R}from"fs";import{join as u}from"path";import{writeFileSync as I,mkdirSync as j,existsSync as L}from"fs";import{join as p,relative as $}from"path";function f(n){let t=Object.keys(n.frontmatter).length>0?m(n.frontmatter).trimEnd():"",s=["---"];return t&&s.push(t),s.push("---",""),s.push(`# ${n.heading}`,""),n.steps.forEach((i,r)=>{s.push(`## Step ${r+1}`,i,"")}),s.join(`
3
- `)}function v(n,e,t){let s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return n.replace(new RegExp(`\\{\\{\\s*${s}(?=\\s*\\}\\}|[.\\[])`,"g"),`{{${t}.${e}`)}function U(n,e){let t={},s={},i=e;for(let[r,l]of Object.entries(n)){if(r.startsWith("global.")||r.startsWith("secrets.user.")||r.startsWith("environment.")){let o=r.startsWith("secrets.user.");t[r]={value:l.value,secret:o,syntax:`{{${r}}}`,type:o?"secret":r.startsWith("environment.")?"environment":"global"},s[r]=r;continue}if(l.secret){let o=`secrets.user.${r}`;t[o]={value:l.value,secret:!0,syntax:`{{secrets.user.${r}}}`,type:"secret"},s[r]=o,i=v(i,r,"secrets.user")}else{let o=`global.${r}`;t[o]={value:l.value,secret:!1,syntax:`{{global.${r}}}`,type:"global"},s[r]=o,i=v(i,r,"global")}}return{variables:t,objective:i,keyMap:s}}var x=/\{\{\s*(?:global|secrets\.user|environment)\.([^{}]+?)\s*\}\}/g;function c(n){return typeof n!="string"||!n.includes("{{")?n:n.replace(x,"{{$1}}")}function d(n){if(typeof n=="string")return c(n);if(Array.isArray(n))return n.map(e=>d(e));if(n&&typeof n=="object"){let e={};for(let[t,s]of Object.entries(n))e[t]=d(s);return e}return n}var N=new Set(["username","access_key","oauth","profile","project_id","folder_id"]),E=new Set(["model","env"]),g=class{constructor(e){this.opts=e}objectives=[];flushed=!1;lastWrittenPath=null;lastCollisionSuffixed=!1;appendObjective(e){this.objectives.push(e)}flush(){if(this.flushed||(this.flushed=!0,this.objectives.length===0))return;let e=this.opts.getName();if(!e)return;let t=p(this.opts.cwd,".testmuai","tests");try{j(t,{recursive:!0})}catch(a){process.stderr.write(`
4
- \u26A0 Failed to create ${$(this.opts.cwd,t)}/
5
- ${a.message}
6
- Your test recording was NOT saved.
7
-
8
- `);return}let s=p(t,`${e}_test.md`),i=2,r=!1;for(;L(s);)s=p(t,`${e}-${i}_test.md`),i++,r=!0;let l=d(F(this.opts.getResolvedGlobal())),o=f({frontmatter:l,heading:`Session: ${e}`,steps:this.objectives.map(c)});try{I(s,o,"utf8")}catch(a){process.stderr.write(`
9
- \u26A0 Failed to save your test recording.
10
- ${a.message}
11
- Path: ${s}
12
-
13
- `);return}this.lastWrittenPath=s,this.lastCollisionSuffixed=r}};function F(n){let e={};for(let[t,s]of Object.entries(n))N.has(t)||E.has(t)||(e[t]=s);return e}var k=u(h,"sessions"),S=class{sessionId;sessionDir;runs=[];_flows=[];_nextIndex=0;_started=!1;_testId=null;_testcaseId=null;_projectId=null;_orgId=null;_userName=null;_userEmail=null;_uploadStatus="pending";_uploadAttempts=0;_uploadError=null;_firstObjective=null;_firstUrl=null;_auteurVariables={};_screenshotSas=null;_model="";_environment="";_profile=null;_plan=null;_startedAt="";_remoteLogger=null;_earlyLogBuffer=[];_recorder=null;_resolvedGlobal={};_sessionName=null;_recordingEnabled=!0;_stepRunRecords=[];constructor(e){this.sessionId=O();let t=e?.baseDir?u(e.baseDir,"sessions"):k;this.sessionDir=u(t,this.sessionId)}setResolvedGlobal(e){this._resolvedGlobal={...this._resolvedGlobal,...e}}setSessionName(e){this._sessionName=e}get sessionName(){return this._sessionName}setRecordingEnabled(e){this._recordingEnabled=e}get recorder(){return this._recorder}flushRecorder(){try{this._recorder?.flush()}catch(e){process.stderr.write(`[recorder] flush failed: ${e.message}
14
- `)}}start(e){if(!this._started){this._started=!0,this._model=e.model,this._environment=e.environment,this._profile=e.profile,this._startedAt=new Date().toISOString();try{D(this.sessionDir,{recursive:!0}),this._recorder=new g({cwd:process.cwd(),getResolvedGlobal:()=>this._resolvedGlobal,getName:()=>this._sessionName});let t={session_id:this.sessionId,started_at:this._startedAt,model:e.model,environment:e.environment,profile:e.profile,plan:this._plan,objectives:[],runs:[],status:"in_progress"};b(u(this.sessionDir,"session.json"),JSON.stringify(t,null,2)+`
15
- `)}catch{}this._log(`SESSION START session_id=${this.sessionId}`),this._log(`CONFIG model=${e.model} env=${e.environment} profile=${e.profile}`),this._earlyLogBuffer.push({level:"info",event:"SESSION_START",message:"Session started",context:{session_id:this.sessionId}},{level:"info",event:"CONFIG",message:"Session config",context:{model:e.model,environment:e.environment,profile:e.profile}})}}setPlan(e){this._plan=e;let t={level:"info",event:"SESSION_INFO",message:"Session info",context:{session_id:this.sessionId,plan:e??null}};this._remoteLogger?this._remoteLogger.log(t.level,t.event,t.message,t.context):this._earlyLogBuffer.push(t)}get plan(){return this._plan}get apMode(){return _()??"v2"}setRemoteLogger(e){this._remoteLogger=e;for(let t of this._earlyLogBuffer)e.log(t.level,t.event,t.message,t.context);this._earlyLogBuffer=[]}get hasRemoteLogger(){return this._remoteLogger!==null}setAuteurVariables(e){Object.assign(this._auteurVariables,e)}get auteurVariables(){return this._auteurVariables}setScreenshotSas(e){this._screenshotSas=e}get screenshotSas(){return this._screenshotSas}get screenshotBaseUrl(){return this._screenshotSas?`${this._screenshotSas.base_url}/${this._screenshotSas.container}`:""}get startedAt(){return this._startedAt||new Date().toISOString()}log(e,t,s,i){if(t===void 0){this._log(e);let o=e.indexOf(" "),a=o>0?e.slice(0,o):e,y=o>0?e.slice(o+1):"",w=/fail|error/i.test(e)?"error":"info";this._remoteLogger?.log(w,a,y||e);return}let r=e,l=s;this._log(`${t} ${l}`,i),this._remoteLogger?.log(r,t,l,i)}logStep(e,t,s){this._log(`${e} ${t}`,s);let i=this._nextIndex>0?this._nextIndex-1:0;this._remoteLogger?.logStep(i,e,t,s)}logCommand(e){this._log(`COMMAND ${e}`)}logRunStart(e,t,s){this._log(`RUN ${e} START objective="${t.slice(0,100)}" url=${s}`),this._remoteLogger?.setRunIndex(e),this._remoteLogger?.log("info","RUN_START",`Run ${e} started`,{run_index:e,objective:t,url:s})}logRunEnd(e,t,s,i,r){let l=(s??0).toFixed(1),o=(i??"").slice(0,100),a=r==null||r===""||Number.isNaN(Number(r))?null:Number(r);this._log(`RUN ${e} END status=${t} duration=${l}s summary="${o}"`,a!=null?{result_code:a}:void 0),this._remoteLogger?.log("info","RUN_END",`Run ${e} ended`,{run_index:e,status:t,duration:s??0,summary:i??"",result_code:a}),t!=="failed"&&t!=="error"&&this._remoteLogger?.discardSteps(e)}escalateRun(e){this._remoteLogger?.escalate(e)}logChromeLaunch(e,t){this._log(`CHROME LAUNCH port=${e} endpoint=${t}`),this._remoteLogger?.log("info","CHROME_LAUNCH","Chrome launched",{port:e,cdp_endpoint:t})}async finish(e="complete"){this._log(`SESSION END status=${e} total_runs=${this.runs.length}`),this._remoteLogger?.log("info","SESSION_END","Session ended",{status:e,total_runs:this.runs.length}),await this._remoteLogger?.shutdown();let t={session_id:this.sessionId,started_at:this._startedAt,ended_at:new Date().toISOString(),model:this._model,environment:this._environment,profile:this._profile,plan:this._plan,status:e,total_runs:this.runs.length,test_id:this._testId,testcase_id:this._testcaseId,commit_id:this.sessionId,project_id:this._projectId,upload_status:this._uploadStatus,upload_attempts:this._uploadAttempts,last_upload_attempt:this._uploadAttempts>0?new Date().toISOString():null,upload_error:this._uploadError,runs:this.runs.map(s=>({index:s.index,objective:s.objective,status:s.status,summary:s.summary,run_dir:s.run_dir}))};R(this.sessionDir)&&b(u(this.sessionDir,"session.json"),JSON.stringify(t,null,2)+`
16
- `),this.flushRecorder(),this._recorder=null}nextRunIndex(){return this._nextIndex}addRunResult(e,t){this.runs.push(e),this._nextIndex+=t??1,this._recordingEnabled&&this._recorder?.appendObjective(e.objective)}getContext(){return{prior_runs:this.runs.map(e=>({index:e.index,objective:e.objective,summary:e.summary,status:e.status,memory:e.context.memory,variables:e.context.variables,pointer:e.context.pointer}))}}addFlow(e){let t={...e,index:this._flows.length+1};return this._flows.push(t),t}getFlows(){return[...this._flows]}getFlow(e){return this._flows.find(t=>t.index===e)}clearFlows(){this._flows=[]}recordStepRun(e){this._stepRunRecords.push(e)}getStepRunRecords(){return[...this._stepRunRecords]}getRunsAsStepRecords(){return this.runs.map((e,t)=>({testmdStepIndex:t+1,runIndex:e.index,totalRunDirs:e.run_dirs?.length??1}))}snapshot(){return{runsLen:this.runs.length,nextRunIndex:this._nextIndex,stepRunRecordsLen:this._stepRunRecords.length}}rollback(e){this.runs.length=e.runsLen,this._nextIndex=e.nextRunIndex,this._stepRunRecords.length=e.stepRunRecordsLen}setTestId(e){this._testId=e}get testId(){return this._testId}setTestcaseId(e){this._testcaseId=e}get testcaseId(){return this._testcaseId}setProjectId(e){this._projectId=e}setOrgId(e){this._orgId=e}get orgId(){return this._orgId}setUserIdentity(e,t){e&&(this._userName=e),t&&(this._userEmail=t)}get userName(){return this._userName}get userEmail(){return this._userEmail}setFirstRun(e,t){this._firstObjective||(this._firstObjective=e,this._firstUrl=t)}get firstObjective(){return this._firstObjective}get firstUrl(){return this._firstUrl}getRunDirs(){let e=[];for(let t of this.runs)t.run_dirs&&t.run_dirs.length>0?e.push(...t.run_dirs):t.run_dir&&e.push(t.run_dir);return e}getRunObjectives(){let e=[];for(let t of this.runs)t.flow_objectives&&t.flow_objectives.length>0?e.push(...t.flow_objectives):e.push(t.objective);return e}getRunMetadata(){let e=[];for(let t of this.runs)if(t.perFlowMetadata&&t.perFlowMetadata.length>0)e.push(...t.perFlowMetadata);else{let s={resultCode:t.resultCode,reasonCode:t.reasonCode,errorMessage:t.status==="failed"?t.summary??null:null,summary:t.summary,oneLiner:t.oneLiner},i=t.run_dirs?.length??1;for(let r=0;r<i;r++)e.push(s)}return e}setUploadStatus(e,t){this._uploadStatus=e,this._uploadAttempts+=1,this._uploadError=t??null}_log(e,t){if(!(!this._started||!R(this.sessionDir)))try{let s=new Date().toISOString().slice(0,19).replace("T"," "),i=u(this.sessionDir,"tui.log"),r=t&&Object.keys(t).length>0?` ${JSON.stringify(t)}`:"";A(i,`[${s}] ${e}${r}
17
- `)}catch{}}};export{f as a,U as b,S as c};
@@ -1,88 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as wn,b as uo,c as mo,d as Ot,e as nt,f as fo,g as _n,h as yo,i as vo}from"./chunk-LNV7C2YO.js";import{T as Eo}from"./chunk-6LGED4FC.js";import{c as Co}from"./chunk-H6TNBKGR.js";import{a as so}from"./chunk-WD52ZNQY.js";import{a as rt,b as po,c as kn}from"./chunk-BHSHGWBL.js";import{c as go}from"./chunk-S3DAAAE5.js";import{e as ho,g as bo}from"./chunk-SX56MVUO.js";import{c as wo}from"./chunk-IICQ5KRD.js";import{a as bn}from"./chunk-PDXZROJM.js";import{b as So,c as Ro}from"./chunk-53MPG2J3.js";import{c as ko,h as _o,i as Io}from"./chunk-L4M7753M.js";import{A as Gr,B as zr,C as Yr,D as Wr,F as pn,G as Jr,I as Xr,R as eo,X as to,Y as no,g as Kr,i as Tt,v as Hr,w as qr}from"./chunk-CGT4NFQN.js";import{c as Qr,d as Zr}from"./chunk-WILT62DP.js";import{a as gn}from"./chunk-CH273NAE.js";import{b as Ue}from"./chunk-M7DN6FO3.js";import{d as Lt,e as co}from"./chunk-RH6KFHJB.js";import{a as tt,b as X,c as ro,e as Ne,f as Be,g as hn,k as oo,m as ao,n as be,o as yn,q as vn,s as lo}from"./chunk-KN65CUNT.js";import{b as io}from"./chunk-NBXYL2JT.js";import{a as xt,c as Pt,d as fn}from"./chunk-GPIXV7AV.js";import{a as Et,c as Br,d as Mr,e as At}from"./chunk-KOL6ZWOQ.js";import{c as $r,e as Vr}from"./chunk-P7YZ3PU3.js";import{a as un,b as mn}from"./chunk-4PMZ5FCD.js";import{a as Nr}from"./chunk-2YEHV2CX.js";import{i as Dr,m as jr}from"./chunk-6F6YI3ZG.js";import{g as Fr,h as Ur}from"./chunk-SGHP44WS.js";import{a as Ct}from"./chunk-BPMSNGXQ.js";import{j as Pr,l as dn,m as Tr,n as Rt,o as Lr,p as Or}from"./chunk-RSSOJ3L2.js";import{a as Er}from"./chunk-Z7S3IWUX.js";import{d as Ar}from"./chunk-4JOD47QI.js";import{a as ne}from"./chunk-OH2NSBO6.js";import{a as Ee}from"./chunk-DHJSM5DT.js";import{a as St,b as xr}from"./chunk-NLCCBXXV.js";import{a as Z}from"./chunk-RZ4F3BHX.js";import{a as Rr}from"./chunk-E47GFYXA.js";import{a as _t,b as It,i as Cr,j as et,k as ln,l as cn}from"./chunk-B2ZGG7WM.js";import{join as pe,basename as qn}from"path";import{existsSync as Ji,readFileSync as Ds}from"fs";function Ao(e,t){if(process.env.KANE_REPLAY_TRACE==="1")for(let n=0;n<e.steps.length;n++){let r=e.steps[n],o=t[n],s=" ".repeat(r.trace.length-1),i=`step ${r.flatIndex}`;if(o.kind==="replay"){let h=o.replayOnly?` [replay-only @${o.replayOnly}]`:"";process.stderr.write(`[replay-trace] ${s}${i}: REPLAY${h} (would skip; v1 always authors)
3
- `)}else process.stderr.write(`[replay-trace] ${s}${i}: AUTHOR (${o.reason})
4
- `)}}function Ae(e){process.env.KANE_REPLAY_TRACE==="1"&&process.stderr.write(e)}function xo(e,t){let n=e===0?"(none)":`0..${e-1}`,r=e>=t?"(none)":`${e}..${t-1}`;Ae(`[replay-trace] phase: replay ${n}, author ${r}
5
- `)}function Po(e,t){Ae(`[replay-trace] step ${e}: REPLAY ${t==="ok"?"OK":"FAILED"}
6
- `)}function To(e,t,n){Ae(`[replay-trace] shrink ${e}/${t} \u2192 new boundary ${n}
7
- `)}function Lo(e,t){Ae(`[replay-trace] complete-reauthor (${e} shrinks exhausted of ${t})
8
- `)}function In(){Ae(`[replay-trace] force-author (--author) \u2014 walker bypassed; identity kept
9
- `)}function Oo(e){Ae(`[replay-trace] cancelled at step ${e}
10
- `)}function xe(e,t){Ae(`[replay-trace] step ${e}: replay-only @${t} failed \u2014 adaptive heal cannot re-author it; the run fails here
11
- `)}import{join as Do}from"path";function Sn(e){let t=fo(e.decision),n={objective:e.step.objective,model:"v16-alpha",width:e.windowSize.width,height:e.windowSize.height,session_id:e.sessionId,run_index:e.runIndex,mode:"replay",replay:{recording_path:t[0],...t.length>1?{recording_paths:t}:{},step_label:e.step.objective,...e.investigationAsync?{investigation:"async"}:{}},screenshot_dir:e.evidence?Do(e.sessionDir,"scratch",String(e.runIndex)):Do(e.sessionDir,"runs",String(e.runIndex)),run_id:"run",test_id:"test"};return e.forceNavigateUrl&&(n.url=e.forceNavigateUrl),e.chrome.wsEndpoint?n.ws_endpoint=e.chrome.wsEndpoint:e.chrome.cdpEndpoint&&(n.cdp_endpoint=e.chrome.cdpEndpoint),e.auth.basicAuth?(n.username=e.auth.basicAuth.username,n.access_key=e.auth.basicAuth.access_key):e.auth.token&&(n.auth={type:"bearer",token:e.auth.token}),e.auth.resolvedCreds?.org_id&&(n.org_id=String(e.auth.resolvedCreds.org_id)),e.environmentId&&(n.environment_id=e.environmentId),e.variables&&Object.keys(e.variables).length>0&&(n.variables=e.variables),e.sessionContext&&(n.session_context=e.sessionContext),e.device&&(n.device=e.device),e.evidence&&(n.evidence=Tt(e.evidence.packTestDir,e.evidence.ordinalOffset)),n}async function jo(e){let t=e.forceAuthor?0:nt(e.decisions),n=0,r=!1;for(;;){let o=e.session.snapshot(),s=e.accumulator.snapshot(),i=await e.runReplayPhase(t);if(i.cancelled)return r=!0,Oo(i.failedAt??0),{authorBoundary:t,cancelledInPhase:r,shrinkCount:n};if(i.failedAt===null)return{authorBoundary:t,cancelledInPhase:r,shrinkCount:n};let h=e.decisions[i.failedAt],l=h?.kind==="replay"?h.replayOnly:void 0,d=po({failedAt:i.failedAt,shrinkCount:n,hasRetry:e.hasRetry,maxShrinks:e.maxShrinks,failedAtReplayOnly:l});if(d.kind==="fail")return d.replayOnly&&(xe(i.failedAt,d.replayOnly),e.onReplayOnlyFail?.(i.failedAt,d.replayOnly)),{authorBoundary:-1,cancelledInPhase:r,shrinkCount:n};if(e.acquireLockIfNeeded&&!await e.acquireLockIfNeeded())return{authorBoundary:-1,cancelledInPhase:r,shrinkCount:n};if(e.recycleBrowser&&!await e.recycleBrowser())return{authorBoundary:-1,cancelledInPhase:r,shrinkCount:n};if(e.archiveAttempt&&await e.archiveAttempt(i.failedAt),e.session.rollback(o),e.accumulator.rollback(s),d.kind==="complete-reauthor")return Lo(n+1,e.maxShrinks),{authorBoundary:0,cancelledInPhase:r,shrinkCount:n};n++,To(n,rt.maxShrinks,d.newAuthorBoundary),t=d.newAuthorBoundary}}var Js=15e3,Rn=3,Fo=[500,1e3];async function Cn(e){if(process.env.KANE_LOCK_CONFLICT_SIMULATE==="1")return{ok:!1,reason:"concurrent",httpStatus:409,message:"simulated contention (KANE_LOCK_CONFLICT_SIMULATE=1)"};let t=`${e.baseUrl}/test/${encodeURIComponent(e.testId)}/playground`,n=await Dt(t,{from_commit_id:e.fromCommitId,new_commit_id:e.newCommitId},e.auth);return n.ok?{ok:!0,sessionExpiresAt:Y(n.body,"session_expires_at")??""}:{ok:!1,...Qs(n)}}function Qs(e){let t=Y(e.body,"error")??Y(e.body,"code")??"",n=Y(e.body,"message")??Y(e.body,"detail")??e.text??`HTTP ${e.status}`,r;return e.status===0?r="network":e.status===401||e.status===403?r="auth":e.status===409&&t==="PlaygroundBaseCommitMismatch"?r="base_mismatch":e.status===409?r="concurrent":e.status===422?r="disabled":e.status===400&&/no committed/i.test(n)?r="no_commits":e.status===400?r="missing_field":e.status>=500||e.status===408||e.status===429?r="network":r="other",{reason:r,httpStatus:e.status,message:n}}async function No(e){let t=`${e.baseUrl}/test/${encodeURIComponent(e.testId)}/playground/reserve`,n=await Dt(t,void 0,e.auth);return n.ok?{ok:!0,sessionExpiresAt:Y(n.body,"session_expires_at")??""}:{ok:!1,expired:n.status===404,httpStatus:n.status,message:Y(n.body,"message")??Y(n.body,"detail")??n.text??`HTTP ${n.status}`}}async function En(e){let t=`${e.baseUrl}/test/${encodeURIComponent(e.testId)}/commit`,n={commit_id:e.body.commitId,from_commit_id:e.body.fromCommitId,commit_message:e.body.commitMessage,total_steps:e.body.totalSteps};e.body.timeTaken!==void 0&&(n.time_taken=e.body.timeTaken),e.body.objectives!==void 0&&(n.objectives=e.body.objectives),e.body.testInstanceId!==void 0&&(n.test_instance_id=e.body.testInstanceId),e.body.trigger!==void 0&&(n.trigger=e.body.trigger);let r=await Dt(t,n,e.auth);return r.ok?{ok:!0,testId:Y(r.body,"test_id")??e.testId,testcaseId:Y(r.body,"testcase_id")??"",projectId:Y(r.body,"project_id"),isTestCaseDeleted:typeof r.body?.is_test_case_deleted=="boolean"?r.body.is_test_case_deleted:void 0}:{ok:!1,...Zs(r)}}function Zs(e){let t=Y(e.body,"error")??Y(e.body,"code")??"",n=Y(e.body,"message")??Y(e.body,"detail")??e.text??`HTTP ${e.status}`,r;return e.status===0?r="network":e.status===401||e.status===403?r="auth":e.status===409&&t==="PlaygroundBaseCommitMismatch"?r="base_mismatch":e.status===409&&t==="PlaygroundCommitLockMismatch"?r="lock_mismatch":e.status===409?r="expired":e.status===422?r="not_found":e.status>=500||e.status===408||e.status===429?r="network":r="other",{reason:r,httpStatus:e.status,message:n}}async function Pe(e){let t=`${e.baseUrl}/test/${encodeURIComponent(e.testId)}/commit`,n={discard:!0,commit_id:e.body.commitId,from_commit_id:e.body.fromCommitId,commit_message:"(discarded)",total_steps:1},r=await Dt(t,n,e.auth);return r.ok?{ok:!0}:{ok:!1,reason:Y(r.body,"error")??"other",httpStatus:r.status,message:Y(r.body,"message")??Y(r.body,"detail")??r.text??`HTTP ${r.status}`}}async function Dt(e,t,n){let r=null;for(let o=1;o<=Rn;o++){let s=new AbortController,i=setTimeout(()=>s.abort(),Js);try{let h=await Z(e,{method:"POST",headers:{Authorization:St(n.username,n.accessKey),"Content-Type":"application/json",Accept:"application/json"},...t!==void 0?{body:JSON.stringify(t)}:{},signal:s.signal});clearTimeout(i);let l=await h.text(),d=null;if(l)try{d=JSON.parse(l)}catch{}let v=h.status>=500||h.status===408||h.status===429;if(h.ok||!v)return{ok:h.ok,status:h.status,body:d,text:l};if(o<Rn){await Uo(Fo[o-1]??1e3);continue}return{ok:!1,status:h.status,body:d,text:l}}catch(h){if(clearTimeout(i),r=h,o<Rn){await Uo(Fo[o-1]??1e3);continue}}}return{ok:!1,status:0,body:null,text:r?.message??"exhausted retries"}}function Uo(e){return new Promise(t=>setTimeout(t,e))}function Y(e,t){if(typeof e!="object"||e===null)return;let n=e[t];return typeof n=="string"?n:void 0}var Xs=60*1e3,Bo="lock-heartbeat",ke=new Map,ot=null,ei={register:(e,t)=>Rt(e,t),deregister:e=>Lr(e),cleanup:(e,t)=>Or(e,t),remoteLogger:null};function Mo(e){if(e!==void 0){let t=ke.get(e);t!==void 0&&(clearInterval(t),ke.delete(e));return}for(let t of ke.values())clearInterval(t);ke.clear()}function jt(e){if(ke.has(e.testId))return;let t=e.lifecycle??ei,n=setInterval(async()=>{let r=await No({baseUrl:e.baseUrl,testId:e.testId,auth:e.auth});if(!r.ok){let o=r.expired?"session expired":r.message;process.stderr.write(`[lock] heartbeat failed (${e.testId}): ${o}; continuing run
12
- `)}},Xs);ke.set(e.testId,n),ot===null&&(ot=t,t.register(Bo,()=>Mo()))}function fe(e){ke.size!==0&&(Mo(e),ke.size===0&&ot!==null&&(ot.deregister(Bo),ot=null))}import{readFileSync as $o,readdirSync as Vo,existsSync as Te,promises as An}from"fs";import{join as ce}from"path";async function ti(e,t){let n=ce(e,"steps",`${t.ordinal}-${t.id}`),r,o=null,s=[];try{r=JSON.parse(await An.readFile(ce(n,"step.json"),"utf8")),o=r.action_id??null,Array.isArray(r.analyze_action_ids)&&(s=r.analyze_action_ids.filter(i=>typeof i=="string"))}catch{}if(typeof r?.screenshot=="string"&&/^screenshot\.(?:png|jpg)$/i.test(r.screenshot)){let i=r.screenshot;try{return{png:await An.readFile(ce(n,i)),filename:i,actionId:o,analyzeActionIds:s}}catch{}}for(let i of["screenshot.png","screenshot.jpg"])try{return{png:await An.readFile(ce(n,i)),filename:i,actionId:o,analyzeActionIds:s}}catch{}return null}function Ca(){let e=[];return{track:t=>{e.push(t.catch(()=>{}))},settle:async()=>{await Promise.all(e)}}}async function Ko(e,t,n,r){try{let o=await ti(e,t);if(!o){r("warn","SCREENSHOT_SKIP","Pack step folder or screenshot not found",{ordinal:t.ordinal,id:t.id,reason:"pack_step_not_found"});return}let s=new Set;o.actionId&&s.add(o.actionId);for(let i of o.analyzeActionIds)s.add(i);if(s.size===0){r("warn","SCREENSHOT_SKIP","No action_id in step.json",{ordinal:t.ordinal,id:t.id,reason:"no_action_id"});return}for(let i of s)n.enqueue(i,o.png);r("info","SCREENSHOT_ENQUEUED","Screenshot enqueued",{ordinal:t.ordinal,id:t.id,action_id:o.actionId,action_ids:[...s],screenshot:o.filename,size:o.png.length})}catch(o){r("error","SCREENSHOT_DISPATCH_ERROR","Screenshot dispatch error",{ordinal:t.ordinal,id:t.id,error:o instanceof Error?o.message:String(o)})}}function Ho(e,t,n,r,o,s){try{let i=ce(e,"runs",String(t),"run-test");if(!Te(i)){o("warn","SCREENSHOT_SKIP","Runs dir not found",{step_index:n,reason:"runsDir_not_found",path:i});return}let h=i;if(s){let S=ce(i,`child-${s}`);if(!Te(S)){o("warn","SCREENSHOT_SKIP","Child dir not found",{step_index:n,child_id:s,reason:"child_dir_not_found",path:S});return}let R=Vo(S).filter(c=>Te(ce(S,c,"screenshots")));if(R.length===0){o("warn","SCREENSHOT_SKIP","No screenshots dir under child",{step_index:n,child_id:s,reason:"no_child_screenshots_dir"});return}h=ce(S,R[0])}else if(!Te(ce(i,"screenshots"))){let S=Vo(i).filter(R=>Te(ce(i,R,"screenshots")));if(S.length===0){o("warn","SCREENSHOT_SKIP","No screenshots dir found",{step_index:n,reason:"no_screenshots_dir"});return}h=ce(i,S[0])}let l=ce(h,"screenshots",`step_${String(n).padStart(3,"0")}.png`);if(!Te(l)){o("warn","SCREENSHOT_SKIP","Screenshot not found",{step_index:n,child_id:s,reason:"screenshot_not_found",path:l});return}let d=ce(i,"actions.ndjson");if(!Te(d)){o("warn","SCREENSHOT_SKIP","NDJSON not found",{step_index:n,reason:"ndjson_not_found"});return}let v=$o(d,"utf-8").trim().split(`
13
- `),m=v[v.length-1];if(!m){o("warn","SCREENSHOT_SKIP","NDJSON empty",{step_index:n,reason:"ndjson_empty"});return}let k=JSON.parse(m).action_id;if(!k){o("warn","SCREENSHOT_SKIP","No action_id in NDJSON",{step_index:n,reason:"no_action_id"});return}let A=$o(l);r.enqueue(k,A),o("info","SCREENSHOT_ENQUEUED","Screenshot enqueued",{step_index:n,child_id:s,action_id:k,size:A.length})}catch(i){o("error","SCREENSHOT_DISPATCH_ERROR","Screenshot dispatch error",{step_index:n,error:i instanceof Error?i.message:String(i)})}}import{dirname as ni,join as ri}from"path";function qo(e,t,n){let r=e.total_runs??1,o=e.run_dir,s,i;if(r>1&&o){let h=ni(o);s=Array.from({length:r},(l,d)=>ri(h,String(t+d))),n&&n.length===r&&(i=n)}return{allRunDirs:s,flowObjectives:i}}function Go(e,t,n,r){return{index:n,objective:t,summary:e.summary,oneLiner:e.one_liner,status:e.status,resultCode:e.result_code,reasonCode:e.reason_code,perFlowMetadata:e.per_flow_metadata,context:e.context??{memory:{},variables:{},pointer:""},run_dir:e.run_dir,run_dirs:r.allRunDirs,flow_objectives:r.flowObjectives}}var Ft=class{constructor(t){this.resolved=t;this.outcomes=t.rootSteps.map(n=>({rootStepIndex:n.index,status:"skipped"}))}outcomes;skipRoot=null;overallHalted=!1;shouldRunFlatStep(t){if(this.overallHalted)return!1;let n=t.trace[0].stepIndex;return!(this.skipRoot!==null&&n===this.skipRoot)}recordStep(t,n){let r=t.trace[0].stepIndex,o=this.outcomes.find(l=>l.rootStepIndex===r),s=this.resolved.rootSteps.find(l=>l.index===r),i=s.body.kind!=="objective";return i&&(o.refKind="import",o.refLabel=s.body.path,o.inlinedCount=(o.inlinedCount??0)+1,o.duration_s=(o.duration_s??0)+n.duration_s),n.status==="passed"?(i?o.status!=="failed"&&(o.status="passed"):(o.status="passed",o.duration_s=n.duration_s),{continueOverall:!0}):t.optional?(o.softFailures=o.softFailures??[],o.softFailures.push({subStepIndex:t.trace[t.trace.length-1].stepIndex,reason:n.reason}),{continueOverall:!0}):(o.status="failed",o.duration_s=i?o.duration_s:n.duration_s,o.failedSubStepIndex=i?t.trace.slice(1).map(l=>l.stepIndex):void 0,o.reason=n.reason,this.skipRoot=r,s.optional??!1?(o.softFailed=!0,{continueOverall:!0}):(this.overallHalted=!0,{continueOverall:!1}))}snapshotOutcomes(){return[...this.outcomes]}snapshot(){return{outcomes:this.outcomes.map(t=>({...t,softFailures:t.softFailures?[...t.softFailures]:void 0})),skipRoot:this.skipRoot,overallHalted:this.overallHalted}}rollback(t){this.outcomes=t.outcomes.map(n=>({...n,softFailures:n.softFailures?[...n.softFailures]:void 0})),this.skipRoot=t.skipRoot,this.overallHalted=t.overallHalted}finalize(){let t=this.outcomes.some(r=>r.status==="failed"&&!r.softFailed)?"failed":"passed",n=this.outcomes.reduce((r,o)=>r+(o.duration_s??0),0);return{overallStatus:t,outcomes:this.outcomes,totalDurationS:n}}};function xn(e){if(!e)return null;let t=e.trim();return t?/^https?:\/\//i.test(t)?t:`https://${t}`:null}function zo(e){return xn(e.flag)??xn(e.frontmatter)??(e.configDefault&&e.configDefault!==et?xn(e.configDefault):null)}function Yo(e){return e.resolvedUrl!==null?!1:!((!!e.local||!!e.allowMissingUrl)&&!e.isTTY)}import{spawn as oi}from"child_process";async function Wo(e,t,n=100){let r=`${e.replace(/\/+$/,"")}/json/version`,o=await Z(r);if(!o.ok)throw new Error(`CDP /json/version returned ${o.status}`);let s=await o.json();if(!s.webSocketDebuggerUrl)throw new Error("CDP /json/version missing webSocketDebuggerUrl");let i=new Rr(s.webSocketDebuggerUrl);await new Promise((f,C)=>{i.once("open",f),i.once("error",C)});let h=1,l=new Map;i.on("message",f=>{let C;try{C=JSON.parse(f.toString())}catch{return}if(C.id==null)return;let $=l.get(C.id);$&&(l.delete(C.id),C.error?$.reject(new Error(C.error.message)):$.resolve(C.result))});function d(f,C){let $=h++;return new Promise((_e,re)=>{l.set($,{resolve:se=>_e(se),reject:re});let oe={id:$,method:f};C&&(oe.params=C),i.send(JSON.stringify(oe))})}let m=(await d("Target.getTargets")).targetInfos.find(f=>f.type==="page");if(!m)throw i.close(),new Error("CDP: no page target found");let k=(await d("Browser.getWindowForTarget",{targetId:m.targetId})).windowId,A="",S=!1,R=null,c=!1;i.on("close",()=>{c=!0}),i.on("error",()=>{c=!0});async function F(){if(!S){if(c){S=!0;return}try{let C=(await d("Browser.getWindowBounds",{windowId:k})).bounds,$=`${C.left}:${C.top}:${C.width}:${C.height}`;$!==A&&(A=$,t({left:C.left,top:C.top,width:C.width,height:C.height}))}catch{}S||(R=setTimeout(F,n))}}return F(),{stop(){if(!S){S=!0,R&&clearTimeout(R);try{i.close()}catch{}}}}}var si=new Set(["1","true","yes"]);function Pn(e){if(e?.headless)return null;let t=process.env.KANE_CLI_DISABLE_MARKER;if(t!=null&&si.has(t.toLowerCase()))return null;let n=Et();if(!n)return null;let r=[...n.args,"overlay"];e?.text&&r.push(e.text);let o;try{o=oi(n.cmd,r,{cwd:n.cwd,stdio:["pipe","ignore","ignore"],detached:!1,windowsHide:!0})}catch{return null}o.stdin?.on("error",()=>{});let s=!1;o.on("exit",()=>{s=!0}),o.on("error",()=>{s=!0});function i(d){if(!(s||!o.stdin||o.stdin.destroyed))try{o.stdin.write(JSON.stringify(d)+`
14
- `)}catch{}}e?.chromePid&&e.chromePid>0&&i({type:"chrome_pid",pid:e.chromePid});let h=null;e?.cdpEndpoint&&Wo(e.cdpEndpoint,d=>i({type:"bounds",...d})).then(d=>{h=d.stop}).catch(()=>{});let l=!1;return{setRunActive(d){l||i({type:"run_active",active:d})},setStepText(d){if(l)return;let v=d.trim();v&&i({type:"step_text",text:v})},setStepComplete(){l||i({type:"step_complete"})},kill(){if(!l){l=!0,h?.();try{o.stdin?.end()}catch{}try{o.kill("SIGTERM")}catch{}}}}}function Jo(e,t,n){return`${e}/projects/${t}/test-cases/${n}`}function Ut(e,t,n,r){return`${Jo(e,t,n)}/dashboard/share/${r}?type=summary&agentView=true&fqdn=summary-page`}function Qo(e,t,n,r){if(!(!t||!n||!r))return Ut(e,t,n,r)}function Zo(e,t,n){return`${Jo(e,t,n)}/dashboard?type=summary&agentView=true&fqdn=summary-page`}import{mkdtempSync as vi,rmSync as wi}from"fs";import{join as ki}from"path";import{tmpdir as _i}from"os";import{spawn as ts,spawnSync as ii}from"child_process";import{existsSync as Tn}from"fs";import{createConnection as ai}from"net";import{homedir as Me,platform as it}from"os";import{join as $e}from"path";var li=new Set(["1","true","yes"]),Nt=class extends Error{constructor(t){super(t),this.name="ChromeNotFoundError"}};function Wa(e){return e instanceof Nt?e.message:`Chrome failed: ${e instanceof Error?e.message:String(e)}`}var Bt={darwin:["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",$e(Me(),"Applications/Google Chrome.app/Contents/MacOS/Google Chrome"),"/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",$e(Me(),"Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing"),"/Applications/Chromium.app/Contents/MacOS/Chromium"],linux:["/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/usr/bin/google-chrome-for-testing","/usr/local/bin/google-chrome-for-testing",$e(Me(),"chrome-for-testing/chrome-linux64/chrome"),"/usr/bin/chromium","/usr/bin/chromium-browser","/snap/bin/chromium"],win32:["C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe","C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",$e(Me(),"AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),"C:\\chrome-for-testing\\chrome-win64\\chrome.exe",$e(Me(),"AppData\\Local\\chrome-for-testing\\chrome-win64\\chrome.exe"),$e(Me(),"AppData\\Local\\kane-chrome\\chrome.exe")]};function ns(){let e=process.env.KANE_CLI_CHROME_PATH?.trim();return e||void 0}function ci(){let e=ns();if(e)return e;let t=it(),n=Bt[t]??Bt.linux;for(let r of n)if(Tn(r))return r;return t==="win32"?"chrome.exe":"google-chrome"}function di(){let e=ns();if(e)return Tn(e);let t=it();if((Bt[t]??Bt.linux).some(s=>Tn(s)))return!0;let r=t==="win32"?"chrome.exe":"google-chrome",o=t==="win32"?"where":"which";try{return ii(o,[r],{stdio:"ignore"}).status===0}catch{return!1}}function ui(){let e=it();return e==="darwin"?["Google Chrome is required but was not found at any standard path.","","Install via Homebrew (recommended):"," brew install --cask google-chrome","","Or download:"," https://www.google.com/chrome/","","Then re-run your command. Set KANE_CLI_CHROME_PATH=/path/to/chrome","to point at a non-standard install."].join(`
15
- `):e==="linux"?["Google Chrome is required but was not found at /usr/bin/google-chrome.","(amd64 / x86_64 only \u2014 Google does not ship Chrome for Linux ARM.)","","Debian / Ubuntu (any version):"," wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"," sudo apt install -y ./google-chrome-stable_current_amd64.deb","","Fedora / RHEL / AlmaLinux / Rocky:"," sudo dnf install -y https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm","","Then re-run your command. Set KANE_CLI_CHROME_PATH=/path/to/chrome","to point at a non-standard install."].join(`
16
- `):e==="win32"?["Google Chrome is required but was not found in Program Files or AppData.","","Install via winget (Windows 10 1809+):"," winget install --id Google.Chrome -e --silent","","Or download:"," https://www.google.com/chrome/","","Then re-run your command. Set KANE_CLI_CHROME_PATH=C:\\path\\to\\chrome.exe","to point at a non-standard install."].join(`
17
- `):["Google Chrome is required.","Install from https://www.google.com/chrome/","(Note: no official Chrome builds for BSD or Alpine/musl Linux.)"].join(`
18
- `)}function mi(e){let t=it(),n=[`--remote-debugging-port=${e.port}`,`--user-data-dir=${e.userDataDir}`,`--window-size=${e.width},${e.height}`,"--no-first-run","--no-default-browser-check","--disable-blink-features=AutomationControlled","--disable-features=DownloadBubble,DownloadBubbleV2","--safebrowsing-disable-download-protection","--disable-popup-blocking","--disable-notifications","--disable-infobars","--disable-translate","--disable-prompt-on-repost","--disable-background-networking","--disable-client-side-phishing-detection","--disable-default-apps","--disable-hang-monitor","--disable-sync","--metrics-recording-only","--safebrowsing-disable-auto-update","--disable-backgrounding-occluded-windows","--disable-background-timer-throttling","--test-type=webdriver","--allow-pre-commit-input","--enable-logging","--v=1"];return t==="linux"&&(n.push("--no-sandbox"),n.push("--disable-dev-shm-usage"),n.push("--password-store=basic")),t==="darwin"&&n.push("--use-mock-keychain"),e.headless&&n.push("--headless=new"),n}function fi(e){return new Promise(t=>{let n=ai({port:e,host:"127.0.0.1"});n.setTimeout(1e3),n.on("connect",()=>{n.destroy(),t(!0)}),n.on("timeout",()=>{n.destroy(),t(!1)}),n.on("error",()=>{n.destroy(),t(!1)})})}async function pi(){for(let e=ln;e<=cn;e++)if(!await fi(e))return e;throw new Error(`All CDP ports ${ln}-${cn} are in use. Close other Chrome instances.`)}var st=class extends Error{constructor(t){super(t),this.name="CdpReadinessError"}};async function gi(e,t){let n=Date.now(),r=`http://127.0.0.1:${e}/json/version`;for(;Date.now()-n<t;){try{if((await Z(r)).ok)return`http://127.0.0.1:${e}`}catch{}await new Promise(o=>setTimeout(o,200))}throw new st(`Chrome CDP not ready after ${t}ms on port ${e}`)}var hi=3e4,bi=2;function Xo(e,t,n){let r=process.env[e];if(r==null||r.trim()==="")return t;let o=Number(r);return!Number.isInteger(o)||o<n?t:o}function yi(e){return Math.min(500*e,3e3)}function es(e,t){try{if(e.pid)if(t==="win32")ts("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"});else try{process.kill(-e.pid,"SIGKILL")}catch{e.kill("SIGKILL")}else e.kill("SIGKILL")}catch{}}async function rs(e){let t=process.env.KANE_CLI_SKIP_BROWSER_DOWNLOAD;if(!(t!=null&&li.has(t.toLowerCase()))&&!di())throw dn()?.log("error","CHROME_NOT_FOUND","Startup gate: Chrome unavailable at standard system paths",{platform:process.platform,kane_cli_chrome_path:process.env.KANE_CLI_CHROME_PATH??null,skip_browser_download:process.env.KANE_CLI_SKIP_BROWSER_DOWNLOAD??null}),new Nt(ui());let r=it(),o=ci(),s=Xo("KANE_CLI_CDP_TIMEOUT_MS",hi,1),h=Xo("KANE_CLI_CDP_RETRIES",bi,0)+1,l;for(let d=1;d<=h;d++){let v=await pi(),m=mi({port:v,...e});e.startUrl&&m.push(e.startUrl);let b=ts(o,m,{stdio:"ignore",detached:!0});b.unref();try{let k=await new Promise((A,S)=>{b.on("error",R=>{S(new Error(`Failed to launch Chrome: ${R.message}. Is Chrome installed at ${o}?`))}),b.on("close",R=>{R!==null&&R!==0&&S(new st(`Chrome exited during startup with code ${R}`))}),gi(v,s).then(A,S)});return{process:b,port:v,cdpEndpoint:k,kill(){es(b,r)}}}catch(k){if(l=k,!(k instanceof st))throw k;es(b,r),dn()?.log("warn","CHROME_CDP_LAUNCH_RETRY",`Chrome CDP launch attempt ${d}/${h} failed`,{attempt:d,max_attempts:h,port:v,timeout_ms:s,headless:e.headless??!1,error:k.message}),d<h&&await new Promise(A=>setTimeout(A,yi(d)))}}throw l??new Error("Chrome launch failed after retries")}async function Ln(e){if(e.cft)return{instance:null,tempDir:null};if(e.wsEndpoint)return{wsEndpoint:e.wsEndpoint,instance:null,tempDir:null};if(e.cdpEndpoint){let o=await Z(`${e.cdpEndpoint}/json/version`);if(!o.ok)throw new Error(`CDP endpoint not reachable: ${e.cdpEndpoint} (${o.status})`);return{cdpEndpoint:e.cdpEndpoint,instance:null,tempDir:null}}let t,n=null;if(e.config.chrome_profile_path)t=e.config.chrome_profile_path.replace("~",process.env.HOME??"~");else{n=vi(ki(_i(),"kane-clean-")),t=n;let o=n;Rt("tempDir",()=>{try{wi(o,{recursive:!0,force:!0})}catch{}})}let r=await rs({userDataDir:t,width:e.config.window_size.width,height:e.config.window_size.height,startUrl:e.startUrl,headless:e.headless});return{cdpEndpoint:r.cdpEndpoint,instance:r,tempDir:n}}async function os(e,t){if(e==="device"){let{device:n,appRef:r,appId:o}=await t.prepareDevice();return{kind:"device",device:n,...r?{appRef:r}:{},...o?{appId:o}:{}}}return{kind:"web",chrome:await t.prepareWeb()}}function sl(e,t={}){if(e.kind==="device"){let n=e.device.target_kind;return n==="emulator"||n==="simulator"?n:void 0}if(e.chrome.instance)return"chrome";if(t.cdpEndpoint)return"cdp";if(t.wsEndpoint)return"ws"}function il(e,t){if(!(e.kind!=="device"||e.device.target_kind!=="simulator"))return t?Er(t):void 0}function al(e){if(e.kind!=="device")return;let t=e.device.target_kind;if(!(t!=="emulator"&&t!=="simulator"))return e.appRef??""}function On(e){let t={objective:e.objective,model:e.model,width:e.windowSize.width,height:e.windowSize.height,session_id:e.sessionId,run_index:e.runIndex,max_steps:e.maxSteps??30,headless:e.headless??!1};return e.conditions&&e.conditions.length>0&&(t.conditions=[...e.conditions]),e.url&&(t.url=e.url),e.requireStartUrl&&(t.require_start_url=!0),e.chrome.wsEndpoint?t.ws_endpoint=e.chrome.wsEndpoint:e.chrome.cdpEndpoint&&(t.cdp_endpoint=e.chrome.cdpEndpoint),e.auth.basicAuth?(t.username=e.auth.basicAuth.username,t.access_key=e.auth.basicAuth.access_key):e.auth.token&&(t.auth={type:"bearer",token:e.auth.token}),e.auth.resolvedCreds?.org_id&&(t.org_id=String(e.auth.resolvedCreds.org_id)),e.disableAskUser&&(t.disable_ask_user=!0),e.enableTaskSkills&&(t.enable_task_skills=!0),e.networkWs&&(t.network_ws=!0),e.networkSse&&(t.network_sse=!0),(e.bugDetection==="stop"||e.bugDetection==="continue")&&(t.bug_detection=e.bugDetection),e.variables&&Object.keys(e.variables).length>0&&(t.variables=e.variables),e.globalContext&&(t.global_context=e.globalContext),e.localContext&&(t.local_context=e.localContext),e.sessionContext&&(t.session_context=e.sessionContext),e.device&&(t.device=e.device),e.evidence&&(t.evidence=Tt(e.evidence.packTestDir,e.evidence.ordinalOffset)),t}import{existsSync as Ii,readFileSync as Si}from"fs";import{join as Ri}from"path";var Mt={max_retries:5,settle_ms:500,on_exhaust:"fail"},Ve=class{constructor(t,n,r){this.steps=t;this.decisions=n;this.deps=r;for(let o=0;o<t.length;o++){let s=t[o];if(s.controlFlow!=="if"&&s.controlFlow!=="while")continue;let i=s.block,h=t.map((b,k)=>[b,k]).filter(([b])=>b.block?.id===i.id&&b.block.depth===i.depth),l=h.find(([b])=>b.block.branch===-1)[1],d=h.filter(([b])=>b.controlFlow!==void 0&&b.block.branch!==-1).map(([,b])=>b),v=d.filter(b=>t[b].controlFlow!=="else").map(b=>t[b].objective),m={kind:s.controlFlow,opener:o,closer:l,markers:d,conditions:v,hasElse:t[d[d.length-1]].controlFlow==="else"};this.blocks.set(o,m),this.closers.set(l,m)}}blocks=new Map;closers=new Map;skip=new Set;attempts=new Map;taken=new Map;whileRuns=new Map;static hasBlocks(t){return t.some(n=>n.block!==void 0)}reset(){this.skip.clear(),this.attempts.clear(),this.taken.clear(),this.whileRuns.clear()}outcomes(){let t={};for(let[r,o]of this.taken)t[this.steps[r].flatIndex]=o;let n={};for(let[r,o]of this.whileRuns)n[this.steps[r].flatIndex]={...o};return{taken:t,whileRuns:n}}range(t,n){let r=t.markers[n]+1,o=n+1<t.markers.length?t.markers[n+1]:t.closer,s=[];for(let i=r;i<o;i++)s.push(i);return s}skipBranch(t,n){for(let r of this.range(t,n))this.skip.add(r)}unskipBody(t){for(let n=t.opener+1;n<t.closer;n++)this.skip.delete(n)}async judge(t){let n=await this.deps.evaluate(t),r=n.findIndex(o=>o==null);return r!==-1||n.length<t.length?{fail:`condition could not be judged: ${t[r===-1?n.length:r]}`}:n}async before(t){if(this.skip.has(t))return{action:"skip"};let r=this.steps[t].controlFlow;if(r==="if"){let s=this.blocks.get(t),i=await this.judge(s.conditions);if("fail"in i)return{action:"fail",reason:i.fail};let h=i.findIndex(l=>l===!0);h===-1&&s.hasElse&&(h=s.markers.length-1),this.taken.set(t,h);for(let l=0;l<s.markers.length;l++)l!==h&&this.skipBranch(s,l);return{action:"structural"}}if(r==="while"){let s=this.blocks.get(t);this.attempts.set(t,0);let i=await this.judge(s.conditions);return"fail"in i?{action:"fail",reason:i.fail}:(this.whileRuns.set(t,{iterations:i[0]?1:0,condition_met:!i[0]}),i[0]||this.skipBranch(s,0),{action:"structural"})}if(r==="end-while"){let s=this.closers.get(t);if(!(s.opener+1===s.closer)&&this.skip.has(s.opener+1))return{action:"structural"};let h=this.deps.whileConfig(s.opener),l=(this.attempts.get(s.opener)??0)+1;this.attempts.set(s.opener,l);let d=this.whileRuns.get(s.opener)??{iterations:l,condition_met:!1};if(d.iterations=l,this.whileRuns.set(s.opener,d),l>=h.max_retries)return h.on_exhaust==="fail"?{action:"fail",reason:`while exhausted after ${l} iteration(s): ${s.conditions[0]}`}:{action:"structural"};await this.deps.sleep(h.settle_ms);let v=await this.judge(s.conditions);return"fail"in v?{action:"fail",reason:v.fail}:v[0]?(this.unskipBody(s),d.iterations=l+1,{action:"jump",to:s.opener+1}):(d.condition_met=!0,{action:"structural"})}if(r!==void 0)return{action:"structural"};let o=this.decisions[t];return o?.kind==="replay"&&o.unrecorded?{action:"author"}:{action:"run"}}};function Dn(e){try{let t=ao(e),n=oo(e.owningFile,e.trace[e.trace.length-1].stepIndex,t.slice(0,8)),r=Ri(n,"flows","0","actions.ndjson");if(!Ii(r))return null;let o=Si(r,"utf8").split(`
19
- `).find(s=>s.trim().length>0);return o?JSON.parse(o):null}catch{return null}}function $t(e){let t=Dn(e);if(!t||t.action_type!=="while")return{...Mt};let n=t.action_params??{};return{max_retries:typeof n.max_retries=="number"&&n.max_retries>0?n.max_retries:Mt.max_retries,settle_ms:typeof n.settle_ms=="number"&&n.settle_ms>=0?n.settle_ms:Mt.settle_ms,on_exhaust:typeof n.on_exhaust=="string"&&n.on_exhaust?n.on_exhaust:Mt.on_exhaust}}import{readdirSync as Ci,readFileSync as is,existsSync as as}from"fs";import{join as Ei}from"path";function ss(e,t){if(!as(e))return{};let n={},r;try{r=Ci(e).filter(o=>o.endsWith(".json")).sort()}catch{return{}}for(let o of r)try{let s=is(Ei(e,o),"utf-8"),i=JSON.parse(s);if(i&&typeof i=="object"){for(let[h,l]of Object.entries(i))if(l&&typeof l=="object"&&"value"in l){let d=l;n[h]={value:typeof d.value=="number"?String(d.value):d.value,secret:d.secret??!1,syntax:d.syntax??`{{${h}}}`,...typeof d.description=="string"?{description:d.description}:{}}}}}catch{t?t("warn","VARIABLE_PARSE_FAILED","Skipping invalid variables file",{file:o}):process.stderr.write(`[variables] Warning: skipping invalid variables file: ${o}
20
- `)}return n}function ls(e){if(!as(e))throw new Error(`Variables file not found: ${e}`);let t=is(e,"utf-8"),n=JSON.parse(t),r={};if(n&&typeof n=="object"){for(let[o,s]of Object.entries(n))if(s&&typeof s=="object"&&"value"in s){let i=s;r[o]={value:typeof i.value=="number"?String(i.value):i.value,secret:i.secret??!1,syntax:i.syntax??`{{${o}}}`,...typeof i.description=="string"?{description:i.description}:{}}}}return r}function cs(e){let t;try{t=JSON.parse(e)}catch{throw new Error("Invalid --variables JSON")}let n={};if(t&&typeof t=="object"){for(let[r,o]of Object.entries(t))if(o&&typeof o=="object"&&"value"in o){let s=o;n[r]={value:typeof s.value=="number"?String(s.value):s.value,secret:s.secret??!1,syntax:s.syntax??`{{${r}}}`,...typeof s.description=="string"?{description:s.description}:{}}}}return n}function ds(e,t,n){let r=ss(e,n),o=ss(t,n);return{...r,...o}}var Ke=class{constructor(t){this.baseUrl=t}async pushSecret(t){let n=St(t.username,t.accessKey),r=await Z(`${this.baseUrl}/logistics/v1.0/secrets/create`,{method:"PUT",headers:{Authorization:n,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({secretKey:t.secretKey,secretValue:t.secretValue,orgId:t.orgId,username:t.username,scope:"user",type:"user",accessKey:t.accessKey})});if(!r.ok)throw new Error(`Push secret failed: ${r.status} ${await r.text()}`)}static extractVariableKeys(t){let n=t.matchAll(/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g),r=new Set;for(let o of n)r.add(o[1]);return[...r]}};var He=class extends xr{constructor(t,n,r){super(t,{username:n,accessKey:r})}async upsertVariable(t){let n=t.environmentId??0,r=await Z(`${this.baseUrl}/v1/variables`,{method:"POST",headers:this.headers(),body:JSON.stringify({name:t.name,value:String(t.value),type:"variable",value_type:"string",is_persist:t.isPersist??!1,environment_id:n})});if(r.ok){let l=await r.json().catch(()=>({}));if(l.type==="Success"&&l.id!=null)return{id:Number(l.id)||0}}let o=await Z(`${this.baseUrl}/v1/variables/${encodeURIComponent(t.name)}?environment_id=${n}`,{method:"GET",headers:this.headers()});if(!o.ok)return{id:0};let i=(await o.json().catch(()=>({}))).data?.id;return i==null?{id:0}:(await Z(`${this.baseUrl}/v1/variables/${i}`,{method:"PUT",headers:this.headers(),body:JSON.stringify({value:String(t.value),value_type:"string"})})).ok?{id:Number(i)||0}:{id:0}}};function us(e,t){if(Object.keys(e).length===0)return{};let n={};for(let[r,o]of Object.entries(e)){let s=o.syntax??`{{${r}}}`;xi(t,s)&&(n[r]=o)}return n}function Ai(e){let t=e.trim();return t.startsWith("{{")&&t.endsWith("}}")?t.slice(2,-2).trim():t.startsWith("${")&&t.endsWith("}")?t.slice(2,-1).trim():t}function xi(e,t){if(!t||!e)return!1;if(e.includes(t))return!0;let n=Ai(t);if(!n)return!1;let r=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`(?:\\{\\{|\\$\\{)\\s*${r}(?=\\s*\\}|[.\\[])`).test(e)}function ms(e){let t=ds(e.globalDir,e.localDir,e.onLoadError),n=e.file?ls(e.file):{},r=e.inline?cs(e.inline):{},o={...t,...n,...r},s=Object.keys(o).length>0,{variables:i,objective:h}=s?Ue(o,e.objective):{variables:{},objective:e.objective},l=Object.entries(o).filter(([,v])=>v.secret),d=Object.entries(o).filter(([,v])=>!v.secret);return{raw:o,auteur:i,auteurObjective:h,secretEntries:l,nonSecretEntries:d}}async function fs(e){if(e.localMode)return{};let t=ne(e.env);if(e.variables.secretEntries.length>0){let r=new Ke(t.secretsBaseUrl);for(let[o,s]of e.variables.secretEntries)r.pushSecret({secretKey:o,secretValue:s.value,username:e.auth.username,accessKey:e.auth.access_key,orgId:e.orgId}).then(()=>e.log("info","SECRET_PUSH_OK","Secret pushed",{key:o})).catch(i=>e.log("error","SECRET_PUSH_FAILED","Secret push failed",{key:o,error:String(i)}))}let n={};if(e.variables.nonSecretEntries.length>0){let r=new He(t.tmsBaseUrl,e.auth.username,e.auth.access_key);for(let[o,s]of e.variables.nonSecretEntries)try{let i=await r.upsertVariable({name:o,value:s.value});n[o]=i.id,e.log("info","VAR_PUSH_OK","Variable pushed",{name:o,id:i.id})}catch(i){e.log("error","VAR_PUSH_FAILED","Variable push failed",{name:o,error:String(i)})}}return n}import{readFileSync as Pi,existsSync as Ti}from"fs";function jn(e){if(!Ti(e))return null;try{return Pi(e,"utf-8").trim()||null}catch{return null}}var Li=()=>{};async function ps(e,t,n){let r=t.log??Li,o=e.session.testId??null,s=null,i=null,h=null;if(!n.localMode&&t.performUpload)try{s=await t.performUpload(),s?.success&&(s.testId&&(o=s.testId),s.testcaseId&&e.session.setTestcaseId(s.testcaseId))}catch(l){r("error","FINALIZE_UPLOAD_ERROR","Upload pipeline threw",{error:String(l)})}if(t.renderFeedbackPrompt)try{i=await t.renderFeedbackPrompt(),i&&o&&t.submitFeedback&&t.submitFeedback(o,i).catch(l=>{r("error","FINALIZE_FEEDBACK_SUBMIT_ERROR","Feedback submit failed",{error:String(l)})})}catch(l){r("error","FINALIZE_FEEDBACK_RENDER_ERROR","Feedback prompt threw",{error:String(l)})}if(e.session.flushRecorder(),n.skipLocalWrites)r("info","FINALIZE_SKIP_LOCAL_WRITES","Skipping local writes (testmd flow handles via staging)");else if(n.sourcePath&&n.rootSteps&&n.outcomes){try{h=wn({sourcePath:n.sourcePath,title:n.title,rootSteps:n.rootSteps,outcomes:n.outcomes,overallStatus:n.overallStatus,startedISO:n.startedISO,durationS:n.durationS,sessionId:e.session.sessionId})}catch(l){r("error","FINALIZE_RESULT_MD_ERROR","_Result.md write failed",{error:String(l)})}try{yn({sourcePath:n.sourcePath,commitId:e.session.sessionId,testId:o??void 0,testcaseId:e.session.testcaseId??void 0,projectId:e.tuiConfig.project_id??void 0,folderId:e.tuiConfig.folder_id??void 0,orgId:e.session.orgId??void 0,sessionName:e.session.sessionName??tt(n.sourcePath),plan:e.session.plan??void 0})}catch(l){r("error","FINALIZE_META_WRITE_ERROR","meta.json write failed",{error:String(l)})}if(s?.codeExportDir)try{let l=bn(e.tuiConfig.code_export?.language??"python",n.mobile);_n(s.codeExportDir,hn(n.sourcePath,l.framework,l.language))}catch(l){r("error","FINALIZE_CODE_COPY_ERROR","code-export copy failed",{error:String(l)})}}else if(e.session.recorder?.lastWrittenPath){let l=e.session.recorder.lastWrittenPath,d=e.session.getFlows(),v=d.map((k,A)=>({index:A+1,heading:`Step ${A+1}`,verifies:[],headingLine:0,body:{kind:"objective",text:k.objective}})),m=d.map((k,A)=>({rootStepIndex:A+1,status:k.status==="passed"?"passed":k.status==="failed"?"failed":"skipped",duration_s:k.duration,reason:k.reason})),b=m.some(k=>k.status==="failed")?"failed":"passed";try{h=wn({sourcePath:l,title:e.session.sessionName??"Session",rootSteps:v,outcomes:m,overallStatus:b,startedISO:e.session.startedAt,durationS:m.reduce((k,A)=>k+(A.duration_s??0),0),sessionId:e.session.sessionId})}catch(k){r("error","FINALIZE_TUI_RESULT_MD_ERROR","TUI _Result.md write failed",{error:String(k)})}try{yn({sourcePath:l,commitId:e.session.sessionId,testId:o??void 0,testcaseId:e.session.testcaseId??void 0,sessionName:e.session.sessionName??void 0,projectId:e.tuiConfig.project_id??void 0,folderId:e.tuiConfig.folder_id??void 0,plan:e.session.plan??void 0})}catch(k){r("error","FINALIZE_TUI_META_WRITE_ERROR","TUI meta.json write failed",{error:String(k)})}if(s?.codeExportDir)try{let k=bn(e.tuiConfig.code_export?.language??"python",n.mobile);_n(s.codeExportDir,hn(l,k.framework,k.language))}catch(k){r("error","FINALIZE_TUI_CODE_COPY_ERROR","TUI code-export copy failed",{error:String(k)})}e.session.recorder.lastCollisionSuffixed&&process.stderr.write(`Saved to ${l} (renamed: ${e.session.sessionName}_test.md already existed)
21
- `)}try{t.runCleanup?.()}catch(l){r("error","FINALIZE_CLEANUP_ERROR","Cleanup hook threw",{error:String(l)})}try{await e.session.finish("complete")}catch(l){r("error","FINALIZE_SESSION_FINISH_ERROR","session.finish threw",{error:String(l)})}return{uploadResult:s,feedbackChoice:i,resultMdPath:h}}import{readFileSync as Un,writeFileSync as Nn,existsSync as ws}from"fs";function gs(e,t,n){if(n.forceAuthor)return"re-recorded from scratch";if(n.retryTriggered)return"re-recorded after retry";if(t.length>0&&t.every(i=>i.kind==="author"&&i.reason==="no-result-md"))return"initial recording";if(t.length>0&&t.every(i=>i.kind==="replay"))return n.wantsPush?"re-recorded (no source changes)":"no changes";let r=[];for(let i=0;i<t.length;i++){let h=t[i];if(!h||h.kind!=="author"||h.reason==="downstream-of-divergence"||h.reason==="no-result-md")continue;let l=Oi(e,e.steps[i]);switch(h.reason){case"structure-mismatch":r.push(`added/removed: ${l}`);break;case"md5-mismatch":r.push(`modified: ${l}`);break;case"missing-recording":r.push(`re-recorded: ${l}`);break;case"recorded-failed":r.push(`re-authored after failure: ${l}`);break}}if(r.length===0)return"automated commit";let o=r.filter((i,h)=>h===0||r[h-1]!==i),s=o.slice(0,3).join("; ");return o.length>3?`${s}; +${o.length-3} more`:s}function Oi(e,t){if(!t)return"unknown step";let n=t.trace[0]?.stepIndex;if(n==null)return"unknown step";let o=e.rootSteps[n-1]?.heading?.trim()??"";return t.trace.length>1?o?`imported step in "${o}"`:`imported step ${n}`:o||`step ${n}`}import{existsSync as Di}from"fs";function ji(e){return!!e&&typeof e.module_id=="string"&&e.module_id.trim()!==""}function Fn(e){return`warn: ${e}: *_module.md without a cloud meta.json module_id \u2014 it ran as a module, but its steps upload as plain blocks (no module_block)`}function hs(e,t,n={}){let r=n.tapePresent??(b=>Di(ro(b))),o=n.readMeta??(b=>be(b)),s=n.onMissingIdentity??(b=>{process.stderr.write(`${Fn(b)}
22
- `)}),i=new Set,h=new Set(e.unitFiles.filter(b=>b.kind==="module").map(b=>b.file)),l=new Map,d=[];for(let b of e.steps){let k=b.flatIndex,A,S="";for(let R=0;R+1<b.trace.length;R++){let c=b.trace[R],F=b.trace[R+1].file;if(S=S?`${S}>${c.file}#${c.stepIndex}`:`${c.file}#${c.stepIndex}`,!h.has(F))continue;let f=l.get(S);if(!f){let C=o(F);if(!ji(C)){i.has(F)||(i.add(F),s(F));continue}f={key:S,file:F,meta:C,flatFrom:k,flatTo:k,dirty:!1,children:[]},l.set(S,f),(A?A.children:d).push(f)}f.flatFrom=Math.min(f.flatFrom,k),f.flatTo=Math.max(f.flatTo,k),A=f}}let v=b=>{for(let k=b.flatFrom;k<=b.flatTo;k++)if(t.has(k))return!0;return!1},m=b=>{for(let k of b)k.dirty=r(k.file)&&v(k),m(k.children)};return m(d),d}function bs(e){let t={};for(let n of e)for(let r=0;r<Math.max(1,n.totalRunDirs);r++)t[n.runIndex+r]=n.testmdStepIndex;return t}function vs(e,t){let n=e.steps,r=[],o=[];for(let s=0;s<n.length;s++){let i=n[s],h=i.controlFlow;if(h==="if"||h==="while"){let l=Fi(i,h,t);(o.length?o[o.length-1].children:r).push(l),o.push(l);continue}if(h==="elif"||h==="else"){let l=o[o.length-1];ys(l,i.flatIndex-1),l.branches.push({branch_type:h,condition:h==="else"?"":i.objective,flatFrom:i.flatIndex+1,flatTo:i.flatIndex,taken:!1});continue}if(h==="end-if"||h==="end-while"){let l=o.pop();ys(l,i.flatIndex-1),l.flatTo=i.flatIndex,Ui(l,t);continue}}return r}function Fi(e,t,n){let r=Dn(e),o=r?.action_params??{},s=typeof o.block_id=="string"?o.block_id:"",i=r?.action_instruction&&r.action_instruction.trim()||e.objective,h={kind:t,blockId:s,instruction:i,flatFrom:e.flatIndex,flatTo:e.flatIndex,branches:[{branch_type:"if",condition:e.objective,flatFrom:e.flatIndex+1,flatTo:e.flatIndex,taken:!1}],children:[]};if(t==="while"){let l=$t(e),d=n?.whileRuns[e.flatIndex];h.whileCfg={...l,iterations:d?.iterations??0,condition_met:d?.condition_met??!1}}return h}function ys(e,t){let n=e.branches[e.branches.length-1];n.flatTo=t}function Ui(e,t){if(e.kind==="while"){e.branches[0].taken=(e.whileCfg?.iterations??0)>0;return}let n=t?.taken[e.flatFrom];typeof n=="number"&&n>=0&&n<e.branches.length&&(e.branches[n].taken=!0)}function Ni(e,t){if(!(!e.shouldReplaceLocalOutput||!e.resolvedTest||!e.sourcePath||!e.stepRunRecords||!e.outcomes||!e.overallStatus))return async()=>{let{changedUnitFiles:n,legacySweep:r}=await yo({resolvedTest:e.resolvedTest,sessionDir:e.session.sessionDir,stepRunRecords:e.stepRunRecords,outcomes:e.outcomes,overallStatus:e.overallStatus,startedISO:e.startedISO??new Date().toISOString(),durationS:e.durationS??0,sessionId:e.session.sessionId,commitId:e.fromCommitId??"",tmsIds:e.tmsIds??{},codeExportDir:e.codeExportDir,packTestDir:e.evidence?.packTestDir??e.evidenceRead?.packTestDir,authoredFlatIdx:new Set(e.authoredFlatIdx??[])});t.files=n;for(let o of n){let s=X(o);if(ws(`${s}.staging`)){so(s);let i=r.find(h=>h.unitFile===o);i&&vo(i.dirs)}}}}function Bi(e,t){if(!e.shouldCommit||e.isFirstRun||!e.tmsBaseUrl||!e.testId||!e.fromCommitId||!e.newCommitId||!e.basicAuth||!e.resolvedTest||!e.decisions)return;let n=(o,s)=>Lt({sourcePath:o,testId:s,sessionId:e.session.sessionId,commitId:e.newCommitId,identityOverride:{commit_id:e.newCommitId},controller:new Ee(ne(e.env).controllerBaseUrl,{username:e.basicAuth.username,accessKey:e.basicAuth.access_key})}),r=(o,s)=>e.onAgentEvent?.({type:"test_md_bundle_sync",status:s.ok?"ok":"failed",commit_id:e.newCommitId,path:o,...s.ok?{bytes:s.bytes}:{stage:s.stage}});return async()=>{let o;if(e.testmdSync===!1)e.log?.("info","BUNDLE_SYNC_SKIPPED","testmd bundle sync skipped",{reason:"flag",commit_id:e.newCommitId});else{if(!e.sourcePath){let m="bundle sync requires a source path";return e.log?.("warn","BUNDLE_SYNC_FAILED","testmd bundle sync failed",{commit_id:e.newCommitId,stage:"collect",error:m}),{ok:!1,reason:"bundle_sync_failed",message:m}}if(o=await n(e.sourcePath,e.testId),!o.ok)return e.log?.("warn","BUNDLE_SYNC_FAILED","testmd bundle sync failed",{commit_id:e.newCommitId,stage:o.stage,error:o.error}),r(e.sourcePath,o),process.stderr.write(` \u26A0 bundle sync failed (${o.stage}): ${o.error} \u2014 commit not attempted; the local tape is kept, run again with --push once fixed
23
- `),{ok:!1,reason:"bundle_sync_failed",message:o.error}}let s=gs(e.resolvedTest,e.decisions,{wantsPush:e.wantsPush??!1,retryTriggered:e.retryTriggered??!1,forceAuthor:e.forceAuthor??!1}),i=e.resolvedTest.steps.map(m=>m.objective).filter(m=>typeof m=="string"&&m.length>0).slice(0,50),h=e.forceAuthor?"always_reauthor":e.retryTriggered?"adaptive_heal":void 0,l=Kr().testInstanceId,d={...l?{testInstanceId:l}:{},...h?{trigger:h}:{}},v=await En({baseUrl:`${e.tmsBaseUrl}/kane-cli/v1`,testId:e.testId,body:{commitId:e.newCommitId,fromCommitId:e.fromCommitId,commitMessage:s,totalSteps:e.resolvedTest.steps.length,timeTaken:Math.round(e.durationS??0),objectives:i,...d},auth:{username:e.basicAuth.username,accessKey:e.basicAuth.access_key}});if(v.ok&&e.commitBox&&(e.commitBox.committed=!0,e.commitBox.testcaseId=v.testcaseId||void 0),v.ok&&o?.ok&&e.sourcePath&&(e.log?.("info","BUNDLE_SYNC_OK","testmd bundle pushed",{commit_id:e.newCommitId,bytes:o.bytes}),r(e.sourcePath,o)),v.ok&&e.sourcePath){let m=Ne(e.sourcePath);try{let b=JSON.parse(Un(m,"utf8"));b.commit_id=e.newCommitId,Nn(m,JSON.stringify(b,null,2)+`
24
- `,"utf8")}catch(b){process.stderr.write(`warn: failed to update meta.json commit_id: ${b.message}
25
- `)}}if(v.ok)for(let m of e.unitLocks??[]){if(!t.files.includes(m.file)){await Pe({baseUrl:`${e.tmsBaseUrl}/kane-cli/v1`,testId:m.testId,body:{commitId:e.newCommitId,fromCommitId:m.fromCommitId},auth:{username:e.basicAuth.username,accessKey:e.basicAuth.access_key}}),fe(m.testId);continue}let b;if(e.testmdSync!==!1&&(b=await n(m.file,m.testId),!b.ok)){e.log?.("warn","BUNDLE_SYNC_FAILED","unit bundle sync failed",{commit_id:e.newCommitId,path:m.file,stage:b.stage,error:b.error}),r(m.file,b),process.stderr.write(`warn: unit bundle sync failed (${m.file}): ${b.stage}: ${b.error} \u2014 unit not committed
26
- `),await Pe({baseUrl:`${e.tmsBaseUrl}/kane-cli/v1`,testId:m.testId,body:{commitId:e.newCommitId,fromCommitId:m.fromCommitId},auth:{username:e.basicAuth.username,accessKey:e.basicAuth.access_key}}),fe(m.testId);continue}let k=e.resolvedTest.steps.filter(R=>R.owningFile===m.file),A=k.map(R=>R.objective).filter(R=>typeof R=="string"&&R.length>0).slice(0,50),S=await En({baseUrl:`${e.tmsBaseUrl}/kane-cli/v1`,testId:m.testId,body:{commitId:e.newCommitId,fromCommitId:m.fromCommitId,commitMessage:`healed via importer ${e.sourcePath??""}`,totalSteps:k.length,timeTaken:0,objectives:A,...d},auth:{username:e.basicAuth.username,accessKey:e.basicAuth.access_key}});if(S.ok){let R=Ne(m.file);try{let c=JSON.parse(Un(R,"utf8"));c.commit_id=e.newCommitId,Nn(R,JSON.stringify(c,null,2)+`
27
- `,"utf8")}catch(c){process.stderr.write(`warn: failed to update unit meta commit_id (${m.file}): ${c.message}
28
- `)}b?.ok&&(e.log?.("info","BUNDLE_SYNC_OK","unit bundle pushed",{commit_id:e.newCommitId,path:m.file,bytes:b.bytes}),r(m.file,b))}else process.stderr.write(`warn: unit self-commit failed (${m.file}): ${S.reason??""} ${S.message??""} \u2014 unit lock released
29
- `),e.log?.("warn","UNIT_COMMIT_FAILED","Imported unit commit failed; lock discarded",{path:m.file,test_id:m.testId,reason:S.reason,message:S.message}),await Pe({baseUrl:`${e.tmsBaseUrl}/kane-cli/v1`,testId:m.testId,body:{commitId:e.newCommitId,fromCommitId:m.fromCommitId},auth:{username:e.basicAuth.username,accessKey:e.basicAuth.access_key}}),fe(m.testId)}return v.ok?{...v,...d}:v}}function Mi(e){if(!(!e.isFirstRun||!e.sourcePath))return async t=>{if(!e.sourcePath)return;let n=Ne(e.sourcePath);try{let r=ws(n)?JSON.parse(Un(n,"utf8")):{};e.session.sessionId&&(r.commit_id=e.session.sessionId),t&&(r.testcase_id=t),e.tmsIds?.testId&&(r.test_id=e.tmsIds.testId),e.tmsIds?.projectId&&(r.project_id=e.tmsIds.projectId),e.tmsIds?.folderId&&(r.folder_id=e.tmsIds.folderId),e.tmsIds?.orgId&&(r.org_id=e.tmsIds.orgId),e.tmsIds?.sessionName&&(r.session_name=e.tmsIds.sessionName),Nn(n,JSON.stringify(r,null,2)+`
30
- `,"utf8")}catch(r){process.stderr.write(`warn: failed to update meta.json after endTest: ${r.message}
31
- `)}}}function $i(e){let t=e.decisions,n=e.resolvedTest?.steps,r=e.sourcePath;if(!t||!n||!r)return;let o=[];if(t.forEach((s,i)=>{s.kind==="replay"&&s.replayOnly&&o.push(n[i]?.flatIndex??i+1)}),o.length!==0)return{authoredExecutionPath:Be(r),flatIndices:o}}function ks(e){let t=$i(e),n=ne(e.env),r=e.resolvedTest,o=!!r&&Array.isArray(r.unitFiles)&&(e.stepRunRecords?.length??0)>0,s=o?hs(r,new Set(e.authoredFlatIdx??[]),{onMissingIdentity:re=>{e.log?.("warn","MODULE_IDENTITY_MISSING","*_module.md without a cloud module_id; its blocks upload unfolded",{path:re}),process.stderr.write(`${Fn(re)}
32
- `)}}):void 0,i=o?bs(e.stepRunRecords):void 0,h=!!r&&r.steps.some(re=>re.block!==void 0),l=o&&h?vs(r,e.blockOutcomes):void 0,d=l?.length&&e.sourcePath?Be(e.sourcePath):void 0,v={files:[]},{session:m,auth:b}=e,k=b.basicAuth?{username:b.basicAuth.username,accessKey:b.basicAuth.access_key}:b.token,A=b.resolvedCreds?.username??b.basicAuth?.username??"",S=b.resolvedCreds?.access_key??b.basicAuth?.access_key??"",R=b.resolvedCreds?.org_id??0,c=b.resolvedCreds?.user_id??0,F=[];for(let re of Object.keys(m.auteurVariables))re.startsWith("secrets.user.")&&F.push({key_name:re.replace("secrets.user.",""),scope:"user"});let C=m.getContext().prior_runs.map(re=>re.status),$=m.auteurVariables,_e=Object.keys($).length>0;return{controllerBaseUrl:n.controllerBaseUrl,tmsBaseUrl:n.tmsBaseUrl,auth:k,authResolver:b.resolver,sessionId:m.sessionId,sessionDir:m.sessionDir,testId:m.testId,commitId:m.sessionId,apMode:m.apMode,projectId:e.projectId,folderId:e.folderId,firstObjective:m.firstObjective??"KaneAI Test",firstUrl:m.firstUrl??"",runDirs:m.getRunDirs(),runObjectives:m.getRunObjectives(),runMetadata:m.getRunMetadata(),startedAt:m.startedAt,endedAt:new Date().toISOString(),totalSteps:e.totalSteps,totalDuration:e.totalDuration,runStatuses:C,orgId:R,userId:c,tmsUsername:A,tmsAccessKey:S,screenshotBaseUrl:m.screenshotBaseUrl,screenshotExtMap:e.screenshotExtMap,shareApiBaseUrl:n.shareApiBaseUrl,variables:_e?$:void 0,variableIds:e.variableIds,secrets:F,codeExport:e.codeExport,...e.mobile?{mobile:!0}:{},onProgress:e.onProgress,log:e.log,shouldUploadArtifacts:e.shouldUploadArtifacts,shouldReplaceLocalOutput:e.shouldReplaceLocalOutput,shouldCommit:e.shouldCommit,isFirstRun:e.isFirstRun,onAtomicReplace:Ni(e,v),onCommitLock:Bi(e,v),onFinalizeSuccess:Mi(e),evidence:e.evidence,evidenceRead:e.evidenceRead,...s?{moduleSpans:s}:{},...l?.length?{blockSpans:l,blockAuthoredExecutionPath:d}:{},...i?{runFlatIndex:i}:{},authoredExecutionPath:e.authoredExecutionPath,...t?{replayOnlyPassthrough:t}:{}}}function _s(e,t=process.env){return t.KANE_MOBILE_APP_BASE_URL||ne(e).mobileAppBaseUrl}var Is=["python","javascript"];function Vi(e){if(e!==void 0){if(!Is.includes(e))throw new Error(`--code-language must be one of: ${Is.join(", ")} (got "${e}")`);return e}}function Ss(e,t){let n=Vi(e.codeLanguage);return{enabled:e.codeExport??t.enabled,language:n??t.language,skipValidation:e.skipCodeValidation??t.skip_validation}}function Rs(e){return{platform:e.platform??"",...e.appId?{appId:e.appId}:{},...e.deviceName?{deviceName:e.deviceName}:{},...e.osVersion?{osVersion:e.osVersion}:{},...e.udid?{udid:e.udid}:{}}}async function Cs(e){try{let t=new Ct(e.tmsBaseUrl,e.auth.username,e.auth.access_key);if(e.mobile){if(!e.mobile.appId)return e.log("warn","ATM_CREATE_SKIPPED","Mobile test not registered in TMS",{reason:"no cloud app id for the build under test"}),null;let r=await t.createMobileAtmTest({objective:e.objective.slice(0,100),creation_mode:"KANECLI",playground_disabled:e.hasCustomProfile,mobile_browser:!1,os:e.mobile.platform.toLowerCase(),app_id:e.mobile.appId,project_id:e.projectId,folder_id:e.folderId,authoring_version:4,...e.mobile.deviceName?{deviceName:e.mobile.deviceName}:{},...e.mobile.osVersion?{osVersion:e.mobile.osVersion}:{},...e.mobile.udid?{udid:e.mobile.udid}:{}});return e.log("info","ATM_CREATE_OK","Mobile test created",{test_id:r}),r}let n=await t.createAtmTest({objective:e.objective.slice(0,100),creation_mode:"KANECLI",playground_disabled:e.hasCustomProfile,testURL:e.url,project_id:e.projectId,folder_id:e.folderId,authoring_version:4});return e.log("info","ATM_CREATE_OK","Test created",{test_id:n}),n}catch(t){return e.log("error","ATM_CREATE_FAILED","Test creation failed",{error:t instanceof Error?t.message:String(t)}),null}}var Ki=null,Hi=()=>Ki??=import("sharp").then(e=>e.default??e).catch(()=>null),Vt=class{maxWorkers;maxRetries=2;queue=[];activeCount=0;drainResolvers=[];sas;log;uploadedExt=new Map;constructor(t,n=3,r){this.sas=t,this.maxWorkers=n,this.log=r}updateSas(t){this.sas=t}enqueue(t,n){this.queue.push({operationId:t,buffer:n}),this.pump()}async drain(t=3e4){if(!(this.queue.length===0&&this.activeCount===0))return new Promise(n=>{this.drainResolvers.push(n),setTimeout(()=>{n()},t)})}pump(){for(;this.activeCount<this.maxWorkers&&this.queue.length>0;){let t=this.queue.shift();this.activeCount++,this.processJob(t).finally(()=>{if(this.activeCount--,this.pump(),this.queue.length===0&&this.activeCount===0){for(let n of this.drainResolvers)n();this.drainResolvers=[]}})}}async processJob(t){let n,r="image/webp",o=await Hi();if(o)try{let l=await o(t.buffer).webp({quality:80}).toBuffer();n=new Uint8Array(l)}catch(l){n=new Uint8Array(t.buffer),r="image/png",this.log?.("warn","SCREENSHOT_CONVERT_FAILED","WebP conversion failed, using PNG",{operation_id:t.operationId,error:l instanceof Error?l.message:String(l)})}else n=new Uint8Array(t.buffer),r="image/png";let s=r==="image/webp"?"webp":"png",i=`test_screenshots/untagged_screenshot/${t.operationId}.${s}`,h=`${this.sas.base_url}/${this.sas.container}/${i}?${this.sas.sas_token}`;for(let l=0;l<=this.maxRetries;l++)try{let d=await Z(h,{method:"PUT",headers:{"Content-Type":r,"x-ms-blob-type":"BlockBlob"},body:n});if(d.ok){this.uploadedExt.set(t.operationId,s);return}if(l<this.maxRetries){await this.backoff(l);continue}this.log?.("warn","SCREENSHOT_UPLOAD_FAILED","Screenshot upload failed after retries",{operation_id:t.operationId,status:d.status,attempts:this.maxRetries+1})}catch{if(l<this.maxRetries){await this.backoff(l);continue}this.log?.("warn","SCREENSHOT_UPLOAD_FAILED","Screenshot upload failed (network error)",{operation_id:t.operationId,error:"network",attempts:this.maxRetries+1})}}backoff(t){let n=t===0?1e3:3e3;return new Promise(r=>setTimeout(r,n))}getExt(t){return this.uploadedExt.get(t)??"png"}getExtMap(){return this.uploadedExt}isNearExpiry(){if(!this.sas.expiry)return!1;let t=new Date(this.sas.expiry).getTime();return Date.now()>t-5*6e4}};import{platform as qi,arch as Gi}from"os";function Es(e){let t={proxyUrl:Cr,sessionId:e.sessionId,identity:e.identity,device:{cli_version:_t,platform:qi(),arch:Gi(),host_agent:mn(),invocation_mode:e.invocationMode},getToken:e.getToken};return new un(t)}async function zi(e){try{let t=ne(e.env),r=await new Ee(t.controllerBaseUrl,e.auth).getScreenshotSas();return e.session.setScreenshotSas(r),e.log("info","SCREENSHOT_SAS_OK","Screenshot SAS fetched",{base_url:r.base_url,container:r.container,expiry:r.expiry}),new Vt(r,3,e.log)}catch(t){return e.log("warn","SCREENSHOT_SAS_FAIL","Screenshot SAS fetch failed",{error:t instanceof Error?t.message:String(t)}),null}}async function Yi(e){if(e.session.hasRemoteLogger||!e.tmsCreds)return null;let t=e.tmsCreds,n=Es({sessionId:e.session.sessionId,identity:{org_id:String(t.org_id??""),user_id:String(t.user_id??""),machine_id:Nr(),email:t.email??null,email_domain:t.email_domain??"unknown",user_type:t.user_type??"unknown",env:e.env,plan:t.plan??"unknown"},invocationMode:e.invocationMode,getToken:e.getToken});return e.session.setRemoteLogger(n),n.start(),n}async function Vn(e){let[t,n]=await Promise.allSettled([e.skipScreenshotQueue?Promise.resolve(null):zi({env:e.env,auth:e.auth,session:e.session,log:e.log}),Yi({env:e.env,tmsCreds:e.tmsCreds,getToken:e.getToken,session:e.session,invocationMode:e.invocationMode})]);return{resolver:e.resolver,screenshotQueue:t.status==="fulfilled"?t.value:null,remoteLogger:n.status==="fulfilled"?n.value:null}}async function Bn(e){await Promise.allSettled([e.screenshotQueue?.drain(),e.remoteLogger?.shutdown()])}async function Rc(e,t){switch(e.kind){case"boot":{if(t.state.identityServicesRef.current)return t.state.identityServicesRef.current;let n=t.auth.initResolver(e.env);n.prime(e.tmsCreds),t.state.setTmsCredsCache(e.tmsCreds);let r=await Mn(e.env,e.tmsCreds,n,t);return $n(r,t),r}case"login":case"switch":{let n=t.state.identityServicesRef.current;n&&(await Bn(n),n.resolver.revoke()),t.state.identityServicesRef.current=null,t.state.screenshotQueueRef.current=null,t.state.setTmsCredsCache(null);let r=t.auth.initResolver(e.env),o=await r.resolve(!0).catch(()=>null);if(!o)return t.log("warn","IDENTITY_VALIDATE_FAILED","Identity validation failed",{kind:e.kind,env:e.env}),null;t.state.setTmsCredsCache(o);let s=await Mn(e.env,o,r,t);return $n(s,t),s}case"logout":{let n=t.state.identityServicesRef.current;return n&&(await Bn(n),n.resolver.revoke()),t.state.identityServicesRef.current=null,t.state.screenshotQueueRef.current=null,t.state.setTmsCredsCache(null),null}case"resessionize":{let n=t.state.identityServicesRef.current;n&&await Bn(n),t.state.identityServicesRef.current=null,t.state.screenshotQueueRef.current=null;let r=t.state.getTmsCredsCache(),o=t.auth.getResolver(),s=o??t.auth.initResolver(e.env);!o&&r&&s.prime(r);let i=await Mn(e.env,r,s,t);return $n(i,t),i}}}async function Mn(e,t,n,r){let o=r.auth.getBasicAuth(),s=o?null:await r.auth.getToken(),i=o?{username:o.username,accessKey:o.access_key}:s??null;return i===null?{resolver:n,screenshotQueue:null,remoteLogger:null}:Vn({env:e,tmsCreds:t,resolver:n,auth:i,getToken:()=>r.auth.getToken(),session:r.getSession(),log:r.log,skipScreenshotQueue:r.options?.skipScreenshotQueue,invocationMode:"tui"})}function $n(e,t){t.state.identityServicesRef.current=e,t.state.screenshotQueueRef.current=e.screenshotQueue,e.remoteLogger&&(t.exit.registerCleanup("remote-logger",()=>e.remoteLogger.shutdownSync()),t.exit.setExitRemoteLogger(e.remoteLogger))}function As(e){if(!e.executionId)return;let t={executionId:e.executionId,published:e.published};return e.testId&&(t.testId=e.testId),e.testcaseId&&(t.testcaseId=e.testcaseId),e.commitId&&(t.commitId=e.commitId),t}import{relative as Qi}from"path";import{readFile as Wi}from"fs/promises";function xs(e){return e.shouldUploadArtifacts&&!e.lockHeld&&!e.isFirstRun&&e.sealed&&!!e.testId}var Kn=e=>e instanceof Error?e.message:String(e);async function Ps(e){let{controller:t,tms:n,testId:r,sessionId:o,executionId:s,sealedPackPath:i,projectId:h}=e,l;try{let d={key:"evidence",content_type:"application/zip",filename:`${s}.evidence`},m=(await t.getPresignedUrls(r,o,[d])).urls?.evidence?.upload_url;if(!m)return{ok:!1,stage:"presign",error:"presign response missing evidence upload_url"};l=m}catch(d){return{ok:!1,stage:"presign",error:Kn(d)}}try{let d=await Wi(i);await io(l,d,"application/zip")}catch(d){return{ok:!1,stage:"upload",error:Kn(d)}}try{await n.ingestEvidence(s,h)}catch(d){return{ok:!1,stage:"ingest",error:Kn(d)}}return{ok:!0}}function Ts(e){return e.isFirstRun||Ot(e.decisions)||e.push===!0||e.author===!0}function Ls(e,t){return{projectId:e?.project_id??t.project_id??null,folderId:e?.folder_id??t.folder_id??null}}function Hn(e){return e?"author":"replay"}function Zi(e,t){return e?{session:e,ownsLifecycle:!1}:{session:t,ownsLifecycle:!0}}function Kt(e,t){return e?.total_runs??t?.length??1}function Xi(e){let t=(e?.per_flow_metadata??[]).map(n=>({resultCode:n?.result_code!=null?Number(n.result_code):null}));return{resultCode:e?.result_code!=null?Number(e.result_code):null,...t.length?{perFlow:t}:{}}}var Ht=["target","chrome_profile","cdp_endpoint","ws_endpoint","headless"];async function qd(e,t,n){let{path:r,cwd:o,opts:s,isAgent:i,disableAskUser:h,resolved:l,resolvedAuth:d,cliOverrides:v,environment:m,envConfig:b,profile:k,model:A,creds:S,configStore:R,session:c}=e,F=!1,f=await oa(r,l,s,{resolvedAuth:d,tmsBaseUrl:b.tmsBaseUrl},c.sessionId,n);if(f.abort)return{overallStatus:"failed",exitCode:f.abort.exitCode,outputDir:X(r),durationS:0,uploadResult:null};let C=f.lockAcquired,$=!1;try{let rn=function(a,u){let p=l.steps[a],y=Os(p.config,v),w=qe(Se.raw,y.variables,p.objective);return On({objective:w.objective,url:P.kind==="device"?void 0:Gt(a)?we??void 0:p.unitEntryUrl,requireStartUrl:P.kind==="web"&&Gt(a)&&Ms,model:A,chrome:G,device:P.kind==="device"?P.device:void 0,auth:d,sessionId:c.sessionId,runIndex:u,windowSize:{width:1920,height:1080},maxSteps:y.max_steps??$s??30,headless:V.headless??!1,disableAskUser:!0,variables:Object.keys(w.variables).length>0?w.variables:void 0,globalContext:y.global_context??or,localContext:y.local_context??sr,sessionContext:c.getContext(),bugDetection:s.bugDetection??K.bug_detection,evidence:nn()})},Ze=function(a){let p=l.steps[a].trace[0].stepIndex,y=l.rootSteps.find(g=>g.index===p);l.steps.slice(0,a).some(g=>g.trace[0].stepIndex===p)||t.onAgentEvent({type:"test_md_step_start",step_index:p,heading:y.heading,ref:y.body.kind==="import_ref"?{kind:"import",label:y.body.path,unit_kind:vn(y.body.path)}:null,...y.replayOnly?{replay_only:y.replayOnly}:{}})},ht=function(a,u,p,y,w,g){let _=l.steps[a],L=_.trace[0].stepIndex,N=!l.steps.slice(a+1).some(M=>M.trace[0].stepIndex===L),E=p?.status==="passed"?"passed":"failed",T=p?.reason??w??void 0,j=p?.duration??g,I=p?.verdict;if(I&&typeof I=="object"){let M=typeof I.one_liner=="string"?I.one_liner:"",U=typeof I.bug_title=="string"&&I.bug_title?I.bug_title:M;if(U&&E==="failed"){let me=[I.family,I.category].filter(Boolean).join("/"),kt=typeof I.confidence=="number"?`, confidence ${I.confidence.toFixed(2)}`:"";T=`${T??"failed"} \u2014 bug verdict: ${U}${me?` [${me}${kt}]`:""}`}let Xe=typeof I.category_proposal=="string"?I.category_proposal:"";Xe&&E==="failed"&&(T=`${T??"failed"}; category proposal: ${Xe} \u2014 consider adding to taxonomy`),t.onAgentEvent({type:"test_md_bug_verdict",step_index:_.trace[0].stepIndex,confirmed:I.confirmed===!0,bug_title:U||null,family:I.family??null,category:I.category??null,category_proposal:Xe||null,severity:I.severity??null,confidence:typeof I.confidence=="number"?I.confidence:null,one_liner:M||null})}let{continueOverall:B}=ae.recordStep(_,{status:E,duration_s:j,reason:T}),Q=Os(_.config,v),x=qe(Se.raw,Q.variables,_.objective).objective;if(p){let M=qo(p,u,y);c.addRunResult(Go(p,x,u,M),p.total_runs)}else c.addRunResult({index:u,objective:x,status:E,summary:"",context:{memory:{},variables:{},pointer:""}},1);if(N||!B){let M=ae.snapshotOutcomes().find(U=>U.rootStepIndex===L);t.onAgentEvent({type:"test_md_step_end",step_index:L,status:M.status,duration_s:M.duration_s??0,ref_kind:M.refKind??null,unit_kind:M.refKind==="import"?vn(M.refLabel??""):null,inlined_count:M.inlinedCount??null,failed_sub_step_index:M.failedSubStepIndex??null})}return B},je=function(a,u){let p=l.steps[a],y=p.trace[p.trace.length-1].heading;process.stderr.write(`\u{1FA79} step ${p.flatIndex} "${y}" @${u} broke on replay \u2014 adaptive heal cannot re-author a replay-only step; the run fails here
33
- `),c.log("warn","REPLAY_ONLY_STEP_FAILED","Replay-only step failed on replay; heal not attempted",{flat_index:p.flatIndex,marker:u})};var _e=rn,re=Ze,oe=ht,se=je;let qt={committed:!1},ue=!1,lt=new Set,Ye=0,Fs=l.steps.some(a=>a.block!==void 0),Gt=a=>Fs?Ye===0:a===0,ge=!1,ct=!1,dt=s.author===!0?0:nt(f.decisions),zt=0,Yt=0,zn=a=>typeof a?.credits_consumed=="number"&&Number.isFinite(a.credits_consumed)?a.credits_consumed:0;{let a;try{a=typeof s.sessionContext=="string"?JSON.parse(s.sessionContext):void 0}catch{a=void 0}let u=ea({resolved:l,cwd:o,globalDir:pe(It,"variables"),opts:s,isAgent:i,authorFrom:dt,produced:Io(a)});if(u.refuse)return i?process.stdout.write(JSON.stringify(u.event)+`
34
- `):process.stderr.write(u.text),{overallStatus:"failed",exitCode:2,outputDir:X(r),durationS:0,uploadResult:null}}C&&t.onLockState({phase:"acquired",scope:"preemptive"}),c.start({model:A,environment:m,profile:k}),c.setRecordingEnabled(!1);let ut=0,Yn=d.basicAuth?{username:d.basicAuth.username,accessKey:d.basicAuth.access_key}:d.token??null,We=null;if(Yn!==null){let a=await Vn({env:m,tmsCreds:d.resolvedCreds??null,resolver:d.resolver,auth:Yn,getToken:async()=>d.token??null,session:c,log:(u,p,y,w)=>c.log(u,p,y,w),skipScreenshotQueue:!!s.local||!d.basicAuth,invocationMode:i?"agent":"cli"});We=a.screenshotQueue,a.remoteLogger&&(n.register("remote-logger",()=>a.remoteLogger.shutdownSync()),n.remoteLogger=a.remoteLogger,e.skipGlobalRemoteLogger||Pr(a.remoteLogger))}if(s.name){try{go(s.name)}catch(a){return process.stderr.write(`error: ${a.message}
35
- `),{overallStatus:"failed",exitCode:2,outputDir:X(r),durationS:0,uploadResult:null}}c.setSessionName(s.name)}let Wt={};for(let[a,u]of Object.entries(l.rootGlobal))Ht.includes(a)||(Wt[a]=u);for(let[a,u]of Object.entries(v))Ht.includes(a)||u!==void 0&&(Wt[a]=u);let V={...l.chrome};for(let a of Ht){let u=v[a];u!==void 0&&(V[a]=u)}let Je={...Wt,...V},Le=ho({flags:{target:s.target,deviceName:s.deviceName,osVersion:s.osVersion,app:s.app},file:{target:l.rootGlobal.target,device_name:l.rootGlobal.device_name,os_version:l.rootGlobal.os_version,app:l.rootGlobal.app,no_reset:l.rootGlobal.no_reset}});if(Le.kind==="invalid")return process.stderr.write(`error: ${Le.message}
36
- `),await c.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:X(r),durationS:0,uploadResult:null};for(let a of Le.warnings)process.stderr.write(`warning: ${a}
37
- `);let ye=Le.kind==="mobile"?Le:null;if(Le.kind==="web"&&l.rootGlobal.target===void 0){let u=l.rootSteps.map(y=>y.body).find(y=>y.kind==="objective")?.text??"",p=/^\s*\[mobile:\s*(emulator|simulator)\]/.exec(u);if(p)return process.stderr.write(`error: this test was designed for a mobile ${p[1]} but its frontmatter has no target: \u2014 add \`target: ${p[1]}\` and \`app: <path-to-build | AppId>\` to the file (or re-design it with the app named in the design chat: kane-cli design tests --use-case <uc> --force), then run again
38
- `),await c.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:X(r),durationS:0,uploadResult:null}}ye?(Je.target=ye.target,ye.app&&(Je.app=ye.app)):(l.rootGlobal.target==="emulator"||l.rootGlobal.target==="simulator")&&(delete Je.app,delete Je.no_reset),c.setResolvedGlobal(Je);let Wn=S.getActiveProfile()??"default",Jn=S.getDefaultEnv(),{rehydrateIfStale:Us}=await import("./profile-sync-DTTRRIVP.js");Us(S,R,Wn,Jn);let K=R.load(),Qn=(v.assertion_mode??K.assertion_mode)==="dom"?"dom":"visual",Zn=v.final_validation,Xn=Zn===void 0?void 0:Zn==="on",q=K.project_id??null,ve=K.folder_id??null,er=be(r)?.environment_id,tr=Ts({isFirstRun:f.isFirstRun,decisions:f.decisions,push:s.push===!0,author:s.author===!0});if(tr){if(d.basicAuth){let a=await Ur({creds:S,config:R,profile:Wn,env:Jn,tmsCreds:d.basicAuth,isLocal:!!s.local,log:(u,p,y,w)=>c.log(u,p,y,w),onAnnounce:e.onAnnounce,onFatalExit:e.onFatalExit});if(a.status==="ok"){q=a.projectId,ve=a.folderId,K=R.load();let u=be(r);u?.project_id&&(q=u.project_id,ve=u.folder_id??ve),i&&a.autoDefaulted&&t.onAgentEvent(Fr(a.autoDefaulted))}else if(a.status==="cancelled"){process.stderr.write(`error: project/folder configuration failed. See remediation above, or use --local.
39
- `);let{shutdown:u}=await import("./exit-manager-ZLDO54S4.js");return u(2,"project/folder gate failed"),{}}}}else{let a=be(r);({projectId:q,folderId:ve}=Ls(a,{project_id:K.project_id??null,folder_id:K.folder_id??null})),c.log("info","GATE_SKIP_REPLAY","Project/folder gate skipped (planned pure replay)",{meta_project:!!a?.project_id,config_project:!!K.project_id})}{let a=lo(l),u=d.resolvedCreds?.org_id!=null?String(d.resolvedCreds.org_id):void 0,p=a.find(g=>g.project_id&&q&&g.project_id!==String(q)||g.org_id&&u&&g.org_id!==u),y=new Set(a.map(g=>g.project_id).filter(Boolean)),w=new Set(a.map(g=>g.org_id).filter(Boolean));if(p||y.size>1||w.size>1){let g=p??a[0];return process.stderr.write(`error: tenant mismatch \u2014 imported test '${g.file}' was authored under project ${g.project_id??"?"} / org ${g.org_id??"?"}, which differs from the run's project/org (or another imported test). Cross-tenant imports are not allowed.
40
- `),await c.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:X(r),durationS:0,uploadResult:null}}}let Ie={},P;try{P=await os(ye?"device":"web",{prepareDevice:async()=>{let a=ye,u=await jr({platform:a.platform,...a.deviceSelector?{device:a.deviceSelector}:{},...a.app?{app:a.app}:{},...a.noReset!==void 0?{noReset:a.noReset}:{},defaults:K.mobile,interactive:Co()&&!i,agent:i,...!s.local&&d.basicAuth&&d.resolvedCreds?.org_id?{cloudUpload:{env:m,orgId:String(d.resolvedCreds.org_id),userId:String(d.resolvedCreds.user_id??""),baseUrl:_s(m),auth:{username:d.basicAuth.username,accessKey:d.basicAuth.access_key}}}:{},onProgress:p=>process.stderr.write(`${p}
41
- `)});return Ie.deviceName=u.target.displayName,u.target.osVersion&&(Ie.osVersion=u.target.osVersion),u.target.modelIdentifier&&(Ie.modelIdentifier=u.target.modelIdentifier),{device:u.device,...u.appRef?{appRef:u.appRef}:{},...u.appId?{appId:u.appId}:{}}},prepareWeb:()=>Ln({config:{chrome_profile_path:V.chrome_profile??null,window_size:{width:1920,height:1080}},startUrl:et,headless:V.headless??!1,wsEndpoint:V.ws_endpoint,cdpEndpoint:V.cdp_endpoint})})}catch(a){if(ye){let u=a instanceof Dr?`${a.doctorText}
42
- ${a.message}`:a.message;process.stderr.write(`error: mobile target preparation failed: ${u}
43
- `)}else process.stderr.write(`error: Chrome launch failed: ${a.message}
44
- `);return await c.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:X(r),durationS:0,uploadResult:null}}if(P.kind==="device"&&!P.device.app_package)return process.stderr.write(`error: ${bo(ye.target,"app")}
45
- `),await c.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:X(r),durationS:0,uploadResult:null};let G=P.kind==="web"?P.chrome:{instance:null,tempDir:null},he=G.instance;he&&n.register("chrome",()=>{try{he?.kill()}catch{}});let Jt=pn(G.cdpEndpoint),H=null,nr=!1,mt=()=>{if(!H?.diedUnexpectedly)return!1;if(!nr){nr=!0;let a=H.stderr.slice(-500);c.log("error","RUNNER_FATAL_DEATH","v16-runner exited unexpectedly mid-session",{stderr_tail:a}),process.stderr.write(`error: v16-runner exited unexpectedly mid-session \u2014 remaining steps skipped.
46
- `)}return!0},z=null,rr=G.cdpEndpoint??V.cdp_endpoint;if(rr&&!V.ws_endpoint&&!V.headless&&!e.isAgent)try{z=Pn({headless:V.headless??!1,cdpEndpoint:rr,chromePid:he?.process.pid}),z&&n.register("marker-overlay",()=>z?.kill())}catch(a){c.log("warn","OVERLAY_SPAWN_FAILED","Marker overlay spawn failed",{error:String(a)})}d.resolvedCreds?.org_id!==void 0&&c.setOrgId(String(d.resolvedCreds.org_id)),c.setUserIdentity(d.resolvedCreds?.username??null,d.resolvedCreds?.email??null);let Se=ms({objective:"",globalDir:pe(It,"variables"),localDir:pe(o,".testmuai","variables"),file:s.variablesFile,inline:s.variables}),Ns=l.rootGlobal.variables??{},ie=ta(Se.raw,Ns);c.setAuteurVariables(ie.auteur);let or=jn(pe(It,"global-memory.md"))??void 0,sr=jn(pe(o,".testmuai","context.md"))??void 0;s.local?process.stderr.write(`info: --local \u2014 cloud upload skipped
47
- `):d.basicAuth?q||(tr?process.stderr.write(`warn: cloud upload skipped \u2014 no project configured.
48
- `):process.stderr.write(`warn: evidence publish will be skipped \u2014 no project_id in meta.json or config.
49
- `)):process.stderr.write(`warn: cloud upload skipped \u2014 TMS credentials could not be resolved.
50
- Run 'kane-cli login' (OAuth) or 'kane-cli config set-username/set-access-key' (basic auth).
51
- `);let Oe=!s.local&&!!d.basicAuth&&q!=null;if(c.log("info","PIPELINE_GATE_STATE","Initial gate state (run-start)",{phase:"run-start",shouldUploadArtifacts:Oe,lockHeld:C,isFirstRun:f.isFirstRun,hasAuth:f.hasAuth}),Oe&&f.testId==null&&!f.degradedReadonly){let a=ne(m);try{let u=await Cs({tmsBaseUrl:a.tmsBaseUrl,auth:d.basicAuth,objective:l.steps[0].objective,url:"",projectId:q,folderId:ve??"",hasCustomProfile:!!V.chrome_profile,...P.kind==="device"?{mobile:Rs({platform:P.device.platform,appId:P.appId,deviceName:Ie.deviceName,osVersion:Ie.osVersion,udid:P.device.udid})}:{},log:(p,y,w,g)=>c.log(p,y,w,g)});u&&c.setTestId(u)}catch(u){process.stderr.write(`warn: ATM test creation failed: ${u.message}
52
- `)}}else f.testId&&c.setTestId(f.testId);let ft={};if(d.basicAuth&&!s.local&&(ie.secretEntries.length>0||ie.nonSecretEntries.length>0))try{ft=await fs({variables:ie,auth:d.basicAuth,orgId:String(d.resolvedCreds?.org_id??""),env:m,localMode:!!s.local,log:(a,u,p,y)=>c.log(a,u,p,y)})}catch(a){process.stderr.write(`warn: variable/secret push failed: ${a.message}
53
- `)}let Qt=new Map;for(let[a,u]of ie.nonSecretEntries)Qt.set(a,u.value);let Zt=new Map;for(let[a,u]of ie.secretEntries)Zt.set(a,u.value);async function Xt(a){if(!d.basicAuth||s.local)return;let u=[],p=[];for(let[w,g]of Object.entries(a))if(g.secret){if(Zt.get(w)===g.value)continue;p.push([w,g])}else{if(Qt.get(w)===g.value)continue;u.push([w,g])}if(u.length===0&&p.length===0)return;let y=ne(m);if(u.length>0){let w=new He(y.tmsBaseUrl,d.basicAuth.username,d.basicAuth.access_key);for(let[g,_]of u)try{let L=await w.upsertVariable({name:g,value:_.value});ft[g]=L.id,Qt.set(g,_.value),c.log("info","VAR_PUSH_STEP","Variable updated mid-run",{name:g})}catch(L){c.log("warn","VAR_PUSH_STEP_FAILED","Mid-run variable push failed",{name:g,error:String(L)})}}if(p.length>0){let w=new Ke(y.secretsBaseUrl);for(let[g,_]of p)try{await w.pushSecret({secretKey:g,secretValue:_.value,username:d.basicAuth.username,accessKey:d.basicAuth.access_key,orgId:String(d.resolvedCreds?.org_id??"")}),Zt.set(g,_.value),c.log("info","SECRET_PUSH_STEP","Secret updated mid-run",{name:g})}catch(L){c.log("warn","SECRET_PUSH_STEP_FAILED","Mid-run secret push failed",{name:g,error:String(L)})}}}let Qe=We?(a,u,p,y)=>{if(!(C||f.isFirstRun))return;if(O&&y){Ko(O.packTestDir,y,We,(g,_,L,N)=>c.log(g,_,L,N));return}let w=ut+u;Ho(c.sessionDir,w,a,We,(g,_,L,N)=>c.log(g,_,L,N),p)}:void 0,ir=l.rootTitle??l.rootSteps[0]?.heading??qn(r),Bs=Object.keys(ie.raw).length>0?Ue(ie.raw,ir).objective:ir,we=zo({flag:s.url,frontmatter:l.rootGlobal?.url,configDefault:R.load().default_url}),Ms=Yo({resolvedUrl:we,local:!!s.local,allowMissingUrl:!!s.allowMissingUrl,isTTY:!!process.stdin.isTTY});c.setFirstRun(Bs,we??"");let ae=new Ft(l),pt=new Date().toISOString(),ar=Date.now(),en=e.evidenceAttach?null:new Jr({origin:"testmd",runKind:"author",pid:process.pid,title:l.rootTitle??qn(r),started:pt,producerVersion:_t,surfaces:we?[we]:void 0,testmdRelPath:Qi(o,r),definition:{path:"test.md",content:Ds(r,"utf8")},cwd:o,packRootDir:pe(c.sessionDir,"evidence")}),J=Zi(e.evidenceAttach,en),W=J.session,O=null;if(e.evidenceAttach)O={executionId:e.evidenceAttach.id,testId:e.evidenceAttach.test,packTestDir:e.evidenceAttach.packTestDir};else if(en)try{O=await en.start()}catch(a){c.log("warn","EVIDENCE_START_FAILED","Evidence pack creation failed",{error:String(a)})}let Re=[],gt=[],lr,De,tn=(a,u,p,y,w)=>{if(!O)return;W.noteSpawn(w?.length?{...a,steps:a.steps.map(_=>({..._,verifies:w}))}:a),a.resolution&&(lr=a.resolution),De=$r(De,a.runnerEnvironment),Re.push(Xi(u));let g=Kt(u,y);for(let _=0;_<g;_++)gt.push(p+_)},nn=()=>O?{packTestDir:O.packTestDir,ordinalOffset:W.nextOrdinalOffset()}:void 0,cr=async a=>{if(!O||!W)return;let u=Hr(Re.length?Re:[{resultCode:null}]);await W.archiveAttempt(u,a,{log:(p,y,w,g)=>c.log(p,y,w,g)}),Re.length=0,gt.length=0},$s=typeof s.maxSteps=="string"&&s.maxSteps!==""?parseInt(s.maxSteps,10):void 0,on=[],bt=Ve.hasBlocks(l.steps)?new Ve(l.steps,f.decisions,{evaluate:async a=>{let u=c.nextRunIndex(),p=Ye===0,w={...On({objective:a.join(`
54
- `),conditions:a,url:p&&P.kind!=="device"?we??void 0:void 0,model:A,chrome:G,auth:d,sessionId:c.sessionId,runIndex:u,windowSize:{width:1920,height:1080},maxSteps:1,headless:V.headless??!1,disableAskUser:!0})};delete w.run_id,At(w,{environment:m});let g=null;try{for await(let _ of H.run(`run-${u}`,"evaluate",w)){if(t.onAgentEvent(_),_.type==="run_end"){g=_;break}if(_.type==="error")break}}catch(_){c.log("error","BLOCK_CONDITION_JUDGE_FAILED","evaluate run failed",{error:_.message})}return p&&g&&Ye++,c.log("info","BLOCK_CONDITION_JUDGED","Control-flow conditions judged",{conditions:a,results:g?.condition_results??null,reasons:g?.condition_reasons??null}),g?.condition_results??a.map(()=>null)},whileConfig:a=>$t(l.steps[a]),sleep:a=>new Promise(u=>setTimeout(u,a))}):null;async function dr(a){if(!bt)return null;let u=await bt.before(a),p=l.steps[a];switch(u.action){case"run":return null;case"author":return{kind:"author"};case"skip":return{kind:"done",stop:null};case"structural":return Ze(a),ae.recordStep(p,{status:"passed",duration_s:0}),c.log("info","BLOCK_STRUCTURAL_STEP","Control-flow marker step",{step:p.flatIndex,marker:p.controlFlow}),{kind:"done",stop:null};case"jump":return c.log("info","BLOCK_WHILE_REENTER","While condition holds \u2014 re-entering the body",{from:p.flatIndex,to:u.to+1}),{kind:"jump",to:u.to};case"fail":return Ze(a),ae.recordStep(p,{status:"failed",duration_s:0,reason:u.reason}),c.log("error","BLOCK_STEP_FAILED",u.reason,{step:p.flatIndex}),{kind:"done",stop:{failedAt:a,cancelled:!1}}}}async function ur(a){let u=l.steps[a];Ze(a),Ye++,ue=!0,lt.add(l.steps[a].flatIndex);let p=c.nextRunIndex();ut=p,await Xt(qe(Se.raw,u.config.variables,u.objective).raw);let y=rn(a,p),w=Date.now(),g=null,_=null,L=null,N=!1,E=0,T=Pt(),j={...y};delete j.run_id,At(j,{environment:m});let I=`run-${p}`;try{z?.setRunActive(!0);try{for await(let x of H.run(I,"author",j)){if(t.onAgentEvent(x),T=fn(T,x),x.type==="bifurcation"){let M=x.count??x.flows?.length??0;(x.is_single_flow??M<=1)||(L=x.flows??null,N=!0,E=0)}else if(x.type==="run_start"&&N)E++;else if(x.type==="step_event"&&x.event==="reasoning")z?.setStepText(x.detail);else if(x.type==="step_end"&&(x.status==="passed"&&z?.setStepComplete(),Qe)){let M=N?Math.max(0,E-1):0;Qe(x.index,M,x.child_id,typeof x.ordinal=="number"&&x.id?{ordinal:x.ordinal,id:x.id}:void 0)}if(x.type==="run_end"){g=x;break}if(x.type==="error"){_=x.message??"runner error";break}}}finally{z?.setRunActive(!1)}}catch(x){_=x.message}H.diedUnexpectedly&&mt();let B=Math.round((Date.now()-w)/1e3),Q=ht(a,p,g,L,_,B);return c.recordStepRun({testmdStepIndex:l.steps[a].flatIndex,runIndex:p,totalRunDirs:Kt(g,L)}),Yt+=zn(g),tn(T,g,p,L,l.steps[a].verifies),{continueOverall:Q}}async function mr(a){if(F||e.signal?.aborted)return{failedAt:a,cancelled:!0};if(mt())return{failedAt:a,cancelled:!1};let u=l.steps[a],p=f.decisions[a];if(p.kind!=="replay")return process.stderr.write(`error: runReplayPhase invoked on a non-replay decision at step ${a}
55
- `),{failedAt:a,cancelled:!1};let y=c.nextRunIndex();ut=y;let w=Gt(a)?we??void 0:l.steps[a].unitEntryUrl,g={width:K.window_size.width,height:K.window_size.height},_=qe(Se.raw,u.config.variables,u.objective),L=Sn({step:u,decision:p,chrome:G,device:P.kind==="device"?P.device:void 0,auth:d,sessionId:c.sessionId,runIndex:y,sessionDir:c.sessionDir,windowSize:g,environmentId:er,forceNavigateUrl:P.kind==="device"?void 0:w,sessionContext:c.getContext(),variables:Object.keys(_.variables).length>0?_.variables:void 0,evidence:nn(),investigationAsync:!J.ownsLifecycle});await Xt(_.raw),Ze(a),Ye++;let N=Date.now(),E=null,T=null,j=Pt(),I={...L};delete I.run_id,At(I,{environment:m});let B=`run-${y}`;try{z?.setRunActive(!0);try{for await(let U of H.run(B,"replay",I)){if(t.onAgentEvent(U),j=fn(j,U),U.type==="step_event"&&U.event==="reasoning"?z?.setStepText(U.detail):U.type==="step_end"&&(U.status==="passed"&&z?.setStepComplete(),Qe&&Qe(U.index,0,U.child_id,typeof U.ordinal=="number"&&U.id?{ordinal:U.ordinal,id:U.id}:void 0)),U.type==="run_end"){E=U;break}if(U.type==="error"){T=U.message??"runner error";break}}!J.ownsLifecycle&&E?.status==="failed"&&on.push({exited:H.exited.then(()=>{}).catch(()=>{}),cancel:()=>{try{H?.cancel()}catch{}}})}finally{z?.setRunActive(!1)}}catch(U){T=U.message}if(H.diedUnexpectedly&&mt(),F)return{failedAt:a,cancelled:!0};let Q=Math.round((Date.now()-N)/1e3),x=ht(a,y,E,null,T,Q);c.recordStepRun({testmdStepIndex:l.steps[a].flatIndex,runIndex:y,totalRunDirs:Kt(E,null)}),tn(j,E,y,null,l.steps[a].verifies);let M=!!T||E?.status==="failed";return Po(a,M?"failed":"ok"),M||!x?{failedAt:a,cancelled:!1}:null}async function Vs(a){xo(a,l.steps.length),bt?.reset();for(let u=0;u<a;u++){let p=await dr(u);if(p?.kind==="done"){if(p.stop)return p.stop;continue}if(p?.kind==="jump"){u=p.to-1;continue}if(p?.kind==="author"){let w=l.steps[u];if(w.replayOnly)return xe(u,w.replayOnly),je(u,w.replayOnly),ae.recordStep(w,{status:"failed",duration_s:0,reason:`replay-only step @${w.replayOnly} has no recording`}),{failedAt:u,cancelled:!1};if(!(await ur(u)).continueOverall)return{failedAt:u,cancelled:!1};continue}let y=await mr(u);if(y)return y}return{failedAt:null,cancelled:!1}}let fr=async()=>{if(C||f.degradedReadonly)return!0;let a=d.basicAuth;if(!a){let g=await d.resolver.resolve(!0);g?.username&&g?.access_key&&(a={username:g.username,access_key:g.access_key},d.basicAuth=a)}if(!f.testId||!f.fromCommitId||!a)return process.stderr.write(`error: cannot acquire lock \u2014 missing required state
56
- `),!1;let u=c.sessionId,p=s.onLockConflict??l.rootGlobal.on_lock_conflict??"readonly",y=await Gn({tmsBaseUrl:b.tmsBaseUrl,testId:f.testId,fromCommitId:f.fromCommitId,newCommitId:u,basicAuth:a,onLockConflict:p}),w=y.outcome;if(w==="ok"){C=!0,f.newCommitId=u,c.log("info","MID_RUN_LOCK_ACQUIRED","Mid-run lock acquired",{test_id:f.testId}),i&&t.onLockState({phase:"acquired",scope:"mid_run"}),jt({baseUrl:Ge(b.tmsBaseUrl),testId:f.testId,auth:ze(a),lifecycle:n});let g=await js({resolved:l,decisions:f.decisions,tmsBaseUrl:b.tmsBaseUrl,newCommitId:u,basicAuth:a,mode:p,lifecycle:n,alreadyLocked:f.unitLocks,allUnits:!0});return g.outcome==="ok"?f.unitLocks.push(...g.locks):process.stderr.write(`warn: mid-run unit lock acquisition degraded (${g.outcome}) \u2014 affected units will not self-commit
57
- `),!0}if(y.outcome==="readonly"){f.degradedReadonly=!0;let g=y.reason==="base_mismatch"?"base commit mismatch":"concurrent session";return c.log("warn","MID_RUN_LOCK_READONLY","Mid-run lock unavailable; healing continues in readonly (no commit)",{test_id:f.testId,reason:y.reason}),i&&t.onLockState({phase:"conflict",scope:"mid_run",reason:"readonly"}),process.stderr.write(`[lock] mid-run ${g} \u2014 healing continues in readonly mode (no commit)
58
- `),!0}return c.log("error","MID_RUN_LOCK_CONFLICT","Mid-run lock acquisition failed",{reason:w}),i&&t.onLockState({phase:"conflict",scope:"mid_run",reason:w}),process.stderr.write(`error: mid-run lock acquisition failed (${w})
59
- `),!1},pr=async()=>{try{z?.kill(),z=null,he?.kill(),G=await Ln({config:{chrome_profile_path:V.chrome_profile??null,window_size:{width:1920,height:1080}},startUrl:et,headless:V.headless??!1,wsEndpoint:V.ws_endpoint,cdpEndpoint:V.cdp_endpoint}),he=G.instance,Jt=pn(G.cdpEndpoint);let a=G.cdpEndpoint??V.cdp_endpoint;if(a&&!V.ws_endpoint&&!V.headless&&!e.isAgent)try{z=Pn({headless:V.headless??!1,cdpEndpoint:a,chromePid:he?.process.pid})}catch(u){c.log("warn","OVERLAY_SPAWN_FAILED","Marker overlay respawn failed",{error:String(u)})}return c.log("info","BROWSER_RECYCLED","Fresh browser brought up for the replay re-attempt",{cdp_endpoint:G.cdpEndpoint}),!0}catch(a){return c.log("error","RECYCLE_FAILED","Could not bring up a fresh browser for the replay re-attempt",{error:a.message}),process.stderr.write(`error: could not recycle the browser for the replay re-attempt: ${a.message}
60
- `),!1}},gr=async()=>{if(P.kind!=="device"||P.device.target_kind!=="simulator"||P.device.no_reset===!0||!P.device.udid)return;let a=await Ar("xcrun",["simctl","keychain",P.device.udid,"reset"],{timeoutMs:3e4});a.code===0?c.log("info","SIM_KEYCHAIN_RESET","Simulator keychain reset for the replay re-attempt"):c.log("warn","SIM_KEYCHAIN_RESET_FAILED","Could not reset the simulator keychain; keychain-backed login state may survive the recycle",{error:a.stderr.trim()||a.stdout.trim()})};if(i){let a=Et();if(!a)return process.stderr.write("error: v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available.\n"),n.cleanup("marker-overlay","v16-runner not found"),n.cleanup("chrome","v16-runner not found"),await c.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:X(r),durationS:0,uploadResult:null};let u=Mr({environment:m,mode:v.mode??"testing",assertionMode:Qn,finalValidation:Xn,username:d.basicAuth?.username,accessKey:d.basicAuth?.access_key,sessionId:c.sessionId});P.kind==="device"&&await Br(u,P.device),H=new xt({env:u,runner:a,log:(E,T,j,I)=>c.log(E,T,j,I),sessionId:c.sessionId}),n.register("runner",()=>{(Tr()||e.signal?.aborted)&&(F=!0);try{H?.kill()}catch{}});let p=E=>{let T={...P.kind==="device"?{device:P.device}:{},cdp_endpoint:E.cdpEndpoint,ws_endpoint:E.wsEndpoint,width:K.window_size.width,height:K.window_size.height,headless:V.headless??!1,model:A,session_id:c.sessionId,disable_ask_user:!0};return d.basicAuth?(T.username=d.basicAuth.username,T.access_key=d.basicAuth.access_key):d.token&&(T.auth={type:"bearer",token:d.token}),T};await H.start(p(G));let y=async()=>{try{await H?.shutdown()}catch{}if(!await pr())return!1;try{return H=new xt({env:u,runner:a,log:(E,T,j,I)=>c.log(E,T,j,I),sessionId:c.sessionId}),await H.start(p(G)),!0}catch(E){return c.log("error","RECYCLE_FAILED","Could not restart the persistent runner after recycle",{error:E.message}),process.stderr.write(`error: could not restart the runner for the replay re-attempt: ${E.message}
61
- `),!1}},w=async()=>{try{await H?.shutdown()}catch{}await gr();try{return H=new xt({env:u,runner:a,log:(E,T,j,I)=>c.log(E,T,j,I),sessionId:c.sessionId}),await H.start(p(G)),P.kind==="device"&&P.device.no_reset===!0&&c.log("warn","DEVICE_RECYCLED_DIRTY","no_reset: true \u2014 the re-attempt keeps the app state the broken replay left behind"),c.log("info","DEVICE_RECYCLED","Fresh device session brought up for the replay re-attempt"),!0}catch(E){return c.log("error","RECYCLE_FAILED","Could not bring up a fresh device session for the replay re-attempt",{error:E.message}),process.stderr.write(`error: could not recycle the device session for the replay re-attempt: ${E.message}
62
- `),!1}},g=s.author===!0;g&&(In(),c.log("info","FORCE_AUTHOR_RUN","--author flag set; walker bypassed; identity kept"));let{authorBoundary:_,cancelledInPhase:L,shrinkCount:N}=await jo({decisions:f.decisions,forceAuthor:g,hasRetry:kn(s),onReplayOnlyFail:je,maxShrinks:rt.maxShrinks,runReplayPhase:Vs,session:c,accumulator:ae,acquireLockIfNeeded:fr,archiveAttempt:cr,recycleBrowser:P.kind==="web"&&he&&J.ownsLifecycle?y:P.kind==="device"&&J.ownsLifecycle?w:void 0});if(ct=N>0,dt=_,zt=N,N>0&&(c.log("info","ADAPTIVE_HEAL_TRIGGERED","Adaptive heal engaged",{shrink_count:N,final_author_boundary:_}),t.onAdaptiveHeal({shrink_count:N,final_author_boundary:_,complete_reauthor:_===0})),_===0&&N>0&&c.log("info","COMPLETE_REAUTHOR_TRIGGERED","Complete reauthor fallback",{shrink_count:N}),!L&&_>=0)for(let E=_;E<l.steps.length&&!e.signal?.aborted;E++){let T=l.steps[E],j=await dr(E);if(j?.kind==="done"){if(j.stop)break;continue}if(j?.kind==="jump"){E=j.to-1;continue}if(j?.kind==="author"&&T.replayOnly){xe(E,T.replayOnly),je(E,T.replayOnly),ae.recordStep(T,{status:"failed",duration_s:0,reason:`replay-only step @${T.replayOnly} has no recording`});break}if(mt()){ae.recordStep(T,{status:"failed",duration_s:0,reason:"v16-runner exited unexpectedly mid-session"});break}if(!ae.shouldRunFlatStep(T))continue;let I=f.decisions[E];if(I?.kind==="replay"&&I.replayOnly){let Q=await mr(E);if(Q){Q.cancelled||(xe(E,I.replayOnly),je(E,I.replayOnly));break}continue}let{continueOverall:B}=await ur(E);if(!B||F||e.signal?.aborted)break}}else{if(Ve.hasBlocks(l.steps))return process.stderr.write(`error: this test has if/else or while blocks (@if \u2026 @end-if, @while \u2026 @end-while), which run in agent mode only \u2014 re-run with --agent
63
- `),n.cleanup("marker-overlay","control-flow blocks need agent mode"),n.cleanup("chrome","control-flow blocks need agent mode"),await c.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:X(r),durationS:0,uploadResult:null};let{effectiveDecisions:a}=await import("./effective-decisions-UNE2TFVA.js"),{decideRetry:u}=await import("./replay-policy-A62KXE6Y.js"),p=kn(s),y=rt.maxShrinks,w=s.author===!0;w&&(In(),c.log("info","FORCE_AUTHOR_RUN","--author flag set; walker bypassed; identity kept"));let g=w?0:nt(f.decisions),_=0,L=null,N=P.kind==="device"?P.device.no_reset:void 0,E=0,T=()=>E++===0?N??!1:!0,j=f.decisions.filter(x=>x.kind==="replay").length,I=f.decisions.length-j,B=[];s.push&&B.push("--push"),p||B.push("--no-adaptive-heal"),w&&B.push("--author");let Q={source:r,steps:{total:f.decisions.length,replay:j,author:I},model:A,viewport:{width:K.window_size.width,height:K.window_size.height},chrome:G.cdpEndpoint??G.wsEndpoint??"managed",session:c.sessionName??"ephemeral",variables:{count:Object.keys(ie.raw).length,secrets:Object.values(ie.raw).filter(x=>x.secret).length,names:Object.keys(ie.raw)},flags:B,mode:v.mode??"testing"};for(;;){let x=c.snapshot(),M=ae.snapshot();E=0;let U=a(f.decisions,g,w);if(_>=1){let D=g===0?`\u{1FA79} Healing \u2014 full re-author, heal budget exhausted (${_}/${y})`:`\u{1FA79} Healing ${_}/${y} \u2014 replay 0..${g-1}, re-author ${g}..${f.decisions.length-1}
64
- reason: replay miss at step ${(L??0)+1}`;process.stderr.write(D+`
65
- `)}let Xe=_>=1&&g>0&&L!==null?{startIdx:0,endIdx:L,count:L}:void 0;z?.setRunActive(!0);let me=await aa({decisions:U,resolved:l,session:c,accumulator:ae,tuiConfig:K,globalConfig:Q,buildStepConfigAt:(D,le)=>{let te=rn(D,le);return P.kind==="device"&&te.device&&(te.device={...te.device,no_reset:T()}),te},buildReplayConfig:D=>{let le=f.decisions[D];if(le.kind!=="replay")throw new Error("expected replay decision at index "+D);let te=l.steps[D];return Sn({step:te,decision:le,chrome:G,device:P.kind==="device"?{...P.device,no_reset:T()}:void 0,auth:d,sessionId:c.sessionId,runIndex:c.nextRunIndex(),sessionDir:c.sessionDir,windowSize:{width:K.window_size.width,height:K.window_size.height},environmentId:er,forceNavigateUrl:P.kind==="device"?void 0:D===0?we??void 0:te.unitEntryUrl,sessionContext:c.getContext(),variables:na(Se.raw,te.config.variables,te.objective),evidence:nn()})},onAnyAuthorStep:D=>{ue=!0,lt.add(l.steps[D].flatIndex)},onCancel:()=>{ge=!0},topBannerModel:A,topBannerAuth:`${S.getActiveProfile()??"no profile"}/${m}`,spawnOpts:{environment:m,mode:v.mode??"testing",assertionMode:Qn,finalValidation:Xn,log:(D,le,te,an)=>c.log(D,le,te,an)},priorAttemptRollup:Xe,pushStepLevelDelta:(D,le)=>Xt(qe(Se.raw,D,le).raw),onSequencerStepEnd:(D,le,te,an)=>{let zs=Math.round((Date.now()-an)/1e3),Ys=D.hadError?D.reason??"runner error":null,Ws=ht(le,te,D.runEnd,D.bifurcationFlows??null,Ys,zs);return c.recordStepRun({testmdStepIndex:l.steps[le].flatIndex,runIndex:te,totalRunDirs:Kt(D.runEnd,D.bifurcationFlows)}),tn(D.evidence??Pt(),D.runEnd,te,D.bifurcationFlows,l.steps[le].verifies),U[le]?.kind==="author"&&(Yt+=zn(D.runEnd)),Ws},screenshotDispatcher:Qe,onReasoning:D=>z?.setStepText(D),onStepComplete:()=>z?.setStepComplete(),onSpawnStart:D=>{ut=D},host:t});if(z?.setRunActive(!1),me.cancelled){n.cleanup("marker-overlay","user cancelled run"),n.cleanup("chrome","user cancelled run");break}if(me.failedAt===null)break;let kt=f.decisions[me.failedAt],Fe=u({failedAt:me.failedAt,shrinkCount:_,hasRetry:p,maxShrinks:y,failedAtReplayOnly:kt?.kind==="replay"?kt.replayOnly:void 0});if(Fe.kind==="fail"){Fe.replayOnly&&(xe(me.failedAt,Fe.replayOnly),je(me.failedAt,Fe.replayOnly));break}if(!C&&!await fr()||P.kind==="web"&&he&&J.ownsLifecycle&&!await pr())break;P.kind==="device"&&J.ownsLifecycle&&await gr(),await cr(me.failedAt),c.rollback(x),ae.rollback(M),Fe.kind==="complete-reauthor"?g=0:(g=Fe.newAuthorBoundary,_++),ct=!0,c.log("info","RETRY_TRIGGERED","Retry loop triggered (TTY)",{shrink_count:_,failed_at:L}),g===0&&c.log("info","COMPLETE_REAUTHOR_TRIGGERED","Complete reauthor fallback (TTY)",{shrink_count:_}),L=me.failedAt}dt=g,zt=_}let ee=ae.finalize(),Ce=Math.round((Date.now()-ar)/1e3),Ks={session:c,resolvedAuth:d,chromeResult:G,chromeInstance:he??null,testId:c.testId??null,preparedVariables:ie,variableIds:ft,globalContext:or,localContext:sr,tuiConfig:K,env:m,localMode:!!s.local},hr=!1,br=!1,yr=!1,sn=!1,vr=async(a={})=>{if(!O)return!1;if(J.ownsLifecycle?hr:yr)return!0;try{let u=await Jt(),p=Hn(ue)==="replay",y=Be(r),w=pe(c.sessionDir,"execution.json"),g=eo(O.packTestDir,p?[y,w]:[w,y],(I,B,Q,x)=>c.log(I,B,Q,x)),{ids:_,linear:L}=g?no(O.packTestDir):{ids:[],linear:!0},{steps:N,tail:E,unjoined:T}=to(W.steps,_,p,L);g?T?c.log("warn","SKIPPED_TAIL_UNJOINED","Executed records don't align with the authored blob \u2014 skipped tail withheld",{executed:W.steps.length,leaves:_.length}):E.length>0&&c.log("info","SKIPPED_TAIL_APPENDED","Unexecuted authored actions recorded as skipped",{count:E.length}):c.log("warn","SKIPPED_TAIL_NO_BLOB","No auteur blob in pack \u2014 unexecuted actions cannot be recorded as skipped",{});let j=await W.writeResult({steps:[...N,...E],heal:{shrinkCount:zt,authorBoundary:dt,totalSteps:f.decisions.length,forced:s.author===!0,creditsConsumed:Yt},spawns:Re.length?Re:[{resultCode:null}],tags:l.rootGlobal.tags,externalIdInput:{execution_id:O.executionId,session_id:c.sessionId,commit_id:p?f.fromCommitId??c.sessionId:c.sessionId,test_id:f.testId??c.testId??void 0,testcase_id:a.testcaseId||f.testcaseId||c.testcaseId||void 0,project_id:q??void 0,folder_id:ve??void 0,org_id:c.orgId!=null?String(c.orgId):void 0,session_name:c.sessionName??tt(r),user_name:c.userName??void 0,user_email:c.userEmail??void 0,sharable_link:Qo(ne(m).testManagerUiUrl,q,a.testcaseId??f.testcaseId??c.testcaseId,a.shareId)},runnerEnv:Wr({cdpBrowser:u,resolution:lr,runnerEnvironment:De,deviceName:Ie.deviceName,deviceModel:Ie.modelIdentifier,pixelResolution:O?await Yr(O.packTestDir):void 0}),intentEnv:Vr(A,De,J.ownsLifecycle?void 0:Hn(ue)),durationMs:Date.now()-ar,log:(I,B,Q,x)=>c.log(I,B,Q,x)});if(!J.ownsLifecycle)return await Gr(W.pack,O.testId,pe(c.sessionDir,"tui.log"),{requireRealLog:!!De?.native_platform,appiumMarks:W.appiumMarks}),yr=!0,c.log("info","EVIDENCE_RESULT_WRITTEN","Member result.yaml written",{execution_id:O.executionId,verdict:j}),!0;if(!br)try{await Eo(gn(process.cwd()),B=>c.log("warn","SYNC_BEHIND",B,{}));let I=Zr({cwd:process.cwd(),members:[{path:r,verdict:j,executionId:O.executionId,startedAt:new Date().toISOString(),acs:Qr(W.steps),mode:"testmd",local:!!s.local}]});br=!0;for(let B of I.warnings)c.log("warn","EXEC_SYNC",B,{});I.synced>0&&c.log("info","EXEC_SYNC",`context sync: ${I.synced} fact(s), ${I.superseded} supersession(s)`,{})}catch(I){c.log("warn","EXEC_SYNC",`exec-sync failed: ${I instanceof Error?I.message:String(I)}`,{})}try{let I=Xr(W.pack,gn(process.cwd()));I.status==="skipped"&&c.log("warn","EVIDENCE_COVERAGE_SKIPPED",`coverage/usecases.yaml not written: ${I.reason}`,{})}catch(I){c.log("warn","EVIDENCE_COVERAGE_SKIPPED","coverage writer threw",{error:String(I)})}return await zr({executionId:O.executionId,testId:O.testId,saved:!0,runKind:Hn(ue),verdict:j,outputStemDir:X(r),cwd:o,packDir:W.pack,tuiLogPath:pe(c.sessionDir,"tui.log"),expectStatusDisagrees:(s.bugDetection??K.bug_detection)==="continue",log:(I,B,Q,x)=>c.log(I,B,Q,x),surface:"testmd",requireRealLog:!!De?.native_platform,appiumMarks:W.appiumMarks}),hr=!0,c.log("info","EVIDENCE_SEALED","Evidence pack sealed",{execution_id:O.executionId,verdict:j}),!0}catch(u){return c.log("warn","EVIDENCE_SEAL_FAILED","Evidence pack seal failed",{error:String(u)}),!1}},yt=Oe&&(C||f.isFirstRun)&&!f.degradedReadonly,Hs=async()=>{if(!d.basicAuth)return null;let a=ne(m),u=(ue||s.push===!0)&&!ge,p=(C||f.isFirstRun)&&!ge&&ee.overallStatus==="passed"&&!f.degradedReadonly;c.log("info","PIPELINE_GATE_STATE","Derived gate state (finalize)",{phase:"finalize",shouldUploadArtifacts:Oe,shouldUploadPipeline:yt,shouldReplaceLocalOutput:u,shouldCommit:p,lockHeld:C,anyAuthorStepRan:ue,cancelled:ge,overallStatus:ee.overallStatus});let y=ks({mobile:P.kind==="device",session:c,env:m,auth:d,variables:ie,variableIds:ft,projectId:q,folderId:ve,totalSteps:ee.outcomes.length,totalDuration:Ce,screenshotExtMap:We?.getExtMap(),codeExport:Ss({codeExport:s.codeExport,codeLanguage:s.codeLanguage,skipCodeValidation:s.skipCodeValidation},K.code_export),onProgress:()=>{},log:(g,_,L,N)=>c.log(g,_,L,N),shouldUploadArtifacts:yt,shouldReplaceLocalOutput:u,shouldCommit:p,isFirstRun:f.isFirstRun,resolvedTest:l,sourcePath:r,stepRunRecords:c.getStepRunRecords(),authoredFlatIdx:[...lt],blockOutcomes:bt?.outcomes(),unitLocks:f.unitLocks,outcomes:ee.outcomes,overallStatus:ee.overallStatus,fromCommitId:f.fromCommitId,startedISO:pt,durationS:Ce,tmsIds:{testId:f.testId??c.testId??void 0,testcaseId:f.testcaseId??c.testcaseId??void 0,projectId:q??void 0,folderId:ve??void 0,orgId:c.orgId??void 0,sessionName:c.sessionName??tt(r)},tmsBaseUrl:b.tmsBaseUrl,testId:f.testId??void 0,newCommitId:f.newCommitId??void 0,basicAuth:d.basicAuth??void 0,decisions:f.decisions,wantsPush:s.push===!0,retryTriggered:ct,forceAuthor:s.author===!0,commitBox:qt,testmdSync:s.testmdSync!==!1,onAgentEvent:g=>t.onAgentEvent(g),evidence:O&&J.ownsLifecycle?{executionId:O.executionId,packTestDir:O.packTestDir,sealedPackPath:W.pack,cwd:o,runIndices:gt,sealFn:vr}:void 0,evidenceRead:O&&!J.ownsLifecycle?{packTestDir:O.packTestDir,runIndices:gt}:void 0,authoredExecutionPath:ue?void 0:Be(r)});f.newCommitId!=null&&(y.skipTmsFinalize=!0);let w=new wo(y);return i?await w.execute():await t.runUpload(w,g=>{if(g.testcaseId&&g.shareId&&q)return Ut(a.testManagerUiUrl,q,g.testcaseId,g.shareId)})};O&&await Jt(),H&&(await H.shutdown(),n.cleanup("runner","test.md run complete"));let de=await ps(Ks,{performUpload:Hs,runCleanup:()=>{n.cleanup("chrome","test.md run complete")},log:(a,u,p,y)=>c.log(a,u,p,y)},{overallStatus:ee.overallStatus,outcomes:ee.outcomes,sourcePath:r,title:l.rootTitle,rootSteps:l.rootSteps,startedISO:pt,durationS:Ce,localMode:!!s.local,skipLocalWrites:!0,mobile:P.kind==="device"});J.ownsLifecycle&&yt&&de.uploadResult?.success&&(sn=!0);let wr=await vr({testcaseId:de.uploadResult?.testcaseId,shareId:de.uploadResult?.shareId}),kr=s.evidencePublish===!1,_r=J.ownsLifecycle&&!!O&&!!d.basicAuth&&xs({shouldUploadArtifacts:Oe,lockHeld:C,isFirstRun:f.isFirstRun,sealed:wr,testId:f.testId});if(_r&&kr)c.log("info","EVIDENCE_PUBLISH_SKIPPED","Replay evidence publish skipped (--no-evidence-publish)",{execution_id:O.executionId}),process.stderr.write(`info: evidence publish skipped (--no-evidence-publish)
66
- `);else if(kr&&(C||f.isFirstRun))process.stderr.write(`note: --no-evidence-publish has no effect on author/commit runs
67
- `);else if(_r){let a=d.basicAuth,u=O,p=q,y=await Ps({controller:new Ee(b.controllerBaseUrl,{username:a.username,accessKey:a.access_key}),tms:new Ct(b.tmsBaseUrl,d.resolvedCreds?.username??a.username,d.resolvedCreds?.access_key??a.access_key),testId:f.testId,sessionId:c.sessionId,executionId:u.executionId,sealedPackPath:W.pack,projectId:p});sn=y.ok,y.ok?c.log("info","EVIDENCE_INGESTED","Replay evidence uploaded and ingested",{execution_id:u.executionId,project_id:p}):(c.log("warn","EVIDENCE_PUBLISH_FAILED","Replay evidence publish failed",{execution_id:u.executionId,stage:y.stage,error:y.error}),process.stderr.write(` \u26A0 evidence publish failed (${y.stage}): ${y.error}
68
- `)),t.onAgentEvent({type:"test_md_evidence_ingest",status:y.ok?"ok":"failed",evidence_id:u.executionId,...y.ok?{}:{stage:y.stage}})}if($=!0,await sa(r,f,c,ee.outcomes,ee.overallStatus,pt,Ce,de.uploadResult,K,s,{resolvedAuth:d,tmsBaseUrl:b.tmsBaseUrl},C,ge,qt.committed),f.isFirstRun&&s.testmdSync!==!1)try{let a=be(r);if(co({shouldUploadPipeline:yt,uploadSucceeded:!!de.uploadResult?.success,metaCommitId:a?.commit_id,metaTestId:a?.test_id})){let u=await Lt({sourcePath:r,testId:a.test_id,sessionId:c.sessionId,commitId:a.commit_id,controller:new Ee(b.controllerBaseUrl,{username:d.basicAuth.username,accessKey:d.basicAuth.access_key})});u.ok?c.log("info","BUNDLE_SYNC_OK","testmd bundle pushed",{commit_id:a.commit_id,bytes:u.bytes}):(c.log("warn","BUNDLE_SYNC_FAILED","testmd bundle sync failed",{commit_id:a.commit_id,stage:u.stage,error:u.error}),process.stderr.write(` \u26A0 bundle sync failed (${u.stage}): ${u.error}
69
- `)),t.onAgentEvent({type:"test_md_bundle_sync",status:u.ok?"ok":"failed",commit_id:a.commit_id,path:r,...u.ok?{bytes:u.bytes}:{stage:u.stage}})}}catch(a){c.log("warn","BUNDLE_SYNC_FAILED","testmd bundle sync threw",{error:a instanceof Error?a.message:String(a)})}else f.isFirstRun&&c.log("info","BUNDLE_SYNC_SKIPPED","testmd bundle sync skipped",{reason:"flag"});let Ir=ne(m),vt=de.uploadResult?.testcaseId,wt=vt&&de.uploadResult?.shareId&&q?Ut(Ir.testManagerUiUrl,q,vt,de.uploadResult.shareId):void 0,qs=l.unitFiles.filter(a=>a.file!==l.rootPath).map(a=>{let u=l.steps.filter(g=>g.owningFile===a.file),p=u.filter(g=>lt.has(g.flatIndex)).length,w=(a.kind==="test"?be(a.file):null)?.commit_id===c.sessionId;return{path:a.file,kind:a.kind,replayed:u.length-p,authored:p,committed:w,...w?{commit_id:c.sessionId}:{}}}),Sr={overallStatus:ee.overallStatus,durationS:Ce,decisions:f.decisions,outcomes:ee.outcomes,cancelled:ge,retryTriggered:ct,lockHeld:C,anyAuthorStepRan:ue,isFirstRun:f.isFirstRun,wantsPush:s.push===!0,uploadResult:de.uploadResult,shouldUploadArtifacts:Oe,shouldReplaceLocalOutput:ue&&!ge,shouldCommit:(C||f.isFirstRun)&&!ge&&ee.overallStatus==="passed"&&!f.degradedReadonly,committed:qt.committed,shareUrl:wt,imports:qs},{buildSummaryEvent:Gs}=await import("./SummaryBox-N2B6DUDD.js");if(i?t.onAgentEvent(Gs(Sr)):await t.onSummary(Sr),!i){let a=vt&&q?Zo(Ir.testManagerUiUrl,q,vt):void 0;await t.onLinks({recordedTestPath:r,outputDir:X(r),shareableLink:wt,testCaseLink:a,codeExportDir:de.uploadResult?.codeExportDir})}if(J.ownsLifecycle&&W&&wr&&!e.suppressEvidenceOffer){let{offerEvidenceView:a}=await import("./evidence-XWR32HWP.js");await a({packPath:W.pack,env:m,isTTY:!i&&!ge&&!!process.stdin.isTTY&&!!process.stderr.isTTY,log:u=>process.stderr.write(u+`
70
- `)})}return t.onAgentEvent({type:"test_md_done",overall_status:ee.overallStatus,duration_s:Ce,session_id:c.sessionId,...wt?{share_url:wt}:{}}),{overallStatus:ee.overallStatus,exitCode:ee.overallStatus==="passed"?0:1,outputDir:X(r),durationS:Ce,uploadResult:de.uploadResult,anyAuthorStepRan:ue,resultCode:qr(Re),...on.length?{pendingInvestigations:on}:{},ownPack:J.ownsLifecycle?As({executionId:O?.executionId,testId:f.testId??O?.testId,testcaseId:de?.uploadResult?.testcaseId,commitId:c.sessionId,published:sn}):void 0}}finally{!$&&(C||f.unitLocks.length>0)&&await ia(f,c,C,{resolvedAuth:d,tmsBaseUrl:b.tmsBaseUrl})}}function ea(e){if((e.env??process.env).KANE_CLI_MODE==="hyperexecute")return{refuse:!1};let t=ko({globalDir:e.globalDir,localDir:pe(e.cwd,".testmuai","variables"),file:e.opts.variablesFile,inline:e.opts.variables}),n=_o(e.resolved,t,{authorFrom:e.authorFrom,produced:e.produced});return n.length===0?{refuse:!1}:{refuse:!0,text:So(n,{cwd:e.cwd,entryFile:qn(e.resolved.rootPath)}),event:Ro(n,{cwd:e.cwd})}}function ta(e,t){let n={...e,...t},r=Object.keys(n).length>0?Ue(n,""):{variables:{},objective:"",keyMap:{}};return{raw:n,auteur:r.variables,auteurObjective:"",secretEntries:Object.entries(n).filter(([,o])=>o.secret),nonSecretEntries:Object.entries(n).filter(([,o])=>!o.secret)}}function qe(e,t,n){let r={...e,...t??{}};if(Object.keys(r).length===0)return{raw:r,variables:{},objective:n};let o=Ue(r,n);return{raw:r,variables:us(o.variables,o.objective),objective:o.objective}}function na(e,t,n){let r=qe(e,t,n).variables;return Object.keys(r).length>0?r:void 0}function Os(e,t){let n=new Set(Ht),r={...e};for(let[o,s]of Object.entries(t))n.has(o)||o!=="variables"&&s!==void 0&&e[o]===void 0&&(r[o]=s);return r}function ra(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}async function oa(e,t,n,r,o,s){let i=mo(t);Ao(t,i);let h=Ne(e),l=Ji(h)?JSON.parse(Ds(h,"utf8")):null,d=l?.testcase_id,v=l?.test_id,m=l?.commit_id,b=n.push===!0,k=n.author===!0;b&&!d&&process.stderr.write(`[--push] no meta.json yet \u2014 flag is a no-op on first run
71
- `);let A=r.resolvedAuth.basicAuth;if(!A){let se=await r.resolvedAuth.resolver.resolve(!0);se?.username&&se?.access_key&&(A={username:se.username,access_key:se.access_key},r.resolvedAuth.basicAuth=A)}let S=!!A,R=!n.local&&S&&v!=null&&m!=null&&d!=null,c=R&&(Ot(i)||b||k),F=uo(t,i);if(F.length>0)return process.stderr.write(`error: replay-only step(s) cannot be replayed \u2014 the agent cannot author them, so the run will not start:
72
- `+F.map(oe=>` step ${oe.flatIndex} "${oe.heading}" @${oe.kind} \u2014 ${oe.reason} (${oe.file})`).join(`
73
- `)+`
74
- Regenerate the test from KaneAI, or drop the marker to let the agent author the step.
75
- `),{resolved:t,decisions:i,testId:v,testcaseId:d,fromCommitId:m,newCommitId:null,isFirstRun:!1,hasAuth:S,canLock:R,lockAcquired:!1,unitLocks:[],degradedReadonly:!1,abort:{exitCode:2}};if(b&&!R)return process.stderr.write(`error: --push requires authenticated credentials for the lock API. Run 'kane-cli login' (OAuth) or pass --username/--access-key inline.
76
- `),{resolved:t,decisions:i,testId:v,testcaseId:d,fromCommitId:m,newCommitId:null,isFirstRun:!1,hasAuth:S,canLock:R,lockAcquired:!1,unitLocks:[],degradedReadonly:!1,abort:{exitCode:2}};if(k&&!S)return process.stderr.write(`error: --author requires authenticated credentials for the TMS API. Run 'kane-cli login' (OAuth) or pass --username/--access-key inline.
77
- `),{resolved:t,decisions:i,testId:v,testcaseId:d,fromCommitId:m,newCommitId:null,isFirstRun:!1,hasAuth:S,canLock:R,lockAcquired:!1,unitLocks:[],degradedReadonly:!1,abort:{exitCode:2}};let f=null,C=!1,$=!1;if(c){f=o;let oe=n.onLockConflict??t.rootGlobal.on_lock_conflict??"readonly",{outcome:se}=await Gn({tmsBaseUrl:r.tmsBaseUrl,testId:v,fromCommitId:m,newCommitId:f,basicAuth:A,onLockConflict:oe});if(se==="ok")C=!0,jt({baseUrl:Ge(r.tmsBaseUrl),testId:v,auth:ze(A),lifecycle:s});else{if(se==="abort")return{resolved:t,decisions:i,testId:v,testcaseId:d,fromCommitId:m,newCommitId:null,isFirstRun:!1,hasAuth:S,canLock:R,lockAcquired:!1,unitLocks:[],degradedReadonly:!1,abort:{exitCode:2}};f=null,$=!0,k&&process.stderr.write(`[lock] --author: re-authoring locally in readonly mode (not committed); run again with --push once the playground is free
78
- `)}}let _e=[],re=c&&!C;if(!n.local&&S&&!re){let oe=n.onLockConflict??t.rootGlobal.on_lock_conflict??"readonly",se=await js({resolved:t,decisions:i,allUnits:k,tmsBaseUrl:r.tmsBaseUrl,newCommitId:f??o,basicAuth:A,mode:oe,lifecycle:s});if(se.outcome==="ok")_e=se.locks;else{if(C&&v&&m&&f&&await at(r,v,m,f),fe(),se.outcome==="abort")return{resolved:t,decisions:i,testId:v,testcaseId:d,fromCommitId:m,newCommitId:null,isFirstRun:d==null,hasAuth:S,canLock:R,lockAcquired:!1,unitLocks:[],degradedReadonly:!1,abort:{exitCode:2}};process.stderr.write(`[lock] imported-unit conflict \u2014 whole run degrades to readonly (no commits, no uploads)
79
- `),f=null,C=!1,$=!0}}return{resolved:t,decisions:i,testId:v,testcaseId:d,fromCommitId:m,newCommitId:f,isFirstRun:d==null,hasAuth:S,canLock:R,lockAcquired:C,unitLocks:_e,degradedReadonly:$}}async function js(e){let t=new Set(e.resolved.steps.filter((r,o)=>e.decisions[o]?.kind==="author").map(r=>r.owningFile)),n=[];for(let r of e.resolved.unitFiles){if(r.kind!=="test"||r.file===e.resolved.rootPath||!e.allUnits&&!t.has(r.file)||e.alreadyLocked?.some(i=>i.file===r.file))continue;let o=be(r.file);if(!o?.test_id||!o?.commit_id)continue;let{outcome:s}=await Gn({tmsBaseUrl:e.tmsBaseUrl,testId:String(o.test_id),fromCommitId:String(o.commit_id),newCommitId:e.newCommitId,basicAuth:e.basicAuth,onLockConflict:e.mode});if(s==="ok"){n.push({file:r.file,testId:String(o.test_id),fromCommitId:String(o.commit_id)}),jt({baseUrl:Ge(e.tmsBaseUrl),testId:String(o.test_id),auth:ze(e.basicAuth),lifecycle:e.lifecycle});continue}for(let i of n)await Pe({baseUrl:Ge(e.tmsBaseUrl),testId:i.testId,body:{commitId:e.newCommitId,fromCommitId:i.fromCommitId},auth:ze(e.basicAuth)}),fe(i.testId);return{outcome:s,locks:[]}}return{outcome:"ok",locks:n}}function Ge(e){return`${e}/kane-cli/v1`}function ze(e){return{username:e.username,accessKey:e.access_key}}async function Gn(e){let t=Ge(e.tmsBaseUrl),n=ze(e.basicAuth),r={baseUrl:t,testId:e.testId,fromCommitId:e.fromCommitId,newCommitId:e.newCommitId,auth:n},o=await Cn(r);if(o.ok)return{outcome:"ok"};if(!(o.reason==="concurrent"||o.reason==="base_mismatch"))return process.stderr.write(`[lock] acquire failed: ${o.reason} (HTTP ${o.httpStatus}): ${o.message}
80
- `),{outcome:"abort"};let i=o.reason,h=o.reason==="concurrent"?"concurrent session":"base commit mismatch (pull latest)";if(e.onLockConflict==="fail")return process.stderr.write(`[lock] ${h}; aborting (--on-lock-conflict fail)
81
- `),{outcome:"abort"};if(e.onLockConflict==="wait"){if(o.reason==="base_mismatch")return process.stderr.write(`[lock] base commit mismatch \u2014 pull latest; aborting
82
- `),{outcome:"abort"};for(;;){process.stderr.write(`[lock] waiting (concurrent session)...
83
- `),await new Promise(d=>setTimeout(d,3e4));let l=await Cn(r);if(l.ok)return{outcome:"ok"};if(l.reason!=="concurrent")return process.stderr.write(`[lock] wait drifted to ${l.reason} (HTTP ${l.httpStatus}): ${l.message}; aborting
84
- `),{outcome:"abort"}}}return process.stderr.write(`[lock] ${h} \u2014 running in readonly mode (no commit)
85
- `),{outcome:"readonly",reason:i}}async function sa(e,t,n,r,o,s,i,h,l,d,v,m,b,k){let{decisions:A,testId:S,testcaseId:R,fromCommitId:c,newCommitId:F}=t,f=o==="passed";if(!k){let C=b?"cancelled":f?"commit did not land":o;m&&S&&c&&F&&(process.stderr.write(`[lock] run not committed (${C}); discarding playground lock
86
- `),await at(v,S,c,F));for(let $ of t.unitLocks)await at(v,$.testId,$.fromCommitId,F??n.sessionId);fe();return}fe()}async function ia(e,t,n,r){let o=e.newCommitId??t.sessionId,s=e.unitLocks.length;process.stderr.write(`[lock] run exited before finalize; discarding playground lock${s?` + ${s} unit lock${s===1?"":"s"}`:""}
87
- `);try{t.log("warn","LOCKS_RELEASED_EARLY_EXIT","Run exited before finalize; discarding held playground locks",{test_id:e.testId??null,unit_locks:s})}catch{}try{n&&e.testId&&e.fromCommitId&&await at(r,e.testId,e.fromCommitId,o);for(let i of e.unitLocks)await at(r,i.testId,i.fromCommitId,o)}finally{fe()}}async function at(e,t,n,r){let o=e.resolvedAuth.basicAuth;if(!o){let i=await e.resolvedAuth.resolver.resolve(!0);i?.username&&i?.access_key&&(o={username:i.username,access_key:i.access_key},e.resolvedAuth.basicAuth=o)}if(!o)return;let s=await Pe({baseUrl:Ge(e.tmsBaseUrl),testId:t,body:{commitId:r,fromCommitId:n},auth:ze(o)});s.ok||process.stderr.write(`warn: discardLock failed: ${s.reason} (HTTP ${s.httpStatus}): ${s.message}
88
- `)}async function aa(e){let t=null,n=!1,r=0,o=-1,s=-1,i=0,h=async l=>{if(l&&l.status==="failed")return r>0&&e.decisions[r-1].kind==="replay"&&(t=r-1),null;for(;r<e.decisions.length&&!e.accumulator.shouldRunFlatStep(e.resolved.steps[r]);)r++;if(r>=e.decisions.length)return null;let d=e.decisions[r],v=e.resolved.steps[r],m=r;r++;let b=e.session.nextRunIndex();o=m,s=b,i=Date.now(),e.onSpawnStart?.(b),d.kind==="author"&&e.onAnyAuthorStep(m),await e.pushStepLevelDelta(v.config.variables,v.objective);let k=d.kind==="replay"?e.buildReplayConfig(m):e.buildStepConfigAt(m,b),A=d.kind==="replay"?"md5-match":d.reason,S=v.config??{},R={};for(let[c,F]of Object.entries(S))F!=null&&c!=="variables"&&c!=="assurance"&&(R[c]=F);return{config:k,banner:{stepLabel:`Step ${m+1}/${e.decisions.length}`,objective:ra(v.objective,100)},mode:d.kind,modeReason:A,perStepOverrides:Object.keys(R).length>0?R:void 0}};return await e.host.runSteps({topBanner:{model:e.topBannerModel,auth:e.topBannerAuth},globalConfig:e.globalConfig,getNextStep:h,onStepEnd:l=>(l.status==="failed"&&o>=0&&e.decisions[o]?.kind==="replay"&&(t=o),e.onSequencerStepEnd(l,o,s,i)),onAllComplete:()=>{},onCancel:()=>{n=!0,e.onCancel()},spawnOpts:e.spawnOpts,priorAttemptRollup:e.priorAttemptRollup,screenshotDispatcher:e.screenshotDispatcher,onReasoning:e.onReasoning,onStepComplete:e.onStepComplete}),{failedAt:t,cancelled:n}}export{_s as a,qo as b,Go as c,Nt as d,Wa as e,rs as f,Pn as g,Ca as h,Ko as i,Ho as j,xn as k,zo as l,Yo as m,Ut as n,Qo as o,Zo as p,Ln as q,os as r,sl as s,il as t,al as u,On as v,Ke as w,us as x,ms as y,fs as z,jn as A,ks as B,Ss as C,Rs as D,Cs as E,Es as F,Vn as G,Rc as H,Ps as I,Hn as J,qd as K,ta as L,qe as M,na as N,Os as O};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{h as a}from"./chunk-BJYGWXVP.js";import"./chunk-NOLYYHVG.js";import"./chunk-B2ZGG7WM.js";import"./chunk-UR6MHSHU.js";export{a as installPlugin};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-MNE5VMHT.js";import"./chunk-RFHMDQXZ.js";import"./chunk-BAKJPQGU.js";import"./chunk-OH2NSBO6.js";import"./chunk-RZ4F3BHX.js";import"./chunk-IQ7NGOAT.js";import"./chunk-B2ZGG7WM.js";import"./chunk-UR6MHSHU.js";export{a as LoginFlow};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as r,e as o,g as s,i as n}from"./chunk-L4M7753M.js";import"./chunk-B2ZGG7WM.js";import"./chunk-UR6MHSHU.js";import{join as a}from"path";function u(e){if((e.env??process.env).KANE_CLI_MODE==="hyperexecute")return{refuse:!1};let l=r({globalDir:e.globalDir,localDir:a(e.cwd,".testmuai","variables"),file:e.opts.variablesFile,inline:e.opts.variables}),i;try{i=e.opts.sessionContext?JSON.parse(e.opts.sessionContext):void 0}catch{i=void 0}let t=s(e.objective,l,{file:o,step:1},n(i));return t.length===0?{refuse:!1}:{refuse:!0,rows:t}}export{u as objectiveVariableGate};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a,b,c}from"./chunk-IICQ5KRD.js";import"./chunk-PDXZROJM.js";import"./chunk-CGT4NFQN.js";import"./chunk-VNFCX2SH.js";import"./chunk-7O54QURK.js";import"./chunk-5GUD3CIH.js";import"./chunk-WILT62DP.js";import"./chunk-YMLC55J4.js";import"./chunk-EHN5HTUD.js";import"./chunk-22QIVSQR.js";import"./chunk-IE3OO5GI.js";import"./chunk-CH273NAE.js";import"./chunk-NBXYL2JT.js";import"./chunk-LBNADEQN.js";import"./chunk-VZ7KXRXB.js";import"./chunk-P7YZ3PU3.js";import"./chunk-GP7WD4UY.js";import"./chunk-JQW2QFSX.js";import"./chunk-3N6IAVD5.js";import"./chunk-FQNQVC5O.js";import"./chunk-AKX4VRRR.js";import"./chunk-UD7KKHPW.js";import"./chunk-3BHRGHIZ.js";import"./chunk-BPMSNGXQ.js";import"./chunk-MMBBQ4OZ.js";import"./chunk-WBHSPN55.js";import"./chunk-MSGW4JDG.js";import"./chunk-4JOD47QI.js";import"./chunk-OH2NSBO6.js";import"./chunk-DHJSM5DT.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import"./chunk-B2ZGG7WM.js";import"./chunk-UR6MHSHU.js";export{c as UploadPipeline,b as packPresignEntry,a as readPackForUpload};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{h as a,i as b,j as c,k as d,l as e,m as f}from"./chunk-6F6YI3ZG.js";import"./chunk-3BHRGHIZ.js";import"./chunk-JJJSDDQ2.js";import"./chunk-RQLU4NDG.js";import"./chunk-MMBBQ4OZ.js";import"./chunk-WBHSPN55.js";import"./chunk-MSGW4JDG.js";import"./chunk-TZXXJWHA.js";import"./chunk-RSSOJ3L2.js";import"./chunk-5EOX4MEY.js";import"./chunk-AC7BPO4X.js";import"./chunk-TAOHYWEO.js";import"./chunk-Z7S3IWUX.js";import"./chunk-4JOD47QI.js";import"./chunk-RZ4F3BHX.js";import"./chunk-B2ZGG7WM.js";import"./chunk-UR6MHSHU.js";export{a as MobileHostUnsupportedError,b as MobilePreflightError,c as PACKAGE_ID_REJECTED,e as isInstallablePath,f as prepareTarget,d as toAppSpec};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as a,c as b,d as c,e as d,f as e}from"./chunk-RQLU4NDG.js";import"./chunk-MMBBQ4OZ.js";import"./chunk-WBHSPN55.js";import"./chunk-MSGW4JDG.js";import"./chunk-Z7S3IWUX.js";import"./chunk-4JOD47QI.js";import"./chunk-RZ4F3BHX.js";import"./chunk-B2ZGG7WM.js";import"./chunk-UR6MHSHU.js";export{d as discoverAll,a as knownPlatforms,c as providerFor,b as registeredPlatforms,e as resolveTarget};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{f as a}from"./chunk-2BFXT7VQ.js";import"./chunk-3MSXQU2C.js";import"./chunk-KOPP4CJW.js";import"./chunk-K7K23DIQ.js";import"./chunk-WR42Q3HU.js";import"./chunk-NBMLBCJ3.js";import"./chunk-ZZTZJPT2.js";import"./chunk-LNV7C2YO.js";import"./chunk-6LGED4FC.js";import"./chunk-C74ABM24.js";import"./chunk-H6TNBKGR.js";import"./chunk-66MOZKD2.js";import"./chunk-YLQHY4A7.js";import"./chunk-ZA4M4O7E.js";import"./chunk-ZWHPIR2Z.js";import"./chunk-JKX57HA7.js";import"./chunk-WD52ZNQY.js";import"./chunk-QPUVOVD7.js";import"./chunk-Q7XBMBMR.js";import"./chunk-O6U2HU5M.js";import"./chunk-PGU64EWQ.js";import"./chunk-BHSHGWBL.js";import"./chunk-S3DAAAE5.js";import"./chunk-SX56MVUO.js";import"./chunk-IICQ5KRD.js";import"./chunk-PDXZROJM.js";import"./chunk-53MPG2J3.js";import"./chunk-L4M7753M.js";import"./chunk-IQ7GPETF.js";import"./chunk-CGT4NFQN.js";import"./chunk-VNFCX2SH.js";import"./chunk-7O54QURK.js";import"./chunk-5GUD3CIH.js";import"./chunk-WILT62DP.js";import"./chunk-YMLC55J4.js";import"./chunk-EHN5HTUD.js";import"./chunk-22QIVSQR.js";import"./chunk-IE3OO5GI.js";import"./chunk-CH273NAE.js";import"./chunk-3SPOJWRA.js";import"./chunk-DA57DXCF.js";import"./chunk-M7DN6FO3.js";import"./chunk-RH6KFHJB.js";import"./chunk-KN65CUNT.js";import"./chunk-NBXYL2JT.js";import"./chunk-LBNADEQN.js";import"./chunk-VZ7KXRXB.js";import"./chunk-GESG672R.js";import"./chunk-GPIXV7AV.js";import"./chunk-KOL6ZWOQ.js";import"./chunk-X74PP5NJ.js";import"./chunk-5Y2G4NC7.js";import"./chunk-P7YZ3PU3.js";import"./chunk-TDPWFYTJ.js";import"./chunk-O5AS2ZIX.js";import"./chunk-4PMZ5FCD.js";import"./chunk-2YEHV2CX.js";import"./chunk-5LJRZI7S.js";import"./chunk-BKM2LWU2.js";import"./chunk-4BBDKWM3.js";import"./chunk-GP7WD4UY.js";import"./chunk-JQW2QFSX.js";import"./chunk-3N6IAVD5.js";import"./chunk-FQNQVC5O.js";import"./chunk-AKX4VRRR.js";import"./chunk-UD7KKHPW.js";import"./chunk-6F6YI3ZG.js";import"./chunk-3BHRGHIZ.js";import"./chunk-WOA7VCGA.js";import"./chunk-YHR2YAN5.js";import"./chunk-YCCUBQY4.js";import"./chunk-RBHQXWR7.js";import"./chunk-SGHP44WS.js";import"./chunk-BPMSNGXQ.js";import"./chunk-VE3SUJMA.js";import"./chunk-MNE5VMHT.js";import"./chunk-RFHMDQXZ.js";import"./chunk-JJJSDDQ2.js";import"./chunk-RQLU4NDG.js";import"./chunk-MMBBQ4OZ.js";import"./chunk-WBHSPN55.js";import"./chunk-MSGW4JDG.js";import"./chunk-TZXXJWHA.js";import"./chunk-RSSOJ3L2.js";import"./chunk-5EOX4MEY.js";import"./chunk-AC7BPO4X.js";import"./chunk-TAOHYWEO.js";import"./chunk-QJ5O27SJ.js";import"./chunk-LL5DQO6V.js";import"./chunk-OO5GMBVI.js";import"./chunk-Z7S3IWUX.js";import"./chunk-4JOD47QI.js";import"./chunk-N7ZRF5K3.js";import"./chunk-BAKJPQGU.js";import"./chunk-OH2NSBO6.js";import"./chunk-DHJSM5DT.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-E47GFYXA.js";import"./chunk-EYOCNMUM.js";import"./chunk-IQ7NGOAT.js";import"./chunk-7L25ZNNP.js";import"./chunk-ARG56PJG.js";import"./chunk-B2ZGG7WM.js";import{a as o}from"./chunk-DFS4RMVP.js";import{a as t}from"./chunk-HCBYKLMW.js";import{c as n}from"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import{e as r}from"./chunk-UR6MHSHU.js";var e=r(t(),1);async function p(i){let c=i.scenarioLimit!==void 0||i.perScenarioLimit!==void 0?{scenarioLimit:i.scenarioLimit,perScenarioLimit:i.perScenarioLimit}:void 0,{waitUntilExit:m}=n((0,e.jsx)(o,{children:(0,e.jsx)(a,{initialChatMode:"generate",initialObjective:i.objective,initialGenerateLimits:c})}),{exitOnCtrlC:!1});await m()}export{p as runGenerate};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{e as a,f as b,g as c,h as d,i as e,j as f,k as g,l as h,m as i,n as j,o as k,p as l,q as m}from"./chunk-ZA4M4O7E.js";import"./chunk-ZWHPIR2Z.js";import"./chunk-JKX57HA7.js";import"./chunk-WD52ZNQY.js";import"./chunk-PDXZROJM.js";import"./chunk-RH6KFHJB.js";import"./chunk-KN65CUNT.js";import"./chunk-NBXYL2JT.js";import"./chunk-LBNADEQN.js";import"./chunk-VZ7KXRXB.js";import"./chunk-O5AS2ZIX.js";import"./chunk-4BBDKWM3.js";import"./chunk-RBHQXWR7.js";import"./chunk-RSSOJ3L2.js";import"./chunk-5EOX4MEY.js";import"./chunk-OO5GMBVI.js";import"./chunk-N7ZRF5K3.js";import"./chunk-BAKJPQGU.js";import"./chunk-OH2NSBO6.js";import"./chunk-DHJSM5DT.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import"./chunk-IQ7NGOAT.js";import"./chunk-B2ZGG7WM.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{i as ExportError,c as assertOrgMatchOrExit,j as exportTestmd,b as metaMatchesOrg,a as readMetaIfExists,d as resolveCurrentOrgId,l as resolveSyncAuth,h as runDeleteAction,k as runExportAction,e as runListAction,f as runListTui,g as runStatusAction,m as runSyncAction};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as a,c as b,d as c,e as d,f as e,g as f}from"./chunk-RH6KFHJB.js";import"./chunk-KN65CUNT.js";import"./chunk-NBXYL2JT.js";import"./chunk-LBNADEQN.js";import"./chunk-VZ7KXRXB.js";import"./chunk-DHJSM5DT.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import"./chunk-B2ZGG7WM.js";import"./chunk-UR6MHSHU.js";export{a as buildBundleZip,c as runBundleSync,d as shouldSyncBundle,e as shouldSyncPersistedBundle,f as syncPersistedBundle,b as syncTestmdBundle};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-N7ZRF5K3.js";import"./chunk-BAKJPQGU.js";import"./chunk-OH2NSBO6.js";import"./chunk-RZ4F3BHX.js";import"./chunk-B2ZGG7WM.js";import"./chunk-UR6MHSHU.js";export{a as refreshOAuthToken};