@testmuai/kane-cli 0.8.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/bin/kane-cli.cjs +1 -1
  2. package/bin/resolve-runtime.cjs +8 -0
  3. package/dist/ChatSurface-FJSO3IKR.js +8 -0
  4. package/dist/{ChromeProfilePicker-AUU7JF6F.js → ChromeProfilePicker-NTZ2RN3L.js} +1 -1
  5. package/dist/{CliFeedbackPrompt-4W74Y3UF.js → CliFeedbackPrompt-BCHUH24C.js} +1 -1
  6. package/dist/{CliUploadProgress-6HL7WTEX.js → CliUploadProgress-QVAJJRUW.js} +1 -1
  7. package/dist/{ConfigView-6BSCZP5Y.js → ConfigView-LAKAQN7O.js} +1 -1
  8. package/dist/EvidenceViewOffer-POKUWAPS.js +2 -0
  9. package/dist/FolderPicker-GR6FZMUJ.js +2 -0
  10. package/dist/{HelpView-TU7ED43J.js → HelpView-JFFVHQAW.js} +1 -1
  11. package/dist/{InfoBox-JLTMKVDE.js → InfoBox-46C7AHDE.js} +1 -1
  12. package/dist/{LinksBox-LREUUJDV.js → LinksBox-KFJXZDUJ.js} +1 -1
  13. package/dist/{ProfilesView-W3GX2N2E.js → ProfilesView-FV3KFVBX.js} +1 -1
  14. package/dist/{ProjectPicker-SYQUJK2J.js → ProjectPicker-MCH35VEF.js} +1 -1
  15. package/dist/{SaveSessionPrompt-MR5NJMRP.js → SaveSessionPrompt-RXHP3YW6.js} +1 -1
  16. package/dist/SingleShotApp-BK5QNXGG.js +2 -0
  17. package/dist/{SummaryBox-UAYSVFB7.js → SummaryBox-33K2MMUW.js} +1 -1
  18. package/dist/TestMdRunView-AT26LOSG.js +2 -0
  19. package/dist/{WhoamiView-2YU76ASQ.js → WhoamiView-HUPBB5AQ.js} +1 -1
  20. package/dist/app-client-ZCCNE3RV.js +2 -0
  21. package/dist/{app-download-AEEFQ63M.js → app-download-3O7NJNGG.js} +1 -1
  22. package/dist/{auth-HET3TBRI.js → auth-OMWFVDL2.js} +1 -1
  23. package/dist/{bind-STKXOUYI.js → bind-NXXKFJMA.js} +2 -2
  24. package/dist/bootstrap-MMRPAHWE.js +2 -0
  25. package/dist/bridge-UH32UGR5.js +2 -0
  26. package/dist/{changelog-7OWRHFHZ.js → changelog-VZ5HFHYM.js} +1 -1
  27. package/dist/{chat-controller-T2FAI55V.js → chat-controller-R4THYYPU.js} +1 -1
  28. package/dist/{chunk-HMYMSRA4.js → chunk-2ERQYYSJ.js} +1 -1
  29. package/dist/{chunk-DCY6R5DP.js → chunk-2N4SZOWN.js} +1 -1
  30. package/dist/{chunk-FMRSMN34.js → chunk-2ZDXNTZT.js} +1 -1
  31. package/dist/{chunk-OTTGS2TE.js → chunk-37ZWKLEN.js} +1 -1
  32. package/dist/{chunk-UV462FZR.js → chunk-3MFTTLOF.js} +1 -1
  33. package/dist/{chunk-DO5HAO3H.js → chunk-3S5DDQLP.js} +1 -1
  34. package/dist/{chunk-BRHNRCEZ.js → chunk-4FQI643D.js} +1 -1
  35. package/dist/chunk-4G4RWARU.js +2 -0
  36. package/dist/{chunk-GZPK6FRP.js → chunk-5BVOF4UW.js} +1 -1
  37. package/dist/{chunk-C7HSWZP6.js → chunk-5CKQTZMG.js} +1 -1
  38. package/dist/{chunk-ZVHCQMJ6.js → chunk-5NQ3TI4S.js} +2 -2
  39. package/dist/{chunk-6O3DDOP2.js → chunk-5OVEBP4D.js} +1 -1
  40. package/dist/{chunk-FQLIW3LM.js → chunk-6G5YKTVN.js} +1 -1
  41. package/dist/chunk-6J5T5FEY.js +2 -0
  42. package/dist/{chunk-QRZRSAZH.js → chunk-7YZMUTJA.js} +1 -1
  43. package/dist/chunk-A2SQD2AY.js +4 -0
  44. package/dist/chunk-A5FFLJVL.js +26 -0
  45. package/dist/{chunk-RFR4ZKIC.js → chunk-AF572MQG.js} +2 -2
  46. package/dist/{chunk-HCKH44I2.js → chunk-APETOVZK.js} +1 -1
  47. package/dist/{chunk-AW2XUHH4.js → chunk-AVH3BEEU.js} +1 -1
  48. package/dist/chunk-AXTPNZPX.js +2 -0
  49. package/dist/{chunk-2WVKOZ6W.js → chunk-BPMSNGXQ.js} +1 -1
  50. package/dist/{chunk-EDSZJZFG.js → chunk-CDB3SYZG.js} +1 -1
  51. package/dist/{chunk-T5Y6MOLM.js → chunk-CJP7RX3E.js} +1 -1
  52. package/dist/{chunk-G7VQCS4J.js → chunk-CVCVBQP6.js} +1 -1
  53. package/dist/{chunk-YFYCCTSL.js → chunk-D5VYMHSO.js} +1 -1
  54. package/dist/chunk-D6FYCAIA.js +2 -0
  55. package/dist/{chunk-ZIUAOEUC.js → chunk-DJR3M7XO.js} +1 -1
  56. package/dist/{chunk-65ZTD5SJ.js → chunk-DN42IM2Z.js} +2 -2
  57. package/dist/{chunk-TKGUT425.js → chunk-DOG7S7R6.js} +1 -1
  58. package/dist/chunk-DSXSU5MH.js +10 -0
  59. package/dist/{chunk-QSDH5P7C.js → chunk-DVYO4CR2.js} +1 -1
  60. package/dist/chunk-DXI5TXNL.js +19 -0
  61. package/dist/{chunk-JJHG3BWO.js → chunk-EBJD2V4Z.js} +1 -1
  62. package/dist/chunk-FPAJURPL.js +2 -0
  63. package/dist/{chunk-3LJWYRAA.js → chunk-GIQURCTO.js} +1 -1
  64. package/dist/{chunk-2BGUUWNF.js → chunk-GR35ZFM2.js} +2 -2
  65. package/dist/chunk-HJ6AXOCR.js +2 -0
  66. package/dist/{chunk-6XX4LEVJ.js → chunk-IEOHAHZO.js} +1 -1
  67. package/dist/{chunk-QW6EZC53.js → chunk-IFIXY3YG.js} +1 -1
  68. package/dist/{chunk-XO5ZH3ZR.js → chunk-IHAHCFFG.js} +1 -1
  69. package/dist/chunk-ITTZYA2G.js +4 -0
  70. package/dist/chunk-IVYXXZEE.js +6 -0
  71. package/dist/chunk-IWWQTXGK.js +11 -0
  72. package/dist/{chunk-GCBKDX2J.js → chunk-JANVTG62.js} +1 -1
  73. package/dist/{chunk-IOFZSQAA.js → chunk-KGSVOTLG.js} +1 -1
  74. package/dist/{chunk-L7MXYCD7.js → chunk-KOMKHFC4.js} +1 -1
  75. package/dist/{chunk-EWCAFKLX.js → chunk-KZVEFBH5.js} +1 -1
  76. package/dist/{chunk-FEJXWJ3L.js → chunk-LCU2P3CH.js} +1 -1
  77. package/dist/{chunk-RC52N7PC.js → chunk-LNQCZ5DS.js} +1 -1
  78. package/dist/{chunk-IP2O264K.js → chunk-LP3BSP74.js} +1 -1
  79. package/dist/chunk-LQQXPY5B.js +4 -0
  80. package/dist/{chunk-3POR47RC.js → chunk-LSZVSYAP.js} +2 -2
  81. package/dist/chunk-MMBBQ4OZ.js +2 -0
  82. package/dist/chunk-NNCMMV6P.js +349 -0
  83. package/dist/{chunk-YJELGSKJ.js → chunk-NVGM5ISX.js} +1 -1
  84. package/dist/{chunk-GKYPNSQP.js → chunk-NWJOPZ7P.js} +2 -2
  85. package/dist/{chunk-ELM6MXGJ.js → chunk-NXXJ56QA.js} +1 -1
  86. package/dist/{chunk-NX7TM662.js → chunk-QJTXNQV5.js} +1 -1
  87. package/dist/chunk-RKXHVP2Z.js +2 -0
  88. package/dist/chunk-RUCSRS4C.js +5 -0
  89. package/dist/{chunk-TFPPEOAK.js → chunk-SA2LQSYP.js} +1 -1
  90. package/dist/chunk-SPQPOUUR.js +11 -0
  91. package/dist/chunk-SQDKYSWT.js +12 -0
  92. package/dist/chunk-TAOHYWEO.js +2 -0
  93. package/dist/{chunk-UXDL4XDL.js → chunk-TRVB7RSW.js} +1 -1
  94. package/dist/{chunk-SDPRO2LE.js → chunk-TUTDSX7T.js} +1 -1
  95. package/dist/{chunk-766WGMBU.js → chunk-UBTNWAKK.js} +1 -1
  96. package/dist/chunk-UJZZDPDY.js +2 -0
  97. package/dist/chunk-VK3NU742.js +21 -0
  98. package/dist/{chunk-DZGCXKKI.js → chunk-WCF2Z4SE.js} +1 -1
  99. package/dist/{chunk-KU6IXFGZ.js → chunk-WMMJXI5O.js} +1 -1
  100. package/dist/chunk-X2FM67OM.js +4 -0
  101. package/dist/chunk-XMYCRE5K.js +4 -0
  102. package/dist/chunk-XO45NGSN.js +2 -0
  103. package/dist/chunk-YJNGBZ42.js +4 -0
  104. package/dist/{chunk-7JWKHKFU.js → chunk-ZH64GOBG.js} +1 -1
  105. package/dist/{chunk-UDIQOJEL.js → chunk-ZNNRCUHH.js} +1 -1
  106. package/dist/{chunk-KFSUPQAG.js → chunk-ZUYPPPC5.js} +43 -43
  107. package/dist/{config-RS47F5SC.js → config-OTUKOTHM.js} +1 -1
  108. package/dist/{credentials-OH6AVI6N.js → credentials-A3RU25MJ.js} +1 -1
  109. package/dist/deps-bundle-RIBEQC2R.js +2 -0
  110. package/dist/{deps-resolve-XC5S53DG.js → deps-resolve-7SWSUDRX.js} +1 -1
  111. package/dist/dispatch-RHSWJJLC.js +2 -0
  112. package/dist/doctor-XP7YDE3J.js +2 -0
  113. package/dist/evidence-K7R7OG2K.js +2 -0
  114. package/dist/evolve-cmd-FFF3F3HO.js +2 -0
  115. package/dist/extract-bind-VIPNGK2H.js +10 -0
  116. package/dist/{extract-cmd-UZMEZMGP.js → extract-cmd-5J47Q4XU.js} +1 -1
  117. package/dist/gaps-cmd-WPCJPLGB.js +3 -0
  118. package/dist/{generate-headless-D3SVQ2AI.js → generate-headless-AJI2OVRG.js} +2 -2
  119. package/dist/index.js +61 -60
  120. package/dist/{ingest-EX72IEQT.js → ingest-4447MYLF.js} +1 -1
  121. package/dist/ingest-cmd-2LK7DWDW.js +2 -0
  122. package/dist/interactive-bind-PI3HY623.js +25 -0
  123. package/dist/{list-commands-MRXL5HGS.js → list-commands-7Y5XV5FK.js} +1 -1
  124. package/dist/login-flow-Z45G34DM.js +2 -0
  125. package/dist/mobile-prompts-O5ALU3QU.js +2 -0
  126. package/dist/{persist-recorded-session-TLDQ5HKP.js → persist-recorded-session-TKSU4HOA.js} +1 -1
  127. package/dist/{phase-seed-VFHIH6FL.js → phase-seed-DIRETNU6.js} +1 -1
  128. package/dist/{pipeline-UOM4LNAI.js → pipeline-HZUV7IMT.js} +1 -1
  129. package/dist/prepare-target-DBYKQ7HW.js +2 -0
  130. package/dist/reconcile-cmd-VHEW2DY5.js +2 -0
  131. package/dist/reconcile-deps-UJ6KVUIS.js +4 -0
  132. package/dist/reconcile-engine-NUQJSIFX.js +2 -0
  133. package/dist/{recording-banner-4M7XHVGI.js → recording-banner-GO2PP53Y.js} +1 -1
  134. package/dist/registry-KYPVINS2.js +2 -0
  135. package/dist/{require-project-folder-4UPQNEBJ.js → require-project-folder-NUQMH224.js} +1 -1
  136. package/dist/resolve-run-intent-H3HX5KUC.js +7 -0
  137. package/dist/{resolver-UBOZLFFE.js → resolver-HHLYRR5W.js} +1 -1
  138. package/dist/run-67ONKMGR.js +2 -0
  139. package/dist/{run-URPGHOQM.js → run-OPLOL3PZ.js} +1 -1
  140. package/dist/{run-test-md-76ZPKXO6.js → run-test-md-3BA56ZYF.js} +2 -2
  141. package/dist/session-items-2ATN7VXG.js +2 -0
  142. package/dist/{skill-installer-CIS6GAYF.js → skill-installer-O7JYVZXD.js} +1 -1
  143. package/dist/{spawner-J67QR4QP.js → spawner-OZ4OE44T.js} +1 -1
  144. package/dist/tcg-generate-EG2MXRJ7.js +2 -0
  145. package/dist/{testmd-actions-77ELR5UU.js → testmd-actions-YJ7O43Z6.js} +1 -1
  146. package/dist/{tms-client-VD3B3SMU.js → tms-client-V3TR4QW3.js} +1 -1
  147. package/dist/token-refresh-K7CANKFQ.js +2 -0
  148. package/dist/{validate-basic-2GVSQ2R5.js → validate-basic-HWYK3CU6.js} +1 -1
  149. package/dist/{verdicts-TRSTJLCL.js → verdicts-KFPMRADV.js} +1 -1
  150. package/dist/{version-check-O6PYTI4T.js → version-check-3ECNG5V2.js} +1 -1
  151. package/dist/walk-session-MZCMXVZB.js +2 -0
  152. package/dist/with-telemetry-Q6V6THIF.js +2 -0
  153. package/package.json +12 -12
  154. package/dist/ChatSurface-U37VZDCW.js +0 -8
  155. package/dist/EvidenceViewOffer-62XHEEGW.js +0 -2
  156. package/dist/FolderPicker-S7U2EN2M.js +0 -2
  157. package/dist/SingleShotApp-XOKVOM7C.js +0 -2
  158. package/dist/TestMdRunView-7UVSDAF4.js +0 -2
  159. package/dist/app-client-OEXESV4U.js +0 -2
  160. package/dist/bootstrap-44YKVWWE.js +0 -2
  161. package/dist/bridge-5Z3BIB77.js +0 -2
  162. package/dist/chunk-27U4PLPX.js +0 -2
  163. package/dist/chunk-2KDGIZED.js +0 -4
  164. package/dist/chunk-3PECJD6S.js +0 -11
  165. package/dist/chunk-7BZSCUPP.js +0 -10
  166. package/dist/chunk-7Q6M6P4X.js +0 -26
  167. package/dist/chunk-CTW2VQKS.js +0 -6
  168. package/dist/chunk-FNH55WSR.js +0 -19
  169. package/dist/chunk-GPG3FIN3.js +0 -21
  170. package/dist/chunk-HEAIJCGZ.js +0 -2
  171. package/dist/chunk-KCCSWEGA.js +0 -4
  172. package/dist/chunk-MA34UWKX.js +0 -4
  173. package/dist/chunk-MBF3FP5P.js +0 -5
  174. package/dist/chunk-MXHHMIO2.js +0 -349
  175. package/dist/chunk-OMQCD3KR.js +0 -2
  176. package/dist/chunk-QGKPLOUI.js +0 -2
  177. package/dist/chunk-RLRNLIRS.js +0 -2
  178. package/dist/chunk-TYLYFERW.js +0 -10
  179. package/dist/chunk-V2R3LCA3.js +0 -12
  180. package/dist/chunk-VGFTNLQQ.js +0 -2
  181. package/dist/chunk-W2JFDDIB.js +0 -2
  182. package/dist/chunk-W4B5LOEX.js +0 -4
  183. package/dist/chunk-YRFMPIU2.js +0 -4
  184. package/dist/dispatch-SE5GY3Z2.js +0 -2
  185. package/dist/doctor-FSECFZUU.js +0 -2
  186. package/dist/evidence-OYPHZUKI.js +0 -2
  187. package/dist/evolve-cmd-BCPNXAMV.js +0 -2
  188. package/dist/extract-bind-LLEASZAK.js +0 -10
  189. package/dist/gaps-cmd-IVXFPFAQ.js +0 -3
  190. package/dist/ingest-cmd-EAE7N5RC.js +0 -2
  191. package/dist/interactive-bind-ORMN2REX.js +0 -25
  192. package/dist/login-flow-QJQM3RHT.js +0 -2
  193. package/dist/mobile-prompts-TOX35ER6.js +0 -2
  194. package/dist/prepare-target-QYWIJIVQ.js +0 -2
  195. package/dist/reconcile-cmd-3H34KVVD.js +0 -2
  196. package/dist/reconcile-deps-XIH75ZLY.js +0 -4
  197. package/dist/reconcile-engine-UKWPG2LV.js +0 -2
  198. package/dist/registry-PYOTKZYZ.js +0 -2
  199. package/dist/resolve-run-intent-X72V3KJA.js +0 -7
  200. package/dist/run-2COODVX2.js +0 -2
  201. package/dist/tcg-generate-BDTRKY2A.js +0 -2
  202. package/dist/token-refresh-4BPAPXKK.js +0 -2
  203. package/dist/walk-session-CHJXHZMO.js +0 -2
  204. package/dist/with-telemetry-CQCWLVOC.js +0 -2
  205. /package/dist/{lifecycle-cmd-O2324GN6.js → lifecycle-cmd-HO5VL7AM.js} +0 -0
