@testmuai/kane-cli 0.8.18 → 0.8.20

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 (181) hide show
  1. package/dist/{ChatSurface-SY7HJD46.js → ChatSurface-757LHEYF.js} +1 -1
  2. package/dist/{ChromeProfilePicker-NCIURJK6.js → ChromeProfilePicker-UAMRJG2H.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-TTVW5COG.js → CliFeedbackPrompt-NAPKBEOP.js} +1 -1
  4. package/dist/{CliUploadProgress-E3WEIF36.js → CliUploadProgress-R6FHYXP5.js} +1 -1
  5. package/dist/{ConfigView-ZY37EGAO.js → ConfigView-CKYIRJBS.js} +1 -1
  6. package/dist/{EvidenceViewOffer-6KT64W7L.js → EvidenceViewOffer-M3DAU4YU.js} +1 -1
  7. package/dist/FolderPicker-I2E2EJON.js +2 -0
  8. package/dist/{InfoBox-JP3TTPIO.js → InfoBox-WKFPWFII.js} +1 -1
  9. package/dist/{LinksBox-4ZB7G5ET.js → LinksBox-MQOD3X3E.js} +1 -1
  10. package/dist/{ProfilesView-25AXMCKS.js → ProfilesView-PLO2SBGI.js} +1 -1
  11. package/dist/{ProjectPicker-RL3LXLTV.js → ProjectPicker-QT2IENIZ.js} +1 -1
  12. package/dist/{SaveSessionPrompt-5W4ATISN.js → SaveSessionPrompt-BRNUVO5J.js} +1 -1
  13. package/dist/SingleShotApp-CQWGPSLT.js +2 -0
  14. package/dist/{SummaryBox-GW4XAX5T.js → SummaryBox-7OBZAVJU.js} +1 -1
  15. package/dist/TestMdRunView-GIOPBTA6.js +2 -0
  16. package/dist/{TestrunEvidenceTable-SYCFAGM4.js → TestrunEvidenceTable-PKFPTUZX.js} +1 -1
  17. package/dist/{WhoamiView-H2DRYRRA.js → WhoamiView-CINKGNTV.js} +1 -1
  18. package/dist/{app-download-2IZ4GPTA.js → app-download-KLCWIQWJ.js} +1 -1
  19. package/dist/{auth-6PKLNV6Z.js → auth-L7PFZJBY.js} +1 -1
  20. package/dist/{binary-OMBH4UTI.js → binary-25KA3XAX.js} +1 -1
  21. package/dist/{bind-IHLHM5UM.js → bind-N5QZUUUU.js} +2 -2
  22. package/dist/{bootstrap-UKZX3LRC.js → bootstrap-545GY5CC.js} +1 -1
  23. package/dist/bridge-VNFL4T6K.js +2 -0
  24. package/dist/{changelog-ZWOIODQ4.js → changelog-ABQ5HREB.js} +1 -1
  25. package/dist/{chunk-7DSZ2YSD.js → chunk-2TNMV4BX.js} +1 -1
  26. package/dist/{chunk-6OIC4S3C.js → chunk-3Q5IQXOI.js} +1 -1
  27. package/dist/{chunk-5RJ2J5QU.js → chunk-47ZPSTT6.js} +1 -1
  28. package/dist/{chunk-WTAJTPI5.js → chunk-4K44ZIC4.js} +1 -1
  29. package/dist/{chunk-4JRCAHHB.js → chunk-4L45IQNU.js} +1 -1
  30. package/dist/{chunk-MSLYSXGM.js → chunk-4ZVGZF2L.js} +1 -1
  31. package/dist/{chunk-GUFIE3Z2.js → chunk-56UYK35Z.js} +1 -1
  32. package/dist/{chunk-6FEEYKSE.js → chunk-5FCXFSAO.js} +1 -1
  33. package/dist/{chunk-ZMM3Y6U7.js → chunk-5UCXN56I.js} +1 -1
  34. package/dist/{chunk-RBVLIMOV.js → chunk-5WZ2WOOM.js} +1 -1
  35. package/dist/{chunk-WWVHK7OA.js → chunk-6MTKXDTH.js} +1 -1
  36. package/dist/{chunk-AK7BMF5T.js → chunk-6V4ANMW4.js} +1 -1
  37. package/dist/{chunk-ZARM7ESN.js → chunk-7BKOTLIL.js} +1 -1
  38. package/dist/{chunk-LHU6TEKD.js → chunk-7SV2NQZV.js} +1 -1
  39. package/dist/chunk-7XC5IQN6.js +95 -0
  40. package/dist/{chunk-7ZSHB3AN.js → chunk-A55WPXDZ.js} +1 -1
  41. package/dist/{chunk-DKPRWI7U.js → chunk-ALK3OUGN.js} +2 -2
  42. package/dist/{chunk-EW3KRQGF.js → chunk-ARCYAF37.js} +1 -1
  43. package/dist/{chunk-JMWRMDSI.js → chunk-AXJ47YFH.js} +1 -1
  44. package/dist/{chunk-WAZUOA3Y.js → chunk-BNWU7JOW.js} +1 -1
  45. package/dist/{chunk-4B3EHSTD.js → chunk-CLLLLX4F.js} +1 -1
  46. package/dist/{chunk-YAUR5CBH.js → chunk-CVXVFF2G.js} +1 -1
  47. package/dist/{chunk-EYVHPJLK.js → chunk-CXXTQ4C5.js} +1 -1
  48. package/dist/{chunk-6VB4FGBZ.js → chunk-DCLMFWCF.js} +1 -1
  49. package/dist/{chunk-7PLIZBXB.js → chunk-DFHVZZI3.js} +1 -1
  50. package/dist/{chunk-G76O7C56.js → chunk-DVYQVSNS.js} +1 -1
  51. package/dist/{chunk-7ZKVI4US.js → chunk-E6MW25UV.js} +1 -1
  52. package/dist/{chunk-H5N25XIT.js → chunk-EPVK2NMQ.js} +1 -1
  53. package/dist/{chunk-ZO75BQ3Z.js → chunk-EV3EU2MT.js} +1 -1
  54. package/dist/{chunk-5WUDW6BG.js → chunk-FD5TFGJX.js} +1 -1
  55. package/dist/{chunk-C3GDK2OS.js → chunk-FNJJGQUI.js} +1 -1
  56. package/dist/{chunk-EKZI5HZV.js → chunk-FYW7USQY.js} +1 -1
  57. package/dist/{chunk-L4U7NP5Q.js → chunk-G5Q4EJAT.js} +1 -1
  58. package/dist/{chunk-YNOADDF7.js → chunk-I3NUTW6U.js} +1 -1
  59. package/dist/{chunk-UUS5AK6L.js → chunk-IHVIIRW5.js} +2 -2
  60. package/dist/{chunk-SYKS57PK.js → chunk-ISBISZUE.js} +1 -1
  61. package/dist/{chunk-J3OGBEEP.js → chunk-IYOL2FUH.js} +1 -1
  62. package/dist/{chunk-DH3H6GWD.js → chunk-JKQX7DUC.js} +1 -1
  63. package/dist/chunk-K3EN7O5N.js +26 -0
  64. package/dist/{chunk-OVL4WXGF.js → chunk-K4D5BB63.js} +1 -1
  65. package/dist/{chunk-UAEU5IPH.js → chunk-LJ5O7DZ7.js} +2 -2
  66. package/dist/{chunk-NXZPWMK5.js → chunk-LPVAOUAC.js} +1 -1
  67. package/dist/{chunk-5NZUMWUD.js → chunk-M5V464PU.js} +2 -2
  68. package/dist/{chunk-WQV5SM5P.js → chunk-N3MZALFQ.js} +1 -1
  69. package/dist/{chunk-EHOYD6VL.js → chunk-NFQ67CQO.js} +3 -3
  70. package/dist/{chunk-5B2NEYHF.js → chunk-OGWYTILK.js} +2 -2
  71. package/dist/{chunk-UQ6A52ML.js → chunk-OWPQZP4C.js} +1 -1
  72. package/dist/{chunk-VH73F65W.js → chunk-P6HK7GSS.js} +7 -6
  73. package/dist/{chunk-MMLYJDXO.js → chunk-PCBCEXYO.js} +1 -1
  74. package/dist/{chunk-NYP7QV54.js → chunk-PN4EL4JN.js} +1 -1
  75. package/dist/{chunk-H7A4R7WY.js → chunk-PP4I2Z6M.js} +1 -1
  76. package/dist/{chunk-YPEIPCQY.js → chunk-PY4BWRR6.js} +1 -1
  77. package/dist/{chunk-IFQD53QB.js → chunk-Q5PQ7U3W.js} +1 -1
  78. package/dist/{chunk-CHA75LBJ.js → chunk-QBU5B4GH.js} +1 -1
  79. package/dist/chunk-R54VY272.js +6 -0
  80. package/dist/{chunk-TSNQLZE3.js → chunk-R5UVQMMP.js} +1 -1
  81. package/dist/{chunk-4R5U7CHE.js → chunk-R6RK32R2.js} +1 -1
  82. package/dist/{chunk-47FQ7ZUQ.js → chunk-RMLC3QWX.js} +1 -1
  83. package/dist/{chunk-ALHCB3LL.js → chunk-RPJUE54T.js} +1 -1
  84. package/dist/{chunk-4BKSQFEP.js → chunk-RTD27WRG.js} +1 -1
  85. package/dist/{chunk-PVJB7CVS.js → chunk-RV3KMXUX.js} +1 -1
  86. package/dist/{chunk-GESZSIB6.js → chunk-SA7ORQHP.js} +1 -1
  87. package/dist/{chunk-QX5LJVTD.js → chunk-SBSANJ2T.js} +2 -2
  88. package/dist/{chunk-DDLEZGZB.js → chunk-SHXJQ73O.js} +1 -1
  89. package/dist/{chunk-EJBJ7MYC.js → chunk-T27HVHZA.js} +1 -1
  90. package/dist/{chunk-UE5EYEFI.js → chunk-T7UACVWW.js} +1 -1
  91. package/dist/{chunk-EA2LT5OJ.js → chunk-TEJG5H2O.js} +1 -1
  92. package/dist/{chunk-BXM5GDIO.js → chunk-TFGGJSTI.js} +2 -2
  93. package/dist/{chunk-IGLCR4J2.js → chunk-U7WMRB5V.js} +1 -1
  94. package/dist/{chunk-PMBQU63H.js → chunk-UFWG6VMI.js} +1 -1
  95. package/dist/{chunk-SBQUEGTP.js → chunk-UUT7EHLT.js} +1 -1
  96. package/dist/{chunk-XYMUKOKK.js → chunk-UVR7MESH.js} +1 -1
  97. package/dist/{chunk-IQCW5SV5.js → chunk-UYTBGBT4.js} +1 -1
  98. package/dist/{chunk-MVOO7RPO.js → chunk-VKFLER7N.js} +1 -1
  99. package/dist/{chunk-4ANRRDC7.js → chunk-VL7LPZVI.js} +1 -1
  100. package/dist/{chunk-PDXZROJM.js → chunk-W3USRQX6.js} +1 -1
  101. package/dist/{chunk-F3IWJ73B.js → chunk-X77AR3IL.js} +1 -1
  102. package/dist/{chunk-LQMA6N5S.js → chunk-XSZH2K3E.js} +1 -1
  103. package/dist/{chunk-2LKSDGWA.js → chunk-Y67FYNLP.js} +1 -1
  104. package/dist/chunk-YKYHVRM2.js +5 -0
  105. package/dist/{chunk-7BMM5DFP.js → chunk-YL5J3SNK.js} +1 -1
  106. package/dist/{chunk-ZV5KM7LI.js → chunk-YV6CSSWA.js} +1 -1
  107. package/dist/{chunk-ZW3JBY5E.js → chunk-ZXP2TJEJ.js} +4 -4
  108. package/dist/{config-ODCFEOAN.js → config-A6MBUY54.js} +1 -1
  109. package/dist/{cover-cmd-AQ7PWJRH.js → cover-cmd-TIY53OMC.js} +1 -1
  110. package/dist/{credentials-MUZUCSJJ.js → credentials-GXICFDVV.js} +1 -1
  111. package/dist/{deps-bundle-7COKI7UV.js → deps-bundle-RDGQAIGD.js} +1 -1
  112. package/dist/{deps-resolve-ADN7P5L7.js → deps-resolve-52BOL7G6.js} +1 -1
  113. package/dist/{dispatch-V24LFEAO.js → dispatch-GJ7RVYPK.js} +1 -1
  114. package/dist/{doctor-3BRZM4EW.js → doctor-XNI2NZZJ.js} +1 -1
  115. package/dist/evidence-QYJ7SQR6.js +2 -0
  116. package/dist/{evolve-cmd-IR7UGOD2.js → evolve-cmd-2LM6NKMY.js} +1 -1
  117. package/dist/{explain-cmd-NNYKSAQK.js → explain-cmd-LQ5CHHNY.js} +1 -1
  118. package/dist/{extract-bind-2GGLO5KU.js → extract-bind-NWA4PSTU.js} +2 -2
  119. package/dist/{extract-cmd-2BQJ2HNT.js → extract-cmd-Q5PZS626.js} +1 -1
  120. package/dist/{gaps-cmd-Y6CZUCIX.js → gaps-cmd-UKMO7KYX.js} +1 -1
  121. package/dist/{generate-headless-SPGLBRH5.js → generate-headless-CLKY4IAU.js} +2 -2
  122. package/dist/index.js +121 -121
  123. package/dist/{ingest-cmd-N37FGNP5.js → ingest-cmd-JZNVRFFS.js} +1 -1
  124. package/dist/install-FLC6WLPZ.js +2 -0
  125. package/dist/{interactive-bind-ZLO6S2SG.js → interactive-bind-7JMBM3OK.js} +3 -3
  126. package/dist/{lifecycle-cmd-6TWIQCKR.js → lifecycle-cmd-VMZKHC2Y.js} +1 -1
  127. package/dist/{list-cmd-NDD2OSP5.js → list-cmd-3XDCASJH.js} +1 -1
  128. package/dist/{list-commands-AARQ2RZG.js → list-commands-QURMKZZH.js} +1 -1
  129. package/dist/login-flow-BPT46DCE.js +2 -0
  130. package/dist/{maintenance-cmd-4QUVSGUY.js → maintenance-cmd-MQ4GCVDU.js} +1 -1
  131. package/dist/{mobile-prompts-GYJS5BYX.js → mobile-prompts-VXNHSCAH.js} +1 -1
  132. package/dist/{objective-variable-gate-FUVNHKRA.js → objective-variable-gate-BDSG2BEA.js} +1 -1
  133. package/dist/{open-provider-QTPN6XOL.js → open-provider-ZYBUD6JW.js} +1 -1
  134. package/dist/{persist-recorded-session-UFK5VC7S.js → persist-recorded-session-NV2ULVPH.js} +1 -1
  135. package/dist/{pipeline-Z477UOXV.js → pipeline-STTNBJC4.js} +1 -1
  136. package/dist/prepare-target-CRO3BGAP.js +2 -0
  137. package/dist/{reconcile-cmd-NDLEM54D.js → reconcile-cmd-VQTFUGEJ.js} +1 -1
  138. package/dist/{reconcile-deps-APR2LE3C.js → reconcile-deps-SE6COSXQ.js} +2 -2
  139. package/dist/{reconcile-engine-C72AP4WS.js → reconcile-engine-GLKGQEVR.js} +1 -1
  140. package/dist/{recording-banner-AZOKNSU3.js → recording-banner-WZECSZJM.js} +1 -1
  141. package/dist/registry-GQEYUEQJ.js +2 -0
  142. package/dist/{require-project-folder-LTVPPY3Q.js → require-project-folder-OFA4F2T5.js} +1 -1
  143. package/dist/{resolve-run-intent-XX6O3RYT.js → resolve-run-intent-M7EXFU7E.js} +1 -1
  144. package/dist/{resolver-XMASFMID.js → resolver-TZAQGCFJ.js} +1 -1
  145. package/dist/{review-cmd-4TNBQDJU.js → review-cmd-RXD2RWKN.js} +1 -1
  146. package/dist/{run-XXA7ILIM.js → run-DVBOAY7S.js} +1 -1
  147. package/dist/{run-EOIV3OQE.js → run-VF2MBI6M.js} +1 -1
  148. package/dist/{run-test-md-GVRVMPRZ.js → run-test-md-Z75BGXRK.js} +2 -2
  149. package/dist/{skill-installer-AWQT3LM2.js → skill-installer-FEOJ4KX3.js} +1 -1
  150. package/dist/{spawner-O3VKHYUY.js → spawner-XHE7OXNW.js} +1 -1
  151. package/dist/{store-guard-MHWBXA4C.js → store-guard-HIBKFC2T.js} +1 -1
  152. package/dist/{sync-cmd-P2CL6YA6.js → sync-cmd-MZYM5IE6.js} +1 -1
  153. package/dist/{sync-setup-JY4T2X3M.js → sync-setup-WGYN6ZTI.js} +1 -1
  154. package/dist/tcg-generate-Y2UMDGPL.js +2 -0
  155. package/dist/testmd-actions-UDNH6W2Z.js +2 -0
  156. package/dist/{testmd-sync-IRV44CGT.js → testmd-sync-4BXMEIJ3.js} +1 -1
  157. package/dist/token-refresh-KYIQ7LZL.js +2 -0
  158. package/dist/{validate-basic-A5TEMJNT.js → validate-basic-GBA5PHIK.js} +1 -1
  159. package/dist/{variable-receipt-QDP2S5CQ.js → variable-receipt-WMV33LAD.js} +1 -1
  160. package/dist/{verdicts-H755EUQL.js → verdicts-34ZGB67K.js} +1 -1
  161. package/dist/{version-check-26W5GVBQ.js → version-check-BHRM4PN4.js} +1 -1
  162. package/dist/{view-cmd-D3BYBDZE.js → view-cmd-FJGT5KZO.js} +1 -1
  163. package/dist/{walk-session-ZZ26LEQE.js → walk-session-CTZ5475S.js} +1 -1
  164. package/dist/{with-telemetry-UE6SYQWL.js → with-telemetry-AIPWSH4P.js} +1 -1
  165. package/package.json +11 -11
  166. package/dist/FolderPicker-MPLLN4VP.js +0 -2
  167. package/dist/SingleShotApp-JV64B4XL.js +0 -2
  168. package/dist/TestMdRunView-7N6QXMNR.js +0 -2
  169. package/dist/bridge-KJNDGKPU.js +0 -2
  170. package/dist/chunk-2KYJOBNI.js +0 -6
  171. package/dist/chunk-N4HKQTD5.js +0 -93
  172. package/dist/chunk-TG4GGP3H.js +0 -26
  173. package/dist/chunk-YVKNKK22.js +0 -5
  174. package/dist/evidence-EBD3FIXA.js +0 -2
  175. package/dist/install-2PUHCC2Y.js +0 -2
  176. package/dist/login-flow-V4US6VQP.js +0 -2
  177. package/dist/prepare-target-IES7FXJG.js +0 -2
  178. package/dist/registry-W3BMHQDQ.js +0 -2
  179. package/dist/tcg-generate-GWLHZYLF.js +0 -2
  180. package/dist/testmd-actions-SYMNRTK4.js +0 -2
  181. package/dist/token-refresh-IM6ELK6S.js +0 -2
