@testmuai/kane-cli 0.8.1 → 0.8.3

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 (205) hide show
  1. package/bin/kane-cli.cjs +1 -1
  2. package/bin/resolve-runtime.cjs +8 -0
  3. package/dist/ChatSurface-FJSO3IKR.js +8 -0
  4. package/dist/{ChromeProfilePicker-AUU7JF6F.js → ChromeProfilePicker-NTZ2RN3L.js} +1 -1
  5. package/dist/{CliFeedbackPrompt-4W74Y3UF.js → CliFeedbackPrompt-BCHUH24C.js} +1 -1
  6. package/dist/{CliUploadProgress-6HL7WTEX.js → CliUploadProgress-QVAJJRUW.js} +1 -1
  7. package/dist/{ConfigView-6BSCZP5Y.js → ConfigView-LAKAQN7O.js} +1 -1
  8. package/dist/EvidenceViewOffer-POKUWAPS.js +2 -0
  9. package/dist/FolderPicker-GR6FZMUJ.js +2 -0
  10. package/dist/{HelpView-TU7ED43J.js → HelpView-JFFVHQAW.js} +1 -1
  11. package/dist/{InfoBox-JLTMKVDE.js → InfoBox-46C7AHDE.js} +1 -1
  12. package/dist/{LinksBox-LREUUJDV.js → LinksBox-KFJXZDUJ.js} +1 -1
  13. package/dist/{ProfilesView-W3GX2N2E.js → ProfilesView-FV3KFVBX.js} +1 -1
  14. package/dist/{ProjectPicker-SYQUJK2J.js → ProjectPicker-MCH35VEF.js} +1 -1
  15. package/dist/{SaveSessionPrompt-MR5NJMRP.js → SaveSessionPrompt-RXHP3YW6.js} +1 -1
  16. package/dist/SingleShotApp-BK5QNXGG.js +2 -0
  17. package/dist/{SummaryBox-UAYSVFB7.js → SummaryBox-33K2MMUW.js} +1 -1
  18. package/dist/TestMdRunView-AT26LOSG.js +2 -0
  19. package/dist/{WhoamiView-2YU76ASQ.js → WhoamiView-HUPBB5AQ.js} +1 -1
  20. package/dist/app-client-ZCCNE3RV.js +2 -0
  21. package/dist/{app-download-AEEFQ63M.js → app-download-3O7NJNGG.js} +1 -1
  22. package/dist/{auth-HET3TBRI.js → auth-OMWFVDL2.js} +1 -1
  23. package/dist/{bind-STKXOUYI.js → bind-NXXKFJMA.js} +2 -2
  24. package/dist/bootstrap-MMRPAHWE.js +2 -0
  25. package/dist/bridge-UH32UGR5.js +2 -0
  26. package/dist/{changelog-7OWRHFHZ.js → changelog-VZ5HFHYM.js} +1 -1
  27. package/dist/{chat-controller-T2FAI55V.js → chat-controller-R4THYYPU.js} +1 -1
  28. package/dist/{chunk-HMYMSRA4.js → chunk-2ERQYYSJ.js} +1 -1
  29. package/dist/{chunk-DCY6R5DP.js → chunk-2N4SZOWN.js} +1 -1
  30. package/dist/{chunk-FMRSMN34.js → chunk-2ZDXNTZT.js} +1 -1
  31. package/dist/{chunk-OTTGS2TE.js → chunk-37ZWKLEN.js} +1 -1
  32. package/dist/{chunk-UV462FZR.js → chunk-3MFTTLOF.js} +1 -1
  33. package/dist/{chunk-DO5HAO3H.js → chunk-3S5DDQLP.js} +1 -1
  34. package/dist/{chunk-BRHNRCEZ.js → chunk-4FQI643D.js} +1 -1
  35. package/dist/chunk-4G4RWARU.js +2 -0
  36. package/dist/{chunk-GZPK6FRP.js → chunk-5BVOF4UW.js} +1 -1
  37. package/dist/{chunk-C7HSWZP6.js → chunk-5CKQTZMG.js} +1 -1
  38. package/dist/{chunk-ZVHCQMJ6.js → chunk-5NQ3TI4S.js} +2 -2
  39. package/dist/{chunk-6O3DDOP2.js → chunk-5OVEBP4D.js} +1 -1
  40. package/dist/{chunk-FQLIW3LM.js → chunk-6G5YKTVN.js} +1 -1
  41. package/dist/chunk-6J5T5FEY.js +2 -0
  42. package/dist/{chunk-QRZRSAZH.js → chunk-7YZMUTJA.js} +1 -1
  43. package/dist/chunk-A2SQD2AY.js +4 -0
  44. package/dist/chunk-A5FFLJVL.js +26 -0
  45. package/dist/{chunk-RFR4ZKIC.js → chunk-AF572MQG.js} +2 -2
  46. package/dist/{chunk-HCKH44I2.js → chunk-APETOVZK.js} +1 -1
  47. package/dist/{chunk-AW2XUHH4.js → chunk-AVH3BEEU.js} +1 -1
  48. package/dist/chunk-AXTPNZPX.js +2 -0
  49. package/dist/{chunk-2WVKOZ6W.js → chunk-BPMSNGXQ.js} +1 -1
  50. package/dist/{chunk-EDSZJZFG.js → chunk-CDB3SYZG.js} +1 -1
  51. package/dist/{chunk-T5Y6MOLM.js → chunk-CJP7RX3E.js} +1 -1
  52. package/dist/{chunk-G7VQCS4J.js → chunk-CVCVBQP6.js} +1 -1
  53. package/dist/{chunk-YFYCCTSL.js → chunk-D5VYMHSO.js} +1 -1
  54. package/dist/chunk-D6FYCAIA.js +2 -0
  55. package/dist/{chunk-ZIUAOEUC.js → chunk-DJR3M7XO.js} +1 -1
  56. package/dist/{chunk-65ZTD5SJ.js → chunk-DN42IM2Z.js} +2 -2
  57. package/dist/{chunk-TKGUT425.js → chunk-DOG7S7R6.js} +1 -1
  58. package/dist/chunk-DSXSU5MH.js +10 -0
  59. package/dist/{chunk-QSDH5P7C.js → chunk-DVYO4CR2.js} +1 -1
  60. package/dist/chunk-DXI5TXNL.js +19 -0
  61. package/dist/{chunk-JJHG3BWO.js → chunk-EBJD2V4Z.js} +1 -1
  62. package/dist/chunk-FPAJURPL.js +2 -0
  63. package/dist/{chunk-3LJWYRAA.js → chunk-GIQURCTO.js} +1 -1
  64. package/dist/{chunk-2BGUUWNF.js → chunk-GR35ZFM2.js} +2 -2
  65. package/dist/chunk-HJ6AXOCR.js +2 -0
  66. package/dist/{chunk-6XX4LEVJ.js → chunk-IEOHAHZO.js} +1 -1
  67. package/dist/{chunk-QW6EZC53.js → chunk-IFIXY3YG.js} +1 -1
  68. package/dist/{chunk-XO5ZH3ZR.js → chunk-IHAHCFFG.js} +1 -1
  69. package/dist/chunk-ITTZYA2G.js +4 -0
  70. package/dist/chunk-IVYXXZEE.js +6 -0
  71. package/dist/chunk-IWWQTXGK.js +11 -0
  72. package/dist/{chunk-GCBKDX2J.js → chunk-JANVTG62.js} +1 -1
  73. package/dist/{chunk-IOFZSQAA.js → chunk-KGSVOTLG.js} +1 -1
  74. package/dist/{chunk-L7MXYCD7.js → chunk-KOMKHFC4.js} +1 -1
  75. package/dist/{chunk-EWCAFKLX.js → chunk-KZVEFBH5.js} +1 -1
  76. package/dist/{chunk-FEJXWJ3L.js → chunk-LCU2P3CH.js} +1 -1
  77. package/dist/{chunk-RC52N7PC.js → chunk-LNQCZ5DS.js} +1 -1
  78. package/dist/{chunk-IP2O264K.js → chunk-LP3BSP74.js} +1 -1
  79. package/dist/chunk-LQQXPY5B.js +4 -0
  80. package/dist/{chunk-3POR47RC.js → chunk-LSZVSYAP.js} +2 -2
  81. package/dist/chunk-MMBBQ4OZ.js +2 -0
  82. package/dist/chunk-NNCMMV6P.js +349 -0
  83. package/dist/{chunk-YJELGSKJ.js → chunk-NVGM5ISX.js} +1 -1
  84. package/dist/{chunk-GKYPNSQP.js → chunk-NWJOPZ7P.js} +2 -2
  85. package/dist/{chunk-ELM6MXGJ.js → chunk-NXXJ56QA.js} +1 -1
  86. package/dist/{chunk-NX7TM662.js → chunk-QJTXNQV5.js} +1 -1
  87. package/dist/chunk-RKXHVP2Z.js +2 -0
  88. package/dist/chunk-RUCSRS4C.js +5 -0
  89. package/dist/{chunk-TFPPEOAK.js → chunk-SA2LQSYP.js} +1 -1
  90. package/dist/chunk-SPQPOUUR.js +11 -0
  91. package/dist/chunk-SQDKYSWT.js +12 -0
  92. package/dist/chunk-TAOHYWEO.js +2 -0
  93. package/dist/{chunk-UXDL4XDL.js → chunk-TRVB7RSW.js} +1 -1
  94. package/dist/{chunk-SDPRO2LE.js → chunk-TUTDSX7T.js} +1 -1
  95. package/dist/{chunk-766WGMBU.js → chunk-UBTNWAKK.js} +1 -1
  96. package/dist/chunk-UJZZDPDY.js +2 -0
  97. package/dist/chunk-VK3NU742.js +21 -0
  98. package/dist/{chunk-DZGCXKKI.js → chunk-WCF2Z4SE.js} +1 -1
  99. package/dist/{chunk-KU6IXFGZ.js → chunk-WMMJXI5O.js} +1 -1
  100. package/dist/chunk-X2FM67OM.js +4 -0
  101. package/dist/chunk-XMYCRE5K.js +4 -0
  102. package/dist/chunk-XO45NGSN.js +2 -0
  103. package/dist/chunk-YJNGBZ42.js +4 -0
  104. package/dist/{chunk-7JWKHKFU.js → chunk-ZH64GOBG.js} +1 -1
  105. package/dist/{chunk-UDIQOJEL.js → chunk-ZNNRCUHH.js} +1 -1
  106. package/dist/{chunk-KFSUPQAG.js → chunk-ZUYPPPC5.js} +43 -43
  107. package/dist/{config-RS47F5SC.js → config-OTUKOTHM.js} +1 -1
  108. package/dist/{credentials-OH6AVI6N.js → credentials-A3RU25MJ.js} +1 -1
  109. package/dist/deps-bundle-RIBEQC2R.js +2 -0
  110. package/dist/{deps-resolve-XC5S53DG.js → deps-resolve-7SWSUDRX.js} +1 -1
  111. package/dist/dispatch-RHSWJJLC.js +2 -0
  112. package/dist/doctor-XP7YDE3J.js +2 -0
  113. package/dist/evidence-K7R7OG2K.js +2 -0
  114. package/dist/evolve-cmd-FFF3F3HO.js +2 -0
  115. package/dist/extract-bind-VIPNGK2H.js +10 -0
  116. package/dist/{extract-cmd-UZMEZMGP.js → extract-cmd-5J47Q4XU.js} +1 -1
  117. package/dist/gaps-cmd-WPCJPLGB.js +3 -0
  118. package/dist/{generate-headless-D3SVQ2AI.js → generate-headless-AJI2OVRG.js} +2 -2
  119. package/dist/index.js +61 -60
  120. package/dist/{ingest-EX72IEQT.js → ingest-4447MYLF.js} +1 -1
  121. package/dist/ingest-cmd-2LK7DWDW.js +2 -0
  122. package/dist/interactive-bind-PI3HY623.js +25 -0
  123. package/dist/{list-commands-MRXL5HGS.js → list-commands-7Y5XV5FK.js} +1 -1
  124. package/dist/login-flow-Z45G34DM.js +2 -0
  125. package/dist/mobile-prompts-O5ALU3QU.js +2 -0
  126. package/dist/{persist-recorded-session-TLDQ5HKP.js → persist-recorded-session-TKSU4HOA.js} +1 -1
  127. package/dist/{phase-seed-VFHIH6FL.js → phase-seed-DIRETNU6.js} +1 -1
  128. package/dist/{pipeline-UOM4LNAI.js → pipeline-HZUV7IMT.js} +1 -1
  129. package/dist/prepare-target-DBYKQ7HW.js +2 -0
  130. package/dist/reconcile-cmd-VHEW2DY5.js +2 -0
  131. package/dist/reconcile-deps-UJ6KVUIS.js +4 -0
  132. package/dist/reconcile-engine-NUQJSIFX.js +2 -0
  133. package/dist/{recording-banner-4M7XHVGI.js → recording-banner-GO2PP53Y.js} +1 -1
  134. package/dist/registry-KYPVINS2.js +2 -0
  135. package/dist/{require-project-folder-4UPQNEBJ.js → require-project-folder-NUQMH224.js} +1 -1
  136. package/dist/resolve-run-intent-H3HX5KUC.js +7 -0
  137. package/dist/{resolver-UBOZLFFE.js → resolver-HHLYRR5W.js} +1 -1
  138. package/dist/run-67ONKMGR.js +2 -0
  139. package/dist/{run-URPGHOQM.js → run-OPLOL3PZ.js} +1 -1
  140. package/dist/{run-test-md-76ZPKXO6.js → run-test-md-3BA56ZYF.js} +2 -2
  141. package/dist/session-items-2ATN7VXG.js +2 -0
  142. package/dist/{skill-installer-CIS6GAYF.js → skill-installer-O7JYVZXD.js} +1 -1
  143. package/dist/{spawner-J67QR4QP.js → spawner-OZ4OE44T.js} +1 -1
  144. package/dist/tcg-generate-EG2MXRJ7.js +2 -0
  145. package/dist/{testmd-actions-77ELR5UU.js → testmd-actions-YJ7O43Z6.js} +1 -1
  146. package/dist/{tms-client-VD3B3SMU.js → tms-client-V3TR4QW3.js} +1 -1
  147. package/dist/token-refresh-K7CANKFQ.js +2 -0
  148. package/dist/{validate-basic-2GVSQ2R5.js → validate-basic-HWYK3CU6.js} +1 -1
  149. package/dist/{verdicts-TRSTJLCL.js → verdicts-KFPMRADV.js} +1 -1
  150. package/dist/{version-check-O6PYTI4T.js → version-check-3ECNG5V2.js} +1 -1
  151. package/dist/walk-session-MZCMXVZB.js +2 -0
  152. package/dist/with-telemetry-Q6V6THIF.js +2 -0
  153. package/package.json +12 -12
  154. package/dist/ChatSurface-U37VZDCW.js +0 -8
  155. package/dist/EvidenceViewOffer-62XHEEGW.js +0 -2
  156. package/dist/FolderPicker-S7U2EN2M.js +0 -2
  157. package/dist/SingleShotApp-XOKVOM7C.js +0 -2
  158. package/dist/TestMdRunView-7UVSDAF4.js +0 -2
  159. package/dist/app-client-OEXESV4U.js +0 -2
  160. package/dist/bootstrap-44YKVWWE.js +0 -2
  161. package/dist/bridge-5Z3BIB77.js +0 -2
  162. package/dist/chunk-27U4PLPX.js +0 -2
  163. package/dist/chunk-2KDGIZED.js +0 -4
  164. package/dist/chunk-3PECJD6S.js +0 -11
  165. package/dist/chunk-7BZSCUPP.js +0 -10
  166. package/dist/chunk-7Q6M6P4X.js +0 -26
  167. package/dist/chunk-CTW2VQKS.js +0 -6
  168. package/dist/chunk-FNH55WSR.js +0 -19
  169. package/dist/chunk-GPG3FIN3.js +0 -21
  170. package/dist/chunk-HEAIJCGZ.js +0 -2
  171. package/dist/chunk-KCCSWEGA.js +0 -4
  172. package/dist/chunk-MA34UWKX.js +0 -4
  173. package/dist/chunk-MBF3FP5P.js +0 -5
  174. package/dist/chunk-MXHHMIO2.js +0 -349
  175. package/dist/chunk-OMQCD3KR.js +0 -2
  176. package/dist/chunk-QGKPLOUI.js +0 -2
  177. package/dist/chunk-RLRNLIRS.js +0 -2
  178. package/dist/chunk-TYLYFERW.js +0 -10
  179. package/dist/chunk-V2R3LCA3.js +0 -12
  180. package/dist/chunk-VGFTNLQQ.js +0 -2
  181. package/dist/chunk-W2JFDDIB.js +0 -2
  182. package/dist/chunk-W4B5LOEX.js +0 -4
  183. package/dist/chunk-YRFMPIU2.js +0 -4
  184. package/dist/dispatch-SE5GY3Z2.js +0 -2
  185. package/dist/doctor-FSECFZUU.js +0 -2
  186. package/dist/evidence-OYPHZUKI.js +0 -2
  187. package/dist/evolve-cmd-BCPNXAMV.js +0 -2
  188. package/dist/extract-bind-LLEASZAK.js +0 -10
  189. package/dist/gaps-cmd-IVXFPFAQ.js +0 -3
  190. package/dist/ingest-cmd-EAE7N5RC.js +0 -2
  191. package/dist/interactive-bind-ORMN2REX.js +0 -25
  192. package/dist/login-flow-QJQM3RHT.js +0 -2
  193. package/dist/mobile-prompts-TOX35ER6.js +0 -2
  194. package/dist/prepare-target-QYWIJIVQ.js +0 -2
  195. package/dist/reconcile-cmd-3H34KVVD.js +0 -2
  196. package/dist/reconcile-deps-XIH75ZLY.js +0 -4
  197. package/dist/reconcile-engine-UKWPG2LV.js +0 -2
  198. package/dist/registry-PYOTKZYZ.js +0 -2
  199. package/dist/resolve-run-intent-X72V3KJA.js +0 -7
  200. package/dist/run-2COODVX2.js +0 -2
  201. package/dist/tcg-generate-BDTRKY2A.js +0 -2
  202. package/dist/token-refresh-4BPAPXKK.js +0 -2
  203. package/dist/walk-session-CHJXHZMO.js +0 -2
  204. package/dist/with-telemetry-CQCWLVOC.js +0 -2
  205. /package/dist/{lifecycle-cmd-O2324GN6.js → lifecycle-cmd-HO5VL7AM.js} +0 -0
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as f}from"./chunk-TUTDSX7T.js";import{c as g}from"./chunk-UD7KKHPW.js";import{existsSync as u}from"fs";import{dirname as A,resolve as l}from"path";import{fileURLToPath as E}from"url";var p=A(E(import.meta.url));function _(){return[l(p,".."),l(p,"../../..")]}function x(s){return{"darwin-arm64":"kane-cli-darwin-arm64","darwin-x64":"kane-cli-darwin-x64","linux-x64":"kane-cli-linux-x64","linux-arm64":"kane-cli-linux-arm64","win32-x64":"kane-cli-win-x64"}[s]??null}function T(s){return{"darwin-arm64":"kane-cli-assurance-darwin-arm64","darwin-x64":"kane-cli-assurance-darwin-x64","linux-x64":"kane-cli-assurance-linux-x64","linux-arm64":"kane-cli-assurance-linux-arm64","win32-x64":"kane-cli-assurance-win-x64"}[s]??null}function I(s=_()){let n=x(`${process.platform}-${process.arch}`),i=T(`${process.platform}-${process.arch}`),a=process.platform==="win32"?"assurance-agent.exe":"assurance-agent";for(let e of s){for(let t of i?["@testmuai","@lambdatestincprivate"]:[]){let m=l(e,"node_modules",t,i,"bin",a);if(u(m))return{cmd:m,args:[],tier:"platform"}}for(let t of n?["@testmuai","@lambdatestincprivate"]:[]){let m=l(e,"node_modules",t,n,"bin",a);if(u(m))return{cmd:m,args:[],tier:"platform"}}let c=l(e,"dist","bin",a);if(u(c))return{cmd:c,args:[],tier:"embedded"};let r=l(e,"../assurance-agent/dist",a);if(u(r))return{cmd:r,args:[],tier:"sibling"};let o=l(e,"../assurance-agent/main.py");if(u(o)){let t=l(e,"../assurance-agent/.venv/bin/python");return{cmd:u(t)?t:"python3",args:[o],tier:"dev-python"}}}return null}function U(s,n={}){return{...process.env,...n,...f(),TESTMUAI_SOURCE:"kane-cli",TESTMUAI_SESSION_ID:s,ASSURANCE_LOG_LEVEL:process.env.ASSURANCE_LOG_LEVEL??"info"}}async function P(){if(process.env.TESTMUAI_API_KEY||process.env.TESTMUAI_BASIC_AUTH)return{};try{let{CredentialsManager:s}=await import("./credentials-A3RU25MJ.js"),n=process.env.TESTMUAI_ENV==="stage"?"stage":"prod",i=new s,a=i.getActiveProfile()??"default",e={TESTMUAI_ENV:n},c=i.loadBasicAuth(a,n);if(c)return e.TESTMUAI_BASIC_AUTH=Buffer.from(`${c.username}:${c.access_key}`,"utf8").toString("base64"),e;let r=i.loadCredentials(a,n);if(r){try{let{refreshOAuthToken:t}=await import("./token-refresh-K7CANKFQ.js");await t({creds:i,profile:a,env:n,credentials:r})}catch{}let o=i.loadCredentials(a,n)??r;if(typeof o.access_token=="string"){let t=await w(n,o.access_token);return t?(e.TESTMUAI_BASIC_AUTH=t,e):(e.TESTMUAI_API_KEY=o.access_token,e)}}return{}}catch{return{}}}var h=8e3;function d(){return g("warn: session auth may expire during long runs \u2014 if that happens, run `kane-cli login` and retry","AUTH_EXCHANGE_FAILED"),null}async function w(s,n){try{let[{getEnvironment:i},{ControllerClient:a}]=await Promise.all([import("./config-OTUKOTHM.js"),import("./controller-client-OB4WD2C4.js")]),e=new a(i(s).controllerBaseUrl,n),c;try{let r=await Promise.race([e.getTmsCredentials().catch(()=>null),new Promise(o=>{c=setTimeout(()=>o(null),h)})]);if(typeof r?.username!="string"||!r.username||typeof r.access_key!="string"||!r.access_key)return d();try{let[{refreshIdentitySnapshot:o},{telemetryEnvName:t}]=await Promise.all([import("./identity-ADZ4PAJF.js"),import("./bootstrap-MMRPAHWE.js")]);await o(t(),r)}catch{}return Buffer.from(`${r.username}:${r.access_key}`,"utf8").toString("base64")}finally{clearTimeout(c)}}catch{return d()}}export{x as a,T as b,I as c,U as d,P as e};
@@ -0,0 +1,4 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as $}from"./chunk-MMBBQ4OZ.js";import{j as h}from"./chunk-SPQPOUUR.js";import{a as w}from"./chunk-RZ4F3BHX.js";import{c as v}from"./chunk-D6FYCAIA.js";import{spawn as V,spawnSync as _}from"child_process";import{createServer as K}from"net";import{mkdirSync as g,openSync as W,readFileSync as I,renameSync as j,rmSync as x,statSync as Y,writeFileSync as M}from"fs";import{readFile as q}from"fs/promises";import{dirname as l,join as y}from"path";var G=[4723,4724,4725,4726,4727,4728,4729,4730],X={emulator:4750,simulator:4790},z=40,E=2e3,D=3e4,T=500,Ce=["emulator","simulator"];function Q(e){return y(v,"mobile",`appium-server-${e}.log`)}function m(){return y(v,"mobile","appium-servers.json")}function Z(){return y(v,"mobile","appium-servers.lock")}var ee=1e4,re=50;function C(e){let r=Z();try{g(l(r),{recursive:!0})}catch{return e()}let n=!1;for(let o=0;o<re;o++)try{g(r),n=!0;break}catch{try{Date.now()-Y(r).mtimeMs>ee&&x(r,{recursive:!0,force:!0})}catch{}ne(10)}try{return e()}finally{if(n)try{x(r,{recursive:!0,force:!0})}catch{}}}function ne(e){try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}catch{}}function te(){try{let e=JSON.parse(I(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}function oe(e){let r=m();g(l(r),{recursive:!0});let n=`${r}.tmp`;M(n,JSON.stringify(e,null,2)),j(n,r)}function se(e,r,n){return`Another mobile session is already running${n?` on ${n}`:""}. Wait for it to finish, or close the terminal running it.`}var A=class extends Error{constructor(n,o){super(n);this.port=o;this.name="DeviceBusyError"}};function ie(e){return w(e,{signal:AbortSignal.timeout(E)}).then(r=>r.ok,()=>!1)}async function ae(e,r){try{return(await w(`http://127.0.0.1:${e}/session/${r}`,{method:"DELETE",signal:AbortSignal.timeout(E)})).ok}catch{return!1}}function R(e){let r=e?.value;return Array.isArray(r)?r.map(n=>{let o=n??{},t=o.capabilities??o;return{...typeof o.id=="string"?{id:o.id}:{},caps:t}}):[]}async function ue(e){try{let r=await w(`http://127.0.0.1:${e}/sessions`,{signal:AbortSignal.timeout(E)});return r.ok?R(await r.json()):[]}catch{return[]}}var ce=["udid","appium:udid","deviceUDID","appium:deviceUDID","deviceName","appium:deviceName"];function L(){let e=r=>{try{let n=_("curl",["-s","--noproxy","*","--max-time","2",...r],{encoding:"utf8",timeout:5e3});return{ok:n.status===0,stdout:n.stdout??""}}catch{return{ok:!1,stdout:""}}};return{readState:()=>{try{let r=JSON.parse(I(m(),"utf8"));return Array.isArray(r)?r:[]}catch{return[]}},alive:b,getJson:r=>{let n=e([r]);if(n.ok)try{return JSON.parse(n.stdout)}catch{return}},del:r=>{let n=e(["-o","/dev/null","-w","%{http_code}","-X","DELETE",r]);return n.ok&&/^2\d\d$/.test(n.stdout.trim())}}}function Le(e,r={}){let n={...L(),...r},o=0;try{for(let t of n.readState()){if(!n.alive(t.pid))continue;let i=R(n.getJson(`http://127.0.0.1:${t.port}/sessions`));for(let s of i)s.id&&de(s.caps,e.udid,e.displayName)&&n.del(`http://127.0.0.1:${t.port}/session/${s.id}`)&&(o+=1)}}catch{}return o}function de(e,r,n){let o=[r,n].filter(t=>!!t).map(t=>t.toLowerCase());for(let t of ce){let i=e[t];if(typeof i=="string"&&o.includes(i.toLowerCase()))return!0}return!1}function pe(e,r,n){let o=W(n.logPath,"a"),t=V(e,r,{stdio:["ignore",o,o],detached:!0,env:{...process.env,...n.env}});return t.unref(),t.pid}async function le(e,r){for(let n=e;n<e+r;n++)if(await new Promise(t=>{let i=K();i.once("error",()=>t(!1)),i.once("listening",()=>i.close(()=>t(!0))),i.listen(n)}))return n;throw new Error(`No free port for the managed Appium server in ${e}-${e+r-1}.`)}function b(e){try{return process.kill(e,0),!0}catch{return!1}}function P(e){try{let r=_("ps",["-o","comm=","-p",String(e)],{encoding:"utf8",timeout:2e3});if(r.status!==0)return!1;let n=r.stdout.trim().toLowerCase();return n===""?!0:n.includes("node")||n.includes("kane")}catch{return!0}}function k(e){try{process.kill(e)}catch{}}async function me(){try{let e=JSON.parse(await q(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}async function fe(e){let r=process.pid,n=e.filter(o=>o.owner===r);C(()=>{let o=[];for(let t of te())t.owner!==r&&(Se(t)?o.push(t):b(t.pid)&&k(t.pid));oe([...o,...n])})}function Se(e){return e.owner===void 0?!1:b(e.owner)&&P(e.owner)}function ve(){return{probe:ie,sessions:ue,deleteSession:ae,spawn:pe,freePort:le,alive:b,kill:k,readState:me,writeState:fe,owner:process.pid,depsEnv:e=>h().environment(e),bundleVersion:async e=>(await h().status(e)).version,nodeBinary:process.execPath,env:process.env,os:process.platform,now:()=>Date.now(),sleep:e=>new Promise(r=>setTimeout(r,e))}}function we(e,r,n){if(!e.platformToolsDir)return{};let o=n==="win32"?";":":",t=$(r),i=t?.root??l(e.platformToolsDir),s=t?.platformToolsDir??e.platformToolsDir;return{ANDROID_HOME:i,ANDROID_SDK_ROOT:i,PATH:r.PATH?`${s}${o}${r.PATH}`:s}}async function ge(e){let r=await e.readState(),n=[],o=[];for(let t of r)t.owner!==void 0&&e.alive(t.owner)&&(e.ownerIsOurs??P)(t.owner)?n.push(t):o.push(t);for(let t of o){let i=e.ownerIsOurs??P;e.alive(t.pid)&&i(t.pid)&&e.kill(t.pid)}return o.length>0&&await e.writeState(n),n}async function Je(e,r={}){if(r.appiumUrl)return{result:"external",url:r.appiumUrl};let n={...ve(),...r.deps},o=await ge(n),t=o.filter(a=>a.owner===n.owner),i=new Set(t.map(a=>a.port)),s=new Set(o.map(a=>a.port));if(r.device){let a=await ye(n,s,i,e);if(a!==null)throw new A(se(r.device,a.port,a.device),a.port)}let c=await n.bundleVersion(e),u=t.find(a=>a.deviceClass===e&&(a.bundleVersion??c)===c);if(u&&await n.probe(`http://127.0.0.1:${u.port}/status`))return{result:"reused",url:`http://127.0.0.1:${u.port}`};for(let a of t.filter(S=>S.deviceClass===e&&S!==u))n.kill(a.pid);u&&n.kill(u.pid);let d=await n.depsEnv(e);if(!d.appiumHome)throw new Error(`The managed dependencies for the ${e} class are not installed.
3
+ Run \`kane-cli doctor --target ${e} --install\` to install them, or pass --appium-url for an external server.`);let p=await n.freePort(X[e],z),O=`http://127.0.0.1:${p}`,J=l(d.appiumHome),U=y(J,"appium","node_modules","appium","index.js"),N=Q(e);r.onProgress?.(`starting the managed Appium server (${e}, port ${p})\u2026`);let f=n.spawn(n.nodeBinary,[U,"--port",String(p)],{env:{APPIUM_HOME:d.appiumHome,...we(d,n.env,n.os)},logPath:N}),B=n.now()+D,F=Math.ceil(D/T)+1;for(let a=0;a<F&&n.now()<B;a++)if(await n.sleep(T),await n.probe(`${O}/status`)){if(f!==void 0){let S=t.filter(H=>H.deviceClass!==e);await n.writeState([...S,{port:p,pid:f,owner:n.owner,deviceClass:e,...c?{bundleVersion:c}:{},startedAt:new Date(n.now()).toISOString()}])}return r.onProgress?.("Appium server ready"),{result:"started",url:O}}throw f!==void 0&&n.kill(f),new Error(`The managed Appium server (${e}) did not answer on ${p} within ${D/1e3}s.
4
+ Check its log: ${N}`)}async function ye(e,r=[],n=[],o){let t=new Set(n),i=new Set([...G,...r]);for(let s of i)if(!t.has(s))for(let c of await e.sessions(s)){if(!c.id)continue;if(o){let d=be(c.caps);if(d&&d!==o)continue}let u=De(c.caps);return{port:s,...u?{device:u}:{}}}return null}function be(e){let r=t=>{let i=e[t];return typeof i=="string"?i.toLowerCase():""},n=r("platformName")||r("appium:platformName");if(n.includes("ios"))return"simulator";if(n.includes("android"))return"emulator";let o=r("appium:automationName")||r("automationName");if(o.includes("xcuitest"))return"simulator";if(o.includes("uiautomator"))return"emulator"}var he=["appium:deviceName","deviceName","appium:udid","udid","appium:deviceUDID","deviceUDID"];function De(e){for(let r of he){let n=e[r];if(typeof n=="string"&&n.trim())return n}}function Ue(e={}){let r={...L(),kill:k,writeState:Ae,...e.deps};try{let n=r.readState(),o=e.owner??process.pid,t=n.filter(s=>s.owner===o&&(!e.deviceClass||s.deviceClass===e.deviceClass));for(let s of t){if(!r.alive(s.pid))continue;let c=R(r.getJson(`http://127.0.0.1:${s.port}/sessions`));for(let u of c)u.id&&r.del(`http://127.0.0.1:${s.port}/session/${u.id}`);r.kill(s.pid)}let i=new Set(t.map(s=>`${s.port}:${s.pid}`));C(()=>{r.writeState(r.readState().filter(s=>!i.has(`${s.port}:${s.pid}`)))})}catch{}}function Ae(e){try{let r=m();g(l(r),{recursive:!0}),M(r,JSON.stringify(e,null,2))}catch{}}export{Ce as a,Q as b,se as c,Le as d,ve as e,Je as f,ye as g,Ue as h};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as $}from"./chunk-HMYMSRA4.js";import{f as D}from"./chunk-GZPK6FRP.js";import{a as E}from"./chunk-NLCCBXXV.js";function U(e){return["completed","failed","ended","stopped"].includes(e.trim().toLowerCase())}function je(e){return["ended","stopped"].includes(e.trim().toLowerCase())}function q(e){return{requestId:e.requestId,objective:e.objective,status:"",turnActive:!1,scenarios:[],thinking:"",thinkingLog:[],chatLog:[],progress:0}}function Re(e){return e.pendingClarification===void 0?e:{...e,pendingClarification:void 0}}function Ce(e){return{...e,turnActive:!0,error:void 0,thinking:"",thinkingLog:[]}}function P(e,t){switch(t.type){case"thinking":return{...e,status:"thinking",thinking:e.thinking+t.delta};case"thinking_done":return{...e,thinkingLog:[...e.thinkingLog,{text:e.thinking,tookMs:t.tookMs}],thinking:""};case"progress":return{...e,progress:t.pct};case"snapshot":return{...e,scenarios:t.data.scenarios,status:t.data.status,headline:t.data.headline??e.headline};case"chat":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}]};case"clarification":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}],pendingClarification:t.text};case"limit":return{...e,limits:{scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit}};case"error":return{...e,error:t.message};case"done":return{...e,status:t.status,turnActive:!1,error:t.status==="failed"&&!e.error?"generation failed":e.error}}}function H(e,t){let n=[],i=e.type??"",d=e.status??"";if(i==="ping")return n;switch(i){case"thinking_token":typeof e.data=="string"&&n.push({type:"thinking",delta:e.data});break;case"thinking_stopped":{let r=e.data??{},o=se(r.time_taken);n.push({type:"thinking_done",text:typeof e.data=="string"?e.data:r.message??"",tookMs:o});break}case"progress":{let r=e.data??{};typeof r.progress=="number"&&n.push({type:"progress",pct:r.progress});break}case"clarification":{let r=e.data??{};typeof r.message=="string"&&n.push({type:"clarification",text:r.message});break}case"chatting_stopped":{let r=e.data??{};typeof r.message=="string"&&r.message.length>0&&n.push({type:"chat",text:r.message});break}case"limit_update":{let r=e.data??{},o=r.test_cases_limit??e.test_cases_limit,p=r.per_scenario_test_cases_limit??e.per_scenario_test_cases_limit;n.push({type:"limit",scenarioLimit:o,perScenarioLimit:p});break}case"error":{let r=typeof e.data=="string"?e.data:e.data?.message??"generation error";n.push({type:"error",message:r});break}case"request_cancelled":return n.push({type:"done",status:"stopped"}),n;case"session_ended":return n.push({type:"done",status:"ended"}),n;default:break}if(Array.isArray(e.scenarios)&&n.push({type:"snapshot",data:{requestId:t,status:d,headline:e.headline,scenarios:e.scenarios}}),d&&U(d)){let r=d.trim().toLowerCase();n.push({type:"done",status:r})}return n}function se(e){if(!e)return;let t=/^([\d.]+)(ms|s)?$/.exec(e.trim());if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return t[2]==="ms"?Math.round(n):Math.round(n*1e3)}var v=class extends Error{constructor(t){super(t),this.name="AuthError"}},M=class extends Error{constructor(t){super(t),this.name="ForbiddenError"}},I=class extends Error{constructor(t){super(t),this.name="InsufficientCreditsError"}},k=class extends Error{constructor(n,i){super(n);this.cause=i;this.name="TransportError"}};function x(e,t){let n=t?.message??t?.error??`HTTP ${e}`;return e===401?new v(n):e===403?t?.key==="insufficient_credits"?new I(n):new M(n):new k(n)}async function*J(e){let t=e.fetchImpl??fetch,n=e.maxRetries??5,i=e.maxBackoffMs??3e4,d=e.connectTimeoutMs??1e4,r=0,o=!1;for(;;){if(e.signal.aborted)return;let p=new AbortController,a=()=>p.abort();e.signal.addEventListener("abort",a,{once:!0});let c=setTimeout(()=>p.abort(),d),g;try{g=await t(e.url,{method:"GET",headers:{Authorization:await e.authHeader(),Accept:"text/event-stream"},signal:p.signal})}catch(w){if(clearTimeout(c),e.signal.removeEventListener("abort",a),e.signal.aborted)return;if(++r>n)throw new k("SSE connect failed",w);await O(F(r,i));continue}if(clearTimeout(c),!g.ok){e.signal.removeEventListener("abort",a);let w=await oe(g);if(g.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(g.status,w)}if(!g.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let m=g.body.getReader(),h=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await m.cancel().catch(()=>{});return}let{done:w,value:s}=await m.read();if(w)break;b+=h.decode(s,{stream:!0});let f;for(;(f=b.indexOf(`
2
+ import{a as $}from"./chunk-2ERQYYSJ.js";import{f as D}from"./chunk-5BVOF4UW.js";import{a as E}from"./chunk-NLCCBXXV.js";function U(e){return["completed","failed","ended","stopped"].includes(e.trim().toLowerCase())}function je(e){return["ended","stopped"].includes(e.trim().toLowerCase())}function q(e){return{requestId:e.requestId,objective:e.objective,status:"",turnActive:!1,scenarios:[],thinking:"",thinkingLog:[],chatLog:[],progress:0}}function Re(e){return e.pendingClarification===void 0?e:{...e,pendingClarification:void 0}}function Ce(e){return{...e,turnActive:!0,error:void 0,thinking:"",thinkingLog:[]}}function P(e,t){switch(t.type){case"thinking":return{...e,status:"thinking",thinking:e.thinking+t.delta};case"thinking_done":return{...e,thinkingLog:[...e.thinkingLog,{text:e.thinking,tookMs:t.tookMs}],thinking:""};case"progress":return{...e,progress:t.pct};case"snapshot":return{...e,scenarios:t.data.scenarios,status:t.data.status,headline:t.data.headline??e.headline};case"chat":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}]};case"clarification":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}],pendingClarification:t.text};case"limit":return{...e,limits:{scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit}};case"error":return{...e,error:t.message};case"done":return{...e,status:t.status,turnActive:!1,error:t.status==="failed"&&!e.error?"generation failed":e.error}}}function H(e,t){let n=[],i=e.type??"",d=e.status??"";if(i==="ping")return n;switch(i){case"thinking_token":typeof e.data=="string"&&n.push({type:"thinking",delta:e.data});break;case"thinking_stopped":{let r=e.data??{},o=se(r.time_taken);n.push({type:"thinking_done",text:typeof e.data=="string"?e.data:r.message??"",tookMs:o});break}case"progress":{let r=e.data??{};typeof r.progress=="number"&&n.push({type:"progress",pct:r.progress});break}case"clarification":{let r=e.data??{};typeof r.message=="string"&&n.push({type:"clarification",text:r.message});break}case"chatting_stopped":{let r=e.data??{};typeof r.message=="string"&&r.message.length>0&&n.push({type:"chat",text:r.message});break}case"limit_update":{let r=e.data??{},o=r.test_cases_limit??e.test_cases_limit,p=r.per_scenario_test_cases_limit??e.per_scenario_test_cases_limit;n.push({type:"limit",scenarioLimit:o,perScenarioLimit:p});break}case"error":{let r=typeof e.data=="string"?e.data:e.data?.message??"generation error";n.push({type:"error",message:r});break}case"request_cancelled":return n.push({type:"done",status:"stopped"}),n;case"session_ended":return n.push({type:"done",status:"ended"}),n;default:break}if(Array.isArray(e.scenarios)&&n.push({type:"snapshot",data:{requestId:t,status:d,headline:e.headline,scenarios:e.scenarios}}),d&&U(d)){let r=d.trim().toLowerCase();n.push({type:"done",status:r})}return n}function se(e){if(!e)return;let t=/^([\d.]+)(ms|s)?$/.exec(e.trim());if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return t[2]==="ms"?Math.round(n):Math.round(n*1e3)}var v=class extends Error{constructor(t){super(t),this.name="AuthError"}},M=class extends Error{constructor(t){super(t),this.name="ForbiddenError"}},I=class extends Error{constructor(t){super(t),this.name="InsufficientCreditsError"}},k=class extends Error{constructor(n,i){super(n);this.cause=i;this.name="TransportError"}};function x(e,t){let n=t?.message??t?.error??`HTTP ${e}`;return e===401?new v(n):e===403?t?.key==="insufficient_credits"?new I(n):new M(n):new k(n)}async function*J(e){let t=e.fetchImpl??fetch,n=e.maxRetries??5,i=e.maxBackoffMs??3e4,d=e.connectTimeoutMs??1e4,r=0,o=!1;for(;;){if(e.signal.aborted)return;let p=new AbortController,a=()=>p.abort();e.signal.addEventListener("abort",a,{once:!0});let c=setTimeout(()=>p.abort(),d),g;try{g=await t(e.url,{method:"GET",headers:{Authorization:await e.authHeader(),Accept:"text/event-stream"},signal:p.signal})}catch(w){if(clearTimeout(c),e.signal.removeEventListener("abort",a),e.signal.aborted)return;if(++r>n)throw new k("SSE connect failed",w);await O(F(r,i));continue}if(clearTimeout(c),!g.ok){e.signal.removeEventListener("abort",a);let w=await oe(g);if(g.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(g.status,w)}if(!g.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let m=g.body.getReader(),h=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await m.cancel().catch(()=>{});return}let{done:w,value:s}=await m.read();if(w)break;b+=h.decode(s,{stream:!0});let f;for(;(f=b.indexOf(`
3
3
 
4
4
  `))>=0;){let u=b.slice(0,f);b=b.slice(f+2);let l=ie(u);l&&(yield l)}}}catch(w){if(e.signal.aborted)return;if(++r>n)throw new k("SSE stream dropped",w);await O(F(r,i));continue}finally{e.signal.removeEventListener("abort",a)}return}}function ie(e){let t="message",n="";for(let i of e.split(`
5
5
  `))i.startsWith("event:")?t=i.slice(6).trim():i.startsWith("data:")&&(n+=i.slice(5).trim());if(t!=="message"||!n)return null;try{let i=Buffer.from(n,"base64").toString("utf-8");return JSON.parse(i)}catch{return null}}function F(e,t){return Math.min(t,1e3*2**(e-1))}function O(e){return new Promise(t=>setTimeout(t,e))}async function oe(e){try{return await e.clone().json()}catch{return}}function W(e,t){t?.length&&(e.append("files",t.map(n=>n.fileKey).join(",")),e.append("gemini_metadata",JSON.stringify(t.map(n=>({fileData:{fileUri:n.geminiUri,mimeType:n.mimeType}})))))}function Ue(e,t={}){let n=t.fetchImpl??fetch,i=new Map,d=!0;async function r(){let s=await e.authResolver.resolve();if(!s)throw new v("unauthorized; run `kane-cli login`");return E(s.username,s.access_key)}function o(s){return`${e.baseUrl}${s}`}async function p(s){if(!s.ok){let f;try{f=await s.clone().json()}catch{f=void 0}throw x(s.status,f)}return s.json()}function a(s){let f=s?.data??s;return{request_id:f.request_id??f.id,status:f.status??""}}function c(s,f,u,l){let y=q({requestId:s,objective:f});l&&(y=P(y,{type:"snapshot",data:l}),l.status==="cleaned_up"&&(y={...y,error:"session was reaped (cleaned_up) \u2014 continuing will destructively regenerate"}));let S=new AbortController;u&&(u.aborted?S.abort():u.addEventListener("abort",()=>S.abort(),{once:!0})),i.set(s,S);let A={requestId:s,state:y,events:void 0};return A.events=(async function*(){try{let C=J({url:o(`/requests/${s}/sse`),authHeader:r,signal:S.signal,log:e.log,fetchImpl:n});for await(let L of C)for(let z of H(L,s))A.state=P(A.state,z),yield z}finally{i.delete(s)}})(),A}async function g(s,f){let u=new FormData;u.append("prompt",s.prompt),d=s.memoryEnhancement??!0,u.append("memory_enhancement",String(d)),s.scenarioLimit!==void 0&&u.append("test_scenario_limit",String(s.scenarioLimit)),s.perScenarioLimit!==void 0&&u.append("per_scenario_test_cases_limit",String(s.perScenarioLimit));let l=s.projectId??e.projectId,y=s.folderId??e.folderId;l&&u.append("project_id",l),y&&u.append("folder_id",y),W(u,s.attachments);let S=await n(o("/requests"),{method:"POST",headers:{Authorization:await r()},body:u}),A=await p(S),{request_id:C}=a(A),L=String(C);return c(L,s.prompt,f)}async function m(s,f){let u=await n(o(`/requests/${s}`),{method:"GET",headers:{Authorization:await r()}}),l=await p(u),y=l?.data??l,S={requestId:s,status:y.status??"",headline:y.headline,scenarios:Array.isArray(y.scenarios)?y.scenarios:[]};return c(s,"",f,S)}async function h(s,f,u){let l=new FormData;l.append("prompt",f),l.append("chat_enabled","true"),l.append("memory_enhancement",String(d)),u?.mappings&&l.append("mappings",JSON.stringify(u.mappings)),W(l,u?.attachments);let y=await n(o(`/requests/${s}`),{method:"PUT",headers:{Authorization:await r()},body:l});if(!y.ok){let S;try{S=await y.clone().json()}catch{}throw x(y.status,S)}}async function b(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/stop`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}async function w(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/end`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}return{start:g,attach:m,chat:h,cancel:b,end:w}}import{statSync as ae,realpathSync as G,existsSync as ce}from"fs";import{extname as ue,resolve as j,isAbsolute as pe}from"path";import{homedir as V}from"os";var de=new Set([".txt",".md",".json",".xml",".jpg",".jpeg",".png",".gif",".bmp",".webp",".pdf",".docx",".csv",".xlsx",".mp3",".wav",".m4a",".webm",".mpeg",".mpga",".mp4",".mov"]),le=50*1024*1024,X=10;function fe(e){return e==="~"?V():e.startsWith("~/")?j(V(),e.slice(2)):e}function Ge(e,t){let n=[],i=[],d=new Set,r=[],o=(()=>{try{return G(j(t))}catch{return j(t)}})(),p=o.endsWith("/")?o:o+"/";for(let a of e){let c=fe(a),g=pe(c)?c:j(t,c);if(!ce(g)){n.push(`Not found: ${a}`);continue}let m;try{m=G(g)}catch{n.push(`Cannot resolve: ${a}`);continue}if(d.has(m))continue;let h;try{h=ae(m)}catch{n.push(`Cannot read: ${a}`);continue}if(!h.isFile()){n.push(`Not a file: ${a}`);continue}if(h.size===0){n.push(`Empty file: ${a}`);continue}let b=ue(m).toLowerCase();if(!de.has(b)){n.push(`Unsupported type ${b||"(none)"}: ${a}`);continue}if(h.size>le){n.push(`Too large (>50MB): ${a}`);continue}m!==o&&!m.startsWith(p)&&i.push(`Outside working dir: ${a}`),d.add(m),r.push(m)}return r.length>X&&n.push(`Too many files: ${r.length} (max ${X})`),{ok:n.length?[]:r,errors:n,warnings:i}}var B=class extends Error{constructor(n){super(n.join("; "));this.errors=n;this.name="AttachmentValidationError"}};async function Xe(e){let{promptText:t,filePaths:n,cwd:i,scenarios:d,isRefine:r,conn:o,deps:p}=e,{ok:a,errors:c,warnings:g}=p.validate(n,i);if(c.length)throw new B(c);e.onValidated?.();let m=a.length?await p.upload(o,a,p.onUpload):[],h=r?p.buildMappings(t,d):void 0;return{promptText:t,mappings:h,attachments:m,warnings:g}}import{readFile as me}from"fs/promises";import{basename as K}from"path";async function ge(e){let t=await e.authResolver.resolve();if(!t)throw new v("unauthorized; run `kane-cli login`");return E(t.username,t.access_key)}async function he(e,t,n={}){let i=n.fetchImpl??fetch,d=await me(t),r=K(t),o=new FormData;o.append("file",new Blob([d]),r),o.append("source","omniBox"),o.append("geminiFileUpload","true");let p=await i(`${e.tmsBaseUrl}/v1/attachment`,{method:"POST",headers:{Authorization:await ge(e)},body:o,signal:n.signal});if(!p.ok){let h;try{h=await p.clone().json()}catch{}throw x(p.status,h)}let a=await p.json(),c=a?.data??a,g=c?.gemini_response?.uri,m=c?.gemini_response?.mimeType;if(!c?.file_key||!g){let h=c&&typeof c=="object"?Object.keys(c).join(","):typeof c,b=(()=>{try{return JSON.stringify(c).slice(0,500)}catch{return"<unserializable>"}})();throw new Error(`attachment upload for ${r} returned no file_key/gemini uri \u2014 status ${p.status}, body keys: [${h}], raw: ${b}`)}return{fileName:c.file_name??r,fileKey:c.file_key,geminiUri:g,mimeType:m??"application/octet-stream"}}async function tt(e,t,n,i={}){let d=[];for(let r=0;r<t.length;r++){if(i.signal?.aborted)throw Object.assign(new Error("upload aborted"),{name:"AbortError"});let o=K(t[r]);n?.({file:o,index:r+1,total:t.length,status:"uploading"});try{d.push(await he(e,t[r],i)),n?.({file:o,index:r+1,total:t.length,status:"done"})}catch(p){throw n?.({file:o,index:r+1,total:t.length,status:"failed"}),p}}return d}var ye=/@([sS])(\d+)\.([cC])(\d+)/g,be=/@([sS])(\d+)(?!\d)(?!\.[cC]\d)/g;function rt(e,t){let n={},i={};for(let d of e.matchAll(ye)){let r=Number(d[2]),o=Number(d[4]),p=t[r-1];if(!p)continue;n[`s${r}`]=String(p.id);let a=p.test_cases??[];if(a[o-1])for(let c=0;c<o;c++){let g=a[c];g&&(i[`s${r}.c${c+1}`]=String(g.id))}}for(let d of e.matchAll(be)){let r=Number(d[2]),o=t[r-1];o&&(n[`s${r}`]=String(o.id))}if(!(Object.keys(n).length===0&&Object.keys(i).length===0))return{scenario:n,testcase:i}}function R(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(n==null||typeof n!="object")return[];let i=n;if(typeof i.step!="string")return[];let d=typeof i.expected_result=="string"?i.expected_result:typeof i.outcome=="string"?i.outcome:"";t.push({step:i.step,expected:d})}return t}var we=30,Se=300;function Z(){return{mode:"testing",max_steps:we,timeout:Se,variables:{}}}function Q(e){return e.title??`Test case ${e.id}`}function ct(e,t){return $({frontmatter:Z(),heading:Q(t),steps:e.sub_objectives.map(n=>n.objective)})}function Y(e){let t=R(e.manual_steps).map(n=>n.step);return $({frontmatter:Z(),heading:Q(e),steps:t})}import{mkdtempSync as xe,mkdirSync as N,writeFileSync as ee,rmSync as te,renameSync as _e,existsSync as ne,readFileSync as ve}from"fs";import{join as _,resolve as ke}from"path";async function ft(e,t,n,i=Y){(n.redirectBareCwd??!0)&&ke(t)===process.cwd()&&(t=_(t,".testmuai","tests"));let d=T(e.objective)??e.headline,r=T(n.suiteName)??`${T(re(d,4))??"tcg"}-${e.requestId}`,o=r,p=_(t,r);ne(p)&&!Te(p,e.requestId)&&(o=`${r}-${e.requestId}`);let a=_(t,o),c=[],g=new Map;for(let h of e.scenarios){let b=(h.test_cases??[]).filter(Ae);if(b.length===0)continue;let w=T(Ee(h.scode))??T(h.sid)??`s${h.id}`,s=g.get(w)??new Set;g.set(w,s);for(let f of b){let u=T(re(f.title,5))??"case",l=`${u}_test.md`;for(let y=2;s.has(l);y++)l=`${u}-${y}_test.md`;s.add(l),c.push({dir:w,file:l,tc:f})}}if(c.length===0)return{suiteDir:a,paths:[],warning:"no functional test cases generated"};N(t,{recursive:!0});let m=xe(_(t,".tcg-tmp-"));try{N(_(m,"helpers"),{recursive:!0}),ee(_(m,".tcg-suite.json"),JSON.stringify({requestId:e.requestId,suiteName:o}));let h=[],b=new Set;for(let s of c){let f=_(m,s.dir);b.has(f)||(N(f,{recursive:!0}),b.add(f));let u=_(f,s.file);ee(u,i(s.tc)),h.push(u)}ne(a)&&te(a,{recursive:!0,force:!0}),_e(m,a);let w=h.map(s=>s.replace(m,a));return{suiteDir:a,paths:w}}catch(h){try{te(m,{recursive:!0,force:!0})}catch{}throw h}}function Ae(e){return(e.category??"").trim().toLowerCase()==="functional"}function Te(e,t){try{return JSON.parse(ve(_(e,".tcg-suite.json"),"utf-8"))?.requestId===t}catch{return!1}}function T(e){return e&&e.length>0?e:void 0}function re(e,t){return e?e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean).slice(0,t).join("-"):""}function Ee(e){return e?e.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,""):""}function ht(e){let t=[];e.title&&t.push(e.title),e.description&&t.push("",e.description);let n=R(e.manual_steps);return n.length>0&&(t.push("","Steps:"),n.forEach((i,d)=>{t.push(`${d+1}. ${i.step}`)})),t.join(`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as u,b as x}from"./chunk-FEJXWJ3L.js";import{y as m}from"./chunk-27U4PLPX.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as r,b as i}from"./chunk-C44QQJR4.js";import{e as n}from"./chunk-UR6MHSHU.js";var e=n(f(),1);function C({title:B,titleColor:c,borderColor:d,variant:p,rows:s,footer:t,labelWidth:l=14,marginBottom:b=1}){return(0,e.jsxs)(u,{title:B,titleColor:c,borderColor:d,variant:p,marginBottom:b,children:[s.map((o,a)=>typeof o.value=="string"?(0,e.jsx)(x,{label:o.label,value:o.value,valueColor:o.valueColor,labelWidth:l},`${o.label}-${a}`):(0,e.jsxs)(r,{children:[(0,e.jsx)(r,{width:l,children:(0,e.jsx)(i,{color:m.dim,children:o.label})}),o.value]},`${o.label}-${a}`)),t&&(0,e.jsx)(r,{marginTop:1,children:t})]})}export{C as a};
2
+ import{a as u,b as x}from"./chunk-LCU2P3CH.js";import{y as m}from"./chunk-D6FYCAIA.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as r,b as i}from"./chunk-C44QQJR4.js";import{e as n}from"./chunk-UR6MHSHU.js";var e=n(f(),1);function C({title:B,titleColor:c,borderColor:d,variant:p,rows:s,footer:t,labelWidth:l=14,marginBottom:b=1}){return(0,e.jsxs)(u,{title:B,titleColor:c,borderColor:d,variant:p,marginBottom:b,children:[s.map((o,a)=>typeof o.value=="string"?(0,e.jsx)(x,{label:o.label,value:o.value,valueColor:o.valueColor,labelWidth:l},`${o.label}-${a}`):(0,e.jsxs)(r,{children:[(0,e.jsx)(r,{width:l,children:(0,e.jsx)(i,{color:m.dim,children:o.label})}),o.value]},`${o.label}-${a}`)),t&&(0,e.jsx)(r,{marginTop:1,children:t})]})}export{C as a};