@@ -1,8 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as pn,b as ue,c as xn,d as Tt,f as Ye,g as Ze,h as kn}from"./chunk-W2JFDDIB.js";import{a as Je}from"./chunk-KCCSWEGA.js";import{a as hn}from"./chunk-CLGC7VEO.js";import{a as fn,b as gn}from"./chunk-VGFTNLQQ.js";import"./chunk-L2TV4G56.js";import"./chunk-6KPPGMO2.js";import{a as un,b as dn,c as mn}from"./chunk-3LJWYRAA.js";import"./chunk-NVGBE2DR.js";import{a as ln}from"./chunk-5Y2G4NC7.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import{a as Ge}from"./chunk-YCCUBQY4.js";import{a as an}from"./chunk-FEJXWJ3L.js";import{y as r}from"./chunk-27U4PLPX.js";import{b as cn}from"./chunk-DFS4RMVP.js";import{a as X}from"./chunk-HCBYKLMW.js";import{a as b,b as n,k as Ce}from"./chunk-C44QQJR4.js";import{a as wr}from"./chunk-6YGTRKDT.js";import{e as Q}from"./chunk-UR6MHSHU.js";var p=Q(wr(),1);var c=Q(X(),1),Tr=60,vr=100;function vt(t,i){let l=t.options.length,u=l,h=t.multi_select?u++:null,m=t.allow_free_text?u++:null,d=i?u++:null;return{optionCount:l,doneIdx:h,freeIdx:m,batchIdx:d,maxSel:u-1}}var $r="\xA0",Cr={high:{text:`\u203C${$r}high`,color:r.red},med:{text:"med",color:"yellow"},low:{text:"low",color:r.dim}};function Rr(t){let i=(t.header??t.text.split(/\s+/).slice(0,3).join(" ")).trim();return i.length>16?`${i.slice(0,15)}\u2026`:i}function Sr(t,i,l){let u=g=>t[g].length+6,h=u(i),m=i,d=i;for(;;){let g=d+1<t.length?u(d+1):1/0,k=m-1>=0?u(m-1):1/0;if(g===1/0&&k===1/0)break;if(g<=k){if(h+g>l)break;h+=g,d+=1}else{if(h+k>l)break;h+=k,m-=1}}return{lo:m,hi:d}}function bn({batch:t,qView:i,sel:l=0,focused:u=!1,freeText:h=null,optionText:m=null,attach:d=null,canAttach:g=!1,multiSelFor:k}){let{stdout:L}=Ce(),$=L?.columns??80,w=$<Tr,A=Math.min($-1,vr),y=Math.max(0,Math.min(t.questions.length-1,i??(t.cursor<0?0:t.cursor))),x=t.questions[y],S=t.resolution[y],P=t.resolution.filter(U=>!U).length,B=t.questions.length-P,O=Je(t),D=vt(x,O!==""),W=k?k(y):[],K=Cr[x.risk],M=U=>u&&l===U?(0,c.jsx)(n,{color:r.assuranceAccent,children:"\u276F"}):" ",Ie=`? the agent needs ${P===1?"one answer":`${P} answers`}`,z=t.questions.length>1?` \xB7 ${y+1} of ${t.questions.length} \xB7 ${B} answered`:"",N=(0,c.jsxs)(b,{flexDirection:"column",children:[(0,c.jsx)(b,{paddingLeft:2,children:(0,c.jsxs)(n,{bold:!0,children:[x.text,K?(0,c.jsx)(n,{color:K.color,bold:!1,children:` ${K.text}`}):null]})}),(0,c.jsx)(b,{paddingLeft:2,children:(0,c.jsx)(n,{color:r.dim,children:x.rationale})}),(0,c.jsx)(n,{children:" "}),x.options.map((U,q)=>{let re=u&&l===q;return m&&m.optionIndex===q?(0,c.jsx)(b,{flexDirection:"column",children:(0,c.jsxs)(b,{children:[(0,c.jsxs)(n,{children:[(0,c.jsx)(n,{color:r.assuranceAccent,children:"\u276F"})," ",(0,c.jsx)(n,{color:r.assuranceAccent,children:`${q+1}. ${U.label}`}),(0,c.jsx)(n,{color:r.dim,children:" \u270E "})]}),(0,c.jsx)(Ge,{value:m.value,onChange:m.onChange,onSubmit:m.onSubmit,onCancel:m.onCancel,placeholder:U.detail||"type your answer"})]})},`o-${q}`):(0,c.jsxs)(b,{flexDirection:"column",children:[(0,c.jsxs)(n,{children:[M(q)," ",x.multi_select?(0,c.jsx)(n,{color:W.includes(q)?r.green:r.dim,children:W.includes(q)?"[x] ":"[ ] "}):null,(0,c.jsx)(n,{color:re?r.assuranceAccent:void 0,children:`${q+1}. ${U.label}`}),q===x.recommended_index?(0,c.jsx)(n,{color:r.dim,children:" (recommended)"}):null,S?.selected_index===q?(0,c.jsx)(n,{color:r.dim,children:" (current)"}):null]}),U.detail?(0,c.jsx)(b,{paddingLeft:5,children:(0,c.jsx)(n,{color:r.dim,children:U.detail})}):null]},`o-${q}`)}),x.multi_select&&D.doneIdx!=null?(0,c.jsxs)(n,{children:[M(D.doneIdx)," ",(0,c.jsx)(n,{color:r.green,children:"\u2714"}),(0,c.jsx)(n,{color:u&&l===D.doneIdx?r.assuranceAccent:void 0,children:" done \u2014 confirm selection"})]}):null,x.allow_free_text?(0,c.jsx)(n,{children:" "}):null,x.allow_free_text?h?(0,c.jsxs)(b,{children:[(0,c.jsxs)(n,{children:[(0,c.jsx)(n,{color:r.assuranceAccent,children:"\u276F"})," ",(0,c.jsx)(n,{color:r.dim,children:"\u270E "})]}),(0,c.jsx)(Ge,{value:h.value,onChange:h.onChange,onSubmit:h.onSubmit,onCancel:h.onCancel,placeholder:"Tell me what to do"})]}):(0,c.jsxs)(n,{children:[D.freeIdx!=null?M(D.freeIdx):" "," ",(0,c.jsx)(n,{color:u&&D.freeIdx!=null&&l===D.freeIdx?r.assuranceAccent:r.dim,children:"\u270E Tell me what to do"})]}):null,d?(0,c.jsxs)(b,{flexDirection:"column",marginTop:1,children:[(0,c.jsxs)(b,{children:[(0,c.jsxs)(n,{children:[(0,c.jsx)(n,{color:r.assuranceAccent,children:"\u276F"})," ",(0,c.jsx)(n,{color:r.assuranceAccent,children:"@ attach a file or URL"}),(0,c.jsx)(n,{color:r.dim,children:" \u270E "})]}),(0,c.jsx)(Ge,{value:d.value,onChange:d.onChange,onSubmit:d.onSubmit,onCancel:d.onCancel,placeholder:"path or URL"})]}),(0,c.jsx)(b,{paddingLeft:2,children:(0,c.jsx)(n,{color:r.dim,children:"the questions are set aside \u2014 the agent reads the source and re-asks what's still open"})})]}):null]}),C=O!==""?(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(n,{children:" "}),(0,c.jsxs)(n,{children:[u&&D.batchIdx!=null&&l===D.batchIdx?(0,c.jsx)(n,{color:r.assuranceAccent,children:"\u276F"}):" "," ",(0,c.jsx)(n,{color:r.assuranceAccent,children:"\xBB"}),(0,c.jsx)(n,{bold:!0,color:u&&D.batchIdx!=null&&l===D.batchIdx?r.assuranceAccent:void 0,children:" Go with recommendations"}),P>=5?(0,c.jsx)(n,{color:r.dim,children:` \u2014 resolves all ${P} open`}):null,(0,c.jsx)(n,{color:r.dim,children:" (tab)"})]})]}):null;if(w)return(0,c.jsxs)(b,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,c.jsx)(n,{color:r.assuranceAccent,bold:!0,children:Ie}),t.questions.length>1?(0,c.jsx)(n,{color:r.dim,children:z.replace(/^ · /,"")}):null,(0,c.jsx)(n,{children:" "}),N,C,(0,c.jsx)(b,{paddingLeft:2,children:(0,c.jsx)(n,{color:r.muted,children:"\u2191\u2193 \u23CE \xB7 \u2190 \u2192 questions \xB7 esc back"})})]});let rt=`\u2500\u2500 ${Ie}${z} `,G=Math.max(2,A-rt.length),E=g?"\u2191\u2193 select \xB7 \u23CE confirm \xB7 \u2190 \u2192 questions \xB7 type = your words \xB7 @ attach a file or URL \xB7 esc back":"\u2191\u2193 select \xB7 \u23CE confirm \xB7 \u2190 \u2192 questions \xB7 type = your words \xB7 esc back",De=`\u2500\u2500 ${E} `,it=Math.max(2,A-De.length),me=t.questions.map(U=>Rr(U)),J=t.questions.length>1?Sr(me,y,A-8):null;return(0,c.jsxs)(b,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,c.jsxs)(n,{color:r.assuranceAccent,children:["\u2500\u2500 ",(0,c.jsx)(n,{bold:!0,children:Ie}),z?(0,c.jsx)(n,{color:r.dim,children:z}):null,` ${"\u2500".repeat(G)}`]}),J?(0,c.jsx)(b,{marginTop:1,children:(0,c.jsxs)(n,{children:[J.lo>0?(0,c.jsx)(n,{color:r.dim,children:"\u25C0 "}):" ",t.questions.slice(J.lo,J.hi+1).map((U,q)=>{let re=J.lo+q,qe=q>0?" ":"";return re===y?(0,c.jsxs)(n,{children:[qe,(0,c.jsx)(n,{backgroundColor:r.assuranceAccent,color:"#0d1117",bold:!0,children:` ${me[re]} `})]},U.id):(0,c.jsxs)(n,{children:[qe,t.resolution[re]?(0,c.jsxs)(n,{children:[(0,c.jsx)(n,{color:r.green,children:"\u2713 "}),(0,c.jsx)(n,{color:r.dim,children:me[re]})]}):(0,c.jsx)(n,{color:r.dim,children:`\u25CB ${me[re]}`})]},U.id)}),J.hi<t.questions.length-1?(0,c.jsx)(n,{color:r.dim,children:" \u25B6"}):null]})}):null,(0,c.jsx)(n,{children:" "}),N,C,(0,c.jsx)(n,{children:" "}),(0,c.jsxs)(n,{color:r.assuranceAccent,children:["\u2500\u2500 ",(0,c.jsx)(n,{color:r.muted,children:E}),` ${"\u2500".repeat(it)}`]})]})}var _=Q(X(),1),yn={high:0,med:1,low:2},Ir={high:r.red,med:"yellow",low:r.dim};function Dr(t){return t.map((i,l)=>({r:i,i:l})).sort((i,l)=>(yn[i.r.risk??"zz"]??3)-(yn[l.r.risk??"zz"]??3)||i.i-l.i).map(({r:i})=>i)}var de=(t,i)=>t.length<=i?t:i<=1?"\u2026":`${t.slice(0,i-1)}\u2026`,et=(t,i)=>t+" ".repeat(Math.max(0,i-t.length));function wn({rows:t,width:i=120,badgeHeader:l="risk"}){if(t.length===0)return null;let u=Dr(t),h=B=>B.staged||!B.id?"(staged)":hn(B.id),m=Math.max(2,...u.map(B=>h(B).length)),d=Math.max(l.length,...u.map(B=>(B.badge??"").length)),g=i>=96&&u.some(B=>B.summary),L=i-(g?13:10)-m-d,$=Math.max(...u.map(B=>Math.max(B.title.length,(B.marker??"").length)),5),w=Math.max(5,g?Math.min($,Math.max(16,Math.floor(L*.5))):Math.min($,L)),A=g?Math.max(7,L-w):0,y=(B,O,D,W)=>B+W.map(K=>`\u2500${"\u2500".repeat(K.length)}\u2500`).join(O)+D,x=(B,O,D,W)=>[et(de(B,m),m),et(de(O,w),w),et(de(D,d),d),...g?[et(de(W,A),A)]:[]],S=x("id","title",l,"summary"),P=[];P.push((0,_.jsx)(n,{color:r.dim,children:y("\u250C","\u252C","\u2510",S)},"t")),P.push((0,_.jsxs)(n,{children:[S.map((B,O)=>(0,_.jsxs)(n,{children:[(0,_.jsx)(n,{color:r.dim,children:O===0?"\u2502 ":" \u2502 "}),(0,_.jsx)(n,{bold:!0,children:B})]},O)),(0,_.jsx)(n,{color:r.dim,children:" \u2502"})]},"h")),P.push((0,_.jsx)(n,{color:r.dim,children:y("\u251C","\u253C","\u2524",S)},"m"));for(let[B,O]of u.entries()){let D=x(h(O),de(O.title,w),de(O.badge??"",d),de(O.summary??"",A)),W=O.badgeColor??Ir[O.badge??""]??r.dim;if(P.push((0,_.jsxs)(n,{children:[(0,_.jsx)(n,{color:r.dim,children:"\u2502 "}),(0,_.jsx)(n,{color:r.assuranceAccent,children:D[0]}),(0,_.jsx)(n,{color:r.dim,children:" \u2502 "}),D[1],(0,_.jsx)(n,{color:r.dim,children:" \u2502 "}),(0,_.jsx)(n,{color:W,children:D[2]}),g?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsx)(n,{color:r.dim,children:" \u2502 "}),D[3]]}):null,(0,_.jsx)(n,{color:r.dim,children:" \u2502"})]},`r-${B}`)),O.marker){let K=x("",de(O.marker,w),"","");P.push((0,_.jsx)(n,{color:r.dim,children:`\u2502 ${K.join(" \u2502 ")} \u2502`},`mk-${B}`))}}return P.push((0,_.jsx)(n,{color:r.dim,children:y("\u2514","\u2534","\u2518",S)},"b")),(0,_.jsx)(_.Fragment,{children:P})}var Ar={"use-case":"use-cases",ac:"ACs",scenario:"scenarios",test:"tests",gap:"gaps"},ce=t=>Ar[t]??`${t}s`,Tn=t=>t==="ac"?"AC":t==="use-case"?"use-case":t,$t=t=>t.kind??"use-case",vn=t=>`${$t(t)}:${t.temp_ref}`;function $n(t){let i=t,l=i.badge??t.risk??null,u=i.why??t.summary??t.description??null;return JSON.stringify([t.title,l,u,i.extra??null,t.depends_on_hint??null])}function Cn(t){return t.filter(i=>i.role==="agent"&&typeof i.turnIndex=="number"&&Array.isArray(i.items)&&i.items.length>0)}function he(t){let i=new Map,l=1;for(let m of Cn(t)){let d=new Set;for(let g of m.items){let k=vn(g);if(d.has(k))continue;d.add(k);let L=i.get(k);i.set(k,{num:L?.num??l++,ref:g.temp_ref,kind:$t(g),item:g,turnIndex:m.turnIndex,fingerprint:$n(g)})}}let u=[...i.values()].sort((m,d)=>m.num-d.num),h=[];for(let m of u){let d=h.find(g=>g.kind===m.kind);d?d.count++:h.push({kind:m.kind,label:ce(m.kind),count:1})}return{entries:u,byRef:i,counts:h}}function Rn(t,i){let u=Cn(t).find(x=>x.turnIndex===i);if(!u)return null;let h=t.filter(x=>x.role!=="agent"||typeof x.turnIndex!="number"||x.turnIndex<=i),m=he(h),d=he(t.filter(x=>x.role!=="agent"||typeof x.turnIndex!="number"||x.turnIndex<i)),g=[],k=new Map,L=new Map,$=new Map,w=new Set;for(let x of u.items){let S=vn(x);if(w.has(S))continue;w.add(S);let P=d.byRef.get(S),B=x.changed===!0,O=m.byRef.get(S).num,D=$t(x);if(P&&!B&&P.fingerprint===$n(x)){k.set(D,(k.get(D)??0)+1);continue}let W=!!P||B,K=W?$:L;K.set(D,(K.get(D)??0)+1),g.push({item:x,num:O,updated:W})}let A=[...k.entries()].map(([x,S])=>({label:ce(x),count:S})),y=[...[...L.entries()].map(([x,S])=>`${S} new ${S===1?Tn(x):ce(x)}`),...[...$.entries()].map(([x,S])=>`${S} updated ${S===1?Tn(x):ce(x)}`)].join(" \xB7 ");return{fresh:g,unchanged:A,headerStats:y}}function Ct(t,i){let l=t.entries.filter(m=>m.turnIndex===i);if(l.length===0)return t;let u=new Map(l.map(m=>[m.ref,m])),h=[];for(let m of l){let d=h.find(g=>g.kind===m.kind);d?d.count+=1:h.push({kind:m.kind,label:ce(m.kind),count:1})}return{entries:l,byRef:u,counts:h}}var v=Q(X(),1);function Mr(t){let i=t.form==="assumed"?" (assumed)":t.form==="deferred"?"":" (you)",l=t.note?` \u2014 ${t.note}`:"";return t.form==="deferred"?`\u21B3 deferred q${t.qNum} ${t.stub}${l}`:t.form==="changed"?`\u21B3 changed q${t.qNum} ${t.stub}: ${t.prev??"?"} \u2192 ${t.choice??"?"}${i}${l}`:`\u21B3 ${t.form} q${t.qNum} ${t.stub}: ${t.choice??"?"}${i}${l}`}var Br=Math.min(process.stdout?.columns??100,120)-2;function Sn({block:t,annotations:i}){switch(t.kind){case"banner":return(0,v.jsx)(b,{marginTop:1,children:(0,v.jsx)(n,{color:r.dim,children:` \u2500\u2500 ${t.text} \u2500\u2500`})});case"user":return(0,v.jsxs)(b,{marginTop:1,children:[(0,v.jsx)(n,{color:r.orange,children:"\u276F "}),(0,v.jsx)(n,{children:t.text})]});case"note":return(0,v.jsx)(n,{color:r.dim,children:` ${t.text}`});case"agent":return(0,v.jsx)(b,{marginTop:1,children:(0,v.jsx)(dn,{text:t.text,accent:r.assuranceAccent})});case"thinking":return(0,v.jsx)(b,{marginTop:1,children:(0,v.jsx)(n,{color:r.dim,children:` thought for ${(t.tookMs/1e3).toFixed(1)}s`})});case"tool":return(0,v.jsx)(n,{color:r.dim,children:` ${fn({name:t.name,status:t.status==="ok"?"done":t.status,detail:t.detail})}`});case"usage":return(0,v.jsx)(n,{color:r.dim,children:` \xB7 ${t.credits.toFixed(1)} credits \u2014 total ${t.total.toFixed(1)}`});case"turn":{let l=i??null,u=l?l.fresh:t.items.map(($,w)=>({item:$,num:w+1,updated:!1})),h={usecase:"risk","use-case":"risk",ac:"check",scenario:"kind",test:"check",gap:"severity",stylenote:"kind"},m=$=>$.kind??"use-case",d=new Map;for(let $ of u){let w=$.item,A=m($.item),y=w.risk==="high"||w.risk==="med"||w.risk==="low"?w.risk:void 0,x={id:w.logical_id??"",staged:!w.logical_id,title:w.title,badge:w.badge??w.risk??"",summary:w.why??w.summary??w.description??"",...y?{risk:y}:{},...$.updated?{marker:"\u21B3 changed"}:{}},S=d.get(A)??[];S.push(x),d.set(A,S)}let g=u.some($=>!!$.item.kind),k=(l?.unchanged??[]).reduce(($,w)=>$+w.count,0),L=l?.headerStats?` \u2014 ${l.headerStats}${k>0?` (${k} unchanged)`:""}`:"";return(0,v.jsxs)(b,{flexDirection:"column",marginLeft:2,children:[(0,v.jsxs)(n,{bold:!0,children:[g?"design":t.heading,L?(0,v.jsx)(n,{bold:!1,color:r.dim,children:L}):null]}),[...d.entries()].map(([$,w])=>(0,v.jsxs)(b,{flexDirection:"column",children:[d.size>1?(0,v.jsx)(n,{color:r.dim,children:`${ce($)} \xB7 ${w.length}`}):null,(0,v.jsx)(wn,{rows:w,width:Br,badgeHeader:h[$]??"info"})]},$)),l&&l.unchanged.length>0&&(0,v.jsx)(n,{color:r.dim,children:` \u22EE unchanged: ${l.unchanged.map($=>`${$.count} ${$.label}`).join(" \xB7 ")}`})]})}case"answer":return(0,v.jsx)(n,{color:r.dim,children:Mr(t.receipt)});case"continued":return(0,v.jsx)(n,{color:r.dim,children:"\u21B3 continued"});case"commit":return(0,v.jsxs)(b,{flexDirection:"column",children:[(0,v.jsx)(n,{color:t.ok?r.green:r.red,children:` ${t.ok?"\u2714":"\u2717"} ${t.line}`}),(t.warnings??[]).map((l,u)=>(0,v.jsx)(n,{color:r.dim,children:` \u26A0 ${l}`},`w-${u}`))]});case"error":return(0,v.jsxs)(an,{variant:"error",paddingX:1,children:[(0,v.jsx)(n,{color:r.red,children:t.title}),t.detail.map((l,u)=>(0,v.jsx)(n,{color:r.dim,children:l},`d-${u}`))]});case"interrupted":return(0,v.jsxs)(b,{flexDirection:"column",children:[(0,v.jsx)(n,{color:r.red,children:"interrupted \u2014 session not saved"}),t.detail?(0,v.jsx)(n,{color:r.dim,children:t.detail}):null]});case"pause":return(0,v.jsxs)(b,{flexDirection:"column",children:[(0,v.jsx)(n,{children:`paused: session ${t.sid} saved`}),t.expires_at?(0,v.jsx)(n,{color:r.dim,children:`expires: ${t.expires_at}`}):null,(0,v.jsx)(n,{children:`resume: ${t.resume}`}),t.messageForm?(0,v.jsx)(n,{children:`or say something on the way in: ${t.messageForm}`}):null]});case"summary":return(0,v.jsxs)(b,{flexDirection:"column",children:[(0,v.jsx)(n,{bold:!0,children:"session summary"}),t.lines.map((l,u)=>(0,v.jsx)(n,{children:` ${l}`},`s-${u}`))]})}}var Re=Q(X(),1);function In({item:t}){return(0,Re.jsxs)(b,{flexDirection:"column",marginLeft:2,children:[(t.cite??[]).map((i,l)=>(0,Re.jsx)(n,{dimColor:!0,children:`cite ${i.anchor??"conv"} \u2014 "${i.quote??""}"`},`cite-${l}`)),(t.depends_on_hint??[]).length>0&&(0,Re.jsx)(n,{dimColor:!0,children:`depends on: ${(t.depends_on_hint??[]).join(", ")}`}),Object.entries(t.extra??{}).map(([i,l])=>(0,Re.jsx)(n,{dimColor:!0,children:`${i}: ${l}`},`extra-${i}`))]})}var R=Q(X(),1),Rt=(t,i)=>Math.max(0,Math.min(i,t));function nt(t,i,l){switch(i.type){case"move":return t.level==="detail"?{...t,scroll:Math.max(0,(t.scroll??0)+i.delta)}:{...t,cursor:Rt(t.cursor+i.delta,Math.max(0,l-1))};case"enter":return t.level==="list"?{...t,level:"detail",scroll:0}:t;case"back":return t.level==="detail"?{...t,level:"list",scroll:0}:null}}var An={"use-case":"use-cases",ac:"acs",scenario:"scenarios",test:"tests",gap:"gaps"};function Mn(t,i){if(t.level==="detail")return{level:"detail",cursor:Rt(t.num-1,Math.max(0,i.entries.length-1))};if(t.section){let l=i.entries.findIndex(u=>An[u.kind]===t.section);if(l>=0)return{level:"list",cursor:l}}return{level:"list",cursor:0}}function Er(t){let i=[];for(let l of t.entries){let u=i.find(h=>h.kind===l.kind);u?u.entries.push(l):i.push({kind:l.kind,entries:[l]})}return i}var Dn=3;function Lr({items:t,cursor:i,verb:l,more:u}){let h=`view \xB7 ${l} so far \xB7 ${t.counts.map(d=>`${d.count} ${d.count===1?d.label.replace(/s$/,""):d.label}`).join(" \xB7 ")}`,m=t.entries[i];return(0,R.jsxs)(b,{flexDirection:"column",borderStyle:"round",borderColor:r.dim,paddingX:1,children:[(0,R.jsx)(n,{bold:!0,children:h}),Er(t).map(({kind:d,entries:g})=>{let k=m?.kind===d,L=k?g.findIndex(y=>y.ref===m.ref):-1,$=k?Rt(L-1,Math.max(0,g.length-Dn)):0,w=g.slice($,$+(k?Dn:1)),A=g.length-w.length;return(0,R.jsxs)(b,{flexDirection:"column",children:[(0,R.jsx)(n,{color:r.dim,children:`${An[d]??ce(d)} \xB7 ${g.length}`}),w.map(y=>{let x=k&&y.ref===m.ref,S=y.item.badge;return(0,R.jsxs)(n,{children:[(0,R.jsx)(n,{color:r.assuranceAccent,children:x?"\u203A ":" "}),(0,R.jsx)(n,{children:`${y.num} \xB7 ${y.item.title}`}),S?(0,R.jsx)(n,{color:r.dim,children:` \xB7 ${S}`}):null]},`${y.kind}:${y.ref}`)}),A>0&&(0,R.jsx)(n,{color:r.dim,children:` \u22EE ${A} more`})]},d)}),u?(0,R.jsxs)(n,{children:[(0,R.jsx)(n,{color:r.assuranceAccent,children:i===t.entries.length?"\u203A ":" "}),(0,R.jsx)(n,{color:r.dim,children:`\u22EF show all \u2014 ${u.hidden} more from earlier turns`})]}):null,(0,R.jsx)(n,{color:r.dim,children:"\u2191\u2193 move \xB7 \u21B5 detail \xB7 esc back"})]})}var tt=14;function _r({items:t,cursor:i,explain:l,grandTotal:u,dossier:h,scroll:m=0}){let d=t.entries[i];if(!d)return(0,R.jsx)(n,{color:r.dim,children:"nothing to show"});if(h){let k=Math.max(0,Math.min(m,Math.max(0,h.lines.length-tt))),L=h.lines.slice(k,k+tt);return(0,R.jsxs)(b,{flexDirection:"column",borderStyle:"round",borderColor:r.dim,paddingX:1,children:[(0,R.jsxs)(n,{bold:!0,children:[`view \xB7 ${h.id}`,h.id.toLowerCase()!==h.rawId?(0,R.jsx)(n,{bold:!1,color:r.dim,children:` \xB7 ${h.rawId}`}):null]}),(0,R.jsx)(n,{bold:!0,children:h.title}),k>0?(0,R.jsx)(n,{color:r.muted,children:`\u22EE ${k} above`}):null,L.map(($,w)=>(0,R.jsx)(n,{color:$.dim?r.dim:void 0,children:$.text},`dl-${w}`)),h.lines.length>k+tt?(0,R.jsx)(n,{color:r.muted,children:`\u22EE ${h.lines.length-k-tt} more`}):null,(0,R.jsx)(n,{color:r.dim,children:"\u2191\u2193 scroll \xB7 esc back"})]})}let g=d.item;return(0,R.jsxs)(b,{flexDirection:"column",borderStyle:"round",borderColor:r.dim,paddingX:1,children:[(0,R.jsx)(n,{bold:!0,children:`view \xB7 ${d.kind} ${d.num} of ${u??t.entries.length}`}),(0,R.jsx)(n,{children:d.item.title}),g.badge?(0,R.jsx)(n,{color:r.dim,children:`kind: ${g.badge}`}):null,g.why?(0,R.jsx)(n,{color:r.dim,children:g.why}):null,(0,R.jsx)(In,{item:d.item}),l?.map((k,L)=>(0,R.jsx)(n,{color:r.dim,children:k},`ex-${L}`)),(0,R.jsx)(n,{color:r.dim,children:"view-only \u2014 approvals happen in chat"}),(0,R.jsx)(n,{color:r.dim,children:"\u2191\u2193 prev/next \xB7 esc back to list"})]})}function Bn({items:t,state:i,verb:l,more:u,explain:h,grandTotal:m,dossier:d=null}){return i.level==="list"?(0,R.jsx)(Lr,{items:t,cursor:i.cursor,verb:l,more:u}):(0,R.jsx)(_r,{items:t,cursor:i.cursor,explain:h,grandTotal:m,dossier:d,scroll:i.scroll??0})}var Y=Q(X(),1),St=14;function Or(t){let i=[],l=null;for(let u of t)u.field!==l&&(l=u.field,i.push({kind:"field",field:l})),i.push({kind:"line",field:l,line:u});return i}function En({title:t,lines:i,offset:l=0}){let{stdout:u}=Ce(),h=u?.columns??80,m=Math.min(h-1,100),d=Or(i),g=Math.max(0,Math.min(l,Math.max(0,d.length-St))),k=d.slice(g,g+St),L=g,$=Math.max(0,d.length-g-St),w=`view \xB7 diff \xB7 ${t} \xB7 current \u2192 proposed`,A=y=>{let x=Math.max(0,m-y.length-1);return`${y} ${"\u2500".repeat(x)}`};return(0,Y.jsxs)(b,{flexDirection:"column",children:[(0,Y.jsx)(n,{color:r.dim,children:A(w)}),L>0?(0,Y.jsx)(b,{paddingLeft:2,children:(0,Y.jsx)(n,{color:r.dim,children:`\u22EE ${L} above`})}):null,k.map((y,x)=>y.kind==="field"?(0,Y.jsx)(b,{paddingLeft:2,children:(0,Y.jsx)(n,{color:r.dim,children:y.field==="criteria"?"criteria":y.field})},`r-${g+x}`):(0,Y.jsx)(b,{paddingLeft:4,children:(0,Y.jsx)(n,{color:y.line.op==="-"?"red":"green",children:`${y.line.op==="-"?"\u2212":"+"} ${y.line.text}`})},`r-${g+x}`)),$>0?(0,Y.jsx)(b,{paddingLeft:2,children:(0,Y.jsx)(n,{color:r.dim,children:`\u22EE ${$} more`})}):null,(0,Y.jsx)(n,{color:r.dim,children:`${"\u2500".repeat(Math.max(0,m-21))} \u2191\u2193 scroll \xB7 esc back`})]})}var Pr={"use-cases":"use-cases",usecases:"use-cases","use-case":"use-cases",acs:"acs",ac:"acs",scenarios:"scenarios",scenario:"scenarios",tests:"tests",test:"tests",gaps:"gaps",gap:"gaps"};function Ln(t){let i=(t??"").trim().toLowerCase();if(!i)return{level:"list"};if(/^\d+$/.test(i)){let u=parseInt(i,10);return u>=1?{level:"detail",num:u}:{error:"items are numbered from 1 \u2014 /view 1"}}let l=Pr[i];return l?{level:"list",section:l}:{error:"try /view, /view <number>, or /view acs|scenarios|tests"}}var I=Q(X(),1),qr=6,_n=12;function jr(t,i,l){let u=Math.max(20,i),h=[];for(let d of t.split(`
3
- `)){if(d.length<=u){h.push(d);continue}let g="";for(let k of d.split(" "))g&&g.length+1+k.length>u?(h.push(g),g=k):g=g?`${g} ${k}`:k;h.push(g)}let m=Math.max(0,h.length-l);return{body:h.slice(-l).join(`
4
- `),hidden:m}}var Se=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function On(t){let i={key:"redesign",label:"re-design from scratch",detail:"replaces the current design"},l={key:"keep",label:"keep the existing design",detail:"back to the list"};return t.designed==="stale"?[{...i,detail:"the use-case changed since it was designed"},l]:[l,i]}function Li({controller:t,verb:i="extract",onCtrlC:l,chain:u=null,inspect:h=null,reconcile:m=null,autoReview:d=!1,onReviewExit:g}){let[,k]=(0,p.useState)(0),[L,$]=(0,p.useState)(!1),[w,A]=(0,p.useState)(null),[y,x]=(0,p.useState)(null),S=(0,p.useRef)(null),[P,B]=(0,p.useState)(null),O=(0,p.useRef)(null),D=e=>{O.current=e,B(e)},W=e=>{S.current=e,x(e),e===null&&D(null)},K=(0,p.useRef)([]),[M,Ie]=(0,p.useState)(null),z=(0,p.useRef)(null),N=e=>{z.current=e,Ie(e)},[C,rt]=(0,p.useState)(null),G=(0,p.useRef)(null),E=e=>{G.current=e,rt(e)},[De,it]=(0,p.useState)(null),me=(0,p.useRef)(null),J=e=>{me.current=e,it(e)},U=(0,p.useRef)({approved:0,rejected:0,deferred:0}),q=(0,p.useRef)(!1),re=cn(),{stdout:qe}=Ce(),Pn=qe?.columns??80,It=(0,p.useRef)(0),st=(0,p.useRef)(0);(0,p.useEffect)(()=>{let e=()=>{let s=t.state.ledger;for(let a=It.current;a<s.length;a++){let f=s[a],T=f.kind==="turn"?Rn(t.state.turns,f.turnIndex):void 0;re.append((0,I.jsx)(Sn,{block:f,annotations:T},`lg-${a}`))}It.current=s.length};e();let o=t.subscribe(()=>{e();let s=t.state;S.current&&(s.pending||s.status==="pausing")&&(W(null),s.pending&&A("questions arrived \u2014 back to chat")),k(a=>a+1)});return k(s=>s+1),o},[t,re]);let{thinking:xe,status:fe,pending:F,confirm:je,ledger:oe,activeTurn:Dt,stream:qn,notice:Fe}=t.state,At=(qn?.text??"").trimEnd(),Mt=At.length>0,jn=L&&(xe.liveThinking.length>0||xe.thinkingLog.length>0),Fn=jr(xe.liveThinking||xe.thinkingLog.map(e=>e.text).join(`
5
- `),Pn-6,_n),Bt=Mt?At.split(`
6
- `).slice(-qr):[];Dt&&(st.current=Dt.turnIndex);let Wn=F?F.resolution.filter(e=>!e).length:0,Et;for(let e=oe.length-1;e>=0;e--){if(K.current.some(s=>s.end!=null&&e>=s.start&&e<s.end))continue;let o=oe[e];if(o.kind==="banner"&&!o.text.startsWith("kane")){Et=o.text;break}}let Ae=xe.activity[xe.activity.length-1],ot=Ae?Ae.status==="decision"?Ae.label:gn({name:Ae.name,status:Ae.status}):void 0,Lt=fe==="streaming"||fe==="working",[lt,Nn]=(0,p.useState)(0);ln(()=>Nn(e=>e+1),Lt||M?.kind==="running"||C?.st.kind==="running"?120:null);let Un=t.state.busySince?Math.floor((Date.now()-t.state.busySince)/1e3):0,Vn=Mt?"Writing\u2026":ot?`${ot.charAt(0).toUpperCase()}${ot.slice(1)}\u2026`:t.state.workingLabel??(i==="design"?"Designing\u2026":"Thinking\u2026"),Kn=t.state.turns.some(e=>e.role==="agent"),[Qn,Hn]=(0,p.useState)(0),[Xn,zn]=(0,p.useState)(!1),[_t,Gn]=(0,p.useState)(null),ke=(0,p.useRef)(0),Ot=(0,p.useRef)(!1),Pt=(0,p.useRef)(null),Me=e=>{ke.current=e,Hn(e)},qt=e=>{Ot.current=e,zn(e)},be=e=>{Pt.current=e,Gn(e)},[We,Jn]=(0,p.useState)(null),at=(0,p.useRef)(null),ye=e=>{at.current=e,Jn(e)},[jt,Yn]=(0,p.useState)(null),Ft=(0,p.useRef)(null),Be=e=>{Ft.current=e,Yn(e)},[ct,Zn]=(0,p.useState)(0),Z=(0,p.useRef)(0),Ee=e=>{Z.current=e,Zn(e)},Wt=F?F.questions[0]?.id??"b":null;(0,p.useEffect)(()=>{F&&Ee(F.cursor<0?0:F.cursor)},[Wt,F?.cursor]);let Ne=()=>{let e=te.current;if(!e)return;let o=e.questions.length;for(let s=1;s<=o;s++){let a=(Z.current+s)%o;if(!e.resolution[a]){Ee(a);return}}},Nt=F?F.questions[Math.max(0,Math.min(F.questions.length-1,ct))]:void 0,ie=(0,p.useRef)(Nt);ie.current=Nt;let te=(0,p.useRef)(F);te.current=F;let er=F?`${Wt}:${ct}`:null;(0,p.useEffect)(()=>{if(be(null),ye(null),Be(null),ie.current){qt(!0);let e=te.current?.resolution[Z.current]?.selected_index;Me(e??ie.current.recommended_index??0)}else qt(!1)},[er]);let Ue=e=>{let o=te.current;return vt(e,o?Je(o)!=="":!1)},tr={isFocused:()=>Ot.current&&ie.current!=null&&Pt.current==null&&at.current==null&&Ft.current==null||G.current!=null&&G.current.st.kind!=="running"&&me.current==null||z.current!=null&&z.current.kind!=="running"||H.current&&sn.current==null,onMove:e=>{let o=ie.current;if(o){Me(Math.max(0,Math.min(Ue(o).maxSel,ke.current+e)));return}let s=G.current;if(s){let f=s.items[s.i];if(s.st.kind==="card"&&f){let T=Ze(f.card)??Ye(f.card).length-1;E({...s,st:{kind:"card",sel:Math.max(0,Math.min(T,s.st.sel+e))}});return}if(s.st.kind==="view"&&f){E({...s,st:{kind:"view",offset:Math.max(0,s.st.offset+e)}});return}if(s.st.kind==="offer"||s.st.kind==="done"){let T=s.st.kind==="offer"?1:Xe.current.length-1;E({...s,st:{...s.st,sel:Math.max(0,Math.min(T,s.st.sel+e))}});return}if(s.st.kind==="running"&&!H.current)return}let a=z.current;if(a?.kind==="picker"){N({...a,sel:Math.max(0,Math.min(a.items.length-1,a.sel+e))});return}if(a?.kind==="ask"||a?.kind==="confirm"||a?.kind==="failed"){let f=(a.kind==="ask"?Qe.current.length:a.kind==="failed"?He.current.length:2)-1;N({...a,sel:Math.max(0,Math.min(f,a.sel+e))});return}a&&!H.current||H.current&&ve(Math.max(0,Math.min(Pe.current.length-1,wt.current+e)))},onSelect:()=>{let e=ie.current,o=te.current;if(!e||!o){let f=G.current;if(f&&f.st.kind!=="running"){let j=f.items[f.i];if(f.st.kind==="card"&&j){let V=f.st.sel;if(V===Ze(j.card)){J("");return}let pe=Ye(j.card)[V];if(!pe)return;if(pe.v==="view_diff"){E({...f,st:{kind:"view",offset:0}});return}let yr=pe.v==="approve"||pe.v==="archive"?"approve":pe.v==="skip"?"reject":"defer";ur(f,yr);return}if(f.st.kind==="view"){E({...f,st:{kind:"card",sel:0}});return}if(f.st.kind==="offer"){f.st.sel===0?en(f,f.st.offer):Te(f);return}if(f.st.kind==="done"){Xe.current[f.st.sel]?.key==="view"?ze(""):(E(null),g?.());return}return}if(f&&!H.current)return;let T=z.current;if(T?.kind==="picker"){let j=T.items[T.sel];j&&(j.designed?N({kind:"confirm",item:j,sel:0}):xt(j,!1));return}if(T?.kind==="confirm"){On(T.item)[T.sel]?.key==="redesign"?xt(T.item,!0):ht();return}if(T?.kind==="ask"){let j=Qe.current[T.sel]?.key;j==="another"?ht():j==="view"?ze(""):N(null);return}if(T?.kind==="failed"){let j=He.current[T.sel]?.key;j==="retry"?xt(T.item,T.force):j==="view"?ze(""):N(null);return}if(T&&!H.current||!H.current)return;switch(Pe.current[wt.current]?.key){case"reconcile-review":Yt();return;case"finish":t.completeSession();return;case"continue":t.continueParked();return;case"design-chain":ht();return;case"view":ze("",st.current);return;case"free":$e("");return}return}let s=Ue(e),a=ke.current;if(s.batchIdx!=null&&a===s.batchIdx){t.goWithRecommendations();return}if(s.freeIdx!=null&&a===s.freeIdx){be("");return}if(s.doneIdx!=null&&a===s.doneIdx){t.confirmMulti(Z.current),Ne();return}if(e.multi_select){t.toggleOption(Z.current,a);return}if(e.options[a]?.input===!0){ye({opt:a,value:""});return}t.submitAnswer(Z.current,a),Ne()},onLeft:()=>{te.current&&Ee(Math.max(0,Z.current-1))},onRight:()=>{let e=te.current;e&&Ee(Math.min(e.questions.length-1,Z.current+1))},onDigit:e=>{let o=ie.current;if(o){e-1<o.options.length&&Me(e-1);return}let s=G.current;if(s){let f=s.items[s.i];if(s.st.kind==="card"&&f){e-1<Ye(f.card).length&&E({...s,st:{kind:"card",sel:e-1}});return}if(s.st.kind==="offer"){e-1<2&&E({...s,st:{...s.st,sel:e-1}});return}if(s.st.kind==="done"){e-1<Xe.current.length&&E({...s,st:{...s.st,sel:e-1}});return}if(s.st.kind!=="running"||!H.current)return}let a=z.current;if(a?.kind==="picker"){e-1<a.items.length&&N({...a,sel:e-1});return}if(a?.kind==="ask"){e-1<Qe.current.length&&N({...a,sel:e-1});return}if(a?.kind==="failed"){e-1<He.current.length&&N({...a,sel:e-1});return}if(a?.kind==="confirm"){e-1<2&&N({...a,sel:e-1});return}if(!(a&&!H.current)&&H.current){let f=Pe.current,T=0;for(let ee=0;ee<f.length;ee++)if(!f[ee].free&&(T+=1,T===e)){ve(ee);return}}},isMulti:()=>{let e=ie.current;return!!e?.multi_select&&ke.current<(e?.options.length??0)},onSpace:()=>{te.current&&t.toggleOption(Z.current,ke.current)},onTab:()=>{let e=ie.current;if(!e)return;let o=Ue(e);o.batchIdx!=null&&Me(o.batchIdx)},onType:e=>{let o=ie.current;if(o){if(e==="@"&&t.canIngest()){Be("");return}let a=ke.current;if(o.options[a]?.input===!0){ye({opt:a,value:e});return}if(!o.allow_free_text)return;let f=Ue(o);Me(f.freeIdx??0),be(e);return}let s=G.current;if(s){if(s.st.kind==="card"){let a=Ze(s.items[s.i].card);a!=null&&(E({...s,st:{kind:"card",sel:a}}),J(e));return}if(s.st.kind!=="running"||!H.current)return}if(!(z.current&&!H.current)&&H.current){let a=pn(Pe.current);if(a==null)return;ve(a),$e(e)}},onBack:()=>{let e=G.current;if(e){e.st.kind==="view"?E({...e,st:{kind:"card",sel:0}}):e.st.kind==="offer"?Te(e):e.st.kind==="done"&&(E(null),g?.());return}let o=z.current;if(o&&o.kind!=="running"){N(null);return}let s=te.current;if(s){for(let a=Z.current-1;a>=0;a--)if(s.resolution[a]){Ee(a);return}}}},nr=_t!=null?{value:_t,onChange:e=>be(e),onSubmit:e=>{be(null),e.trim()&&te.current&&(t.submitFreeText(Z.current,e),Ne())},onCancel:()=>be(null)}:null,rr=jt!=null?{value:jt,onChange:e=>Be(e),onSubmit:e=>{Be(null),e.trim()&&t.ingestAttach(e)},onCancel:()=>Be(null)}:null,ir=We!=null?{optionIndex:We.opt,value:We.value,onChange:e=>ye({opt:We.opt,value:e}),onSubmit:e=>{let o=at.current?.opt;ye(null),o!=null&&te.current&&(t.submitAnswerWithText(Z.current,o,e),Ne())},onCancel:()=>ye(null)}:null,Ve=(0,p.useRef)(!1),ut=l??(()=>t.requestPause()),Ut=()=>{if(q.current&&!Ve.current){Ve.current=!0,A("finishing the verdict \u2014 exiting once it lands (ctrl+c again = force)");return}ut()},le=t.state.checkpoint,Le=M?.kind==="running"&&fe==="idle",Vt=C?.st.kind==="running"&&fe==="idle",ge=fe==="idle"&&Kn&&!F&&!y&&(!M||Le)&&(!C||Vt),H=(0,p.useRef)(!1);H.current=ge;let ne=he(t.state.turns).entries.length,_e,se;for(let e=oe.length-1;e>=0;e--){if(K.current.some(s=>s.end!=null&&e>=s.start&&e<s.end))continue;let o=oe[e];if(!_e&&o.kind==="commit"&&o.ok&&(_e=o.line),!se&&o.kind==="banner"&&o.text.startsWith("designing: ")&&(se=o.text.slice(11)),_e&&se)break}let dt;for(let e=oe.length-1;e>=0;e--){let o=oe[e];if(o.kind==="user")break;if(o.kind==="commit"&&o.ok&&/\bapplied\b/.test(o.line)){dt=o.line;break}}let ae=se?{"acceptance criteria":"scenarios",scenarios:"acceptance criteria + exercises","acceptance criteria + exercises":"tests + gaps"}[se]:void 0,Kt={"acceptance criteria":"the promises every path of this use-case must keep",scenarios:"the concrete user journeys that exercise those promises","acceptance criteria + exercises":"the wiring pass \u2014 per-journey checks, tied to the promises each journey exercises","tests + gaps":"runnable browser tests \u2014 anything unautomatable is recorded as a gap"},Qt=se?Kt[se]:void 0,Ht=ae?Kt[ae]:void 0,sr="phases: acceptance criteria \u2192 scenarios \u2192 wiring \u2192 tests \xB7 stop anytime with finish",or=(()=>{for(let e=oe.length-1;e>=0;e--){let o=oe[e];if(o.kind==="agent")return o.text}return null})(),we=/\?\s*$/.test((or??"").trimEnd()),Xt=i==="design"&&!le&&(we||ae!==void 0),zt=se==="tests + gaps",Ke=M?.kind==="running"?M.title:"the design",Gt=!!t.state.error&&!t.senderAlive(),lr=je?"the agent needs a clarification before it can apply that":Le&&!le?we?`${Ke} \u2014 the agent asked a question`:dt?`${Ke} \u2014 ${dt}`:zt?`${Ke} \u2014 design complete`:`${Ke} \u2014 the agent is waiting on you`:le?se?`${se} done${ae?` \u2014 next: ${ae}`:""}`:_e??"phase done":Gt?"the agent stopped \u2014 the session is view-only":Xt?we?"the agent asked a question \u2014 answer or continue":`design incomplete \u2014 ${ae} not started`:_e??"waiting on you",[Oe,ar]=(0,p.useState)(null),cr=(0,p.useRef)(null);(0,p.useEffect)(()=>{if(!m)return;let e=ge||le?m.pending():null;cr.current=e,ar(e)},[ge,le,oe.length,C==null]);let Jt=Oe?[{key:"reconcile-review",label:Oe.kind==="cards"?`review ${Oe.count} change(s) from ${Oe.source}`:`review change(s) detected in ${Oe.source}`}]:[],mt=je?[{key:"free",label:"clarify \u2014 type which one you meant",free:!0}]:Le&&!le?zt&&!we?[{key:"finish",label:"finish this design"},...ne>0?[{key:"view",label:"view what's saved"}]:[],{key:"free",label:"reply \u2014 tell the agent what to change",free:!0}]:[{key:"continue",label:we?"continue \u2014 go with your suggestion":"continue designing"},...ne>0?[{key:"view",label:"view what's saved"}]:[],{key:"finish",label:"finish this design"},{key:"free",label:"reply \u2014 tell the agent what to change",free:!0}]:le?[...Jt,{key:"continue",label:ae?`continue to ${ae}`:"continue"},...ne>0?[{key:"view",label:"view what's saved"}]:[],{key:"finish",label:"finish here"},{key:"free",label:"adjust \u2014 tell me what to change",free:!0}]:Gt?[...ne>0?[{key:"view",label:"view what's saved"}]:[],{key:"free",label:"tell me what to change",free:!0}]:Xt?[{key:"continue",label:we?"continue \u2014 go with your suggestion":`continue \u2014 ${ae} next`},...ne>0?[{key:"view",label:"view the design"}]:[],{key:"finish",label:"finish anyway"},{key:"free",label:"reply \u2014 answer and continue",free:!0}]:[...Jt,{key:"finish",label:i==="design"?"finish":"looks good \u2014 finish the session"},...u?[{key:"design-chain",label:"design tests for a use-case\u2026"}]:[],...ne>0?[{key:"view",label:i==="design"?"view the design":`view the ${ne} draft${ne===1?"":"s"}`}]:[],{key:"free",label:i==="design"?"keep adjusting \u2014 tell me what to change":"tell me what to change",free:!0}],ft=[{key:"another",label:"design another use-case\u2026"},...ne>0?[{key:"view",label:"view what was designed"}]:[],{key:"back",label:"done \u2014 back"}],Qe=(0,p.useRef)(ft);Qe.current=ft;let gt=[{key:"retry",label:"try again"},...ne>0?[{key:"view",label:"view what's saved"}]:[],{key:"back",label:"back"}],He=(0,p.useRef)(gt);He.current=gt;let pt=[...ne>0?[{key:"view",label:"view what's saved"}]:[],{key:"back",label:"back to the check-in"}],Xe=(0,p.useRef)(pt);Xe.current=pt;let ht=()=>{let e=u?.listUcs()??[];if(e.length===0){A("no use-cases to design yet");return}N({kind:"picker",items:e,sel:0})},xt=(e,o)=>{let s={start:t.state.ledger.length,end:null};K.current.push(s);let a=()=>{s.end=t.state.ledger.length};N({kind:"running",title:e.title,item:e,force:o,startedAt:Date.now()}),u.runDesignChild(e.key,o).then(f=>{a(),f===0?(t.ledger({kind:"commit",ok:!0,line:`designed ${e.title}`}),N({kind:"ask",title:e.title,sel:0})):(t.ledger({kind:"commit",ok:!1,line:`design for ${e.title} failed \u2014 child exited ${f}`}),N({kind:"failed",item:e,force:o,detail:`child exited ${f}`,sel:0}))}).catch(f=>{a();let T=f instanceof Error?f.message:String(f);t.ledger({kind:"commit",ok:!1,line:`design for ${e.title} failed \u2014 ${T}`}),N({kind:"failed",item:e,force:o,detail:T,sel:0})})},Yt=()=>{let e=m?.pending();if(!e){A("nothing awaiting review");return}if(U.current={approved:0,rejected:0,deferred:0},e.kind==="needs-run"){E({items:[],i:0,st:{kind:"running",label:`reviewing changes in ${e.source}`,startedAt:Date.now()}}),m.startReview(e.source).then(()=>{let s=m.loadCards();if(s.length===0){t.note("no reviewable changes came back \u2014 the source may be unchanged"),E(null);return}E({items:s,i:0,st:{kind:"card",sel:0}})}).catch(s=>{t.note(`the review run failed \u2014 ${s instanceof Error?s.message:String(s)}`),E(null)});return}let o=m.loadCards();if(o.length===0){A("nothing awaiting review");return}E({items:o,i:0,st:{kind:"card",sel:0}})},Zt=e=>{let o=U.current,s=`${o.approved} approved \xB7 ${o.rejected} rejected \xB7 ${o.deferred} deferred`;E({...e,st:{kind:"done",sel:0,summary:s}})},Te=e=>{if(e.i+1<e.items.length){E({...e,i:e.i+1,st:{kind:"card",sel:0}});return}let o=m?.loadCards()??[];o.length===0?Zt(e):E({items:o,i:0,st:{kind:"card",sel:0}})},en=(e,o)=>{if(!u){Te(e);return}let s={start:t.state.ledger.length,end:null};K.current.push(s),E({...e,st:{kind:"running",label:`${o.kind==="evolve"?"Evolving":"Designing"} ${o.title}`,startedAt:Date.now()}}),u.runDesignChild(o.key,o.kind==="evolve").then(a=>{s.end=t.state.ledger.length,t.ledger({kind:"commit",ok:a===0,line:a===0?`${o.kind==="evolve"?"evolved":"designed"} ${o.title}`:`${o.kind} child for ${o.title} failed \u2014 exited ${a}`}),Te(G.current??e)}).catch(a=>{s.end=t.state.ledger.length,t.ledger({kind:"commit",ok:!1,line:`${o.kind} child for ${o.title} failed \u2014 ${a instanceof Error?a.message:String(a)}`}),Te(G.current??e)})},ur=(e,o,s)=>{let a=e.items[e.i];!a||q.current||(q.current=!0,m.applyVerdict(a.key,o,s).then(f=>{if(q.current=!1,Ve.current){ut();return}let T=G.current??e;if(!f.ok){t.note(f.refusal);let ee=m.loadCards();ee.length===0?Zt(T):E({items:ee,i:Math.min(T.i,ee.length-1),st:{kind:"card",sel:0}});return}U.current[o==="approve"?"approved":o==="reject"?"rejected":"deferred"]+=1,t.ledger({kind:"commit",ok:!0,line:f.line}),f.note&&t.note(f.note),f.offer?en(T,f.offer):Te(T)}).catch(f=>{if(q.current=!1,Ve.current){ut();return}t.note(`the verdict did not land \u2014 ${f instanceof Error?f.message:String(f)}; try the card again`)}))},dr=e=>{m?.noteSteer?.(),E(null),J(null),A(null),t.submit(e)},mr=De!=null?{value:De,onChange:e=>J(e),onSubmit:e=>{let o=e.trim();o?dr(o):J(null)},onCancel:()=>J(null)}:null,tn=(0,p.useRef)(!1);(0,p.useEffect)(()=>{!d||tn.current||(tn.current=!0,m?.pending()?Yt():g?.())},[d]);let Pe=(0,p.useRef)(mt);Pe.current=mt;let kt=ge&&le&&Qt!==void 0,bt=K.current.find(e=>e.end==null)?.start??"top",nn=(0,p.useRef)(new Set),[fr,rn]=(0,p.useState)(!1);(0,p.useEffect)(()=>{kt?nn.current.has(bt)||(nn.current.add(bt),rn(!0)):rn(!1)},[kt,bt]);let gr=kt?[...fr?[sr]:[],`${Qt}${Ht?` \xB7 next: ${Ht}`:""}`]:[],[pr,hr]=(0,p.useState)(0),[yt,xr]=(0,p.useState)(null),wt=(0,p.useRef)(0),sn=(0,p.useRef)(null),ve=e=>{wt.current=e,hr(e)},$e=e=>{sn.current=e,xr(e)},kr=`${ge}:${le}:${st.current}`;(0,p.useEffect)(()=>{ve(0),$e(null)},[kr]);let br=yt!=null?{value:yt,onChange:e=>$e(e),onSubmit:e=>{$e(null),ve(0);let o=e.trim();o&&(A(null),t.submit(o))},onCancel:()=>{$e(null),ve(0)}}:null,ze=(e,o)=>{if(/^(uc|sc|ac|t|gap|sty)-\d+$/i.test(e.trim())){let T=e.trim().toLowerCase(),j=he(t.state.turns).entries.findIndex(V=>(V.item.logical_id??"").toLowerCase()===T);if(j<0){A(`${e.trim().toUpperCase()} isn't in this session's items \u2014 view lists what this session minted`);return}W({level:"detail",cursor:j,scroll:0}),D(null);return}let s=Ln(e);if("error"in s){A(s.error);return}let a=he(t.state.turns);if(a.entries.length===0){A("nothing proposed yet \u2014 the first turn is still coming");return}if(s.level==="detail"&&s.num>a.entries.length){A(`no item ${s.num} \u2014 the set has ${a.entries.length} item${a.entries.length===1?"":"s"}`);return}let f=o!=null?Ct(a,o):a;W(Mn(s,f)),D(o!=null&&f.entries.length<a.entries.length?o:null)},on=(0,I.jsx)(xn,{verb:i,subject:Et,pendingCount:Wn,creditsTotal:t.state.credits?.total,state:Le?"waiting on you":F||ge||y||M&&M.kind!=="running"?"idle":void 0});if(y){let e=he(t.state.turns),o=P!=null?Ct(e,P):e,s=e.entries.length-o.entries.length,a=y.level==="list"&&s>0,f=o.entries.length+(a?1:0),T=o.entries[y.cursor],ee=y.level==="detail"&&T?t.explainLines(T.item.slug??T.item.temp_ref):null,j=y.level==="detail"&&T&&h?h(T.item.logical_id??t.aliasOf(T.item.temp_ref)??T.item.temp_ref):null;return(0,I.jsxs)(b,{flexDirection:"column",children:[(0,I.jsx)(Tt,{onToggleThinking:()=>$(V=>!V),onCtrlC:Ut,explorer:{isOpen:()=>S.current!==null,onMove:V=>W(S.current&&nt(S.current,{type:"move",delta:V},f)),onEnter:()=>{let V=S.current;if(V){if(V.level==="list"&&a&&V.cursor===o.entries.length){D(null);return}W(nt(V,{type:"enter"},f))}},onBack:()=>{W(S.current&&nt(S.current,{type:"back"},f)),setTimeout(()=>k(V=>V+1),0)}}}),(0,I.jsx)(Bn,{items:o,state:y,verb:i,more:a?{hidden:s}:null,explain:ee,grandTotal:e.entries.length,dossier:j}),(Fe??w)&&(Fe??w).split(`
7
- `).map((V,pe)=>(0,I.jsx)(n,{color:r.orange,children:V},`nt-${pe}`)),on]})}return(0,I.jsxs)(b,{flexDirection:"column",children:[(0,I.jsx)(Tt,{onToggleThinking:()=>$(e=>!e),onCtrlC:Ut,panel:tr}),jn&&(0,I.jsx)(mn,{thinking:Fn.body,expanded:!0,thinkingDone:fe!=="streaming",maxLines:_n+1}),Bt.length>0&&(0,I.jsx)(b,{flexDirection:"column",children:Bt.map((e,o)=>(0,I.jsx)(n,{children:un(e).map((s,a)=>(0,I.jsx)(n,{bold:s.bold,italic:s.italic,color:s.code?r.dim:void 0,children:s.text},a))},`st-${o}`))}),F&&(0,I.jsx)(bn,{batch:F,qView:ct,sel:Qn,focused:Xn,freeText:nr,optionText:ir,attach:rr,canAttach:t.canIngest(),multiSelFor:e=>t.multiSelection(e)}),je&&(0,I.jsx)(n,{color:"yellow",children:je.prompt}),(Fe??w)&&(Fe??w).split(`
8
- `).map((e,o)=>(0,I.jsx)(n,{color:r.orange,children:e},`nt-${o}`)),Lt&&!F&&(0,I.jsxs)(n,{color:r.assuranceAccent,children:[`${Se[lt%Se.length]} ${Vn} `,(0,I.jsx)(n,{color:r.dim,children:`(${Un}s)`})]}),ge&&(0,I.jsx)(ue,{headline:lr,rows:mt,sel:pr,focused:yt==null,legend:"\u2191\u2193 \xB7 \u23CE select \xB7 type = your own words",freeText:br,sublines:gr}),C?.st.kind==="card"&&C.items[C.i]&&(0,I.jsx)(kn,{card:C.items[C.i].card,position:{n:C.i+1,of:C.items.length},sel:C.st.sel,focused:De==null,freeText:mr,editorIntent:"steer"}),C?.st.kind==="view"&&C.items[C.i]&&(0,I.jsx)(En,{title:C.items[C.i].card.title,lines:C.items[C.i].viewLines,offset:C.st.offset}),C?.st.kind==="offer"&&(0,I.jsx)(ue,{ask:!0,headline:C.st.offer.kind==="evolve"?`approved \u2014 the design for ${C.st.offer.title} should evolve with it`:`approved \u2014 ${C.st.offer.title} has no tests yet`,rows:[{key:"run",label:C.st.offer.kind==="evolve"?"evolve the design now":"design tests now"},{key:"later",label:"later \u2014 next change"}],sel:C.st.sel,focused:!0,legend:"\u2191\u2193 \xB7 \u23CE select \xB7 esc later"}),C?.st.kind==="running"&&!Vt&&(0,I.jsxs)(n,{color:r.assuranceAccent,children:[`${Se[lt%Se.length]} ${C.st.label}\u2026 `,(0,I.jsx)(n,{color:r.dim,children:`(${Math.floor((Date.now()-C.st.startedAt)/1e3)}s)`})]}),C?.st.kind==="done"&&(0,I.jsx)(ue,{headline:`review complete \u2014 ${C.st.summary}`,rows:pt,sel:C.st.sel,focused:!0,legend:"\u2191\u2193 \xB7 \u23CE select \xB7 esc back"}),M?.kind==="picker"&&(0,I.jsx)(ue,{ask:!0,headline:"design tests for which use-case?",rows:M.items.map(e=>({key:e.key,label:e.title,detail:e.badge})),sel:M.sel,focused:!0,legend:"\u2191\u2193 \xB7 \u23CE select \xB7 esc back"}),M?.kind==="confirm"&&(0,I.jsx)(ue,{ask:!0,headline:`${M.item.title} is already designed${M.item.designed==="stale"?" \u2014 and the use-case has changed since":""}`,rows:On(M.item).map(e=>({key:e.key,label:e.label,detail:e.detail})),sel:M.sel,focused:!0,legend:"\u2191\u2193 \xB7 \u23CE select \xB7 esc back"}),M?.kind==="running"&&!Le&&(0,I.jsxs)(n,{color:r.assuranceAccent,children:[`${Se[lt%Se.length]} Designing ${M.title}\u2026 `,(0,I.jsx)(n,{color:r.dim,children:`(${Math.floor((Date.now()-M.startedAt)/1e3)}s)`})]}),M?.kind==="ask"&&(0,I.jsx)(ue,{headline:`designed ${M.title}`,rows:ft,sel:M.sel,focused:!0,legend:"\u2191\u2193 \xB7 \u23CE select \xB7 esc back"}),M?.kind==="failed"&&(0,I.jsx)(ue,{headline:`design failed \u2014 ${M.item.title} (${M.detail})`,rows:gt,sel:M.sel,focused:!0,legend:"\u2191\u2193 \xB7 \u23CE select \xB7 esc back"}),fe==="pausing"&&(0,I.jsx)(n,{color:r.dim,children:"pausing \u2014 saving session\u2026 (ctrl+c again = force quit)"}),on]})}export{Li as ChatSurface,jr as tailVisualRows};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-YFYCCTSL.js";import"./chunk-ZVHCQMJ6.js";import"./chunk-5DBK6QNS.js";import"./chunk-CJJXT5DO.js";import"./chunk-XWKUZJCP.js";import"./chunk-ZPDM6FO7.js";import"./chunk-EHN5HTUD.js";import"./chunk-NVGBE2DR.js";import"./chunk-CH273NAE.js";import"./chunk-L5LI2JF4.js";import"./chunk-6IA6QMPH.js";import"./chunk-TH47OOBV.js";import"./chunk-VAYBKR76.js";import"./chunk-CUM23TLF.js";import"./chunk-DUAXZYAD.js";import"./chunk-DBIBROYW.js";import"./chunk-WXHQYYD5.js";import"./chunk-IAHKTEET.js";import"./chunk-UD7KKHPW.js";import"./chunk-RFHMDQXZ.js";import"./chunk-2KDGIZED.js";import"./chunk-TYLYFERW.js";import"./chunk-MSGW4JDG.js";import"./chunk-56PAQAX5.js";import"./chunk-5EOX4MEY.js";import"./chunk-4JOD47QI.js";import"./chunk-G7VQCS4J.js";import"./chunk-RZ4F3BHX.js";import"./chunk-27U4PLPX.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{a as EvidenceViewOffer};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a,b}from"./chunk-UXDL4XDL.js";import"./chunk-YCCUBQY4.js";import"./chunk-L7MXYCD7.js";import"./chunk-2WVKOZ6W.js";import"./chunk-TFPPEOAK.js";import"./chunk-G7VQCS4J.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-27U4PLPX.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{b as FolderPicker,a as formatFolderLine};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-FQLIW3LM.js";import"./chunk-3PECJD6S.js";import"./chunk-IOFZSQAA.js";import"./chunk-HMYMSRA4.js";import"./chunk-L5LI2JF4.js";import"./chunk-TDPWFYTJ.js";import"./chunk-T5Y6MOLM.js";import"./chunk-OTTGS2TE.js";import"./chunk-QRZRSAZH.js";import"./chunk-UXDL4XDL.js";import"./chunk-YCCUBQY4.js";import"./chunk-L7MXYCD7.js";import"./chunk-2WVKOZ6W.js";import"./chunk-VE3SUJMA.js";import"./chunk-TZXXJWHA.js";import"./chunk-56PAQAX5.js";import"./chunk-5EOX4MEY.js";import"./chunk-AW2XUHH4.js";import"./chunk-HEAIJCGZ.js";import"./chunk-TFPPEOAK.js";import"./chunk-766WGMBU.js";import"./chunk-G7VQCS4J.js";import"./chunk-DPUV6OSP.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import"./chunk-6O3DDOP2.js";import"./chunk-27U4PLPX.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{a as SingleShotApp};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{g as a}from"./chunk-ZIUAOEUC.js";import"./chunk-CTW2VQKS.js";import"./chunk-GZPK6FRP.js";import"./chunk-6IA6QMPH.js";import"./chunk-TDPWFYTJ.js";import"./chunk-T5Y6MOLM.js";import"./chunk-EWCAFKLX.js";import"./chunk-5Y2G4NC7.js";import"./chunk-FNH55WSR.js";import"./chunk-TYLYFERW.js";import"./chunk-MSGW4JDG.js";import"./chunk-56PAQAX5.js";import"./chunk-5EOX4MEY.js";import"./chunk-4JOD47QI.js";import"./chunk-G7VQCS4J.js";import"./chunk-RZ4F3BHX.js";import"./chunk-EYOCNMUM.js";import"./chunk-UDIQOJEL.js";import"./chunk-FEJXWJ3L.js";import"./chunk-27U4PLPX.js";import"./chunk-DFS4RMVP.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{a as TestMdRunView};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a,b,c,d,e,f,g}from"./chunk-HEAIJCGZ.js";import"./chunk-RZ4F3BHX.js";import"./chunk-UR6MHSHU.js";export{g as AppClient,f as AppUploadError,a as UPLOAD_CONTENT_TYPE,d as parseAppDetails,b as parseAppListPage,c as parseUploadResponse,e as transportReason};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a,b}from"./chunk-IP2O264K.js";import"./chunk-R5T4RLF5.js";import"./chunk-IDX3TOPY.js";import"./chunk-BKM2LWU2.js";import"./chunk-KBM3XHAM.js";import"./chunk-2YEHV2CX.js";import"./chunk-56PAQAX5.js";import"./chunk-5EOX4MEY.js";import"./chunk-RZ4F3BHX.js";import"./chunk-27U4PLPX.js";import"./chunk-UR6MHSHU.js";export{b as telemetryBootstrap,a as telemetryEnvName};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a}from"./chunk-QSDH5P7C.js";import"./chunk-OMQCD3KR.js";import"./chunk-SDPRO2LE.js";import"./chunk-UD7KKHPW.js";import"./chunk-27U4PLPX.js";import"./chunk-UR6MHSHU.js";export{a as runAgent};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{homedir as a}from"os";import{join as t}from"path";var m="0.8.1",d="kane-cli",e=t(a(),".testmuai","kaneai"),g=t(e,"profiles"),h=t(e,"tui-config.json"),_=t(e,"media"),A="https://registry.npmjs.org/@testmuai/kane-cli",L="https://api.github.com/repos/LambdaTest/kane-cli/releases",n="@testmuai/kane-cli-skill",b=`https://registry.npmjs.org/${n}`,r="kane-cli",x=[{dir:t(a(),".claude","skills",r),agent:"Claude Code"},{dir:t(a(),".agents","skills",r),agent:"Codex CLI"},{dir:t(a(),".gemini","skills",r),agent:"Gemini CLI"}],u="https://dd-proxy.lambdatest.com/intake/kane-cli",U="https://kaneai-playground.lambdatest.io",R=9222,I=9230,E=t(e,"chrome-profiles"),o=t(e,"hints"),C=t(o,"state.json");function T(s){return t(o,`catalog-${s}.json`)}var c="127.0.0.1",S=18392,f=18400,i="/callback";function N(s){return`http://${c}:${s}${i}`}var P="KANE CLI",B="*",O={prod:{authBaseUrl:"https://auth.lambdatest.com",consentUrl:"https://accounts.lambdatest.com",controllerBaseUrl:"https://kaneai-api.lambdatest.com/v16-controller/v1",tmsBaseUrl:"https://test-manager-api.lambdatest.com/api",testGeneratorBaseUrl:"https://test-manager-api.lambdatest.com",secretsBaseUrl:"https://api-hyperexecute.lambdatest.com",testManagerUiUrl:"https://test-manager.lambdatest.com",shareApiBaseUrl:"https://api.lambdatest.com",v16ServerHost:"https://kaneai-api.lambdatest.com/v16-server",evidenceViewerUrl:"https://evidence.lambdatest.com",mediaArtefactsHost:"prod-mobile-artefacts.lambdatest.com"},stage:{authBaseUrl:"https://stage-auth.lambdatestinternal.com",consentUrl:"https://stage-accounts.lambdatestinternal.com",controllerBaseUrl:"https://auteur-stage-automind.lambdatestinternal.com/v16-controller/v1",tmsBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com/api",testGeneratorBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com",secretsBaseUrl:"https://api-stage-hyperexecute.lambdatestinternal.com",testManagerUiUrl:"https://stage-test-manager.lambdatestinternal.com",shareApiBaseUrl:"https://stage-api.lambdatestinternal.com",v16ServerHost:"https://auteur-stage-automind.lambdatestinternal.com/v16-server",evidenceViewerUrl:"https://stage-evidence.lambdatestinternal.com",mediaArtefactsHost:"stage-mobile-artefacts.lambdatestinternal.com"}},k={orange:"#ff9500",generateAccent:"#0d9488",assuranceAccent:"#b388ff",purple:"#b388ff",secondary:"#888888",dim:"#666666",muted:"#444444",green:"#4ade80",red:"#ef4444"};export{m as a,d as b,e as c,h as d,_ as e,A as f,L as g,n as h,x as i,u as j,U as k,R as l,I as m,E as n,C as o,T as p,c as q,S as r,f as s,i as t,N as u,P as v,B as w,O as x,k as y};
@@ -1,4 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as h,d as $}from"./chunk-TYLYFERW.js";import{a as w}from"./chunk-RZ4F3BHX.js";import{c as S}from"./chunk-27U4PLPX.js";import{spawn as V,spawnSync as _}from"child_process";import{createServer as K}from"net";import{mkdirSync as g,openSync as W,readFileSync as I,renameSync as j,rmSync as x,statSync as Y,writeFileSync as C}from"fs";import{readFile as q}from"fs/promises";import{dirname as l,join as y}from"path";var G=[4723,4724,4725,4726,4727,4728,4729,4730],X={emulator:4750,simulator:4790},z=40,E=2e3,D=3e4,T=500,Me=["emulator","simulator"];function Q(e){return y(S,"mobile",`appium-server-${e}.log`)}function m(){return y(S,"mobile","appium-servers.json")}function Z(){return y(S,"mobile","appium-servers.lock")}var ee=1e4,re=50;function M(e){let r=Z();try{g(l(r),{recursive:!0})}catch{return e()}let n=!1;for(let o=0;o<re;o++)try{g(r),n=!0;break}catch{try{Date.now()-Y(r).mtimeMs>ee&&x(r,{recursive:!0,force:!0})}catch{}ne(10)}try{return e()}finally{if(n)try{x(r,{recursive:!0,force:!0})}catch{}}}function ne(e){try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}catch{}}function te(){try{let e=JSON.parse(I(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}function oe(e){let r=m();g(l(r),{recursive:!0});let n=`${r}.tmp`;C(n,JSON.stringify(e,null,2)),j(n,r)}function se(e,r,n){return`Another mobile session is already running${n?` on ${n}`:""}. Wait for it to finish, or close the terminal running it.`}var A=class extends Error{constructor(n,o){super(n);this.port=o;this.name="DeviceBusyError"}};function ie(e){return w(e,{signal:AbortSignal.timeout(E)}).then(r=>r.ok,()=>!1)}async function ae(e,r){try{return(await w(`http://127.0.0.1:${e}/session/${r}`,{method:"DELETE",signal:AbortSignal.timeout(E)})).ok}catch{return!1}}function R(e){let r=e?.value;return Array.isArray(r)?r.map(n=>{let o=n??{},t=o.capabilities??o;return{...typeof o.id=="string"?{id:o.id}:{},caps:t}}):[]}async function ue(e){try{let r=await w(`http://127.0.0.1:${e}/sessions`,{signal:AbortSignal.timeout(E)});return r.ok?R(await r.json()):[]}catch{return[]}}var ce=["udid","appium:udid","deviceUDID","appium:deviceUDID","deviceName","appium:deviceName"];function L(){let e=r=>{try{let n=_("curl",["-s","--noproxy","*","--max-time","2",...r],{encoding:"utf8",timeout:5e3});return{ok:n.status===0,stdout:n.stdout??""}}catch{return{ok:!1,stdout:""}}};return{readState:()=>{try{let r=JSON.parse(I(m(),"utf8"));return Array.isArray(r)?r:[]}catch{return[]}},alive:b,getJson:r=>{let n=e([r]);if(n.ok)try{return JSON.parse(n.stdout)}catch{return}},del:r=>{let n=e(["-o","/dev/null","-w","%{http_code}","-X","DELETE",r]);return n.ok&&/^2\d\d$/.test(n.stdout.trim())}}}function Le(e,r={}){let n={...L(),...r},o=0;try{for(let t of n.readState()){if(!n.alive(t.pid))continue;let i=R(n.getJson(`http://127.0.0.1:${t.port}/sessions`));for(let s of i)s.id&&de(s.caps,e.udid,e.displayName)&&n.del(`http://127.0.0.1:${t.port}/session/${s.id}`)&&(o+=1)}}catch{}return o}function de(e,r,n){let o=[r,n].filter(t=>!!t).map(t=>t.toLowerCase());for(let t of ce){let i=e[t];if(typeof i=="string"&&o.includes(i.toLowerCase()))return!0}return!1}function pe(e,r,n){let o=W(n.logPath,"a"),t=V(e,r,{stdio:["ignore",o,o],detached:!0,env:{...process.env,...n.env}});return t.unref(),t.pid}async function le(e,r){for(let n=e;n<e+r;n++)if(await new Promise(t=>{let i=K();i.once("error",()=>t(!1)),i.once("listening",()=>i.close(()=>t(!0))),i.listen(n)}))return n;throw new Error(`No free port for the managed Appium server in ${e}-${e+r-1}.`)}function b(e){try{return process.kill(e,0),!0}catch{return!1}}function P(e){try{let r=_("ps",["-o","comm=","-p",String(e)],{encoding:"utf8",timeout:2e3});if(r.status!==0)return!1;let n=r.stdout.trim().toLowerCase();return n===""?!0:n.includes("node")||n.includes("kane")}catch{return!0}}function k(e){try{process.kill(e)}catch{}}async function me(){try{let e=JSON.parse(await q(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}async function fe(e){let r=process.pid,n=e.filter(o=>o.owner===r);M(()=>{let o=[];for(let t of te())t.owner!==r&&(ve(t)?o.push(t):b(t.pid)&&k(t.pid));oe([...o,...n])})}function ve(e){return e.owner===void 0?!1:b(e.owner)&&P(e.owner)}function Se(){return{probe:ie,sessions:ue,deleteSession:ae,spawn:pe,freePort:le,alive:b,kill:k,readState:me,writeState:fe,owner:process.pid,depsEnv:e=>h().environment(e),bundleVersion:async e=>(await h().status(e)).version,nodeBinary:process.execPath,env:process.env,os:process.platform,now:()=>Date.now(),sleep:e=>new Promise(r=>setTimeout(r,e))}}function we(e,r,n){if(!e.platformToolsDir)return{};let o=n==="win32"?";":":",t=$(r),i=t?.root??l(e.platformToolsDir),s=t?.platformToolsDir??e.platformToolsDir;return{ANDROID_HOME:i,ANDROID_SDK_ROOT:i,PATH:r.PATH?`${s}${o}${r.PATH}`:s}}async function ge(e){let r=await e.readState(),n=[],o=[];for(let t of r)t.owner!==void 0&&e.alive(t.owner)&&(e.ownerIsOurs??P)(t.owner)?n.push(t):o.push(t);for(let t of o){let i=e.ownerIsOurs??P;e.alive(t.pid)&&i(t.pid)&&e.kill(t.pid)}return o.length>0&&await e.writeState(n),n}async function Je(e,r={}){if(r.appiumUrl)return{result:"external",url:r.appiumUrl};let n={...Se(),...r.deps},o=await ge(n),t=o.filter(a=>a.owner===n.owner),i=new Set(t.map(a=>a.port)),s=new Set(o.map(a=>a.port));if(r.device){let a=await ye(n,s,i,e);if(a!==null)throw new A(se(r.device,a.port,a.device),a.port)}let c=await n.bundleVersion(e),u=t.find(a=>a.deviceClass===e&&(a.bundleVersion??c)===c);if(u&&await n.probe(`http://127.0.0.1:${u.port}/status`))return{result:"reused",url:`http://127.0.0.1:${u.port}`};for(let a of t.filter(v=>v.deviceClass===e&&v!==u))n.kill(a.pid);u&&n.kill(u.pid);let d=await n.depsEnv(e);if(!d.appiumHome)throw new Error(`The managed dependencies for the ${e} class are not installed.
3
- Run \`kane-cli doctor --install\` to install them, or pass --appium-url for an external server.`);let p=await n.freePort(X[e],z),O=`http://127.0.0.1:${p}`,J=l(d.appiumHome),U=y(J,"appium","node_modules","appium","index.js"),N=Q(e);r.onProgress?.(`starting the managed Appium server (${e}, port ${p})\u2026`);let f=n.spawn(n.nodeBinary,[U,"--port",String(p)],{env:{APPIUM_HOME:d.appiumHome,...we(d,n.env,n.os)},logPath:N}),B=n.now()+D,F=Math.ceil(D/T)+1;for(let a=0;a<F&&n.now()<B;a++)if(await n.sleep(T),await n.probe(`${O}/status`)){if(f!==void 0){let v=t.filter(H=>H.deviceClass!==e);await n.writeState([...v,{port:p,pid:f,owner:n.owner,deviceClass:e,...c?{bundleVersion:c}:{},startedAt:new Date(n.now()).toISOString()}])}return r.onProgress?.("Appium server ready"),{result:"started",url:O}}throw f!==void 0&&n.kill(f),new Error(`The managed Appium server (${e}) did not answer on ${p} within ${D/1e3}s.
4
- Check its log: ${N}`)}async function ye(e,r=[],n=[],o){let t=new Set(n),i=new Set([...G,...r]);for(let s of i)if(!t.has(s))for(let c of await e.sessions(s)){if(!c.id)continue;if(o){let d=be(c.caps);if(d&&d!==o)continue}let u=De(c.caps);return{port:s,...u?{device:u}:{}}}return null}function be(e){let r=t=>{let i=e[t];return typeof i=="string"?i.toLowerCase():""},n=r("platformName")||r("appium:platformName");if(n.includes("ios"))return"simulator";if(n.includes("android"))return"emulator";let o=r("appium:automationName")||r("automationName");if(o.includes("xcuitest"))return"simulator";if(o.includes("uiautomator"))return"emulator"}var he=["appium:deviceName","deviceName","appium:udid","udid","appium:deviceUDID","deviceUDID"];function De(e){for(let r of he){let n=e[r];if(typeof n=="string"&&n.trim())return n}}function Ue(e={}){let r={...L(),kill:k,writeState:Ae,...e.deps};try{let n=r.readState(),o=e.owner??process.pid,t=n.filter(s=>s.owner===o&&(!e.deviceClass||s.deviceClass===e.deviceClass));for(let s of t){if(!r.alive(s.pid))continue;let c=R(r.getJson(`http://127.0.0.1:${s.port}/sessions`));for(let u of c)u.id&&r.del(`http://127.0.0.1:${s.port}/session/${u.id}`);r.kill(s.pid)}let i=new Set(t.map(s=>`${s.port}:${s.pid}`));M(()=>{r.writeState(r.readState().filter(s=>!i.has(`${s.port}:${s.pid}`)))})}catch{}}function Ae(e){try{let r=m();g(l(r),{recursive:!0}),C(r,JSON.stringify(e,null,2))}catch{}}export{Me as a,Q as b,se as c,Le as d,Se as e,Je as f,ye as g,Ue as h};
@@ -1,11 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Ve}from"./chunk-T5Y6MOLM.js";import{a as Ye}from"./chunk-OTTGS2TE.js";import{a as We}from"./chunk-YCCUBQY4.js";import{a as qe}from"./chunk-VE3SUJMA.js";import{a as be}from"./chunk-TFPPEOAK.js";import{a as Ge}from"./chunk-766WGMBU.js";import{a as He}from"./chunk-G7VQCS4J.js";import{c as Le,y as u}from"./chunk-27U4PLPX.js";import{a as ne}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
- `)}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 Q=$(ne(),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,Q.jsxs)(h,{flexDirection:"column",marginLeft:2,borderStyle:"single",paddingX:1,children:[(0,Q.jsx)(f,{color:u.muted,bold:!0,children:"reverse search"}),(0,Q.jsxs)(h,{gap:1,children:[(0,Q.jsx)(f,{color:u.dim,children:"search:"}),(0,Q.jsx)(f,{children:o}),(0,Q.jsx)(f,{color:u.orange,children:"\u2588"})]}),v.length>0&&(0,Q.jsx)(f,{children:" "}),v.map((b,d)=>(0,Q.jsx)(h,{marginLeft:2,children:(0,Q.jsxs)(f,{color:d===l?u.orange:u.dim,bold:d===l,children:[d===l?"\u25B8 ":" ",b]})},`${d}-${b}`))]})}var de=$(ne(),1);function Je({commands:n,selectedIndex:t}){return n.length===0?null:(0,de.jsx)(h,{flexDirection:"column",marginBottom:0,children:n.map((e,o)=>{let s=o===t;return(0,de.jsxs)(h,{children:[(0,de.jsx)(f,{color:s?u.orange:u.dim,children:s?"\u276F ":" "}),(0,de.jsxs)(f,{color:s?u.orange:void 0,bold:s,children:["/",e.name]}),e.args&&(0,de.jsxs)(f,{color:u.dim,children:[" ",e.args]}),(0,de.jsxs)(f,{color:u.dim,children:[" ",e.description]})]},e.name)})})}var Ze=$(we(),1);var q=$(ne(),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,C=S===0||n[U-1].kind!==d.kind;return(0,q.jsxs)(Ze.default.Fragment,{children:[C&&(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=$(ne(),1);function yt(n,t){let e=t-1;for(;e>=0&&n[e]!=="@"&&n[e]!==" "&&n[e]!==`
4
- `;)e--;return e<0||n[e]!=="@"||e>0&&n[e-1]!==" "&&n[e-1]!==`
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 Ct(n){return n.replace(/\x1b?\[200~/g,"").replace(/\x1b?\[201~/g,"").replace(/\r\n/g,`
6
- `).replace(/\r/g,`
7
- `).replace(/[\x00-\x08\x0b-\x1f\x7f]/g,"")}function Rt(n,t){let e=[],o=0;for(;o<=n.length;){let s=o;for(;s<n.length&&n[s]!==`
8
- `;)s++;if(o===s)e.push({start:o,end:o});else{let l=o;for(;l<s;){let m=Math.min(l+t,s);e.push({start:l,end:m}),l=m}}if(s>=n.length)break;o=s+1}return e}function It(n,t,e){if(n.length===0)return 0;if(t>=e.length)return n.length-1;if(e[t]===`
9
- `){for(let o=n.length-1;o>=0;o--)if(n[o].end===t)return o;return n.length-1}for(let o=0;o<n.length;o++){let s=n[o];if(s.start<=t&&t<s.end)return o}return n.length-1}function it(n,t,e,o){let s=Rt(n,e);if(s.length===0)return null;let l=It(s,t,n),m=l+o;if(m<0||m>=s.length)return null;let v=t-s[l].start,b=s[m],d=b.end-b.start;return b.start+Math.min(v,d)}function rn({onSubmit:n,onEscape:t,history:e,placeholder:o="Type an objective or /command...",commands:s,clearSeq:l,submitVerb:m,footerBindings:v,inert:b=!1,clearOnSubmit:d=!0,noHistory:S=!1,accent:U=u.orange,scenarios:F,mentionFiles:E,loadMentionItems:C,onMentionSelect:Ee,mentionHint:G,submitEmpty:V=!1}){let[c,A]=(0,D.useState)([]),[x,g]=(0,D.useState)(0),[N,Z]=(0,D.useState)("none"),[re,M]=(0,D.useState)(-1),ie=(0,D.useRef)(""),[Y,oe]=(0,D.useState)(!0),{stdout:Ie}=Ne(),se=Ie?.columns??80,[me,ee]=(0,D.useState)(0),[ce,le]=(0,D.useState)(0),[P,R]=(0,D.useState)([]),[_,B]=(0,D.useState)([]),[j,ye]=(0,D.useState)(null),$e=(0,D.useRef)(!1);(0,D.useEffect)(()=>{if(l!==void 0){if(!$e.current){$e.current=!0;return}A([]),g(0),M(-1),ie.current="",oe(!0),Z("none"),ee(0)}},[l]);let L=c.join(""),Ae=(()=>{if(N!=="none"||c.length===0)return"";if(L.startsWith("/")&&s&&L.length>=2){let r=L.slice(1).toLowerCase(),i=s.find(T=>T.name.startsWith(r)&&T.name!==r);return i?`/${i.name}`.slice(L.length):""}if(L.startsWith("/")||S)return"";let a=e.getAll();for(let r=a.length-1;r>=0;r--)if(a[r].startsWith(L)&&a[r]!==L)return a[r].slice(L.length);return""})(),he=(()=>{if(!s||!L.startsWith("/"))return[];let a=L.length>=2?L.slice(1).toLowerCase():"";return a&&s.some(r=>r.name===a)?[]:s.filter(r=>!a||r.name.startsWith(a))})(),ge=he.length>0&&L.startsWith("/"),O=!!C||!!E||!!(F&&F.length)?yt(c,x):null,Ce=O?O.query:null,z=(()=>{if(!O)return[];if(C)return _;let a=O.query.toLowerCase(),r=[];(F??[]).forEach((i,T)=>{let y=`s${T+1}`;(!a||y.includes(a)||(i.title??"").toLowerCase().includes(a))&&r.push({kind:"scenario",value:y,label:`@${y} ${i.title??i.sid??""}`.trim()})}),(F??[]).forEach((i,T)=>{let I=T+1;(i.test_cases??[]).forEach((y,W)=>{let X=`s${I}.c${W+1}`;(!a||X.includes(a)||(y.title??"").toLowerCase().includes(a))&&r.push({kind:"case",value:X,label:`@${X} ${y.title??""}`.trim()})})});for(let i of P)r.push({kind:"file",value:i,label:i});return r})(),Te=O!==null&&O.at!==j&&!ge&&N==="none"&&z.length>0,st=O!==null&&O.at!==j&&!ge&&N==="none"&&!!G;(0,D.useEffect)(()=>{if(C&&Ce!==null){let r=!1;return C(Ce).then(i=>{r||B(i)}).catch(()=>{r||B([])}),()=>{r=!0}}if(!E||Ce===null){R([]),B([]);return}let a=!1;return E(Ce).then(r=>{a||R(r)}).catch(()=>{a||R([])}),()=>{a=!0}},[Ce,E,C]),(0,D.useEffect)(()=>{ce>=z.length&&le(0)},[z.length]);let Re=z[ce]?.selectable===!1?At(z):ce,Ke=a=>{if(!O||a.selectable===!1)return;if(Ee){let T=[...c.slice(0,O.at),...c.slice(x)];A(T),g(O.at),le(0),ye(O.at),oe(T.length===0),Ee(a);return}let r=/\s/.test(a.value)?`@"${a.value}"`:`@${a.value}`,i=[...c.slice(0,O.at),...r,...c.slice(x)];A(i),g(O.at+r.length),le(0),ye(O.at),oe(!1)};if(Se((a,r)=>{if(Y&&a&&oe(!1),r.return){if(Te&&z[Re]){Ke(z[Re]);return}if(ge&&he[me]){let i=`/${he[me].name}`;S||e.push(i),n(i),A([]),g(0),Z("none"),M(-1),ie.current="",oe(!0),ee(0);return}L.trim()?(S||e.push(L.trim()),n(L.trim()),d&&(A([]),g(0),Z("none"),M(-1),ie.current="",oe(!0),ee(0))):V&&n("");return}if(r.escape){if(Te){ye(O.at);return}N!=="none"?Z("none"):c.length>0?(A([]),g(0),M(-1),ie.current=""):t?.();return}if(r.tab&&!r.shift){if(Te&&z[Re]){Ke(z[Re]);return}if(ge&&he[me]){let i=`/${he[me].name}`;A([...i]),g(i.length),ee(0);return}if(Ae){let i=L+Ae;A([...i]),g(i.length);return}return}if(r.ctrl&&a==="r"){if(S)return;Z("search");return}if(r.ctrl&&a==="a"){g(0);return}if(r.ctrl&&a==="e"){g(c.length);return}if(r.ctrl&&a==="w"){if(x===0)return;let i=x-1;for(;i>0&&c[i]===" ";)i--;for(;i>0&&c[i-1]!==" ";)i--;let T=[...c.slice(0,i),...c.slice(x)];A(T),g(i);return}if(r.ctrl&&a==="u"){A([]),g(0),M(-1),Z("none");return}if(r.meta&&a==="b"){let i=x-1;for(;i>0&&c[i]===" ";)i--;for(;i>0&&c[i-1]!==" ";)i--;g(Math.max(0,i));return}if(r.meta&&a==="f"){let i=x;for(;i<c.length&&c[i]!==" ";)i++;for(;i<c.length&&c[i]===" ";)i++;g(i);return}if(r.leftArrow){if(r.ctrl||r.shift)return;g(i=>Math.max(0,i-1));return}if(r.rightArrow){if(r.ctrl||r.shift)return;if(x>=c.length&&Ae){let i=L+Ae;A([...i]),g(i.length)}else g(i=>Math.min(c.length,i+1));return}if(r.upArrow){if(r.shift)return;if(Te){le(i=>rt(z,i,-1));return}if(ge){ee(i=>Math.max(0,i-1));return}if(N==="none"){let i=Math.max(1,se-2),T=it(c,x,i,-1);if(T!==null){g(T);return}if(S)return;let I=e.getAll();if(I.length===0)return;if(re===-1){ie.current=L,M(I.length-1);let y=I[I.length-1];A([...y]),g(y.length)}else if(re>0){let y=re-1;M(y);let W=I[y];A([...W]),g(W.length)}}return}if(r.downArrow){if(r.shift)return;if(Te){le(i=>rt(z,i,1));return}if(ge){ee(i=>Math.min(he.length-1,i+1));return}if(N==="none"){let i=Math.max(1,se-2),T=it(c,x,i,1);if(T!==null){g(T);return}if(S)return;let I=e.getAll();if(re===-1)return;if(re<I.length-1){let y=re+1;M(y);let W=I[y];A([...W]),g(W.length)}else{M(-1);let y=ie.current;A([...y]),g(y.length)}}return}if(r.backspace||r.delete){if(r.meta||r.ctrl)return;if(x>0){let i=[...c.slice(0,x-1),...c.slice(x)];A(i),g(x-1),M(-1),ee(0),ye(null),le(0)}return}if(a&&!r.ctrl&&!r.meta){let i=Ct(a);if(!i)return;let T=[...c.slice(0,x),...i,...c.slice(x)];A(T),g(x+i.length),M(-1),ee(0),ye(null),le(0)}},{isActive:!b&&N!=="search"}),nt(a=>{if(a.home){g(0);return}if(a.end){g(c.length);return}if(a.killToEnd){A(c.slice(0,x));return}if(a.arrowLeft&&(a.ctrl||a.meta)){let r=x-1;for(;r>0&&c[r]===" ";)r--;for(;r>0&&c[r-1]!==" ";)r--;g(Math.max(0,r));return}if(a.arrowRight&&(a.ctrl||a.meta)){let r=x;for(;r<c.length&&c[r]!==" ";)r++;for(;r<c.length&&c[r]===" ";)r++;g(r);return}if(a.backspace&&a.meta){if(x===0)return;let r=x-1;for(;r>0&&c[r]===" ";)r--;for(;r>0&&c[r-1]!==" ";)r--;let i=[...c.slice(0,r),...c.slice(x)];A(i),g(r);return}if(a.delete&&(a.ctrl||a.meta)){let r=x;for(;r<c.length&&c[r]===" ";)r++;for(;r<c.length&&c[r]!==" ";)r++;A([...c.slice(0,x),...c.slice(r)]);return}},{isActive:!b&&N!=="search"}),b)return(0,w.jsxs)(h,{flexDirection:"column",children:[(0,w.jsx)(f,{color:u.muted,children:"\u2500".repeat(se)}),(0,w.jsxs)(h,{children:[(0,w.jsx)(f,{color:u.muted,children:"\u276F "}),(0,w.jsx)(f,{color:u.dim,children:o})]}),(0,w.jsx)(be,{bindings:v??[{keys:"ctrl+c",label:"cancel"},{keys:"/cancel",label:"stop turn"},{keys:"ctrl+t",label:"thinking"}],suppressEscBack:!0})]});let lt=a=>{A([...a]),g(a.length),Z("none")},at=()=>{Z("none")},_e=(()=>{if(Y&&c.length===0)return null;let a=x>=c.length,r=c.slice(0,x).join(""),i,T;a?(i=" ",T=""):c[x]===`
10
- `?(i=" ",T=c.slice(x).join("")):(i=c[x],T=c.slice(x+1).join(""));let I=r+i+T+Ae,y=r.length,W=y+1,X=W+T.length,Me=Math.max(1,se-2),k=[],ae=0;for(;ae<=I.length;){let H=I.indexOf(`
11
- `,ae);if(H===-1&&(H=I.length),ae===H)k.push({type:"content",start:ae,end:ae});else{let J=ae;for(;J<H;){let ue=Math.min(J+Me,H);k.push({type:"content",start:J,end:ue}),J=ue}}if(H>=I.length)break;ae=H+1}let te=Math.max(0,k.findIndex(H=>H.start<=y&&y<=H.end)),xe;if(k.length<=Oe)xe=k;else{let J=Oe-1-4;if(te<4||te>=k.length-J)xe=[...k.slice(0,4),{type:"ellipsis",hidden:k.length-4-J},...k.slice(k.length-J)];else{let ue=Oe-2,Ue=Math.floor(ue/2),fe=te-Ue,ve=te+(ue-Ue)-1;fe<1&&(ve+=1-fe,fe=1),ve>k.length-2&&(fe-=ve-(k.length-2),ve=k.length-2),fe=Math.max(1,fe),xe=[{type:"ellipsis",hidden:fe},...k.slice(fe,ve+1),{type:"ellipsis",hidden:k.length-ve-1}]}}return{full:I,b:y,c:W,a:X,rows:xe}})();return(0,w.jsxs)(h,{flexDirection:"column",children:[N==="search"&&(0,w.jsx)(Xe,{history:e,onSelect:lt,onClose:at}),ge&&(0,w.jsx)(Je,{commands:he,selectedIndex:me}),Te&&(0,w.jsx)(tt,{items:z,selectedIndex:Re,accent:U}),st&&(0,w.jsx)(h,{children:(0,w.jsx)(f,{color:u.dim,children:G})}),(0,w.jsx)(f,{color:u.muted,children:"\u2500".repeat(se)}),_e===null?(0,w.jsxs)(h,{children:[(0,w.jsx)(f,{color:U,children:"\u276F "}),(0,w.jsx)(f,{inverse:!0,children:" "}),(0,w.jsx)(f,{color:u.dim,children:o})]}):(()=>{let a=_e.rows.findIndex(r=>r.type==="content");return(0,w.jsx)(h,{flexDirection:"column",children:_e.rows.map((r,i)=>{if(r.type==="ellipsis")return(0,w.jsx)(h,{children:(0,w.jsxs)(f,{color:u.dim,children:[" \u22EF ","(",r.hidden," more line",r.hidden===1?"":"s",")"]})},i);let{full:T,b:I,c:y,a:W}=_e,X=r.start,pe=r.end,Me=i===a,k=Me?"\u276F ":" ",ae=Me?U:u.muted,te=[(0,w.jsx)(f,{color:ae,children:k},"p")];X<Math.min(I,pe)&&te.push((0,w.jsx)(f,{children:T.slice(X,Math.min(I,pe))},"b"));let xe=Math.max(I,X),H=Math.min(y,pe);xe<H&&te.push((0,w.jsx)(f,{color:U,inverse:!0,children:T.slice(xe,H)},"c"));let J=Math.max(y,X),ue=Math.min(W,pe);return J<ue&&te.push((0,w.jsx)(f,{children:T.slice(J,ue)},"a")),pe>W&&te.push((0,w.jsx)(f,{color:u.dim,children:T.slice(Math.max(W,X),pe)},"g")),(0,w.jsx)(h,{children:te},i)})})})(),(0,w.jsx)(be,{bindings:v??[{keys:"\u2191\u2193",label:"history"},{keys:"\u21B5",label:m??"submit"},{keys:"tab",label:"complete"},{keys:"ctrl+r",label:"search"}],escBackLabel:"clear"})]})}var K=$(we(),1);var p=$(ne(),1);function _t(n){let t=[{id:"method",label:"Auth method",options:[{label:"Basic Auth",value:"basic"},{label:"OAuth (browser)",value:"oauth"}]}];return n&&t.push({id:"env",label:"Environment",options:[{label:"prod",value:"prod"},{label:"stage",value:"stage"}]}),t.push({id:"profile",label:"Profile"}),t.push({id:"credentials",label:"Credentials"}),t}function fn({devMode:n,profiles:t,onBasicLogin:e,onOAuthLogin:o,onComplete:s,onCancel:l}){let m=_t(n),[v,b]=(0,K.useState)(0),[d,S]=(0,K.useState)(0),[U,F]=(0,K.useState)({}),[E,C]=(0,K.useState)("select"),[Ee,G]=(0,K.useState)(""),[V,c]=(0,K.useState)("username"),[A,x]=(0,K.useState)(""),[g,N]=(0,K.useState)(null),[Z,re]=(0,K.useState)(null),M=m[v],ie=U.method??"basic",Y=U.env??"prod",oe=(0,K.useCallback)(()=>{let R=t.filter(_=>_.env===Y).map(_=>({label:`${_.profile} [${_.env}]`,value:_.profile}));return R.push({label:"+ Create new",value:"__new__"}),R},[t,Y]),Ie=(0,K.useCallback)(()=>{v===0?l():(b(P=>P-1),S(0),C("select"),G(""),N(null))},[v,l]),se=(0,K.useCallback)(P=>{ie==="basic"?(C("text-input"),c("username"),G("")):(C("waiting"),o(P,Y).then(()=>{re(`Logged in via OAuth as ${P} [${Y}]`),C("done")}).catch(R=>{N(R.message),C("error")}))},[ie,Y,o]),me=(0,K.useCallback)(P=>{let R=P.trim();if(R){if(V==="profileName"){let _=R;F(B=>({...B,profile:_})),se(_);return}if(V==="username"){x(R),G(""),c("accessKey"),C("text-input-masked");return}if(V==="accessKey"){let _=U.profile??"default";C("waiting"),(async()=>{try{await e(_,Y,A,R),re(`Logged in as ${_} [${Y}] via basic auth`),C("done")}catch{N("Credentials not valid. Please use valid credentials."),x(""),G(""),c("username"),C("text-input")}})()}}},[V,U.profile,Y,e,A,se]),ee=(0,K.useCallback)(P=>{G(P),g&&N(null)},[g]);Se((P,R)=>{if(E==="done"){let B=U.profile??"default";s(B,Y);return}if(E==="error"){l();return}if(E==="waiting"){R.escape&&l();return}if(E==="text-input"||E==="text-input-masked")return;if(R.escape){Ie();return}let _=M?.id==="profile"?oe():M?.options??[];if(R.upArrow){S(B=>Math.max(0,B-1));return}if(R.downArrow){S(B=>Math.min(_.length-1,B+1));return}if(R.return&&_[d]){let B=_[d];if(M.id==="profile"){if(B.value==="__new__"){C("text-input"),c("profileName"),G("");return}F(j=>({...j,profile:B.value})),b(j=>j+1),S(0),se(B.value);return}F(j=>({...j,[M.id]:B.value})),b(j=>j+1),S(0)}});let ce="Login";if(E==="done")return(0,p.jsxs)(h,{flexDirection:"column",borderStyle:"round",borderColor:u.green,paddingX:2,paddingY:1,children:[(0,p.jsxs)(f,{color:u.green,bold:!0,children:["\u2713 ",Z]}),(0,p.jsx)(h,{marginTop:1,children:(0,p.jsx)(f,{color:u.dim,children:"press any key"})})]});if(E==="error")return(0,p.jsxs)(h,{flexDirection:"column",borderStyle:"round",borderColor:u.red,paddingX:2,paddingY:1,children:[(0,p.jsx)(f,{color:u.red,bold:!0,children:"Login failed"}),(0,p.jsx)(h,{marginTop:1,children:(0,p.jsx)(f,{color:u.red,children:g})}),(0,p.jsx)(h,{marginTop:1,children:(0,p.jsx)(f,{color:u.dim,children:"press any key"})})]});if(E==="waiting")return(0,p.jsxs)(h,{flexDirection:"column",borderStyle:"round",borderColor:u.orange,paddingX:2,paddingY:1,children:[(0,p.jsxs)(f,{color:u.orange,bold:!0,children:[ce," \u203A OAuth"]}),(0,p.jsx)(h,{marginTop:1,children:(0,p.jsx)(f,{color:u.secondary,children:"Opening browser for login..."})}),(0,p.jsx)(h,{marginTop:1,children:(0,p.jsx)(f,{color:u.orange,children:"Waiting for callback \u27F3"})}),(0,p.jsx)(be,{bindings:[],escBackLabel:"cancel"})]});if(E==="text-input"||E==="text-input-masked"){let P=V==="username"?"Username":V==="accessKey"?"Access Key":"Profile name",R=V==="username"||V==="accessKey"?`${ce} \u203A Basic Auth`:`${ce} \u203A New Profile`;return(0,p.jsxs)(h,{flexDirection:"column",borderStyle:"round",borderColor:u.orange,paddingX:2,paddingY:1,children:[g&&(V==="username"||V==="accessKey")&&(0,p.jsx)(h,{marginBottom:1,children:(0,p.jsxs)(f,{color:u.red,children:["\u2717 ",g]})}),(0,p.jsx)(f,{color:u.orange,bold:!0,children:R}),V==="accessKey"&&(0,p.jsxs)(h,{marginTop:1,children:[(0,p.jsx)(f,{color:u.secondary,children:"Username: "}),(0,p.jsx)(f,{children:A})]}),(0,p.jsxs)(h,{marginTop:1,children:[(0,p.jsxs)(f,{color:u.secondary,children:[P,": "]}),(0,p.jsx)(We,{value:Ee,onChange:ee,onSubmit:me,onCancel:Ie,masked:E==="text-input-masked"})]}),(0,p.jsx)(be,{bindings:[{keys:"\u21B5",label:"confirm"}],escBackLabel:"back"})]})}let le=M?.id==="profile"?oe():M?.options??[];return(0,p.jsxs)(h,{flexDirection:"column",borderStyle:"round",borderColor:u.orange,paddingX:2,paddingY:1,children:[(0,p.jsx)(f,{color:u.orange,bold:!0,children:ce}),(0,p.jsx)(h,{marginTop:1,children:(0,p.jsxs)(f,{color:u.secondary,children:[M?.label,":"]})}),(0,p.jsx)(h,{flexDirection:"column",marginTop:1,children:le.map((P,R)=>{let _=R===d,B=_?"\u276F ":" ",j=P.value==="__new__"?u.green:_?u.orange:void 0;return(0,p.jsxs)(f,{color:j,children:[B,P.label]},P.value)})}),(0,p.jsx)(be,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}async function ot(n,t,e,o){let s=n.loadBasicAuth(t,e),l=n.loadCredentials(t,e);if(!s&&!l)return o("info","STARTUP_GATE_NO_CREDS","Profile has no credentials",{profile:t,env:e}),{status:"needs_login",profile:t,env:e};let m=He(e),v=async()=>n.loadCredentials(t,e)?.access_token??null,b=new Ye(m.controllerBaseUrl,v,s,o);o("info","STARTUP_GATE_VALIDATE","Validating credentials with controller",{profile:t,env:e,method:s?"basic":"oauth"});let d=await b.resolve(!0);if(d)return o("info","STARTUP_GATE_VALID","Credentials validated",{profile:t,env:e,username:d.username,org_id:d.org_id}),{status:"authenticated",result:{profile:t,env:e,credentials:l,basicAuth:s,tmsCreds:d,resolver:b}};if(!s&&l){let S=l.refresh_token,F=n.loadClient(t,e)?.client_id;if(S&&F){o("info","STARTUP_GATE_REFRESH","Attempting token refresh",{profile:t,env:e});try{let C=await new Ge(e).refreshToken(S,F);if(C.access_token){n.saveCredentials(t,e,{...l,...C,expires_at:Date.now()/1e3+(C.expires_in??3600)});let G=await b.resolve(!0);if(G)return o("info","STARTUP_GATE_REFRESH_OK","Token refreshed and validated",{profile:t,env:e,username:G.username}),{status:"authenticated",result:{profile:t,env:e,credentials:{...l,...C},basicAuth:null,tmsCreds:G,resolver:b}}}o("warn","STARTUP_GATE_REFRESH_INVALID","Refreshed token still invalid",{profile:t,env:e})}catch(E){o("warn","STARTUP_GATE_REFRESH_FAILED","Token refresh failed",{profile:t,env:e,error:E instanceof Error?E.message:String(E)})}}else o("info","STARTUP_GATE_NO_REFRESH","No refresh_token or client_id \u2014 login required",{profile:t,env:e})}return o("info","STARTUP_GATE_INVALID","Credentials invalid \u2014 login required",{profile:t,env:e}),{status:"needs_login",profile:t,env:e}}async function bn(n,t,e=new Ve){let o=n.listProfiles();if(t("info","STARTUP_GATE_START","Auth startup gate",{profile_count:o.length}),o.length===0)return t("info","STARTUP_GATE_NONE","No profiles found \u2014 login required"),{status:"needs_login"};if(o.length>1){let m=n.getActiveProfile(),v=n.getDefaultEnv();if(m&&o.some(d=>d.profile===m&&d.env===v)){t("info","STARTUP_GATE_TRY_ACTIVE","Multiple profiles \u2014 trying active first",{activeProfile:m,activeEnv:v});let d=await ot(n,m,v,t);if(d.status==="authenticated")return d;t("info","STARTUP_GATE_ACTIVE_FAILED","Active profile invalid \u2014 showing picker",{activeProfile:m,activeEnv:v})}return t("info","STARTUP_GATE_MULTI","Multiple profiles \u2014 picker required",{profiles:o.map(b=>`${b.profile}/${b.env}`)}),{status:"needs_pick",profiles:o}}let{profile:s,env:l}=o[0];return n.setActiveProfile(s),n.setDefaultEnv(l),qe(n,e,s,l),ot(n,s,l,t)}export{Dt as a,kt as b,rn as c,fn as d,ot as e,bn as f};
@@ -1,10 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as U,b as te,c as ne,j as x}from"./chunk-W4B5LOEX.js";import{a as M,b as J}from"./chunk-2UIHS2FH.js";import{a as B}from"./chunk-N2P4MI32.js";import{b as j,d as ee}from"./chunk-NVGBE2DR.js";import{A as Q}from"./chunk-TH47OOBV.js";import{x as q}from"./chunk-27U4PLPX.js";var w="https://integrations.lambdatest.com",g=class extends Error{constructor(e,r){super(r);this.code=e;this.name="LisError"}};function he(t){let n=t.TESTMUAI_ENV==="stage"?"stage":"prod";return`${q[n].shareApiBaseUrl}/lis/api/v1`}function ye(t){let n=t.env??process.env,e=t.auth?.TESTMUAI_BASIC_AUTH||n.TESTMUAI_BASIC_AUTH;if(e)return{authorization:`Basic ${e}`};let r=t.auth?.TESTMUAI_API_KEY||n.TESTMUAI_API_KEY;return r?{authorization:`Bearer ${r}`}:{}}function $(t){let n=t.split(`
3
- `,1)[0].replace(/[\u0000-\u001f\u007f-\u009f]/g,"");return n.length>200?`${n.slice(0,200)}\u2026`:n}function Ee(t,n,e="the issue"){return t===401||t===403?new g("LIS_AUTH","credentials rejected \u2014 run `kane-cli login` and retry"):t>=500?new g("LIS_UNAVAILABLE",`the integrations service returned an error (HTTP ${t}) \u2014 retry later`):new g("JIRA_ISSUE_UNAVAILABLE",`could not fetch ${e}: ${$(n)||`HTTP ${t}`}`)}function P(t){try{return JSON.parse(t.bytes.toString("utf8"))}catch{throw new g("LIS_UNAVAILABLE","the integrations service returned a malformed response \u2014 retry later")}}function Z(t){try{return JSON.parse(t.bytes.toString("utf8"))}catch{return{}}}function re(t){return Z(t).code}function C(t,n="the issue"){let e=Z(t);switch(e.code){case"TOKEN_EXPIRED":return new g("LIS_SETUP",`your Atlassian connection needs a resync \u2014 reconnect at ${w} and retry`);case"NOT_INSTALLED":return new g("LIS_SETUP",`no Atlassian connection for this account \u2014 create one at ${w} and retry`);case"SCOPE_MISSING":return new g("LIS_SETUP",`the connection has no Confluence access \u2014 reconnect with Confluence at ${w} and retry`);case"FORBIDDEN":return new g("LIS_FORBIDDEN",`you don't have access to ${n}`);case"NOT_FOUND":return new g("JIRA_ISSUE_UNAVAILABLE",`could not fetch ${n}: ${$(e.message??"")||"not found"}`);case"PAYLOAD_TOO_LARGE":return new g("ATTACHMENT_TOO_LARGE","the attachment exceeds the integrations service's size cap");case"INVALID_PAYLOAD":return new g("LIS_UNAVAILABLE",`the integrations service rejected the request (${$(e.message??"")||"invalid payload"}) \u2014 retry later`);case"NOT_SUPPORTED":return new g("LIS_UNAVAILABLE","the integrations service does not support this operation yet");case"UPSTREAM_ERROR":case"UPSTREAM_TIMEOUT":return new g("LIS_UNAVAILABLE","Atlassian is not responding through the integrations service \u2014 retry later");default:return Ee(t.status,e.message??"",n)}}var be=3e4,_e=5;async function N(t,n,e){let r=e.env??process.env,d=e.fetchImpl??fetch;for(let o=0;;o++){let h=new AbortController,E=setTimeout(()=>h.abort(),be);try{let s=await d(`${he(r)}${t}`,{...n,headers:{"content-type":"application/json",...ye(e),...n.headers??{}},signal:h.signal}),u=await Promise.race([s.arrayBuffer(),new Promise((c,l)=>{h.signal.addEventListener("abort",()=>l(new DOMException("aborted","AbortError")),{once:!0})})]),a={status:s.status,ok:s.ok,headers:s.headers,bytes:Buffer.from(u)};if(a.status===429){if(o>0)throw new g("LIS_RATE_LIMITED","the integrations service is busy \u2014 try again in a moment");let c=Z(a).data?.retry_after_sec,l=Math.min(Math.max(typeof c=="number"&&Number.isFinite(c)?c:1,0),_e);clearTimeout(E),await new Promise(y=>setTimeout(y,l*1e3));continue}return a}catch(s){throw s instanceof g?s:h.signal.aborted?new g("LIS_UNAVAILABLE","the integrations service did not respond within 30 seconds \u2014 retry later"):new g("LIS_UNAVAILABLE",`could not reach the integrations service (${$(s instanceof Error?s.message:String(s))}) \u2014 check your connection and retry`)}finally{clearTimeout(E)}}}function D(t){let n=t.headers.get("content-type")??"application/octet-stream";if(n.includes("json"))try{let e=JSON.parse(t.bytes.toString("utf8")),r=e.content??e.data?.content;if(typeof r=="string")return{bytes:Buffer.from(r,"base64"),mediaType:e.mime_type??e.data?.mime_type??"application/octet-stream"}}catch{}return{bytes:t.bytes,mediaType:n}}async function k(t={}){let n=await N("/jira/info",{method:"GET"},t);if(!n.ok)throw C(n);let e=P(n),r=(e.data?.SELECTED_PROJECTS??[]).map(d=>d?.key).filter(d=>typeof d=="string"&&d.length>0);return{installed:e.data?.INSTALLED==="YES",selectAll:e.data?.SELECT_ALL===!0,selectedProjects:r,capabilities:{document:e.data?.capabilities?.document===!0,comments:e.data?.capabilities?.comments===!0}}}async function F(t,n={}){let e=await N("/jira/issue?details=true",{method:"POST",body:JSON.stringify({plugin_code:"jira",issueKey:t})},n);if(!e.ok)throw C(e);let r=P(e);if(r.type==="error"||!r.data)throw new g("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue: ${$(r.message??"")||"issue not found or not accessible"}`);return r.data}var se=100,Ae=5e3,Ie=60;async function V(t,n={}){let e=[],r=new Set,d=null,o=0;for(let h=0;;h++){if(h>=Ie)throw new g("LIS_UNAVAILABLE","the integrations service kept returning comment pages without finishing \u2014 retry later");let E=await N("/jira/issue/comments",{method:"POST",body:JSON.stringify({resource_id:t,max_results:se,cursor:d,start_at:o,order_by:"created",fetch_all:!1})},n);if(!E.ok)throw C(E,"the issue's comments");let s=P(E);if(s.type==="error"||!s.data)throw new g("JIRA_ISSUE_UNAVAILABLE",`could not fetch the issue's comments: ${$(s.message??"")||"unavailable"}`);for(let R of s.data.comments??[]){let m=String(R.id);r.has(m)||(r.add(m),e.push(R))}let u=s.data.pagination;if(!u?.has_more)return e;if(e.length>=Ae)throw new g("JIRA_ISSUE_UNAVAILABLE","the issue has more comments than can be ingested \u2014 cannot build a complete identity");let a=u.next_cursor??null,c=u.next_start_at!=null,l=c?u.next_start_at:o+se;if(!(a!=null&&a!==d||a==null&&c&&l!==o))throw new g("LIS_UNAVAILABLE","the integrations service returned a non-advancing comments page \u2014 retry later");d=a,o=l}}async function G(t,n={}){let e=await N("/jira/attachment",{method:"POST",body:JSON.stringify({attachment_id:t})},n);if(!e.ok){if(re(e)===void 0){if(e.status===413)throw new g("ATTACHMENT_TOO_LARGE","the attachment exceeds the integrations service's size cap");if(e.status===404)throw new g("JIRA_NOT_CONNECTED",`Jira is not connected for this account \u2014 connect it at ${w} and retry`)}throw C(e,`attachment ${t}`)}return D(e)}var K="kane.source.jira/2";function oe(t){if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(Array.isArray(t)){let n=t.map(oe).filter(e=>e!==null);return n.length===0?null:n.join(", ")}if(t!==null&&typeof t=="object"){let n=t;for(let e of["name","value","displayName"])if(typeof n[e]=="string")return n[e];return null}return null}function ie(t,n,e){let r=[],d={},o=t.additional_fields??{};for(let a of Object.keys(o).sort()){let c=oe(o[a]);if(c===null){r.push(`field "${a}" has no stable text form \u2014 dropped from the envelope`);continue}d[a]=c}let h=[...t.attachments??[]].map(a=>({id:String(a.id),filename:a.filename??"",media_type:a.mime_type??"application/octet-stream",size:a.size??0})).sort((a,c)=>{let l=Number(a.id),y=Number(c.id);return Number.isFinite(l)&&Number.isFinite(y)?l-y:a.id<c.id?-1:a.id>c.id?1:0}),E=e.map(a=>({id:String(a.id),author:a.author?.display_name??"",body:a.body??"",created:a.created??""})).sort((a,c)=>{if(a.created!==c.created)return a.created<c.created?-1:1;let l=Number(a.id),y=Number(c.id);return Number.isFinite(l)&&Number.isFinite(y)&&l!==y?l-y:a.id<c.id?-1:a.id>c.id?1:0}),s=t.key;if(!/^[A-Za-z][A-Za-z0-9_]*-\d+$/.test(s))throw new Error(`cannot build a stable identity for issue key "${s}" \u2014 expected a PROJECT-NUMBER key`);let u={schema:K,site:n,project:s.slice(0,s.lastIndexOf("-")),issue:{id:t.id,key:s},content:{summary:t.summary??"",description:t.description??"",fields:d},attachments:h,comments:E};return{bytes:Buffer.from(JSON.stringify(u),"utf8"),envelope:u,warnings:r}}var ae=64,Le=16,we=6e6,Se=5e7,Re=12e6,ve={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},$e=new Set(["png","jpeg","webp"]);function ce(t){return async n=>{let e;try{e=JSON.parse(n.toString("utf8"))}catch{throw new Error("JIRA_ENVELOPE_SCHEMA: source bytes are not a kane jira envelope")}if(e.schema!==K)throw new Error(`JIRA_ENVELOPE_SCHEMA: unknown envelope schema "${e.schema}" \u2014 this CLI understands ${K}`);let r=[],d=new Map,o=[],h=0,E=new Map,s=[];for(let c=0;c<e.attachments.length;c++){let l=e.attachments[c],y=`i${c+1}`,R=`attachment:${l.filename}`,m=I=>`[img#${y}] ${l.filename} (${l.media_type}, ${l.size} bytes${I?"":" \u2014 not delivered"})`,p=(I,L,T)=>{r.push({ref:y,loc:R,media_type:I,...T?.blob?{blob:T.blob}:{},...T?.appearance?{appearance:T.appearance}:{},delivery:L,...T?.duplicate_of?{duplicate_of:T.duplicate_of}:{}})};if(!l.media_type.startsWith("image/")){p(l.media_type,"unsupported-vision-media-type"),s.push(m(!1));continue}let S;try{S=await t.fetchAttachment(l.id)}catch{p(l.media_type,"external-image-not-fetched"),s.push(m(!1));continue}let f=S.bytes,i=M(f),b=ve[i.format],_=j(f);if(d.set(_,f),!$e.has(i.format)){let I=i.format==="gif"||i.format==="bmp"||i.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";p(b,I,{blob:_}),s.push(m(!1));continue}if(i.width===void 0||i.height===void 0||i.width*i.height>Se){p(b,"undecodable",{blob:_}),s.push(m(!1));continue}let A;if(i.format==="png"||i.format==="jpeg"){let I=J(f,i.format);if(I===null){p(b,"undecodable",{blob:_}),s.push(m(!1));continue}A=B(I.data,{width:I.width,height:I.height,channels:I.channels})}if(i.width<ae||i.height<ae){p(b,"below-dimension-floor",{blob:_,appearance:A}),s.push(m(!1));continue}let v=E.get(_);if(v!==void 0){p(b,"duplicate",{blob:_,appearance:A,duplicate_of:v}),s.push(m(!1));continue}if(f.byteLength>we){p(b,"image-too-large",{blob:_,appearance:A}),s.push(m(!1));continue}if(h+f.byteLength>Re){p(b,"vision-byte-budget-reached",{blob:_,appearance:A}),s.push(m(!1));continue}if(o.length>=Le){p(b,"image-cap-reached",{blob:_,appearance:A}),s.push(m(!1));continue}E.set(_,y),h+=f.byteLength,o.push(y),p(b,"selected",{blob:_,appearance:A}),s.push(m(!0))}let u=[];u.push(`${e.issue.key} \xB7 ${e.site}/${e.project}`,`Summary: ${e.content.summary}`),e.content.description!==""&&u.push("",...e.content.description.split(`
4
- `));let a=Object.keys(e.content.fields);return a.length>0&&u.push("","--- fields ---",...a.map(c=>`${c}: ${e.content.fields[c]}`)),s.length>0&&u.push("","--- attachments ---",...s),e.comments.length>0&&(u.push("","--- comments ---"),e.comments.forEach((c,l)=>{l>0&&u.push(""),u.push(`[${l+1}] ${c.author} \xB7 ${c.created}`,...c.body.split(`
5
- `))})),{projection:u.join(`
6
- `)+`
7
- `,inventory:r,blobs:d,delivered:o,converter:{name:"jira-convert",version:"2",policy:"v1"}}}}var Te=/^[A-Za-z][A-Za-z0-9_]*-\d+$/;function Y(t){if(!/^https?:\/\/.+/i.test(t))return null;let n;try{n=new URL(t)}catch{return null}let e=n.pathname.split("/").filter(Boolean),r=e.lastIndexOf("browse");if(r===-1||r+1>=e.length)return null;let d=e[r+1];return Te.test(d)?{site:n.hostname,issueKey:d.toUpperCase()}:null}function H(t,n){let e=Q(t),r=e.heads.get(n);if(r==null)return null;let d=e.getNode(r)?.content?.blob;if(typeof d!="string")return null;let o=ee(t,d);if(o===null)return null;try{let h=JSON.parse(o.toString("utf8"));return typeof h.site=="string"&&h.site.length>0?h.site:null}catch{return null}}async function Ce(t,n,e,r,d){let o=Y(t);if(o===null)return(e.err??e.out)(`error: ${t}: unsupported remote URL \u2014 expected a Jira issue URL (https://<site>/browse/KEY-123)`),{code:1};let h=d?.lis??{jiraInfo:k,jiraIssue:F,jiraAttachment:G,jiraComments:V};try{let s={auth:await(d?.authEnv??(await import("./auth-HET3TBRI.js")).resolveLisAuthEnv)(),env:process.env},u=await h.jiraInfo(s);if(!u.installed)return(e.err??e.out)(`error: ${t}: no Atlassian connection for this account \u2014 create one at ${w} and retry`),{code:1};if(u.capabilities.comments===!1)return(e.err??e.out)(`error: ${t}: the connection cannot read issue comments yet \u2014 resync it at ${w} and retry`),{code:1};let a=o.issueKey.slice(0,o.issueKey.lastIndexOf("-"));if(!u.selectAll&&u.selectedProjects.length>0&&!u.selectedProjects.includes(a))return(e.err??e.out)(`error: ${t}: project ${a} is not in the integration's selected projects (${u.selectedProjects.join(", ")}) \u2014 add it at ${w}`),{code:1};let c=await h.jiraIssue(o.issueKey,s),l=await h.jiraComments(o.issueKey,s),y=o.site;if(c.host)try{y=new URL(c.host).hostname}catch{y=c.host.replace(/^https?:\/\//,"").replace(/[/:].*$/,"")}let{bytes:R,warnings:m}=ie(c,y,l),p=n??o.issueKey.toLowerCase();U(p);let S=H(r,p);if(S!==null&&S!==y)return(e.err??e.out)(`error: ${t}: source '${p}' was ingested from ${S}, but this read serves ${y} \u2014 retire it first (kane-cli context retire ${p}) or ingest under a different id with --as`),{code:1};let f=await x({contextDir:r,bytes:R,media:te,sourceId:p,label:t,confirmSameSource:e.isTTY?i=>e.confirm(`identical content already ingested as ${i} \u2014 treat as the same source?`):void 0,converters:{jira:ce({fetchAttachment:i=>h.jiraAttachment(i,s)})}});e.out(z(e.isTTY,f,o.issueKey));for(let i of m)e.out(`warning: ${i}`);for(let i of f.warnings??[])e.out(`warning: ${i}`);if(f.composite){let i=f.composite.delivered+f.composite.omitted;e.out(`${f.source_id}: jira, ${i} attachments, ${f.composite.delivered} images delivered (${f.composite.omitted} omitted)`)}return{code:0,result:{status:f.status,source_id:f.source_id,source_cid:f.cid}}}catch(E){return E instanceof g?((e.err??e.out)(`error: ${t}: ${E.message}`),{code:1}):((e.err??e.out)(`error: ${t}: ${Ne(E instanceof Error?E.message:String(E))}`),{code:1})}}function Ne(t){let n=t.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the issue's content is too large to ingest (${n[1]}; the limit is ${n[2]}) \u2014 trim the description or attachments in Jira and retry`:t.startsWith("PROJECTION_TOO_LARGE:")?"the issue's text is too large to ingest \u2014 trim the description in Jira and retry":t}var ue={name:"jira",hint:"Jira issue URLs (https://<site>/browse/KEY-123)",match:t=>Y(t)!==null,ingest:Ce,sourceIdFor:t=>{let n=Y(t);return n?n.issueKey.toLowerCase():null}};async function le(t,n={}){let e=await N("/jira/document",{method:"POST",body:JSON.stringify({resource_id:t,format:"markdown"})},n);if(!e.ok)throw C(e,"the page");let r=P(e);if(r.type==="error"||!r.data)throw new g("JIRA_ISSUE_UNAVAILABLE",`could not fetch the page: ${$(r.message??"")||"page not found or not accessible"}`);return r.data}async function de(t,n={}){let e=await N("/jira/attachment",{method:"POST",body:JSON.stringify({source:"confluence",download:t})},n);if(!e.ok)throw C(e,"the page's attachment");return{bytes:D(e).bytes}}var W="kane.source.confluence/1";function me(t,n){if(typeof t.id!="string"||t.id==="")throw new Error("cannot build a stable identity for this page \u2014 the integrations service returned no page id");let e=[...t.labels??[]].filter(o=>typeof o=="string").sort(),r=[...t.attachments??[]].map(o=>({id:String(o.id),filename:o.filename??"",media_type:o.mime_type??"application/octet-stream",size:o.size??0})).sort((o,h)=>o.id<h.id?-1:o.id>h.id?1:0),d={schema:W,site:n,page:{id:t.id},space:{key:t.space?.key??""},title:t.title??"",labels:e,content:{body:t.body??""},attachments:r};return{bytes:Buffer.from(JSON.stringify(d),"utf8"),envelope:d,warnings:[]}}var pe=64,Oe=16,Pe=6e6,je=5e7,Ue=12e6,xe={png:"image/png",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",bmp:"image/bmp",tiff:"image/tiff",emf:"image/emf",wmf:"image/wmf",unknown:"application/octet-stream"},Be=new Set(["png","jpeg","webp"]);function fe(t){let n=new Map(Object.entries(t.downloads));return async e=>{let r;try{r=JSON.parse(e.toString("utf8"))}catch{throw new Error("CONFLUENCE_ENVELOPE_SCHEMA: source bytes are not a kane confluence envelope")}if(r.schema!==W)throw new Error(`CONFLUENCE_ENVELOPE_SCHEMA: unknown envelope schema "${r.schema}" \u2014 this CLI understands ${W}`);let d=[],o=new Map,h=[],E=0,s=new Map,u=[];for(let c=0;c<r.attachments.length;c++){let l=r.attachments[c],y=`i${c+1}`,R=`attachment:${l.filename}`,m=L=>`[img#${y}] ${l.filename} (${l.media_type}, ${l.size} bytes${L?"":" \u2014 not delivered"})`,p=(L,T,O)=>{d.push({ref:y,loc:R,media_type:L,...O?.blob?{blob:O.blob}:{},...O?.appearance?{appearance:O.appearance}:{},delivery:T,...O?.duplicate_of?{duplicate_of:O.duplicate_of}:{}})};if(!l.media_type.startsWith("image/")){p(l.media_type,"unsupported-vision-media-type"),u.push(m(!1));continue}let S=n.get(l.id);if(!S){p(l.media_type,"external-image-not-fetched"),u.push(m(!1));continue}let f;try{f=await t.fetchAttachment({id:l.id,download:S})}catch{p(l.media_type,"external-image-not-fetched"),u.push(m(!1));continue}let i=f.bytes,b=M(i),_=xe[b.format],A=j(i);if(o.set(A,i),!Be.has(b.format)){let L=b.format==="gif"||b.format==="bmp"||b.format==="tiff"?"unsupported-vision-media-type":"unsupported-image-kind";p(_,L,{blob:A}),u.push(m(!1));continue}if(b.width===void 0||b.height===void 0||b.width*b.height>je){p(_,"undecodable",{blob:A}),u.push(m(!1));continue}let v;if(b.format==="png"||b.format==="jpeg"){let L=J(i,b.format);if(L===null){p(_,"undecodable",{blob:A}),u.push(m(!1));continue}v=B(L.data,{width:L.width,height:L.height,channels:L.channels})}if(b.width<pe||b.height<pe){p(_,"below-dimension-floor",{blob:A,appearance:v}),u.push(m(!1));continue}let I=s.get(A);if(I!==void 0){p(_,"duplicate",{blob:A,appearance:v,duplicate_of:I}),u.push(m(!1));continue}if(i.byteLength>Pe){p(_,"image-too-large",{blob:A,appearance:v}),u.push(m(!1));continue}if(E+i.byteLength>Ue){p(_,"vision-byte-budget-reached",{blob:A,appearance:v}),u.push(m(!1));continue}if(h.length>=Oe){p(_,"image-cap-reached",{blob:A,appearance:v}),u.push(m(!1));continue}s.set(A,y),E+=i.byteLength,h.push(y),p(_,"selected",{blob:A,appearance:v}),u.push(m(!0))}let a=[];return a.push(`${r.title} \xB7 ${r.site} \xB7 ${r.space.key}`),r.labels.length>0&&a.push(`labels: ${r.labels.join(", ")}`),r.content.body!==""&&a.push("",...r.content.body.split(`
8
- `)),u.length>0&&a.push("","--- attachments ---",...u),{projection:a.join(`
9
- `)+`
10
- `,inventory:d,blobs:o,delivered:h,converter:{name:"confluence-convert",version:"1",policy:"v1"}}}}var Me=/^[A-Za-z0-9~][A-Za-z0-9._~-]*$/;function X(t){if(!/^https?:\/\/.+/i.test(t))return null;let n;try{n=new URL(t)}catch{return null}let e=n.pathname.split("/").filter(Boolean),r=e.indexOf("wiki");if(r===-1||e[r+1]!=="spaces"||e[r+3]!=="pages")return null;let d=e[r+2],o=e[r+4];return d===void 0||o===void 0||!Me.test(d)||!/^\d+$/.test(o)?null:{site:n.hostname,spaceKey:d,pageId:o}}async function Je(t,n,e,r,d){let o=X(t);if(o===null)return(e.err??e.out)(`error: ${t}: unsupported remote URL \u2014 expected a Confluence page URL (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)`),{code:1};let h=d?.lis??{jiraInfo:k,jiraIssue:F,jiraAttachment:G,jiraComments:V},E=d?.confluence??{confluenceDocument:le,confluenceAttachment:de};try{let u={auth:await(d?.authEnv??(await import("./auth-HET3TBRI.js")).resolveLisAuthEnv)(),env:process.env},a=await h.jiraInfo(u);if(!a.installed)return(e.err??e.out)(`error: ${t}: no Atlassian connection for this account \u2014 create one at ${w} and retry`),{code:1};if(a.capabilities.document===!1)return(e.err??e.out)(`error: ${t}: the connection has no Confluence access \u2014 reconnect with Confluence at ${w} and retry`),{code:1};let c=await E.confluenceDocument(o.pageId,u),l=o.site;if(c.url)try{l=new URL(c.url).hostname}catch{}let{bytes:y,warnings:R}=me(c,l),m=n??`page-${o.pageId}`;U(m);let p=H(r,m);if(p!==null&&p!==l)return(e.err??e.out)(`error: ${t}: source '${m}' was ingested from ${p}, but this read serves ${l} \u2014 retire it first (kane-cli context retire ${m}) or ingest under a different id with --as`),{code:1};let S=Object.fromEntries((c.attachments??[]).filter(i=>typeof i.download=="string"&&i.download.length>0).map(i=>[String(i.id),i.download])),f=await x({contextDir:r,bytes:y,media:ne,sourceId:m,label:t,confirmSameSource:e.isTTY?i=>e.confirm(`identical content already ingested as ${i} \u2014 treat as the same source?`):void 0,converters:{confluence:fe({downloads:S,fetchAttachment:i=>E.confluenceAttachment(i.download,u)})}});e.out(z(e.isTTY,f,`${o.spaceKey}/${o.pageId}`));for(let i of R)e.out(`warning: ${i}`);for(let i of f.warnings??[])e.out(`warning: ${i}`);if(f.composite){let i=f.composite.delivered+f.composite.omitted;e.out(`${f.source_id}: confluence, ${i} attachments, ${f.composite.delivered} images delivered (${f.composite.omitted} omitted)`)}return{code:0,result:{status:f.status,source_id:f.source_id,source_cid:f.cid}}}catch(s){return s instanceof g?((e.err??e.out)(`error: ${t}: ${s.message}`),{code:1}):((e.err??e.out)(`error: ${t}: ${De(s instanceof Error?s.message:String(s))}`),{code:1})}}function De(t){let n=t.match(/too large — ([\d.]+ [KM]B), the limit for .+ is ([\d.]+ [KM]B) \[FILE_TOO_LARGE\]/);return n?`the page's content is too large to ingest (${n[1]}; the limit is ${n[2]}) \u2014 trim the page in Confluence and retry`:t.startsWith("PROJECTION_TOO_LARGE:")?"the page's text is too large to ingest \u2014 trim the page in Confluence and retry":t}var ge={name:"confluence",hint:"Confluence page URLs (https://<site>/wiki/spaces/<KEY>/pages/<id>/\u2026)",match:t=>X(t)!==null,ingest:Je,sourceIdFor:t=>{let n=X(t);return n?`page-${n.pageId}`:null}};function z(t,n,e){return t?n.status==="created"?`landed ${n.source_id} (${e}) \u2014 new source`:n.status==="versioned"?`landed ${n.source_id} (${e}) \u2014 new version; dependents go stale`:`${n.source_id} unchanged \u2014 already landed`:`${n.status} ${n.source_id} source ${n.cid} blob ${n.blob}`}var ke=[ue,ge];function xt(t){return/^https?:\/\/.+/i.test(t)}function Bt(t){return ke.find(n=>n.match(t))??null}export{z as a,ke as b,xt as c,Bt as d};