@@ -1,10 +1,10 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as j,b as H}from"./chunk-5NZUMWUD.js";import{a as B,b as N}from"./chunk-EW3KRQGF.js";import{a as se,b as ie,c as ae}from"./chunk-PDXZROJM.js";import{d as ce}from"./chunk-YAUR5CBH.js";import{a as $,b as q,e as M,g as oe}from"./chunk-L45HDSJ7.js";import{a as re,b as ne}from"./chunk-CAOZKSQ3.js";import{a as L}from"./chunk-GESZSIB6.js";import{a as te}from"./chunk-H7A4R7WY.js";import{a as X}from"./chunk-RBVLIMOV.js";import{a as ee}from"./chunk-DHJSM5DT.js";import{a as A}from"./chunk-RZ4F3BHX.js";import{a as O}from"./chunk-47FQ7ZUQ.js";import{y}from"./chunk-UQ6A52ML.js";import{a as F}from"./chunk-HCBYKLMW.js";import{a as k,b as p,i as Z}from"./chunk-C44QQJR4.js";import{a as K}from"./chunk-6YGTRKDT.js";import{e as v}from"./chunk-UR6MHSHU.js";var D=v(K(),1);import{existsSync as P,readFileSync as He,rmSync as ye,unlinkSync as Ve}from"fs";import{resolve as Q}from"path";import{promises as le,realpathSync as Ee}from"fs";import{homedir as Se}from"os";import{join as V,parse as ve,relative as ue,resolve as de}from"path";var fe=new Set(["node_modules",".git","dist","build",".next",".venv","venv","target","__pycache__"]),R=class extends Error{constructor(s){super(`refusing to scan '${s}'. Run from your project root, or pass --root <dir>.`);this.cwd=s;this.name="HomeRefusedError"}};function me(e){try{return Ee(de(e))}catch{return de(e)}}function Re(e){let r=me(e),s=me(Se()),n=ve(r).root;if(process.platform==="win32"){let o=t=>t.toLowerCase();return o(r)===o(s)||o(r)===o(n)}return r===s||r===n}async function U(e){if(Re(e.root))throw new R(e.root);let r=e.maxEntries??5e4,s=e.maxResults??5e3,n=new Set(e.ignore??[]),o=[],t=0,i=0,a=!1,u,c=[e.root];for(;c.length>0&&!a;){let l=c.shift(),g;try{g=await le.readdir(l,{withFileTypes:!0})}catch{continue}i++;for(let _ of g){if(t++,t>r){a=!0,u="max_entries";break}let m=_.name,T=V(l,m);if(_.isDirectory()){if(fe.has(m)||m.startsWith(".")||m.startsWith("output-")||n.has(m))continue;c.push(T)}else if(_.isFile()&&m.endsWith("_test.md")&&(o.push({path:T,relPath:ue(e.root,T),source:"cwd"}),o.length>=s)){a=!0,u="max_results";break}}e.onProgress?.(i,o.length)}if(!a){let g=[{dir:V(e.root,".testmuai","tests"),depth:0}];for(;g.length>0&&!a;){let{dir:_,depth:m}=g.shift(),T;try{T=await le.readdir(_,{withFileTypes:!0})}catch{continue}i++;for(let d of T){if(t++,t>r){a=!0,u="max_entries";break}let b=d.name,w=V(_,b);if(d.isDirectory()){if(m>=20||b.startsWith(".")||b.startsWith("output-")||fe.has(b))continue;g.push({dir:w,depth:m+1})}else if(d.isFile()&&b.endsWith("_test.md")&&(o.push({path:w,relPath:ue(e.root,w),source:"tests-dir"}),o.length>=s)){a=!0,u="max_results";break}}}}return{results:o,aborted:a,abortReason:u,dirsScanned:i}}import{readFileSync as Pe}from"fs";function Y(e){let r;try{r=Pe(e,"utf8")}catch{return{tags:[]}}try{let{global:s}=re(e,r),n=ne(s);return{tags:s.tags??[],...n?{mobileTarget:n}:{}}}catch{return{tags:[],...De(r)?{mobileTarget:Me}:{}}}}var Me={platform:"",app:""};function De(e){let r=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!r)return!1;let s=r[1].split(/\r?\n/);if(s.some(o=>/^target:\s*['"]?(emulator|simulator)['"]?\s*$/.test(o)))return!0;let n=s.findIndex(o=>/^target:\s*$/.test(o));return n<0?!1:s.slice(n+1).some(o=>/^\s+\S/.test(o))}function W(e){return Y(e).tags}import{mkdirSync as Ce,writeFileSync as $e}from"fs";import{join as Ie}from"path";function ge(e,r){return`Basic ${Buffer.from(`${e}:${r}`).toString("base64")}`}async function Fe(e){let r=ie({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId,codeExport:{enabled:!0,language:e.language,skipValidation:e.skipValidation},mobile:e.framework==="appium"}),s=await A(r.url,{method:"POST",headers:{"content-type":"application/json",authorization:ge(e.auth.username,e.auth.access_key)},body:JSON.stringify(r.body)});if(!s.ok)throw new Error(`code-export trigger failed: ${s.status} ${await s.text()}`);e.log("info","CODE_EXPORT_TRIGGERED","Code export triggered",{testcase_id:e.testcaseId})}async function Oe(e){let r=ae({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId}),s=e.pollIntervalMs??5e3,n=e.timeoutMs??3e5,o=Date.now()+n;for(;Date.now()<o;){let t=await A(r,{headers:{authorization:ge(e.auth.username,e.auth.access_key),accept:"application/json"}});if(!t.ok){await new Promise(c=>setTimeout(c,s));continue}let a=(await t.json()).data?.find(c=>c.code_name==="kane-cli-trigger");if(!a){await new Promise(c=>setTimeout(c,s));continue}let u=(a.status??"").toLowerCase();if(u==="in progress"||u==="in_progress"||u==="pending"){await new Promise(c=>setTimeout(c,s));continue}if(!a.url||a.url.length===0)throw new Error(`code-export status=${a.status} but no files returned`);Ce(e.outDir,{recursive:!0});for(let c of a.url){let l=Ie(e.outDir,c.file_name),g=await A(c.file_url);if(!g.ok){e.log("warn","CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:c.file_name,status:g.status});continue}let _=await g.text();$e(l,_,"utf-8")}return e.log("info","CODE_EXPORT_DOWNLOADED","Code export saved",{out_dir:e.outDir,file_count:a.url.length}),e.outDir}throw new Error("code-export polling timed out")}async function pe(e){return await Fe(e),await Oe(e)}var E=v(K(),1);import{existsSync as Ae,readFileSync as Le}from"fs";var h=v(F(),1);function je(e){j(e);let r=M(e);if(!Ae(r))return null;try{return JSON.parse(Le(r,"utf8"))}catch{return{}}}function Be(e){return e===null?"never_run":e.testcase_id?"synced":"local_only"}function Ne(e){return e==="synced"?"\u2601":e==="local_only"?"\u25A3":"\u25CB"}function Ue(e){return e==="tests-dir"?"\u2726":" "}function We(e,r){return r==="all"?!0:r==="synced"?e.status==="synced":r==="local"?e.status==="local_only":r==="never_run"?e.status==="never_run":r==="cli"?e.source==="tests-dir":r==="hand"?e.source==="cwd":!0}var z=["all","synced","local","never_run","cli","hand"];function Je(e){let r=z.indexOf(e);return z[(r+1)%z.length]}function he({root:e,currentOrgId:r,onSelect:s,onCancel:n}){let[o,t]=(0,E.useState)([]),[i,a]=(0,E.useState)(null),[u,c]=(0,E.useState)(!0),[l,g]=(0,E.useState)("all");(0,E.useEffect)(()=>{(async()=>{try{let d=await U({root:e}),b=[];for(let w of d.results){let G=je(w.path);G?.org_id!==void 0&&G.org_id!==r||b.push({path:w.path,relPath:w.relPath,name:$(w.path),status:Be(G),source:w.source,tags:W(w.path)})}t(b),c(!1)}catch(d){d instanceof R,a(d.message),c(!1)}})()},[e,r]);let _=(0,E.useMemo)(()=>o.filter(d=>We(d,l)).map(d=>({id:d.path,label:`${Ne(d.status)} ${Ue(d.source)} ${d.relPath}${d.tags.length>0?` [${d.tags.join(", ")}]`:""}`})),[o,l]),m=(0,E.useMemo)(()=>Ke(l,o),[l,o]);if(i)return(0,h.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:y.red,paddingX:2,paddingY:1,children:[(0,h.jsx)(p,{color:y.red,bold:!0,children:"testmd"}),(0,h.jsx)(k,{marginTop:1,children:(0,h.jsx)(p,{color:y.red,children:i})})]});let T=l==="all"?"all":Ge(l);return(0,h.jsx)(te,{title:`testmd \xB7 filter: ${T}`,items:_,loading:u,itemNoun:"tests",onSelect:d=>{let b=o.find(w=>w.path===d.id);b&&s(b)},onCancel:n,onTab:()=>g(d=>Je(d)),extraHint:"cycle filter",footer:m})}function Ge(e){return e==="synced"?"synced (\u2601)":e==="local"?"local (\u25A3)":e==="never_run"?"never run (\u25CB)":e==="cli"?"cli-generated (\u2726)":e==="hand"?"hand-written":"all"}function Ke(e,r){let s={synced:r.filter(o=>o.status==="synced").length,local:r.filter(o=>o.status==="local_only").length,never:r.filter(o=>o.status==="never_run").length,cli:r.filter(o=>o.source==="tests-dir").length,hand:r.filter(o=>o.source==="cwd").length},n=o=>o?y.orange:y.dim;return(0,h.jsxs)(k,{flexDirection:"column",children:[(0,h.jsx)(p,{color:y.dim,children:"legend:"}),(0,h.jsxs)(k,{children:[(0,h.jsx)(p,{color:n(e==="synced"),children:` \u2601 synced (${s.synced}) `}),(0,h.jsx)(p,{color:n(e==="local"),children:`\u25A3 local (${s.local}) `}),(0,h.jsx)(p,{color:n(e==="never_run"),children:`\u25CB never run (${s.never})`})]}),(0,h.jsxs)(k,{children:[(0,h.jsx)(p,{color:n(e==="cli"),children:` \u2726 cli-generated (${s.cli}) `}),(0,h.jsx)(p,{color:n(e==="hand"),children:` hand-written (${s.hand})`})]})]})}var I=v(K(),1);import{existsSync as Xe,readFileSync as qe}from"fs";var f=v(F(),1);function _e({path:e,relPath:r,onAction:s,onBack:n,onView:o}){let[t,i]=(0,I.useState)(null),[a,u]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let l=M(e);if(Xe(l))try{i(JSON.parse(qe(l,"utf8")))}catch{i(null)}},[e]),Z((l,g)=>{if(g.escape){if(a){u(!1);return}n();return}if(a){l==="y"||l==="Y"?(u(!1),s("delete")):(l==="n"||l==="N")&&u(!1);return}l==="r"&&s("run"),l==="e"&&t?.testcase_id&&s("export"),l==="d"&&u(!0),l==="v"&&o&&o()});let c=({k:l,v:g})=>g?(0,f.jsxs)(p,{children:[(0,f.jsx)(p,{color:y.dim,children:l.padEnd(14)}),g]}):null;return(0,f.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:y.orange,paddingX:2,paddingY:1,children:[(0,f.jsx)(p,{color:y.orange,bold:!0,children:r}),(0,f.jsx)(k,{marginTop:1,flexDirection:"column",children:t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(c,{k:"test_id",v:t.test_id}),(0,f.jsx)(c,{k:"testcase_id",v:t.testcase_id}),(0,f.jsx)(c,{k:"project_id",v:t.project_id}),(0,f.jsx)(c,{k:"folder_id",v:t.folder_id}),(0,f.jsx)(c,{k:"org_id",v:t.org_id}),(0,f.jsx)(c,{k:"session_name",v:t.session_name}),(0,f.jsx)(c,{k:"commit_id",v:t.commit_id})]}):(0,f.jsx)(p,{color:y.dim,children:"(never run \u2014 no meta.json)"})}),a?(0,f.jsx)(k,{marginTop:1,children:(0,f.jsxs)(p,{color:y.red,bold:!0,children:["Delete ",r," and its output dir? [y/n]"]})}):(0,f.jsx)(k,{marginTop:1,children:(0,f.jsxs)(p,{color:y.dim,children:["[r] run [e] export",t?.testcase_id?"":" (need testcase_id)"," [d] delete",o?" [v] view":""," [Esc] back"]})})]})}function C(e){j(e);let r=M(e);if(!P(r))return null;try{return JSON.parse(He(r,"utf8"))}catch{return null}}function xe(e,r){return!e||e.org_id===void 0?!0:e.org_id===r}function J(e,r){return xe(e,r)?null:(process.stderr.write(`error: this test belongs to org ${e.org_id}; you are logged in as org ${r}.
2
+ import{a as j,b as H}from"./chunk-M5V464PU.js";import{a as B,b as N}from"./chunk-ARCYAF37.js";import{a as se,b as ie,c as ae}from"./chunk-W3USRQX6.js";import{d as ce}from"./chunk-CVXVFF2G.js";import{a as $,b as q,e as M,g as oe}from"./chunk-L45HDSJ7.js";import{a as re,b as ne}from"./chunk-CAOZKSQ3.js";import{a as L}from"./chunk-SA7ORQHP.js";import{a as te}from"./chunk-PP4I2Z6M.js";import{a as X}from"./chunk-5WZ2WOOM.js";import{a as ee}from"./chunk-DHJSM5DT.js";import{a as A}from"./chunk-RZ4F3BHX.js";import{a as O}from"./chunk-RMLC3QWX.js";import{y}from"./chunk-OWPQZP4C.js";import{a as F}from"./chunk-HCBYKLMW.js";import{a as k,b as p,i as Z}from"./chunk-C44QQJR4.js";import{a as K}from"./chunk-6YGTRKDT.js";import{e as v}from"./chunk-UR6MHSHU.js";var D=v(K(),1);import{existsSync as P,readFileSync as He,rmSync as ye,unlinkSync as Ve}from"fs";import{resolve as Q}from"path";import{promises as le,realpathSync as Ee}from"fs";import{homedir as Se}from"os";import{join as V,parse as ve,relative as ue,resolve as de}from"path";var fe=new Set(["node_modules",".git","dist","build",".next",".venv","venv","target","__pycache__"]),R=class extends Error{constructor(s){super(`refusing to scan '${s}'. Run from your project root, or pass --root <dir>.`);this.cwd=s;this.name="HomeRefusedError"}};function me(e){try{return Ee(de(e))}catch{return de(e)}}function Re(e){let r=me(e),s=me(Se()),n=ve(r).root;if(process.platform==="win32"){let o=t=>t.toLowerCase();return o(r)===o(s)||o(r)===o(n)}return r===s||r===n}async function U(e){if(Re(e.root))throw new R(e.root);let r=e.maxEntries??5e4,s=e.maxResults??5e3,n=new Set(e.ignore??[]),o=[],t=0,i=0,a=!1,u,c=[e.root];for(;c.length>0&&!a;){let l=c.shift(),g;try{g=await le.readdir(l,{withFileTypes:!0})}catch{continue}i++;for(let _ of g){if(t++,t>r){a=!0,u="max_entries";break}let m=_.name,T=V(l,m);if(_.isDirectory()){if(fe.has(m)||m.startsWith(".")||m.startsWith("output-")||n.has(m))continue;c.push(T)}else if(_.isFile()&&m.endsWith("_test.md")&&(o.push({path:T,relPath:ue(e.root,T),source:"cwd"}),o.length>=s)){a=!0,u="max_results";break}}e.onProgress?.(i,o.length)}if(!a){let g=[{dir:V(e.root,".testmuai","tests"),depth:0}];for(;g.length>0&&!a;){let{dir:_,depth:m}=g.shift(),T;try{T=await le.readdir(_,{withFileTypes:!0})}catch{continue}i++;for(let d of T){if(t++,t>r){a=!0,u="max_entries";break}let b=d.name,w=V(_,b);if(d.isDirectory()){if(m>=20||b.startsWith(".")||b.startsWith("output-")||fe.has(b))continue;g.push({dir:w,depth:m+1})}else if(d.isFile()&&b.endsWith("_test.md")&&(o.push({path:w,relPath:ue(e.root,w),source:"tests-dir"}),o.length>=s)){a=!0,u="max_results";break}}}}return{results:o,aborted:a,abortReason:u,dirsScanned:i}}import{readFileSync as Pe}from"fs";function Y(e){let r;try{r=Pe(e,"utf8")}catch{return{tags:[]}}try{let{global:s}=re(e,r),n=ne(s);return{tags:s.tags??[],...n?{mobileTarget:n}:{}}}catch{return{tags:[],...De(r)?{mobileTarget:Me}:{}}}}var Me={platform:"",app:""};function De(e){let r=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!r)return!1;let s=r[1].split(/\r?\n/);if(s.some(o=>/^target:\s*['"]?(emulator|simulator)['"]?\s*$/.test(o)))return!0;let n=s.findIndex(o=>/^target:\s*$/.test(o));return n<0?!1:s.slice(n+1).some(o=>/^\s+\S/.test(o))}function W(e){return Y(e).tags}import{mkdirSync as Ce,writeFileSync as $e}from"fs";import{join as Ie}from"path";function ge(e,r){return`Basic ${Buffer.from(`${e}:${r}`).toString("base64")}`}async function Fe(e){let r=ie({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId,codeExport:{enabled:!0,language:e.language,skipValidation:e.skipValidation},mobile:e.framework==="appium"}),s=await A(r.url,{method:"POST",headers:{"content-type":"application/json",authorization:ge(e.auth.username,e.auth.access_key)},body:JSON.stringify(r.body)});if(!s.ok)throw new Error(`code-export trigger failed: ${s.status} ${await s.text()}`);e.log("info","CODE_EXPORT_TRIGGERED","Code export triggered",{testcase_id:e.testcaseId})}async function Oe(e){let r=ae({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId}),s=e.pollIntervalMs??5e3,n=e.timeoutMs??3e5,o=Date.now()+n;for(;Date.now()<o;){let t=await A(r,{headers:{authorization:ge(e.auth.username,e.auth.access_key),accept:"application/json"}});if(!t.ok){await new Promise(c=>setTimeout(c,s));continue}let a=(await t.json()).data?.find(c=>c.code_name==="kane-cli-trigger");if(!a){await new Promise(c=>setTimeout(c,s));continue}let u=(a.status??"").toLowerCase();if(u==="in progress"||u==="in_progress"||u==="pending"){await new Promise(c=>setTimeout(c,s));continue}if(!a.url||a.url.length===0)throw new Error(`code-export status=${a.status} but no files returned`);Ce(e.outDir,{recursive:!0});for(let c of a.url){let l=Ie(e.outDir,c.file_name),g=await A(c.file_url);if(!g.ok){e.log("warn","CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:c.file_name,status:g.status});continue}let _=await g.text();$e(l,_,"utf-8")}return e.log("info","CODE_EXPORT_DOWNLOADED","Code export saved",{out_dir:e.outDir,file_count:a.url.length}),e.outDir}throw new Error("code-export polling timed out")}async function pe(e){return await Fe(e),await Oe(e)}var E=v(K(),1);import{existsSync as Ae,readFileSync as Le}from"fs";var h=v(F(),1);function je(e){j(e);let r=M(e);if(!Ae(r))return null;try{return JSON.parse(Le(r,"utf8"))}catch{return{}}}function Be(e){return e===null?"never_run":e.testcase_id?"synced":"local_only"}function Ne(e){return e==="synced"?"\u2601":e==="local_only"?"\u25A3":"\u25CB"}function Ue(e){return e==="tests-dir"?"\u2726":" "}function We(e,r){return r==="all"?!0:r==="synced"?e.status==="synced":r==="local"?e.status==="local_only":r==="never_run"?e.status==="never_run":r==="cli"?e.source==="tests-dir":r==="hand"?e.source==="cwd":!0}var z=["all","synced","local","never_run","cli","hand"];function Je(e){let r=z.indexOf(e);return z[(r+1)%z.length]}function he({root:e,currentOrgId:r,onSelect:s,onCancel:n}){let[o,t]=(0,E.useState)([]),[i,a]=(0,E.useState)(null),[u,c]=(0,E.useState)(!0),[l,g]=(0,E.useState)("all");(0,E.useEffect)(()=>{(async()=>{try{let d=await U({root:e}),b=[];for(let w of d.results){let G=je(w.path);G?.org_id!==void 0&&G.org_id!==r||b.push({path:w.path,relPath:w.relPath,name:$(w.path),status:Be(G),source:w.source,tags:W(w.path)})}t(b),c(!1)}catch(d){d instanceof R,a(d.message),c(!1)}})()},[e,r]);let _=(0,E.useMemo)(()=>o.filter(d=>We(d,l)).map(d=>({id:d.path,label:`${Ne(d.status)} ${Ue(d.source)} ${d.relPath}${d.tags.length>0?` [${d.tags.join(", ")}]`:""}`})),[o,l]),m=(0,E.useMemo)(()=>Ke(l,o),[l,o]);if(i)return(0,h.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:y.red,paddingX:2,paddingY:1,children:[(0,h.jsx)(p,{color:y.red,bold:!0,children:"testmd"}),(0,h.jsx)(k,{marginTop:1,children:(0,h.jsx)(p,{color:y.red,children:i})})]});let T=l==="all"?"all":Ge(l);return(0,h.jsx)(te,{title:`testmd \xB7 filter: ${T}`,items:_,loading:u,itemNoun:"tests",onSelect:d=>{let b=o.find(w=>w.path===d.id);b&&s(b)},onCancel:n,onTab:()=>g(d=>Je(d)),extraHint:"cycle filter",footer:m})}function Ge(e){return e==="synced"?"synced (\u2601)":e==="local"?"local (\u25A3)":e==="never_run"?"never run (\u25CB)":e==="cli"?"cli-generated (\u2726)":e==="hand"?"hand-written":"all"}function Ke(e,r){let s={synced:r.filter(o=>o.status==="synced").length,local:r.filter(o=>o.status==="local_only").length,never:r.filter(o=>o.status==="never_run").length,cli:r.filter(o=>o.source==="tests-dir").length,hand:r.filter(o=>o.source==="cwd").length},n=o=>o?y.orange:y.dim;return(0,h.jsxs)(k,{flexDirection:"column",children:[(0,h.jsx)(p,{color:y.dim,children:"legend:"}),(0,h.jsxs)(k,{children:[(0,h.jsx)(p,{color:n(e==="synced"),children:` \u2601 synced (${s.synced}) `}),(0,h.jsx)(p,{color:n(e==="local"),children:`\u25A3 local (${s.local}) `}),(0,h.jsx)(p,{color:n(e==="never_run"),children:`\u25CB never run (${s.never})`})]}),(0,h.jsxs)(k,{children:[(0,h.jsx)(p,{color:n(e==="cli"),children:` \u2726 cli-generated (${s.cli}) `}),(0,h.jsx)(p,{color:n(e==="hand"),children:` hand-written (${s.hand})`})]})]})}var I=v(K(),1);import{existsSync as Xe,readFileSync as qe}from"fs";var f=v(F(),1);function _e({path:e,relPath:r,onAction:s,onBack:n,onView:o}){let[t,i]=(0,I.useState)(null),[a,u]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let l=M(e);if(Xe(l))try{i(JSON.parse(qe(l,"utf8")))}catch{i(null)}},[e]),Z((l,g)=>{if(g.escape){if(a){u(!1);return}n();return}if(a){l==="y"||l==="Y"?(u(!1),s("delete")):(l==="n"||l==="N")&&u(!1);return}l==="r"&&s("run"),l==="e"&&t?.testcase_id&&s("export"),l==="d"&&u(!0),l==="v"&&o&&o()});let c=({k:l,v:g})=>g?(0,f.jsxs)(p,{children:[(0,f.jsx)(p,{color:y.dim,children:l.padEnd(14)}),g]}):null;return(0,f.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:y.orange,paddingX:2,paddingY:1,children:[(0,f.jsx)(p,{color:y.orange,bold:!0,children:r}),(0,f.jsx)(k,{marginTop:1,flexDirection:"column",children:t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(c,{k:"test_id",v:t.test_id}),(0,f.jsx)(c,{k:"testcase_id",v:t.testcase_id}),(0,f.jsx)(c,{k:"project_id",v:t.project_id}),(0,f.jsx)(c,{k:"folder_id",v:t.folder_id}),(0,f.jsx)(c,{k:"org_id",v:t.org_id}),(0,f.jsx)(c,{k:"session_name",v:t.session_name}),(0,f.jsx)(c,{k:"commit_id",v:t.commit_id})]}):(0,f.jsx)(p,{color:y.dim,children:"(never run \u2014 no meta.json)"})}),a?(0,f.jsx)(k,{marginTop:1,children:(0,f.jsxs)(p,{color:y.red,bold:!0,children:["Delete ",r," and its output dir? [y/n]"]})}):(0,f.jsx)(k,{marginTop:1,children:(0,f.jsxs)(p,{color:y.dim,children:["[r] run [e] export",t?.testcase_id?"":" (need testcase_id)"," [d] delete",o?" [v] view":""," [Esc] back"]})})]})}function C(e){j(e);let r=M(e);if(!P(r))return null;try{return JSON.parse(He(r,"utf8"))}catch{return null}}function xe(e,r){return!e||e.org_id===void 0?!0:e.org_id===r}function J(e,r){return xe(e,r)?null:(process.stderr.write(`error: this test belongs to org ${e.org_id}; you are logged in as org ${r}.
3
3
  Switch profiles with \`kane-cli profiles switch\` to act on it.
4
4
  `),2)}async function Ht(e={}){let r=!!process.stdin.isTTY&&!e.json,s=new O,n=new L;await H({isInteractive:r,creds:s,config:n});let o=s.getDefaultEnv()??"prod";try{let t=await N({creds:s,env:o,log:()=>{}});return t.resolvedCreds?.org_id===void 0?(process.stderr.write("error: TMS did not return an org_id. Run `kane-cli login` again.\n"),{ok:!1,code:2}):{ok:!0,orgId:String(t.resolvedCreds.org_id)}}catch(t){if(t instanceof B)return process.stderr.write("error: not authenticated. Run `kane-cli login` first.\n"),{ok:!1,code:2};throw t}}async function Vt(e,r){if(process.stdin.isTTY&&!e.json)return await Qe(r,e.root);let s=e.root??process.cwd(),n;try{n=await U({root:s,ignore:e.ignore})}catch(o){if(o instanceof R)return process.stderr.write(`error: ${o.message}
5
5
  `),2;throw o}for(let o of n.results){let t=C(o.path);if(!xe(t,r))continue;let i={path:o.relPath.startsWith(".")?o.relPath:`./${o.relPath}`,name:$(o.path),has_meta:t!==null,source:o.source,synced:!!t?.testcase_id,tags:W(o.path)};t&&(t.test_id&&(i.test_id=t.test_id),t.testcase_id&&(i.testcase_id=t.testcase_id),t.org_id&&(i.org_id=t.org_id),t.project_id&&(i.project_id=t.project_id),t.folder_id&&(i.folder_id=t.folder_id)),process.stdout.write(JSON.stringify(i)+`
6
6
  `)}return n.aborted&&process.stderr.write(`warn: walk aborted (${n.abortReason}). Pass --root or --ignore to narrow.
7
- `),0}var we=-1001,be=-1002,ke=-1003,x={action:null,path:null};function Ye(e,r){return x.action=e,x.path=r,e==="run"?we:e==="export"?be:ke}function ze({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(he,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(_e,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Ye(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function Qe(e,r){let s=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:a}=n(D.default.createElement(ze,{root:s,currentOrgId:e,onComplete:u=>{i(),t(u)}}),{stdout:process.stderr,exitOnCtrlC:!0});a().then(()=>t(0)).catch(()=>t(0))});if(o===we&&x.path){let{runTestMdFile:t}=await import("./run-test-md-GVRVMPRZ.js"),i=await t(x.path,{});return x.action=null,x.path=null,i}if(o===be&&x.path){let t=await et(x.path,{},e);return x.action=null,x.path=null,t}if(o===ke&&x.path){let t=await Ze(x.path,!0,e);return x.action=null,x.path=null,t}return o}async function Yt(e,r){let s=Q(e);if(!P(s))return process.stderr.write(`error: file not found: ${s}
7
+ `),0}var we=-1001,be=-1002,ke=-1003,x={action:null,path:null};function Ye(e,r){return x.action=e,x.path=r,e==="run"?we:e==="export"?be:ke}function ze({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(he,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(_e,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Ye(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function Qe(e,r){let s=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:a}=n(D.default.createElement(ze,{root:s,currentOrgId:e,onComplete:u=>{i(),t(u)}}),{stdout:process.stderr,exitOnCtrlC:!0});a().then(()=>t(0)).catch(()=>t(0))});if(o===we&&x.path){let{runTestMdFile:t}=await import("./run-test-md-Z75BGXRK.js"),i=await t(x.path,{});return x.action=null,x.path=null,i}if(o===be&&x.path){let t=await et(x.path,{},e);return x.action=null,x.path=null,t}if(o===ke&&x.path){let t=await Ze(x.path,!0,e);return x.action=null,x.path=null,t}return o}async function Yt(e,r){let s=Q(e);if(!P(s))return process.stderr.write(`error: file not found: ${s}
8
8
  `),2;let n=C(s),o=J(n,r);if(o!==null)return o;let t={path:s,name:$(s),has_meta:n!==null};return n&&(n.commit_id&&(t.commit_id=n.commit_id),n.test_id&&(t.test_id=n.test_id),n.testcase_id&&(t.testcase_id=n.testcase_id),n.project_id&&(t.project_id=n.project_id),n.folder_id&&(t.folder_id=n.folder_id),n.org_id&&(t.org_id=n.org_id),n.session_name&&(t.session_name=n.session_name)),process.stdout.write(JSON.stringify(t)+`
9
9
  `),0}async function Ze(e,r,s){let n=Q(e);if(!P(n))return process.stderr.write(`error: file not found: ${n}
10
10
  `),2;let o=C(n),t=J(o,s);if(t!==null)return t;if(!r)return process.stderr.write(`error: refusing to delete without --yes.
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as h}from"./chunk-SYKS57PK.js";import{a as f}from"./chunk-LHU6TEKD.js";import{a as m}from"./chunk-RBVLIMOV.js";var i=class extends Error{constructor(a,l){super(a);this.code=l;this.name="AuthError"}};async function k(c){let{creds:o,env:a,usernameFlag:l,accessKeyFlag:g,log:t}=c,e=null,u=null;if(l&&g)e={username:l,access_key:g},t("info","AUTH_RESOLVE_FLAGS","Auth resolved via CLI flags",{username:l});else{let r=o.resolveAuth();r?.method==="basic"&&(e={username:r.username,access_key:r.access_key},t("info","AUTH_RESOLVE_CONFIG","Auth resolved via config",{username:r.username}))}if(!e){let{credentials:r,profile:E}=o.getActiveCredentials();if(!r)throw new i("Not authenticated \u2014 no credentials found","not_authenticated");if(u=r.access_token,r.expires_at-Date.now()/1e3<300)try{let n=await f({creds:o,profile:E,env:a,credentials:r});n&&(u=n.accessToken,t("info","AUTH_TOKEN_REFRESHED","OAuth token refreshed"))}catch(n){let d=n instanceof Error?n.message:String(n);throw t("error","TOKEN_REFRESH_FAILED","Token refresh failed",{error:d}),new i(`Token refresh failed: ${d}`,"refresh_failed")}}let v=m(a),b=async()=>u,y=e?{username:e.username,access_key:e.access_key}:null,p=new h(v.controllerBaseUrl,b,y,t),s=await p.resolve();return s&&!e&&(e={username:s.username,access_key:s.access_key},t("info","AUTH_RESOLVE_CONTROLLER","Auth resolved via controller",{username:s.username})),{basicAuth:e,token:u,resolver:p,resolvedCreds:s}}export{i as a,k as b};
2
+ import{a as h}from"./chunk-ISBISZUE.js";import{a as f}from"./chunk-7SV2NQZV.js";import{a as m}from"./chunk-5WZ2WOOM.js";var i=class extends Error{constructor(a,l){super(a);this.code=l;this.name="AuthError"}};async function k(c){let{creds:o,env:a,usernameFlag:l,accessKeyFlag:g,log:t}=c,e=null,u=null;if(l&&g)e={username:l,access_key:g},t("info","AUTH_RESOLVE_FLAGS","Auth resolved via CLI flags",{username:l});else{let r=o.resolveAuth();r?.method==="basic"&&(e={username:r.username,access_key:r.access_key},t("info","AUTH_RESOLVE_CONFIG","Auth resolved via config",{username:r.username}))}if(!e){let{credentials:r,profile:E}=o.getActiveCredentials();if(!r)throw new i("Not authenticated \u2014 no credentials found","not_authenticated");if(u=r.access_token,r.expires_at-Date.now()/1e3<300)try{let n=await f({creds:o,profile:E,env:a,credentials:r});n&&(u=n.accessToken,t("info","AUTH_TOKEN_REFRESHED","OAuth token refreshed"))}catch(n){let d=n instanceof Error?n.message:String(n);throw t("error","TOKEN_REFRESH_FAILED","Token refresh failed",{error:d}),new i(`Token refresh failed: ${d}`,"refresh_failed")}}let v=m(a),b=async()=>u,y=e?{username:e.username,access_key:e.access_key}:null,p=new h(v.controllerBaseUrl,b,y,t),s=await p.resolve();return s&&!e&&(e={username:s.username,access_key:s.access_key},t("info","AUTH_RESOLVE_CONTROLLER","Auth resolved via controller",{username:s.username})),{basicAuth:e,token:u,resolver:p,resolvedCreds:s}}export{i as a,k as b};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as o,d as a}from"./chunk-H6TNBKGR.js";import{a as m,b as d}from"./chunk-DDLEZGZB.js";import{t as c}from"./chunk-RDHWNSDP.js";import{resolve as l}from"path";async function u(n,w,t={}){let r=d({verb:n,mode:"cli",contextRoot:l(process.cwd(),".context"),env:m(),write:t.write}),s=()=>{o(t.mode??"")!=="ndjson"&&process.stderr.write(r.supportFooter()+`
2
+ import{b as o,d as a}from"./chunk-H6TNBKGR.js";import{a as m,b as d}from"./chunk-SHXJQ73O.js";import{t as c}from"./chunk-RDHWNSDP.js";import{resolve as l}from"path";async function u(n,w,t={}){let r=d({verb:n,mode:"cli",contextRoot:l(process.cwd(),".context"),env:m(),write:t.write}),s=()=>{o(t.mode??"")!=="ndjson"&&process.stderr.write(r.supportFooter()+`
3
3
  `)};try{let e=await w(r);return t.write&&e===0&&await r.lateBindContext(l(process.cwd(),".context")),e===1&&s(),await r.end({exit_code:e}),e}catch(e){if(e instanceof c){if(o(t.mode??"")==="ndjson"){let i=a("ndjson",t.streamVerb??n,{stdout:y=>process.stdout.write(y),stderr:()=>{}});i.event({type:"sync_error",code:e.code,detail:e.message,remedy:e.remedy}),i.done(2,"refused")}else process.stderr.write(`error: ${e.message}
4
4
  next: ${e.remedy}
5
5
  `);return r.error("rebase_open"),await r.end({exit_code:2}),2}throw r.error("cli_crash"),s(),await r.end({exit_code:1}),e}}export{u as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as c}from"./chunk-RBVLIMOV.js";import{a as n}from"./chunk-RZ4F3BHX.js";import{v as s,w as a}from"./chunk-UQ6A52ML.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l as a};
2
+ import{a as c}from"./chunk-5WZ2WOOM.js";import{a as n}from"./chunk-RZ4F3BHX.js";import{v as s,w as a}from"./chunk-OWPQZP4C.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l as a};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as $}from"./chunk-NYP7QV54.js";import{f as D}from"./chunk-7PLIZBXB.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-PN4EL4JN.js";import{f as D}from"./chunk-DFHVZZI3.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,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as N,c as O,e as S,f as D,j as T,p as y,r as z,t as U}from"./chunk-L45HDSJ7.js";import{a as Y,b as M}from"./chunk-NBXYL2JT.js";import{a as F}from"./chunk-CAOZKSQ3.js";import{a as R}from"./chunk-DHJSM5DT.js";import{a as A}from"./chunk-UQ6A52ML.js";import{e as $}from"./chunk-UR6MHSHU.js";var C=$(Y(),1);import{existsSync as k,readFileSync as I,readdirSync as J,statSync as K}from"fs";import{dirname as H,isAbsolute as V,join as h,relative as P,resolve as Z,sep as _}from"path";import{createHash as q}from"crypto";var b="testmd-bundle.json",u=class extends Error{constructor(t){super(t),this.name="BundleUsageError"}},B=e=>e.split(_).join("/");function v(e){if(!k(e))return[];let t=[];for(let s of J(e).sort()){let r=h(e,s);K(r).isDirectory()?t.push(...v(r)):t.push(r)}return t}function G(e){let t=e.map(r=>H(r).split(_)),s=t[0];for(let r of t.slice(1)){let i=0;for(;i<s.length&&i<r.length&&s[i]===r[i];)i++;s=s.slice(0,i)}return s.join(_)||_}function Q(e){for(let t of e){let s=F(t,I(t,"utf8"));for(let r of s.steps)if(r.body.kind==="import_ref"&&V(r.body.path))throw new u(`bundle sync: absolute @import is not portable after unzip: ${t} step ${r.index} (@import ${r.body.path})`)}}function j(e,t={}){let s=Z(e),r=S(s),i=y(s);if(!i?.commit_id||!i?.test_id)throw new u(`bundle sync: ${s} is not authored \u2014 run \`kane-cli testmd run\` first (output-<stem>/.internal/meta.json needs commit_id + test_id)`);let l;try{l=U(s)}catch(n){throw n instanceof z?new u(`bundle sync: ${n.message}`):n}let c=[s];for(let n of l.steps)for(let a of n.trace.slice(1))c.includes(a.file)||c.push(a.file);Q(c);let o=[],d=[];for(let n of l.unitFiles){if(n.file===s)continue;let a=N(n.file);o.includes(a)||o.push(a),n.kind==="module"&&d.push(S(n.file))}let m=[...c],p=n=>{k(n)&&m.push(n)};p(O(s)),m.push(r),p(D(s)),m.push(...v(T(s)));for(let n of o)p(h(n,"Result.md")),m.push(...v(h(n,".internal","steps")));for(let n of d)p(n);let f=G(m);if(k(h(f,b)))throw new u(`bundle sync: a real file named ${b} exists at the zip root (${f}) \u2014 it would collide with the generated manifest`);let w=m.map(n=>{let a=n===r&&t.identityOverride?Buffer.from(JSON.stringify({...JSON.parse(I(n,"utf8")),commit_id:t.identityOverride.commit_id},null,2)+`
2
+ import{b as N,c as O,e as S,f as D,j as T,p as y,r as z,t as U}from"./chunk-L45HDSJ7.js";import{a as Y,b as M}from"./chunk-NBXYL2JT.js";import{a as F}from"./chunk-CAOZKSQ3.js";import{a as R}from"./chunk-DHJSM5DT.js";import{a as A}from"./chunk-OWPQZP4C.js";import{e as $}from"./chunk-UR6MHSHU.js";var C=$(Y(),1);import{existsSync as k,readFileSync as I,readdirSync as J,statSync as K}from"fs";import{dirname as H,isAbsolute as V,join as h,relative as P,resolve as Z,sep as _}from"path";import{createHash as q}from"crypto";var b="testmd-bundle.json",u=class extends Error{constructor(t){super(t),this.name="BundleUsageError"}},B=e=>e.split(_).join("/");function v(e){if(!k(e))return[];let t=[];for(let s of J(e).sort()){let r=h(e,s);K(r).isDirectory()?t.push(...v(r)):t.push(r)}return t}function G(e){let t=e.map(r=>H(r).split(_)),s=t[0];for(let r of t.slice(1)){let i=0;for(;i<s.length&&i<r.length&&s[i]===r[i];)i++;s=s.slice(0,i)}return s.join(_)||_}function Q(e){for(let t of e){let s=F(t,I(t,"utf8"));for(let r of s.steps)if(r.body.kind==="import_ref"&&V(r.body.path))throw new u(`bundle sync: absolute @import is not portable after unzip: ${t} step ${r.index} (@import ${r.body.path})`)}}function j(e,t={}){let s=Z(e),r=S(s),i=y(s);if(!i?.commit_id||!i?.test_id)throw new u(`bundle sync: ${s} is not authored \u2014 run \`kane-cli testmd run\` first (output-<stem>/.internal/meta.json needs commit_id + test_id)`);let l;try{l=U(s)}catch(n){throw n instanceof z?new u(`bundle sync: ${n.message}`):n}let c=[s];for(let n of l.steps)for(let a of n.trace.slice(1))c.includes(a.file)||c.push(a.file);Q(c);let o=[],d=[];for(let n of l.unitFiles){if(n.file===s)continue;let a=N(n.file);o.includes(a)||o.push(a),n.kind==="module"&&d.push(S(n.file))}let m=[...c],p=n=>{k(n)&&m.push(n)};p(O(s)),m.push(r),p(D(s)),m.push(...v(T(s)));for(let n of o)p(h(n,"Result.md")),m.push(...v(h(n,".internal","steps")));for(let n of d)p(n);let f=G(m);if(k(h(f,b)))throw new u(`bundle sync: a real file named ${b} exists at the zip root (${f}) \u2014 it would collide with the generated manifest`);let w=m.map(n=>{let a=n===r&&t.identityOverride?Buffer.from(JSON.stringify({...JSON.parse(I(n,"utf8")),commit_id:t.identityOverride.commit_id},null,2)+`
3
3
  `):void 0,E=a??I(n);return{abs:n,rel:B(P(f,n)),sha256:q("sha256").update(E).digest("hex"),bytes:E.length,...a?{contents:a}:{}}}).sort((n,a)=>n.rel<a.rel?-1:1),x=B(P(f,s)),L={schema_version:2,entry:x,commit_id:t.identityOverride?.commit_id??i.commit_id,test_id:i.test_id,testcase_id:i.testcase_id??null,project_id:i.project_id??null,folder_id:i.folder_id??null,org_id:i.org_id??null,created_at:new Date().toISOString(),producer:{name:"kane-cli",version:A},files:w.map(n=>({path:n.rel,sha256:n.sha256,bytes:n.bytes})),units:l.unitFiles.filter(n=>n.file!==s).map(n=>({path:B(P(f,n.file)),kind:n.kind}))};return{zipRoot:f,entry:x,files:w,manifest:L}}var g=e=>e instanceof Error?e.message:String(e);function W(e){return new Promise((t,s)=>{let r=(0,C.default)("zip",{zlib:{level:6}}),i=[];r.on("data",l=>i.push(l)),r.on("error",s),r.on("end",()=>t(Buffer.concat(i))),r.append(JSON.stringify(e.manifest,null,2)+`
4
4
  `,{name:b});for(let l of e.files)l.contents?r.append(l.contents,{name:l.rel}):r.file(l.abs,{name:l.rel});r.finalize()})}async function X(e){let{plan:t,controller:s,testId:r,sessionId:i,commitId:l}=e,c;try{c=await W(t)}catch(d){return{ok:!1,stage:"zip",error:g(d)}}let o;try{let d={key:"testmd",content_type:"application/zip",filename:`${l}-testmd.zip`},p=(await s.getPresignedUrls(r,i,[d])).urls?.testmd?.upload_url;if(!p)return{ok:!1,stage:"presign",error:"presign response missing testmd upload_url"};o=p}catch(d){return{ok:!1,stage:"presign",error:g(d)}}try{await M(o,c,"application/zip")}catch(d){return{ok:!1,stage:"upload",error:g(d)}}return{ok:!0,bytes:c.length}}async function ee(e){let t;try{t=j(e.sourcePath,{identityOverride:e.identityOverride})}catch(s){return s instanceof u?{ok:!1,stage:"collect",error:s.message}:{ok:!1,stage:"collect",error:g(s)}}return X({...e,plan:t})}function ge(e){return e.shouldUploadPipeline&&e.uploadSucceeded&&!!e.metaCommitId&&!!e.metaTestId}function te(e){return e.persisted?e.uploadSucceeded?e.local?"local":e.hasBasicAuth?!e.metaCommitId||!e.metaTestId?"not_authored":null:"no_auth":"upload_failed":"not_persisted"}async function ye(e){let t=e.recordedTestPath??null,s=t?y(t):null,r=te({persisted:!!t,uploadSucceeded:e.uploadSucceeded,local:e.local,hasBasicAuth:!!e.basicAuth,metaCommitId:s?.commit_id,metaTestId:s?.test_id});if(r)return e.log("info","BUNDLE_SYNC_SKIPPED","testmd bundle sync skipped",{reason:r,...t?{path:t}:{}}),{skipped:r};let i=s.commit_id,l=s.test_id,c=o=>{try{e.onAgentEvent?.(o)}catch{}};try{let o=await(e.syncFn??ee)({sourcePath:t,testId:l,sessionId:e.sessionId,commitId:i,controller:new R(e.controllerBaseUrl,{username:e.basicAuth.username,accessKey:e.basicAuth.access_key})});return o.ok?(e.log("info","BUNDLE_SYNC_OK","testmd bundle pushed",{commit_id:i,path:t,bytes:o.bytes}),c({type:"test_md_bundle_sync",status:"ok",commit_id:i,path:t,bytes:o.bytes})):(e.log("warn","BUNDLE_SYNC_FAILED","testmd bundle sync failed",{commit_id:i,path:t,stage:o.stage,error:o.error}),c({type:"test_md_bundle_sync",status:"failed",commit_id:i,path:t,stage:o.stage})),o}catch(o){let d=g(o);return e.log("warn","BUNDLE_SYNC_FAILED","testmd bundle sync threw",{commit_id:i,path:t,error:d}),c({type:"test_md_bundle_sync",status:"failed",commit_id:i,path:t,stage:"upload"}),{ok:!1,stage:"upload",error:d}}}export{j as a,W as b,X as c,ee as d,ge as e,te as f,ye as g};
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as n}from"./chunk-UQ6A52ML.js";import{createHash as _}from"crypto";import{existsSync as m,readFileSync as u}from"fs";import{dirname as T,join as f,resolve as o}from"path";import{fileURLToPath as E}from"url";var s=T(E(import.meta.url)),l=2;function p(e,r){let t=_("sha256");return t.update(`kane-assurance-contract
2
+ import{a as n}from"./chunk-OWPQZP4C.js";import{createHash as _}from"crypto";import{existsSync as m,readFileSync as u}from"fs";import{dirname as T,join as f,resolve as o}from"path";import{fileURLToPath as E}from"url";var s=T(E(import.meta.url)),l=2;function p(e,r){let t=_("sha256");return t.update(`kane-assurance-contract
3
3
  `),t.update(e),t.update(`
4
4
  agent_state_schema=${r}`),"sha256:"+t.digest("hex")}function d(){return[o(s,".."),o(s,"../../..")]}function i(){return"sha256:4f00de27d151118e79aafd46ebe51bb69ce7dd9fabe647124c62f2d187e11aa7"}var a=class extends Error{constructor(t,c){super(`agent/cli contract mismatch (cli ${t||"<unset>"}, agent ${c||"<unset>"}) \u2014 rebuild or reinstall the stale half`);this.expected=t;this.actual=c;this.name="PairMismatchError"}};function I(){return{TESTMUAI_CONTRACT_DIGEST:i(),TESTMUAI_CLIENT_VERSION:process.env.KANE_DEV_FORCE_CLIENT_RELEASE??`kane-cli/${n}`}}export{a,I as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-5Y2G4NC7.js";import{y as o}from"./chunk-UQ6A52ML.js";import{a as n}from"./chunk-HCBYKLMW.js";import{b as t}from"./chunk-C44QQJR4.js";import{a as s}from"./chunk-6YGTRKDT.js";import{e as r}from"./chunk-UR6MHSHU.js";var l=r(s(),1);var m=r(n(),1),i=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function b({active:e=!0}){let[p,c]=(0,l.useState)(0);return a(()=>{c(f=>(f+1)%i.length)},e?80:null),(0,m.jsx)(t,{color:o.orange,children:e?i[p]:"\u25CF"})}export{b as a};
2
+ import{a}from"./chunk-5Y2G4NC7.js";import{y as o}from"./chunk-OWPQZP4C.js";import{a as n}from"./chunk-HCBYKLMW.js";import{b as t}from"./chunk-C44QQJR4.js";import{a as s}from"./chunk-6YGTRKDT.js";import{e as r}from"./chunk-UR6MHSHU.js";var l=r(s(),1);var m=r(n(),1),i=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function b({active:e=!0}){let[p,c]=(0,l.useState)(0);return a(()=>{c(f=>(f+1)%i.length)},e?80:null),(0,m.jsx)(t,{color:o.orange,children:e?i[p]:"\u25CF"})}export{b as a};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as R}from"./chunk-TDPWFYTJ.js";import{a as x}from"./chunk-GESZSIB6.js";import{d as S}from"./chunk-4JRCAHHB.js";import{a as y}from"./chunk-MMBBQ4OZ.js";import{a as p}from"./chunk-RBVLIMOV.js";import{d as g,i as E}from"./chunk-UQ6A52ML.js";import{spawn as M,execSync as h}from"child_process";import{appendFileSync as b,existsSync as m,mkdirSync as C}from"fs";import{homedir as L}from"os";import{join as V,resolve as s,dirname as v,delimiter as T}from"path";import{fileURLToPath as U}from"url";import{createInterface as I}from"readline";async function*A(e){let n=I({input:e,crlfDelay:1/0});for await(let r of n){let o=r.trim();if(o)try{let i=JSON.parse(o);i&&typeof i.type=="string"&&(yield i)}catch{}}}function O(e){return e==="action"?{set:{V16_AGENT_ENABLE_ALL_BLOCKERS:"true",V16_BIFURCATION_PHASES:"1"},unset:["V16_NETWORK_WS","V16_NETWORK_SSE"]}:{set:{V16_BIFURCATION_PHASES:"1"},unset:["V16_AGENT_ENABLE_ALL_BLOCKERS","V16_NETWORK_WS","V16_NETWORK_SSE"]}}function w(e){return e?{set:{},unset:["V16_AGENT_SKIP_CP_FINAL"]}:{set:{V16_AGENT_SKIP_CP_FINAL:"true"},unset:[]}}function N(e){return e==="dom"?{set:{V16_AGENT_ENABLE_TEXTUAL_VISUAL:"true"},unset:[]}:{set:{},unset:["V16_AGENT_ENABLE_TEXTUAL_VISUAL"]}}var c=v(U(import.meta.url));function k(){for(let e of["python3","python"])try{return h(`${e} --version`,{stdio:"ignore"}),e}catch{}return null}function D(){let n=process.platform==="win32"?"v16-runner.exe":"v16-runner",r={"darwin-arm64":["@testmuai/kane-cli-darwin-arm64","@lambdatestincprivate/kane-cli-darwin-arm64"],"darwin-x64":["@testmuai/kane-cli-darwin-x64","@lambdatestincprivate/kane-cli-darwin-x64"],"linux-x64":["@testmuai/kane-cli-linux-x64","@lambdatestincprivate/kane-cli-linux-x64"],"linux-arm64":["@testmuai/kane-cli-linux-arm64","@lambdatestincprivate/kane-cli-linux-arm64"],"win32-x64":["@testmuai/kane-cli-win-x64","@lambdatestincprivate/kane-cli-win-x64"]},o=`${process.platform}-${process.arch}`,i=r[o];if(i)for(let t of i){let a=[s(c,"..","node_modules",t,"bin",n),s(c,"..","..","node_modules",t,"bin",n),s(c,"..","..","..","node_modules",t,"bin",n),s(c,"..","..","..","..","node_modules",t,"bin",n)];for(let u of a)if(m(u))return{cmd:u,args:[]}}let d=[s(c,"bin",n),s(c,"..","bin",n),s(c,"..","..","..","..","v16-runner","dist",n),s(c,"..","..","..","v16-runner","dist",n),s(c,"..","..","v16-runner","dist",n),s(process.cwd(),"v16-runner","dist",n),s(process.cwd(),"..","v16-runner","dist",n)];for(let t of d)if(m(t))return{cmd:t,args:[]};let l=[s(c,"..","..","v16-runner"),s(c,"..","..","..","..","v16-runner"),s(c,"..","..","..","v16-runner"),s(process.cwd(),"v16-runner"),s(process.cwd(),"..","v16-runner")];for(let t of l)if(m(s(t,"main.py"))){for(let u of[s(t,".venv","bin","python"),s(t,"..",".venv","bin","python"),s(t,"..","browser-agent",".venv","bin","python")])if(m(u))return{cmd:u,args:["main.py"],cwd:t};let a=k();if(a)return{cmd:a,args:["main.py"],cwd:t}}return null}function P(e){return e?V(L(),".testmuai","kaneai","sessions",e,"runner-stderr.log"):null}function K(e){let n=M(e.runner.cmd,e.runner.args,{stdio:["pipe","pipe","pipe"],env:e.env,cwd:e.runner.cwd});n.stdin.on("error",()=>{});let r=P(e.sessionId);if(r)try{C(v(r),{recursive:!0})}catch{}let o=1e5,i="";n.stderr.on("data",u=>{if(i+=u.toString(),i.length>o&&(i=i.slice(-o)),r)try{b(r,u)}catch{}}),n.on("error",u=>{e.log?.("error","RUNNER_SPAWN_ERROR","Runner spawn error",{error:u.message})});let d=null,l=null,t=new Promise(u=>{n.on("close",(f,_)=>{d=f,l=_?String(_):null,e.log?.("info","RUNNER_EXIT","Runner exited",{code:f,signal:l??"none"}),u({code:f,signal:l})})}),a=A(n.stdout);return{child:n,events:a,getStderr:()=>i,getExitCode:()=>d,getExitSignal:()=>l,exited:t}}async function B(e,n){if(!n?.platform||!n.target_kind)return;let r=await S(n.platform)?.toolEnv(n.target_kind)??{dirs:[]};if(r.dirs.length>0&&(e.PATH=[...r.dirs,e.PATH??""].filter(Boolean).join(T)),r.appiumHome&&(e.APPIUM_HOME=r.appiumHome),r.wdaRoot&&(e.TESTMU_IOS_WDA_DERIVED_DATA=r.wdaRoot),n.platform==="android"){let o=y();o&&(e.PATH=[o.platformToolsDir,e.PATH??""].filter(Boolean).join(T),e.ANDROID_HOME=o.root,e.ANDROID_SDK_ROOT=o.root)}}function H(e){let n={...process.env};e.environment&&(n.TESTMUAI_ENV=e.environment),n.TESTMUAI_SOURCE="kane-cli",process.platform==="win32"&&(n.PYTHONIOENCODING="utf-8",n.PYTHONUTF8="1");let r=p(e.environment);n.V16_SERVER_API_HOST=r.v16ServerHost,n.ATMS_URL=r.tmsBaseUrl.replace(/\/api\/?$/,""),e.username&&e.accessKey&&(n.LT_USERNAME=e.username,n.LT_ACCESS_KEY=e.accessKey),e.sessionId&&(n.TESTMUAI_SESSION_ID=e.sessionId);let o=O(e.mode??"testing");Object.assign(n,o.set);for(let a of o.unset)delete n[a];let i=new x().load(),d=N(e.assertionMode??(i.assertion_mode==="visual"?"visual":"dom"));Object.assign(n,d.set);for(let a of d.unset)delete n[a];let l=e.finalValidation??i.final_validation,t=w(l);Object.assign(n,t.set);for(let a of t.unset)delete n[a];return n}function G(e,n){let r=p(n?.environment),o=R();o!==void 0&&e.ap_mode===void 0&&(e.ap_mode=o),e.telemetry_proxy_url===void 0&&process.env.KANE_TELEMETRY!=="0"&&(e.telemetry_proxy_url=E),e.media_upload===void 0&&e.org_id&&e.username&&e.access_key&&(e.media_upload={url:r.shareApiBaseUrl.replace(/\/$/,"")+"/mfs/v1.0/media/upload",artefacts_host:r.mediaArtefactsHost,org_id:e.org_id,media_dir:g})}async function oe(e,n){let r=D();if(!r)throw new Error("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available.");process.env.KANE_SPAWN_DEBUG&&process.stderr.write(`[spawn-debug] ${JSON.stringify(r)}
2
+ import{a as R}from"./chunk-TDPWFYTJ.js";import{a as x}from"./chunk-SA7ORQHP.js";import{d as S}from"./chunk-4L45IQNU.js";import{a as y}from"./chunk-MMBBQ4OZ.js";import{a as p}from"./chunk-5WZ2WOOM.js";import{d as g,i as E}from"./chunk-OWPQZP4C.js";import{spawn as M,execSync as h}from"child_process";import{appendFileSync as b,existsSync as m,mkdirSync as C}from"fs";import{homedir as L}from"os";import{join as V,resolve as s,dirname as v,delimiter as T}from"path";import{fileURLToPath as U}from"url";import{createInterface as I}from"readline";async function*A(e){let n=I({input:e,crlfDelay:1/0});for await(let r of n){let o=r.trim();if(o)try{let i=JSON.parse(o);i&&typeof i.type=="string"&&(yield i)}catch{}}}function O(e){return e==="action"?{set:{V16_AGENT_ENABLE_ALL_BLOCKERS:"true",V16_BIFURCATION_PHASES:"1"},unset:["V16_NETWORK_WS","V16_NETWORK_SSE"]}:{set:{V16_BIFURCATION_PHASES:"1"},unset:["V16_AGENT_ENABLE_ALL_BLOCKERS","V16_NETWORK_WS","V16_NETWORK_SSE"]}}function w(e){return e?{set:{},unset:["V16_AGENT_SKIP_CP_FINAL"]}:{set:{V16_AGENT_SKIP_CP_FINAL:"true"},unset:[]}}function N(e){return e==="dom"?{set:{V16_AGENT_ENABLE_TEXTUAL_VISUAL:"true"},unset:[]}:{set:{},unset:["V16_AGENT_ENABLE_TEXTUAL_VISUAL"]}}var c=v(U(import.meta.url));function k(){for(let e of["python3","python"])try{return h(`${e} --version`,{stdio:"ignore"}),e}catch{}return null}function D(){let n=process.platform==="win32"?"v16-runner.exe":"v16-runner",r={"darwin-arm64":["@testmuai/kane-cli-darwin-arm64","@lambdatestincprivate/kane-cli-darwin-arm64"],"darwin-x64":["@testmuai/kane-cli-darwin-x64","@lambdatestincprivate/kane-cli-darwin-x64"],"linux-x64":["@testmuai/kane-cli-linux-x64","@lambdatestincprivate/kane-cli-linux-x64"],"linux-arm64":["@testmuai/kane-cli-linux-arm64","@lambdatestincprivate/kane-cli-linux-arm64"],"win32-x64":["@testmuai/kane-cli-win-x64","@lambdatestincprivate/kane-cli-win-x64"]},o=`${process.platform}-${process.arch}`,i=r[o];if(i)for(let t of i){let a=[s(c,"..","node_modules",t,"bin",n),s(c,"..","..","node_modules",t,"bin",n),s(c,"..","..","..","node_modules",t,"bin",n),s(c,"..","..","..","..","node_modules",t,"bin",n)];for(let u of a)if(m(u))return{cmd:u,args:[]}}let d=[s(c,"bin",n),s(c,"..","bin",n),s(c,"..","..","..","..","v16-runner","dist",n),s(c,"..","..","..","v16-runner","dist",n),s(c,"..","..","v16-runner","dist",n),s(process.cwd(),"v16-runner","dist",n),s(process.cwd(),"..","v16-runner","dist",n)];for(let t of d)if(m(t))return{cmd:t,args:[]};let l=[s(c,"..","..","v16-runner"),s(c,"..","..","..","..","v16-runner"),s(c,"..","..","..","v16-runner"),s(process.cwd(),"v16-runner"),s(process.cwd(),"..","v16-runner")];for(let t of l)if(m(s(t,"main.py"))){for(let u of[s(t,".venv","bin","python"),s(t,"..",".venv","bin","python"),s(t,"..","browser-agent",".venv","bin","python")])if(m(u))return{cmd:u,args:["main.py"],cwd:t};let a=k();if(a)return{cmd:a,args:["main.py"],cwd:t}}return null}function P(e){return e?V(L(),".testmuai","kaneai","sessions",e,"runner-stderr.log"):null}function K(e){let n=M(e.runner.cmd,e.runner.args,{stdio:["pipe","pipe","pipe"],env:e.env,cwd:e.runner.cwd});n.stdin.on("error",()=>{});let r=P(e.sessionId);if(r)try{C(v(r),{recursive:!0})}catch{}let o=1e5,i="";n.stderr.on("data",u=>{if(i+=u.toString(),i.length>o&&(i=i.slice(-o)),r)try{b(r,u)}catch{}}),n.on("error",u=>{e.log?.("error","RUNNER_SPAWN_ERROR","Runner spawn error",{error:u.message})});let d=null,l=null,t=new Promise(u=>{n.on("close",(f,_)=>{d=f,l=_?String(_):null,e.log?.("info","RUNNER_EXIT","Runner exited",{code:f,signal:l??"none"}),u({code:f,signal:l})})}),a=A(n.stdout);return{child:n,events:a,getStderr:()=>i,getExitCode:()=>d,getExitSignal:()=>l,exited:t}}async function B(e,n){if(!n?.platform||!n.target_kind)return;let r=await S(n.platform)?.toolEnv(n.target_kind)??{dirs:[]};if(r.dirs.length>0&&(e.PATH=[...r.dirs,e.PATH??""].filter(Boolean).join(T)),r.appiumHome&&(e.APPIUM_HOME=r.appiumHome),r.wdaRoot&&(e.TESTMU_IOS_WDA_DERIVED_DATA=r.wdaRoot),n.platform==="android"){let o=y();o&&(e.PATH=[o.platformToolsDir,e.PATH??""].filter(Boolean).join(T),e.ANDROID_HOME=o.root,e.ANDROID_SDK_ROOT=o.root)}}function H(e){let n={...process.env};e.environment&&(n.TESTMUAI_ENV=e.environment),n.TESTMUAI_SOURCE="kane-cli",process.platform==="win32"&&(n.PYTHONIOENCODING="utf-8",n.PYTHONUTF8="1");let r=p(e.environment);n.V16_SERVER_API_HOST=r.v16ServerHost,n.ATMS_URL=r.tmsBaseUrl.replace(/\/api\/?$/,""),e.username&&e.accessKey&&(n.LT_USERNAME=e.username,n.LT_ACCESS_KEY=e.accessKey),e.sessionId&&(n.TESTMUAI_SESSION_ID=e.sessionId);let o=O(e.mode??"testing");Object.assign(n,o.set);for(let a of o.unset)delete n[a];let i=new x().load(),d=N(e.assertionMode??(i.assertion_mode==="visual"?"visual":"dom"));Object.assign(n,d.set);for(let a of d.unset)delete n[a];let l=e.finalValidation??i.final_validation,t=w(l);Object.assign(n,t.set);for(let a of t.unset)delete n[a];return n}function G(e,n){let r=p(n?.environment),o=R();o!==void 0&&e.ap_mode===void 0&&(e.ap_mode=o),e.telemetry_proxy_url===void 0&&process.env.KANE_TELEMETRY!=="0"&&(e.telemetry_proxy_url=E),e.media_upload===void 0&&e.org_id&&e.username&&e.access_key&&(e.media_upload={url:r.shareApiBaseUrl.replace(/\/$/,"")+"/mfs/v1.0/media/upload",artefacts_host:r.mediaArtefactsHost,org_id:e.org_id,media_dir:g})}async function oe(e,n){let r=D();if(!r)throw new Error("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available.");process.env.KANE_SPAWN_DEBUG&&process.stderr.write(`[spawn-debug] ${JSON.stringify(r)}
3
3
  `);let o=H({environment:n?.environment,mode:n?.mode,assertionMode:n?.assertionMode,finalValidation:n?.finalValidation,username:e.username,accessKey:e.access_key,sessionId:e.session_id});e.device?.platform&&await B(o,e.device),G(e,{environment:n?.environment});let i=K({env:o,runner:r,log:n?.log,sessionId:e.session_id}),d=i.child;d.stdin.write(JSON.stringify(e)+`
4
4
  `);let l=P(e.session_id);if(l)try{C(v(l),{recursive:!0}),b(l,`--- runner spawn ${new Date().toISOString()} run_index=${e.run_index} ---
5
5
  `)}catch{}return{child:d,events:i.events,sendUserResponse(t){let a=JSON.stringify({type:"user_response",answer:t});try{d.stdin.write(a+`
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as u,d as p}from"./chunk-UE5EYEFI.js";import{spawn as h}from"child_process";var k=new Set(["progress","ask_user","graph_query","ingest_request","proposal","design","error","done","reasoning_delta","reasoning_done","tool_activity","decision_activity","text_delta","usage","receipt","chat_ops","session_paused","session_complete","state_checkpoint"]);function v(g,n={}){let a=n.spawnCmd!==void 0?n.spawnCmd:u();if(!a)throw new Error("assurance agent not found \u2014 your platform package may be missing; reinstall kane-cli (npm i -g @testmuai/kane-cli)");let f=g.source.images?.length??0;a.tier==="dev-python"&&f>0&&n.onWarn?.("warn: development agent in use \u2014 if image citations are missing, update the agent package");let t=h(a.cmd,a.args,{stdio:["pipe","pipe","pipe"],env:p(g.session_id,n.auth)});if(t.stdin.write(JSON.stringify(g)+`
2
+ import{c as u,d as p}from"./chunk-T7UACVWW.js";import{spawn as h}from"child_process";var k=new Set(["progress","ask_user","graph_query","ingest_request","proposal","design","error","done","reasoning_delta","reasoning_done","tool_activity","decision_activity","text_delta","usage","receipt","chat_ops","session_paused","session_complete","state_checkpoint"]);function v(g,n={}){let a=n.spawnCmd!==void 0?n.spawnCmd:u();if(!a)throw new Error("assurance agent not found \u2014 your platform package may be missing; reinstall kane-cli (npm i -g @testmuai/kane-cli)");let f=g.source.images?.length??0;a.tier==="dev-python"&&f>0&&n.onWarn?.("warn: development agent in use \u2014 if image citations are missing, update the agent package");let t=h(a.cmd,a.args,{stdio:["pipe","pipe","pipe"],env:p(g.session_id,n.auth)});if(t.stdin.write(JSON.stringify(g)+`
3
3
  `),n.onStderr){let e="";t.stderr.on("data",r=>{e+=r.toString("utf8");let i;for(;(i=e.indexOf(`
4
4
  `))>=0;){let o=e.slice(0,i);e=e.slice(i+1),o.trim()&&n.onStderr(o)}})}let d=new Promise(e=>{t.on("exit",(r,i)=>e({code:r,signal:i}))});async function*m(){let e="",r=!1;for await(let i of t.stdout){e+=i.toString("utf8");let o;for(;(o=e.indexOf(`
5
5
  `))>=0;){let l=e.slice(0,o).trim();if(e=e.slice(o+1),!l)continue;let c;try{c=JSON.parse(l)}catch{n.onWarn?.(`agent: skipping malformed line: ${l.slice(0,120)}`);continue}let s=c;if(!s||typeof s!="object"||!k.has(s.type)){n.onWarn?.(`agent: skipping unknown event type "${s&&typeof s=="object"?String(s.type??"?"):"?"}"`);continue}if(yield s,s.type==="done"){r=!0;break}}if(r)break}await d.catch(()=>{})}return{events:m(),send:e=>{t.stdin&&!t.stdin.destroyed&&t.stdin.write(JSON.stringify(e)+`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as y}from"./chunk-RBVLIMOV.js";import{createServer as b}from"http";import{createReadStream as C,promises as S}from"fs";import{randomBytes as R}from"crypto";var u="127.0.0.1";function A(n,e){if(!n)return null;let o=/^bytes=(\d*)-(\d*)$/.exec(n.trim());if(!o)return null;let[,a,r]=o;if(a===""&&r==="")return null;if(a===""){let i=Number(r);return i===0||e===0?"unsatisfiable":{start:Math.max(0,e-i),end:e-1}}let t=Number(a);if(t>=e)return"unsatisfiable";let c=r===""?e-1:Math.min(Number(r),e-1);return c<t?null:{start:t,end:c}}async function I(n){let e=R(16).toString("hex"),o=b((r,t)=>{H(r,t,n,e).catch(()=>t.destroy())});await new Promise((r,t)=>{o.once("error",t),o.listen(n.port??0,u,()=>{o.removeListener("error",t),r()})});let a=o.address().port;return{port:a,urlFor:r=>`http://${u}:${a}/${e}/${encodeURIComponent(r)}`,close:()=>new Promise(r=>{o.close(()=>r()),o.closeAllConnections()})}}async function H(n,e,o,a){let r=n.url??"/",t=s=>{try{o.log?.("warn","EVIDENCE_SERVE_DENIED",{reason:s,path:r})}catch{}};if(n.headers.host!==`${u}:${n.socket.localPort}`){t("host_mismatch"),e.writeHead(403).end();return}let c=n.headers.origin;if(c!==void 0&&!o.allowedOrigins.includes(c)){t("origin_denied"),e.writeHead(403).end();return}let i=c?{"Access-Control-Allow-Origin":c,Vary:"Origin","Access-Control-Expose-Headers":"Content-Range, Content-Length"}:{};if(n.method==="OPTIONS"){let s={...i,"Access-Control-Allow-Methods":"GET, HEAD, OPTIONS","Access-Control-Allow-Headers":"range","Access-Control-Max-Age":"86400"};n.headers["access-control-request-private-network"]==="true"&&(s["Access-Control-Allow-Private-Network"]="true"),e.writeHead(204,s).end();return}if(n.method!=="GET"&&n.method!=="HEAD"){e.writeHead(405,i).end();return}let v;try{let s=new URL(n.url??"/",`http://${u}`).pathname.split("/");if(s.length!==3||s[1]!==a){t("bad_token"),e.writeHead(404,i).end();return}v=decodeURIComponent(s[2])}catch{t("not_found"),e.writeHead(404,i).end();return}let g=o.packs.get(v);if(!g){t("not_found"),e.writeHead(404,i).end();return}let d;try{let s=await S.stat(g);if(!s.isFile())throw new Error("not a file");d=s.size}catch{t("not_found"),e.writeHead(404,i).end();return}let h={...i,"Accept-Ranges":"bytes","Content-Type":"application/zip","Cache-Control":"no-store"};if(n.method==="HEAD"){e.writeHead(200,{...h,"Content-Length":String(d)}).end();return}let l=A(n.headers.range,d);if(l==="unsatisfiable"){t("unsatisfiable"),e.writeHead(416,{...i,"Content-Range":`bytes */${d}`}).end();return}let[m,p,w]=l===null?[0,d-1,200]:[l.start,l.end,206],E={...h,"Content-Length":String(p-m+1)};if(w===206&&(E["Content-Range"]=`bytes ${m}-${p}/${d}`),e.writeHead(w,E),d===0){e.end();return}let f=C(g,{start:m,end:p});f.on("error",()=>e.destroy()),e.on("close",()=>f.destroy()),f.pipe(e)}function O(n,e){return(e??y(n).evidenceViewerUrl).replace(/\/+$/,"")}function k(n,e){return`${e}/?pack=${encodeURIComponent(n)}`}function P(n){return`evidence: view locally with \`kane-cli evidence serve ${n}\``}export{A as a,I as b,O as c,k as d,P as e};
2
+ import{a as y}from"./chunk-5WZ2WOOM.js";import{createServer as b}from"http";import{createReadStream as C,promises as S}from"fs";import{randomBytes as R}from"crypto";var u="127.0.0.1";function A(n,e){if(!n)return null;let o=/^bytes=(\d*)-(\d*)$/.exec(n.trim());if(!o)return null;let[,a,r]=o;if(a===""&&r==="")return null;if(a===""){let i=Number(r);return i===0||e===0?"unsatisfiable":{start:Math.max(0,e-i),end:e-1}}let t=Number(a);if(t>=e)return"unsatisfiable";let c=r===""?e-1:Math.min(Number(r),e-1);return c<t?null:{start:t,end:c}}async function I(n){let e=R(16).toString("hex"),o=b((r,t)=>{H(r,t,n,e).catch(()=>t.destroy())});await new Promise((r,t)=>{o.once("error",t),o.listen(n.port??0,u,()=>{o.removeListener("error",t),r()})});let a=o.address().port;return{port:a,urlFor:r=>`http://${u}:${a}/${e}/${encodeURIComponent(r)}`,close:()=>new Promise(r=>{o.close(()=>r()),o.closeAllConnections()})}}async function H(n,e,o,a){let r=n.url??"/",t=s=>{try{o.log?.("warn","EVIDENCE_SERVE_DENIED",{reason:s,path:r})}catch{}};if(n.headers.host!==`${u}:${n.socket.localPort}`){t("host_mismatch"),e.writeHead(403).end();return}let c=n.headers.origin;if(c!==void 0&&!o.allowedOrigins.includes(c)){t("origin_denied"),e.writeHead(403).end();return}let i=c?{"Access-Control-Allow-Origin":c,Vary:"Origin","Access-Control-Expose-Headers":"Content-Range, Content-Length"}:{};if(n.method==="OPTIONS"){let s={...i,"Access-Control-Allow-Methods":"GET, HEAD, OPTIONS","Access-Control-Allow-Headers":"range","Access-Control-Max-Age":"86400"};n.headers["access-control-request-private-network"]==="true"&&(s["Access-Control-Allow-Private-Network"]="true"),e.writeHead(204,s).end();return}if(n.method!=="GET"&&n.method!=="HEAD"){e.writeHead(405,i).end();return}let v;try{let s=new URL(n.url??"/",`http://${u}`).pathname.split("/");if(s.length!==3||s[1]!==a){t("bad_token"),e.writeHead(404,i).end();return}v=decodeURIComponent(s[2])}catch{t("not_found"),e.writeHead(404,i).end();return}let g=o.packs.get(v);if(!g){t("not_found"),e.writeHead(404,i).end();return}let d;try{let s=await S.stat(g);if(!s.isFile())throw new Error("not a file");d=s.size}catch{t("not_found"),e.writeHead(404,i).end();return}let h={...i,"Accept-Ranges":"bytes","Content-Type":"application/zip","Cache-Control":"no-store"};if(n.method==="HEAD"){e.writeHead(200,{...h,"Content-Length":String(d)}).end();return}let l=A(n.headers.range,d);if(l==="unsatisfiable"){t("unsatisfiable"),e.writeHead(416,{...i,"Content-Range":`bytes */${d}`}).end();return}let[m,p,w]=l===null?[0,d-1,200]:[l.start,l.end,206],E={...h,"Content-Length":String(p-m+1)};if(w===206&&(E["Content-Range"]=`bytes ${m}-${p}/${d}`),e.writeHead(w,E),d===0){e.end();return}let f=C(g,{start:m,end:p});f.on("error",()=>e.destroy()),e.on("close",()=>f.destroy()),f.pipe(e)}function O(n,e){return(e??y(n).evidenceViewerUrl).replace(/\/+$/,"")}function k(n,e){return`${e}/?pack=${encodeURIComponent(n)}`}function P(n){return`evidence: view locally with \`kane-cli evidence serve ${n}\``}export{A as a,I as b,O as c,k as d,P as e};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as k}from"./chunk-RFHMDQXZ.js";import{a as b}from"./chunk-WAZUOA3Y.js";import{a as C}from"./chunk-47FQ7ZUQ.js";import{q as m,r as u,s as f,t as x,u as y}from"./chunk-UQ6A52ML.js";import{createServer as S}from"http";import{randomBytes as A}from"crypto";import{URL as L}from"url";var P=class{profile;environment;creds;oauth;constructor(r="default",o="prod",e){this.profile=r,this.environment=o,this.creds=e??new C,this.oauth=new b(o)}async login(){let{server:r,port:o}=await this.startCallbackServer(),e=y(o);try{let t=this.creds.loadClient(this.profile,this.environment),i=t?.redirect_uris;(!t||!i?.includes(e))&&(t=await this.oauth.registerClient(e),this.creds.saveClient(this.profile,this.environment,t));let c=t.client_id,[h,d]=b.generatePkce(),a=A(32).toString("hex"),n=this.oauth.buildAuthorizationUrl(c,d,a,e),l=await this.waitForCallback(r,o,n,a);if(!l)throw new Error("Login cancelled or timed out");let p=await this.oauth.exchangeCode(l,c,h,e),g={access_token:p.access_token,refresh_token:p.refresh_token,expires_at:Math.floor(Date.now()/1e3)+p.expires_in,scope:p.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,g),this.creds.setActiveProfile(this.profile),g}catch(t){throw r.close(),t}}startCallbackServer(){return new Promise((r,o)=>{let e=u,t=()=>{let i=S();i.on("error",c=>{c.code==="EADDRINUSE"&&e<f?(e++,t()):o(new Error(`Failed to start callback server: ${c.message}. Ports ${u}-${f} are all in use.`))}),i.listen(e,m,()=>{r({server:i,port:e})})};t()})}waitForCallback(r,o,e,t){return new Promise(i=>{let c=!1,h=setTimeout(()=>d(null),12e4),d=a=>{c||(c=!0,clearTimeout(h),r.close(),i(a))};r.on("request",(a,n)=>{let l=new L(a.url??"/",`http://${m}:${o}`);if(l.pathname!==x){n.writeHead(404),n.end();return}let p=l.searchParams.get("state"),g=l.searchParams.get("code");if(l.searchParams.get("error")){n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),d(null);return}if(p!==t){n.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),d(null);return}n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),d(g)}),k(e).catch(a=>{let n=a instanceof Error?a.message:String(a);process.stderr.write(`[auth] Could not open browser: ${n}
2
+ import{c as k}from"./chunk-RFHMDQXZ.js";import{a as b}from"./chunk-BNWU7JOW.js";import{a as C}from"./chunk-RMLC3QWX.js";import{q as m,r as u,s as f,t as x,u as y}from"./chunk-OWPQZP4C.js";import{createServer as S}from"http";import{randomBytes as A}from"crypto";import{URL as L}from"url";var P=class{profile;environment;creds;oauth;constructor(r="default",o="prod",e){this.profile=r,this.environment=o,this.creds=e??new C,this.oauth=new b(o)}async login(){let{server:r,port:o}=await this.startCallbackServer(),e=y(o);try{let t=this.creds.loadClient(this.profile,this.environment),i=t?.redirect_uris;(!t||!i?.includes(e))&&(t=await this.oauth.registerClient(e),this.creds.saveClient(this.profile,this.environment,t));let c=t.client_id,[h,d]=b.generatePkce(),a=A(32).toString("hex"),n=this.oauth.buildAuthorizationUrl(c,d,a,e),l=await this.waitForCallback(r,o,n,a);if(!l)throw new Error("Login cancelled or timed out");let p=await this.oauth.exchangeCode(l,c,h,e),g={access_token:p.access_token,refresh_token:p.refresh_token,expires_at:Math.floor(Date.now()/1e3)+p.expires_in,scope:p.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,g),this.creds.setActiveProfile(this.profile),g}catch(t){throw r.close(),t}}startCallbackServer(){return new Promise((r,o)=>{let e=u,t=()=>{let i=S();i.on("error",c=>{c.code==="EADDRINUSE"&&e<f?(e++,t()):o(new Error(`Failed to start callback server: ${c.message}. Ports ${u}-${f} are all in use.`))}),i.listen(e,m,()=>{r({server:i,port:e})})};t()})}waitForCallback(r,o,e,t){return new Promise(i=>{let c=!1,h=setTimeout(()=>d(null),12e4),d=a=>{c||(c=!0,clearTimeout(h),r.close(),i(a))};r.on("request",(a,n)=>{let l=new L(a.url??"/",`http://${m}:${o}`);if(l.pathname!==x){n.writeHead(404),n.end();return}let p=l.searchParams.get("state"),g=l.searchParams.get("code");if(l.searchParams.get("error")){n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),d(null);return}if(p!==t){n.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),d(null);return}n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),d(g)}),k(e).catch(a=>{let n=a instanceof Error?a.message:String(a);process.stderr.write(`[auth] Could not open browser: ${n}
3
3
  Please open this URL manually: ${e}
4
4
  `)})})}};function v(s){let r=s.state==="success",o=r?"#22c55e":"#ef4444",e=r?"rgba(34, 197, 94, 0.12)":"rgba(239, 68, 68, 0.12)",t=r?'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7"/></svg>':'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>',i=s.autoClose?"<script>setTimeout(function(){try{window.close();}catch(e){}}, 1500);</script>":"";return`<!doctype html>
5
5
  <html lang="en">
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as he}from"./chunk-WVHMPIDQ.js";import{a as pe}from"./chunk-5B2NEYHF.js";import{b as ue,c as de,d as q,e as Y}from"./chunk-MMLYJDXO.js";import{d as ge,e as me}from"./chunk-AXTPNZPX.js";import{d as fe}from"./chunk-BZAGVBCX.js";import{a as L}from"./chunk-KDNNMU7Q.js";import{a as le}from"./chunk-EYVHPJLK.js";import{z as I}from"./chunk-IICT4VOU.js";import{F as ce,X as ae}from"./chunk-RDHWNSDP.js";function mt(t){let e=process.env.HOME??"";return e&&t.startsWith(e)?`~${t.slice(e.length)}`:t}import{randomBytes as lt}from"crypto";function J(t,e){let r=Math.min(t.length,e.length),o=0,n=0,c=0;for(let s=0;s<r;s++)o+=t[s]*e[s],n+=t[s]*t[s],c+=e[s]*e[s];return n===0||c===0?0:o/(Math.sqrt(n)*Math.sqrt(c))}function Z(t,e,r){return r*t+(1-r)*e}var ee=.7;var je=["get_node","get_edges","find_by_provenance","match_by_type","stale_nodes","search_similar","search_similar_batch","history"],Pe=["source_read","source_grep","source_list"],Ue=[...je,...Pe],ke=50,be=200,te=10,xe=50,_e=20,Ve=200,He=50;function P(t,e,r){let o=typeof t=="number"&&Number.isFinite(t)?Math.floor(t):e;return Math.max(1,Math.min(o,r))}function M(t,e){let r=t[e];if(typeof r!="string"||r.length===0)throw new k(`param "${e}" must be a non-empty string`);return r}function $(t,e){let r=t[e];if(r==null)return null;if(typeof r!="string")throw new k(`param "${e}" must be a string when present`);return r}var k=class extends Error{},ye=24,Qe=10,ze=10;function Ke(t){let e=t.cursor;if(e==null)return 0;if(typeof e=="string"&&/^\d+$/.test(e))return Number.parseInt(e,10);throw new k(`BAD_CURSOR: cursor ${JSON.stringify(e)} is not a cursor this store minted`)}function ve(t,e){let r=e.fields;if(!Array.isArray(r)||r.length===0)return t;let o=new Set(r.filter(n=>typeof n=="string"));return t.map(n=>Object.fromEntries(Object.entries(n).filter(([c])=>o.has(c))))}function ne(t,e,r=ke,o=be){let n=Ke(e),c=P(e.limit,r,o),s=t.slice(n,n+c),u=n+s.length<t.length;return{rows:ve(s,e),truncated:u,next_cursor:u?String(n+s.length):null}}var We=t=>t.cursor!=null||t.fields!=null;function U(t,e,r=ke){let o=ne(t,e,r);return We(e)||o.truncated?{rows:o.rows,truncated:o.truncated,next_cursor:o.next_cursor}:o.rows}function re(t,e){let r=t.getNode(e);return r?{cid:e,label:r.label,content:r.content,trust:t.trust.get(e)??null,freshness:t.stale(e)}:null}function we(t){return new Set(t.toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").split(" ").filter(Boolean))}function V(t,...e){let r=we(t);if(r.size===0)return 0;let o=t.trim().toLowerCase(),n=0;for(let c of e){let s=we(c);if(s.size===0)continue;let u=0;for(let l of r)s.has(l)&&u++;let f=r.size+s.size-u,d=f===0?0:u/f;o&&c.toLowerCase().includes(o)&&(d=Math.max(d,.9)),n=Math.max(n,d)}return n}function Xe(t,e){let r=M(e,"cid"),o=$(e,"type"),n=$(e,"direction")??"both";if(!["out","in","both"].includes(n))throw new k('param "direction" must be out|in|both');let c=[];(n==="out"||n==="both")&&c.push(...t.edgesFrom(r)),(n==="in"||n==="both")&&c.push(...t.edgesInto(r));let s=c.filter(u=>o==null||u.type===o);return U(s,e)}function qe(t,e){let r=M(e,"source_id"),o=t.heads.get(r)??null,n=[];for(let c of t.nodeLabel.keys()){let s=t.derivesInto(c).filter(f=>f.props.source_id===r).map(f=>({source_cid:f.props.source_cid,anchor:f.props.anchor??null}));if(s.length===0)continue;let u=re(t,c);u&&n.push({...u,pins:s,pinned_to_head:o!=null&&s.some(f=>f.source_cid===o)})}return U(n,e,be)}function Ye(t,e){let r=M(e,"label"),o=$(e,"trust"),n=$(e,"freshness"),c=[];for(let{cid:s}of t.byLabel(r)){let u=re(t,s);u&&(o!=null&&u.trust!==o||n!=null&&u.freshness!==n||c.push(u))}return U(c,e)}function Je(t,e={}){let r=$(e,"label"),o=t.staleList().map(({cid:n,state:c})=>{let s=t.getNode(n);return{cid:n,state:c,label:s?.label??null,title:s?.content.title??null}}).filter(n=>r==null||n.label===r);return U(o,e)}function Ze(t,e,r){let o=e.extracted,n=$(e,"kind"),c=[];for(let d of[...t.heads.keys()].sort()){let l=t.heads.get(d);if(typeof l!="string")continue;let h=t.mediaOf(l).format;if(n!=null&&h!==n)continue;let p=t.extractedSourceCids.has(l);if(typeof o=="boolean"&&p!==o)continue;let S=0;if(h!=="image"){let b=L(r,t,l);b&&(S=b.toString("utf8").replace(/\n$/,"").split(`
2
+ import{a as he}from"./chunk-WVHMPIDQ.js";import{a as pe}from"./chunk-OGWYTILK.js";import{b as ue,c as de,d as q,e as Y}from"./chunk-PCBCEXYO.js";import{d as ge,e as me}from"./chunk-AXTPNZPX.js";import{d as fe}from"./chunk-BZAGVBCX.js";import{a as L}from"./chunk-KDNNMU7Q.js";import{a as le}from"./chunk-CXXTQ4C5.js";import{z as I}from"./chunk-IICT4VOU.js";import{F as ce,X as ae}from"./chunk-RDHWNSDP.js";function mt(t){let e=process.env.HOME??"";return e&&t.startsWith(e)?`~${t.slice(e.length)}`:t}import{randomBytes as lt}from"crypto";function J(t,e){let r=Math.min(t.length,e.length),o=0,n=0,c=0;for(let s=0;s<r;s++)o+=t[s]*e[s],n+=t[s]*t[s],c+=e[s]*e[s];return n===0||c===0?0:o/(Math.sqrt(n)*Math.sqrt(c))}function Z(t,e,r){return r*t+(1-r)*e}var ee=.7;var je=["get_node","get_edges","find_by_provenance","match_by_type","stale_nodes","search_similar","search_similar_batch","history"],Pe=["source_read","source_grep","source_list"],Ue=[...je,...Pe],ke=50,be=200,te=10,xe=50,_e=20,Ve=200,He=50;function P(t,e,r){let o=typeof t=="number"&&Number.isFinite(t)?Math.floor(t):e;return Math.max(1,Math.min(o,r))}function M(t,e){let r=t[e];if(typeof r!="string"||r.length===0)throw new k(`param "${e}" must be a non-empty string`);return r}function $(t,e){let r=t[e];if(r==null)return null;if(typeof r!="string")throw new k(`param "${e}" must be a string when present`);return r}var k=class extends Error{},ye=24,Qe=10,ze=10;function Ke(t){let e=t.cursor;if(e==null)return 0;if(typeof e=="string"&&/^\d+$/.test(e))return Number.parseInt(e,10);throw new k(`BAD_CURSOR: cursor ${JSON.stringify(e)} is not a cursor this store minted`)}function ve(t,e){let r=e.fields;if(!Array.isArray(r)||r.length===0)return t;let o=new Set(r.filter(n=>typeof n=="string"));return t.map(n=>Object.fromEntries(Object.entries(n).filter(([c])=>o.has(c))))}function ne(t,e,r=ke,o=be){let n=Ke(e),c=P(e.limit,r,o),s=t.slice(n,n+c),u=n+s.length<t.length;return{rows:ve(s,e),truncated:u,next_cursor:u?String(n+s.length):null}}var We=t=>t.cursor!=null||t.fields!=null;function U(t,e,r=ke){let o=ne(t,e,r);return We(e)||o.truncated?{rows:o.rows,truncated:o.truncated,next_cursor:o.next_cursor}:o.rows}function re(t,e){let r=t.getNode(e);return r?{cid:e,label:r.label,content:r.content,trust:t.trust.get(e)??null,freshness:t.stale(e)}:null}function we(t){return new Set(t.toLowerCase().replace(/[^\p{L}\p{N}]+/gu," ").split(" ").filter(Boolean))}function V(t,...e){let r=we(t);if(r.size===0)return 0;let o=t.trim().toLowerCase(),n=0;for(let c of e){let s=we(c);if(s.size===0)continue;let u=0;for(let l of r)s.has(l)&&u++;let f=r.size+s.size-u,d=f===0?0:u/f;o&&c.toLowerCase().includes(o)&&(d=Math.max(d,.9)),n=Math.max(n,d)}return n}function Xe(t,e){let r=M(e,"cid"),o=$(e,"type"),n=$(e,"direction")??"both";if(!["out","in","both"].includes(n))throw new k('param "direction" must be out|in|both');let c=[];(n==="out"||n==="both")&&c.push(...t.edgesFrom(r)),(n==="in"||n==="both")&&c.push(...t.edgesInto(r));let s=c.filter(u=>o==null||u.type===o);return U(s,e)}function qe(t,e){let r=M(e,"source_id"),o=t.heads.get(r)??null,n=[];for(let c of t.nodeLabel.keys()){let s=t.derivesInto(c).filter(f=>f.props.source_id===r).map(f=>({source_cid:f.props.source_cid,anchor:f.props.anchor??null}));if(s.length===0)continue;let u=re(t,c);u&&n.push({...u,pins:s,pinned_to_head:o!=null&&s.some(f=>f.source_cid===o)})}return U(n,e,be)}function Ye(t,e){let r=M(e,"label"),o=$(e,"trust"),n=$(e,"freshness"),c=[];for(let{cid:s}of t.byLabel(r)){let u=re(t,s);u&&(o!=null&&u.trust!==o||n!=null&&u.freshness!==n||c.push(u))}return U(c,e)}function Je(t,e={}){let r=$(e,"label"),o=t.staleList().map(({cid:n,state:c})=>{let s=t.getNode(n);return{cid:n,state:c,label:s?.label??null,title:s?.content.title??null}}).filter(n=>r==null||n.label===r);return U(o,e)}function Ze(t,e,r){let o=e.extracted,n=$(e,"kind"),c=[];for(let d of[...t.heads.keys()].sort()){let l=t.heads.get(d);if(typeof l!="string")continue;let h=t.mediaOf(l).format;if(n!=null&&h!==n)continue;let p=t.extractedSourceCids.has(l);if(typeof o=="boolean"&&p!==o)continue;let S=0;if(h!=="image"){let b=L(r,t,l);b&&(S=b.toString("utf8").replace(/\n$/,"").split(`
3
3
  `).length)}let _=t.extractionCompleteness.get(d);c.push({source_id:d,kind:h,lines:S,head_cid:l,extracted:p,last_extract_at:_?.at??null,extractor_version:_?.extractor_version??null})}let{rows:s,truncated:u,next_cursor:f}=ne(c,e);return{sources:s,truncated:u,next_cursor:f}}function et(t,e,r){let o=M(e,"ref"),n=t.resolve(o);if(!n)throw new k(`UNKNOWN_REF: ${o} names nothing in the graph`);let c=n.tip,s=new Map;for(let[m,w]of t.superseded)typeof w=="string"&&w!==m&&s.set(w,[...s.get(w)??[],m]);let u=[],f=[c],d=new Set;for(;f.length>0;){let m=f.pop();d.has(m)||(d.add(m),u.push(m),f.push(...s.get(m)??[]))}let{records:l}=ce(r),g=new Map,h=new Map;for(let m of l){for(let w of m.nodes)g.has(w.cid)||g.set(w.cid,m.ts);for(let w of m.supersessions)w.kind==="node"&&h.set(w.old,{by_cid:w.new,reason:w.reason})}let p=u.map(m=>({cid:m,minted_at:g.get(m)??null,superseded_by:h.get(m)?.by_cid??null,reason:h.get(m)?.reason??null,change_note:null})),{rows:S,truncated:_,next_cursor:b}=ne(p,e,ze);return{root_logical_id:t.displayNameOf(c),live_tip:t.superseded.has(c)?null:c,truncated:_,next_cursor:b,chain:S}}function Se(t){let e=t.queries;if(!Array.isArray(e)||e.length<1||e.length>ye)throw new k(`param "queries" must be 1..${ye} entries`);return e.map((r,o)=>{if(typeof r!="object"||r===null)throw new k(`queries[${o}] must be an object`);let n=r;if(typeof n.qid!="string"||n.qid.length===0)throw new k(`queries[${o}].qid must be a non-empty string`);if(typeof n.text!="string"||n.text.length===0)throw new k(`queries[${o}].text must be a non-empty string`);return{qid:n.qid,text:n.text,topK:P(n.top_k,te,Qe)}})}function Ae(t){let e=[];for(let{cid:r,content:o}of t.byLabel("usecase"))t.superseded.has(r)||e.push({cid:r,title:String(o.title??""),summary:String(o.summary??""),description:String(o.description??"")});return e}function Re(t,e,r){let o=Ae(t);return e.map(n=>{let c=[];for(let s of o){let u=r(n,s);u<=0||c.push({cid:s.cid,logical_id:t.displayNameOf(s.cid),title:s.title,score:Math.round(u*1e3)/1e3,trust:t.trust.get(s.cid)??null,superseded:!1})}return c.sort((s,u)=>u.score-s.score||s.cid.localeCompare(u.cid)),{qid:n.qid,truncated:c.length>n.topK,matches:c.slice(0,n.topK)}})}function Ee(t,e){let r=Se(e);return{results:Re(t,r,(o,n)=>V(o.text,n.title,n.summary,n.description)),scorer:"lexical_fallback"}}function tt(t,e){let r=M(e,"text"),o=$(e,"label")??"usecase",n=P(e.k,te,xe),c=[];for(let{cid:s,content:u}of t.byLabel(o)){let f=String(u.title??""),d=String(u.summary??""),l=V(r,f,d);l<=0||c.push({cid:s,title:f,summary:d,score:Math.round(l*1e3)/1e3,trust:t.trust.get(s)??null,freshness:t.stale(s)})}return c.sort((s,u)=>u.score-s.score||s.cid.localeCompare(u.cid)),c.slice(0,n)}function De(t,e,r){let o=t.heads.get(r);if(typeof o!="string"){let c=[...t.heads.keys()].sort().join(", ");throw new k(`unknown source_id "${r}" \u2014 known: ${c||"(none)"}`)}if(t.mediaOf(o).format==="image")throw new k(`source "${r}" is an image \u2014 no line window (cite img#whole)`);let n=L(e,t,o);if(n==null)throw new k(`source "${r}" blob is missing from the store`);return{head:o,lines:n.toString("utf8").replace(/\n$/,"").split(`
4
4
  `)}}function nt(t,e,r){return t.slice(e-1,r).map((o,n)=>`${String(e+n).padStart(4,"0")}| ${o}`).join(`
5
5
  `)}function rt(t,e,r){let o=M(e,"source_id"),n=$(e,"anchor"),c=e.line_range;if(n!=null&&c!=null)throw new k("give anchor OR line_range, not both");let{head:s,lines:u}=De(t,r,o),f=u.length,d,l;if(n!=null){let g=/^L(\d+)-L(\d+)$/.exec(n);if(!g)throw new k(`anchor "${n}" is not L<a>-L<b>`);let h=Number(g[1]),p=Number(g[2]);if(h<1||p<h||p>f)throw new k(`anchor "${n}" does not resolve (source has ${f} lines)`);d=Math.max(1,h-_e),l=Math.min(f,p+_e)}else if(c!=null){if(!Array.isArray(c)||c.length!==2||!c.every(p=>Number.isInteger(p)))throw new k('param "line_range" must be [from_line, to_line]');let[g,h]=c;if(g<1||h<g)throw new k('param "line_range" must be 1-based with from \u2264 to');if(g>f)throw new k(`line_range starts past the end (source has ${f} lines)`);d=g,l=Math.min(h,f)}else d=1,l=f;return l=Math.min(l,d+Ve-1),{window:nt(u,d,l),from_line:d,to_line:l,source_cid:s,total_lines:f}}function st(t,e,r){let o=M(e,"pattern"),n=$(e,"source_id"),c;try{c=new RegExp(o,"u")}catch(d){throw new k(`invalid pattern: ${d instanceof Error?d.message:String(d)}`)}let s=n!=null?[n]:[...t.heads.keys()].sort(),u=[],f=!1;e:for(let d of s){if(n==null){let g=t.heads.get(d);if(typeof g!="string"||t.mediaOf(g).format==="image")continue}let{lines:l}=De(t,r,d);for(let g=0;g<l.length;g++)if(c.test(l[g])){if(u.length>=He){f=!0;break e}u.push({source_id:d,line:g+1,text:l[g]})}}return{matches:u,truncated:f}}function ot(t,e,r,o){try{switch(e){case"get_node":{let n=re(t,M(r,"cid"));return n==null?{ok:!0,result:null}:{ok:!0,result:ve([n],r)[0]}}case"get_edges":return{ok:!0,result:Xe(t,r)};case"find_by_provenance":return{ok:!0,result:qe(t,r)};case"match_by_type":return{ok:!0,result:Ye(t,r)};case"stale_nodes":return{ok:!0,result:Je(t,r)};case"search_similar":return{ok:!0,result:tt(t,r)};case"search_similar_batch":return{ok:!0,result:Ee(t,r)};case"history":{if(o==null)throw new k("history unavailable (no context store)");return{ok:!0,result:et(t,r,o)}}case"source_list":{if(o==null)throw new k("source roster unavailable (no context store)");return{ok:!0,result:Ze(t,r,o)}}case"source_read":case"source_grep":{if(o==null)throw new k("source text unavailable (no context store)");return{ok:!0,result:(e==="source_read"?rt:st)(t,r,o)}}default:return{ok:!1,error:`unknown method: ${e} \u2014 available: ${Ue.join(", ")}`}}}catch(n){return n instanceof k?{ok:!1,error:`${e}: ${n.message}`}:{ok:!1,error:`${e}: graph read failed: ${n instanceof Error?n.message:String(n)}`}}}var j="assurance.sim";function it(t){return[t.title,t.summary,t.description].filter(Boolean).join(`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as f}from"./chunk-6VB4FGBZ.js";import{y as t}from"./chunk-UQ6A52ML.js";import{a as x}from"./chunk-HCBYKLMW.js";import{a,b as n}from"./chunk-C44QQJR4.js";import{a as R}from"./chunk-6YGTRKDT.js";import{e as c}from"./chunk-UR6MHSHU.js";var p=c(R(),1);var e=c(x(),1);function v(){return[{name:"convert",label:"Converting session data",status:"pending"},{name:"zip",label:"Compressing artifacts",status:"pending"},{name:"presign",label:"Requesting upload URLs",status:"pending"},{name:"upload",label:"Uploading to KaneAI",status:"pending"},{name:"atomic_replace",label:"Replacing local output",status:"pending"},{name:"commit_lock",label:"Committing to TMS",status:"pending"},{name:"finalize",label:"Finalizing test case",status:"pending"},{name:"code_export",label:"Downloading test code",status:"pending"}]}function U(s,o,d,i){return s.map(l=>l.name===o?{...l,status:d,detail:i}:l)}function D(s){let o=s/1e3;if(o<60)return`${o.toFixed(1)}s`;let d=Math.floor(o/60),i=Math.round(o%60);return`${d}m ${i}s`}function w(s){let[o,d]=(0,p.useState)(0),i=p.default.useRef(Date.now());return(0,p.useEffect)(()=>{if(!s)return;i.current=Date.now();let l=setInterval(()=>{d(Date.now()-i.current)},100);return()=>clearInterval(l)},[s]),o}function h({steps:s,status:o,testUrl:d,error:i}){let l=w(o==="uploading");return o==="uploading"?(0,e.jsxs)(a,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(n,{color:t.orange,children:"\u2601 "}),(0,e.jsx)(n,{color:t.orange,bold:!0,children:"Saving to KaneAI"}),(0,e.jsxs)(n,{color:t.dim,children:[" ",D(l)]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:s.filter(r=>r.status!=="skipped"||r.detail).map((r,S,T)=>{let b=S===T.length-1?"\u2514\u2500":"\u251C\u2500",u=r.status==="done",m=r.status==="running",g=r.status==="failed",B=r.status==="skipped";return(0,e.jsxs)(a,{children:[(0,e.jsxs)(n,{color:t.dim,children:[" ",b," "]}),(0,e.jsx)(a,{width:3,children:m?(0,e.jsx)(f,{}):u?(0,e.jsx)(n,{color:t.green,children:"\u2713"}):g?(0,e.jsx)(n,{color:t.red,children:"\u2717"}):B?(0,e.jsx)(n,{color:t.muted,children:"\u2013"}):(0,e.jsx)(n,{color:t.muted,children:"\u25CB"})}),(0,e.jsx)(n,{color:u?t.dim:m?void 0:g?t.red:t.muted,children:r.label}),r.detail&&(0,e.jsxs)(n,{color:t.dim,children:[" ",r.detail]})]},r.name)})}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(n,{color:t.muted,children:" press Ctrl+C twice to force exit"})})]}):o==="success"?(0,e.jsx)(e.Fragment,{}):(0,e.jsxs)(a,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(n,{color:t.red,children:"\u2601 "}),(0,e.jsx)(n,{color:t.red,bold:!0,children:"Save failed"})]}),i&&(0,e.jsxs)(a,{marginTop:0,children:[(0,e.jsx)(n,{color:t.dim,children:" "}),(0,e.jsx)(n,{color:t.dim,children:i})]})]})}export{v as a,U as b,h as c};
2
+ import{a as f}from"./chunk-DCLMFWCF.js";import{y as t}from"./chunk-OWPQZP4C.js";import{a as x}from"./chunk-HCBYKLMW.js";import{a,b as n}from"./chunk-C44QQJR4.js";import{a as R}from"./chunk-6YGTRKDT.js";import{e as c}from"./chunk-UR6MHSHU.js";var p=c(R(),1);var e=c(x(),1);function v(){return[{name:"convert",label:"Converting session data",status:"pending"},{name:"zip",label:"Compressing artifacts",status:"pending"},{name:"presign",label:"Requesting upload URLs",status:"pending"},{name:"upload",label:"Uploading to KaneAI",status:"pending"},{name:"atomic_replace",label:"Replacing local output",status:"pending"},{name:"commit_lock",label:"Committing to TMS",status:"pending"},{name:"finalize",label:"Finalizing test case",status:"pending"},{name:"code_export",label:"Downloading test code",status:"pending"}]}function U(s,o,d,i){return s.map(l=>l.name===o?{...l,status:d,detail:i}:l)}function D(s){let o=s/1e3;if(o<60)return`${o.toFixed(1)}s`;let d=Math.floor(o/60),i=Math.round(o%60);return`${d}m ${i}s`}function w(s){let[o,d]=(0,p.useState)(0),i=p.default.useRef(Date.now());return(0,p.useEffect)(()=>{if(!s)return;i.current=Date.now();let l=setInterval(()=>{d(Date.now()-i.current)},100);return()=>clearInterval(l)},[s]),o}function h({steps:s,status:o,testUrl:d,error:i}){let l=w(o==="uploading");return o==="uploading"?(0,e.jsxs)(a,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(n,{color:t.orange,children:"\u2601 "}),(0,e.jsx)(n,{color:t.orange,bold:!0,children:"Saving to KaneAI"}),(0,e.jsxs)(n,{color:t.dim,children:[" ",D(l)]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:s.filter(r=>r.status!=="skipped"||r.detail).map((r,S,T)=>{let b=S===T.length-1?"\u2514\u2500":"\u251C\u2500",u=r.status==="done",m=r.status==="running",g=r.status==="failed",B=r.status==="skipped";return(0,e.jsxs)(a,{children:[(0,e.jsxs)(n,{color:t.dim,children:[" ",b," "]}),(0,e.jsx)(a,{width:3,children:m?(0,e.jsx)(f,{}):u?(0,e.jsx)(n,{color:t.green,children:"\u2713"}):g?(0,e.jsx)(n,{color:t.red,children:"\u2717"}):B?(0,e.jsx)(n,{color:t.muted,children:"\u2013"}):(0,e.jsx)(n,{color:t.muted,children:"\u25CB"})}),(0,e.jsx)(n,{color:u?t.dim:m?void 0:g?t.red:t.muted,children:r.label}),r.detail&&(0,e.jsxs)(n,{color:t.dim,children:[" ",r.detail]})]},r.name)})}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(n,{color:t.muted,children:" press Ctrl+C twice to force exit"})})]}):o==="success"?(0,e.jsx)(e.Fragment,{}):(0,e.jsxs)(a,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(n,{color:t.red,children:"\u2601 "}),(0,e.jsx)(n,{color:t.red,bold:!0,children:"Save failed"})]}),i&&(0,e.jsxs)(a,{marginTop:0,children:[(0,e.jsx)(n,{color:t.dim,children:" "}),(0,e.jsx)(n,{color:t.dim,children:i})]})]})}export{v as a,U as b,h as c};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as wr}from"./chunk-NJ4BXZBX.js";import{a as br}from"./chunk-Q4YYAN6E.js";import{a as gr}from"./chunk-3VAU3PNU.js";import{a as mr,b as yr}from"./chunk-EVFFDODK.js";import{a as hr}from"./chunk-WVHMPIDQ.js";import{c as ur,d as fr}from"./chunk-V4B5QA3U.js";import{a as lr,d as pr}from"./chunk-BB2W35TW.js";import{a as ir,g as xt,h as ar,n as dr,p as cr}from"./chunk-7N6OCHPC.js";import{e as ct,f as jt,g as Tt,h as Le}from"./chunk-PMBQU63H.js";import{A as tr,B as qt,C as te,D as it,E as fe,F as nr,G as ne,H as _e,I as at,J as rr,K as Y,L as Fe,M as dt,N as Re,O as sr,P as or,S as Be,a as Dn,b as Mn,c as Ae,d as Pe,e as le,f as st,g as Gn,h as Vn,i as pe,j as Kn,k as qe,l as je,m as Yn,n as ot,o as ue,p as zn,q as Qn,r as Zn,s as Xn,t as At,u as Pt,v as X,w as Te,x as er,y as Nt,z as xe}from"./chunk-QX5LJVTD.js";import{b as Ln,d as Bn,g as Ct,h as K}from"./chunk-H6TNBKGR.js";import{a as R,b as Hn,d as ee,e as Ne,h as Jn,i as Wn,k as Un}from"./chunk-YLQHY4A7.js";import{a as Tn,b as xn,e as Fn}from"./chunk-U2LDPUDZ.js";import{b as sn,f as on,h as an,k as dn,l as cn}from"./chunk-IPQAKIJO.js";import{b as Ot,d as ce}from"./chunk-VVOKM2VO.js";import{a as jn}from"./chunk-CH273NAE.js";import{b as ve}from"./chunk-BKM2LWU2.js";import{A as qn,n as Sn,o as En,p as On,q as Cn,r as An,s as Pn,t as Nn,x as tt,y as nt,z as rt}from"./chunk-IICT4VOU.js";import{B as oe,C as vn,D as $n,F as $e,G as Xe,J as kn,K as Ce,O as _n,P as et,U as Rn,W as In,X as ke,b as rn,c as de,f as Et,h as pn,l as un,m as fn,o as Oe,p as O,q as hn,t as gn,v as mn,x as yn,y as bn,z as wn}from"./chunk-RDHWNSDP.js";import{d as ln,f as Qe,g as Ze}from"./chunk-XLSOQLVT.js";import{existsSync as Ue,readdirSync as os,readFileSync as is,realpathSync as Mo,statSync as Ho,writeFileSync as Go}from"fs";import{basename as Rt,join as Ke,relative as Vo,resolve as tn}from"path";import{randomBytes as _s}from"crypto";var vr=8,De=()=>Un(_s(8).toString("hex")),$r=(e,t)=>e!==null&&Buffer.from(e).equals(Buffer.from(t)),Rs=[["P1 exclusive create",async e=>{for(let t=1;t<=2;t++){let n=De(),r=Buffer.from(`probe ${t} first`);if(await e.putIfAbsent(n,r)!=="created")return"a fresh key was reported as existing";if(await e.putIfAbsent(n,Buffer.from(`probe ${t} second`))!=="exists")return"the second write to one key was not refused";if(!$r(await e.get(n),r))return"the second write replaced the first"}return null}],["P2 contention",async e=>{let t=De(),r=(await Promise.all(Array.from({length:vr},(o,i)=>e.putIfAbsent(t,Buffer.from(`contender ${i}`))))).filter(o=>o==="created").length;return r===1?null:`${r} of ${vr} concurrent writers were told "created"`}],["P3 read-after-write",async e=>{let t=De(),n=Buffer.from("visible");return await e.putIfAbsent(t,n),await e.head(t)?$r(await e.get(t),n)?(await e.list(t)).includes(t)?null:"list does not show a key just created":"get does not return the bytes just created":"head does not see a key just created"}],["P4 definitive absence",async e=>await e.head(De())?"a never-written key was reported present":null]];async function lt(e){if(e.probe){let r=await e.probe();return{tier:Math.max(r.tier,e.ceilingTier),detail:r.detail}}let t=1,n="all probes passed";for(let[r,o]of Rs){let i;try{i=await o(e)}catch(s){if(s instanceof R){if(!(s.code==="SYNC_LOCATION_REFUSED_WRITE"&&r.startsWith("P1")&&await kr(e)))throw s;n=`${r}: ${s.message}`,t=3;break}n=`${r}: ${s instanceof Error?s.message:String(s)}`,t=r.startsWith("P1")&&await kr(e)?3:2;break}if(i!==null){n=`${r}: ${i}`,t=2;break}}return{tier:Math.max(t,e.ceilingTier),detail:n}}async function kr(e){try{return!await e.head(De())}catch(t){if(t instanceof R)throw t;return!1}}import{existsSync as Is,readFileSync as Ir}from"fs";import{join as Ss}from"path";async function Ft(e,t,n,r){let i=le(e).entries[n];if(!i)throw new Error(`no sync state for ${n} \u2014 run kane-cli context sync add ${n} <descriptor> first`);if(i.tier!==1)throw new R("SYNC_READ_ONLY",`${n} is a tier ${i.tier} location: it can be cloned and pulled, never pushed`,"push to a location whose probe reached tier 1, or pull from this one");let s=await qe(e,t,i.witness);switch(s.kind){case"empty-storage":case"ahead":case"up-to-date":break;case"behind":case"empty-local":throw new R("SYNC_BEHIND",`${n} holds ${s.storage.seq} records, this store ${s.local?.seq??0}: it has records this store has not seen`,`kane-cli context pull ${n}`);case"diverged":throw new R("SYNC_DIVERGED",`you and ${n} both added work after position ${s.at-1}; nothing was pushed`,`run kane-cli context pull ${n} --rebase to save your local work, take the team version from ${n}, and then reapply yours`);case"foreign-lineage":throw new R("SYNC_FOREIGN_LINEAGE",`${n} holds a different history (its first record is not this store's)`,`to work on it, clone it: kane-cli context clone <descriptor of ${n}> <dir>; to share this store, add an empty location`)}let d=s.storage,c=wn(e),a;try{mn(e),a=Es(e,d)}catch(F){throw F instanceof gn?new R("SYNC_REBASE_PENDING",`${F.message.split(";")[0]}; nothing was pushed`,F.remedy):F}finally{c()}let l=a.map(F=>Os(e,F)),g=0,p=0,f=0,u=0,y=d,b=null,h=null,m=t.beginTransaction?await t.beginTransaction():void 0,w=m?{...t,head:m.head,get:m.get,list:t.list.bind(t),putIfAbsent:t.putIfAbsent.bind(t)}:t,v=m?m.stageIfAbsent.bind(m):t.putIfAbsent.bind(t),x=[],ae=F=>m?x.push(F):r(F);try{let F=new Set;for(let A of l){for(let $ of A.blobs)if(await v($.key,$.bytes)!=="exists")p++,F.add($.key);else if(!F.has($.key)){let M=await w.get($.key);if(M===null||Ot(Buffer.from(M))!==$.fp){h=new R("SYNC_OBJECT_CORRUPT",`the blob ${$.fp} ${n} already holds does not hash to its name (named by record ${A.seq}); the record was not pushed`,"the storage object needs a human look before anything more is pushed to it");break}F.add($.key)}if(h)break;A.proposal&&await v(A.proposal.key,A.proposal.bytes)!=="exists"&&f++;let Q=Ne(A.seq);if(await v(Q,A.raw)!=="exists")g++;else if((await pe(w,A.seq)).hash===A.hash)ae(`position ${A.seq} is already on ${n}`),u++;else{b=A.seq;break}y={seq:A.seq,hash:A.hash}}if(m||await Rr(t,y,d,n),y&&!await w.head(ee)){let A=await pe(w,1),Q={layout:1,canonicalizer:"v1",genesis_hash:A.hash};await v(ee,Buffer.from(JSON.stringify(Q)+`
2
+ import{a as wr}from"./chunk-NJ4BXZBX.js";import{a as br}from"./chunk-Q4YYAN6E.js";import{a as gr}from"./chunk-3VAU3PNU.js";import{a as mr,b as yr}from"./chunk-EVFFDODK.js";import{a as hr}from"./chunk-WVHMPIDQ.js";import{c as ur,d as fr}from"./chunk-V4B5QA3U.js";import{a as lr,d as pr}from"./chunk-BB2W35TW.js";import{a as ir,g as xt,h as ar,n as dr,p as cr}from"./chunk-7N6OCHPC.js";import{e as ct,f as jt,g as Tt,h as Le}from"./chunk-UFWG6VMI.js";import{A as tr,B as qt,C as te,D as it,E as fe,F as nr,G as ne,H as _e,I as at,J as rr,K as Y,L as Fe,M as dt,N as Re,O as sr,P as or,S as Be,a as Dn,b as Mn,c as Ae,d as Pe,e as le,f as st,g as Gn,h as Vn,i as pe,j as Kn,k as qe,l as je,m as Yn,n as ot,o as ue,p as zn,q as Qn,r as Zn,s as Xn,t as At,u as Pt,v as X,w as Te,x as er,y as Nt,z as xe}from"./chunk-SBSANJ2T.js";import{b as Ln,d as Bn,g as Ct,h as K}from"./chunk-H6TNBKGR.js";import{a as R,b as Hn,d as ee,e as Ne,h as Jn,i as Wn,k as Un}from"./chunk-YLQHY4A7.js";import{a as Tn,b as xn,e as Fn}from"./chunk-U2LDPUDZ.js";import{b as sn,f as on,h as an,k as dn,l as cn}from"./chunk-IPQAKIJO.js";import{b as Ot,d as ce}from"./chunk-VVOKM2VO.js";import{a as jn}from"./chunk-CH273NAE.js";import{b as ve}from"./chunk-BKM2LWU2.js";import{A as qn,n as Sn,o as En,p as On,q as Cn,r as An,s as Pn,t as Nn,x as tt,y as nt,z as rt}from"./chunk-IICT4VOU.js";import{B as oe,C as vn,D as $n,F as $e,G as Xe,J as kn,K as Ce,O as _n,P as et,U as Rn,W as In,X as ke,b as rn,c as de,f as Et,h as pn,l as un,m as fn,o as Oe,p as O,q as hn,t as gn,v as mn,x as yn,y as bn,z as wn}from"./chunk-RDHWNSDP.js";import{d as ln,f as Qe,g as Ze}from"./chunk-XLSOQLVT.js";import{existsSync as Ue,readdirSync as os,readFileSync as is,realpathSync as Mo,statSync as Ho,writeFileSync as Go}from"fs";import{basename as Rt,join as Ke,relative as Vo,resolve as tn}from"path";import{randomBytes as _s}from"crypto";var vr=8,De=()=>Un(_s(8).toString("hex")),$r=(e,t)=>e!==null&&Buffer.from(e).equals(Buffer.from(t)),Rs=[["P1 exclusive create",async e=>{for(let t=1;t<=2;t++){let n=De(),r=Buffer.from(`probe ${t} first`);if(await e.putIfAbsent(n,r)!=="created")return"a fresh key was reported as existing";if(await e.putIfAbsent(n,Buffer.from(`probe ${t} second`))!=="exists")return"the second write to one key was not refused";if(!$r(await e.get(n),r))return"the second write replaced the first"}return null}],["P2 contention",async e=>{let t=De(),r=(await Promise.all(Array.from({length:vr},(o,i)=>e.putIfAbsent(t,Buffer.from(`contender ${i}`))))).filter(o=>o==="created").length;return r===1?null:`${r} of ${vr} concurrent writers were told "created"`}],["P3 read-after-write",async e=>{let t=De(),n=Buffer.from("visible");return await e.putIfAbsent(t,n),await e.head(t)?$r(await e.get(t),n)?(await e.list(t)).includes(t)?null:"list does not show a key just created":"get does not return the bytes just created":"head does not see a key just created"}],["P4 definitive absence",async e=>await e.head(De())?"a never-written key was reported present":null]];async function lt(e){if(e.probe){let r=await e.probe();return{tier:Math.max(r.tier,e.ceilingTier),detail:r.detail}}let t=1,n="all probes passed";for(let[r,o]of Rs){let i;try{i=await o(e)}catch(s){if(s instanceof R){if(!(s.code==="SYNC_LOCATION_REFUSED_WRITE"&&r.startsWith("P1")&&await kr(e)))throw s;n=`${r}: ${s.message}`,t=3;break}n=`${r}: ${s instanceof Error?s.message:String(s)}`,t=r.startsWith("P1")&&await kr(e)?3:2;break}if(i!==null){n=`${r}: ${i}`,t=2;break}}return{tier:Math.max(t,e.ceilingTier),detail:n}}async function kr(e){try{return!await e.head(De())}catch(t){if(t instanceof R)throw t;return!1}}import{existsSync as Is,readFileSync as Ir}from"fs";import{join as Ss}from"path";async function Ft(e,t,n,r){let i=le(e).entries[n];if(!i)throw new Error(`no sync state for ${n} \u2014 run kane-cli context sync add ${n} <descriptor> first`);if(i.tier!==1)throw new R("SYNC_READ_ONLY",`${n} is a tier ${i.tier} location: it can be cloned and pulled, never pushed`,"push to a location whose probe reached tier 1, or pull from this one");let s=await qe(e,t,i.witness);switch(s.kind){case"empty-storage":case"ahead":case"up-to-date":break;case"behind":case"empty-local":throw new R("SYNC_BEHIND",`${n} holds ${s.storage.seq} records, this store ${s.local?.seq??0}: it has records this store has not seen`,`kane-cli context pull ${n}`);case"diverged":throw new R("SYNC_DIVERGED",`you and ${n} both added work after position ${s.at-1}; nothing was pushed`,`run kane-cli context pull ${n} --rebase to save your local work, take the team version from ${n}, and then reapply yours`);case"foreign-lineage":throw new R("SYNC_FOREIGN_LINEAGE",`${n} holds a different history (its first record is not this store's)`,`to work on it, clone it: kane-cli context clone <descriptor of ${n}> <dir>; to share this store, add an empty location`)}let d=s.storage,c=wn(e),a;try{mn(e),a=Es(e,d)}catch(F){throw F instanceof gn?new R("SYNC_REBASE_PENDING",`${F.message.split(";")[0]}; nothing was pushed`,F.remedy):F}finally{c()}let l=a.map(F=>Os(e,F)),g=0,p=0,f=0,u=0,y=d,b=null,h=null,m=t.beginTransaction?await t.beginTransaction():void 0,w=m?{...t,head:m.head,get:m.get,list:t.list.bind(t),putIfAbsent:t.putIfAbsent.bind(t)}:t,v=m?m.stageIfAbsent.bind(m):t.putIfAbsent.bind(t),x=[],ae=F=>m?x.push(F):r(F);try{let F=new Set;for(let A of l){for(let $ of A.blobs)if(await v($.key,$.bytes)!=="exists")p++,F.add($.key);else if(!F.has($.key)){let M=await w.get($.key);if(M===null||Ot(Buffer.from(M))!==$.fp){h=new R("SYNC_OBJECT_CORRUPT",`the blob ${$.fp} ${n} already holds does not hash to its name (named by record ${A.seq}); the record was not pushed`,"the storage object needs a human look before anything more is pushed to it");break}F.add($.key)}if(h)break;A.proposal&&await v(A.proposal.key,A.proposal.bytes)!=="exists"&&f++;let Q=Ne(A.seq);if(await v(Q,A.raw)!=="exists")g++;else if((await pe(w,A.seq)).hash===A.hash)ae(`position ${A.seq} is already on ${n}`),u++;else{b=A.seq;break}y={seq:A.seq,hash:A.hash}}if(m||await Rr(t,y,d,n),y&&!await w.head(ee)){let A=await pe(w,1),Q={layout:1,canonicalizer:"v1",genesis_hash:A.hash};await v(ee,Buffer.from(JSON.stringify(Q)+`
3
3
  `,"utf8"))!=="exists"&&ae(`wrote ${ee} on ${n}`)}if(m){if(y){let M=await w.get(ee),T=await pe(w,1),be={};try{let Z=JSON.parse(Buffer.from(M??[]).toString("utf8"));Z&&typeof Z=="object"&&!Array.isArray(Z)&&(be=Z)}catch{}if(be.layout!==1||be.canonicalizer!=="v1"||be.genesis_hash!==T.hash)throw new R("SYNC_OBJECT_CORRUPT",`${ee} does not describe this context's verified genesis and format.`,"Ask the location owner to inspect the metadata before publishing.")}if(h)throw h;if(b!==null)throw new R("SYNC_POSITION_TAKEN",`position ${b} on ${n} was taken by another writer; this batch was not published`,_r(n,b));let A=await m.commit(),Q=new Set(A.created),$=l.filter(M=>Q.has(Ne(M.seq))).length;u+=g-$,g=$,p=new Set(l.flatMap(M=>M.blobs.map(T=>T.key)).filter(M=>Q.has(M))).size,f=new Set(l.flatMap(M=>M.proposal?[M.proposal.key]:[]).filter(M=>Q.has(M))).size}m&&await Rr(t,y,d,n);for(let A of x)r(A);let U="";if(y)try{Yn(e,n,y,{forwardOnly:!0})}catch(A){if(b===null||!(A instanceof O))throw A;U=" (the witness was not saved; the next pull records it)"}if(h)throw h;if(b!==null)throw new R("SYNC_POSITION_TAKEN",`position ${b} on ${n} was taken by another writer while this push ran; this store's history through position ${y?.seq??0} is confirmed on ${n}${U}`,_r(n,b))}finally{await m?.abort()}return{pushed:g,from:d?.seq??0,to:y?.seq??0,blobs:p,proposals:f,alreadyThere:u}}function _r(e,t){return t===1?`${e} holds a different history: to work on it, clone it with kane-cli context clone <descriptor of ${e}> <dir>; to share this store, add an empty location`:`kane-cli context pull ${e} --rebase`}async function Rr(e,t,n,r){if(!t||t.seq<=(n?.seq??0))return;let o=await pe(e,t.seq);if(o.hash!==t.hash)throw new R("SYNC_OBJECT_CORRUPT",`${r} answered "created" for position ${t.seq} but serves a record hashing ${o.hash}, not ${t.hash}`,"The location needs inspection before publishing more context.")}function Es(e,t){let{records:n,hashes:r}=Ce(e,t?.seq??0,t?.hash??null);return n.map((o,i)=>{let s=r[i],d=Ir(Ss(e,"commits",`${String(o.seq).padStart(6,"0")}-${s.slice(7,19)}.json`));if(oe(JSON.parse(d.toString("utf8")))!==s)throw new Error(`record ${o.seq} changed on disk while it was being read \u2014 run kane-cli context fsck`);return{rec:o,hash:s,raw:d}})}function Os(e,{rec:t,hash:n,raw:r}){{let o=Dn(t),i=o.blobs.map(s=>{let d=ce(e,s);if(d===null)throw new R("SYNC_CLOSURE_MISSING",`record ${t.seq} names blob ${s}, which this store does not hold`,"restore the blob from a copy of this store, or run kane-cli context fsck");if(Ot(d)!==s)throw new R("SYNC_LOCAL_BLOB_CORRUPT",`record ${t.seq} names blob ${s}, but the local file does not hash to that: it is torn`,"restore the blob from a copy of this store, or run kane-cli context fsck");return{key:Jn(s),fp:s,bytes:d}});return{seq:t.seq,hash:n,raw:new Uint8Array(r),blobs:i,proposal:Cs(e,o.proposalId)}}}function Cs(e,t){if(t===null)return null;let n=pn(e,t);if(!Is(n))return null;let r=Ir(n);return{key:Wn(t,Mn(r.toString("utf8"))),bytes:r}}import{existsSync as As,readdirSync as Ps,readFileSync as Sr}from"fs";import{basename as Ns,join as Lt}from"path";var qs=/^\d{6}-[0-9a-f]{12}\.json$/;function Bt(e,t){let n=Lt(e,"commits"),r=As(n)?Ps(n).filter(s=>qs.test(s)).sort():[],o=t.hash,i=t.seq;return r.map(s=>{let d;try{d=JSON.parse(Sr(Lt(n,s),"utf8"))}catch(a){throw new O(`backup record ${s} is not JSON: ${String(a)}`)}if(i+=1,d.seq!==i||d.prev_hash!==o)throw new O(`backup record ${s} does not continue the chain at ${i} from ${String(o)}`);let c=oe(d);if(!c.slice(7).startsWith(s.slice(7,19)))throw new O(`backup record ${s} does not match its name`);return o=c,{seq:i,hash:c,body:d}})}function pt(e,t){let n=JSON.parse(Sr(Lt(t,"base-witness.json"),"utf8")),r=$e(e),o=r.records.slice(0,n.base.seq),i=Bt(t,n.base),s=[...o,...i.map(f=>f.body)],d=[...r.hashes.slice(0,n.base.seq),...i.map(f=>f.hash)],c=new Map;for(let f of s)for(let u of f.nodes)c.set(u.cid,{label:u.label,content:u.content});let a=Rn();In(e,a,s,d,{writeNodeFiles:!1});let l=qn(e,a,c),g=new Map(i.map(f=>[f.seq,f])),p=f=>l.displayNameOf(f)??f.slice(0,19);return{backupDir:t,backupId:Ns(t),from:n.from,base:n.base,index:a,graph:l,records:i,chain:s,recordAt:f=>g.get(f),resolveName:f=>l.resolve(f)?.cid,nameOf:f=>l.displayNameOf(f)??void 0,displayNameFor:f=>{let u=Dt(t,f),y=Object.keys(f.source_head_moves),b=u==="revert"?String(js(t,f)??""):u==="names"?(f.names??[]).map(h=>h.slug).join(", "):y.length>0?y.join(", "):f.nodes.length>0?[...new Set(f.nodes.map(h=>p(h.cid)))].join(", "):(f.executions?.length??0)>0?[...new Set(f.executions.map(h=>p(h.about)))].join(", "):f.review.length>0?[...new Set(f.review.map(h=>p(h.id)))].join(", "):f.supersessions.length>0?[...new Set(f.supersessions.map(h=>h.kind==="node"?p(h.old):h.ecid.slice(0,19)))].join(", "):y.join(", ");return b?`${u} ${b}`:u}}}function js(e,t){try{let r=Oe(e,oe(t))?.args?.seq;return typeof r=="number"?r:void 0}catch{return}}function Dt(e,t){let n=null;try{n=Oe(e,oe(t))}catch{n=null}if(n)return n.verb;if(t.intent_verb)return t.intent_verb;let r=Object.entries(t.source_head_moves);return(t.executions?.length??0)>0?"execution":t.design_of?"design":t.proposal_id!=null?"extract":t.conv?t.conv.turn===0?"conv-mint":"conv-turn":r.length===1&&r[0][1]===null&&t.supersessions.some(o=>o.kind==="node"&&o.new===null)?"retire":r.length===1&&typeof r[0][1]=="string"&&t.nodes.some(o=>o.label==="source")?"ingest":t.review.some(o=>o.resolution==="reset")||t.supersessions.some(o=>o.kind==="node"&&o.new===o.old||o.kind==="edge"&&o.revoke)?"revert":t.nodes.length===0&&t.edges.length===0&&t.supersessions.length===1&&t.supersessions[0].kind==="node"&&t.supersessions[0].new===null?"archive":t.nodes.length===0&&t.edges.length===0&&t.review.length===0&&(t.names?.length??0)>0?"names":t.nodes.length===0&&t.edges.length===0&&t.supersessions.length===0&&t.review.length>0?"review":"unknown"}import{existsSync as Er,readdirSync as Ts,readFileSync as Mt}from"fs";import{isAbsolute as xs,join as ut,normalize as Fs,relative as Ls,sep as Bs}from"path";var Ds=e=>e===""||xs(e)||e.includes("\\")||Fs(e).split(Bs).some(t=>t==="..")||e.startsWith("./")||e.includes("\0");function He(e){let t=ut(e,"manifest.json");if(!Er(t))throw new O(`backup ${e} has no manifest.json \u2014 it was never completed; kane-cli context sync doctor`);let n;try{n=JSON.parse(Mt(t,"utf8"))}catch(s){throw new O(`backup manifest ${t} is not JSON: ${s instanceof Error?s.message:String(s)}`)}if(!Array.isArray(n))throw new O(`backup manifest ${t} is not a list`);let r=new Set,o=[];for(let s of n){let d=typeof s?.name=="string"?s.name:"";if(Ds(d))throw new O(`backup manifest names an unsafe path ${JSON.stringify(s?.name)} \u2014 the backup is not trusted`);let c=ut(e,d);if(!Er(c))throw new O(`backup file ${d} is missing from ${e}`);let a=Mt(c);if("sha256:"+rn(a)!==s.hash)throw new O(`backup file ${d} does not match its manifest hash \u2014 the backup was changed after it was written`);if(d.startsWith("commits/"))try{r.add(oe(JSON.parse(a.toString("utf8"))))}catch(l){throw new O(`backup record ${d} is not a record: ${l instanceof Error?l.message:String(l)}`)}d.startsWith("intents/")&&o.push(d)}let i=new Set(n.map(s=>s.name));for(let s of Or(e)){let d=Ls(e,s);if(d!=="manifest.json"&&!i.has(d))throw new O(`backup ${e} holds ${d}, which its manifest does not name \u2014 the backup was changed after it was written`)}for(let s of o){let d;try{d=JSON.parse(Mt(ut(e,s),"utf8"))}catch(a){throw new O(`backup envelope ${s} is not JSON: ${a instanceof Error?a.message:String(a)}`)}let c=un(d);if(c!==null)throw new O(`backup envelope ${s} is not a valid intent: ${c}`);if(typeof d.born?.hash!="string"||!r.has(d.born.hash))throw new O(`backup envelope ${s} was born from a record the backup does not hold`)}}function Or(e){let t=[];for(let n of Ts(e,{withFileTypes:!0})){let r=ut(e,n.name);n.isDirectory()?t.push(...Or(r)):t.push(r)}return t}import{basename as lo,join as po}from"path";import{existsSync as uo,readFileSync as fo}from"fs";var G=class extends Error{},B=(e,t)=>({kind:"apply",inputs:e,...t&&t.length>0?{aliases:t}:{}}),J=e=>({kind:"noop",reason:e}),Ht=e=>({kind:"dedupe",as:e}),k=(e,t,n,r,o={})=>({kind:"hold",hold:{kind:e,mine:t,theirs:n,answers:r,detail:o}}),Cr=(e,t)=>{let n=ft(t.label,t.content);return e.graph.byLabel(t.label).filter(r=>!e.graph.superseded.has(r.cid)&&ft(t.label,r.content)===n).map(r=>r.cid)},re=e=>e?e.slice(0,19):"none",H=(e,t)=>e.maps.cid.rewrite(t);function I(e,t,n){if(typeof t!="string")throw new G(`${n} was not pinned`);let r=H(e,t);if(!e.graph.hasNode(r))throw new G(`${n} ${_(e,t)} has no counterpart on ${e.location}`);return r}var j=(e,t)=>e.graph.tipOf(t),Gt=(e,t)=>e.graph.superseded.has(e.graph.tipOf(t)),_=(e,t)=>e.fold.nameOf(t)??re(t),S=(e,t)=>e.graph.displayNameOf(t)??re(t);function Vt(e,t,n,r){let o=r==="fold"?e.fold.graph:e.graph,i=o.displayNameOf(t);if(i!==null&&i!==n)return i;let s=o.tipOf(t);for(let[a,l]of o.heads)if(l===t||l===s)return a;let d=o.getNode(t);if(d?.label==="source"&&typeof d.content.source_id=="string")return d.content.source_id;let c=d?.content.title??d?.content.text??d?.content.statement;return d&&typeof c=="string"&&c!==""?`${d.label} "${z(c,32)}"`:re(t)}var L=e=>e.created_by?.by?.id??e.review[0]?.by.id??e.supersessions[0]?.by.id??e.names?.[0]?.by.id??"someone",P=e=>e.ts;function z(e,t=48){let n=typeof e=="string"?e:JSON.stringify(e);return n.length>t?`${n.slice(0,t-1)}\u2026`:n}function he(e,t,n,r){return`${[...new Set([...Object.keys(e),...Object.keys(t)])].filter(s=>s!=="derived"&&JSON.stringify(e[s])!==JSON.stringify(t[s])).map(s=>`${s} "${z(e[s]??"")}" \u2192 "${z(t[s]??"")}"`).join(", ")||"no field changed"} by ${n} at ${r}`}function ie(e,t){for(let n of e.theirs)for(let r of n.supersessions)if(r.kind==="node"&&r.old===t)return{rec:n,next:r.new}}function Jt(e,t){let n=new Set([t]);for(let o=!0;o;){o=!1;for(let[i,s]of e.graph.superseded)typeof s=="string"&&n.has(s)&&!n.has(i)&&(n.add(i),o=!0)}let r=[];for(let o of e.theirs)for(let i of o.review)n.has(i.id)&&i.resolution!=="pending"&&r.push({rec:o,resolution:i.resolution});return r}var Ms=new Set(Object.values(Ze).filter(e=>e!==Ze.DERIVES&&e!==Ze.ANNOTATES));function Wt(e,t){let n=new Set,r=[],o=[t,e.graph.tipOf(t)];for(;o.length>0;){let i=o.pop();if(!n.has(i)){n.add(i);for(let s of e.graph.edgesInto(i))!Ms.has(s.type)||e.graph.superseded.has(s.src)||(!(s.src in e.fold.index.nodeLabel)&&!r.some(d=>d.cid===s.src)&&r.push({cid:s.src,label:e.graph.nodeLabel.get(s.src)??"node"}),o.push(s.src))}}return r}function Ut(e){let t=new Map;for(let n of e)t.set(n.label,(t.get(n.label)??0)+1);return[...t].map(([n,r])=>`${r} ${n}${r===1?"":"s"}`).join(", ")}function ht(e,t,n){if(!e.theirs.some(o=>o.edges.some(i=>i.type===t&&i.src===n)))return;let r=e.graph.edgesFrom(n).find(o=>o.type===t);return r?{live:r.dst}:void 0}function Ie(e,t){let n=t.event_ids??[],r=n.filter(i=>i in e.index.eventDigests);return n.length===0||r.length===0?void 0:r.every(i=>{let s=n.indexOf(i),d=t.event_digests?.[s];return d!==void 0&&d!==""&&e.index.eventDigests[i]===d})&&r.length===n.length?J("already applied: every event id is in the chain with the same intent"):k("ambiguous",`committed ${n.length} event id${n.length===1?"":"s"}`,`${r.length} of them already in the shared chain under another intent`,["keep-theirs"],{event_ids:n})}function Hs(e){return String(e??"").toLowerCase().trim().replace(/\s+/g," ")}function ft(e,t){let n=t.question;return`${e}\0${Hs(t.title??t.text??t.statement??n?.header??t.source_id??"")}`}function Ar(e,t){let n=[],r=new Set;for(let o of e.nodes){let i=ft(o.label,o.content),s=t.nodes.find(d=>!r.has(d.cid)&&ft(d.label,d.content)===i);s&&(r.add(s.cid),n.push([o.cid,s.cid]))}for(let o of e.nodes){if(n.some(([s])=>s===o.cid))continue;let i=t.nodes.find(s=>!r.has(s.cid)&&s.label===o.label);i&&(r.add(i.cid),n.push([o.cid,i.cid]))}return n}function Pr(e,t){let n=[],r=new Set;for(let o of t.names??[]){if(!tt.test(o.slug))continue;let i=t.nodes.find(d=>d.cid===o.cid);if(!i||e.graph.nameOf.has(H(e,o.cid)))continue;let s=nt(i.label,d=>r.has(d),e.graph.names.keys());s!==null&&(r.add(s),s!==o.slug&&n.push({from:o.slug,to:s}))}return n}function Nr(e,t,n){let r=[];for(let o of e.names??[]){let i=n.find(([d])=>d===o.cid)?.[1],s=t.names?.find(d=>d.cid===i);s&&s.slug!==o.slug&&r.push({from:o.slug,to:s.slug})}return r}function qr(e,t,n){let r=e===void 0?void 0:e.split(`
4
4
  `).map(s=>{let d=/^(##\s.*?)\s@verifies\s+(.+?)\s*$/.exec(s);if(d)return`${d[1]} @verifies ${d[2].split(",").map(l=>l.trim()).filter(Boolean).map(n).join(", ")}`;let c=/^(\s*)@import\s+(\S+)\s*$/.exec(s);if(c)return`${c[1]}@import ${n(c[2])}`;let a=/^## Import: (\S+)\s*$/.exec(s);return a?`## Import: ${n(a[1])}`:s}).join(`
5
5
  `),o=!1,i=t===void 0?void 0:t.split(`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as f}from"./chunk-YPEIPCQY.js";import{y as r}from"./chunk-UQ6A52ML.js";import{a as g}from"./chunk-HCBYKLMW.js";import{a as i,b as n,i as p}from"./chunk-C44QQJR4.js";import{a as x}from"./chunk-6YGTRKDT.js";import{e as d}from"./chunk-UR6MHSHU.js";var b=d(x(),1);var e=d(g(),1),v=[{value:"desktop",label:"Desktop",hint:"Chrome on this machine"},{value:"emulator",label:"Emulator",hint:"a virtual Android device"},{value:"simulator",label:"Simulator",hint:"a virtual iOS device"}];function T(a){return a==="all"?v:v.filter(l=>l.value!=="desktop")}function B({mode:a="all",onSelect:l,onCancel:c}){let u=T(a),[h,m]=(0,b.useState)(0);return p((s,o)=>{if(o.escape&&c){c();return}o.upArrow&&m(t=>Math.max(0,t-1)),o.downArrow&&m(t=>Math.min(u.length-1,t+1)),o.return&&l(u[h].value)}),(0,e.jsxs)(i,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(n,{color:r.orange,bold:!0,children:a==="all"?"Where should tests run?":"Which kind of device?"}),(0,e.jsx)(i,{marginTop:1,flexDirection:"column",children:u.map((s,o)=>{let t=o===h;return(0,e.jsxs)(i,{children:[(0,e.jsxs)(n,{color:t?r.orange:void 0,children:[t?"\u276F ":" ",s.label]}),(0,e.jsxs)(n,{color:r.dim,children:[" ",s.hint]})]},s.value)})}),(0,e.jsx)(i,{marginTop:1,children:(0,e.jsx)(n,{color:r.dim,children:"You can change this any time with /desktop or /mobile."})}),(0,e.jsx)(f,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],suppressEscBack:!c,escBackLabel:"skip"})]})}export{B as a};
2
+ import{a as f}from"./chunk-PY4BWRR6.js";import{y as r}from"./chunk-OWPQZP4C.js";import{a as g}from"./chunk-HCBYKLMW.js";import{a as i,b as n,i as p}from"./chunk-C44QQJR4.js";import{a as x}from"./chunk-6YGTRKDT.js";import{e as d}from"./chunk-UR6MHSHU.js";var b=d(x(),1);var e=d(g(),1),v=[{value:"desktop",label:"Desktop",hint:"Chrome on this machine"},{value:"emulator",label:"Emulator",hint:"a virtual Android device"},{value:"simulator",label:"Simulator",hint:"a virtual iOS device"}];function T(a){return a==="all"?v:v.filter(l=>l.value!=="desktop")}function B({mode:a="all",onSelect:l,onCancel:c}){let u=T(a),[h,m]=(0,b.useState)(0);return p((s,o)=>{if(o.escape&&c){c();return}o.upArrow&&m(t=>Math.max(0,t-1)),o.downArrow&&m(t=>Math.min(u.length-1,t+1)),o.return&&l(u[h].value)}),(0,e.jsxs)(i,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(n,{color:r.orange,bold:!0,children:a==="all"?"Where should tests run?":"Which kind of device?"}),(0,e.jsx)(i,{marginTop:1,flexDirection:"column",children:u.map((s,o)=>{let t=o===h;return(0,e.jsxs)(i,{children:[(0,e.jsxs)(n,{color:t?r.orange:void 0,children:[t?"\u276F ":" ",s.label]}),(0,e.jsxs)(n,{color:r.dim,children:[" ",s.hint]})]},s.value)})}),(0,e.jsx)(i,{marginTop:1,children:(0,e.jsx)(n,{color:r.dim,children:"You can change this any time with /desktop or /mobile."})}),(0,e.jsx)(f,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],suppressEscBack:!c,escBackLabel:"skip"})]})}export{B as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as C}from"./chunk-6VB4FGBZ.js";import{k as Z}from"./chunk-WTAJTPI5.js";import{a as D}from"./chunk-YCCUBQY4.js";import{a as M}from"./chunk-H7A4R7WY.js";import{a as z}from"./chunk-4JRCAHHB.js";import{b as W}from"./chunk-2LKSDGWA.js";import{a as B}from"./chunk-YPEIPCQY.js";import{e as V}from"./chunk-Z7S3IWUX.js";import{y as o}from"./chunk-UQ6A52ML.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as n,b as t,i as L}from"./chunk-C44QQJR4.js";import{a as N}from"./chunk-6YGTRKDT.js";import{e as g}from"./chunk-UR6MHSHU.js";var T=g(A(),1);function te(e){let i=e.kind==="simulator";switch(e.state){case"ready":return i?"Booted":"Running";case"stopped":return i?"Shutdown":"Stopped";case"unauthorized":return"UNAUTHORIZED";case"offline":return"Offline"}}function re(e){switch(e.state){case"unauthorized":return"accept the authorisation prompt on the device, then reopen this list";case"offline":return e.kind==="simulator"?"not responding \u2014 open Simulator.app to inspect it":"not responding \u2014 reconnect it, or restart the emulator";default:return}}function ne(e,i){let m=i.id!==void 0?{...i,id:z(i.id)}:i,c=e.virtualName!==void 0?{...e,virtualName:z(e.virtualName)}:e;return V(c,m)}function ie(e){return e.virtualName??e.displayName}function ae(e,i){let m=e.state==="ready"||e.state==="stopped",c=re(e),b=e.osVersion?` (${e.osVersion})`:"";return{id:e.id,label:`${ie(e)}${b} \xB7 ${te(e)}`,...i&&ne(e,i)?{isActive:!0}:{},...m?{}:{disabled:!0},...!m&&c?{disabledHint:c}:{}}}function le(e){return e==="emulator"?"No Android emulator found. Make sure an emulator exists on this machine (Android Studio \u2192 Device Manager), then reopen this list.":e==="simulator"?"No iOS simulator found. Make sure a simulator exists on this machine (Xcode \u2192 Windows \u2192 Devices and Simulators), then reopen this list.":"No emulator or simulator found. Make sure one exists on this machine, then reopen this list."}function he({targets:e,preselectedTarget:i,preselectedId:m,busyMessage:c,onSelect:b,onCancel:f,kind:l}){if(c)return(0,T.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,T.jsx)(t,{color:o.orange,bold:!0,children:"Device"}),(0,T.jsxs)(n,{marginTop:1,children:[(0,T.jsx)(C,{}),(0,T.jsxs)(t,{color:o.secondary,children:[" ",c]})]})]});if(e.length===0)return(0,T.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,T.jsx)(t,{color:o.orange,bold:!0,children:"Device"}),(0,T.jsx)(n,{marginTop:1,children:(0,T.jsx)(t,{color:o.dim,children:le(l)})})]});let d=e.map(r=>ae(r,i)),p=i?d.find(r=>r.isActive)?.id??null:m?e.find(r=>r.id===m||r.virtualName===m)?.id??null:null,a=new Map(e.map(r=>[r.id,r]));return(0,T.jsx)(M,{title:"Device",items:d,itemNoun:"devices",defaultActiveId:p,preserveSelectionById:!0,onSelect:r=>{let y=a.get(r.id);y&&b(y)},onCancel:f})}var x=g(N(),1);var u=g(A(),1),q=50,G=500;function pe(e){return`${e.name} (${e.appId})`}function Pe({kind:e,listApps:i,onSelect:m,onManualEntry:c,onCancel:b,busyMessage:f}){let[l,d]=(0,x.useState)([]),[p,a]=(0,x.useState)(!0),[r,y]=(0,x.useState)(!1),[Q,O]=(0,x.useState)(!1),[E,H]=(0,x.useState)(null),[w,J]=(0,x.useState)(""),[j,U]=(0,x.useState)(!1),$=(0,x.useRef)(!0),R=(0,x.useRef)(0);if((0,x.useEffect)(()=>{let h=++R.current,k=w.trim();$.current?a(!0):k&&O(!0),y(!0),H(null),U(!1),(async()=>{let I=[];try{for(let P=0;;P+=q){let X=await i({limit:q,offset:P,search:k});if(h!==R.current)return;if(I.push(...X.apps),d([...I]),$.current&&(a(!1),$.current=!1),O(!1),X.apps.length===0||I.length>=X.total)break;if(I.length>=G){U(!0);break}}}catch(P){if(h!==R.current)return;H(P instanceof Error?P.message:String(P)),a(!1),O(!1)}finally{h===R.current&&y(!1)}})()},[w,i]),L((h,k)=>{if(k.tab){c();return}k.escape&&b()},{isActive:!!E&&!f}),f)return(0,u.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,u.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,u.jsxs)(n,{marginTop:1,children:[(0,u.jsx)(C,{}),(0,u.jsxs)(t,{color:o.secondary,children:[" ",f]})]})]});if(E)return(0,u.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.red,paddingX:2,paddingY:1,children:[(0,u.jsx)(t,{color:o.red,bold:!0,children:"App under test"}),(0,u.jsx)(n,{marginTop:1,children:(0,u.jsx)(t,{color:o.red,children:"Could not load your uploads."})}),(0,u.jsx)(n,{marginTop:1,children:(0,u.jsx)(t,{color:o.dim,children:E})}),(0,u.jsx)(B,{bindings:[{keys:"tab",label:"tab to enter an app id"}],escBackLabel:"back to chat"})]});let ee=new Map(l.map(h=>[h.appId,h])),oe=l.map(h=>({id:h.appId,label:pe(h)})),_=!p&&!r&&l.length===0&&!w.trim()?e==="simulator"?"No simulator builds uploaded to this account yet \u2014 press Tab to enter an app id.":"No emulator builds uploaded to this account yet \u2014 press Tab to enter an app id.":null;return(0,u.jsx)(M,{title:"App under test",items:oe,loading:p,loadingText:"Loading your uploads\u2026",loadingMore:r,searching:Q,itemNoun:"uploads",preserveSelectionById:!0,onSearch:J,onTab:c,extraHint:"tab to enter an id",footer:_?(0,u.jsx)(t,{color:o.dim,children:_}):j?(0,u.jsx)(t,{color:o.dim,children:`Showing the first ${G} \u2014 type to search the rest.`}):void 0,onSelect:h=>{let k=ee.get(h.id);k&&m({appId:k.appId,name:k.name})},onCancel:b})}var Y=g(N(),1);var S=g(A(),1),se={emulator:["apk"],simulator:["zip"]};function ce(e){return Z(e.trim())}function Oe({kind:e,onBack:i,onSelect:m,onCancel:c}){let[b,f]=(0,Y.useState)(""),[l,d]=(0,Y.useState)(null),p=e==="emulator"?".apk":".zip";return(0,S.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,S.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,S.jsx)(n,{marginTop:1,children:(0,S.jsx)(t,{color:o.dim,children:`Path to a build (${p}): `})}),(0,S.jsxs)(n,{marginTop:1,children:[(0,S.jsx)(t,{color:o.dim,children:" "}),(0,S.jsx)(D,{value:b,onChange:a=>{f(a),l&&d(null)},onSubmit:a=>{let r=ce(a);if(!r){d(a.trim()?`Not a build \u2014 expected ${p}.`:"Enter the path to a build.");return}if(!se[e].includes(r.kind)){d(`${r.kind} builds don't run on a ${e} \u2014 expected ${p}.`);return}d(null),m(r).then(y=>{!y.ok&&y.error&&d(y.error)})},onCancel:i,placeholder:e==="emulator"?"/path/to/app-debug.apk":"/path/to/MyApp.zip"})]}),l&&(0,S.jsx)(n,{marginTop:1,children:(0,S.jsx)(t,{color:o.red,children:l})}),(0,S.jsx)(B,{bindings:[{keys:"\u21B5",label:"use this build"}],escBackLabel:"back"})]})}var F=g(N(),1);var v=g(A(),1);function de(e){return[{value:"local",label:"Local build",hint:e==="emulator"?".apk":".zip",available:!0},{value:"uploaded",label:"Uploaded app",hint:"an app id from your cloud uploads",available:!0}]}function Ye({kind:e,onSelect:i,onCancel:m}){let c=de(e),[b,f]=(0,F.useState)(0),[l,d]=(0,F.useState)(null);return L((p,a)=>{if(a.escape){m();return}if(a.upArrow&&f(r=>Math.max(0,r-1)),a.downArrow&&f(r=>Math.min(c.length-1,r+1)),a.return){let r=c[b];if(!r.available){d("That source isn't available \u2014 choose a local build for now.");return}d(null),i(r.value)}}),(0,v.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,v.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,v.jsx)(n,{marginTop:1,flexDirection:"column",children:c.map((p,a)=>{let r=a===b,y=p.available?r?o.orange:void 0:o.muted;return(0,v.jsxs)(n,{children:[(0,v.jsxs)(t,{color:y,children:[r?"\u276F ":" ",p.label]}),(0,v.jsxs)(t,{color:o.dim,children:[" ",p.hint]})]},p.value)})}),l&&(0,v.jsx)(n,{marginTop:1,children:(0,v.jsx)(t,{color:o.red,children:l})}),(0,v.jsx)(B,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}var K=g(N(),1);var s=g(A(),1);function qe({busyMessage:e,onSubmit:i,onBack:m}){let[c,b]=(0,K.useState)(""),[f,l]=(0,K.useState)(null);return e?(0,s.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,s.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,s.jsxs)(n,{marginTop:1,children:[(0,s.jsx)(C,{}),(0,s.jsxs)(t,{color:o.secondary,children:[" ",e]})]})]}):(0,s.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,s.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,s.jsx)(n,{marginTop:1,children:(0,s.jsx)(t,{color:o.dim,children:"App id from your cloud uploads:"})}),(0,s.jsxs)(n,{marginTop:1,children:[(0,s.jsx)(t,{color:o.dim,children:" "}),(0,s.jsx)(D,{value:c,onChange:d=>{b(d),f&&l(null)},onSubmit:d=>{let p=d.trim();if(!p){l("Enter an app id.");return}if(!W(p)){l("That doesn't look like an app id \u2014 they start with APP.");return}l(null),i(p).then(a=>{!a.ok&&a.error&&l(a.error)})},onCancel:m,placeholder:"APP1016032231178585590501450"})]}),f&&(0,s.jsxs)(n,{marginTop:1,flexDirection:"column",children:[(0,s.jsx)(t,{color:o.red,children:f}),(0,s.jsx)(t,{color:o.dim,children:"Enter a valid app id \u2014 copy it from your cloud uploads."})]}),(0,s.jsx)(B,{bindings:[{keys:"\u21B5",label:"use this app"}],escBackLabel:"back"})]})}export{he as a,Pe as b,Oe as c,Ye as d,qe as e};
2
+ import{a as C}from"./chunk-DCLMFWCF.js";import{k as Z}from"./chunk-4K44ZIC4.js";import{a as D}from"./chunk-YCCUBQY4.js";import{a as M}from"./chunk-PP4I2Z6M.js";import{a as z}from"./chunk-4L45IQNU.js";import{b as W}from"./chunk-Y67FYNLP.js";import{a as B}from"./chunk-PY4BWRR6.js";import{e as V}from"./chunk-Z7S3IWUX.js";import{y as o}from"./chunk-OWPQZP4C.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as n,b as t,i as L}from"./chunk-C44QQJR4.js";import{a as N}from"./chunk-6YGTRKDT.js";import{e as g}from"./chunk-UR6MHSHU.js";var T=g(A(),1);function te(e){let i=e.kind==="simulator";switch(e.state){case"ready":return i?"Booted":"Running";case"stopped":return i?"Shutdown":"Stopped";case"unauthorized":return"UNAUTHORIZED";case"offline":return"Offline"}}function re(e){switch(e.state){case"unauthorized":return"accept the authorisation prompt on the device, then reopen this list";case"offline":return e.kind==="simulator"?"not responding \u2014 open Simulator.app to inspect it":"not responding \u2014 reconnect it, or restart the emulator";default:return}}function ne(e,i){let m=i.id!==void 0?{...i,id:z(i.id)}:i,c=e.virtualName!==void 0?{...e,virtualName:z(e.virtualName)}:e;return V(c,m)}function ie(e){return e.virtualName??e.displayName}function ae(e,i){let m=e.state==="ready"||e.state==="stopped",c=re(e),b=e.osVersion?` (${e.osVersion})`:"";return{id:e.id,label:`${ie(e)}${b} \xB7 ${te(e)}`,...i&&ne(e,i)?{isActive:!0}:{},...m?{}:{disabled:!0},...!m&&c?{disabledHint:c}:{}}}function le(e){return e==="emulator"?"No Android emulator found. Make sure an emulator exists on this machine (Android Studio \u2192 Device Manager), then reopen this list.":e==="simulator"?"No iOS simulator found. Make sure a simulator exists on this machine (Xcode \u2192 Windows \u2192 Devices and Simulators), then reopen this list.":"No emulator or simulator found. Make sure one exists on this machine, then reopen this list."}function he({targets:e,preselectedTarget:i,preselectedId:m,busyMessage:c,onSelect:b,onCancel:f,kind:l}){if(c)return(0,T.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,T.jsx)(t,{color:o.orange,bold:!0,children:"Device"}),(0,T.jsxs)(n,{marginTop:1,children:[(0,T.jsx)(C,{}),(0,T.jsxs)(t,{color:o.secondary,children:[" ",c]})]})]});if(e.length===0)return(0,T.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,T.jsx)(t,{color:o.orange,bold:!0,children:"Device"}),(0,T.jsx)(n,{marginTop:1,children:(0,T.jsx)(t,{color:o.dim,children:le(l)})})]});let d=e.map(r=>ae(r,i)),p=i?d.find(r=>r.isActive)?.id??null:m?e.find(r=>r.id===m||r.virtualName===m)?.id??null:null,a=new Map(e.map(r=>[r.id,r]));return(0,T.jsx)(M,{title:"Device",items:d,itemNoun:"devices",defaultActiveId:p,preserveSelectionById:!0,onSelect:r=>{let y=a.get(r.id);y&&b(y)},onCancel:f})}var x=g(N(),1);var u=g(A(),1),q=50,G=500;function pe(e){return`${e.name} (${e.appId})`}function Pe({kind:e,listApps:i,onSelect:m,onManualEntry:c,onCancel:b,busyMessage:f}){let[l,d]=(0,x.useState)([]),[p,a]=(0,x.useState)(!0),[r,y]=(0,x.useState)(!1),[Q,O]=(0,x.useState)(!1),[E,H]=(0,x.useState)(null),[w,J]=(0,x.useState)(""),[j,U]=(0,x.useState)(!1),$=(0,x.useRef)(!0),R=(0,x.useRef)(0);if((0,x.useEffect)(()=>{let h=++R.current,k=w.trim();$.current?a(!0):k&&O(!0),y(!0),H(null),U(!1),(async()=>{let I=[];try{for(let P=0;;P+=q){let X=await i({limit:q,offset:P,search:k});if(h!==R.current)return;if(I.push(...X.apps),d([...I]),$.current&&(a(!1),$.current=!1),O(!1),X.apps.length===0||I.length>=X.total)break;if(I.length>=G){U(!0);break}}}catch(P){if(h!==R.current)return;H(P instanceof Error?P.message:String(P)),a(!1),O(!1)}finally{h===R.current&&y(!1)}})()},[w,i]),L((h,k)=>{if(k.tab){c();return}k.escape&&b()},{isActive:!!E&&!f}),f)return(0,u.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,u.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,u.jsxs)(n,{marginTop:1,children:[(0,u.jsx)(C,{}),(0,u.jsxs)(t,{color:o.secondary,children:[" ",f]})]})]});if(E)return(0,u.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.red,paddingX:2,paddingY:1,children:[(0,u.jsx)(t,{color:o.red,bold:!0,children:"App under test"}),(0,u.jsx)(n,{marginTop:1,children:(0,u.jsx)(t,{color:o.red,children:"Could not load your uploads."})}),(0,u.jsx)(n,{marginTop:1,children:(0,u.jsx)(t,{color:o.dim,children:E})}),(0,u.jsx)(B,{bindings:[{keys:"tab",label:"tab to enter an app id"}],escBackLabel:"back to chat"})]});let ee=new Map(l.map(h=>[h.appId,h])),oe=l.map(h=>({id:h.appId,label:pe(h)})),_=!p&&!r&&l.length===0&&!w.trim()?e==="simulator"?"No simulator builds uploaded to this account yet \u2014 press Tab to enter an app id.":"No emulator builds uploaded to this account yet \u2014 press Tab to enter an app id.":null;return(0,u.jsx)(M,{title:"App under test",items:oe,loading:p,loadingText:"Loading your uploads\u2026",loadingMore:r,searching:Q,itemNoun:"uploads",preserveSelectionById:!0,onSearch:J,onTab:c,extraHint:"tab to enter an id",footer:_?(0,u.jsx)(t,{color:o.dim,children:_}):j?(0,u.jsx)(t,{color:o.dim,children:`Showing the first ${G} \u2014 type to search the rest.`}):void 0,onSelect:h=>{let k=ee.get(h.id);k&&m({appId:k.appId,name:k.name})},onCancel:b})}var Y=g(N(),1);var S=g(A(),1),se={emulator:["apk"],simulator:["zip"]};function ce(e){return Z(e.trim())}function Oe({kind:e,onBack:i,onSelect:m,onCancel:c}){let[b,f]=(0,Y.useState)(""),[l,d]=(0,Y.useState)(null),p=e==="emulator"?".apk":".zip";return(0,S.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,S.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,S.jsx)(n,{marginTop:1,children:(0,S.jsx)(t,{color:o.dim,children:`Path to a build (${p}): `})}),(0,S.jsxs)(n,{marginTop:1,children:[(0,S.jsx)(t,{color:o.dim,children:" "}),(0,S.jsx)(D,{value:b,onChange:a=>{f(a),l&&d(null)},onSubmit:a=>{let r=ce(a);if(!r){d(a.trim()?`Not a build \u2014 expected ${p}.`:"Enter the path to a build.");return}if(!se[e].includes(r.kind)){d(`${r.kind} builds don't run on a ${e} \u2014 expected ${p}.`);return}d(null),m(r).then(y=>{!y.ok&&y.error&&d(y.error)})},onCancel:i,placeholder:e==="emulator"?"/path/to/app-debug.apk":"/path/to/MyApp.zip"})]}),l&&(0,S.jsx)(n,{marginTop:1,children:(0,S.jsx)(t,{color:o.red,children:l})}),(0,S.jsx)(B,{bindings:[{keys:"\u21B5",label:"use this build"}],escBackLabel:"back"})]})}var F=g(N(),1);var v=g(A(),1);function de(e){return[{value:"local",label:"Local build",hint:e==="emulator"?".apk":".zip",available:!0},{value:"uploaded",label:"Uploaded app",hint:"an app id from your cloud uploads",available:!0}]}function Ye({kind:e,onSelect:i,onCancel:m}){let c=de(e),[b,f]=(0,F.useState)(0),[l,d]=(0,F.useState)(null);return L((p,a)=>{if(a.escape){m();return}if(a.upArrow&&f(r=>Math.max(0,r-1)),a.downArrow&&f(r=>Math.min(c.length-1,r+1)),a.return){let r=c[b];if(!r.available){d("That source isn't available \u2014 choose a local build for now.");return}d(null),i(r.value)}}),(0,v.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,v.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,v.jsx)(n,{marginTop:1,flexDirection:"column",children:c.map((p,a)=>{let r=a===b,y=p.available?r?o.orange:void 0:o.muted;return(0,v.jsxs)(n,{children:[(0,v.jsxs)(t,{color:y,children:[r?"\u276F ":" ",p.label]}),(0,v.jsxs)(t,{color:o.dim,children:[" ",p.hint]})]},p.value)})}),l&&(0,v.jsx)(n,{marginTop:1,children:(0,v.jsx)(t,{color:o.red,children:l})}),(0,v.jsx)(B,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}var K=g(N(),1);var s=g(A(),1);function qe({busyMessage:e,onSubmit:i,onBack:m}){let[c,b]=(0,K.useState)(""),[f,l]=(0,K.useState)(null);return e?(0,s.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,s.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,s.jsxs)(n,{marginTop:1,children:[(0,s.jsx)(C,{}),(0,s.jsxs)(t,{color:o.secondary,children:[" ",e]})]})]}):(0,s.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,s.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,s.jsx)(n,{marginTop:1,children:(0,s.jsx)(t,{color:o.dim,children:"App id from your cloud uploads:"})}),(0,s.jsxs)(n,{marginTop:1,children:[(0,s.jsx)(t,{color:o.dim,children:" "}),(0,s.jsx)(D,{value:c,onChange:d=>{b(d),f&&l(null)},onSubmit:d=>{let p=d.trim();if(!p){l("Enter an app id.");return}if(!W(p)){l("That doesn't look like an app id \u2014 they start with APP.");return}l(null),i(p).then(a=>{!a.ok&&a.error&&l(a.error)})},onCancel:m,placeholder:"APP1016032231178585590501450"})]}),f&&(0,s.jsxs)(n,{marginTop:1,flexDirection:"column",children:[(0,s.jsx)(t,{color:o.red,children:f}),(0,s.jsx)(t,{color:o.dim,children:"Enter a valid app id \u2014 copy it from your cloud uploads."})]}),(0,s.jsx)(B,{bindings:[{keys:"\u21B5",label:"use this app"}],escBackLabel:"back"})]})}export{he as a,Pe as b,Oe as c,Ye as d,qe as e};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Ve}from"./chunk-GESZSIB6.js";import{a as Ye}from"./chunk-SYKS57PK.js";import{a as We}from"./chunk-YCCUBQY4.js";import{a as qe}from"./chunk-VE3SUJMA.js";import{a as be}from"./chunk-YPEIPCQY.js";import{a as Ge}from"./chunk-WAZUOA3Y.js";import{a as He}from"./chunk-RBVLIMOV.js";import{b as Le,y as u}from"./chunk-UQ6A52ML.js";import{a as re}from"./chunk-HCBYKLMW.js";import{a as h,b as f,h as Fe,i as Se,k as Ne}from"./chunk-C44QQJR4.js";import{a as we}from"./chunk-6YGTRKDT.js";import{e as $}from"./chunk-UR6MHSHU.js";var je=$(we(),1);import{readFileSync as ct,writeFileSync as ut,mkdirSync as ft}from"fs";import{dirname as dt,join as ze}from"path";var mt=ze(Le,"command-history.json"),Dt=ze(Le,"generate-history.json"),ht=200,De=class{entries;filePath;max;constructor(t=mt,e=ht){this.filePath=t,this.max=e,this.entries=this._load()}push(t){this.entries.length>0&&this.entries[this.entries.length-1]===t||(this.entries.push(t),this.entries.length>this.max&&(this.entries=this.entries.slice(this.entries.length-this.max)),this._save())}getAll(){return[...this.entries]}search(t){let e=t.toLowerCase(),o=[];for(let s=this.entries.length-1;s>=0;s--)this.entries[s].toLowerCase().includes(e)&&o.push(this.entries[s]);return o}_load(){if(this.filePath===null)return[];try{let t=ct(this.filePath,"utf-8"),e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}}_save(){if(this.filePath!==null)try{ft(dt(this.filePath),{recursive:!0}),ut(this.filePath,JSON.stringify(this.entries)+`
2
+ import{a as Ve}from"./chunk-SA7ORQHP.js";import{a as Ye}from"./chunk-ISBISZUE.js";import{a as We}from"./chunk-YCCUBQY4.js";import{a as qe}from"./chunk-VE3SUJMA.js";import{a as be}from"./chunk-PY4BWRR6.js";import{a as Ge}from"./chunk-BNWU7JOW.js";import{a as He}from"./chunk-5WZ2WOOM.js";import{b as Le,y as u}from"./chunk-OWPQZP4C.js";import{a as re}from"./chunk-HCBYKLMW.js";import{a as h,b as f,h as Fe,i as Se,k as Ne}from"./chunk-C44QQJR4.js";import{a as we}from"./chunk-6YGTRKDT.js";import{e as $}from"./chunk-UR6MHSHU.js";var je=$(we(),1);import{readFileSync as ct,writeFileSync as ut,mkdirSync as ft}from"fs";import{dirname as dt,join as ze}from"path";var mt=ze(Le,"command-history.json"),Dt=ze(Le,"generate-history.json"),ht=200,De=class{entries;filePath;max;constructor(t=mt,e=ht){this.filePath=t,this.max=e,this.entries=this._load()}push(t){this.entries.length>0&&this.entries[this.entries.length-1]===t||(this.entries.push(t),this.entries.length>this.max&&(this.entries=this.entries.slice(this.entries.length-this.max)),this._save())}getAll(){return[...this.entries]}search(t){let e=t.toLowerCase(),o=[];for(let s=this.entries.length-1;s>=0;s--)this.entries[s].toLowerCase().includes(e)&&o.push(this.entries[s]);return o}_load(){if(this.filePath===null)return[];try{let t=ct(this.filePath,"utf-8"),e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}}_save(){if(this.filePath!==null)try{ft(dt(this.filePath),{recursive:!0}),ut(this.filePath,JSON.stringify(this.entries)+`
3
3
  `)}catch{}}};function kt(n){let t=(0,je.useRef)(null);return t.current||(t.current=new De(n)),t.current}var D=$(we(),1);var ke=$(we(),1);var Z=$(re(),1);function Xe({history:n,onSelect:t,onClose:e}){let[o,s]=(0,ke.useState)(""),[l,m]=(0,ke.useState)(0),v=o?n.search(o).slice(0,8):[];return Se((b,d)=>{if(d.escape){e();return}if(d.return){v.length>0&&v[l]?t(v[l]):e();return}if(d.upArrow){m(S=>Math.max(0,S-1));return}if(d.downArrow){m(S=>Math.min(v.length-1,S+1));return}if(d.backspace||d.delete){s(S=>S.slice(0,-1)),m(0);return}b&&!d.ctrl&&!d.meta&&(s(S=>S+b),m(0))}),(0,Z.jsxs)(h,{flexDirection:"column",marginLeft:2,borderStyle:"single",paddingX:1,children:[(0,Z.jsx)(f,{color:u.muted,bold:!0,children:"reverse search"}),(0,Z.jsxs)(h,{gap:1,children:[(0,Z.jsx)(f,{color:u.dim,children:"search:"}),(0,Z.jsx)(f,{children:o}),(0,Z.jsx)(f,{color:u.orange,children:"\u2588"})]}),v.length>0&&(0,Z.jsx)(f,{children:" "}),v.map((b,d)=>(0,Z.jsx)(h,{marginLeft:2,children:(0,Z.jsxs)(f,{color:d===l?u.orange:u.dim,bold:d===l,children:[d===l?"\u25B8 ":" ",b]})},`${d}-${b}`))]})}var X=$(re(),1);function Je({commands:n,selectedIndex:t}){return n.length===0?null:(0,X.jsx)(h,{flexDirection:"column",marginBottom:0,children:n.map((e,o)=>{let s=o===t;return e.disabled?(0,X.jsxs)(h,{children:[(0,X.jsx)(f,{color:u.dim,children:s?"\u276F ":" "}),(0,X.jsxs)(f,{color:u.dim,children:["/",e.name]}),(0,X.jsxs)(f,{color:u.dim,children:[" ",e.disabledReason??e.description]})]},e.name):(0,X.jsxs)(h,{children:[(0,X.jsx)(f,{color:s?u.orange:u.dim,children:s?"\u276F ":" "}),(0,X.jsxs)(f,{color:s?u.orange:void 0,bold:s,children:["/",e.name]}),e.args&&(0,X.jsxs)(f,{color:u.dim,children:[" ",e.args]}),(0,X.jsxs)(f,{color:u.dim,children:[" ",e.description]})]},e.name)})})}var Ze=$(we(),1);var q=$(re(),1),et={scenario:"Scenarios",case:"Test Cases",file:"Files",artifact:"Artifact candidates",installed:"Installed on device"};function Qe(n){let t={scenario:0,case:0,file:0,artifact:0,installed:0};for(let e of n)t[e.kind]++;return["scenario","case","file","artifact","installed"].filter(e=>t[e]>0).map(e=>`${t[e]} ${et[e]}`).join(" \xB7 ")}var Pe=7;function tt({items:n,selectedIndex:t,accent:e=u.orange}){let o=n.length;if(o===0)return null;let s=Math.floor(Pe/2),l=o<=Pe?0:Math.max(0,Math.min(t-s,o-Pe)),m=Math.min(o,l+Pe),v=l,b=o-m;return(0,q.jsxs)(h,{flexDirection:"column",marginBottom:0,children:[v>0&&(0,q.jsx)(h,{children:(0,q.jsx)(f,{color:u.dim,children:` \u22EF ${v} above \u2014 ${Qe(n.slice(0,l))}`})}),n.slice(l,m).map((d,S)=>{let U=l+S,F=d.selectable!==!1,E=U===t&&F,R=S===0||n[U-1].kind!==d.kind;return(0,q.jsxs)(Ze.default.Fragment,{children:[R&&(0,q.jsx)(h,{children:(0,q.jsx)(f,{color:u.dim,children:et[d.kind]})}),(0,q.jsxs)(h,{children:[(0,q.jsx)(f,{color:E?e:u.dim,children:E?"\u276F ":" "}),(0,q.jsxs)(f,{color:E?e:F?void 0:u.dim,bold:E,children:[d.label,d.reason?` \u2014 ${d.reason}`:""]})]})]},`${d.kind}:${d.value}:${U}`)}),b>0&&(0,q.jsx)(h,{children:(0,q.jsx)(f,{color:u.dim,children:` \u22EF ${b} more \u2014 ${Qe(n.slice(m))}`})})]})}var Be=$(we(),1);var gt=27,pt=127,xt=11;function bt(n){return n>=64&&n<=126}function Tt(n,t){n===xt&&t({killToEnd:!0,ctrl:!0,raw:String.fromCharCode(n)})}function vt(n,t){n===pt&&t({backspace:!0,meta:!0,raw:"\x1B\x7F"})}function wt(n,t){let e=n.map(s=>String.fromCharCode(s)).join(""),o=/^\[1;([0-9]+)([A-D])$/.exec(e);if(o){let s=parseInt(o[1],10),l=o[2],m={raw:"\x1B"+e};if(s===2)m.shift=!0;else if(s===3)m.meta=!0;else if(s===5)m.ctrl=!0;else return;l==="A"?m.arrowUp=!0:l==="B"?m.arrowDown=!0:l==="C"?m.arrowRight=!0:l==="D"&&(m.arrowLeft=!0),t(m);return}if(e==="[H"||e==="[1~"||e==="[7~"){t({home:!0,raw:"\x1B"+e});return}if(e==="[F"||e==="[4~"||e==="[8~"){t({end:!0,raw:"\x1B"+e});return}if(e==="[3;5~"){t({delete:!0,ctrl:!0,raw:"\x1B"+e});return}if(e==="[3;3~"){t({delete:!0,meta:!0,raw:"\x1B"+e});return}}function St(n,t){n===72?t({home:!0,raw:"\x1BO"+String.fromCharCode(n)}):n===70&&t({end:!0,raw:"\x1BO"+String.fromCharCode(n)})}function Et(){let n="IDLE",t=[];function e(){n="IDLE",t=[]}return{feed(o,s){for(let l of o)n==="IDLE"?l===gt?(n="ESC",t=[]):Tt(l,s):n==="ESC"?l===91?(n="CSI",t=[]):l===79?(n="SS3",t=[]):(vt(l,s),e()):n==="CSI"?(t.push(l),bt(l)&&(wt([91,...t],s),e())):n==="SS3"&&(St(l,s),e())},flushIdle(o){n==="ESC"&&t.length===0&&o({raw:"\x1B"}),e()}}}function nt(n,t={}){let e=(0,Be.useRef)(n);e.current=n;let{stdin:o}=Fe();(0,Be.useEffect)(()=>{if(t.isActive===!1||!o)return;let s=Et(),l=null,m=v=>{l&&(clearTimeout(l),l=null);let b=Buffer.isBuffer(v)?v:Buffer.from(v,"binary");s.feed(b,d=>e.current(d)),l=setTimeout(()=>{s.flushIdle(d=>e.current(d)),l=null},50)};return o.on("data",m),()=>{o.removeListener("data",m),l&&clearTimeout(l)}},[t.isActive,o])}var w=$(re(),1);function yt(n,t){let e=t-1;for(;e>=0&&n[e]!=="@"&&n[e]!==" "&&n[e]!==`
4
4
  `;)e--;return e<0||n[e]!=="@"||e>0&&n[e-1]!==" "&&n[e-1]!==`
5
5
  `?null:{at:e,query:n.slice(e+1,t).join("")}}function rt(n,t,e){for(let o=t+e;o>=0&&o<n.length;o+=e)if(n[o]?.selectable!==!1)return o;return t}function At(n){let t=n.findIndex(e=>e.selectable!==!1);return t===-1?0:t}var Oe=10;function Rt(n){return n.replace(/\x1b?\[200~/g,"").replace(/\x1b?\[201~/g,"").replace(/\r\n/g,`